From 4261a8c4d4e9045c0e8aaf9041a2764aaadad0db Mon Sep 17 00:00:00 2001 From: Eric Nordelo Date: Tue, 29 Nov 2022 23:14:19 +0100 Subject: [PATCH 1/3] feat: process calldata --- src/nile/core/account.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/nile/core/account.py b/src/nile/core/account.py index 3d10a196..0b70e6c6 100644 --- a/src/nile/core/account.py +++ b/src/nile/core/account.py @@ -195,6 +195,8 @@ async def deploy_contract( deployer_address or UNIVERSAL_DEPLOYER_ADDRESS ) + max_fee, _, calldata = await self._process_arguments(max_fee, None, calldata) + await deploy_with_deployer( self, contract_name, From 47ca3748e0c5b52d754843aaeddc5e24c377ed5d Mon Sep 17 00:00:00 2001 From: Eric Nordelo Date: Wed, 30 Nov 2022 00:24:58 +0100 Subject: [PATCH 2/3] fix: avoid computing nonce --- src/nile/core/account.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nile/core/account.py b/src/nile/core/account.py index 0b70e6c6..b118378f 100644 --- a/src/nile/core/account.py +++ b/src/nile/core/account.py @@ -195,7 +195,7 @@ async def deploy_contract( deployer_address or UNIVERSAL_DEPLOYER_ADDRESS ) - max_fee, _, calldata = await self._process_arguments(max_fee, None, calldata) + max_fee, _, calldata = await self._process_arguments(max_fee, 0, calldata) await deploy_with_deployer( self, From e1e51334149d9d57e13b6e2884d5f165983c56eb Mon Sep 17 00:00:00 2001 From: Eric Nordelo Date: Wed, 30 Nov 2022 13:10:43 +0100 Subject: [PATCH 3/3] feat: test hex calldata allowance --- tests/commands/test_account.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/commands/test_account.py b/tests/commands/test_account.py index 5d54a284..1a73b318 100644 --- a/tests/commands/test_account.py +++ b/tests/commands/test_account.py @@ -149,18 +149,24 @@ async def test_declare(mock_declare, mock_get_class, mock_hash, mock_deploy): @pytest.mark.parametrize("deployer_address", [None, 0xDE0]) @pytest.mark.parametrize("watch_mode", [None, "debug"]) @pytest.mark.parametrize("abi", [None, "TEST_ABI"]) +@pytest.mark.parametrize("calldata", [["0x123", 456]]) @patch("nile.core.account.deploy_account", return_value=(MOCK_ADDRESS, MOCK_INDEX)) @patch("nile.core.deploy.get_class_hash", return_value=0x434343) @patch("nile.core.account.deploy_with_deployer") async def test_deploy_contract( - mock_deploy_contract, mock_get_class, mock_deploy, abi, watch_mode, deployer_address + mock_deploy_contract, + mock_get_class, + mock_deploy, + calldata, + abi, + watch_mode, + deployer_address, ): account = await Account(KEY, NETWORK) contract_name = "contract" salt = 4 unique = True - calldata = [] alias = "my_contract" max_fee = 1 @@ -180,12 +186,14 @@ async def test_deploy_contract( deployer_address = normalize_number(UNIVERSAL_DEPLOYER_ADDRESS) # Check values are correctly passed to 'deploy_with_deployer' + exp_calldata = [normalize_number(x) for x in calldata] + mock_deploy_contract.assert_called_with( account, contract_name, salt, unique, - calldata, + exp_calldata, alias, deployer_address, max_fee,