Skip to content

Commit

Permalink
Merge branch 'rc/v1.6.0' of https://github.com/multiversx/mx-chain-es…
Browse files Browse the repository at this point in the history
…-indexer-go into rc/v1.7.0
  • Loading branch information
sstanculeanu committed Dec 28, 2023
2 parents fff5b02 + 9e37d0c commit e3b0caf
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
"roles": {
"ESDTRoleNFTCreate": [
"erd1suhxyflu4w4pqdxmushpxzc6a3qszr89m8uswzqcvyh0mh9mzxwqdwkm0x"
],
"ESDTRoleNFTBurn": []
]
},
"properties": {
"canMint": false,
Expand Down
21 changes: 15 additions & 6 deletions process/elasticproc/logsevents/esdtPropertiesProcessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"unicode"

"github.com/multiversx/mx-chain-core-go/core"
vmcommon "github.com/multiversx/mx-chain-vm-common-go"
)

const (
Expand All @@ -23,10 +24,12 @@ func newEsdtPropertiesProcessor(pubKeyConverter core.PubkeyConverter) *esdtPrope
return &esdtPropertiesProc{
pubKeyConverter: pubKeyConverter,
rolesOperationsIdentifiers: map[string]struct{}{
core.BuiltInFunctionSetESDTRole: {},
core.BuiltInFunctionUnSetESDTRole: {},
core.BuiltInFunctionESDTNFTCreateRoleTransfer: {},
upgradePropertiesEvent: {},
core.BuiltInFunctionSetESDTRole: {},
core.BuiltInFunctionUnSetESDTRole: {},
core.BuiltInFunctionESDTNFTCreateRoleTransfer: {},
upgradePropertiesEvent: {},
vmcommon.BuiltInFunctionESDTUnSetBurnRoleForAll: {},
vmcommon.BuiltInFunctionESDTSetBurnRoleForAll: {},
},
}
}
Expand Down Expand Up @@ -67,10 +70,16 @@ func (epp *esdtPropertiesProc) processEvent(args *argsProcessEvent) argOutputPro
}
}

shouldAddRole := identifier == core.BuiltInFunctionSetESDTRole
shouldAddRole := identifier == core.BuiltInFunctionSetESDTRole || identifier == vmcommon.BuiltInFunctionESDTSetBurnRoleForAll

addrBech := epp.pubKeyConverter.SilentEncode(args.event.GetAddress(), log)
for _, roleBytes := range rolesBytes {
args.tokenRolesAndProperties.AddRole(string(topics[tokenTopicsIndex]), addrBech, string(roleBytes), shouldAddRole)
addr := addrBech
if string(roleBytes) == vmcommon.ESDTRoleBurnForAll {
addr = ""
}

args.tokenRolesAndProperties.AddRole(string(topics[tokenTopicsIndex]), addr, string(roleBytes), shouldAddRole)
}

return argOutputProcessEvent{
Expand Down
5 changes: 4 additions & 1 deletion process/elasticproc/logsevents/serialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,10 @@ func serializeRoleData(buffSlice *data.BufferSlice, rd *tokeninfo.RoleData, role
codeToExecute := `
if (ctx._source.containsKey('roles')) {
if (ctx._source.roles.containsKey(params.role)) {
ctx._source.roles.get(params.role).removeIf(p -> p.equals(params.address))
ctx._source.roles.get(params.role).removeIf(p -> p.equals(params.address));
if (ctx._source.roles.get(params.role).length == 0) {
ctx._source.roles.remove(params.role)
}
}
}
`
Expand Down

0 comments on commit e3b0caf

Please sign in to comment.