Skip to content

Commit 2906430

Browse files
committed
fixes
1 parent e066bc9 commit 2906430

7 files changed

Lines changed: 16 additions & 20 deletions

File tree

multiversx_sdk_cli/cli_contracts.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ def deploy(args: Any):
390390
args=args,
391391
)
392392

393-
chain_id = cli_shared.get_chain_id(args.chain, args.proxy)
393+
chain_id = cli_shared.get_chain_id(args.proxy, args.chain)
394394
config = TransactionsFactoryConfig(chain_id)
395395

396396
abi = Abi.load(Path(args.abi)) if args.abi else None
@@ -442,7 +442,7 @@ def call(args: Any):
442442
args=args,
443443
)
444444

445-
chain_id = cli_shared.get_chain_id(args.chain, args.proxy)
445+
chain_id = cli_shared.get_chain_id(args.proxy, args.chain)
446446
config = TransactionsFactoryConfig(chain_id)
447447

448448
abi = Abi.load(Path(args.abi)) if args.abi else None
@@ -487,7 +487,7 @@ def upgrade(args: Any):
487487
args=args,
488488
)
489489

490-
chain_id = cli_shared.get_chain_id(args.chain, args.proxy)
490+
chain_id = cli_shared.get_chain_id(args.proxy, args.chain)
491491
config = TransactionsFactoryConfig(chain_id)
492492

493493
abi = Abi.load(Path(args.abi)) if args.abi else None

multiversx_sdk_cli/cli_delegation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ def validate_arguments(args: Any):
395395

396396

397397
def _get_delegation_controller(args: Any):
398-
chain_id = cli_shared.get_chain_id(args.chain, args.proxy)
398+
chain_id = cli_shared.get_chain_id(args.proxy, args.chain)
399399
config = TransactionsFactoryConfig(chain_id)
400400
delegation = DelegationOperations(config)
401401
return delegation

multiversx_sdk_cli/cli_shared.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from argparse import FileType
77
from functools import cache
88
from pathlib import Path
9-
from typing import Any, Text, Union, cast
9+
from typing import Any, Optional, Text, Union, cast
1010

1111
from multiversx_sdk import (
1212
Account,
@@ -39,7 +39,7 @@
3939
from multiversx_sdk_cli.simulation import Simulator
4040
from multiversx_sdk_cli.transactions import send_and_wait_for_result
4141
from multiversx_sdk_cli.utils import log_explorer_transaction
42-
from multiversx_sdk_cli.ux import confirm_continuation, show_warning
42+
from multiversx_sdk_cli.ux import confirm_continuation
4343

4444
logger = logging.getLogger("cli_shared")
4545

@@ -509,16 +509,8 @@ def get_current_nonce_for_address(address: Address, proxy_url: Union[str, None])
509509

510510

511511
@cache
512-
def get_chain_id(chain_id: str, proxy_url: str) -> str:
513-
if chain_id and proxy_url:
514-
fetched_chain_id = _fetch_chain_id(proxy_url)
515-
516-
if chain_id != fetched_chain_id:
517-
show_warning(
518-
f"The chain ID you have provided does not match the chain ID you got from the proxy. Will use the proxy's value: '{fetched_chain_id}'"
519-
)
520-
return fetched_chain_id
521-
512+
def get_chain_id(proxy_url: str, chain_id: Optional[str] = None) -> str:
513+
"""We know and have already validated that if chainID is not provided, proxy is provided."""
522514
if chain_id:
523515
return chain_id
524516

@@ -647,8 +639,11 @@ def prepare_guardian_relayer_data(args: Any) -> GuardianRelayerData:
647639

648640

649641
def set_proxy_from_config_if_not_provided(args: Any, config: config.MxpyConfig) -> None:
650-
"""This function modifies the `args` object by setting the proxy from the config if not already set."""
642+
"""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."""
651643
if not args.proxy:
644+
if hasattr(args, "chain") and args.chain and hasattr(args, "nonce") and args.nonce:
645+
return
646+
652647
if config.proxy_url:
653648
logger.info(f"Using proxy URL from config: {config.proxy_url}")
654649
args.proxy = config.proxy_url

multiversx_sdk_cli/cli_transactions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def create_transaction(args: Any):
138138
transfers = getattr(args, "token_transfers", None)
139139
transfers = prepare_token_transfers(transfers) if transfers else None
140140

141-
chain_id = cli_shared.get_chain_id(args.chain, args.proxy)
141+
chain_id = cli_shared.get_chain_id(args.proxy, args.chain)
142142
tx_controller = TransactionsController(chain_id)
143143

144144
tx = tx_controller.create_transaction(

multiversx_sdk_cli/cli_validators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def do_stake(args: Any):
198198

199199

200200
def _get_validators_controller(args: Any):
201-
chain_id = cli_shared.get_chain_id(args.chain, args.proxy)
201+
chain_id = cli_shared.get_chain_id(args.proxy, args.chain)
202202
validators = ValidatorsController(chain_id)
203203
return validators
204204

multiversx_sdk_cli/dns.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def register(args: Any):
7777
receiver = dns_address_for_name(args.name)
7878
data = dns_register_data(args.name)
7979

80-
chain_id = cli_shared.get_chain_id(args.chain, args.proxy)
80+
chain_id = cli_shared.get_chain_id(args.proxy, args.chain)
8181
controller = TransactionsController(chain_id)
8282

8383
tx = controller.create_transaction(

multiversx_sdk_cli/tests/test_cli_contracts.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ def test_contract_flow(capsys: Any):
270270

271271

272272
def test_contract_deploy_without_required_arguments():
273+
"""This test passes with an unaltered config. If proxy is set in the config, the test will fail due to mxpy fetching the nonce and the chain ID."""
273274
alice = f"{parent}/testdata/alice.pem"
274275
adder = f"{parent}/testdata/adder.wasm"
275276

0 commit comments

Comments
 (0)