Skip to content

Commit

Permalink
add missing roles
Browse files Browse the repository at this point in the history
  • Loading branch information
popenta committed Jul 26, 2024
1 parent 0642b04 commit 8e12e5a
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,15 @@ def create_transaction_for_setting_special_role_on_semi_fungible_token(
sender: IAddress,
user: IAddress,
token_identifier: str,
add_role_nft_create: bool,
add_role_nft_burn: bool,
add_role_nft_add_quantity: bool,
add_role_esdt_transfer_role: bool,
add_role_esdt_modify_creator: bool = False
add_role_nft_create: bool = False,
add_role_nft_burn: bool = False,
add_role_nft_add_quantity: bool = False,
add_role_esdt_transfer_role: bool = False,
add_role_nft_update: bool = False,
add_role_esdt_modify_royalties: bool = False,
add_role_esdt_set_new_uri: bool = False,
add_role_esdt_modify_creator: bool = False,
add_role_nft_recreate: bool = False,
) -> Transaction:
parts: List[str] = [
"setSpecialRole",
Expand All @@ -333,7 +337,11 @@ def create_transaction_for_setting_special_role_on_semi_fungible_token(
*([arg_to_string("ESDTRoleNFTBurn")] if add_role_nft_burn else []),
*([arg_to_string("ESDTRoleNFTAddQuantity")] if add_role_nft_add_quantity else []),
*([arg_to_string("ESDTTransferRole")] if add_role_esdt_transfer_role else []),
*([arg_to_string("ESDTRoleModifyCreator")] if add_role_esdt_modify_creator else [])
*([arg_to_string("ESDTRoleNFTUpdate")] if add_role_nft_update else []),
*([arg_to_string("ESDTRoleModifyRoyalties")] if add_role_esdt_modify_royalties else []),
*([arg_to_string("ESDTRoleSetNewURI")] if add_role_esdt_set_new_uri else []),
*([arg_to_string("ESDTRoleModifyCreator")] if add_role_esdt_modify_creator else []),
*([arg_to_string("ESDTRoleNFTRecreate")] if add_role_nft_recreate else []),
]

return TransactionBuilder(
Expand All @@ -351,15 +359,16 @@ def create_transaction_for_setting_special_role_on_non_fungible_token(
sender: IAddress,
user: IAddress,
token_identifier: str,
add_role_nft_create: bool,
add_role_nft_burn: bool,
add_role_nft_update_attributes: bool,
add_role_nft_add_uri: bool,
add_role_esdt_transfer_role: bool,
add_role_nft_create: bool = False,
add_role_nft_burn: bool = False,
add_role_nft_update_attributes: bool = False,
add_role_nft_add_uri: bool = False,
add_role_esdt_transfer_role: bool = False,
add_role_nft_update: bool = False,
add_role_esdt_modify_royalties: bool = False,
add_role_esdt_set_new_uri: bool = False,
add_role_esdt_modify_creator: bool = False,
add_role_nft_recreate: bool = False,
add_role_esdt_set_new_uri: bool = False,
add_role_esdt_modify_royalties: bool = False
) -> Transaction:
parts: List[str] = [
"setSpecialRole",
Expand All @@ -370,10 +379,11 @@ def create_transaction_for_setting_special_role_on_non_fungible_token(
*([arg_to_string("ESDTRoleNFTUpdateAttributes")] if add_role_nft_update_attributes else []),
*([arg_to_string("ESDTRoleNFTAddURI")] if add_role_nft_add_uri else []),
*([arg_to_string("ESDTTransferRole")] if add_role_esdt_transfer_role else []),
*([arg_to_string("ESDTRoleNFTUpdate")] if add_role_nft_update else []),
*([arg_to_string("ESDTRoleModifyRoyalties")] if add_role_esdt_modify_royalties else []),
*([arg_to_string("ESDTRoleSetNewURI")] if add_role_esdt_set_new_uri else []),
*([arg_to_string("ESDTRoleModifyCreator")] if add_role_esdt_modify_creator else []),
*([arg_to_string("ESDTRoleNFTRecreate")] if add_role_nft_recreate else []),
*([arg_to_string("ESDTRoleSetNewURI")] if add_role_esdt_set_new_uri else []),
*([arg_to_string("ESDTRoleModifyRoyalties")] if add_role_esdt_modify_royalties else [])
]

return TransactionBuilder(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,38 @@ def test_create_transaction_for_setting_special_role_on_non_fungible_token():
assert transaction.value == 0


def test_set_roles_on_nft():
transaction = factory.create_transaction_for_setting_special_role_on_non_fungible_token(
sender=frank,
user=grace,
token_identifier="FRANK-11ce3e",
add_role_esdt_transfer_role=True
)

assert transaction.data
assert transaction.data.decode() == "setSpecialRole@4652414e4b2d313163653365@1e8a8b6b49de5b7be10aaa158a5a6a4abb4b56cc08f524bb5e6cd5f211ad3e13@455344545472616e73666572526f6c65"
assert transaction.sender == frank.to_bech32()
assert transaction.receiver == "erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzllls8a5w6u"
assert transaction.value == 0

transaction = factory.create_transaction_for_setting_special_role_on_non_fungible_token(
sender=frank,
user=grace,
token_identifier="FRANK-11ce3e",
add_role_nft_create=True,
add_role_nft_burn=True,
add_role_nft_update_attributes=True,
add_role_nft_update=True,
add_role_esdt_modify_royalties=True,
add_role_esdt_set_new_uri=True,
add_role_esdt_modify_creator=True,
add_role_nft_recreate=True,
add_role_esdt_transfer_role=True,
add_role_nft_add_uri=True
)
assert transaction.data.decode() == "setSpecialRole@4652414e4b2d313163653365@1e8a8b6b49de5b7be10aaa158a5a6a4abb4b56cc08f524bb5e6cd5f211ad3e13@45534454526f6c654e4654437265617465@45534454526f6c654e46544275726e@45534454526f6c654e465455706461746541747472696275746573@45534454526f6c654e4654416464555249@455344545472616e73666572526f6c65@45534454526f6c654e4654557064617465@45534454526f6c654d6f64696679526f79616c74696573@45534454526f6c655365744e6577555249@45534454526f6c654d6f6469667943726561746f72@45534454526f6c654e46545265637265617465"


def test_create_transaction_for_creating_nft():
transaction = factory.create_transaction_for_creating_nft(
sender=grace,
Expand Down

0 comments on commit 8e12e5a

Please sign in to comment.