Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ESDTTransferRole on fungible token #26

Merged
merged 2 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -283,14 +283,16 @@ def create_transaction_for_setting_special_role_on_fungible_token(
user: IAddress,
token_identifier: str,
add_role_local_mint: bool,
add_role_local_burn: bool
add_role_local_burn: bool,
add_role_esdt_transfer_role: bool
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Breaking change, but we can live with it (there will be a minor version anyway).

) -> Transaction:
parts: List[str] = [
"setSpecialRole",
arg_to_string(token_identifier),
user.to_hex(),
*([arg_to_string("ESDTRoleLocalMint")] if add_role_local_mint else []),
*([arg_to_string("ESDTRoleLocalBurn")] if add_role_local_burn else [])
*([arg_to_string("ESDTRoleLocalBurn")] if add_role_local_burn else []),
*([arg_to_string("ESDTTransferRole")] if add_role_esdt_transfer_role else [])
]

return TransactionBuilder(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from multiversx_sdk.core.address import Address
from multiversx_sdk.core.serializer import arg_to_string
from multiversx_sdk.core.transactions_factories.token_management_transactions_factory import (
RegisterAndSetAllRolesTokenType, TokenManagementTransactionsFactory)
from multiversx_sdk.core.transactions_factories.transactions_factory_config import \
Expand Down Expand Up @@ -151,16 +152,39 @@ def test_create_transaction_for_creating_nft():


def test_create_transaction_for_setting_special_role_on_fungible_token():
mint_role_as_hex = arg_to_string("ESDTRoleLocalMint")

transaction = factory.create_transaction_for_setting_special_role_on_fungible_token(
sender=frank,
user=grace,
token_identifier="FRANK-11ce3e",
add_role_local_mint=True,
add_role_local_burn=False,
add_role_esdt_transfer_role=False
)

assert transaction.data
assert transaction.data.decode() == f"setSpecialRole@4652414e4b2d313163653365@1e8a8b6b49de5b7be10aaa158a5a6a4abb4b56cc08f524bb5e6cd5f211ad3e13@{mint_role_as_hex}"
assert transaction.sender == frank.to_bech32()
assert transaction.value == 0


def test_set_all_roles_on_fungible_token():
mint_role_as_hex = arg_to_string("ESDTRoleLocalMint")
burn_role_as_hex = arg_to_string("ESDTRoleLocalBurn")
transfer_role_as_hex = arg_to_string("ESDTTransferRole")

transaction = factory.create_transaction_for_setting_special_role_on_fungible_token(
sender=frank,
user=grace,
token_identifier="FRANK-11ce3e",
add_role_local_mint=True,
add_role_local_burn=True,
add_role_esdt_transfer_role=True
)

assert transaction.data
assert transaction.data.decode() == "setSpecialRole@4652414e4b2d313163653365@1e8a8b6b49de5b7be10aaa158a5a6a4abb4b56cc08f524bb5e6cd5f211ad3e13@45534454526f6c654c6f63616c4d696e74"
assert transaction.data.decode() == f"setSpecialRole@4652414e4b2d313163653365@1e8a8b6b49de5b7be10aaa158a5a6a4abb4b56cc08f524bb5e6cd5f211ad3e13@{mint_role_as_hex}@{burn_role_as_hex}@{transfer_role_as_hex}"
assert transaction.sender == frank.to_bech32()
assert transaction.value == 0

Expand Down
Loading