From 8bb500d1d5d2f9b3465f39d9f0cc8ba93c0ad770 Mon Sep 17 00:00:00 2001 From: kkawula <57270771+kkawula@users.noreply.github.com> Date: Tue, 3 Sep 2024 09:46:07 +0200 Subject: [PATCH 01/27] Rename 'fee_contract_abi' -> 'cairo_0_fee_contract_abi' --- starknet_py/tests/e2e/fixtures/contracts.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/starknet_py/tests/e2e/fixtures/contracts.py b/starknet_py/tests/e2e/fixtures/contracts.py index cb777d608..374ab27d8 100644 --- a/starknet_py/tests/e2e/fixtures/contracts.py +++ b/starknet_py/tests/e2e/fixtures/contracts.py @@ -92,35 +92,35 @@ async def deploy_v1_contract( @pytest.fixture(scope="package") -def eth_fee_contract(account: BaseAccount, fee_contract_abi) -> Contract: +def eth_fee_contract(account: BaseAccount, cairo_0_fee_contract_abi) -> Contract: """ Returns an instance of the ETH fee contract. It is used to transfer tokens. """ return Contract( address=FEE_CONTRACT_ADDRESS, - abi=fee_contract_abi, + abi=cairo_0_fee_contract_abi, provider=account, cairo_version=0, ) @pytest.fixture(scope="package") -def strk_fee_contract(account: BaseAccount, fee_contract_abi) -> Contract: +def strk_fee_contract(account: BaseAccount, cairo_0_fee_contract_abi) -> Contract: """ Returns an instance of the STRK fee contract. It is used to transfer tokens. """ return Contract( address=STRK_FEE_CONTRACT_ADDRESS, - abi=fee_contract_abi, + abi=cairo_0_fee_contract_abi, provider=account, cairo_version=0, ) @pytest.fixture(scope="package") -def fee_contract_abi(): +def cairo_0_fee_contract_abi(): return [ { "inputs": [ From b2dbfa83bebc3141cd44fcda2eebd6cac3aeeaa1 Mon Sep 17 00:00:00 2001 From: kkawula <57270771+kkawula@users.noreply.github.com> Date: Tue, 3 Sep 2024 09:49:33 +0200 Subject: [PATCH 02/27] Rename 'cairo_1_erc20_class_hash' -> 'erc20_class_hash' --- .../tests/e2e/contract_interaction/v1_interaction_test.py | 8 ++++---- .../tests/e2e/docs/guide/test_simple_deploy_cairo1.py | 4 ++-- starknet_py/tests/e2e/fixtures/contracts_v1.py | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/starknet_py/tests/e2e/contract_interaction/v1_interaction_test.py b/starknet_py/tests/e2e/contract_interaction/v1_interaction_test.py index 20987836e..61683300d 100644 --- a/starknet_py/tests/e2e/contract_interaction/v1_interaction_test.py +++ b/starknet_py/tests/e2e/contract_interaction/v1_interaction_test.py @@ -15,7 +15,7 @@ reason="Contract exists only in v2 directory", ) @pytest.mark.asyncio -async def test_general_v1_interaction(account, cairo1_erc20_class_hash: int): +async def test_general_v1_interaction(account, erc20_class_hash: int): calldata = { "name_": encode_shortstring("erc20_basic"), "symbol_": encode_shortstring("ERC20B"), @@ -26,7 +26,7 @@ async def test_general_v1_interaction(account, cairo1_erc20_class_hash: int): erc20 = await deploy_v1_contract( account=account, contract_name="ERC20", - class_hash=cairo1_erc20_class_hash, + class_hash=erc20_class_hash, calldata=calldata, ) @@ -153,7 +153,7 @@ async def test_serializing_enum(account, cairo1_test_enum_class_hash: int): reason="Contract exists only in v2 directory", ) @pytest.mark.asyncio -async def test_from_address_on_v1_contract(account, cairo1_erc20_class_hash: int): +async def test_from_address_on_v1_contract(account, erc20_class_hash: int): calldata = { "name_": encode_shortstring("erc20_basic"), "symbol_": encode_shortstring("ERC20B"), @@ -164,7 +164,7 @@ async def test_from_address_on_v1_contract(account, cairo1_erc20_class_hash: int erc20 = await deploy_v1_contract( account=account, contract_name="ERC20", - class_hash=cairo1_erc20_class_hash, + class_hash=erc20_class_hash, calldata=calldata, ) diff --git a/starknet_py/tests/e2e/docs/guide/test_simple_deploy_cairo1.py b/starknet_py/tests/e2e/docs/guide/test_simple_deploy_cairo1.py index 9ad852dce..956ef3432 100644 --- a/starknet_py/tests/e2e/docs/guide/test_simple_deploy_cairo1.py +++ b/starknet_py/tests/e2e/docs/guide/test_simple_deploy_cairo1.py @@ -11,7 +11,7 @@ reason="Some cairo 1 contracts compiled with v1 compiler fail with new devnet-rs - test simply for a code example.", ) @pytest.mark.asyncio -async def test_simple_deploy_cairo1(account, cairo1_erc20_class_hash): +async def test_simple_deploy_cairo1(account, erc20_class_hash): # pylint: disable=import-outside-toplevel # docs: start from starknet_py.cairo.felt import encode_shortstring @@ -24,7 +24,7 @@ async def test_simple_deploy_cairo1(account, cairo1_erc20_class_hash): contract_name="ERC20", version=ContractVersion.V2 )["sierra"] - class_hash = cairo1_erc20_class_hash + class_hash = erc20_class_hash # docs: start abi = create_sierra_compiled_contract( diff --git a/starknet_py/tests/e2e/fixtures/contracts_v1.py b/starknet_py/tests/e2e/fixtures/contracts_v1.py index 360aa1d9e..87b418c01 100644 --- a/starknet_py/tests/e2e/fixtures/contracts_v1.py +++ b/starknet_py/tests/e2e/fixtures/contracts_v1.py @@ -34,7 +34,7 @@ async def declare_cairo1_contract( @pytest_asyncio.fixture(scope="package") -async def cairo1_erc20_class_hash(account: BaseAccount) -> int: +async def erc20_class_hash(account: BaseAccount) -> int: contract = load_contract("ERC20") class_hash, _ = await declare_cairo1_contract( account, contract["sierra"], contract["casm"] @@ -155,7 +155,7 @@ async def cairo1_token_bridge_class_hash(account: BaseAccount) -> int: @pytest_asyncio.fixture(scope="package", name="erc20_contract") -async def cairo1_erc20_deploy(account, cairo1_erc20_class_hash): +async def cairo1_erc20_deploy(account, erc20_class_hash): calldata = { "name_": encode_shortstring("erc20_basic"), "symbol_": encode_shortstring("ERC20B"), @@ -166,7 +166,7 @@ async def cairo1_erc20_deploy(account, cairo1_erc20_class_hash): return await deploy_v1_contract( account=account, contract_name="ERC20", - class_hash=cairo1_erc20_class_hash, + class_hash=erc20_class_hash, calldata=calldata, ) From f458a248be524d09579099ad4fb75fef4e35fe30 Mon Sep 17 00:00:00 2001 From: kkawula <57270771+kkawula@users.noreply.github.com> Date: Tue, 3 Sep 2024 09:51:46 +0200 Subject: [PATCH 03/27] Rename 'cairo1_token_bridge_class_hash' -> 'token_bridge_class_hash' --- .../tests/e2e/contract_interaction/v1_interaction_test.py | 4 ++-- starknet_py/tests/e2e/fixtures/contracts_v1.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/starknet_py/tests/e2e/contract_interaction/v1_interaction_test.py b/starknet_py/tests/e2e/contract_interaction/v1_interaction_test.py index 61683300d..c44d42642 100644 --- a/starknet_py/tests/e2e/contract_interaction/v1_interaction_test.py +++ b/starknet_py/tests/e2e/contract_interaction/v1_interaction_test.py @@ -61,11 +61,11 @@ async def test_general_v1_interaction(account, erc20_class_hash: int): reason="Contract exists only in v2 directory", ) @pytest.mark.asyncio -async def test_serializing_struct(account, cairo1_token_bridge_class_hash: int): +async def test_serializing_struct(account, token_bridge_class_hash: int): bridge = await deploy_v1_contract( account=account, contract_name="TokenBridge", - class_hash=cairo1_token_bridge_class_hash, + class_hash=token_bridge_class_hash, calldata={"governor_address": account.address}, ) diff --git a/starknet_py/tests/e2e/fixtures/contracts_v1.py b/starknet_py/tests/e2e/fixtures/contracts_v1.py index 87b418c01..d5f678c28 100644 --- a/starknet_py/tests/e2e/fixtures/contracts_v1.py +++ b/starknet_py/tests/e2e/fixtures/contracts_v1.py @@ -144,7 +144,7 @@ async def cairo1_test_option_class_hash(account: BaseAccount) -> int: @pytest_asyncio.fixture(scope="package") -async def cairo1_token_bridge_class_hash(account: BaseAccount) -> int: +async def token_bridge_class_hash(account: BaseAccount) -> int: contract = load_contract(contract_name="TokenBridge") class_hash, _ = await declare_cairo1_contract( account, From 212393f494d5a76da9caf41ea02396e3743587d2 Mon Sep 17 00:00:00 2001 From: kkawula <57270771+kkawula@users.noreply.github.com> Date: Tue, 3 Sep 2024 09:52:23 +0200 Subject: [PATCH 04/27] Rename 'cairo1_test_option_class_hash' -> 'test_option_class_hash' --- .../tests/e2e/contract_interaction/v1_interaction_test.py | 4 ++-- starknet_py/tests/e2e/fixtures/contracts_v1.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/starknet_py/tests/e2e/contract_interaction/v1_interaction_test.py b/starknet_py/tests/e2e/contract_interaction/v1_interaction_test.py index c44d42642..bc31a1083 100644 --- a/starknet_py/tests/e2e/contract_interaction/v1_interaction_test.py +++ b/starknet_py/tests/e2e/contract_interaction/v1_interaction_test.py @@ -77,11 +77,11 @@ async def test_serializing_struct(account, token_bridge_class_hash: int): @pytest.mark.asyncio -async def test_serializing_option(account, cairo1_test_option_class_hash: int): +async def test_serializing_option(account, test_option_class_hash: int): test_option = await deploy_v1_contract( account=account, contract_name="TestOption", - class_hash=cairo1_test_option_class_hash, + class_hash=test_option_class_hash, ) (received_option,) = await test_option.functions["get_option_struct"].call() diff --git a/starknet_py/tests/e2e/fixtures/contracts_v1.py b/starknet_py/tests/e2e/fixtures/contracts_v1.py index d5f678c28..2f0f31937 100644 --- a/starknet_py/tests/e2e/fixtures/contracts_v1.py +++ b/starknet_py/tests/e2e/fixtures/contracts_v1.py @@ -133,7 +133,7 @@ async def cairo1_test_enum_class_hash(account: BaseAccount) -> int: @pytest_asyncio.fixture(scope="package") -async def cairo1_test_option_class_hash(account: BaseAccount) -> int: +async def test_option_class_hash(account: BaseAccount) -> int: contract = load_contract(contract_name="TestOption") class_hash, _ = await declare_cairo1_contract( account, From beeb41b90de6ea7c41370d943d9a4e465c5472c5 Mon Sep 17 00:00:00 2001 From: kkawula <57270771+kkawula@users.noreply.github.com> Date: Tue, 3 Sep 2024 09:52:57 +0200 Subject: [PATCH 05/27] Rename 'cairo1_test_enum_class_hash' -> 'test_enum_class_hash' --- .../tests/e2e/contract_interaction/v1_interaction_test.py | 4 ++-- starknet_py/tests/e2e/fixtures/contracts_v1.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/starknet_py/tests/e2e/contract_interaction/v1_interaction_test.py b/starknet_py/tests/e2e/contract_interaction/v1_interaction_test.py index bc31a1083..5d587ef89 100644 --- a/starknet_py/tests/e2e/contract_interaction/v1_interaction_test.py +++ b/starknet_py/tests/e2e/contract_interaction/v1_interaction_test.py @@ -112,11 +112,11 @@ async def test_serializing_option(account, test_option_class_hash: int): @pytest.mark.asyncio -async def test_serializing_enum(account, cairo1_test_enum_class_hash: int): +async def test_serializing_enum(account, test_enum_class_hash: int): test_enum = await deploy_v1_contract( account=account, contract_name="TestEnum", - class_hash=cairo1_test_enum_class_hash, + class_hash=test_enum_class_hash, ) (received_enum,) = await test_enum.functions["get_enum"].call() diff --git a/starknet_py/tests/e2e/fixtures/contracts_v1.py b/starknet_py/tests/e2e/fixtures/contracts_v1.py index 2f0f31937..426c57774 100644 --- a/starknet_py/tests/e2e/fixtures/contracts_v1.py +++ b/starknet_py/tests/e2e/fixtures/contracts_v1.py @@ -122,7 +122,7 @@ async def cairo1_minimal_contract_class_hash(account: BaseAccount) -> int: @pytest_asyncio.fixture(scope="package") -async def cairo1_test_enum_class_hash(account: BaseAccount) -> int: +async def test_enum_class_hash(account: BaseAccount) -> int: contract = load_contract(contract_name="TestEnum") class_hash, _ = await declare_cairo1_contract( account, From a92c713785e89f48a6450d236afbc626e542b397 Mon Sep 17 00:00:00 2001 From: kkawula <57270771+kkawula@users.noreply.github.com> Date: Tue, 3 Sep 2024 09:55:09 +0200 Subject: [PATCH 06/27] Rename 'cairo_1_hello_starknet_class_hash_tx_hash' -> 'hello_starknet_class_hash_tx_hash' --- starknet_py/tests/e2e/client/client_test.py | 8 ++++---- starknet_py/tests/e2e/fixtures/contracts_v1.py | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/starknet_py/tests/e2e/client/client_test.py b/starknet_py/tests/e2e/client/client_test.py index 7b7131eec..a0d5f5d3f 100644 --- a/starknet_py/tests/e2e/client/client_test.py +++ b/starknet_py/tests/e2e/client/client_test.py @@ -543,10 +543,10 @@ async def test_get_class_by_hash_sierra_program( @pytest.mark.asyncio async def test_get_declare_v2_transaction( client, - cairo1_hello_starknet_class_hash_tx_hash: Tuple[int, int], + hello_starknet_class_hash_tx_hash, declare_v2_hello_starknet: DeclareV2, ): - (class_hash, tx_hash) = cairo1_hello_starknet_class_hash_tx_hash + (class_hash, tx_hash) = hello_starknet_class_hash_tx_hash transaction = await client.get_transaction(tx_hash=tx_hash) @@ -566,11 +566,11 @@ async def test_get_declare_v2_transaction( @pytest.mark.asyncio async def test_get_block_with_declare_v2( client, - cairo1_hello_starknet_class_hash_tx_hash: Tuple[int, int], + hello_starknet_class_hash_tx_hash, declare_v2_hello_starknet: DeclareV2, block_with_declare_v2_number: int, ): - (class_hash, tx_hash) = cairo1_hello_starknet_class_hash_tx_hash + (class_hash, tx_hash) = hello_starknet_class_hash_tx_hash block = await client.get_block(block_number=block_with_declare_v2_number) diff --git a/starknet_py/tests/e2e/fixtures/contracts_v1.py b/starknet_py/tests/e2e/fixtures/contracts_v1.py index 426c57774..b990e0030 100644 --- a/starknet_py/tests/e2e/fixtures/contracts_v1.py +++ b/starknet_py/tests/e2e/fixtures/contracts_v1.py @@ -75,7 +75,7 @@ async def declare_v2_hello_starknet(account: BaseAccount) -> DeclareV2: @pytest_asyncio.fixture(scope="package") -async def cairo1_hello_starknet_class_hash_tx_hash( +async def hello_starknet_class_hash_tx_hash( account: BaseAccount, declare_v2_hello_starknet: DeclareV2 ) -> Tuple[int, int]: resp = await account.client.declare(declare_v2_hello_starknet) @@ -96,17 +96,17 @@ async def cairo1_hello_starknet_abi() -> List: @pytest.fixture(scope="package") def cairo1_hello_starknet_class_hash( - cairo1_hello_starknet_class_hash_tx_hash: Tuple[int, int] + hello_starknet_class_hash_tx_hash ) -> int: - class_hash, _ = cairo1_hello_starknet_class_hash_tx_hash + class_hash, _ = hello_starknet_class_hash_tx_hash return class_hash @pytest.fixture(scope="package") def cairo1_hello_starknet_tx_hash( - cairo1_hello_starknet_class_hash_tx_hash: Tuple[int, int] + hello_starknet_class_hash_tx_hash ) -> int: - _, tx_hash = cairo1_hello_starknet_class_hash_tx_hash + _, tx_hash = hello_starknet_class_hash_tx_hash return tx_hash From c902a012f2520812fc3585159411f1dab8765236 Mon Sep 17 00:00:00 2001 From: kkawula <57270771+kkawula@users.noreply.github.com> Date: Tue, 3 Sep 2024 09:56:50 +0200 Subject: [PATCH 07/27] Rename 'cairo_1hello_starknet_class_hash' -> 'hello_starknet_class_hash' --- starknet_py/tests/e2e/account/account_test.py | 4 ++-- starknet_py/tests/e2e/client/client_test.py | 13 ++++++------- .../tests/e2e/client/fixtures/transactions.py | 4 ++-- .../tests/e2e/contract_interaction/deploy_test.py | 6 +++--- .../tests/e2e/docs/code_examples/test_contract.py | 12 ++++++------ .../tests/e2e/docs/guide/test_simple_deploy.py | 4 ++-- starknet_py/tests/e2e/fixtures/contracts_v1.py | 12 ++++-------- 7 files changed, 25 insertions(+), 30 deletions(-) diff --git a/starknet_py/tests/e2e/account/account_test.py b/starknet_py/tests/e2e/account/account_test.py index 5b1464c78..c63228fd0 100644 --- a/starknet_py/tests/e2e/account/account_test.py +++ b/starknet_py/tests/e2e/account/account_test.py @@ -703,8 +703,8 @@ async def test_sign_deploy_account_v1_for_fee_estimation( @pytest.mark.asyncio -async def test_sign_transaction_custom_nonce(account, cairo1_hello_starknet_class_hash): - deployment = Deployer().create_contract_deployment(cairo1_hello_starknet_class_hash) +async def test_sign_transaction_custom_nonce(account, hello_starknet_class_hash): + deployment = Deployer().create_contract_deployment(hello_starknet_class_hash) deploy_tx = await account.sign_invoke_v1(deployment.call, max_fee=MAX_FEE) new_balance = 30 diff --git a/starknet_py/tests/e2e/client/client_test.py b/starknet_py/tests/e2e/client/client_test.py index a0d5f5d3f..96d74c905 100644 --- a/starknet_py/tests/e2e/client/client_test.py +++ b/starknet_py/tests/e2e/client/client_test.py @@ -1,5 +1,4 @@ # pylint: disable=too-many-arguments -from typing import Tuple from unittest.mock import AsyncMock, Mock, patch import pytest @@ -526,10 +525,10 @@ async def test_state_update_deployed_contracts( @pytest.mark.asyncio async def test_get_class_by_hash_sierra_program( - client, cairo1_hello_starknet_class_hash: int + client, hello_starknet_class_hash: int ): contract_class = await client.get_class_by_hash( - class_hash=cairo1_hello_starknet_class_hash + class_hash=hello_starknet_class_hash ) assert isinstance(contract_class.parsed_abi, list) @@ -543,7 +542,7 @@ async def test_get_class_by_hash_sierra_program( @pytest.mark.asyncio async def test_get_declare_v2_transaction( client, - hello_starknet_class_hash_tx_hash, + hello_starknet_class_hash_tx_hash, declare_v2_hello_starknet: DeclareV2, ): (class_hash, tx_hash) = hello_starknet_class_hash_tx_hash @@ -566,7 +565,7 @@ async def test_get_declare_v2_transaction( @pytest.mark.asyncio async def test_get_block_with_declare_v2( client, - hello_starknet_class_hash_tx_hash, + hello_starknet_class_hash_tx_hash, declare_v2_hello_starknet: DeclareV2, block_with_declare_v2_number: int, ): @@ -593,7 +592,7 @@ async def test_get_block_with_declare_v2( @pytest.mark.asyncio async def test_get_new_state_update( client, - cairo1_hello_starknet_class_hash: int, + hello_starknet_class_hash: int, declare_v2_hello_starknet: DeclareV2, block_with_declare_v2_number: int, ): @@ -603,7 +602,7 @@ async def test_get_new_state_update( assert state_update_first.state_diff.replaced_classes == [] assert ( DeclaredContractHash( - class_hash=cairo1_hello_starknet_class_hash, + class_hash=hello_starknet_class_hash, compiled_class_hash=declare_v2_hello_starknet.compiled_class_hash, ) in state_update_first.state_diff.declared_classes diff --git a/starknet_py/tests/e2e/client/fixtures/transactions.py b/starknet_py/tests/e2e/client/fixtures/transactions.py index 6ac67e52a..0e1c55085 100644 --- a/starknet_py/tests/e2e/client/fixtures/transactions.py +++ b/starknet_py/tests/e2e/client/fixtures/transactions.py @@ -68,11 +68,11 @@ def block_with_deploy_account_number( @pytest_asyncio.fixture(scope="package") async def hello_starknet_deploy_transaction_address( - account: Account, cairo1_hello_starknet_class_hash + account: Account, hello_starknet_class_hash ) -> int: deployer = Deployer() contract_deployment = deployer.create_contract_deployment_raw( - class_hash=cairo1_hello_starknet_class_hash + class_hash=hello_starknet_class_hash ) deploy_invoke_transaction = await account.sign_invoke_v1( calls=contract_deployment.call, max_fee=MAX_FEE diff --git a/starknet_py/tests/e2e/contract_interaction/deploy_test.py b/starknet_py/tests/e2e/contract_interaction/deploy_test.py index 72c20100a..7896796c7 100644 --- a/starknet_py/tests/e2e/contract_interaction/deploy_test.py +++ b/starknet_py/tests/e2e/contract_interaction/deploy_test.py @@ -94,14 +94,14 @@ async def test_throws_on_wrong_abi(account, cairo1_minimal_contract_class_hash: @pytest.mark.asyncio -async def test_deploy_contract_v1(account, cairo1_hello_starknet_class_hash: int): +async def test_deploy_contract_v1(account, hello_starknet_class_hash: int): compiled_contract = load_contract("HelloStarknet")["sierra"] abi = create_sierra_compiled_contract( compiled_contract=compiled_contract ).parsed_abi deploy_result = await Contract.deploy_contract_v1( - class_hash=cairo1_hello_starknet_class_hash, + class_hash=hello_starknet_class_hash, account=account, abi=abi, max_fee=MAX_FEE, @@ -120,4 +120,4 @@ async def test_deploy_contract_v1(account, cairo1_hello_starknet_class_hash: int class_hash = await account.client.get_class_hash_at( contract_address=contract.address ) - assert class_hash == cairo1_hello_starknet_class_hash + assert class_hash == hello_starknet_class_hash diff --git a/starknet_py/tests/e2e/docs/code_examples/test_contract.py b/starknet_py/tests/e2e/docs/code_examples/test_contract.py index b5a911a4c..d37c552ac 100644 --- a/starknet_py/tests/e2e/docs/code_examples/test_contract.py +++ b/starknet_py/tests/e2e/docs/code_examples/test_contract.py @@ -134,14 +134,14 @@ async def test_deploy_contract_v1(account, class_hash): @pytest.mark.asyncio -async def test_deploy_contract_v3(account, cairo1_hello_starknet_class_hash: int): +async def test_deploy_contract_v3(account, hello_starknet_class_hash: int): compiled_contract = load_contract("HelloStarknet")["sierra"] # docs-start: deploy_contract_v3 abi = create_sierra_compiled_contract( compiled_contract=compiled_contract ).parsed_abi # docs-end: deploy_contract_v3 - class_hash = cairo1_hello_starknet_class_hash + class_hash = hello_starknet_class_hash # docs-start: deploy_contract_v3 deploy_result = await Contract.deploy_contract_v3( class_hash=class_hash, @@ -164,15 +164,15 @@ async def test_deploy_contract_v3(account, cairo1_hello_starknet_class_hash: int class_hash = await account.client.get_class_hash_at( contract_address=contract.address ) - assert class_hash == cairo1_hello_starknet_class_hash + assert class_hash == hello_starknet_class_hash @pytest.mark.asyncio async def test_deploy_contract_v3_without_abi( - account, cairo1_hello_starknet_class_hash: int + account, hello_starknet_class_hash: int ): deploy_result = await Contract.deploy_contract_v3( - class_hash=cairo1_hello_starknet_class_hash, + class_hash=hello_starknet_class_hash, account=account, l1_resource_bounds=ResourceBounds( max_amount=int(1e5), max_price_per_unit=int(1e13) @@ -190,4 +190,4 @@ async def test_deploy_contract_v3_without_abi( class_hash = await account.client.get_class_hash_at( contract_address=contract.address ) - assert class_hash == cairo1_hello_starknet_class_hash + assert class_hash == hello_starknet_class_hash diff --git a/starknet_py/tests/e2e/docs/guide/test_simple_deploy.py b/starknet_py/tests/e2e/docs/guide/test_simple_deploy.py index eee8ac93f..ddc325777 100644 --- a/starknet_py/tests/e2e/docs/guide/test_simple_deploy.py +++ b/starknet_py/tests/e2e/docs/guide/test_simple_deploy.py @@ -5,7 +5,7 @@ @pytest.mark.asyncio async def test_simple_deploy( - account, cairo1_hello_starknet_class_hash, cairo1_hello_starknet_abi + account, hello_starknet_class_hash, cairo1_hello_starknet_abi ): # pylint: disable=import-outside-toplevel # docs: start @@ -13,7 +13,7 @@ async def test_simple_deploy( # docs: end - class_hash = cairo1_hello_starknet_class_hash + class_hash = hello_starknet_class_hash abi = cairo1_hello_starknet_abi # docs: start diff --git a/starknet_py/tests/e2e/fixtures/contracts_v1.py b/starknet_py/tests/e2e/fixtures/contracts_v1.py index b990e0030..3b2ab8b7a 100644 --- a/starknet_py/tests/e2e/fixtures/contracts_v1.py +++ b/starknet_py/tests/e2e/fixtures/contracts_v1.py @@ -95,17 +95,13 @@ async def cairo1_hello_starknet_abi() -> List: @pytest.fixture(scope="package") -def cairo1_hello_starknet_class_hash( - hello_starknet_class_hash_tx_hash -) -> int: +def hello_starknet_class_hash(hello_starknet_class_hash_tx_hash) -> int: class_hash, _ = hello_starknet_class_hash_tx_hash return class_hash @pytest.fixture(scope="package") -def cairo1_hello_starknet_tx_hash( - hello_starknet_class_hash_tx_hash -) -> int: +def cairo1_hello_starknet_tx_hash(hello_starknet_class_hash_tx_hash) -> int: _, tx_hash = hello_starknet_class_hash_tx_hash return tx_hash @@ -173,12 +169,12 @@ async def cairo1_erc20_deploy(account, erc20_class_hash): @pytest_asyncio.fixture(scope="package", name="hello_starknet_contract") async def cairo1_hello_starknet_deploy( - account: BaseAccount, cairo1_hello_starknet_class_hash + account: BaseAccount, hello_starknet_class_hash ): return await deploy_v1_contract( account=account, contract_name="HelloStarknet", - class_hash=cairo1_hello_starknet_class_hash, + class_hash=hello_starknet_class_hash, ) From 4963af7574da198b92f04d73602a874c4a79f95e Mon Sep 17 00:00:00 2001 From: kkawula <57270771+kkawula@users.noreply.github.com> Date: Tue, 3 Sep 2024 09:57:40 +0200 Subject: [PATCH 08/27] Rename 'cairo_1_hello_starknet_tx_hash' -> 'hello_starknet_tx_hash' --- starknet_py/tests/e2e/client/client_test.py | 6 ++---- starknet_py/tests/e2e/client/fixtures/transactions.py | 8 ++------ starknet_py/tests/e2e/docs/code_examples/test_contract.py | 4 +--- starknet_py/tests/e2e/fixtures/contracts_v1.py | 6 ++---- 4 files changed, 7 insertions(+), 17 deletions(-) diff --git a/starknet_py/tests/e2e/client/client_test.py b/starknet_py/tests/e2e/client/client_test.py index 96d74c905..d40b22e63 100644 --- a/starknet_py/tests/e2e/client/client_test.py +++ b/starknet_py/tests/e2e/client/client_test.py @@ -524,9 +524,7 @@ async def test_state_update_deployed_contracts( @pytest.mark.asyncio -async def test_get_class_by_hash_sierra_program( - client, hello_starknet_class_hash: int -): +async def test_get_class_by_hash_sierra_program(client, hello_starknet_class_hash: int): contract_class = await client.get_class_by_hash( class_hash=hello_starknet_class_hash ) @@ -592,7 +590,7 @@ async def test_get_block_with_declare_v2( @pytest.mark.asyncio async def test_get_new_state_update( client, - hello_starknet_class_hash: int, + hello_starknet_class_hash: int, declare_v2_hello_starknet: DeclareV2, block_with_declare_v2_number: int, ): diff --git a/starknet_py/tests/e2e/client/fixtures/transactions.py b/starknet_py/tests/e2e/client/fixtures/transactions.py index 0e1c55085..f7d659844 100644 --- a/starknet_py/tests/e2e/client/fixtures/transactions.py +++ b/starknet_py/tests/e2e/client/fixtures/transactions.py @@ -83,13 +83,9 @@ async def hello_starknet_deploy_transaction_address( @pytest_asyncio.fixture(scope="package") -async def block_with_declare_v2_number( - cairo1_hello_starknet_tx_hash: int, client -) -> int: +async def block_with_declare_v2_number(hello_starknet_tx_hash: int, client) -> int: """ Returns number of the block with DeclareV2 transaction """ - declare_v2_receipt = await client.get_transaction_receipt( - cairo1_hello_starknet_tx_hash - ) + declare_v2_receipt = await client.get_transaction_receipt(hello_starknet_tx_hash) return declare_v2_receipt.block_number diff --git a/starknet_py/tests/e2e/docs/code_examples/test_contract.py b/starknet_py/tests/e2e/docs/code_examples/test_contract.py index d37c552ac..02a26220d 100644 --- a/starknet_py/tests/e2e/docs/code_examples/test_contract.py +++ b/starknet_py/tests/e2e/docs/code_examples/test_contract.py @@ -168,9 +168,7 @@ async def test_deploy_contract_v3(account, hello_starknet_class_hash: int): @pytest.mark.asyncio -async def test_deploy_contract_v3_without_abi( - account, hello_starknet_class_hash: int -): +async def test_deploy_contract_v3_without_abi(account, hello_starknet_class_hash: int): deploy_result = await Contract.deploy_contract_v3( class_hash=hello_starknet_class_hash, account=account, diff --git a/starknet_py/tests/e2e/fixtures/contracts_v1.py b/starknet_py/tests/e2e/fixtures/contracts_v1.py index 3b2ab8b7a..4c5e1cbe5 100644 --- a/starknet_py/tests/e2e/fixtures/contracts_v1.py +++ b/starknet_py/tests/e2e/fixtures/contracts_v1.py @@ -101,7 +101,7 @@ def hello_starknet_class_hash(hello_starknet_class_hash_tx_hash) -> int: @pytest.fixture(scope="package") -def cairo1_hello_starknet_tx_hash(hello_starknet_class_hash_tx_hash) -> int: +def hello_starknet_tx_hash(hello_starknet_class_hash_tx_hash) -> int: _, tx_hash = hello_starknet_class_hash_tx_hash return tx_hash @@ -168,9 +168,7 @@ async def cairo1_erc20_deploy(account, erc20_class_hash): @pytest_asyncio.fixture(scope="package", name="hello_starknet_contract") -async def cairo1_hello_starknet_deploy( - account: BaseAccount, hello_starknet_class_hash -): +async def cairo1_hello_starknet_deploy(account: BaseAccount, hello_starknet_class_hash): return await deploy_v1_contract( account=account, contract_name="HelloStarknet", From 1571d7d61cf7d9060d30fcaeabf90f832925b23b Mon Sep 17 00:00:00 2001 From: kkawula <57270771+kkawula@users.noreply.github.com> Date: Tue, 3 Sep 2024 09:58:27 +0200 Subject: [PATCH 09/27] Rename 'cairo1_minimal_contract_class_hash' -> 'minimal_contract_class_hash' --- .../tests/e2e/contract_interaction/deploy_test.py | 12 ++++++------ starknet_py/tests/e2e/declare/declare_test.py | 6 +++--- starknet_py/tests/e2e/fixtures/contracts_v1.py | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/starknet_py/tests/e2e/contract_interaction/deploy_test.py b/starknet_py/tests/e2e/contract_interaction/deploy_test.py index 7896796c7..c623d3325 100644 --- a/starknet_py/tests/e2e/contract_interaction/deploy_test.py +++ b/starknet_py/tests/e2e/contract_interaction/deploy_test.py @@ -15,7 +15,7 @@ @pytest.mark.asyncio async def test_declare_deploy_v1( account, - cairo1_minimal_contract_class_hash: int, + minimal_contract_class_hash: int, ): compiled_contract = load_contract("MinimalContract")["sierra"] @@ -23,7 +23,7 @@ async def test_declare_deploy_v1( _account=account, _client=account.client, _cairo_version=1, - class_hash=cairo1_minimal_contract_class_hash, + class_hash=minimal_contract_class_hash, compiled_contract=compiled_contract, hash=0, declare_transaction=Mock(spec=DeclareV2), @@ -40,7 +40,7 @@ async def test_declare_deploy_v1( @pytest.mark.asyncio async def test_declare_deploy_v3( account, - cairo1_minimal_contract_class_hash: int, + minimal_contract_class_hash: int, ): compiled_contract = load_contract("MinimalContract")["sierra"] @@ -48,7 +48,7 @@ async def test_declare_deploy_v3( _account=account, _client=account.client, _cairo_version=1, - class_hash=cairo1_minimal_contract_class_hash, + class_hash=minimal_contract_class_hash, compiled_contract=compiled_contract, hash=0, declare_transaction=Mock(spec=DeclareV2), @@ -65,14 +65,14 @@ async def test_declare_deploy_v3( @pytest.mark.asyncio -async def test_throws_on_wrong_abi(account, cairo1_minimal_contract_class_hash: int): +async def test_throws_on_wrong_abi(account, minimal_contract_class_hash: int): compiled_contract = load_contract("MinimalContract")["sierra"] declare_result = DeclareResult( _account=account, _client=account.client, _cairo_version=1, - class_hash=cairo1_minimal_contract_class_hash, + class_hash=minimal_contract_class_hash, compiled_contract=compiled_contract, hash=0, declare_transaction=Mock(spec=DeclareV2), diff --git a/starknet_py/tests/e2e/declare/declare_test.py b/starknet_py/tests/e2e/declare/declare_test.py index 9ed4f246a..7e5e3924a 100644 --- a/starknet_py/tests/e2e/declare/declare_test.py +++ b/starknet_py/tests/e2e/declare/declare_test.py @@ -6,9 +6,9 @@ @pytest.mark.asyncio -async def test_declare_v2_tx(cairo1_minimal_contract_class_hash: int): - assert isinstance(cairo1_minimal_contract_class_hash, int) - assert cairo1_minimal_contract_class_hash != 0 +async def test_declare_v2_tx(minimal_contract_class_hash: int): + assert isinstance(minimal_contract_class_hash, int) + assert minimal_contract_class_hash != 0 @pytest.mark.asyncio diff --git a/starknet_py/tests/e2e/fixtures/contracts_v1.py b/starknet_py/tests/e2e/fixtures/contracts_v1.py index 4c5e1cbe5..8803e1fcd 100644 --- a/starknet_py/tests/e2e/fixtures/contracts_v1.py +++ b/starknet_py/tests/e2e/fixtures/contracts_v1.py @@ -107,7 +107,7 @@ def hello_starknet_tx_hash(hello_starknet_class_hash_tx_hash) -> int: @pytest_asyncio.fixture(scope="package") -async def cairo1_minimal_contract_class_hash(account: BaseAccount) -> int: +async def minimal_contract_class_hash(account: BaseAccount) -> int: contract = load_contract(contract_name="MinimalContract") class_hash, _ = await declare_cairo1_contract( account, From 3b36d48d32525b5684eac591a410cad99f87d66a Mon Sep 17 00:00:00 2001 From: kkawula <57270771+kkawula@users.noreply.github.com> Date: Tue, 3 Sep 2024 10:03:46 +0200 Subject: [PATCH 10/27] Move cairo 1 fixtures to proper dir --- .../e2e/client_devnet/fixtures/contracts.py | 6 +- .../v1_interaction_test.py | 2 +- starknet_py/tests/e2e/fixtures/contracts.py | 145 +----------------- .../tests/e2e/fixtures/contracts_v1.py | 140 ++++++++++++++++- 4 files changed, 143 insertions(+), 150 deletions(-) diff --git a/starknet_py/tests/e2e/client_devnet/fixtures/contracts.py b/starknet_py/tests/e2e/client_devnet/fixtures/contracts.py index 4ac85b118..69adbf06a 100644 --- a/starknet_py/tests/e2e/client_devnet/fixtures/contracts.py +++ b/starknet_py/tests/e2e/client_devnet/fixtures/contracts.py @@ -1,8 +1,10 @@ import pytest_asyncio from starknet_py.contract import Contract -from starknet_py.tests.e2e.fixtures.contracts import deploy_v1_contract -from starknet_py.tests.e2e.fixtures.contracts_v1 import declare_cairo1_contract +from starknet_py.tests.e2e.fixtures.contracts_v1 import ( + declare_cairo1_contract, + deploy_v1_contract, +) from starknet_py.tests.e2e.fixtures.misc import load_contract diff --git a/starknet_py/tests/e2e/contract_interaction/v1_interaction_test.py b/starknet_py/tests/e2e/contract_interaction/v1_interaction_test.py index 5d587ef89..0b7213a1d 100644 --- a/starknet_py/tests/e2e/contract_interaction/v1_interaction_test.py +++ b/starknet_py/tests/e2e/contract_interaction/v1_interaction_test.py @@ -5,7 +5,7 @@ from starknet_py.cairo.felt import decode_shortstring, encode_shortstring from starknet_py.contract import Contract from starknet_py.tests.e2e.fixtures.constants import MAX_FEE -from starknet_py.tests.e2e.fixtures.contracts import deploy_v1_contract +from starknet_py.tests.e2e.fixtures.contracts_v1 import deploy_v1_contract # TODO (#1219): investigate why some of these tests fails for contracts_compiled_v1 diff --git a/starknet_py/tests/e2e/fixtures/contracts.py b/starknet_py/tests/e2e/fixtures/contracts.py index 374ab27d8..5c4d732e4 100644 --- a/starknet_py/tests/e2e/fixtures/contracts.py +++ b/starknet_py/tests/e2e/fixtures/contracts.py @@ -1,51 +1,12 @@ # pylint: disable=redefined-outer-name -from typing import Any, Dict, List, Optional, Tuple +from typing import List import pytest -import pytest_asyncio -from starknet_py.common import create_casm_class, create_sierra_compiled_contract from starknet_py.constants import FEE_CONTRACT_ADDRESS from starknet_py.contract import Contract -from starknet_py.hash.casm_class_hash import compute_casm_class_hash from starknet_py.net.account.base_account import BaseAccount -from starknet_py.net.udc_deployer.deployer import Deployer -from starknet_py.tests.e2e.fixtures.constants import ( - MAX_FEE, - PRECOMPILED_CONTRACTS_DIR, - STRK_FEE_CONTRACT_ADDRESS, -) -from starknet_py.tests.e2e.fixtures.misc import ( - ContractVersion, - load_contract, - read_contract, -) - - -@pytest.fixture(scope="package") -def sierra_minimal_compiled_contract_and_class_hash() -> Tuple[str, int]: - """ - Returns minimal contract compiled to sierra and its compiled class hash. - """ - contract = load_contract(contract_name="MinimalContract") - - return ( - contract["sierra"], - compute_casm_class_hash(create_casm_class(contract["casm"])), - ) - - -@pytest.fixture(scope="package") -def abi_types_compiled_contract_and_class_hash() -> Tuple[str, int]: - """ - Returns abi_types contract compiled to sierra and its compiled class hash. - """ - contract = load_contract(contract_name="AbiTypes", version=ContractVersion.V2) - - return ( - contract["sierra"], - compute_casm_class_hash(create_casm_class(contract["casm"])), - ) +from starknet_py.tests.e2e.fixtures.constants import MAX_FEE, STRK_FEE_CONTRACT_ADDRESS async def deploy_contract(account: BaseAccount, class_hash: int, abi: List) -> Contract: @@ -59,38 +20,6 @@ async def deploy_contract(account: BaseAccount, class_hash: int, abi: List) -> C return deployment_result.deployed_contract -async def deploy_v1_contract( - account: BaseAccount, - contract_name: str, - class_hash: int, - calldata: Optional[Dict[str, Any]] = None, -) -> Contract: - """ - Deploys Cairo1.0 contract. - - :param account: An account which will be used to deploy the Contract. - :param contract_name: Name of the contract from project mocks (e.g. `ERC20`). - :param class_hash: class_hash of the contract to be deployed. - :param calldata: Dict with constructor arguments (can be empty). - :returns: Instance of the deployed contract. - """ - contract_sierra = load_contract(contract_name)["sierra"] - - abi = create_sierra_compiled_contract(compiled_contract=contract_sierra).parsed_abi - - deployer = Deployer() - deploy_call, address = deployer.create_contract_deployment( - class_hash=class_hash, - abi=abi, - calldata=calldata, - cairo_version=1, - ) - res = await account.execute_v1(calls=deploy_call, max_fee=MAX_FEE) - await account.client.wait_for_tx(res.transaction_hash) - - return Contract(address, abi, provider=account, cairo_version=1) - - @pytest.fixture(scope="package") def eth_fee_contract(account: BaseAccount, cairo_0_fee_contract_abi) -> Contract: """ @@ -141,73 +70,3 @@ def cairo_0_fee_contract_abi(): "type": "struct", }, ] - - -async def declare_account( - account: BaseAccount, compiled_contract: str, compiled_class_hash: int -) -> int: - """ - Declares a specified account. - """ - - declare_tx = await account.sign_declare_v2( - compiled_contract, - compiled_class_hash, - max_fee=MAX_FEE, - ) - resp = await account.client.declare(transaction=declare_tx) - await account.client.wait_for_tx(resp.transaction_hash) - - return resp.class_hash - - -async def declare_cairo1_account( - account: BaseAccount, - compiled_account_contract: str, - compiled_account_contract_casm: str, -) -> int: - """ - Declares a specified Cairo1 account. - """ - - casm_class = create_casm_class(compiled_account_contract_casm) - casm_class_hash = compute_casm_class_hash(casm_class) - declare_v2_transaction = await account.sign_declare_v2( - compiled_contract=compiled_account_contract, - compiled_class_hash=casm_class_hash, - max_fee=MAX_FEE, - ) - resp = await account.client.declare(transaction=declare_v2_transaction) - await account.client.wait_for_tx(resp.transaction_hash) - return resp.class_hash - - -@pytest_asyncio.fixture(scope="package") -async def account_with_validate_deploy_class_hash( - pre_deployed_account_with_validate_deploy: BaseAccount, -) -> int: - contract = load_contract("Account") - casm_class_hash = compute_casm_class_hash(create_casm_class(contract["casm"])) - - return await declare_account( - pre_deployed_account_with_validate_deploy, contract["sierra"], casm_class_hash - ) - - -@pytest_asyncio.fixture(scope="package") -async def argent_cairo1_account_class_hash( - account: BaseAccount, -) -> int: - # Use precompiled argent account contracts - # we don't have the source code for this contract - compiled_contract = read_contract( - "argent_account.json", directory=PRECOMPILED_CONTRACTS_DIR - ) - compiled_contract_casm = read_contract( - "argent_account.casm", directory=PRECOMPILED_CONTRACTS_DIR - ) - return await declare_cairo1_account( - account=account, - compiled_account_contract=compiled_contract, - compiled_account_contract_casm=compiled_contract_casm, - ) diff --git a/starknet_py/tests/e2e/fixtures/contracts_v1.py b/starknet_py/tests/e2e/fixtures/contracts_v1.py index 8803e1fcd..4561b94f3 100644 --- a/starknet_py/tests/e2e/fixtures/contracts_v1.py +++ b/starknet_py/tests/e2e/fixtures/contracts_v1.py @@ -1,5 +1,5 @@ # pylint: disable=redefined-outer-name -from typing import List, Tuple +from typing import Any, Dict, List, Optional, Tuple import pytest import pytest_asyncio @@ -10,9 +10,13 @@ from starknet_py.hash.casm_class_hash import compute_casm_class_hash from starknet_py.net.account.base_account import BaseAccount from starknet_py.net.models import DeclareV2 -from starknet_py.tests.e2e.fixtures.constants import MAX_FEE -from starknet_py.tests.e2e.fixtures.contracts import deploy_v1_contract -from starknet_py.tests.e2e.fixtures.misc import ContractVersion, load_contract +from starknet_py.net.udc_deployer.deployer import Deployer +from starknet_py.tests.e2e.fixtures.constants import MAX_FEE, PRECOMPILED_CONTRACTS_DIR +from starknet_py.tests.e2e.fixtures.misc import ( + ContractVersion, + load_contract, + read_contract, +) async def declare_cairo1_contract( @@ -262,3 +266,131 @@ async def simple_storage_with_event_contract( contract_name="SimpleStorageWithEvent", class_hash=simple_storage_with_event_class_hash, ) + + +@pytest.fixture(scope="package") +def sierra_minimal_compiled_contract_and_class_hash() -> Tuple[str, int]: + """ + Returns minimal contract compiled to sierra and its compiled class hash. + """ + contract = load_contract(contract_name="MinimalContract") + + return ( + contract["sierra"], + compute_casm_class_hash(create_casm_class(contract["casm"])), + ) + + +@pytest.fixture(scope="package") +def abi_types_compiled_contract_and_class_hash() -> Tuple[str, int]: + """ + Returns abi_types contract compiled to sierra and its compiled class hash. + """ + contract = load_contract(contract_name="AbiTypes", version=ContractVersion.V2) + + return ( + contract["sierra"], + compute_casm_class_hash(create_casm_class(contract["casm"])), + ) + + +async def declare_account( + account: BaseAccount, compiled_contract: str, compiled_class_hash: int +) -> int: + """ + Declares a specified account. + """ + + declare_tx = await account.sign_declare_v2( + compiled_contract, + compiled_class_hash, + max_fee=MAX_FEE, + ) + resp = await account.client.declare(transaction=declare_tx) + await account.client.wait_for_tx(resp.transaction_hash) + + return resp.class_hash + + +async def declare_cairo1_account( + account: BaseAccount, + compiled_account_contract: str, + compiled_account_contract_casm: str, +) -> int: + """ + Declares a specified Cairo1 account. + """ + + casm_class = create_casm_class(compiled_account_contract_casm) + casm_class_hash = compute_casm_class_hash(casm_class) + declare_v2_transaction = await account.sign_declare_v2( + compiled_contract=compiled_account_contract, + compiled_class_hash=casm_class_hash, + max_fee=MAX_FEE, + ) + resp = await account.client.declare(transaction=declare_v2_transaction) + await account.client.wait_for_tx(resp.transaction_hash) + return resp.class_hash + + +@pytest_asyncio.fixture(scope="package") +async def account_with_validate_deploy_class_hash( + pre_deployed_account_with_validate_deploy: BaseAccount, +) -> int: + contract = load_contract("Account") + casm_class_hash = compute_casm_class_hash(create_casm_class(contract["casm"])) + + return await declare_account( + pre_deployed_account_with_validate_deploy, contract["sierra"], casm_class_hash + ) + + +@pytest_asyncio.fixture(scope="package") +async def argent_cairo1_account_class_hash( + account: BaseAccount, +) -> int: + # Use precompiled argent account contracts + # we don't have the source code for this contract + compiled_contract = read_contract( + "argent_account.json", directory=PRECOMPILED_CONTRACTS_DIR + ) + compiled_contract_casm = read_contract( + "argent_account.casm", directory=PRECOMPILED_CONTRACTS_DIR + ) + return await declare_cairo1_account( + account=account, + compiled_account_contract=compiled_contract, + compiled_account_contract_casm=compiled_contract_casm, + ) + + +async def deploy_v1_contract( + account: BaseAccount, + contract_name: str, + class_hash: int, + calldata: Optional[Dict[str, Any]] = None, +) -> Contract: + """ + Deploys Cairo1.0 contract. + + :param account: An account which will be used to deploy the Contract. + :param contract_name: Name of the contract from project mocks (e.g. `ERC20`). + :param class_hash: class_hash of the contract to be deployed. + :param calldata: Dict with constructor arguments (can be empty). + :returns: Instance of the deployed contract. + """ + contract_sierra = load_contract(contract_name)["sierra"] + + abi = create_sierra_compiled_contract(compiled_contract=contract_sierra).parsed_abi + + deployer = Deployer() + deploy_call, address = deployer.create_contract_deployment( + class_hash=class_hash, + abi=abi, + calldata=calldata, + cairo_version=1, + ) + res = await account.execute_v1(calls=deploy_call, max_fee=MAX_FEE) + await account.client.wait_for_tx(res.transaction_hash) + + return Contract(address, abi, provider=account, cairo_version=1) From 588028109e24cd246e1dd8d840d006617a1833dc Mon Sep 17 00:00:00 2001 From: kkawula <57270771+kkawula@users.noreply.github.com> Date: Tue, 3 Sep 2024 10:05:20 +0200 Subject: [PATCH 11/27] Remove unused function --- starknet_py/tests/e2e/fixtures/contracts.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/starknet_py/tests/e2e/fixtures/contracts.py b/starknet_py/tests/e2e/fixtures/contracts.py index 5c4d732e4..ffec37122 100644 --- a/starknet_py/tests/e2e/fixtures/contracts.py +++ b/starknet_py/tests/e2e/fixtures/contracts.py @@ -9,17 +9,6 @@ from starknet_py.tests.e2e.fixtures.constants import MAX_FEE, STRK_FEE_CONTRACT_ADDRESS -async def deploy_contract(account: BaseAccount, class_hash: int, abi: List) -> Contract: - """ - Deploys a contract and returns its instance. - """ - deployment_result = await Contract.deploy_contract_v1( - account=account, class_hash=class_hash, abi=abi, max_fee=MAX_FEE - ) - deployment_result = await deployment_result.wait_for_acceptance() - return deployment_result.deployed_contract - - @pytest.fixture(scope="package") def eth_fee_contract(account: BaseAccount, cairo_0_fee_contract_abi) -> Contract: """ From c0084432095799dbc12495e9c515b16c0b4052e6 Mon Sep 17 00:00:00 2001 From: kkawula <57270771+kkawula@users.noreply.github.com> Date: Tue, 3 Sep 2024 10:09:47 +0200 Subject: [PATCH 12/27] Lint --- starknet_py/tests/e2e/fixtures/contracts.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/starknet_py/tests/e2e/fixtures/contracts.py b/starknet_py/tests/e2e/fixtures/contracts.py index ffec37122..e23cac960 100644 --- a/starknet_py/tests/e2e/fixtures/contracts.py +++ b/starknet_py/tests/e2e/fixtures/contracts.py @@ -1,12 +1,11 @@ # pylint: disable=redefined-outer-name -from typing import List import pytest from starknet_py.constants import FEE_CONTRACT_ADDRESS from starknet_py.contract import Contract from starknet_py.net.account.base_account import BaseAccount -from starknet_py.tests.e2e.fixtures.constants import MAX_FEE, STRK_FEE_CONTRACT_ADDRESS +from starknet_py.tests.e2e.fixtures.constants import STRK_FEE_CONTRACT_ADDRESS @pytest.fixture(scope="package") From f7d2900a83292164a00f15b174fc31b4147b8110 Mon Sep 17 00:00:00 2001 From: kkawula <57270771+kkawula@users.noreply.github.com> Date: Tue, 3 Sep 2024 11:59:44 +0200 Subject: [PATCH 13/27] Update docsstring in 'deploy_v1_contract' function --- starknet_py/tests/e2e/fixtures/contracts_v1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/starknet_py/tests/e2e/fixtures/contracts_v1.py b/starknet_py/tests/e2e/fixtures/contracts_v1.py index 4561b94f3..283dba10f 100644 --- a/starknet_py/tests/e2e/fixtures/contracts_v1.py +++ b/starknet_py/tests/e2e/fixtures/contracts_v1.py @@ -371,7 +371,7 @@ async def deploy_v1_contract( calldata: Optional[Dict[str, Any]] = None, ) -> Contract: """ - Deploys Cairo1.0 contract. + Deploys Cairo1 contract. :param account: An account which will be used to deploy the Contract. :param contract_name: Name of the contract from project mocks (e.g. `ERC20`). From 4b435cbe257f60366f2103e1e6aa49c38550e423 Mon Sep 17 00:00:00 2001 From: kkawula <57270771+kkawula@users.noreply.github.com> Date: Tue, 3 Sep 2024 12:00:21 +0200 Subject: [PATCH 14/27] Update 'load_contract' function argument --- starknet_py/tests/e2e/fixtures/contracts_v1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/starknet_py/tests/e2e/fixtures/contracts_v1.py b/starknet_py/tests/e2e/fixtures/contracts_v1.py index 283dba10f..5f1df8ed6 100644 --- a/starknet_py/tests/e2e/fixtures/contracts_v1.py +++ b/starknet_py/tests/e2e/fixtures/contracts_v1.py @@ -112,7 +112,7 @@ def hello_starknet_tx_hash(hello_starknet_class_hash_tx_hash) -> int: @pytest_asyncio.fixture(scope="package") async def minimal_contract_class_hash(account: BaseAccount) -> int: - contract = load_contract(contract_name="MinimalContract") + contract = load_contract("MinimalContract") class_hash, _ = await declare_cairo1_contract( account, contract["sierra"], From e094451140148f560957294ae451dc06c9ff8db4 Mon Sep 17 00:00:00 2001 From: kkawula <57270771+kkawula@users.noreply.github.com> Date: Tue, 3 Sep 2024 12:04:36 +0200 Subject: [PATCH 15/27] Rename 'cairo1_hello_starknet_deploy' -> 'hello_starknet_contract' --- starknet_py/tests/e2e/fixtures/contracts_v1.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/starknet_py/tests/e2e/fixtures/contracts_v1.py b/starknet_py/tests/e2e/fixtures/contracts_v1.py index 5f1df8ed6..6b032d028 100644 --- a/starknet_py/tests/e2e/fixtures/contracts_v1.py +++ b/starknet_py/tests/e2e/fixtures/contracts_v1.py @@ -171,8 +171,8 @@ async def cairo1_erc20_deploy(account, erc20_class_hash): ) -@pytest_asyncio.fixture(scope="package", name="hello_starknet_contract") -async def cairo1_hello_starknet_deploy(account: BaseAccount, hello_starknet_class_hash): +@pytest_asyncio.fixture(scope="package") +async def hello_starknet_contract(account: BaseAccount, hello_starknet_class_hash): return await deploy_v1_contract( account=account, contract_name="HelloStarknet", From 5e31a166af820118405552181c236c8e07242893 Mon Sep 17 00:00:00 2001 From: kkawula <57270771+kkawula@users.noreply.github.com> Date: Tue, 3 Sep 2024 12:05:46 +0200 Subject: [PATCH 16/27] Rename 'cairo1_hello_starknet_abi' -> 'hello_starknet_abi' --- starknet_py/tests/e2e/docs/guide/test_simple_deploy.py | 6 ++---- starknet_py/tests/e2e/fixtures/contracts_v1.py | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/starknet_py/tests/e2e/docs/guide/test_simple_deploy.py b/starknet_py/tests/e2e/docs/guide/test_simple_deploy.py index ddc325777..ed89a066d 100644 --- a/starknet_py/tests/e2e/docs/guide/test_simple_deploy.py +++ b/starknet_py/tests/e2e/docs/guide/test_simple_deploy.py @@ -4,9 +4,7 @@ @pytest.mark.asyncio -async def test_simple_deploy( - account, hello_starknet_class_hash, cairo1_hello_starknet_abi -): +async def test_simple_deploy(account, hello_starknet_class_hash, hello_starknet_abi): # pylint: disable=import-outside-toplevel # docs: start from starknet_py.contract import Contract @@ -14,7 +12,7 @@ async def test_simple_deploy( # docs: end class_hash = hello_starknet_class_hash - abi = cairo1_hello_starknet_abi + abi = hello_starknet_abi # docs: start # To deploy contract just use `Contract.deploy_contract_v1` method diff --git a/starknet_py/tests/e2e/fixtures/contracts_v1.py b/starknet_py/tests/e2e/fixtures/contracts_v1.py index 6b032d028..397785eb9 100644 --- a/starknet_py/tests/e2e/fixtures/contracts_v1.py +++ b/starknet_py/tests/e2e/fixtures/contracts_v1.py @@ -89,7 +89,7 @@ async def hello_starknet_class_hash_tx_hash( @pytest_asyncio.fixture(scope="package") -async def cairo1_hello_starknet_abi() -> List: +async def hello_starknet_abi() -> List: contract = load_contract("HelloStarknet") compiled_contract = create_sierra_compiled_contract( compiled_contract=contract["sierra"] From cf2035807150106a83aadea9c8e87d28a6d35e16 Mon Sep 17 00:00:00 2001 From: kkawula <57270771+kkawula@users.noreply.github.com> Date: Tue, 3 Sep 2024 12:06:27 +0200 Subject: [PATCH 17/27] Remove unnecessary name --- starknet_py/tests/e2e/fixtures/contracts_v1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/starknet_py/tests/e2e/fixtures/contracts_v1.py b/starknet_py/tests/e2e/fixtures/contracts_v1.py index 397785eb9..07ea7e7a2 100644 --- a/starknet_py/tests/e2e/fixtures/contracts_v1.py +++ b/starknet_py/tests/e2e/fixtures/contracts_v1.py @@ -211,7 +211,7 @@ async def map_class_hash(account: BaseAccount) -> int: return class_hash -@pytest_asyncio.fixture(scope="package", name="map_contract") +@pytest_asyncio.fixture(scope="package") async def map_contract(account: BaseAccount, map_class_hash) -> Contract: return await deploy_v1_contract( account=account, From d8fc2521047389eb605b0144e01a22c9d646f8c0 Mon Sep 17 00:00:00 2001 From: kkawula <57270771+kkawula@users.noreply.github.com> Date: Tue, 3 Sep 2024 12:08:11 +0200 Subject: [PATCH 18/27] Update 'load_contract' function argument --- starknet_py/tests/e2e/fixtures/contracts_v1.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/starknet_py/tests/e2e/fixtures/contracts_v1.py b/starknet_py/tests/e2e/fixtures/contracts_v1.py index 07ea7e7a2..f2c1dd6dd 100644 --- a/starknet_py/tests/e2e/fixtures/contracts_v1.py +++ b/starknet_py/tests/e2e/fixtures/contracts_v1.py @@ -123,7 +123,7 @@ async def minimal_contract_class_hash(account: BaseAccount) -> int: @pytest_asyncio.fixture(scope="package") async def test_enum_class_hash(account: BaseAccount) -> int: - contract = load_contract(contract_name="TestEnum") + contract = load_contract("TestEnum") class_hash, _ = await declare_cairo1_contract( account, contract["sierra"], @@ -134,7 +134,7 @@ async def test_enum_class_hash(account: BaseAccount) -> int: @pytest_asyncio.fixture(scope="package") async def test_option_class_hash(account: BaseAccount) -> int: - contract = load_contract(contract_name="TestOption") + contract = load_contract("TestOption") class_hash, _ = await declare_cairo1_contract( account, contract["sierra"], @@ -145,7 +145,7 @@ async def test_option_class_hash(account: BaseAccount) -> int: @pytest_asyncio.fixture(scope="package") async def token_bridge_class_hash(account: BaseAccount) -> int: - contract = load_contract(contract_name="TokenBridge") + contract = load_contract("TokenBridge") class_hash, _ = await declare_cairo1_contract( account, contract["sierra"], @@ -273,7 +273,7 @@ def sierra_minimal_compiled_contract_and_class_hash() -> Tuple[str, int]: """ Returns minimal contract compiled to sierra and its compiled class hash. """ - contract = load_contract(contract_name="MinimalContract") + contract = load_contract("MinimalContract") return ( contract["sierra"], From 443081550a309a00480929ea8f37335d963e6466 Mon Sep 17 00:00:00 2001 From: kkawula <57270771+kkawula@users.noreply.github.com> Date: Tue, 3 Sep 2024 12:13:47 +0200 Subject: [PATCH 19/27] Update 'erc20_contract' name --- starknet_py/tests/e2e/fixtures/contracts_v1.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/starknet_py/tests/e2e/fixtures/contracts_v1.py b/starknet_py/tests/e2e/fixtures/contracts_v1.py index f2c1dd6dd..524eeb4d5 100644 --- a/starknet_py/tests/e2e/fixtures/contracts_v1.py +++ b/starknet_py/tests/e2e/fixtures/contracts_v1.py @@ -154,8 +154,8 @@ async def token_bridge_class_hash(account: BaseAccount) -> int: return class_hash -@pytest_asyncio.fixture(scope="package", name="erc20_contract") -async def cairo1_erc20_deploy(account, erc20_class_hash): +@pytest_asyncio.fixture(scope="package") +async def erc20_contract(account, erc20_class_hash): calldata = { "name_": encode_shortstring("erc20_basic"), "symbol_": encode_shortstring("ERC20B"), From 3b2daa1e1287a3729100e6fc3c1885e208177873 Mon Sep 17 00:00:00 2001 From: kkawula <57270771+kkawula@users.noreply.github.com> Date: Tue, 3 Sep 2024 13:51:51 +0200 Subject: [PATCH 20/27] Remove unnecessary argument --- starknet_py/tests/e2e/fixtures/contracts_v1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/starknet_py/tests/e2e/fixtures/contracts_v1.py b/starknet_py/tests/e2e/fixtures/contracts_v1.py index 524eeb4d5..f70727747 100644 --- a/starknet_py/tests/e2e/fixtures/contracts_v1.py +++ b/starknet_py/tests/e2e/fixtures/contracts_v1.py @@ -393,4 +393,4 @@ async def deploy_v1_contract( res = await account.execute_v1(calls=deploy_call, max_fee=MAX_FEE) await account.client.wait_for_tx(res.transaction_hash) - return Contract(address, abi, provider=account, cairo_version=1) + return Contract(address, abi, provider=account) From 113b50356fba8a6e2205b391f7ff2b593d33065d Mon Sep 17 00:00:00 2001 From: kkawula <57270771+kkawula@users.noreply.github.com> Date: Tue, 3 Sep 2024 13:53:17 +0200 Subject: [PATCH 21/27] Rename 'argent_cairo1_account_class_hash' -> 'argent_account_class_hash' --- starknet_py/tests/e2e/account/account_test.py | 4 ++-- starknet_py/tests/e2e/fixtures/accounts.py | 4 ++-- starknet_py/tests/e2e/fixtures/contracts_v1.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/starknet_py/tests/e2e/account/account_test.py b/starknet_py/tests/e2e/account/account_test.py index c63228fd0..621cfd0e6 100644 --- a/starknet_py/tests/e2e/account/account_test.py +++ b/starknet_py/tests/e2e/account/account_test.py @@ -735,11 +735,11 @@ async def test_sign_transaction_custom_nonce(account, hello_starknet_class_hash) @pytest.mark.asyncio async def test_argent_cairo1_account_deploy( client, - argent_cairo1_account_class_hash, + argent_account_class_hash, deploy_account_details_factory, ): address, key_pair, salt, class_hash = await deploy_account_details_factory.get( - class_hash=argent_cairo1_account_class_hash, argent_calldata=True + class_hash=argent_account_class_hash, argent_calldata=True ) deploy_result = await Account.deploy_account_v1( diff --git a/starknet_py/tests/e2e/fixtures/accounts.py b/starknet_py/tests/e2e/fixtures/accounts.py index 8983d6a64..b39546db4 100644 --- a/starknet_py/tests/e2e/fixtures/accounts.py +++ b/starknet_py/tests/e2e/fixtures/accounts.py @@ -151,12 +151,12 @@ def pre_deployed_account_with_validate_deploy(client) -> BaseAccount: @pytest_asyncio.fixture(scope="package") async def argent_cairo1_account( - argent_cairo1_account_class_hash, + argent_account_class_hash, deploy_account_details_factory: AccountToBeDeployedDetailsFactory, client, ) -> BaseAccount: address, key_pair, salt, class_hash = await deploy_account_details_factory.get( - class_hash=argent_cairo1_account_class_hash, + class_hash=argent_account_class_hash, argent_calldata=True, ) deploy_result = await Account.deploy_account_v1( diff --git a/starknet_py/tests/e2e/fixtures/contracts_v1.py b/starknet_py/tests/e2e/fixtures/contracts_v1.py index f70727747..6af90c0f5 100644 --- a/starknet_py/tests/e2e/fixtures/contracts_v1.py +++ b/starknet_py/tests/e2e/fixtures/contracts_v1.py @@ -346,7 +346,7 @@ async def account_with_validate_deploy_class_hash( @pytest_asyncio.fixture(scope="package") -async def argent_cairo1_account_class_hash( +async def argent_account_class_hash( account: BaseAccount, ) -> int: # Use precompiled argent account contracts From d8521c628318c2b08c3163f260b171824c2cf732 Mon Sep 17 00:00:00 2001 From: kkawula <57270771+kkawula@users.noreply.github.com> Date: Tue, 3 Sep 2024 14:45:45 +0200 Subject: [PATCH 22/27] Rename function 'declare_cairo1_contract' to 'declare_contract' --- .../e2e/client/fixtures/prepare_network.py | 4 ++-- .../e2e/client_devnet/fixtures/contracts.py | 6 +++--- .../tests/e2e/fixtures/contracts_v1.py | 20 +++++++++---------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/starknet_py/tests/e2e/client/fixtures/prepare_network.py b/starknet_py/tests/e2e/client/fixtures/prepare_network.py index 9d1d32fd4..ed7f049b8 100644 --- a/starknet_py/tests/e2e/client/fixtures/prepare_network.py +++ b/starknet_py/tests/e2e/client/fixtures/prepare_network.py @@ -15,14 +15,14 @@ ) from starknet_py.tests.e2e.fixtures.accounts import AccountToBeDeployedDetailsFactory from starknet_py.tests.e2e.fixtures.constants import MAX_RESOURCE_BOUNDS_L1 -from starknet_py.tests.e2e.fixtures.contracts_v1 import declare_cairo1_contract +from starknet_py.tests.e2e.fixtures.contracts_v1 import declare_contract from starknet_py.tests.e2e.fixtures.misc import load_contract @pytest_asyncio.fixture(scope="package") async def balance_class_and_transaction_hash(account: BaseAccount) -> Tuple[int, int]: contract = load_contract("Balance") - class_hash, transaction_hash = await declare_cairo1_contract( + class_hash, transaction_hash = await declare_contract( account, contract["sierra"], contract["casm"], diff --git a/starknet_py/tests/e2e/client_devnet/fixtures/contracts.py b/starknet_py/tests/e2e/client_devnet/fixtures/contracts.py index 69adbf06a..7a4a36b19 100644 --- a/starknet_py/tests/e2e/client_devnet/fixtures/contracts.py +++ b/starknet_py/tests/e2e/client_devnet/fixtures/contracts.py @@ -2,7 +2,7 @@ from starknet_py.contract import Contract from starknet_py.tests.e2e.fixtures.contracts_v1 import ( - declare_cairo1_contract, + declare_contract, deploy_v1_contract, ) from starknet_py.tests.e2e.fixtures.misc import load_contract @@ -11,7 +11,7 @@ @pytest_asyncio.fixture(scope="package", name="f_string_contract_class_hash") async def declare_string_contract(account_forked_devnet) -> int: contract = load_contract("MyString") - class_hash, _ = await declare_cairo1_contract( + class_hash, _ = await declare_contract( account_forked_devnet, contract["sierra"], contract["casm"] ) return class_hash @@ -31,7 +31,7 @@ async def deploy_string_contract( @pytest_asyncio.fixture(scope="package", name="l1_l2_contract_class_hash") async def declare_l1_l2_contract(account) -> int: contract = load_contract("l1_l2") - class_hash, _ = await declare_cairo1_contract( + class_hash, _ = await declare_contract( account, contract["sierra"], contract["casm"] ) return class_hash diff --git a/starknet_py/tests/e2e/fixtures/contracts_v1.py b/starknet_py/tests/e2e/fixtures/contracts_v1.py index 6af90c0f5..a7efed610 100644 --- a/starknet_py/tests/e2e/fixtures/contracts_v1.py +++ b/starknet_py/tests/e2e/fixtures/contracts_v1.py @@ -19,7 +19,7 @@ ) -async def declare_cairo1_contract( +async def declare_contract( account: BaseAccount, compiled_contract: str, compiled_contract_casm: str ) -> Tuple[int, int]: casm_class_hash = compute_casm_class_hash(create_casm_class(compiled_contract_casm)) @@ -40,7 +40,7 @@ async def declare_cairo1_contract( @pytest_asyncio.fixture(scope="package") async def erc20_class_hash(account: BaseAccount) -> int: contract = load_contract("ERC20") - class_hash, _ = await declare_cairo1_contract( + class_hash, _ = await declare_contract( account, contract["sierra"], contract["casm"] ) return class_hash @@ -49,7 +49,7 @@ async def erc20_class_hash(account: BaseAccount) -> int: @pytest_asyncio.fixture(scope="package") async def constructor_with_arguments_class_hash(account: BaseAccount) -> int: contract = load_contract("ConstructorWithArguments") - class_hash, _ = await declare_cairo1_contract( + class_hash, _ = await declare_contract( account, contract["sierra"], contract["casm"] ) return class_hash @@ -113,7 +113,7 @@ def hello_starknet_tx_hash(hello_starknet_class_hash_tx_hash) -> int: @pytest_asyncio.fixture(scope="package") async def minimal_contract_class_hash(account: BaseAccount) -> int: contract = load_contract("MinimalContract") - class_hash, _ = await declare_cairo1_contract( + class_hash, _ = await declare_contract( account, contract["sierra"], contract["casm"], @@ -124,7 +124,7 @@ async def minimal_contract_class_hash(account: BaseAccount) -> int: @pytest_asyncio.fixture(scope="package") async def test_enum_class_hash(account: BaseAccount) -> int: contract = load_contract("TestEnum") - class_hash, _ = await declare_cairo1_contract( + class_hash, _ = await declare_contract( account, contract["sierra"], contract["casm"], @@ -135,7 +135,7 @@ async def test_enum_class_hash(account: BaseAccount) -> int: @pytest_asyncio.fixture(scope="package") async def test_option_class_hash(account: BaseAccount) -> int: contract = load_contract("TestOption") - class_hash, _ = await declare_cairo1_contract( + class_hash, _ = await declare_contract( account, contract["sierra"], contract["casm"], @@ -146,7 +146,7 @@ async def test_option_class_hash(account: BaseAccount) -> int: @pytest_asyncio.fixture(scope="package") async def token_bridge_class_hash(account: BaseAccount) -> int: contract = load_contract("TokenBridge") - class_hash, _ = await declare_cairo1_contract( + class_hash, _ = await declare_contract( account, contract["sierra"], contract["casm"], @@ -183,7 +183,7 @@ async def hello_starknet_contract(account: BaseAccount, hello_starknet_class_has @pytest_asyncio.fixture(scope="package", name="string_contract_class_hash") async def declare_string_contract(account: BaseAccount) -> int: contract = load_contract("MyString", version=ContractVersion.V2) - class_hash, _ = await declare_cairo1_contract( + class_hash, _ = await declare_contract( account, contract["sierra"], contract["casm"] ) return class_hash @@ -203,7 +203,7 @@ async def deploy_string_contract( @pytest_asyncio.fixture(scope="package") async def map_class_hash(account: BaseAccount) -> int: contract = load_contract("Map") - class_hash, _ = await declare_cairo1_contract( + class_hash, _ = await declare_contract( account, contract["sierra"], contract["casm"], @@ -250,7 +250,7 @@ def map_compiled_contract_casm() -> str: @pytest_asyncio.fixture(scope="package") async def simple_storage_with_event_class_hash(account: BaseAccount) -> int: contract = load_contract("SimpleStorageWithEvent") - class_hash, _ = await declare_cairo1_contract( + class_hash, _ = await declare_contract( account, contract["sierra"], contract["casm"] ) return class_hash From c41e378cd9e5ab34d69a1329acd8ab1a07e7e539 Mon Sep 17 00:00:00 2001 From: kkawula <57270771+kkawula@users.noreply.github.com> Date: Tue, 3 Sep 2024 14:50:40 +0200 Subject: [PATCH 23/27] Rename 'declare_cairo1_account' -> 'account_declare_class_hash' --- starknet_py/tests/e2e/fixtures/contracts_v1.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/starknet_py/tests/e2e/fixtures/contracts_v1.py b/starknet_py/tests/e2e/fixtures/contracts_v1.py index a7efed610..db1d28c54 100644 --- a/starknet_py/tests/e2e/fixtures/contracts_v1.py +++ b/starknet_py/tests/e2e/fixtures/contracts_v1.py @@ -312,7 +312,7 @@ async def declare_account( return resp.class_hash -async def declare_cairo1_account( +async def account_declare_class_hash( account: BaseAccount, compiled_account_contract: str, compiled_account_contract_casm: str, @@ -357,7 +357,7 @@ async def argent_account_class_hash( compiled_contract_casm = read_contract( "argent_account.casm", directory=PRECOMPILED_CONTRACTS_DIR ) - return await declare_cairo1_account( + return await account_declare_class_hash( account=account, compiled_account_contract=compiled_contract, compiled_account_contract_casm=compiled_contract_casm, From 17d5201060659638183a364946f3cf46c895b2cf Mon Sep 17 00:00:00 2001 From: kkawula <57270771+kkawula@users.noreply.github.com> Date: Tue, 3 Sep 2024 14:55:19 +0200 Subject: [PATCH 24/27] Rename 'argent_cairo1_account' -> 'argent_account' --- starknet_py/tests/e2e/account/account_test.py | 12 ++++++------ starknet_py/tests/e2e/fixtures/accounts.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/starknet_py/tests/e2e/account/account_test.py b/starknet_py/tests/e2e/account/account_test.py index 621cfd0e6..ce32a24eb 100644 --- a/starknet_py/tests/e2e/account/account_test.py +++ b/starknet_py/tests/e2e/account/account_test.py @@ -767,7 +767,7 @@ async def test_argent_cairo1_account_deploy( @pytest.mark.asyncio async def test_argent_cairo1_account_execute( deployed_balance_contract, - argent_cairo1_account: BaseAccount, + argent_account: BaseAccount, ): # verify that initial balance is 0 get_balance_call = Call( @@ -775,7 +775,7 @@ async def test_argent_cairo1_account_execute( selector=get_selector_from_name("get_balance"), calldata=[], ) - get_balance = await argent_cairo1_account.client.call_contract( + get_balance = await argent_account.client.call_contract( call=get_balance_call, block_number="latest" ) @@ -787,11 +787,11 @@ async def test_argent_cairo1_account_execute( selector=get_selector_from_name("increase_balance"), calldata=[value], ) - execute = await argent_cairo1_account.execute_v1( + execute = await argent_account.execute_v1( calls=increase_balance_by_20_call, max_fee=MAX_FEE ) - await argent_cairo1_account.client.wait_for_tx(tx_hash=execute.transaction_hash) - receipt = await argent_cairo1_account.client.get_transaction_receipt( + await argent_account.client.wait_for_tx(tx_hash=execute.transaction_hash) + receipt = await argent_account.client.get_transaction_receipt( tx_hash=execute.transaction_hash ) @@ -803,7 +803,7 @@ async def test_argent_cairo1_account_execute( selector=get_selector_from_name("get_balance"), calldata=[], ) - get_balance = await argent_cairo1_account.client.call_contract( + get_balance = await argent_account.client.call_contract( call=get_balance_call, block_number="latest" ) diff --git a/starknet_py/tests/e2e/fixtures/accounts.py b/starknet_py/tests/e2e/fixtures/accounts.py index b39546db4..709c4c40e 100644 --- a/starknet_py/tests/e2e/fixtures/accounts.py +++ b/starknet_py/tests/e2e/fixtures/accounts.py @@ -150,7 +150,7 @@ def pre_deployed_account_with_validate_deploy(client) -> BaseAccount: @pytest_asyncio.fixture(scope="package") -async def argent_cairo1_account( +async def argent_account( argent_account_class_hash, deploy_account_details_factory: AccountToBeDeployedDetailsFactory, client, From fb8ee70737ee74758cbed27b944004d2d3e6e3cc Mon Sep 17 00:00:00 2001 From: kkawula <57270771+kkawula@users.noreply.github.com> Date: Tue, 3 Sep 2024 14:56:08 +0200 Subject: [PATCH 25/27] Remove 'cairo1' word from a few tests --- starknet_py/tests/e2e/account/account_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/starknet_py/tests/e2e/account/account_test.py b/starknet_py/tests/e2e/account/account_test.py index ce32a24eb..54a249841 100644 --- a/starknet_py/tests/e2e/account/account_test.py +++ b/starknet_py/tests/e2e/account/account_test.py @@ -733,7 +733,7 @@ async def test_sign_transaction_custom_nonce(account, hello_starknet_class_hash) @pytest.mark.asyncio -async def test_argent_cairo1_account_deploy( +async def test_argent_account_deploy( client, argent_account_class_hash, deploy_account_details_factory, @@ -765,7 +765,7 @@ async def test_argent_cairo1_account_deploy( @pytest.mark.asyncio -async def test_argent_cairo1_account_execute( +async def test_argent_account_execute( deployed_balance_contract, argent_account: BaseAccount, ): From 78ee522e45b37d24b95e19f50121a232d1a0b991 Mon Sep 17 00:00:00 2001 From: kkawula <57270771+kkawula@users.noreply.github.com> Date: Tue, 3 Sep 2024 16:44:28 +0200 Subject: [PATCH 26/27] Remove default cairo version param. --- starknet_py/tests/e2e/fixtures/contracts_v1.py | 1 - 1 file changed, 1 deletion(-) diff --git a/starknet_py/tests/e2e/fixtures/contracts_v1.py b/starknet_py/tests/e2e/fixtures/contracts_v1.py index db1d28c54..79dfb21b7 100644 --- a/starknet_py/tests/e2e/fixtures/contracts_v1.py +++ b/starknet_py/tests/e2e/fixtures/contracts_v1.py @@ -388,7 +388,6 @@ async def deploy_v1_contract( class_hash=class_hash, abi=abi, calldata=calldata, - cairo_version=1, ) res = await account.execute_v1(calls=deploy_call, max_fee=MAX_FEE) await account.client.wait_for_tx(res.transaction_hash) From dde711d3ed2a9611e3116237306958157720e905 Mon Sep 17 00:00:00 2001 From: kkawula <57270771+kkawula@users.noreply.github.com> Date: Tue, 3 Sep 2024 16:45:22 +0200 Subject: [PATCH 27/27] Remove unnecessary argument name --- starknet_py/tests/e2e/fixtures/contracts_v1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/starknet_py/tests/e2e/fixtures/contracts_v1.py b/starknet_py/tests/e2e/fixtures/contracts_v1.py index 79dfb21b7..aa5f44ff2 100644 --- a/starknet_py/tests/e2e/fixtures/contracts_v1.py +++ b/starknet_py/tests/e2e/fixtures/contracts_v1.py @@ -381,7 +381,7 @@ async def deploy_v1_contract( """ contract_sierra = load_contract(contract_name)["sierra"] - abi = create_sierra_compiled_contract(compiled_contract=contract_sierra).parsed_abi + abi = create_sierra_compiled_contract(contract_sierra).parsed_abi deployer = Deployer() deploy_call, address = deployer.create_contract_deployment(