multiversx-sdk-cli 11.3.1__tar.gz → 11.4.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-11.3.1 → multiversx_sdk_cli-11.4.0}/PKG-INFO +1 -1
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/cli.py +2 -1
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/cli_faucet.py +8 -1
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/cli_get.py +8 -11
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/cli_shared.py +24 -1
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/cli_tokens.py +2 -2
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/config.py +12 -3
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/config_env.py +76 -4
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/dependencies/modules.py +15 -5
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/utils.py +9 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/pyproject.toml +1 -1
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/.gitignore +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/LICENSE +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/README.md +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/__init__.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/args_converter.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/args_validation.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/cli_config.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/cli_config_env.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/cli_config_wallet.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/cli_contracts.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/cli_data.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/cli_delegation.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/cli_deps.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/cli_dns.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/cli_governance.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/cli_ledger.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/cli_localnet.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/cli_multisig.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/cli_output.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/cli_password.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/cli_transactions.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/cli_validator_wallet.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/cli_validators.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/cli_wallet.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/config_wallet.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/constants.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/contract_verification.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/cosign_transaction.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/dependencies/__init__.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/dependencies/install.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/dependencies/resolution.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/dns.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/docker.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/downloader.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/errors.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/guardian_relayer_data.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/guards.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/interfaces.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/localnet/__init__.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/localnet/config_default.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/localnet/config_general.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/localnet/config_networking.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/localnet/config_part.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/localnet/config_root.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/localnet/config_sharding.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/localnet/config_software.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/localnet/constants.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/localnet/genesis.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/localnet/genesis_json.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/localnet/genesis_smart_contracts_json.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/localnet/libraries.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/localnet/node.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/localnet/node_config_toml.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/localnet/nodes_setup_json.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/localnet/p2p_toml.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/localnet/seednode_p2pKey.pem +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/localnet/step_build_software.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/localnet/step_clean.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/localnet/step_config.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/localnet/step_new.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/localnet/step_prerequisites.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/localnet/step_start.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/localnet/wallets.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/myprocess.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/sign_verify.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/signing_wrapper.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/simulation.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/transactions.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/ux.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/version.py +0 -0
- {multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/workstation.py +0 -0
|
@@ -30,7 +30,7 @@ import multiversx_sdk_cli.cli_validators
|
|
|
30
30
|
import multiversx_sdk_cli.cli_wallet
|
|
31
31
|
import multiversx_sdk_cli.version
|
|
32
32
|
from multiversx_sdk_cli import config, errors, utils, ux
|
|
33
|
-
from multiversx_sdk_cli.cli_shared import set_proxy_from_config_if_not_provided
|
|
33
|
+
from multiversx_sdk_cli.cli_shared import parse_proxy_headers, set_proxy_from_config_if_not_provided
|
|
34
34
|
from multiversx_sdk_cli.config_env import get_address_hrp
|
|
35
35
|
from multiversx_sdk_cli.constants import LOG_LEVELS, SDK_PATH
|
|
36
36
|
|
|
@@ -81,6 +81,7 @@ def _do_main(cli_args: list[str]):
|
|
|
81
81
|
parser.print_help()
|
|
82
82
|
else:
|
|
83
83
|
set_proxy_from_config_if_not_provided(args)
|
|
84
|
+
config.set_proxy_headers(parse_proxy_headers(getattr(args, "proxy_headers", None)))
|
|
84
85
|
args.func(args)
|
|
85
86
|
|
|
86
87
|
|
|
@@ -29,6 +29,12 @@ def setup_parser(args: list[str], subparsers: Any) -> Any:
|
|
|
29
29
|
cli_shared.add_wallet_args(args, sub)
|
|
30
30
|
sub.add_argument("--chain", choices=["D", "T"], help="the chain identifier")
|
|
31
31
|
sub.add_argument("--api", type=str, help="custom api url for the native auth client")
|
|
32
|
+
sub.add_argument(
|
|
33
|
+
"--api-headers",
|
|
34
|
+
nargs="+",
|
|
35
|
+
metavar="KEY=VALUE",
|
|
36
|
+
help="extra HTTP headers for API requests, e.g. 'Api-Key=mytoken'"
|
|
37
|
+
)
|
|
32
38
|
sub.add_argument("--wallet-url", type=str, help="custom wallet url to call the faucet from")
|
|
33
39
|
sub.set_defaults(func=faucet)
|
|
34
40
|
|
|
@@ -40,7 +46,8 @@ def faucet(args: Any):
|
|
|
40
46
|
account = cli_shared.prepare_account(args)
|
|
41
47
|
wallet, api = get_wallet_and_api_urls(args)
|
|
42
48
|
|
|
43
|
-
|
|
49
|
+
extra_headers = cli_shared.parse_proxy_headers(getattr(args, "api_headers", None))
|
|
50
|
+
config = NativeAuthClientConfig(origin=wallet, api_url=api, extra_request_headers=extra_headers or None)
|
|
44
51
|
client = NativeAuthClient(config)
|
|
45
52
|
|
|
46
53
|
init_token = client.initialize()
|
|
@@ -6,6 +6,7 @@ from multiversx_sdk import NetworkProviderError as SDKNetworkProviderError
|
|
|
6
6
|
from multiversx_sdk import ProxyNetworkProvider, Token, TokenComputer
|
|
7
7
|
|
|
8
8
|
from multiversx_sdk_cli import cli_shared
|
|
9
|
+
from multiversx_sdk_cli.cli_shared import add_proxy_arg
|
|
9
10
|
from multiversx_sdk_cli.config import get_config_for_network_providers
|
|
10
11
|
from multiversx_sdk_cli.config_env import MxpyEnv
|
|
11
12
|
from multiversx_sdk_cli.errors import (
|
|
@@ -25,7 +26,7 @@ def setup_parser(subparsers: Any) -> Any:
|
|
|
25
26
|
sub = cli_shared.add_command_subparser(subparsers, "get", "account", "Get info about an account.")
|
|
26
27
|
_add_alias_arg(sub)
|
|
27
28
|
_add_address_arg(sub)
|
|
28
|
-
|
|
29
|
+
add_proxy_arg(sub)
|
|
29
30
|
sub.add_argument(
|
|
30
31
|
"--balance",
|
|
31
32
|
action="store_true",
|
|
@@ -40,7 +41,7 @@ def setup_parser(subparsers: Any) -> Any:
|
|
|
40
41
|
)
|
|
41
42
|
_add_alias_arg(sub)
|
|
42
43
|
_add_address_arg(sub)
|
|
43
|
-
|
|
44
|
+
add_proxy_arg(sub)
|
|
44
45
|
sub.set_defaults(func=get_storage)
|
|
45
46
|
|
|
46
47
|
sub = cli_shared.add_command_subparser(
|
|
@@ -48,14 +49,14 @@ def setup_parser(subparsers: Any) -> Any:
|
|
|
48
49
|
)
|
|
49
50
|
_add_alias_arg(sub)
|
|
50
51
|
_add_address_arg(sub)
|
|
51
|
-
|
|
52
|
+
add_proxy_arg(sub)
|
|
52
53
|
sub.add_argument("--key", type=str, required=True, help="the storage key to read from")
|
|
53
54
|
sub.set_defaults(func=get_key)
|
|
54
55
|
|
|
55
56
|
sub = cli_shared.add_command_subparser(subparsers, "get", "token", "Get a token of an account.")
|
|
56
57
|
_add_alias_arg(sub)
|
|
57
58
|
_add_address_arg(sub)
|
|
58
|
-
|
|
59
|
+
add_proxy_arg(sub)
|
|
59
60
|
sub.add_argument(
|
|
60
61
|
"--identifier",
|
|
61
62
|
type=str,
|
|
@@ -65,16 +66,16 @@ def setup_parser(subparsers: Any) -> Any:
|
|
|
65
66
|
sub.set_defaults(func=get_token)
|
|
66
67
|
|
|
67
68
|
sub = cli_shared.add_command_subparser(subparsers, "get", "transaction", "Get a transaction from the network.")
|
|
68
|
-
|
|
69
|
+
add_proxy_arg(sub)
|
|
69
70
|
sub.add_argument("--hash", type=str, required=True, help="the transaction hash")
|
|
70
71
|
sub.set_defaults(func=get_transaction)
|
|
71
72
|
|
|
72
73
|
sub = cli_shared.add_command_subparser(subparsers, "get", "network-config", "Get the network configuration.")
|
|
73
|
-
|
|
74
|
+
add_proxy_arg(sub)
|
|
74
75
|
sub.set_defaults(func=get_network_config)
|
|
75
76
|
|
|
76
77
|
sub = cli_shared.add_command_subparser(subparsers, "get", "network-status", "Get the network status.")
|
|
77
|
-
|
|
78
|
+
add_proxy_arg(sub)
|
|
78
79
|
sub.add_argument(
|
|
79
80
|
"--shard",
|
|
80
81
|
type=int,
|
|
@@ -96,10 +97,6 @@ def _add_address_arg(sub: Any):
|
|
|
96
97
|
sub.add_argument("--address", type=str, help="the bech32 address")
|
|
97
98
|
|
|
98
99
|
|
|
99
|
-
def _add_proxy_arg(sub: Any):
|
|
100
|
-
sub.add_argument("--proxy", type=str, help="the proxy url")
|
|
101
|
-
|
|
102
|
-
|
|
103
100
|
def get_account(args: Any):
|
|
104
101
|
if args.alias and args.address:
|
|
105
102
|
raise BadUsage("Provide either '--alias' or '--address'")
|
|
@@ -58,7 +58,7 @@ from multiversx_sdk_cli.interfaces import IAccount
|
|
|
58
58
|
from multiversx_sdk_cli.signing_wrapper import SigningWrapper
|
|
59
59
|
from multiversx_sdk_cli.simulation import Simulator
|
|
60
60
|
from multiversx_sdk_cli.transactions import send_and_wait_for_result
|
|
61
|
-
from multiversx_sdk_cli.utils import log_explorer_transaction
|
|
61
|
+
from multiversx_sdk_cli.utils import log_explorer_transaction, parse_headers_list
|
|
62
62
|
from multiversx_sdk_cli.ux import confirm_continuation
|
|
63
63
|
|
|
64
64
|
logger = logging.getLogger("cli_shared")
|
|
@@ -270,6 +270,24 @@ def add_relayed_v3_wallet_args(args: list[str], sub: Any):
|
|
|
270
270
|
|
|
271
271
|
def add_proxy_arg(sub: Any):
|
|
272
272
|
sub.add_argument("--proxy", type=str, help="🔗 the URL of the proxy")
|
|
273
|
+
sub.add_argument(
|
|
274
|
+
"--proxy-headers",
|
|
275
|
+
nargs="+",
|
|
276
|
+
metavar="KEY=VALUE",
|
|
277
|
+
help="custom HTTP headers for proxy requests, e.g. 'Api-Key=mytoken'",
|
|
278
|
+
)
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
def parse_proxy_headers(proxy_headers: Optional[list[str]]) -> dict[str, str]:
|
|
282
|
+
if not proxy_headers:
|
|
283
|
+
return {}
|
|
284
|
+
for item in proxy_headers:
|
|
285
|
+
if "=" not in item:
|
|
286
|
+
raise ArgumentsNotProvidedError(f"Invalid request header (expected KEY=VALUE): {item!r}")
|
|
287
|
+
key, _, _ = item.partition("=")
|
|
288
|
+
if not key.strip():
|
|
289
|
+
raise ArgumentsNotProvidedError(f"Invalid request header (expected non-empty KEY=VALUE): {item!r}")
|
|
290
|
+
return parse_headers_list(proxy_headers)
|
|
273
291
|
|
|
274
292
|
|
|
275
293
|
def add_outfile_arg(sub: Any, what: str = ""):
|
|
@@ -810,6 +828,11 @@ def prepare_token_transfers(transfers: list[str]) -> list[TokenTransfer]:
|
|
|
810
828
|
|
|
811
829
|
def set_proxy_from_config_if_not_provided(args: Any) -> None:
|
|
812
830
|
"""This function modifies the `args` object by setting the proxy from the config if not already set. If proxy is not needed (chainID and nonce are provided), the proxy will not be set."""
|
|
831
|
+
if hasattr(args, "proxy_headers") and not args.proxy_headers:
|
|
832
|
+
env = MxpyEnv.from_active_env()
|
|
833
|
+
if env.proxy_headers:
|
|
834
|
+
args.proxy_headers = [f"{key}={value}" for key, value in env.proxy_headers.items()]
|
|
835
|
+
|
|
813
836
|
if not hasattr(args, "proxy"):
|
|
814
837
|
return
|
|
815
838
|
|
|
@@ -7,7 +7,7 @@ from multiversx_sdk import (
|
|
|
7
7
|
TokenType,
|
|
8
8
|
)
|
|
9
9
|
|
|
10
|
-
from multiversx_sdk_cli import cli_shared
|
|
10
|
+
from multiversx_sdk_cli import cli_shared, config
|
|
11
11
|
from multiversx_sdk_cli.args_validation import (
|
|
12
12
|
validate_broadcast_args,
|
|
13
13
|
validate_chain_id_args,
|
|
@@ -828,7 +828,7 @@ def _initialize_controller(args: Any) -> TokenManagementController:
|
|
|
828
828
|
proxy_url = args.proxy if args.proxy else ""
|
|
829
829
|
return TokenManagementController(
|
|
830
830
|
chain_id=chain_id,
|
|
831
|
-
network_provider=ProxyNetworkProvider(proxy_url),
|
|
831
|
+
network_provider=ProxyNetworkProvider(proxy_url, config=config.get_config_for_network_providers()),
|
|
832
832
|
gas_limit_estimator=gas_estimator,
|
|
833
833
|
)
|
|
834
834
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import os
|
|
2
2
|
from functools import cache
|
|
3
3
|
from pathlib import Path
|
|
4
|
-
from typing import Any
|
|
4
|
+
from typing import Any, Optional
|
|
5
5
|
|
|
6
6
|
from multiversx_sdk import NetworkProviderConfig
|
|
7
7
|
|
|
@@ -129,7 +129,7 @@ def get_defaults() -> dict[str, Any]:
|
|
|
129
129
|
return {
|
|
130
130
|
"dependencies.golang.resolution": "SDK",
|
|
131
131
|
"dependencies.golang.tag": "go1.23.10",
|
|
132
|
-
"dependencies.golang.urlTemplate.linux": "https://golang.org/dl/{TAG}.linux-
|
|
132
|
+
"dependencies.golang.urlTemplate.linux": "https://golang.org/dl/{TAG}.linux-{ARCH}.tar.gz",
|
|
133
133
|
"dependencies.golang.urlTemplate.osx": "https://golang.org/dl/{TAG}.darwin-amd64.tar.gz",
|
|
134
134
|
"dependencies.golang.urlTemplate.windows": "https://golang.org/dl/{TAG}.windows-amd64.zip",
|
|
135
135
|
"dependencies.testwallets.tag": "v1.0.0",
|
|
@@ -192,5 +192,14 @@ def get_dependency_parent_directory(key: str) -> Path:
|
|
|
192
192
|
return SDK_PATH / key
|
|
193
193
|
|
|
194
194
|
|
|
195
|
+
_proxy_headers: dict[str, str] = {}
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
def set_proxy_headers(headers: dict[str, str]) -> None:
|
|
199
|
+
global _proxy_headers
|
|
200
|
+
_proxy_headers = headers
|
|
201
|
+
|
|
202
|
+
|
|
195
203
|
def get_config_for_network_providers() -> NetworkProviderConfig:
|
|
196
|
-
|
|
204
|
+
requests_options: Optional[dict[str, Any]] = {"headers": _proxy_headers} if _proxy_headers else None
|
|
205
|
+
return NetworkProviderConfig(client_name="mxpy", requests_options=requests_options)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import json
|
|
1
2
|
from dataclasses import dataclass
|
|
2
3
|
from functools import cache
|
|
3
4
|
from pathlib import Path
|
|
@@ -11,7 +12,7 @@ from multiversx_sdk_cli.errors import (
|
|
|
11
12
|
InvalidEnvironmentValue,
|
|
12
13
|
UnknownEnvironmentError,
|
|
13
14
|
)
|
|
14
|
-
from multiversx_sdk_cli.utils import read_json_file, write_json_file
|
|
15
|
+
from multiversx_sdk_cli.utils import parse_headers_list, read_json_file, write_json_file
|
|
15
16
|
|
|
16
17
|
LOCAL_ENV_PATH = Path("env.mxpy.json").resolve()
|
|
17
18
|
GLOBAL_ENV_PATH = SDK_PATH / "env.mxpy.json"
|
|
@@ -21,6 +22,7 @@ GLOBAL_ENV_PATH = SDK_PATH / "env.mxpy.json"
|
|
|
21
22
|
class MxpyEnv:
|
|
22
23
|
address_hrp: str
|
|
23
24
|
proxy_url: str
|
|
25
|
+
proxy_headers: dict[str, str]
|
|
24
26
|
explorer_url: str
|
|
25
27
|
ask_confirmation: bool
|
|
26
28
|
|
|
@@ -30,6 +32,7 @@ class MxpyEnv:
|
|
|
30
32
|
return cls(
|
|
31
33
|
address_hrp=get_address_hrp(),
|
|
32
34
|
proxy_url=get_proxy_url(),
|
|
35
|
+
proxy_headers=get_proxy_headers(),
|
|
33
36
|
explorer_url=get_explorer_url(),
|
|
34
37
|
ask_confirmation=get_confirmation_setting(),
|
|
35
38
|
)
|
|
@@ -39,6 +42,7 @@ def get_defaults() -> dict[str, str]:
|
|
|
39
42
|
return {
|
|
40
43
|
"default_address_hrp": "erd",
|
|
41
44
|
"proxy_url": "",
|
|
45
|
+
"proxy_headers": "",
|
|
42
46
|
"explorer_url": "",
|
|
43
47
|
"ask_confirmation": "false",
|
|
44
48
|
}
|
|
@@ -72,6 +76,35 @@ def get_proxy_url() -> str:
|
|
|
72
76
|
return _get_env_value("proxy_url")
|
|
73
77
|
|
|
74
78
|
|
|
79
|
+
@cache
|
|
80
|
+
def get_proxy_headers() -> dict[str, str]:
|
|
81
|
+
"""
|
|
82
|
+
Returns the proxy headers for the active environment as a dict.
|
|
83
|
+
Supports two formats:
|
|
84
|
+
- JSON object, e.g. {"Authorization": "Bearer token"}
|
|
85
|
+
- legacy space-separated KEY=VALUE pairs, e.g. "X-Api-Key=abc Another=value"
|
|
86
|
+
"""
|
|
87
|
+
raw = _get_raw_env_value("proxy_headers")
|
|
88
|
+
|
|
89
|
+
if not raw:
|
|
90
|
+
return {}
|
|
91
|
+
|
|
92
|
+
if isinstance(raw, dict):
|
|
93
|
+
return {str(key): str(value) for key, value in raw.items()}
|
|
94
|
+
|
|
95
|
+
if not isinstance(raw, str):
|
|
96
|
+
raise InvalidEnvironmentValue(f"Invalid proxy_headers value: [{raw!r}]")
|
|
97
|
+
|
|
98
|
+
stripped = raw.strip()
|
|
99
|
+
if stripped.startswith("{"):
|
|
100
|
+
parsed = json.loads(stripped)
|
|
101
|
+
if not isinstance(parsed, dict):
|
|
102
|
+
raise InvalidEnvironmentValue("proxy_headers must be a JSON object")
|
|
103
|
+
return {str(key): str(value) for key, value in parsed.items()}
|
|
104
|
+
|
|
105
|
+
return parse_headers_list(raw.split())
|
|
106
|
+
|
|
107
|
+
|
|
75
108
|
@cache
|
|
76
109
|
def get_explorer_url() -> str:
|
|
77
110
|
"""
|
|
@@ -112,16 +145,32 @@ def get_value(name: str, env_name: str) -> str:
|
|
|
112
145
|
return value
|
|
113
146
|
|
|
114
147
|
|
|
148
|
+
def _get_raw_env_value(key: str) -> Any:
|
|
149
|
+
"""Returns the raw value of a key for the active environment."""
|
|
150
|
+
data = read_env_file()
|
|
151
|
+
active_env_name: str = data.get("active", "default")
|
|
152
|
+
|
|
153
|
+
if active_env_name == "default":
|
|
154
|
+
return get_defaults()[key]
|
|
155
|
+
|
|
156
|
+
envs = data.get("environments", {})
|
|
157
|
+
env = envs.get(active_env_name, None)
|
|
158
|
+
if env is None:
|
|
159
|
+
raise UnknownEnvironmentError(active_env_name)
|
|
160
|
+
|
|
161
|
+
return env.get(key, get_defaults()[key])
|
|
162
|
+
|
|
163
|
+
|
|
115
164
|
def _guard_valid_name(name: str):
|
|
116
165
|
if name not in get_defaults().keys():
|
|
117
166
|
raise InvalidEnvironmentValue(f"Key is not present in environment config: [{name}]")
|
|
118
167
|
|
|
119
168
|
|
|
120
|
-
def get_active_env() -> dict[str,
|
|
169
|
+
def get_active_env() -> dict[str, Any]:
|
|
121
170
|
data = read_env_file()
|
|
122
171
|
envs: dict[str, Any] = data.get("environments", {})
|
|
123
172
|
active_env_name: str = data.get("active", "default")
|
|
124
|
-
result: dict[str,
|
|
173
|
+
result: dict[str, Any] = envs.get(active_env_name, {})
|
|
125
174
|
|
|
126
175
|
return result
|
|
127
176
|
|
|
@@ -150,12 +199,35 @@ def set_value(name: str, value: str, env_name: str):
|
|
|
150
199
|
if env is None:
|
|
151
200
|
raise UnknownEnvironmentError(env_name)
|
|
152
201
|
|
|
153
|
-
env[name] = value
|
|
202
|
+
env[name] = _prepare_value_for_storage(name, value)
|
|
154
203
|
envs[env_name] = env
|
|
155
204
|
data["environments"] = envs
|
|
156
205
|
write_file(data)
|
|
157
206
|
|
|
158
207
|
|
|
208
|
+
def _prepare_value_for_storage(name: str, value: str) -> Any:
|
|
209
|
+
if name != "proxy_headers":
|
|
210
|
+
return value
|
|
211
|
+
|
|
212
|
+
stripped = value.strip()
|
|
213
|
+
if not stripped.startswith("{"):
|
|
214
|
+
return value
|
|
215
|
+
|
|
216
|
+
try:
|
|
217
|
+
parsed = json.loads(stripped)
|
|
218
|
+
except json.JSONDecodeError as error:
|
|
219
|
+
raise InvalidEnvironmentValue(f"Invalid JSON for proxy_headers: [{error}]")
|
|
220
|
+
|
|
221
|
+
if not isinstance(parsed, dict):
|
|
222
|
+
raise InvalidEnvironmentValue("proxy_headers must be a JSON object")
|
|
223
|
+
|
|
224
|
+
for key, item in parsed.items():
|
|
225
|
+
if not isinstance(key, str) or not isinstance(item, str):
|
|
226
|
+
raise InvalidEnvironmentValue("proxy_headers JSON object must have string keys and values")
|
|
227
|
+
|
|
228
|
+
return parsed
|
|
229
|
+
|
|
230
|
+
|
|
159
231
|
def write_file(data: dict[str, Any]):
|
|
160
232
|
env_path = resolve_env_path()
|
|
161
233
|
write_json_file(str(env_path), data)
|
{multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/dependencies/modules.py
RENAMED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import logging
|
|
2
|
+
import platform
|
|
2
3
|
import os
|
|
3
4
|
import shutil
|
|
4
5
|
from os import path
|
|
@@ -122,13 +123,22 @@ class StandaloneModule(DependencyModule):
|
|
|
122
123
|
return config.get_dependency_parent_directory(self.key)
|
|
123
124
|
|
|
124
125
|
def _get_download_url(self, tag: str) -> str:
|
|
125
|
-
|
|
126
|
+
plat = workstation.get_platform()
|
|
126
127
|
|
|
127
|
-
url = config.get_dependency_url(self.key, tag,
|
|
128
|
+
url = config.get_dependency_url(self.key, tag, plat)
|
|
128
129
|
if not url:
|
|
129
|
-
raise errors.PlatformNotSupported(self.key,
|
|
130
|
-
|
|
131
|
-
|
|
130
|
+
raise errors.PlatformNotSupported(self.key, plat)
|
|
131
|
+
|
|
132
|
+
machine = platform.machine().lower()
|
|
133
|
+
arch_map = {
|
|
134
|
+
"x86_64": "amd64",
|
|
135
|
+
"amd64": "amd64",
|
|
136
|
+
"aarch64": "arm64",
|
|
137
|
+
"arm64": "arm64",
|
|
138
|
+
}
|
|
139
|
+
arch = arch_map.get(machine, "amd64")
|
|
140
|
+
|
|
141
|
+
url = url.replace("{TAG}", tag).replace("{ARCH}", arch)
|
|
132
142
|
return url
|
|
133
143
|
|
|
134
144
|
def _get_archive_path(self, tag: str) -> Path:
|
|
@@ -183,3 +183,12 @@ def get_explorer_by_chain_id(chain_id: str) -> str:
|
|
|
183
183
|
return explorers_by_chain_id[chain_id]
|
|
184
184
|
except KeyError:
|
|
185
185
|
return ""
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
def parse_headers_list(items: list[str]) -> dict[str, str]:
|
|
189
|
+
"""Parses a list of KEY=VALUE strings into a dict."""
|
|
190
|
+
headers: dict[str, str] = {}
|
|
191
|
+
for item in items:
|
|
192
|
+
key, _, value = item.partition("=")
|
|
193
|
+
headers[key.strip()] = value.strip()
|
|
194
|
+
return headers
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/args_converter.py
RENAMED
|
File without changes
|
{multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/args_validation.py
RENAMED
|
File without changes
|
|
File without changes
|
{multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/cli_config_env.py
RENAMED
|
File without changes
|
{multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/cli_config_wallet.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/cli_delegation.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/cli_governance.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/cli_transactions.py
RENAMED
|
File without changes
|
{multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/cli_validator_wallet.py
RENAMED
|
File without changes
|
{multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/cli_validators.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/contract_verification.py
RENAMED
|
File without changes
|
{multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/cosign_transaction.py
RENAMED
|
File without changes
|
{multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/dependencies/__init__.py
RENAMED
|
File without changes
|
{multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/dependencies/install.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/guardian_relayer_data.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/localnet/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/localnet/config_part.py
RENAMED
|
File without changes
|
{multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/localnet/config_root.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/localnet/constants.py
RENAMED
|
File without changes
|
{multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/localnet/genesis.py
RENAMED
|
File without changes
|
{multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/localnet/genesis_json.py
RENAMED
|
File without changes
|
|
File without changes
|
{multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/localnet/libraries.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/localnet/p2p_toml.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/localnet/step_clean.py
RENAMED
|
File without changes
|
{multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/localnet/step_config.py
RENAMED
|
File without changes
|
{multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/localnet/step_new.py
RENAMED
|
File without changes
|
|
File without changes
|
{multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/localnet/step_start.py
RENAMED
|
File without changes
|
{multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/localnet/wallets.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{multiversx_sdk_cli-11.3.1 → multiversx_sdk_cli-11.4.0}/multiversx_sdk_cli/signing_wrapper.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|