multiversx-sdk-cli 7.3.0__tar.gz → 8.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/PKG-INFO +1 -1
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/accounts.py +19 -84
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/cli.py +4 -8
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/cli_accounts.py +2 -2
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/cli_config.py +1 -2
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/cli_contracts.py +47 -50
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/cli_dns.py +10 -5
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/cli_output.py +12 -6
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/cli_password.py +3 -3
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/cli_shared.py +32 -7
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/cli_transactions.py +14 -15
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/cli_wallet.py +11 -35
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/config.py +2 -2
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/constants.py +3 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/contract_verification.py +3 -2
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/contracts.py +75 -75
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/cosign_transaction.py +5 -9
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/delegation/staking_provider.py +2 -2
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/dns.py +11 -8
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/downloader.py +3 -3
- multiversx_sdk_cli-8.0.0/multiversx_sdk_cli/guards.py +13 -0
- multiversx_sdk_cli-8.0.0/multiversx_sdk_cli/interfaces.py +47 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/localnet/genesis.py +4 -2
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/localnet/genesis_json.py +3 -1
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/projects/core.py +3 -4
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/projects/project_base.py +2 -5
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/projects/project_rust.py +28 -47
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/projects/report/do_report.py +24 -7
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/projects/report/features/twiggy_paths_check.py +6 -2
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/projects/report/report_creator.py +15 -10
- multiversx_sdk_cli-8.0.0/multiversx_sdk_cli/transactions.py +208 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/utils.py +3 -12
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/validators/core.py +6 -6
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/pyproject.toml +1 -1
- multiversx_sdk_cli-7.3.0/multiversx_sdk_cli/cli_block.py +0 -31
- multiversx_sdk_cli-7.3.0/multiversx_sdk_cli/cli_network.py +0 -52
- multiversx_sdk_cli-7.3.0/multiversx_sdk_cli/diskcache.py +0 -51
- multiversx_sdk_cli-7.3.0/multiversx_sdk_cli/guards.py +0 -26
- multiversx_sdk_cli-7.3.0/multiversx_sdk_cli/interfaces.py +0 -53
- multiversx_sdk_cli-7.3.0/multiversx_sdk_cli/transactions.py +0 -323
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/.gitignore +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/LICENSE +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/README.md +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/.vscode/settings.json +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/__init__.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/cli_data.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/cli_delegation.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/cli_deps.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/cli_ledger.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/cli_localnet.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/cli_validators.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/delegation/__init__.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/dependencies/__init__.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/dependencies/install.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/dependencies/modules.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/dependencies/resolution.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/docker.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/errors.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/ledger/__init__.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/ledger/config.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/ledger/ledger_app_handler.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/ledger/ledger_functions.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/localnet/__init__.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/localnet/config_default.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/localnet/config_general.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/localnet/config_networking.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/localnet/config_part.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/localnet/config_root.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/localnet/config_sharding.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/localnet/config_software.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/localnet/constants.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/localnet/genesis_smart_contracts_json.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/localnet/libraries.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/localnet/node.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/localnet/node_config_toml.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/localnet/nodes_setup_json.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/localnet/p2p_toml.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/localnet/seednode_p2pKey.pem +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/localnet/step_build_software.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/localnet/step_clean.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/localnet/step_config.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/localnet/step_new.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/localnet/step_prerequisites.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/localnet/step_start.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/localnet/wallets.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/myprocess.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/projects/__init__.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/projects/constants.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/projects/interfaces.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/projects/migrations.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/projects/project_clang.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/projects/project_cpp.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/projects/project_sol.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/projects/report/__init__.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/projects/report/data/__init__.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/projects/report/data/common.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/projects/report/data/extracted_feature.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/projects/report/data/folder_report.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/projects/report/data/project_report.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/projects/report/data/report.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/projects/report/data/wasm_report.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/projects/report/features/__init__.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/projects/report/features/features.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/projects/report/features/report_option.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/projects/report/features/size.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/projects/report/format/__init__.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/projects/report/format/change_type.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/projects/report/format/format_options.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/projects/shared.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/projects/templates.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/projects/templates_config.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/projects/templates_repository.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/simulation.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/ux.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/validators/__init__.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/validators/validators_file.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/version.py +0 -0
- {multiversx_sdk_cli-7.3.0 → multiversx_sdk_cli-8.0.0}/multiversx_sdk_cli/workstation.py +0 -0
|
@@ -2,11 +2,11 @@ import logging
|
|
|
2
2
|
from pathlib import Path
|
|
3
3
|
from typing import Any, Optional, Protocol
|
|
4
4
|
|
|
5
|
-
from multiversx_sdk_core import
|
|
5
|
+
from multiversx_sdk_core import Address, MessageV1
|
|
6
6
|
from multiversx_sdk_network_providers.accounts import AccountOnNetwork
|
|
7
7
|
from multiversx_sdk_wallet import UserSigner
|
|
8
8
|
|
|
9
|
-
from multiversx_sdk_cli import
|
|
9
|
+
from multiversx_sdk_cli.constants import DEFAULT_HRP
|
|
10
10
|
from multiversx_sdk_cli.interfaces import IAccount, IAddress, ITransaction
|
|
11
11
|
from multiversx_sdk_cli.ledger.config import compare_versions
|
|
12
12
|
from multiversx_sdk_cli.ledger.ledger_app_handler import \
|
|
@@ -24,9 +24,17 @@ class INetworkProvider(Protocol):
|
|
|
24
24
|
...
|
|
25
25
|
|
|
26
26
|
|
|
27
|
+
class EmptyAddress(IAddress):
|
|
28
|
+
def hex(self) -> str:
|
|
29
|
+
return ""
|
|
30
|
+
|
|
31
|
+
def bech32(self) -> str:
|
|
32
|
+
return ""
|
|
33
|
+
|
|
34
|
+
|
|
27
35
|
class AccountBase(IAccount):
|
|
28
|
-
def __init__(self, address: Any = None
|
|
29
|
-
self.address =
|
|
36
|
+
def __init__(self, address: Any = EmptyAddress()) -> None:
|
|
37
|
+
self.address = address
|
|
30
38
|
self.nonce: int = 0
|
|
31
39
|
|
|
32
40
|
def sync_nonce(self, proxy: INetworkProvider):
|
|
@@ -47,17 +55,17 @@ class Account(AccountBase):
|
|
|
47
55
|
pem_file: Optional[str] = None,
|
|
48
56
|
pem_index: int = 0,
|
|
49
57
|
key_file: str = "",
|
|
50
|
-
password: str = ""):
|
|
58
|
+
password: str = "") -> None:
|
|
51
59
|
super().__init__(address)
|
|
52
60
|
|
|
53
61
|
if pem_file:
|
|
54
62
|
pem_path = Path(pem_file).expanduser().resolve()
|
|
55
63
|
self.signer = UserSigner.from_pem_file(pem_path, pem_index)
|
|
56
|
-
self.address = Address(self.signer.get_pubkey().buffer)
|
|
64
|
+
self.address = Address(self.signer.get_pubkey().buffer, DEFAULT_HRP)
|
|
57
65
|
elif key_file and password:
|
|
58
66
|
key_file_path = Path(key_file).expanduser().resolve()
|
|
59
67
|
self.signer = UserSigner.from_wallet(key_file_path, password)
|
|
60
|
-
self.address = Address(self.signer.get_pubkey().buffer)
|
|
68
|
+
self.address = Address(self.signer.get_pubkey().buffer, DEFAULT_HRP)
|
|
61
69
|
|
|
62
70
|
def sign_transaction(self, transaction: ITransaction) -> str:
|
|
63
71
|
assert self.signer is not None
|
|
@@ -73,18 +81,18 @@ class Account(AccountBase):
|
|
|
73
81
|
|
|
74
82
|
|
|
75
83
|
class LedgerAccount(Account):
|
|
76
|
-
def __init__(self, account_index: int = 0, address_index: int = 0):
|
|
84
|
+
def __init__(self, account_index: int = 0, address_index: int = 0) -> None:
|
|
77
85
|
super().__init__()
|
|
78
86
|
self.account_index = account_index
|
|
79
87
|
self.address_index = address_index
|
|
80
|
-
self.address = Address(do_get_ledger_address(account_index=account_index, address_index=address_index))
|
|
88
|
+
self.address = Address.from_bech32(do_get_ledger_address(account_index=account_index, address_index=address_index))
|
|
81
89
|
|
|
82
90
|
def sign_transaction(self, transaction: ITransaction) -> str:
|
|
83
91
|
ledger_version = do_get_ledger_version()
|
|
84
92
|
should_use_hash_signing = compare_versions(ledger_version, SIGN_USING_HASH_VERSION) >= 0
|
|
85
93
|
if should_use_hash_signing:
|
|
86
|
-
transaction.
|
|
87
|
-
transaction.
|
|
94
|
+
transaction.version = TX_HASH_SIGN_VERSION
|
|
95
|
+
transaction.options = TX_HASH_SIGN_OPTIONS
|
|
88
96
|
|
|
89
97
|
signature = do_sign_transaction_with_ledger(
|
|
90
98
|
transaction.serialize_for_signing(),
|
|
@@ -111,76 +119,3 @@ class LedgerAccount(Account):
|
|
|
111
119
|
|
|
112
120
|
logger.debug(f"LedgerAccount.sign_message(): signature = {signature}")
|
|
113
121
|
return signature
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
class Address(IAddress):
|
|
117
|
-
HRP = "erd"
|
|
118
|
-
PUBKEY_LENGTH = 32
|
|
119
|
-
PUBKEY_STRING_LENGTH = PUBKEY_LENGTH * 2 # hex-encoded
|
|
120
|
-
BECH32_LENGTH = 62
|
|
121
|
-
_value_hex: str
|
|
122
|
-
|
|
123
|
-
def __init__(self, value: Any):
|
|
124
|
-
self._value_hex = ''
|
|
125
|
-
|
|
126
|
-
if not value:
|
|
127
|
-
return
|
|
128
|
-
|
|
129
|
-
# Copy-constructor
|
|
130
|
-
if isinstance(value, Address):
|
|
131
|
-
value = value._value_hex
|
|
132
|
-
|
|
133
|
-
# We keep a hex-encoded string as the "backing" value
|
|
134
|
-
if len(value) == Address.PUBKEY_LENGTH:
|
|
135
|
-
self._value_hex = value.hex()
|
|
136
|
-
elif len(value) == Address.PUBKEY_STRING_LENGTH:
|
|
137
|
-
self._value_hex = _as_string(value)
|
|
138
|
-
elif len(value) == Address.BECH32_LENGTH:
|
|
139
|
-
self._value_hex = _decode_bech32(value).hex()
|
|
140
|
-
else:
|
|
141
|
-
raise errors.BadAddressFormatError(value)
|
|
142
|
-
|
|
143
|
-
def hex(self) -> str:
|
|
144
|
-
self._assert_validity()
|
|
145
|
-
return self._value_hex
|
|
146
|
-
|
|
147
|
-
def bech32(self) -> str:
|
|
148
|
-
self._assert_validity()
|
|
149
|
-
pubkey = self.pubkey()
|
|
150
|
-
b32 = bech32.bech32_encode(self.HRP, bech32.convertbits(pubkey, 8, 5))
|
|
151
|
-
assert isinstance(b32, str)
|
|
152
|
-
return b32
|
|
153
|
-
|
|
154
|
-
def pubkey(self):
|
|
155
|
-
self._assert_validity()
|
|
156
|
-
pubkey = bytes.fromhex(self._value_hex)
|
|
157
|
-
return pubkey
|
|
158
|
-
|
|
159
|
-
def is_contract_address(self):
|
|
160
|
-
return self.hex().startswith(constants.SC_HEX_PUBKEY_PREFIX)
|
|
161
|
-
|
|
162
|
-
def _assert_validity(self):
|
|
163
|
-
if self._value_hex == '':
|
|
164
|
-
raise errors.EmptyAddressError()
|
|
165
|
-
|
|
166
|
-
def __repr__(self):
|
|
167
|
-
return self.bech32()
|
|
168
|
-
|
|
169
|
-
@classmethod
|
|
170
|
-
def zero(cls) -> 'Address':
|
|
171
|
-
return Address("0" * 64)
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
def _as_string(value):
|
|
175
|
-
if isinstance(value, str):
|
|
176
|
-
return value
|
|
177
|
-
return value.decode("utf-8")
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
def _decode_bech32(value):
|
|
181
|
-
bech32_string = _as_string(value)
|
|
182
|
-
hrp, value_bytes = bech32.bech32_decode(bech32_string)
|
|
183
|
-
if hrp != Address.HRP:
|
|
184
|
-
raise errors.BadAddressFormatError(value)
|
|
185
|
-
decoded_bytes = bech32.convertbits(value_bytes, 5, 8, False)
|
|
186
|
-
return bytearray(decoded_bytes)
|
|
@@ -4,8 +4,9 @@ import sys
|
|
|
4
4
|
from argparse import ArgumentParser
|
|
5
5
|
from typing import Any, List
|
|
6
6
|
|
|
7
|
+
from rich.logging import RichHandler
|
|
8
|
+
|
|
7
9
|
import multiversx_sdk_cli.cli_accounts
|
|
8
|
-
import multiversx_sdk_cli.cli_block
|
|
9
10
|
import multiversx_sdk_cli.cli_config
|
|
10
11
|
import multiversx_sdk_cli.cli_contracts
|
|
11
12
|
import multiversx_sdk_cli.cli_data
|
|
@@ -14,7 +15,6 @@ import multiversx_sdk_cli.cli_deps
|
|
|
14
15
|
import multiversx_sdk_cli.cli_dns
|
|
15
16
|
import multiversx_sdk_cli.cli_ledger
|
|
16
17
|
import multiversx_sdk_cli.cli_localnet
|
|
17
|
-
import multiversx_sdk_cli.cli_network
|
|
18
18
|
import multiversx_sdk_cli.cli_transactions
|
|
19
19
|
import multiversx_sdk_cli.cli_validators
|
|
20
20
|
import multiversx_sdk_cli.cli_wallet
|
|
@@ -38,16 +38,14 @@ def main(cli_args: List[str] = sys.argv[1:]):
|
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
def _do_main(cli_args: List[str]):
|
|
41
|
-
logging.basicConfig(level=logging.INFO)
|
|
42
|
-
|
|
43
41
|
argv_with_config_args = config.add_config_args(cli_args)
|
|
44
42
|
parser = setup_parser(argv_with_config_args)
|
|
45
43
|
args = parser.parse_args(argv_with_config_args)
|
|
46
44
|
|
|
47
45
|
if args.verbose:
|
|
48
|
-
logging.basicConfig(level=
|
|
46
|
+
logging.basicConfig(level="DEBUG", force=True, format='%(name)s: %(message)s', handlers=[RichHandler(show_time=False, rich_tracebacks=True)])
|
|
49
47
|
else:
|
|
50
|
-
logging.basicConfig(level=
|
|
48
|
+
logging.basicConfig(level="INFO", format='%(name)s: %(message)s', handlers=[RichHandler(show_time=False, rich_tracebacks=True)])
|
|
51
49
|
|
|
52
50
|
if not hasattr(args, "func"):
|
|
53
51
|
parser.print_help()
|
|
@@ -87,10 +85,8 @@ https://docs.multiversx.com/sdk-and-tools/mxpy.
|
|
|
87
85
|
commands.append(multiversx_sdk_cli.cli_accounts.setup_parser(subparsers))
|
|
88
86
|
commands.append(multiversx_sdk_cli.cli_ledger.setup_parser(subparsers))
|
|
89
87
|
commands.append(multiversx_sdk_cli.cli_wallet.setup_parser(args, subparsers))
|
|
90
|
-
commands.append(multiversx_sdk_cli.cli_network.setup_parser(subparsers))
|
|
91
88
|
commands.append(multiversx_sdk_cli.cli_deps.setup_parser(subparsers))
|
|
92
89
|
commands.append(multiversx_sdk_cli.cli_config.setup_parser(subparsers))
|
|
93
|
-
commands.append(multiversx_sdk_cli.cli_block.setup_parser(subparsers))
|
|
94
90
|
commands.append(multiversx_sdk_cli.cli_localnet.setup_parser(args, subparsers))
|
|
95
91
|
commands.append(multiversx_sdk_cli.cli_data.setup_parser(subparsers))
|
|
96
92
|
commands.append(multiversx_sdk_cli.cli_delegation.setup_parser(args, subparsers))
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
from typing import Any
|
|
3
3
|
|
|
4
|
+
from multiversx_sdk_core import Address
|
|
4
5
|
from multiversx_sdk_network_providers.proxy_network_provider import \
|
|
5
6
|
ProxyNetworkProvider
|
|
6
7
|
|
|
7
8
|
from multiversx_sdk_cli import cli_shared, utils
|
|
8
|
-
from multiversx_sdk_cli.accounts import Address
|
|
9
9
|
|
|
10
10
|
logger = logging.getLogger("cli.accounts")
|
|
11
11
|
|
|
@@ -36,7 +36,7 @@ def get_account(args: Any):
|
|
|
36
36
|
proxy_url = args.proxy
|
|
37
37
|
address = args.address
|
|
38
38
|
proxy = ProxyNetworkProvider(proxy_url)
|
|
39
|
-
account = proxy.get_account(Address(address))
|
|
39
|
+
account = proxy.get_account(Address.from_bech32(address))
|
|
40
40
|
|
|
41
41
|
if args.balance:
|
|
42
42
|
print(account.balance)
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
import os
|
|
3
3
|
from pathlib import Path
|
|
4
|
-
from typing import Any,
|
|
4
|
+
from typing import Any, List
|
|
5
5
|
|
|
6
|
+
from multiversx_sdk_core import Address, Transaction
|
|
6
7
|
from multiversx_sdk_network_providers.proxy_network_provider import \
|
|
7
8
|
ProxyNetworkProvider
|
|
8
9
|
|
|
9
10
|
from multiversx_sdk_cli import cli_shared, errors, projects, utils
|
|
10
|
-
from multiversx_sdk_cli.accounts import Account,
|
|
11
|
+
from multiversx_sdk_cli.accounts import Account, LedgerAccount
|
|
11
12
|
from multiversx_sdk_cli.cli_output import CLIOutputBuilder
|
|
12
13
|
from multiversx_sdk_cli.cli_password import load_password
|
|
13
14
|
from multiversx_sdk_cli.contract_verification import \
|
|
@@ -17,7 +18,6 @@ from multiversx_sdk_cli.cosign_transaction import cosign_transaction
|
|
|
17
18
|
from multiversx_sdk_cli.docker import is_docker_installed, run_docker
|
|
18
19
|
from multiversx_sdk_cli.errors import DockerMissingError, NoWalletProvided
|
|
19
20
|
from multiversx_sdk_cli.projects.core import get_project_paths_recursively
|
|
20
|
-
from multiversx_sdk_cli.transactions import Transaction
|
|
21
21
|
|
|
22
22
|
logger = logging.getLogger("cli.contracts")
|
|
23
23
|
|
|
@@ -40,14 +40,11 @@ def setup_parser(args: List[str], subparsers: Any) -> Any:
|
|
|
40
40
|
|
|
41
41
|
sub = cli_shared.add_command_subparser(subparsers, "contract", "build",
|
|
42
42
|
"Build a Smart Contract project using the appropriate buildchain.")
|
|
43
|
-
|
|
44
|
-
_add_recursive_arg(sub)
|
|
45
|
-
_add_build_options_args(sub)
|
|
43
|
+
_add_build_options_sc_meta(sub)
|
|
46
44
|
sub.set_defaults(func=build)
|
|
47
45
|
|
|
48
46
|
sub = cli_shared.add_command_subparser(subparsers, "contract", "clean", "Clean a Smart Contract project.")
|
|
49
|
-
|
|
50
|
-
_add_recursive_arg(sub)
|
|
47
|
+
sub.add_argument("--path", default=os.getcwd(), help="the project directory (default: current directory)")
|
|
51
48
|
sub.set_defaults(func=clean)
|
|
52
49
|
|
|
53
50
|
sub = cli_shared.add_command_subparser(subparsers, "contract", "test", "Run scenarios (tests).")
|
|
@@ -59,13 +56,12 @@ def setup_parser(args: List[str], subparsers: Any) -> Any:
|
|
|
59
56
|
sub.set_defaults(func=run_tests)
|
|
60
57
|
|
|
61
58
|
sub = cli_shared.add_command_subparser(subparsers, "contract", "report", "Print a detailed report of the smart contracts.")
|
|
62
|
-
_add_project_arg(sub)
|
|
63
59
|
sub.add_argument("--skip-build", action="store_true", default=False, help="skips the step of building of the wasm contracts")
|
|
64
60
|
sub.add_argument("--skip-twiggy", action="store_true", default=False, help="skips the steps of building the debug wasm files and running twiggy")
|
|
65
61
|
sub.add_argument("--output-format", type=str, default="text-markdown", choices=["github-markdown", "text-markdown", "json"], help="report output format (default: %(default)s)")
|
|
66
62
|
sub.add_argument("--output-file", type=Path, help="if specified, the output is written to a file, otherwise it's written to the standard output")
|
|
67
63
|
sub.add_argument("--compare", type=Path, nargs='+', metavar=("report-1.json", "report-2.json"), help="create a comparison from two or more reports")
|
|
68
|
-
|
|
64
|
+
_add_build_options_sc_meta(sub)
|
|
69
65
|
sub.set_defaults(func=do_report)
|
|
70
66
|
|
|
71
67
|
output_description = CLIOutputBuilder.describe(with_contract=True, with_transaction_on_network=True, with_simulation=True)
|
|
@@ -131,12 +127,9 @@ def setup_parser(args: List[str], subparsers: Any) -> Any:
|
|
|
131
127
|
_add_arguments_arg(sub)
|
|
132
128
|
sub.set_defaults(func=query)
|
|
133
129
|
|
|
134
|
-
sub = cli_shared.add_command_subparser(
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
"verify",
|
|
138
|
-
"Verify the authenticity of the code of a deployed Smart Contract",
|
|
139
|
-
)
|
|
130
|
+
sub = cli_shared.add_command_subparser(subparsers, "contract", "verify",
|
|
131
|
+
"Verify the authenticity of the code of a deployed Smart Contract",
|
|
132
|
+
)
|
|
140
133
|
|
|
141
134
|
sub.add_argument(
|
|
142
135
|
"--packaged-src", required=True, help="JSON file containing the source code of the contract"
|
|
@@ -175,6 +168,29 @@ def _add_project_arg(sub: Any):
|
|
|
175
168
|
help="🗀 the project directory (default: current directory)")
|
|
176
169
|
|
|
177
170
|
|
|
171
|
+
def _add_build_options_sc_meta(sub: Any):
|
|
172
|
+
sub.add_argument("--path", default=os.getcwd(), help="the project directory (default: current directory)")
|
|
173
|
+
sub.add_argument("--no-wasm-opt", action="store_true", default=False,
|
|
174
|
+
help="do not optimize wasm files after the build (default: %(default)s)")
|
|
175
|
+
sub.add_argument("--wasm-symbols", action="store_true", default=False,
|
|
176
|
+
help="for rust projects, does not strip the symbols from the wasm output. Useful for analysing the bytecode. Creates larger wasm files. Avoid in production (default: %(default)s)")
|
|
177
|
+
sub.add_argument("--wasm-name", type=str,
|
|
178
|
+
help="for rust projects, optionally specify the name of the wasm bytecode output file")
|
|
179
|
+
sub.add_argument("--wasm-suffix", type=str,
|
|
180
|
+
help="for rust projects, optionally specify the suffix of the wasm bytecode output file")
|
|
181
|
+
sub.add_argument("--target-dir", type=str, help="for rust projects, forward the parameter to Cargo")
|
|
182
|
+
sub.add_argument("--wat", action="store_true", help="also generate a WAT file when building", default=False)
|
|
183
|
+
sub.add_argument("--mir", action="store_true", help="also emit MIR files when building", default=False)
|
|
184
|
+
sub.add_argument("--llvm-ir", action="store_true", help="also emit LL (LLVM) files when building", default=False)
|
|
185
|
+
sub.add_argument("--ignore", help="ignore all directories with these names. [default: target]")
|
|
186
|
+
sub.add_argument("--no-imports", action="store_true", default=False, help="skips extracting the EI imports after building the contracts")
|
|
187
|
+
sub.add_argument("--no-abi-git-version", action="store_true", default=False, help="skips loading the Git version into the ABI")
|
|
188
|
+
sub.add_argument("--twiggy-top", action="store_true", default=False, help="generate a twiggy top report after building")
|
|
189
|
+
sub.add_argument("--twiggy-paths", action="store_true", default=False, help="generate a twiggy paths report after building")
|
|
190
|
+
sub.add_argument("--twiggy-monos", action="store_true", default=False, help="generate a twiggy monos report after building")
|
|
191
|
+
sub.add_argument("--twiggy-dominators", action="store_true", default=False, help="generate a twiggy dominators report after building")
|
|
192
|
+
|
|
193
|
+
|
|
178
194
|
def _add_build_options_args(sub: Any):
|
|
179
195
|
sub.add_argument("--debug", action="store_true", default=False, help="set debug flag (default: %(default)s)")
|
|
180
196
|
sub.add_argument("--no-optimization", action="store_true", default=False,
|
|
@@ -246,35 +262,21 @@ def get_project_paths(args: Any) -> List[Path]:
|
|
|
246
262
|
|
|
247
263
|
|
|
248
264
|
def clean(args: Any):
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
projects.clean_project(project)
|
|
265
|
+
project_path = args.path
|
|
266
|
+
projects.clean_project(Path(project_path))
|
|
252
267
|
|
|
253
268
|
|
|
254
269
|
def build(args: Any):
|
|
255
|
-
project_paths =
|
|
256
|
-
|
|
270
|
+
project_paths = [Path(args.path)]
|
|
271
|
+
arg_list = cli_shared.convert_args_object_to_args_list(args)
|
|
257
272
|
|
|
258
273
|
for project in project_paths:
|
|
259
|
-
projects.build_project(project,
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
def _prepare_build_options(args: Any) -> Dict[str, Any]:
|
|
263
|
-
return {
|
|
264
|
-
"debug": args.debug,
|
|
265
|
-
"optimized": not args.no_optimization,
|
|
266
|
-
"no-wasm-opt": args.no_wasm_opt,
|
|
267
|
-
"verbose": args.verbose,
|
|
268
|
-
"cargo-target-dir": args.cargo_target_dir,
|
|
269
|
-
"wasm-symbols": args.wasm_symbols,
|
|
270
|
-
"wasm-name": args.wasm_name,
|
|
271
|
-
"wasm-suffix": args.wasm_suffix
|
|
272
|
-
}
|
|
274
|
+
projects.build_project(project, arg_list)
|
|
273
275
|
|
|
274
276
|
|
|
275
277
|
def do_report(args: Any):
|
|
276
|
-
|
|
277
|
-
projects.do_report(args,
|
|
278
|
+
args_dict = args.__dict__
|
|
279
|
+
projects.do_report(args, args_dict)
|
|
278
280
|
|
|
279
281
|
|
|
280
282
|
def run_tests(args: Any):
|
|
@@ -301,8 +303,8 @@ def deploy(args: Any):
|
|
|
301
303
|
tx = contract.deploy(sender, arguments, gas_price, gas_limit, value, args.chain, version, args.guardian, args.options)
|
|
302
304
|
tx = _sign_guarded_tx(args, tx)
|
|
303
305
|
|
|
304
|
-
logger.info("Contract address: %s", contract.address)
|
|
305
|
-
utils.log_explorer_contract_address(args.chain, contract.address)
|
|
306
|
+
logger.info("Contract address: %s", contract.address.bech32())
|
|
307
|
+
utils.log_explorer_contract_address(args.chain, contract.address.bech32())
|
|
306
308
|
|
|
307
309
|
_send_or_simulate(tx, contract, args)
|
|
308
310
|
|
|
@@ -354,21 +356,16 @@ def _prepare_signer(args: Any) -> Account:
|
|
|
354
356
|
|
|
355
357
|
|
|
356
358
|
def _sign_guarded_tx(args: Any, tx: Transaction) -> Transaction:
|
|
357
|
-
signature = tx.signature
|
|
358
|
-
tx.signature = ""
|
|
359
|
-
|
|
360
359
|
try:
|
|
361
360
|
guardian_account = cli_shared.prepare_guardian_account(args)
|
|
362
361
|
except NoWalletProvided:
|
|
363
362
|
guardian_account = None
|
|
364
363
|
|
|
365
364
|
if guardian_account:
|
|
366
|
-
tx.
|
|
365
|
+
tx.guardian_signature = bytes.fromhex(guardian_account.sign_transaction(tx))
|
|
367
366
|
elif args.guardian:
|
|
368
367
|
tx = cosign_transaction(tx, args.guardian_service_url, args.guardian_2fa_code) # type: ignore
|
|
369
368
|
|
|
370
|
-
tx.signature = signature
|
|
371
|
-
|
|
372
369
|
return tx
|
|
373
370
|
|
|
374
371
|
|
|
@@ -385,7 +382,7 @@ def call(args: Any):
|
|
|
385
382
|
value = args.value
|
|
386
383
|
version = args.version
|
|
387
384
|
|
|
388
|
-
contract = SmartContract(contract_address)
|
|
385
|
+
contract = SmartContract(Address.from_bech32(contract_address))
|
|
389
386
|
sender = _prepare_sender(args)
|
|
390
387
|
cli_shared.prepare_chain_id_in_args(args)
|
|
391
388
|
|
|
@@ -407,7 +404,7 @@ def upgrade(args: Any):
|
|
|
407
404
|
version = args.version
|
|
408
405
|
|
|
409
406
|
contract = _prepare_contract(args)
|
|
410
|
-
contract.address = Address(contract_address)
|
|
407
|
+
contract.address = Address.from_bech32(contract_address)
|
|
411
408
|
sender = _prepare_sender(args)
|
|
412
409
|
cli_shared.prepare_chain_id_in_args(args)
|
|
413
410
|
|
|
@@ -424,7 +421,7 @@ def query(args: Any):
|
|
|
424
421
|
function = args.function
|
|
425
422
|
arguments = args.arguments
|
|
426
423
|
|
|
427
|
-
contract = SmartContract(contract_address)
|
|
424
|
+
contract = SmartContract(address=Address.from_bech32(contract_address))
|
|
428
425
|
result = contract.query(ProxyNetworkProvider(args.proxy), function, arguments)
|
|
429
426
|
utils.dump_out_json(result)
|
|
430
427
|
|
|
@@ -436,7 +433,7 @@ def _send_or_simulate(tx: Transaction, contract: SmartContract, args: Any):
|
|
|
436
433
|
|
|
437
434
|
|
|
438
435
|
def verify(args: Any) -> None:
|
|
439
|
-
contract = Address(args.contract)
|
|
436
|
+
contract = Address.from_bech32(args.contract)
|
|
440
437
|
verifier_url = args.verifier_url
|
|
441
438
|
|
|
442
439
|
packaged_src = Path(args.packaged_src).expanduser().resolve()
|
|
@@ -465,7 +462,7 @@ def do_reproducible_build(args: Any):
|
|
|
465
462
|
|
|
466
463
|
utils.ensure_folder(output_path)
|
|
467
464
|
|
|
468
|
-
options =
|
|
465
|
+
options = args.__dict__
|
|
469
466
|
no_wasm_opt = options.get("no-wasm-opt", True)
|
|
470
467
|
|
|
471
468
|
if not is_docker_installed():
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
from typing import Any, List
|
|
2
|
+
|
|
3
|
+
from multiversx_sdk_core import Address
|
|
4
|
+
from multiversx_sdk_network_providers.proxy_network_provider import \
|
|
5
|
+
ProxyNetworkProvider
|
|
2
6
|
from prettytable import PrettyTable
|
|
3
7
|
|
|
4
8
|
from multiversx_sdk_cli import cli_shared
|
|
5
|
-
from multiversx_sdk_cli.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
from multiversx_sdk_cli.constants import ADDRESS_ZERO_BECH32
|
|
10
|
+
from multiversx_sdk_cli.dns import (compute_dns_address_for_shard_id,
|
|
11
|
+
dns_address_for_name, name_hash, register,
|
|
12
|
+
registration_cost, resolve, validate_name,
|
|
13
|
+
version)
|
|
9
14
|
|
|
10
15
|
|
|
11
16
|
def setup_parser(args: List[str], subparsers: Any) -> Any:
|
|
@@ -69,7 +74,7 @@ def _add_name_arg(sub: Any):
|
|
|
69
74
|
|
|
70
75
|
def dns_resolve(args: Any):
|
|
71
76
|
addr = resolve(args.name, ProxyNetworkProvider(args.proxy))
|
|
72
|
-
if addr.hex() != Address.
|
|
77
|
+
if addr.hex() != Address.from_bech32(ADDRESS_ZERO_BECH32).hex():
|
|
73
78
|
print(addr.bech32())
|
|
74
79
|
|
|
75
80
|
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
from collections import OrderedDict
|
|
2
1
|
import json
|
|
3
|
-
from typing import Any, Dict, List, Union
|
|
4
2
|
import logging
|
|
5
|
-
from
|
|
3
|
+
from collections import OrderedDict
|
|
4
|
+
from typing import Any, Dict, List, Optional, Union
|
|
5
|
+
|
|
6
|
+
from multiversx_sdk_core import Address
|
|
6
7
|
|
|
7
|
-
from multiversx_sdk_cli
|
|
8
|
+
from multiversx_sdk_cli import utils
|
|
8
9
|
from multiversx_sdk_cli.interfaces import ITransaction
|
|
9
10
|
from multiversx_sdk_cli.utils import ISerializable
|
|
10
11
|
|
|
@@ -13,6 +14,7 @@ logger = logging.getLogger("cli.output")
|
|
|
13
14
|
|
|
14
15
|
class CLIOutputBuilder:
|
|
15
16
|
def __init__(self) -> None:
|
|
17
|
+
self.emitted_transaction_hash: Optional[str] = None
|
|
16
18
|
self.emitted_transaction: Union[ITransaction, None] = None
|
|
17
19
|
self.emitted_transaction_omitted_fields: List[str] = []
|
|
18
20
|
self.contract_address: Union[Address, None] = None
|
|
@@ -20,6 +22,10 @@ class CLIOutputBuilder:
|
|
|
20
22
|
self.transaction_on_network_omitted_fields: List[str] = []
|
|
21
23
|
self.simulation_results: Union[ISerializable, None] = None
|
|
22
24
|
|
|
25
|
+
def set_emitted_transaction_hash(self, hash: str):
|
|
26
|
+
self.emitted_transaction_hash = hash
|
|
27
|
+
return self
|
|
28
|
+
|
|
23
29
|
def set_emitted_transaction(self, emitted_transaction: ITransaction, omitted_fields: List[str] = []):
|
|
24
30
|
self.emitted_transaction = emitted_transaction
|
|
25
31
|
self.emitted_transaction_omitted_fields = omitted_fields
|
|
@@ -46,8 +52,8 @@ class CLIOutputBuilder:
|
|
|
46
52
|
|
|
47
53
|
if self.emitted_transaction:
|
|
48
54
|
emitted_transaction_dict = self.emitted_transaction.to_dictionary()
|
|
49
|
-
emitted_transaction_hash = self.
|
|
50
|
-
emitted_transaction_data = self.emitted_transaction.
|
|
55
|
+
emitted_transaction_hash = self.emitted_transaction_hash or ""
|
|
56
|
+
emitted_transaction_data = str(self.emitted_transaction.data)
|
|
51
57
|
utils.omit_fields(emitted_transaction_dict, self.emitted_transaction_omitted_fields)
|
|
52
58
|
|
|
53
59
|
output["emittedTransaction"] = emitted_transaction_dict
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
from typing import Any
|
|
2
1
|
from getpass import getpass
|
|
2
|
+
from typing import Any
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
def load_password(args: Any):
|
|
5
|
+
def load_password(args: Any) -> str:
|
|
6
6
|
if args.passfile:
|
|
7
7
|
with open(args.passfile) as pass_file:
|
|
8
8
|
return pass_file.read().strip()
|
|
9
9
|
return getpass("Keyfile's password: ")
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
def load_guardian_password(args: Any):
|
|
12
|
+
def load_guardian_password(args: Any) -> str:
|
|
13
13
|
if args.guardian_passfile:
|
|
14
14
|
with open(args.guardian_passfile) as pass_file:
|
|
15
15
|
return pass_file.read().strip()
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import argparse
|
|
2
2
|
import ast
|
|
3
|
+
import copy
|
|
3
4
|
import sys
|
|
4
5
|
from argparse import FileType
|
|
5
|
-
from typing import Any, List, Text, cast
|
|
6
|
+
from typing import Any, Dict, List, Text, cast
|
|
6
7
|
|
|
8
|
+
from multiversx_sdk_core import Address
|
|
7
9
|
from multiversx_sdk_network_providers.proxy_network_provider import \
|
|
8
10
|
ProxyNetworkProvider
|
|
9
11
|
|
|
@@ -15,9 +17,10 @@ from multiversx_sdk_cli.cli_password import (load_guardian_password,
|
|
|
15
17
|
from multiversx_sdk_cli.constants import (DEFAULT_TX_VERSION,
|
|
16
18
|
TRANSACTION_OPTIONS_TX_GUARDED)
|
|
17
19
|
from multiversx_sdk_cli.errors import ArgumentsNotProvidedError
|
|
20
|
+
from multiversx_sdk_cli.interfaces import ITransaction
|
|
18
21
|
from multiversx_sdk_cli.ledger.ledger_functions import do_get_ledger_address
|
|
19
22
|
from multiversx_sdk_cli.simulation import Simulator
|
|
20
|
-
from multiversx_sdk_cli.transactions import
|
|
23
|
+
from multiversx_sdk_cli.transactions import send_and_wait_for_result
|
|
21
24
|
from multiversx_sdk_cli.ux import show_warning
|
|
22
25
|
|
|
23
26
|
|
|
@@ -147,7 +150,7 @@ def prepare_account(args: Any):
|
|
|
147
150
|
account = Account(key_file=args.keyfile, password=password)
|
|
148
151
|
elif args.ledger:
|
|
149
152
|
address = do_get_ledger_address(account_index=args.ledger_account_index, address_index=args.ledger_address_index)
|
|
150
|
-
account = Account(address=address)
|
|
153
|
+
account = Account(address=Address.from_bech32(address))
|
|
151
154
|
else:
|
|
152
155
|
raise errors.NoWalletProvided()
|
|
153
156
|
|
|
@@ -162,7 +165,7 @@ def prepare_guardian_account(args: Any):
|
|
|
162
165
|
account = Account(key_file=args.guardian_keyfile, password=password)
|
|
163
166
|
elif args.guardian_ledger:
|
|
164
167
|
address = do_get_ledger_address(account_index=args.guardian_ledger_account_index, address_index=args.guardian_ledger_address_index)
|
|
165
|
-
account = Account(address
|
|
168
|
+
account = Account(Address.from_bech32(address))
|
|
166
169
|
else:
|
|
167
170
|
raise errors.NoWalletProvided()
|
|
168
171
|
|
|
@@ -245,7 +248,7 @@ def check_options_for_guarded_tx(options: int):
|
|
|
245
248
|
raise errors.BadUsage("Invalid guarded transaction's options. The second least significant bit must be set.")
|
|
246
249
|
|
|
247
250
|
|
|
248
|
-
def send_or_simulate(tx:
|
|
251
|
+
def send_or_simulate(tx: ITransaction, args: Any, dump_output: bool = True) -> CLIOutputBuilder:
|
|
249
252
|
proxy = ProxyNetworkProvider(args.proxy)
|
|
250
253
|
|
|
251
254
|
is_set_wait_result = hasattr(args, "wait_result") and args.wait_result
|
|
@@ -262,10 +265,11 @@ def send_or_simulate(tx: Transaction, args: Any, dump_output: bool = True) -> CL
|
|
|
262
265
|
|
|
263
266
|
try:
|
|
264
267
|
if send_wait_result:
|
|
265
|
-
transaction_on_network = tx
|
|
268
|
+
transaction_on_network = send_and_wait_for_result(tx, proxy, args.timeout)
|
|
266
269
|
output_builder.set_awaited_transaction(transaction_on_network)
|
|
267
270
|
elif send_only:
|
|
268
|
-
|
|
271
|
+
hash = proxy.send_transaction(tx)
|
|
272
|
+
output_builder.set_emitted_transaction_hash(hash)
|
|
269
273
|
elif simulate:
|
|
270
274
|
simulation = Simulator(proxy).run(tx)
|
|
271
275
|
output_builder.set_simulation_results(simulation)
|
|
@@ -288,3 +292,24 @@ def check_if_sign_method_required(args: List[str], checked_method: str) -> bool:
|
|
|
288
292
|
return False
|
|
289
293
|
|
|
290
294
|
return True
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
def convert_args_object_to_args_list(args: Any) -> List[str]:
|
|
298
|
+
arguments = copy.deepcopy(args)
|
|
299
|
+
args_dict: Dict[str, Any] = arguments.__dict__
|
|
300
|
+
|
|
301
|
+
# delete the function key because we don't need to pass it along
|
|
302
|
+
args_dict.pop("func", None)
|
|
303
|
+
|
|
304
|
+
args_list: List[str] = []
|
|
305
|
+
for key, val in args_dict.items():
|
|
306
|
+
modified_key = "--" + key.replace("_", "-")
|
|
307
|
+
|
|
308
|
+
if isinstance(val, bool) and val:
|
|
309
|
+
args_list.extend([modified_key])
|
|
310
|
+
continue
|
|
311
|
+
|
|
312
|
+
if val:
|
|
313
|
+
args_list.extend([modified_key, val])
|
|
314
|
+
|
|
315
|
+
return args_list
|