diff --git a/integrationtests/testdata/issueTokenAndSetRoles/token-after-unset-role.json b/integrationtests/testdata/issueTokenAndSetRoles/token-after-unset-role.json index f0fd19fd..42c45bfe 100644 --- a/integrationtests/testdata/issueTokenAndSetRoles/token-after-unset-role.json +++ b/integrationtests/testdata/issueTokenAndSetRoles/token-after-unset-role.json @@ -15,8 +15,7 @@ "roles": { "ESDTRoleNFTCreate": [ "erd1suhxyflu4w4pqdxmushpxzc6a3qszr89m8uswzqcvyh0mh9mzxwqdwkm0x" - ], - "ESDTRoleNFTBurn": [] + ] }, "properties": { "canMint": false, diff --git a/process/elasticproc/logsevents/esdtPropertiesProcessor.go b/process/elasticproc/logsevents/esdtPropertiesProcessor.go index 1b1802ec..004f9790 100644 --- a/process/elasticproc/logsevents/esdtPropertiesProcessor.go +++ b/process/elasticproc/logsevents/esdtPropertiesProcessor.go @@ -4,6 +4,7 @@ import ( "unicode" "github.com/multiversx/mx-chain-core-go/core" + vmcommon "github.com/multiversx/mx-chain-vm-common-go" ) const ( @@ -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: {}, }, } } @@ -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{ diff --git a/process/elasticproc/logsevents/serialize.go b/process/elasticproc/logsevents/serialize.go index c9db9274..488b1282 100644 --- a/process/elasticproc/logsevents/serialize.go +++ b/process/elasticproc/logsevents/serialize.go @@ -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) + } } } `