Skip to content

Commit

Permalink
update getAllRolesForTokenType
Browse files Browse the repository at this point in the history
  • Loading branch information
ssd04 committed Jul 30, 2024
1 parent c5975d8 commit 5087af1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
2 changes: 2 additions & 0 deletions integrationTests/chainSimulator/vm/esdtImprovements_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2849,6 +2849,7 @@ func TestChainSimulator_NFT_RegisterAndSetAllRolesDynamic(t *testing.T) {
[]byte(core.ESDTRoleModifyCreator),
[]byte(core.ESDTRoleModifyRoyalties),
[]byte(core.ESDTRoleSetNewURI),
[]byte(core.ESDTRoleNFTUpdate),
}

checkTokenRoles(t, result.ReturnData, expectedRoles)
Expand Down Expand Up @@ -2969,6 +2970,7 @@ func TestChainSimulator_SFT_RegisterAndSetAllRolesDynamic(t *testing.T) {
[]byte(core.ESDTRoleModifyCreator),
[]byte(core.ESDTRoleModifyRoyalties),
[]byte(core.ESDTRoleSetNewURI),
[]byte(core.ESDTRoleNFTUpdate),
}

checkTokenRoles(t, result.ReturnData, expectedRoles)
Expand Down
33 changes: 29 additions & 4 deletions vm/systemSmartContracts/esdt.go
Original file line number Diff line number Diff line change
Expand Up @@ -548,9 +548,21 @@ func (e *esdt) registerAndSetRoles(args *vmcommon.ContractCallInput) vmcommon.Re
func (e *esdt) getAllRolesForTokenType(tokenType string) ([][]byte, error) {
switch tokenType {
case core.NonFungibleESDT, core.NonFungibleESDTv2, core.DynamicNFTESDT:
nftRoles := [][]byte{[]byte(core.ESDTRoleNFTCreate), []byte(core.ESDTRoleNFTBurn), []byte(core.ESDTRoleNFTUpdateAttributes), []byte(core.ESDTRoleNFTAddURI)}
nftRoles := [][]byte{
[]byte(core.ESDTRoleNFTCreate),
[]byte(core.ESDTRoleNFTBurn),
[]byte(core.ESDTRoleNFTUpdateAttributes),
[]byte(core.ESDTRoleNFTAddURI),
}

if e.enableEpochsHandler.IsFlagEnabled(common.DynamicESDTFlag) {
nftRoles = append(nftRoles, [][]byte{[]byte(core.ESDTRoleNFTRecreate), []byte(core.ESDTRoleModifyCreator), []byte(core.ESDTRoleModifyRoyalties), []byte(core.ESDTRoleSetNewURI)}...)
nftRoles = append(nftRoles, [][]byte{
[]byte(core.ESDTRoleNFTRecreate),
[]byte(core.ESDTRoleModifyCreator),
[]byte(core.ESDTRoleModifyRoyalties),
[]byte(core.ESDTRoleSetNewURI),
[]byte(core.ESDTRoleNFTUpdate),
}...)
}

return nftRoles, nil
Expand All @@ -559,8 +571,21 @@ func (e *esdt) getAllRolesForTokenType(tokenType string) ([][]byte, error) {
case core.FungibleESDT:
return [][]byte{[]byte(core.ESDTRoleLocalMint), []byte(core.ESDTRoleLocalBurn)}, nil
case core.DynamicSFTESDT, core.DynamicMetaESDT:
dynamicRoles := [][]byte{[]byte(core.ESDTRoleNFTCreate), []byte(core.ESDTRoleNFTBurn), []byte(core.ESDTRoleNFTAddQuantity), []byte(core.ESDTRoleNFTUpdateAttributes), []byte(core.ESDTRoleNFTAddURI)}
dynamicRoles = append(dynamicRoles, [][]byte{[]byte(core.ESDTRoleNFTRecreate), []byte(core.ESDTRoleModifyCreator), []byte(core.ESDTRoleModifyRoyalties), []byte(core.ESDTRoleSetNewURI)}...)
dynamicRoles := [][]byte{
[]byte(core.ESDTRoleNFTCreate),
[]byte(core.ESDTRoleNFTBurn),
[]byte(core.ESDTRoleNFTAddQuantity),
[]byte(core.ESDTRoleNFTUpdateAttributes),
[]byte(core.ESDTRoleNFTAddURI),
}

dynamicRoles = append(dynamicRoles, [][]byte{
[]byte(core.ESDTRoleNFTRecreate),
[]byte(core.ESDTRoleModifyCreator),
[]byte(core.ESDTRoleModifyRoyalties),
[]byte(core.ESDTRoleSetNewURI),
[]byte(core.ESDTRoleNFTUpdate),
}...)

return dynamicRoles, nil
}
Expand Down

0 comments on commit 5087af1

Please sign in to comment.