5858from multiversx_sdk_cli .signing_wrapper import SigningWrapper
5959from multiversx_sdk_cli .simulation import Simulator
6060from 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
6262from multiversx_sdk_cli .ux import confirm_continuation
6363
6464logger = logging .getLogger ("cli_shared" )
6565
66-
6766trusted_cosigner_service_url_by_chain_id = {
6867 "1" : "https://tools.multiversx.com/guardian" ,
6968 "D" : "https://devnet-tools.multiversx.com/guardian" ,
@@ -118,11 +117,11 @@ def add_command_subparser(subparsers: Any, group: str, command: str, description
118117
119118
120119def add_tx_args (
121- args : list [str ],
122- sub : Any ,
123- with_nonce : bool = True ,
124- with_receiver : bool = True ,
125- with_data : bool = True ,
120+ args : list [str ],
121+ sub : Any ,
122+ with_nonce : bool = True ,
123+ with_receiver : bool = True ,
124+ with_data : bool = True ,
126125):
127126 if with_nonce :
128127 sub .add_argument (
@@ -270,6 +269,21 @@ def add_relayed_v3_wallet_args(args: list[str], sub: Any):
270269
271270def add_proxy_arg (sub : Any ):
272271 sub .add_argument ("--proxy" , type = str , help = "🔗 the URL of the proxy" )
272+ sub .add_argument (
273+ "--proxy-headers" ,
274+ nargs = "+" ,
275+ metavar = "KEY=VALUE" ,
276+ help = "custom HTTP headers for proxy requests, e.g. 'Api-Key=mytoken'" ,
277+ )
278+
279+
280+ def parse_proxy_headers (proxy_headers : Optional [list [str ]]) -> dict [str , str ]:
281+ if not proxy_headers :
282+ return {}
283+ for item in proxy_headers :
284+ if "=" not in item :
285+ raise ArgumentsNotProvidedError (f"Invalid proxy header (expected KEY=VALUE): { item !r} " )
286+ return parse_headers_list (proxy_headers )
273287
274288
275289def add_outfile_arg (sub : Any , what : str = "" ):
@@ -302,7 +316,7 @@ def add_token_transfers_args(sub: Any):
302316 "--token-transfers" ,
303317 nargs = "+" ,
304318 help = "token transfers for transfer & execute, as [token, amount] "
305- "E.g. --token-transfers NFT-123456-0a 1 ESDT-987654 100000000" ,
319+ "E.g. --token-transfers NFT-123456-0a 1 ESDT-987654 100000000" ,
306320 )
307321
308322
@@ -843,9 +857,9 @@ def initialize_gas_limit_estimator(args: Any) -> Union[GasLimitEstimator, None]:
843857
844858
845859def set_options_for_hash_signing_if_needed (
846- transaction : Transaction ,
847- guardian : Union [IAccount , None ],
848- relayer : Union [IAccount , None ],
860+ transaction : Transaction ,
861+ guardian : Union [IAccount , None ],
862+ relayer : Union [IAccount , None ],
849863):
850864 transaction_computer = TransactionComputer ()
851865
@@ -858,10 +872,10 @@ def set_options_for_hash_signing_if_needed(
858872
859873
860874def alter_transaction_and_sign_again_if_needed (
861- args : Any ,
862- tx : Transaction ,
863- sender : IAccount ,
864- guardian_and_relayer_data : GuardianRelayerData ,
875+ args : Any ,
876+ tx : Transaction ,
877+ sender : IAccount ,
878+ guardian_and_relayer_data : GuardianRelayerData ,
865879):
866880 initial_tx = deepcopy (tx )
867881
@@ -886,9 +900,9 @@ def alter_transaction_and_sign_again_if_needed(
886900
887901
888902def _alter_version_and_options_if_provided (
889- args : Any ,
890- initial_tx : Transaction ,
891- transaction : Transaction ,
903+ args : Any ,
904+ initial_tx : Transaction ,
905+ transaction : Transaction ,
892906) -> bool :
893907 """Alters the transaction version and options if they are provided in args.
894908 Returns True if any alteration was made, False otherwise.
@@ -913,9 +927,9 @@ def _alter_version_and_options_if_provided(
913927
914928
915929def _sign_transaction (
916- transaction : Transaction ,
917- sender : Optional [IAccount ] = None ,
918- guardian_and_relayer_data : GuardianRelayerData = GuardianRelayerData (),
930+ transaction : Transaction ,
931+ sender : Optional [IAccount ] = None ,
932+ guardian_and_relayer_data : GuardianRelayerData = GuardianRelayerData (),
919933):
920934 signer = SigningWrapper ()
921935 signer .sign_transaction (
0 commit comments