Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

Commit

Permalink
Allow hex params in calldata for deployments through Account (#318)
Browse files Browse the repository at this point in the history
* feat: process calldata

* fix: avoid computing nonce

* feat: test hex calldata allowance
  • Loading branch information
ericnordelo authored Dec 1, 2022
1 parent 6643bcd commit e57aaf9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/nile/core/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ async def deploy_contract(
deployer_address or UNIVERSAL_DEPLOYER_ADDRESS
)

max_fee, _, calldata = await self._process_arguments(max_fee, 0, calldata)

await deploy_with_deployer(
self,
contract_name,
Expand Down
7 changes: 5 additions & 2 deletions tests/commands/test_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ 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]])
@pytest.mark.parametrize("overriding_path", [None, PATH])
@patch("nile.core.account.deploy_account", return_value=(MOCK_ADDRESS, MOCK_INDEX))
@patch("nile.core.deploy.get_class_hash", return_value=0x434343)
Expand All @@ -160,6 +161,7 @@ async def test_deploy_contract(
mock_get_class,
mock_deploy,
overriding_path,
calldata,
abi,
watch_mode,
deployer_address,
Expand All @@ -169,7 +171,6 @@ async def test_deploy_contract(
contract_name = "contract"
salt = 4
unique = True
calldata = []
alias = "my_contract"
max_fee = 1

Expand All @@ -190,12 +191,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,
Expand Down

0 comments on commit e57aaf9

Please sign in to comment.