Skip to content

Commit

Permalink
Merge pull request #11 from multiversx/change-directory-name-and-fixes
Browse files Browse the repository at this point in the history
Directory renaming and small fix for token management parser
  • Loading branch information
popenta authored Feb 16, 2024
2 parents f03476b + eb2c2c1 commit cf8a0d1
Show file tree
Hide file tree
Showing 21 changed files with 67 additions and 62 deletions.
19 changes: 0 additions & 19 deletions multiversx_sdk/core/transaction_factories/__init__.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from multiversx_sdk.core import Address
from multiversx_sdk.core.codec import encode_unsigned_number
from multiversx_sdk.core.transaction_factories.transactions_factory_config import \
TransactionsFactoryConfig
from multiversx_sdk.core.transaction_parsers.token_operations_outcome_parser import \
TokenOperationsOutcomeParser
from multiversx_sdk.core.transaction_parsers.transaction_on_network_wrapper import (
ContractResultsWrapper, TransactionEventTopicWrapper,
TransactionEventWrapper, TransactionLogsWrapper,
TransactionOnNetworkWrapper)
from multiversx_sdk.core.transactions_factories.transactions_factory_config import \
TransactionsFactoryConfig

frank = Address.new_from_bech32("erd1kdl46yctawygtwg2k462307dmz2v55c605737dp3zkxh04sct7asqylhyv")
grace = Address.new_from_bech32("erd1r69gk66fmedhhcg24g2c5kn2f2a5k4kvpr6jfw67dn2lyydd8cfswy6ede")
Expand Down
19 changes: 19 additions & 0 deletions multiversx_sdk/core/transactions_factories/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from multiversx_sdk.core.transactions_factories.delegation_transactions_factory import \
DelegationTransactionsFactory
from multiversx_sdk.core.transactions_factories.smart_contract_transactions_factory import \
SmartContractTransactionsFactory
from multiversx_sdk.core.transactions_factories.token_management_transactions_factory import (
RegisterAndSetAllRolesTokenType, TokenManagementTransactionsFactory)
from multiversx_sdk.core.transactions_factories.transactions_factory_config import \
TransactionsFactoryConfig
from multiversx_sdk.core.transactions_factories.transfer_transactions_factory import \
TransferTransactionsFactory

__all__ = [
"DelegationTransactionsFactory",
"TokenManagementTransactionsFactory",
"RegisterAndSetAllRolesTokenType",
"TransactionsFactoryConfig",
"SmartContractTransactionsFactory",
"TransferTransactionsFactory"
]
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from multiversx_sdk.core.interfaces import IAddress, IValidatorPublicKey
from multiversx_sdk.core.serializer import arg_to_string
from multiversx_sdk.core.transaction import Transaction
from multiversx_sdk.core.transaction_factories.transaction_builder import \
from multiversx_sdk.core.transactions_factories.transaction_builder import \
TransactionBuilder


Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from multiversx_sdk.core.address import Address
from multiversx_sdk.core.constants import DELEGATION_MANAGER_SC_ADDRESS
from multiversx_sdk.core.transaction_factories.delegation_transactions_factory import \
from multiversx_sdk.core.transactions_factories.delegation_transactions_factory import \
DelegationTransactionsFactory
from multiversx_sdk.core.transaction_factories.transactions_factory_config import \
from multiversx_sdk.core.transactions_factories.transactions_factory_config import \
TransactionsFactoryConfig
from multiversx_sdk.wallet import ValidatorSecretKey, ValidatorSigner

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,6 @@ def _prepare_inner_transaction_for_relayed_v1(self, inner_transaction: ITransact
tx["sndUserName"] = base64.b64encode(inner_transaction.sender_username.encode()).decode()

if inner_transaction.receiver_username:
tx[f"rcvUserName"] = base64.b64encode(inner_transaction.receiver_username.encode()).decode()
tx["rcvUserName"] = base64.b64encode(inner_transaction.receiver_username.encode()).decode()

return json.dumps(tx, separators=(",", ":"))
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from multiversx_sdk.core.address import Address
from multiversx_sdk.core.errors import InvalidInnerTransactionError
from multiversx_sdk.core.transaction import Transaction, TransactionComputer
from multiversx_sdk.core.transaction_factories.relayed_transactions_factory import \
from multiversx_sdk.core.transactions_factories.relayed_transactions_factory import \
RelayedTransactionsFactory
from multiversx_sdk.core.transaction_factories.transactions_factory_config import \
from multiversx_sdk.core.transactions_factories.transactions_factory_config import \
TransactionsFactoryConfig
from multiversx_sdk.testutils.wallets import load_wallets

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from multiversx_sdk.core.address import Address
from multiversx_sdk.core.constants import CONTRACT_DEPLOY_ADDRESS
from multiversx_sdk.core.tokens import Token, TokenComputer, TokenTransfer
from multiversx_sdk.core.transaction_factories.smart_contract_transactions_factory import \
from multiversx_sdk.core.transactions_factories.smart_contract_transactions_factory import \
SmartContractTransactionsFactory
from multiversx_sdk.core.transaction_factories.transactions_factory_config import \
from multiversx_sdk.core.transactions_factories.transactions_factory_config import \
TransactionsFactoryConfig


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
from multiversx_sdk.core.interfaces import IAddress, IToken, ITokenTransfer
from multiversx_sdk.core.serializer import arg_to_string, args_to_strings
from multiversx_sdk.core.transaction import Transaction
from multiversx_sdk.core.transaction_factories.token_transfers_data_builder import \
from multiversx_sdk.core.transactions_factories.token_transfers_data_builder import \
TokenTransfersDataBuilder
from multiversx_sdk.core.transaction_factories.transaction_builder import \
from multiversx_sdk.core.transactions_factories.transaction_builder import \
TransactionBuilder


Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@

import logging
from enum import Enum
from typing import List, Protocol

from multiversx_sdk.core.interfaces import IAddress
from multiversx_sdk.core.serializer import arg_to_string
from multiversx_sdk.core.transaction import Transaction
from multiversx_sdk.core.transaction_factories.transaction_builder import \
from multiversx_sdk.core.transactions_factories.transaction_builder import \
TransactionBuilder

logger = logging.getLogger(__name__)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from multiversx_sdk.core.address import Address
from multiversx_sdk.core.transaction_factories.token_management_transactions_factory import (
from multiversx_sdk.core.transactions_factories.token_management_transactions_factory import (
RegisterAndSetAllRolesTokenType, TokenManagementTransactionsFactory)
from multiversx_sdk.core.transaction_factories.transactions_factory_config import \
from multiversx_sdk.core.transactions_factories.transactions_factory_config import \
TransactionsFactoryConfig

frank = Address.new_from_bech32("erd1kdl46yctawygtwg2k462307dmz2v55c605737dp3zkxh04sct7asqylhyv")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from multiversx_sdk.core.errors import BadUsageError
from multiversx_sdk.core.interfaces import IAddress, IToken, ITokenTransfer
from multiversx_sdk.core.transaction import Transaction
from multiversx_sdk.core.transaction_factories.token_transfers_data_builder import \
from multiversx_sdk.core.transactions_factories.token_transfers_data_builder import \
TokenTransfersDataBuilder
from multiversx_sdk.core.transaction_factories.transaction_builder import \
from multiversx_sdk.core.transactions_factories.transaction_builder import \
TransactionBuilder

ADDITIONAL_GAS_FOR_ESDT_TRANSFER = 100000
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from multiversx_sdk.core.address import Address
from multiversx_sdk.core.tokens import Token, TokenComputer, TokenTransfer
from multiversx_sdk.core.transaction_factories.transactions_factory_config import \
from multiversx_sdk.core.transactions_factories.transactions_factory_config import \
TransactionsFactoryConfig
from multiversx_sdk.core.transaction_factories.transfer_transactions_factory import \
from multiversx_sdk.core.transactions_factories.transfer_transactions_factory import \
TransferTransactionsFactory


Expand Down
6 changes: 6 additions & 0 deletions multiversx_sdk/core/transactions_outcome_parsers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from multiversx_sdk.core.transactions_outcome_parsers.resources import (
SmartContractResult, TransactionEvent, TransactionLogs, TransactionOutcome)
from multiversx_sdk.core.transactions_outcome_parsers.token_management_transactions_outcome_parser import \
TokenManagementTransactionsOutcomeParser

__all__ = ["TokenManagementTransactionsOutcomeParser", "SmartContractResult", "TransactionEvent", "TransactionLogs", "TransactionOutcome"]
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def __init__(self,
address: str = "",
identifier: str = "",
topics: List[str] = [],
data: str = "") -> None:
data: bytes = b"") -> None:
self.address = address
self.identifier = identifier
self.topics = topics
Expand All @@ -25,7 +25,7 @@ class SmartContractResult:
def __init__(self,
sender: str = "",
receiver: str = "",
data: str = "",
data: bytes = b"",
logs: TransactionLogs = TransactionLogs()) -> None:
self.sender = sender
self.receiver = receiver
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
from multiversx_sdk.core.codec import decode_unsigned_number
from multiversx_sdk.core.constants import DEFAULT_HRP
from multiversx_sdk.core.errors import ParseTransactionOutcomeError
from multiversx_sdk.core.transaction_outcome_parsers.resources import (
from multiversx_sdk.core.transactions_outcome_parsers.resources import (
TransactionEvent, TransactionOutcome)
from multiversx_sdk.core.transaction_outcome_parsers.token_management_transactions_outcome_parser_types import (
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import pytest

from multiversx_sdk.core.errors import ParseTransactionOutcomeError
from multiversx_sdk.core.transaction_outcome_parsers.resources import (
from multiversx_sdk.core.transactions_outcome_parsers.resources import (
SmartContractResult, TransactionEvent, TransactionLogs, TransactionOutcome)
from multiversx_sdk.core.transaction_outcome_parsers.token_management_transactions_outcome_parser import \
from multiversx_sdk.core.transactions_outcome_parsers.token_management_transactions_outcome_parser import \
TokenManagementTransactionsOutcomeParser


Expand All @@ -18,7 +18,7 @@ def test_ensure_error(self):
address="erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzllls8a5w6u",
identifier="signalError",
topics=["Avk0jZ1kR+l9c76wQQoYcu4hvXPz+jxxTdqQeaCrbX8=", "dGlja2VyIG5hbWUgaXMgbm90IHZhbGlk"],
data="QDc1NzM2NTcyMjA2NTcyNzI2Zjcy"
data="QDc1NzM2NTcyMjA2NTcyNzI2Zjcy".encode()
)

sc_result = SmartContractResult()
Expand Down Expand Up @@ -49,7 +49,7 @@ def test_parse_issue_fungible(self):
tx_results_and_logs = TransactionOutcome([empty_result], tx_log)

outcome = self.parser.parse_issue_fungible(tx_results_and_logs)
assert outcome.identifier == identifier
assert outcome.token_identifier == identifier

def test_parse_issue_non_fungible(self):
identifier = "NFT-f01d1e"
Expand Down Expand Up @@ -91,7 +91,7 @@ def test_parse_issue_non_fungible(self):
tx_results_and_logs = TransactionOutcome([empty_result], tx_log)

outcome = self.parser.parse_issue_non_fungible(tx_results_and_logs)
assert outcome.identifier == identifier
assert outcome.token_identifier == identifier

def test_parse_issue_semi_fungible(self):
identifier = "SEMIFNG-2c6d9f"
Expand All @@ -112,7 +112,7 @@ def test_parse_issue_semi_fungible(self):
tx_results_and_logs = TransactionOutcome([empty_result], tx_log)

outcome = self.parser.parse_issue_semi_fungible(tx_results_and_logs)
assert outcome.identifier == identifier
assert outcome.token_identifier == identifier

def test_parse_register_meta_esdt(self):
identifier = "METATEST-e05d11"
Expand All @@ -133,7 +133,7 @@ def test_parse_register_meta_esdt(self):
tx_results_and_logs = TransactionOutcome([empty_result], tx_log)

outcome = self.parser.parse_register_meta_esdt(tx_results_and_logs)
assert outcome.identifier == identifier
assert outcome.token_identifier == identifier

def test_parse_register_and_set_all_roles(self):
identifier = "LMAO-d9f892"
Expand Down Expand Up @@ -168,7 +168,7 @@ def test_parse_register_and_set_all_roles(self):
sc_result = SmartContractResult(
sender="erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzllls8a5w6u",
receiver="erd18s6a06ktr2v6fgxv4ffhauxvptssnaqlds45qgsrucemlwc8rawq553rt2",
data="RVNEVFNldFJvbGVANGM0ZDQxNGYyZDY0Mzk2NjM4MzkzMkA0NTUzNDQ1NDUyNmY2YzY1NGM2ZjYzNjE2YzRkNjk2ZTc0QDQ1NTM0NDU0NTI2ZjZjNjU0YzZmNjM2MTZjNDI3NTcyNmU=",
data="RVNEVFNldFJvbGVANGM0ZDQxNGYyZDY0Mzk2NjM4MzkzMkA0NTUzNDQ1NDUyNmY2YzY1NGM2ZjYzNjE2YzRkNjk2ZTc0QDQ1NTM0NDU0NTI2ZjZjNjU0YzZmNjM2MTZjNDI3NTcyNmU=".encode(),
logs=result_log
)

Expand Down Expand Up @@ -295,7 +295,7 @@ def test_parse_pause(self):
tx_results_and_logs = TransactionOutcome([empty_result], tx_log)

outcome = self.parser.parse_pause(tx_results_and_logs)
assert outcome.identifier == identifier
assert outcome.token_identifier == identifier

def test_parse_unpause(self):
identifier = "AAA-29c4c9"
Expand All @@ -313,7 +313,7 @@ def test_parse_unpause(self):
tx_results_and_logs = TransactionOutcome([empty_result], tx_log)

outcome = self.parser.parse_unpause(tx_results_and_logs)
assert outcome.identifier == identifier
assert outcome.token_identifier == identifier

def test_parse_freeze(self):
identifier = "AAA-29c4c9"
Expand All @@ -336,7 +336,7 @@ def test_parse_freeze(self):
sc_result = SmartContractResult(
sender="erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzllls8a5w6u",
receiver="erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th",
data="RVNEVEZyZWV6ZUA0MTQxNDEyZDMyMzk2MzM0NjMzOQ==",
data="RVNEVEZyZWV6ZUA0MTQxNDEyZDMyMzk2MzM0NjMzOQ==".encode(),
logs=tx_log
)
tx_results_and_logs = TransactionOutcome([sc_result], TransactionLogs())
Expand Down Expand Up @@ -368,7 +368,7 @@ def test_parse_unfreeze(self):
sc_result = SmartContractResult(
sender="erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzllls8a5w6u",
receiver="erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th",
data="RVNEVEZyZWV6ZUA0MTQxNDEyZDMyMzk2MzM0NjMzOQ==",
data="RVNEVEZyZWV6ZUA0MTQxNDEyZDMyMzk2MzM0NjMzOQ==".encode(),
logs=tx_log
)
tx_results_and_logs = TransactionOutcome([sc_result], TransactionLogs())
Expand Down Expand Up @@ -400,7 +400,7 @@ def test_parse_wipe(self):
sc_result = SmartContractResult(
sender="erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzllls8a5w6u",
receiver="erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th",
data="RVNEVEZyZWV6ZUA0MTQxNDEyZDMyMzk2MzM0NjMzOQ==",
data="RVNEVEZyZWV6ZUA0MTQxNDEyZDMyMzk2MzM0NjMzOQ==".encode(),
logs=tx_log
)
tx_results_and_logs = TransactionOutcome([sc_result], TransactionLogs())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@

@dataclass
class IssueFungibleOutcome:
identifier: str
token_identifier: str


@dataclass
class IssueNonFungibleOutcome:
identifier: str
token_identifier: str


@dataclass
class IssueSemiFungibleOutcome:
identifier: str
token_identifier: str


@dataclass
class RegisterMetaEsdtOutcome:
identifier: str
token_identifier: str


@dataclass
Expand Down Expand Up @@ -60,12 +60,12 @@ class BurnOutcome:

@dataclass
class PauseOutcome:
identifier: str
token_identifier: str


@dataclass
class UnPauseOutcome:
identifier: str
token_identifier: str


@dataclass
Expand Down

0 comments on commit cf8a0d1

Please sign in to comment.