diff --git a/multiversx_sdk/controllers/delegation_controller.py b/multiversx_sdk/controllers/delegation_controller.py index 9bfd01f2..573c6ca8 100644 --- a/multiversx_sdk/controllers/delegation_controller.py +++ b/multiversx_sdk/controllers/delegation_controller.py @@ -1,4 +1,4 @@ -from typing import Any, List, Sequence +from typing import List, Protocol, Sequence from multiversx_sdk.controllers.interfaces import IAccount from multiversx_sdk.controllers.network_provider_wrapper import ProviderWrapper @@ -16,9 +16,13 @@ from multiversx_sdk.network_providers.transactions import TransactionOnNetwork +class INetworkProvider(Protocol): + ... + + class DelegationController: - def __init__(self, chain_id: str, network_provider: Any) -> None: - self.provider = network_provider + def __init__(self, chain_id: str, network_provider: INetworkProvider) -> None: + self.transaction_awaiter = TransactionAwaiter(ProviderWrapper(network_provider)) self.factory = DelegationTransactionsFactory(TransactionsFactoryConfig(chain_id)) self.parser = DelegationTransactionsOutcomeParser() self.tx_computer = TransactionComputer() @@ -49,9 +53,7 @@ def parse_create_new_delegation_contract(self, return self.parser.parse_create_new_delegation_contract(tx_outcome) def await_completed_create_new_delegation_contract(self, tx_hash: str) -> List[CreateNewDelegationContractOutcome]: - provider = ProviderWrapper(self.provider) - transaction_awaiter = TransactionAwaiter(provider) - transaction = transaction_awaiter.await_completed(tx_hash) + transaction = self.transaction_awaiter.await_completed(tx_hash) return self.parse_create_new_delegation_contract(transaction) def create_transaction_for_adding_nodes(self, diff --git a/multiversx_sdk/controllers/smart_contract_controller.py b/multiversx_sdk/controllers/smart_contract_controller.py index 69ba2732..a7d8db31 100644 --- a/multiversx_sdk/controllers/smart_contract_controller.py +++ b/multiversx_sdk/controllers/smart_contract_controller.py @@ -69,14 +69,14 @@ def decode_endpoint_output_parameters(self, endpoint_name: str, encoded_values: class SmartContractController: def __init__(self, chain_id: str, network_provider: INetworkProvider, abi: Optional[IAbi] = None) -> None: - self.provider = network_provider self.abi = abi self.factory = SmartContractTransactionsFactory(TransactionsFactoryConfig(chain_id)) self.parser = SmartContractTransactionsOutcomeParser() self.query_controller = SmartContractQueriesController( - query_runner=QueryRunnerAdapter(self.provider), + query_runner=QueryRunnerAdapter(network_provider), abi=self.abi ) + self.transaction_awaiter = TransactionAwaiter(ProviderWrapper(network_provider)) self.tx_computer = TransactionComputer() def create_transaction_for_deploy(self, @@ -114,9 +114,7 @@ def parse_deploy(self, transaction_on_network: TransactionOnNetwork) -> SmartCon return self.parser.parse_deploy(tx_outcome) def await_completed_deploy(self, tx_hash: str) -> SmartContractDeployOutcome: - provider = ProviderWrapper(self.provider) - transaction_awaiter = TransactionAwaiter(provider) - transaction = transaction_awaiter.await_completed(tx_hash) + transaction = self.transaction_awaiter.await_completed(tx_hash) return self.parse_deploy(transaction) def create_transaction_for_upgrade(self, diff --git a/multiversx_sdk/controllers/token_management_controller.py b/multiversx_sdk/controllers/token_management_controller.py index f8725f64..e09d516b 100644 --- a/multiversx_sdk/controllers/token_management_controller.py +++ b/multiversx_sdk/controllers/token_management_controller.py @@ -28,8 +28,7 @@ class INetworkProvider(Protocol): class TokenManagementController: def __init__(self, chain_id: str, network_provider: INetworkProvider) -> None: self.factory = TokenManagementTransactionsFactory(TransactionsFactoryConfig(chain_id)) - self.provider_wrapper = ProviderWrapper(network_provider) - self.transaction_awaiter = TransactionAwaiter(self.provider_wrapper) + self.transaction_awaiter = TransactionAwaiter(ProviderWrapper(network_provider)) self.tx_computer = TransactionComputer() self.tx_converter = TransactionsConverter() self.parser = TokenManagementTransactionsOutcomeParser() diff --git a/multiversx_sdk/facades/entrypoints.py b/multiversx_sdk/facades/entrypoints.py index e9e41bab..09524674 100644 --- a/multiversx_sdk/facades/entrypoints.py +++ b/multiversx_sdk/facades/entrypoints.py @@ -13,6 +13,7 @@ from multiversx_sdk.core.message import Message, MessageComputer from multiversx_sdk.core.transaction import Transaction from multiversx_sdk.core.transaction_computer import TransactionComputer +from multiversx_sdk.facades.account import Account from multiversx_sdk.facades.config import (DevnetEntrypointConfig, MainnetEntrypointConfig, TestnetEntrypointConfig) @@ -24,7 +25,6 @@ from multiversx_sdk.network_providers.transaction_awaiter import \ TransactionAwaiter from multiversx_sdk.network_providers.transactions import TransactionOnNetwork -from multiversx_sdk.wallet.user_signer import UserSigner from multiversx_sdk.wallet.user_verifer import UserVerifier @@ -56,7 +56,7 @@ def __init__(self, self.chain_id = chain_id - def sign_transaction(self, transaction: Transaction, account: UserSigner): + def sign_transaction(self, transaction: Transaction, account: Account): """Signs the transactions and applies the signature on the transaction.""" tx_computer = TransactionComputer() transaction.signature = account.sign(tx_computer.compute_bytes_for_signing(transaction)) @@ -70,7 +70,7 @@ def verify_transaction_signature(self, transaction: Transaction) -> bool: signature=transaction.signature ) - def sign_message(self, message: Message, account: UserSigner): + def sign_message(self, message: Message, account: Account): """Signs the message and applies the signature on the message.""" message_computer = MessageComputer() message.signature = account.sign(message_computer.compute_bytes_for_signing(message)) diff --git a/multiversx_sdk/facades/entrypoints_test.py b/multiversx_sdk/facades/entrypoints_test.py index 26ff52b4..e5b6e6cf 100644 --- a/multiversx_sdk/facades/entrypoints_test.py +++ b/multiversx_sdk/facades/entrypoints_test.py @@ -63,15 +63,8 @@ def test_contract_flow(self): ) tx_hash = self.entrypoint.send_transaction(transaction) - - retries = 10 - while retries: - time.sleep(0.5) - try: - self.entrypoint.await_completed_transaction(tx_hash) - break - except: - retries -= 1 + time.sleep(1) + self.entrypoint.await_completed_transaction(tx_hash) query_result = controller.query_contract( contract=contract_address,