From 6fe877f69984312793ffb906f3f96a2ded6e453d Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Thu, 11 Jan 2024 11:17:40 +0200 Subject: [PATCH] fixes --- multiversx_sdk_cli/cli_contracts.py | 2 +- multiversx_sdk_cli/contracts.py | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/multiversx_sdk_cli/cli_contracts.py b/multiversx_sdk_cli/cli_contracts.py index 829e3732..53cdf3db 100644 --- a/multiversx_sdk_cli/cli_contracts.py +++ b/multiversx_sdk_cli/cli_contracts.py @@ -227,7 +227,7 @@ def _add_contract_arg(sub: Any): def _add_function_arg(sub: Any): - sub.add_argument("--function", required=True, help="the function to call") + sub.add_argument("--function", required=True, type=str, help="the function to call") def _add_arguments_arg(sub: Any): diff --git a/multiversx_sdk_cli/contracts.py b/multiversx_sdk_cli/contracts.py index f7628c0a..251ffbae 100644 --- a/multiversx_sdk_cli/contracts.py +++ b/multiversx_sdk_cli/contracts.py @@ -1,7 +1,7 @@ import base64 import logging from pathlib import Path -from typing import Any, List, Optional, Protocol, Sequence +from typing import Any, List, Optional, Protocol, Sequence, Union from multiversx_sdk_core import (Token, TokenComputer, TokenTransfer, Transaction, TransactionPayload) @@ -79,7 +79,7 @@ def __init__(self, config: IConfig): def prepare_deploy_transaction(self, owner: Account, bytecode: Path, - arguments: List[str], + arguments: Union[List[str], None], upgradeable: bool, readable: bool, payable: bool, @@ -90,11 +90,13 @@ def prepare_deploy_transaction(self, version: int, options: int, guardian: str) -> Transaction: + args = prepare_args_for_factory(arguments) if arguments else [] + tx = self._factory.create_transaction_for_deploy( sender=owner.address, bytecode=bytecode, gas_limit=gas_limit, - arguments=prepare_args_for_factory(arguments), + arguments=args, native_transfer_amount=value, is_upgradeable=upgradeable, is_readable=readable, @@ -113,22 +115,23 @@ def prepare_execute_transaction(self, caller: Account, contract: Address, function: str, - arguments: List[str], + arguments: Union[List[str], None], gas_limit: int, value: int, - transfers: List[str], + transfers: Union[List[str], None], nonce: int, version: int, options: int, guardian: str) -> Transaction: token_transfers = self._prepare_token_transfers(transfers) if transfers else [] + args = prepare_args_for_factory(arguments) if arguments else [] tx = self._factory.create_transaction_for_execute( sender=caller.address, contract=contract, function=function, gas_limit=gas_limit, - arguments=prepare_args_for_factory(arguments), + arguments=args, native_transfer_amount=value, token_transfers=token_transfers ) @@ -144,7 +147,7 @@ def prepare_upgrade_transaction(self, owner: Account, contract: IAddress, bytecode: Path, - arguments: List[str], + arguments: Union[List[str], None], upgradeable: bool, readable: bool, payable: bool, @@ -155,14 +158,14 @@ def prepare_upgrade_transaction(self, version: int, options: int, guardian: str) -> Transaction: - arguments = prepare_args_for_factory(arguments) + args = prepare_args_for_factory(arguments) if arguments else [] tx = self._factory.create_transaction_for_upgrade( sender=owner.address, contract=contract, bytecode=bytecode, gas_limit=gas_limit, - arguments=arguments, + arguments=args, native_transfer_amount=value, is_upgradeable=upgradeable, is_readable=readable,