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 missing methods for token management controller #188

Merged
merged 1 commit into from
Jan 22, 2025
Merged
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
243 changes: 243 additions & 0 deletions multiversx_sdk/token_management/token_management_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,249 @@ def await_completed_burn_quantity(self, transaction_hash: Union[str, bytes]) ->
transaction = self.network_provider.await_transaction_completed(transaction_hash)
return self.parse_burn_quantity(transaction)

Copy link
Contributor

Choose a reason for hiding this comment

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

the await completed and the parse methods are missing

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

will be added in a future PR.

def create_transaction_for_modifying_royalties(
self,
sender: IAccount,
nonce: int,
token_identifier: str,
token_nonce: int,
new_royalties: int,
guardian: Optional[Address] = None,
relayer: Optional[Address] = None,
) -> Transaction:
transaction = self.factory.create_transaction_for_modifying_royalties(
sender=sender.address,
token_identifier=token_identifier,
token_nonce=token_nonce,
new_royalties=new_royalties,
)

transaction.guardian = guardian
transaction.relayer = relayer
transaction.nonce = nonce

self._set_version_and_options_for_hash_signing(sender, transaction)
transaction.signature = sender.sign_transaction(transaction)

return transaction

def create_transaction_for_setting_new_uris(
self,
sender: IAccount,
nonce: int,
token_identifier: str,
token_nonce: int,
new_uris: list[str],
guardian: Optional[Address] = None,
relayer: Optional[Address] = None,
) -> Transaction:
transaction = self.factory.create_transaction_for_setting_new_uris(
sender=sender.address,
token_identifier=token_identifier,
token_nonce=token_nonce,
new_uris=new_uris,
)

transaction.guardian = guardian
transaction.relayer = relayer
transaction.nonce = nonce

self._set_version_and_options_for_hash_signing(sender, transaction)
transaction.signature = sender.sign_transaction(transaction)

return transaction

def create_transaction_for_modifying_creator(
self,
sender: IAccount,
nonce: int,
token_identifier: str,
token_nonce: int,
guardian: Optional[Address] = None,
relayer: Optional[Address] = None,
) -> Transaction:
transaction = self.factory.create_transaction_for_modifying_creator(
sender=sender.address, token_identifier=token_identifier, token_nonce=token_nonce
)

transaction.guardian = guardian
transaction.relayer = relayer
transaction.nonce = nonce

self._set_version_and_options_for_hash_signing(sender, transaction)
transaction.signature = sender.sign_transaction(transaction)

return transaction

def create_transaction_for_updating_metadata(
self,
sender: IAccount,
nonce: int,
token_identifier: str,
token_nonce: int,
new_token_name: str,
new_royalties: int,
new_hash: str,
new_attributes: bytes,
new_uris: list[str],
guardian: Optional[Address] = None,
relayer: Optional[Address] = None,
) -> Transaction:
transaction = self.factory.create_transaction_for_updating_metadata(
sender=sender.address,
token_identifier=token_identifier,
token_nonce=token_nonce,
new_token_name=new_token_name,
new_royalties=new_royalties,
new_hash=new_hash,
new_attributes=new_attributes,
new_uris=new_uris,
)

transaction.guardian = guardian
transaction.relayer = relayer
transaction.nonce = nonce

self._set_version_and_options_for_hash_signing(sender, transaction)
transaction.signature = sender.sign_transaction(transaction)

return transaction

def create_transaction_for_nft_metadata_recreate(
self,
sender: IAccount,
nonce: int,
token_identifier: str,
token_nonce: int,
new_token_name: str,
new_royalties: int,
new_hash: str,
new_attributes: bytes,
new_uris: list[str],
guardian: Optional[Address] = None,
relayer: Optional[Address] = None,
) -> Transaction:
transaction = self.factory.create_transaction_for_nft_metadata_recreate(
sender=sender.address,
token_identifier=token_identifier,
token_nonce=token_nonce,
new_token_name=new_token_name,
new_royalties=new_royalties,
new_hash=new_hash,
new_attributes=new_attributes,
new_uris=new_uris,
)

transaction.guardian = guardian
transaction.relayer = relayer
transaction.nonce = nonce

self._set_version_and_options_for_hash_signing(sender, transaction)
transaction.signature = sender.sign_transaction(transaction)

return transaction

def create_transaction_for_changing_token_to_dynamic(
self,
sender: IAccount,
nonce: int,
token_identifier: str,
guardian: Optional[Address] = None,
relayer: Optional[Address] = None,
) -> Transaction:
"""The following token types cannot be changed to dynamic: FungibleESDT, NonFungibleESDT, NonFungibleESDTv2"""
transaction = self.factory.create_transaction_for_changing_token_to_dynamic(
sender=sender.address,
token_identifier=token_identifier,
)

transaction.guardian = guardian
transaction.relayer = relayer
transaction.nonce = nonce

self._set_version_and_options_for_hash_signing(sender, transaction)
transaction.signature = sender.sign_transaction(transaction)

return transaction

def create_transaction_for_updating_token_id(
self,
sender: IAccount,
nonce: int,
token_identifier: str,
guardian: Optional[Address] = None,
relayer: Optional[Address] = None,
) -> Transaction:
transaction = self.factory.create_transaction_for_updating_token_id(
sender=sender.address,
token_identifier=token_identifier,
)

transaction.guardian = guardian
transaction.relayer = relayer
transaction.nonce = nonce

self._set_version_and_options_for_hash_signing(sender, transaction)
transaction.signature = sender.sign_transaction(transaction)

return transaction

def create_transaction_for_registering_dynamic_token(
self,
sender: IAccount,
nonce: int,
token_name: str,
token_ticker: str,
token_type: TokenType,
denominator: Optional[int] = None,
guardian: Optional[Address] = None,
relayer: Optional[Address] = None,
) -> Transaction:
transaction = self.factory.create_transaction_for_registering_dynamic_token(
sender=sender.address,
token_name=token_name,
token_ticker=token_ticker,
token_type=token_type,
denominator=denominator,
)

transaction.guardian = guardian
transaction.relayer = relayer
transaction.nonce = nonce

self._set_version_and_options_for_hash_signing(sender, transaction)
transaction.signature = sender.sign_transaction(transaction)

return transaction

def create_transaction_for_registering_dynamic_and_setting_roles(
self,
sender: IAccount,
nonce: int,
token_name: str,
token_ticker: str,
token_type: TokenType,
denominator: Optional[int] = None,
guardian: Optional[Address] = None,
relayer: Optional[Address] = None,
) -> Transaction:
transaction = self.factory.create_transaction_for_registering_dynamic_and_setting_roles(
sender=sender.address,
token_name=token_name,
token_ticker=token_ticker,
token_type=token_type,
denominator=denominator,
)

transaction.guardian = guardian
transaction.relayer = relayer
transaction.nonce = nonce

self._set_version_and_options_for_hash_signing(sender, transaction)
transaction.signature = sender.sign_transaction(transaction)

return transaction

def create_transaction_for_transferring_ownership(
self,
sender: IAccount,
Expand Down
Loading