Skip to content

Commit

Permalink
first part of fixes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
popenta committed Nov 24, 2023
1 parent b030c13 commit 8064660
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
4 changes: 2 additions & 2 deletions multiversx_sdk_cli/contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,15 @@ def query_contract(
function: str,
arguments: List[Any],
value: int = 0,
caller: Optional[Address] = None
caller: Optional[IAddress] = None
) -> List[Any]:
response_data = query_detailed(contract_address, proxy, function, arguments, value, caller)
return_data = response_data.return_data
return [_interpret_return_data(data) for data in return_data]


def query_detailed(contract_address: IAddress, proxy: INetworkProvider, function: str, arguments: List[Any],
value: int = 0, caller: Optional[Address] = None) -> Any:
value: int = 0, caller: Optional[IAddress] = None) -> Any:
arguments = arguments or []
# Temporary workaround, until we use sdk-core's serializer.
prepared_arguments = [bytes.fromhex(_prepare_argument(arg)) for arg in arguments]
Expand Down
19 changes: 18 additions & 1 deletion multiversx_sdk_cli/tests/test_contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
from multiversx_sdk_cli.accounts import Account
from multiversx_sdk_cli.contract_verification import _create_request_signature
from multiversx_sdk_cli.contracts import (_interpret_as_number_if_safely,
_prepare_argument)
_prepare_argument,
prepare_args_for_factory)

logging.basicConfig(level=logging.INFO)

Expand Down Expand Up @@ -66,3 +67,19 @@ def test_interpret_as_number_if_safely():
assert _interpret_as_number_if_safely("") == 0
assert _interpret_as_number_if_safely("0x5") == 5
assert _interpret_as_number_if_safely("FF") == 255


def test_prepare_args_for_factories():
args = [
"0x5", "123", "false", "true",
"str:test-string",
"erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th"
]

arguments = prepare_args_for_factory(args)
assert arguments[0] == b"\x05"
assert arguments[1] == 123
assert arguments[2] == False
assert arguments[3] == True
assert arguments[4] == "test-string"
assert arguments[5].to_bech32() == "erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th"

0 comments on commit 8064660

Please sign in to comment.