Skip to content

Commit

Permalink
adjust exports and small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
popenta committed Sep 6, 2024
1 parent bae49e0 commit 0501acf
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 81 deletions.
17 changes: 16 additions & 1 deletion multiversx_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,23 @@
TransferTransactionsFactory
from multiversx_sdk.core.transactions_outcome_parsers.delegation_transactions_outcome_parser import \
DelegationTransactionsOutcomeParser
from multiversx_sdk.core.transactions_outcome_parsers.delegation_transactions_outcome_parser_types import \
CreateNewDelegationContractOutcome
from multiversx_sdk.core.transactions_outcome_parsers.resources import (
SmartContractResult, TransactionEvent, TransactionLogs, TransactionOutcome,
find_events_by_first_topic, find_events_by_identifier)
from multiversx_sdk.core.transactions_outcome_parsers.smart_contract_transactions_outcome_parser import \
SmartContractTransactionsOutcomeParser
from multiversx_sdk.core.transactions_outcome_parsers.smart_contract_transactions_outcome_parser_types import (
DeployedSmartContract, SmartContractDeployOutcome)
from multiversx_sdk.core.transactions_outcome_parsers.token_management_transactions_outcome_parser import \
TokenManagementTransactionsOutcomeParser
from multiversx_sdk.core.transactions_outcome_parsers.token_management_transactions_outcome_parser_types import (
AddQuantityOutcome, BurnOutcome, BurnQuantityOutcome, FreezeOutcome,
IssueFungibleOutcome, IssueNonFungibleOutcome, IssueSemiFungibleOutcome,
MintOutcome, NFTCreateOutcome, PauseOutcome, RegisterAndSetAllRolesOutcome,
RegisterMetaEsdtOutcome, SetSpecialRoleOutcome, UnFreezeOutcome,
UnPauseOutcome, UpdateAttributesOutcome, WipeOutcome)
from multiversx_sdk.core.transactions_outcome_parsers.transaction_events_parser import \
TransactionEventsParser
from multiversx_sdk.facades.account import Account
Expand Down Expand Up @@ -95,5 +105,10 @@
"TransactionDecoder", "TransactionMetadata", "TransactionEventsParser",
"Account", "DevnetEntrypoint", "MainnetEntrypoint", "NetworkEntrypoint", "TestnetEntrypoint",
"AccountController", "DelegationController", "RelayedController", "SmartContractController",
"TokenManagementController", "TransfersController"
"TokenManagementController", "TransfersController",
"CreateNewDelegationContractOutcome", "SmartContractDeployOutcome", "DeployedSmartContract",
"IssueFungibleOutcome", "IssueNonFungibleOutcome", "IssueSemiFungibleOutcome", "RegisterMetaEsdtOutcome",
"RegisterAndSetAllRolesOutcome", "SetSpecialRoleOutcome", "NFTCreateOutcome", "MintOutcome", "BurnOutcome",
"PauseOutcome", "UnPauseOutcome", "FreezeOutcome", "UnFreezeOutcome", "WipeOutcome", "UpdateAttributesOutcome",
"AddQuantityOutcome", "BurnQuantityOutcome"
]
6 changes: 2 additions & 4 deletions multiversx_sdk/controllers/account_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
from multiversx_sdk.core.interfaces import IAddress
from multiversx_sdk.core.transaction import Transaction
from multiversx_sdk.core.transaction_computer import TransactionComputer
from multiversx_sdk.core.transactions_factories.account_transactions_factory import \
AccountTransactionsFactory
from multiversx_sdk.core.transactions_factories.transactions_factory_config import \
TransactionsFactoryConfig
from multiversx_sdk.core.transactions_factories import (
AccountTransactionsFactory, TransactionsFactoryConfig)


class AccountController:
Expand Down
12 changes: 4 additions & 8 deletions multiversx_sdk/controllers/delegation_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,10 @@
from multiversx_sdk.core.interfaces import IAddress, IValidatorPublicKey
from multiversx_sdk.core.transaction import Transaction
from multiversx_sdk.core.transaction_computer import TransactionComputer
from multiversx_sdk.core.transactions_factories.delegation_transactions_factory import \
DelegationTransactionsFactory
from multiversx_sdk.core.transactions_factories.transactions_factory_config import \
TransactionsFactoryConfig
from multiversx_sdk.core.transactions_outcome_parsers.delegation_transactions_outcome_parser import \
DelegationTransactionsOutcomeParser
from multiversx_sdk.core.transactions_outcome_parsers.delegation_transactions_outcome_parser_types import \
CreateNewDelegationContractOutcome
from multiversx_sdk.core.transactions_factories import (
DelegationTransactionsFactory, TransactionsFactoryConfig)
from multiversx_sdk.core.transactions_outcome_parsers.delegation_transactions_outcome_parser import (
CreateNewDelegationContractOutcome, DelegationTransactionsOutcomeParser)
from multiversx_sdk.network_providers.transaction_awaiter import \
TransactionAwaiter
from multiversx_sdk.network_providers.transactions import TransactionOnNetwork
Expand Down
6 changes: 2 additions & 4 deletions multiversx_sdk/controllers/relayed_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
from multiversx_sdk.core.interfaces import ITransaction
from multiversx_sdk.core.transaction import Transaction
from multiversx_sdk.core.transaction_computer import TransactionComputer
from multiversx_sdk.core.transactions_factories.relayed_transactions_factory import \
RelayedTransactionsFactory
from multiversx_sdk.core.transactions_factories.transactions_factory_config import \
TransactionsFactoryConfig
from multiversx_sdk.core.transactions_factories import (
RelayedTransactionsFactory, TransactionsFactoryConfig)


class RelayedController:
Expand Down
18 changes: 5 additions & 13 deletions multiversx_sdk/controllers/smart_contract_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from typing import Any, List, Optional, Protocol, Sequence, Union

from multiversx_sdk.adapters.query_runner_adapter import QueryRunnerAdapter
from multiversx_sdk.controllers.interfaces import IAccount
from multiversx_sdk.controllers.network_provider_wrapper import ProviderWrapper
from multiversx_sdk.controllers.token_management_controller import IAccount
from multiversx_sdk.converters.transactions_converter import \
TransactionsConverter
from multiversx_sdk.core.interfaces import IAddress
Expand All @@ -12,14 +12,10 @@
from multiversx_sdk.core.tokens import TokenTransfer
from multiversx_sdk.core.transaction import Transaction
from multiversx_sdk.core.transaction_computer import TransactionComputer
from multiversx_sdk.core.transactions_factories.smart_contract_transactions_factory import \
SmartContractTransactionsFactory
from multiversx_sdk.core.transactions_factories.transactions_factory_config import \
TransactionsFactoryConfig
from multiversx_sdk.core.transactions_outcome_parsers.smart_contract_transactions_outcome_parser import \
SmartContractTransactionsOutcomeParser
from multiversx_sdk.core.transactions_outcome_parsers.smart_contract_transactions_outcome_parser_types import \
SmartContractDeployOutcome
from multiversx_sdk.core.transactions_factories import (
SmartContractTransactionsFactory, TransactionsFactoryConfig)
from multiversx_sdk.core.transactions_outcome_parsers import (
SmartContractDeployOutcome, SmartContractTransactionsOutcomeParser)
from multiversx_sdk.network_providers.transaction_awaiter import \
TransactionAwaiter
from multiversx_sdk.network_providers.transactions import TransactionOnNetwork
Expand Down Expand Up @@ -52,10 +48,6 @@ def get_return_data_parts(self) -> List[bytes]:
...


class INetworkConfig(Protocol):
chain_id: str


class INetworkProvider(Protocol):
def query_contract(self, query: IQuery) -> IQueryResponse:
...
Expand Down
25 changes: 8 additions & 17 deletions multiversx_sdk/controllers/token_management_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,28 @@
from multiversx_sdk.core.interfaces import IAddress
from multiversx_sdk.core.transaction import Transaction
from multiversx_sdk.core.transaction_computer import TransactionComputer
from multiversx_sdk.core.transactions_factories.token_management_transactions_factory import (
TokenManagementTransactionsFactory, TokenType)
from multiversx_sdk.core.transactions_factories.transactions_factory_config import \
TransactionsFactoryConfig
from multiversx_sdk.core.transactions_outcome_parsers.token_management_transactions_outcome_parser import \
TokenManagementTransactionsOutcomeParser
from multiversx_sdk.core.transactions_outcome_parsers.token_management_transactions_outcome_parser_types import (
from multiversx_sdk.core.transactions_factories import (
TokenManagementTransactionsFactory, TokenType, TransactionsFactoryConfig)
from multiversx_sdk.core.transactions_outcome_parsers import (
AddQuantityOutcome, BurnOutcome, BurnQuantityOutcome, FreezeOutcome,
IssueFungibleOutcome, IssueNonFungibleOutcome, IssueSemiFungibleOutcome,
MintOutcome, NFTCreateOutcome, PauseOutcome, RegisterAndSetAllRolesOutcome,
RegisterMetaEsdtOutcome, SetSpecialRoleOutcome, UnFreezeOutcome,
UnPauseOutcome, UpdateAttributesOutcome, WipeOutcome)
RegisterMetaEsdtOutcome, SetSpecialRoleOutcome,
TokenManagementTransactionsOutcomeParser, UnFreezeOutcome, UnPauseOutcome,
UpdateAttributesOutcome, WipeOutcome)
from multiversx_sdk.network_providers.transaction_awaiter import \
TransactionAwaiter
from multiversx_sdk.network_providers.transactions import TransactionOnNetwork


class INetworkConfig(Protocol):
chain_id: str


class INetworkProvider(Protocol):
def get_network_config(self) -> INetworkConfig:
...
...


class TokenManagementController:
def __init__(self, chain_id: str, network_provider: INetworkProvider) -> None:
self.factory = TokenManagementTransactionsFactory(TransactionsFactoryConfig(chain_id))
self.provider = network_provider
self.provider_wrapper = ProviderWrapper(self.provider)
self.provider_wrapper = ProviderWrapper(network_provider)
self.transaction_awaiter = TransactionAwaiter(self.provider_wrapper)
self.tx_computer = TransactionComputer()
self.tx_converter = TransactionsConverter()
Expand Down
6 changes: 2 additions & 4 deletions multiversx_sdk/controllers/transfers_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
from multiversx_sdk.core.tokens import TokenTransfer
from multiversx_sdk.core.transaction import Transaction
from multiversx_sdk.core.transaction_computer import TransactionComputer
from multiversx_sdk.core.transactions_factories.transactions_factory_config import \
TransactionsFactoryConfig
from multiversx_sdk.core.transactions_factories.transfer_transactions_factory import \
TransferTransactionsFactory
from multiversx_sdk.core.transactions_factories import (
TransactionsFactoryConfig, TransferTransactionsFactory)


class TransfersController:
Expand Down
47 changes: 22 additions & 25 deletions multiversx_sdk/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,23 @@
TokenIdentifierParts, TokenTransfer)
from multiversx_sdk.core.transaction import Transaction
from multiversx_sdk.core.transaction_computer import TransactionComputer
from multiversx_sdk.core.transactions_factories.account_transactions_factory import \
AccountTransactionsFactory
from multiversx_sdk.core.transactions_factories.delegation_transactions_factory import \
DelegationTransactionsFactory
from multiversx_sdk.core.transactions_factories.relayed_transactions_factory import \
RelayedTransactionsFactory
from multiversx_sdk.core.transactions_factories.smart_contract_transactions_factory import \
SmartContractTransactionsFactory
from multiversx_sdk.core.transactions_factories.token_management_transactions_factory import (
TokenManagementTransactionsFactory, TokenType)
from multiversx_sdk.core.transactions_factories.transactions_factory_config import \
TransactionsFactoryConfig
from multiversx_sdk.core.transactions_factories.transfer_transactions_factory import \
TransferTransactionsFactory
from multiversx_sdk.core.transactions_outcome_parsers.delegation_transactions_outcome_parser import \
DelegationTransactionsOutcomeParser
from multiversx_sdk.core.transactions_outcome_parsers.resources import (
SmartContractResult, TransactionEvent, TransactionLogs, TransactionOutcome,
from multiversx_sdk.core.transactions_factories import (
AccountTransactionsFactory, DelegationTransactionsFactory,
RelayedTransactionsFactory, SmartContractTransactionsFactory,
TokenManagementTransactionsFactory, TokenType, TransactionsFactoryConfig,
TransferTransactionsFactory)
from multiversx_sdk.core.transactions_outcome_parsers import (
AddQuantityOutcome, BurnOutcome, BurnQuantityOutcome,
CreateNewDelegationContractOutcome, DelegationTransactionsOutcomeParser,
DeployedSmartContract, FreezeOutcome, IssueFungibleOutcome,
IssueNonFungibleOutcome, IssueSemiFungibleOutcome, MintOutcome,
NFTCreateOutcome, PauseOutcome, RegisterAndSetAllRolesOutcome,
RegisterMetaEsdtOutcome, SetSpecialRoleOutcome, SmartContractDeployOutcome,
SmartContractResult, SmartContractTransactionsOutcomeParser,
TokenManagementTransactionsOutcomeParser, TransactionEvent,
TransactionEventsParser, TransactionLogs, TransactionOutcome,
UnFreezeOutcome, UnPauseOutcome, UpdateAttributesOutcome, WipeOutcome,
find_events_by_first_topic, find_events_by_identifier)
from multiversx_sdk.core.transactions_outcome_parsers.smart_contract_transactions_outcome_parser import \
SmartContractTransactionsOutcomeParser
from multiversx_sdk.core.transactions_outcome_parsers.token_management_transactions_outcome_parser import \
TokenManagementTransactionsOutcomeParser
from multiversx_sdk.core.transactions_outcome_parsers.transaction_events_parser import \
TransactionEventsParser

__all__ = [
"AccountNonceHolder", "Address", "AddressFactory", "AddressComputer",
Expand All @@ -49,5 +41,10 @@
"SmartContractTransactionsFactory", "TransferTransactionsFactory",
"RelayedTransactionsFactory", "AccountTransactionsFactory", "DelegationTransactionsOutcomeParser",
"find_events_by_identifier", "find_events_by_first_topic", "SmartContractTransactionsOutcomeParser",
"SmartContractQueriesController", "SmartContractQuery", "SmartContractQueryResponse", "TransactionEventsParser"
"SmartContractQueriesController", "SmartContractQuery", "SmartContractQueryResponse", "TransactionEventsParser",
"CreateNewDelegationContractOutcome", "SmartContractDeployOutcome", "DeployedSmartContract",
"IssueFungibleOutcome", "IssueNonFungibleOutcome", "IssueSemiFungibleOutcome", "RegisterMetaEsdtOutcome",
"RegisterAndSetAllRolesOutcome", "SetSpecialRoleOutcome", "NFTCreateOutcome", "MintOutcome", "BurnOutcome",
"PauseOutcome", "UnPauseOutcome", "FreezeOutcome", "UnFreezeOutcome", "WipeOutcome", "UpdateAttributesOutcome",
"AddQuantityOutcome", "BurnQuantityOutcome"
]
17 changes: 16 additions & 1 deletion multiversx_sdk/core/transactions_outcome_parsers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
from multiversx_sdk.core.transactions_outcome_parsers.delegation_transactions_outcome_parser import \
DelegationTransactionsOutcomeParser
from multiversx_sdk.core.transactions_outcome_parsers.delegation_transactions_outcome_parser_types import \
CreateNewDelegationContractOutcome
from multiversx_sdk.core.transactions_outcome_parsers.resources import (
SmartContractResult, TransactionEvent, TransactionLogs, TransactionOutcome,
find_events_by_first_topic, find_events_by_identifier)
from multiversx_sdk.core.transactions_outcome_parsers.smart_contract_transactions_outcome_parser import \
SmartContractTransactionsOutcomeParser
from multiversx_sdk.core.transactions_outcome_parsers.smart_contract_transactions_outcome_parser_types import (
DeployedSmartContract, SmartContractDeployOutcome)
from multiversx_sdk.core.transactions_outcome_parsers.token_management_transactions_outcome_parser import \
TokenManagementTransactionsOutcomeParser
from multiversx_sdk.core.transactions_outcome_parsers.token_management_transactions_outcome_parser_types import (
AddQuantityOutcome, BurnOutcome, BurnQuantityOutcome, FreezeOutcome,
IssueFungibleOutcome, IssueNonFungibleOutcome, IssueSemiFungibleOutcome,
MintOutcome, NFTCreateOutcome, PauseOutcome, RegisterAndSetAllRolesOutcome,
RegisterMetaEsdtOutcome, SetSpecialRoleOutcome, UnFreezeOutcome,
UnPauseOutcome, UpdateAttributesOutcome, WipeOutcome)
from multiversx_sdk.core.transactions_outcome_parsers.transaction_events_parser import \
TransactionEventsParser

__all__ = [
"TokenManagementTransactionsOutcomeParser", "SmartContractResult", "TransactionEvent",
"TransactionLogs", "TransactionOutcome", "find_events_by_identifier", "DelegationTransactionsOutcomeParser",
"SmartContractTransactionsOutcomeParser", "find_events_by_first_topic", "TransactionEventsParser"
"SmartContractTransactionsOutcomeParser", "find_events_by_first_topic", "TransactionEventsParser",
"CreateNewDelegationContractOutcome", "SmartContractDeployOutcome", "DeployedSmartContract",
"IssueFungibleOutcome", "IssueNonFungibleOutcome", "IssueSemiFungibleOutcome", "RegisterMetaEsdtOutcome",
"RegisterAndSetAllRolesOutcome", "SetSpecialRoleOutcome", "NFTCreateOutcome", "MintOutcome", "BurnOutcome",
"PauseOutcome", "UnPauseOutcome", "FreezeOutcome", "UnFreezeOutcome", "WipeOutcome", "UpdateAttributesOutcome",
"AddQuantityOutcome", "BurnQuantityOutcome"
]
8 changes: 4 additions & 4 deletions multiversx_sdk/facades/entrypoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ def __init__(self,

self.chain_id = chain_id

def sign_transaction(self, transaction: Transaction, signer: UserSigner):
def sign_transaction(self, transaction: Transaction, account: UserSigner):
"""Signs the transactions and applies the signature on the transaction."""
tx_computer = TransactionComputer()
transaction.signature = signer.sign(tx_computer.compute_bytes_for_signing(transaction))
transaction.signature = account.sign(tx_computer.compute_bytes_for_signing(transaction))

def verify_transaction_signature(self, transaction: Transaction) -> bool:
verifier = UserVerifier.from_address(Address.new_from_bech32(transaction.sender))
Expand All @@ -70,10 +70,10 @@ def verify_transaction_signature(self, transaction: Transaction) -> bool:
signature=transaction.signature
)

def sign_message(self, message: Message, signer: UserSigner):
def sign_message(self, message: Message, account: UserSigner):
"""Signs the message and applies the signature on the message."""
message_computer = MessageComputer()
message.signature = signer.sign(message_computer.compute_bytes_for_signing(message))
message.signature = account.sign(message_computer.compute_bytes_for_signing(message))

def verify_message_signature(self, message: Message) -> bool:
if message.address is None:
Expand Down

0 comments on commit 0501acf

Please sign in to comment.