From 1a3f3048eee2d053059e91b768ed7d161a98c303 Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Wed, 4 Dec 2024 14:32:14 +0200 Subject: [PATCH] assign fields directly --- .../account_management/account_controller.py | 24 +- .../delegation/delegation_controller.py | 158 +++--------- .../smart_contract_controller.py | 24 +- .../token_management_controller.py | 232 +++++------------- .../transfers/transfers_controller.py | 27 +- 5 files changed, 117 insertions(+), 348 deletions(-) diff --git a/multiversx_sdk/account_management/account_controller.py b/multiversx_sdk/account_management/account_controller.py index 8f168291..fc023544 100644 --- a/multiversx_sdk/account_management/account_controller.py +++ b/multiversx_sdk/account_management/account_controller.py @@ -24,12 +24,8 @@ def create_transaction_for_saving_key_value(self, key_value_pairs=key_value_pairs ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -47,9 +43,7 @@ def create_transaction_for_setting_guardian(self, service_id=service_id ) - if relayer: - transaction.relayer = relayer - + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -63,9 +57,7 @@ def create_transaction_for_guarding_account(self, sender=sender.address ) - if relayer: - transaction.relayer = relayer - + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -80,12 +72,8 @@ def create_transaction_for_unguarding_account(self, sender=sender.address ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) diff --git a/multiversx_sdk/delegation/delegation_controller.py b/multiversx_sdk/delegation/delegation_controller.py index 8bf0f28e..fc3f9fe6 100644 --- a/multiversx_sdk/delegation/delegation_controller.py +++ b/multiversx_sdk/delegation/delegation_controller.py @@ -40,12 +40,8 @@ def create_transaction_for_new_delegation_contract(self, amount=amount ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -75,12 +71,8 @@ def create_transaction_for_adding_nodes(self, signed_messages=signed_messages ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -99,12 +91,8 @@ def create_transaction_for_removing_nodes(self, public_keys=public_keys ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -123,12 +111,8 @@ def create_transaction_for_staking_nodes(self, public_keys=public_keys ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -147,12 +131,8 @@ def create_transaction_for_unbonding_nodes(self, public_keys=public_keys ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -171,12 +151,8 @@ def create_transaction_for_unstaking_nodes(self, public_keys=public_keys ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -197,12 +173,8 @@ def create_transaction_for_unjailing_nodes(self, amount=amount ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -221,12 +193,8 @@ def create_transaction_for_changing_service_fee(self, service_fee=service_fee ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -245,12 +213,8 @@ def create_transaction_for_modifying_delegation_cap(self, delegation_cap=delegation_cap ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -267,15 +231,10 @@ def create_transaction_for_setting_automatic_activation(self, delegation_contract=delegation_contract ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce - transaction.signature = sender.sign( - self.tx_computer.compute_bytes_for_signing(transaction)) + transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) return transaction @@ -290,12 +249,8 @@ def create_transaction_for_unsetting_automatic_activation(self, delegation_contract=delegation_contract ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -312,12 +267,8 @@ def create_transaction_for_setting_cap_check_on_redelegate_rewards(self, delegation_contract=delegation_contract ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -334,12 +285,8 @@ def create_transaction_for_unsetting_cap_check_on_redelegate_rewards(self, delegation_contract=delegation_contract ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -362,12 +309,8 @@ def create_transaction_for_setting_metadata(self, identifier=identifier ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -386,15 +329,10 @@ def create_transaction_for_delegating(self, amount=amount ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce - transaction.signature = sender.sign( - self.tx_computer.compute_bytes_for_signing(transaction)) + transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) return transaction @@ -409,12 +347,8 @@ def create_transaction_for_claiming_rewards(self, delegation_contract=delegation_contract ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -431,12 +365,8 @@ def create_transaction_for_redelegating_rewards(self, delegation_contract=delegation_contract ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -455,12 +385,8 @@ def create_transaction_for_undelegating(self, amount=amount ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -477,12 +403,8 @@ def create_transaction_for_withdrawing(self, delegation_contract=delegation_contract ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) diff --git a/multiversx_sdk/smart_contracts/smart_contract_controller.py b/multiversx_sdk/smart_contracts/smart_contract_controller.py index e6c9d34c..6546d2e8 100644 --- a/multiversx_sdk/smart_contracts/smart_contract_controller.py +++ b/multiversx_sdk/smart_contracts/smart_contract_controller.py @@ -65,12 +65,8 @@ def create_transaction_for_deploy(self, is_payable_by_sc=is_payable_by_sc ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -111,12 +107,8 @@ def create_transaction_for_upgrade(self, is_payable_by_sc=is_payable_by_sc ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -143,12 +135,8 @@ def create_transaction_for_execute(self, token_transfers=token_transfers ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) diff --git a/multiversx_sdk/token_management/token_management_controller.py b/multiversx_sdk/token_management/token_management_controller.py index 2ae852e6..7c6e322c 100644 --- a/multiversx_sdk/token_management/token_management_controller.py +++ b/multiversx_sdk/token_management/token_management_controller.py @@ -59,12 +59,8 @@ def create_transaction_for_issuing_fungible(self, can_add_special_roles=can_add_special_roles ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -105,12 +101,8 @@ def create_transaction_for_issuing_semi_fungible(self, can_add_special_roles=can_add_special_roles ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -151,12 +143,8 @@ def create_transaction_for_issuing_non_fungible(self, can_add_special_roles=can_add_special_roles ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign( self.tx_computer.compute_bytes_for_signing(transaction)) @@ -199,12 +187,8 @@ def create_transaction_for_registering_meta_esdt(self, can_add_special_roles=can_add_special_roles ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -235,12 +219,8 @@ def create_transaction_for_registering_and_setting_roles(self, num_decimals=num_decimals, ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -264,12 +244,8 @@ def create_transaction_for_setting_burn_role_globally(self, token_identifier=token_identifier ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -294,12 +270,8 @@ def create_transaction_for_unsetting_burn_role_globally(self, token_identifier=token_identifier ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -331,12 +303,8 @@ def create_transaction_for_setting_special_role_on_fungible_token(self, add_role_esdt_transfer_role=add_role_esdt_transfer_role ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -370,12 +338,8 @@ def create_transaction_for_setting_special_role_on_semi_fungible_token(self, add_role_esdt_transfer_role=add_role_esdt_transfer_role ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -411,12 +375,8 @@ def create_transaction_for_setting_special_role_on_non_fungible_token(self, add_role_esdt_transfer_role=add_role_esdt_transfer_role ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -452,12 +412,8 @@ def create_transaction_for_creating_nft(self, uris=uris ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -481,12 +437,8 @@ def create_transaction_for_pausing(self, token_identifier=token_identifier ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -510,12 +462,8 @@ def create_transaction_for_unpausing(self, token_identifier=token_identifier ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -541,12 +489,8 @@ def create_transaction_for_freezing(self, token_identifier=token_identifier ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -572,12 +516,8 @@ def create_transaction_for_unfreezing(self, token_identifier=token_identifier ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -603,12 +543,8 @@ def create_transaction_for_wiping(self, token_identifier=token_identifier ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -634,12 +570,8 @@ def create_transaction_for_local_minting(self, supply_to_mint=supply_to_mint ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -665,12 +597,8 @@ def create_transaction_for_local_burning(self, supply_to_burn=supply_to_burn ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -698,12 +626,8 @@ def create_transaction_for_updating_attributes(self, attributes=attributes ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -731,12 +655,8 @@ def create_transaction_for_adding_quantity(self, quantity_to_add=quantity_to_add ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -764,12 +684,8 @@ def create_transaction_for_burning_quantity(self, quantity_to_burn=quantity_to_burn ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -795,12 +711,8 @@ def create_transaction_for_transferring_ownership(self, new_owner=new_owner ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -821,12 +733,8 @@ def create_transaction_for_freezing_single_nft(self, user=user ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -847,12 +755,8 @@ def create_transaction_for_unfreezing_single_nft(self, user=user ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -871,12 +775,8 @@ def create_transaction_for_changing_sft_to_meta_esdt(self, num_decimals=num_decimals ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -895,12 +795,8 @@ def create_transaction_for_transferring_nft_create_role(self, user=user ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -917,12 +813,8 @@ def create_transaction_for_stopping_nft_creation(self, token_identifier=token_identifier ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -943,12 +835,8 @@ def create_transaction_for_wiping_single_nft(self, user=user ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -967,12 +855,8 @@ def create_transction_for_adding_uris(self, uris=uris ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) diff --git a/multiversx_sdk/transfers/transfers_controller.py b/multiversx_sdk/transfers/transfers_controller.py index 4b4e5670..bb7c5550 100644 --- a/multiversx_sdk/transfers/transfers_controller.py +++ b/multiversx_sdk/transfers/transfers_controller.py @@ -29,15 +29,10 @@ def create_transaction_for_native_token_transfer(self, data=data.decode() if data else None ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce - transaction.signature = sender.sign( - self.tx_computer.compute_bytes_for_signing(transaction)) + transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) return transaction @@ -54,12 +49,8 @@ def create_transaction_for_esdt_token_transfer(self, token_transfers=token_transfers ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction)) @@ -82,12 +73,8 @@ def create_transaction_for_transfer(self, data=data ) - if guardian: - transaction.guardian = guardian - - if relayer: - transaction.relayer = relayer - + transaction.guardian = guardian + transaction.relayer = relayer transaction.nonce = nonce transaction.signature = sender.sign(self.tx_computer.compute_bytes_for_signing(transaction))