From 841e56686b69530d72348ba29f3398ea763e6c69 Mon Sep 17 00:00:00 2001 From: Fiiranek Date: Mon, 15 Jul 2024 11:46:17 +0200 Subject: [PATCH 01/15] Add `test_init_with_custom_client_session`; Rename `test_execute` to `test_execute_v1` --- .../tests/e2e/docs/code_examples/test_account.py | 8 +++----- .../e2e/docs/code_examples/test_full_node_client.py | 13 +++++++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/starknet_py/tests/e2e/docs/code_examples/test_account.py b/starknet_py/tests/e2e/docs/code_examples/test_account.py index 2f32f4b78..6ee37626f 100644 --- a/starknet_py/tests/e2e/docs/code_examples/test_account.py +++ b/starknet_py/tests/e2e/docs/code_examples/test_account.py @@ -25,8 +25,8 @@ def test_init(): @pytest.mark.asyncio -async def test_execute(account, contract_address): - # docs-start: execute +async def test_execute_v1(account, contract_address): + # docs-start: execute_v1 resp = await account.execute_v1( Call( to_addr=contract_address, @@ -36,15 +36,13 @@ async def test_execute(account, contract_address): max_fee=int(1e15), ) # or - # docs-end: execute call1 = call2 = Call( to_addr=contract_address, selector=get_selector_from_name("increase_balance"), calldata=[123], ) - # docs-start: execute resp = await account.execute_v1(calls=[call1, call2], auto_estimate=True) - # docs-end: execute + # docs-end: execute_v1 @pytest.mark.asyncio diff --git a/starknet_py/tests/e2e/docs/code_examples/test_full_node_client.py b/starknet_py/tests/e2e/docs/code_examples/test_full_node_client.py index cd729b4fa..b3ab0147c 100644 --- a/starknet_py/tests/e2e/docs/code_examples/test_full_node_client.py +++ b/starknet_py/tests/e2e/docs/code_examples/test_full_node_client.py @@ -1,5 +1,6 @@ # pylint: disable=unused-variable import pytest +from aiohttp import ClientSession from starknet_py.contract import Contract from starknet_py.hash.selector import get_selector_from_name @@ -14,6 +15,18 @@ def test_init(): # docs-end: init +@pytest.mark.asyncio +async def test_init_with_custom_client_session(): + # docs-start: init + # or with custom client session + session = ClientSession() + client = FullNodeClient(node_url="https://your.node.url", session=session) + # perform operations... + # close the session + await session.close() + # docs-end: init + + @pytest.mark.asyncio async def test_get_block(client, block_with_declare_hash): # docs-start: get_block From b247a9491b3a4f030bbf610464d45929d0bdab30 Mon Sep 17 00:00:00 2001 From: Fiiranek Date: Mon, 15 Jul 2024 11:46:59 +0200 Subject: [PATCH 02/15] Remove `net` param from `FullNodeClient.__init__()` docstring --- starknet_py/net/full_node_client.py | 1 - 1 file changed, 1 deletion(-) diff --git a/starknet_py/net/full_node_client.py b/starknet_py/net/full_node_client.py index ea71f0767..c26dfc43e 100644 --- a/starknet_py/net/full_node_client.py +++ b/starknet_py/net/full_node_client.py @@ -98,7 +98,6 @@ def __init__( Client for interacting with Starknet json-rpc interface. :param node_url: Url of the node providing rpc interface - :param net: Starknet network identifier :param session: Aiohttp session to be used for request. If not provided, client will create a session for every request. When using a custom session, user is responsible for closing it manually. """ From 95f4e76fb6d9b2c73ff731f1f69ea1ea410b5416 Mon Sep 17 00:00:00 2001 From: Fiiranek Date: Mon, 15 Jul 2024 12:23:48 +0200 Subject: [PATCH 03/15] Remove goerli mention --- starknet_py/tests/e2e/docs/guide/test_deploying_with_udc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/starknet_py/tests/e2e/docs/guide/test_deploying_with_udc.py b/starknet_py/tests/e2e/docs/guide/test_deploying_with_udc.py index e1a2451dc..9f81345ab 100644 --- a/starknet_py/tests/e2e/docs/guide/test_deploying_with_udc.py +++ b/starknet_py/tests/e2e/docs/guide/test_deploying_with_udc.py @@ -17,7 +17,7 @@ async def test_deploying_with_udc( salt = None # docs: start - # If you use mainnet/goerli/sepolia there is no need to explicitly specify + # If you use mainnet/sepolia there is no need to explicitly specify # address of the deployer (default one will be used) deployer = Deployer() From 09759f7ddb6e1c584bd8be524784acf132e64d4e Mon Sep 17 00:00:00 2001 From: Fiiranek Date: Mon, 15 Jul 2024 13:12:22 +0200 Subject: [PATCH 04/15] Fix `test_create_contract_deployment_raw()` docs --- starknet_py/tests/e2e/docs/code_examples/test_deployer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/starknet_py/tests/e2e/docs/code_examples/test_deployer.py b/starknet_py/tests/e2e/docs/code_examples/test_deployer.py index b4bffa7e0..b2aded890 100644 --- a/starknet_py/tests/e2e/docs/code_examples/test_deployer.py +++ b/starknet_py/tests/e2e/docs/code_examples/test_deployer.py @@ -15,8 +15,8 @@ def test_init(): def test_create_contract_deployment_raw(): deployer = Deployer() - # docs-start: create_deployment_call_raw + # docs-start: create_contract_deployment_raw contract_deployment = deployer.create_contract_deployment_raw( class_hash=0x123, salt=1, raw_calldata=[3, 1, 2, 3] ) - # docs-end: create_deployment_call_raw + # docs-end: create_contract_deployment_raw From 765d0ec88460c0695548a29b9808d1f4f1eae087 Mon Sep 17 00:00:00 2001 From: Fiiranek Date: Mon, 15 Jul 2024 14:11:59 +0200 Subject: [PATCH 05/15] Fix `test_deploy_contract` docs --- starknet_py/tests/e2e/docs/code_examples/test_contract.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 14274a9c2..a3e133c05 100644 --- a/starknet_py/tests/e2e/docs/code_examples/test_contract.py +++ b/starknet_py/tests/e2e/docs/code_examples/test_contract.py @@ -61,8 +61,8 @@ async def test_declare(account, custom_proxy): @pytest.mark.asyncio -async def test_deploy_contract(account, class_hash): - # docs-start: deploy_contract +async def test_deploy_contract_v1(account, class_hash): + # docs-start: deploy_contract_v1 deploy_result = await Contract.deploy_contract_v1( account=account, class_hash=class_hash, From 8e56d24546f8b5e4f70e8fe0ff0df81b148f35b8 Mon Sep 17 00:00:00 2001 From: Fiiranek Date: Mon, 15 Jul 2024 14:15:51 +0200 Subject: [PATCH 06/15] Fix declare v1 docs --- starknet_py/tests/e2e/docs/code_examples/test_contract.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 a3e133c05..e349a556d 100644 --- a/starknet_py/tests/e2e/docs/code_examples/test_contract.py +++ b/starknet_py/tests/e2e/docs/code_examples/test_contract.py @@ -51,13 +51,13 @@ async def test_from_address(account, contract_address): @pytest.mark.asyncio -async def test_declare(account, custom_proxy): +async def test_declare_v1(account, custom_proxy): compiled_contract = custom_proxy - # docs-start: declare + # docs-start: declare_v1 declare_result = await Contract.declare_v1( account=account, compiled_contract=compiled_contract, max_fee=int(1e15) ) - # docs-end: declare + # docs-end: declare_v1 @pytest.mark.asyncio From cabb515fd83c52f2e1e35ed06f3b153f78f2fd20 Mon Sep 17 00:00:00 2001 From: Fiiranek Date: Mon, 15 Jul 2024 14:19:32 +0200 Subject: [PATCH 07/15] Add missing `docs-end` to `deploy_contract_v1` --- starknet_py/tests/e2e/docs/code_examples/test_contract.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 e349a556d..edeaa4acf 100644 --- a/starknet_py/tests/e2e/docs/code_examples/test_contract.py +++ b/starknet_py/tests/e2e/docs/code_examples/test_contract.py @@ -91,7 +91,7 @@ async def test_deploy_contract_v1(account, class_hash): constructor_args={"value": 1}, max_fee=int(1e15), ) - # docs-end: deploy_contract + # docs-end: deploy_contract_v1 def test_compute_address(custom_proxy): From 2f71007c80a5049328207beb0bddd1a6b705a5f0 Mon Sep 17 00:00:00 2001 From: Fiiranek Date: Tue, 16 Jul 2024 19:44:10 +0200 Subject: [PATCH 08/15] Restructure execute v1 docs example --- starknet_py/tests/e2e/docs/code_examples/test_account.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/starknet_py/tests/e2e/docs/code_examples/test_account.py b/starknet_py/tests/e2e/docs/code_examples/test_account.py index 6ee37626f..c9a7f92b6 100644 --- a/starknet_py/tests/e2e/docs/code_examples/test_account.py +++ b/starknet_py/tests/e2e/docs/code_examples/test_account.py @@ -36,11 +36,13 @@ async def test_execute_v1(account, contract_address): max_fee=int(1e15), ) # or + # docs-end: execute_v1 call1 = call2 = Call( to_addr=contract_address, selector=get_selector_from_name("increase_balance"), calldata=[123], ) + # docs-start: execute_v1 resp = await account.execute_v1(calls=[call1, call2], auto_estimate=True) # docs-end: execute_v1 From c16222b0b88ed1a4e643abb69c44ee4930c80a1d Mon Sep 17 00:00:00 2001 From: Fiiranek Date: Wed, 17 Jul 2024 14:28:08 +0200 Subject: [PATCH 09/15] Add docs examples for declare v2, v3 and deploy contract v3 --- .../e2e/contract_interaction/declare_test.py | 40 +--------- .../e2e/contract_interaction/deploy_test.py | 31 +------ .../e2e/docs/code_examples/test_contract.py | 80 ++++++++++++++++++- 3 files changed, 81 insertions(+), 70 deletions(-) diff --git a/starknet_py/tests/e2e/contract_interaction/declare_test.py b/starknet_py/tests/e2e/contract_interaction/declare_test.py index 370f9a845..0acd91410 100644 --- a/starknet_py/tests/e2e/contract_interaction/declare_test.py +++ b/starknet_py/tests/e2e/contract_interaction/declare_test.py @@ -1,46 +1,8 @@ import pytest from starknet_py.contract import Contract -from starknet_py.net.models import DeclareV2, DeclareV3 from starknet_py.tests.e2e.fixtures.constants import MAX_FEE, MAX_RESOURCE_BOUNDS_L1 -from starknet_py.tests.e2e.fixtures.misc import ContractVersion, load_contract - - -@pytest.mark.asyncio -async def test_contract_declare_v2(account): - compiled_contract = load_contract( - contract_name="TestContract", version=ContractVersion.V1 - ) - - declare_result = await Contract.declare_v2( - account, - compiled_contract=compiled_contract["sierra"], - compiled_contract_casm=compiled_contract["casm"], - max_fee=MAX_FEE, - ) - await declare_result.wait_for_acceptance() - - assert isinstance(declare_result.declare_transaction, DeclareV2) - assert isinstance(declare_result.hash, int) - assert isinstance(declare_result.class_hash, int) - assert declare_result.compiled_contract == compiled_contract["sierra"] - - -@pytest.mark.asyncio -async def test_contract_declare_v3(account): - contract = load_contract(contract_name="TestContract", version=ContractVersion.V2) - declare_result = await Contract.declare_v3( - account, - compiled_contract=contract["sierra"], - compiled_contract_casm=contract["casm"], - l1_resource_bounds=MAX_RESOURCE_BOUNDS_L1, - ) - await declare_result.wait_for_acceptance() - - assert isinstance(declare_result.declare_transaction, DeclareV3) - assert isinstance(declare_result.hash, int) - assert isinstance(declare_result.class_hash, int) - assert declare_result.compiled_contract == contract["sierra"] +from starknet_py.tests.e2e.fixtures.misc import load_contract @pytest.mark.asyncio diff --git a/starknet_py/tests/e2e/contract_interaction/deploy_test.py b/starknet_py/tests/e2e/contract_interaction/deploy_test.py index 04176ccbb..e2d4ab85c 100644 --- a/starknet_py/tests/e2e/contract_interaction/deploy_test.py +++ b/starknet_py/tests/e2e/contract_interaction/deploy_test.py @@ -6,7 +6,7 @@ from starknet_py.common import create_sierra_compiled_contract from starknet_py.contract import Contract, DeclareResult -from starknet_py.net.client_models import InvokeTransactionV1, InvokeTransactionV3 +from starknet_py.net.client_models import InvokeTransactionV1 from starknet_py.net.models import DeclareV2 from starknet_py.tests.e2e.fixtures.constants import MAX_FEE, MAX_RESOURCE_BOUNDS_L1 from starknet_py.tests.e2e.fixtures.misc import load_contract @@ -123,35 +123,6 @@ async def test_deploy_contract_v1(account, cairo1_hello_starknet_class_hash: int assert class_hash == cairo1_hello_starknet_class_hash -@pytest.mark.asyncio -async def test_deploy_contract_v3(account, cairo1_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_v3( - class_hash=cairo1_hello_starknet_class_hash, - account=account, - abi=abi, - l1_resource_bounds=MAX_RESOURCE_BOUNDS_L1, - cairo_version=1, - ) - await deploy_result.wait_for_acceptance() - - contract = deploy_result.deployed_contract - assert isinstance(contract.address, int) - assert len(contract.functions) != 0 - - transaction = await account.client.get_transaction(tx_hash=deploy_result.hash) - assert isinstance(transaction, InvokeTransactionV3) - - class_hash = await account.client.get_class_hash_at( - contract_address=contract.address - ) - assert class_hash == cairo1_hello_starknet_class_hash - - @pytest.mark.asyncio async def test_general_simplified_deployment_flow(account, map_compiled_contract): declare_result = await Contract.declare_v1( 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 edeaa4acf..9d424e877 100644 --- a/starknet_py/tests/e2e/docs/code_examples/test_contract.py +++ b/starknet_py/tests/e2e/docs/code_examples/test_contract.py @@ -1,11 +1,14 @@ # pylint: disable=unused-variable import pytest +from starknet_py.common import create_sierra_compiled_contract from starknet_py.contract import Contract from starknet_py.net.account.account import Account +from starknet_py.net.client_models import InvokeTransactionV3, ResourceBounds from starknet_py.net.full_node_client import FullNodeClient -from starknet_py.net.models import StarknetChainId +from starknet_py.net.models import DeclareV2, DeclareV3, StarknetChainId from starknet_py.net.signer.stark_curve_signer import KeyPair +from starknet_py.tests.e2e.fixtures.misc import ContractVersion, load_contract def test_init(): @@ -60,6 +63,49 @@ async def test_declare_v1(account, custom_proxy): # docs-end: declare_v1 +@pytest.mark.asyncio +async def test_declare_v2(account): + compiled_contract = load_contract( + contract_name="TestContract", version=ContractVersion.V1 + ) + # docs-start: declare_v2 + # here contract is a dict containing sierra and casm artifacts + declare_result = await Contract.declare_v2( + account, + compiled_contract=compiled_contract["sierra"], + compiled_contract_casm=compiled_contract["casm"], + max_fee=int(1e15), + ) + # docs-end: declare_v2 + await declare_result.wait_for_acceptance() + + assert isinstance(declare_result.declare_transaction, DeclareV2) + assert isinstance(declare_result.hash, int) + assert isinstance(declare_result.class_hash, int) + assert declare_result.compiled_contract == compiled_contract["sierra"] + + +@pytest.mark.asyncio +async def test_declare_v3(account): + contract = load_contract(contract_name="TestContract", version=ContractVersion.V2) + # docs-start: declare_v3 + declare_result = await Contract.declare_v3( + account, + compiled_contract=contract["sierra"], + compiled_contract_casm=contract["casm"], + l1_resource_bounds=ResourceBounds( + max_amount=int(1e5), max_price_per_unit=int(1e13) + ), + ) + # docs-end: declare_v3 + await declare_result.wait_for_acceptance() + + assert isinstance(declare_result.declare_transaction, DeclareV3) + assert isinstance(declare_result.hash, int) + assert isinstance(declare_result.class_hash, int) + assert declare_result.compiled_contract == contract["sierra"] + + @pytest.mark.asyncio async def test_deploy_contract_v1(account, class_hash): # docs-start: deploy_contract_v1 @@ -94,6 +140,38 @@ async def test_deploy_contract_v1(account, class_hash): # docs-end: deploy_contract_v1 +@pytest.mark.asyncio +async def test_deploy_contract_v3(account, cairo1_hello_starknet_class_hash: int): + compiled_contract = load_contract("HelloStarknet")["sierra"] + abi = create_sierra_compiled_contract( + compiled_contract=compiled_contract + ).parsed_abi + # docs-start: deploy_contract_v3 + deploy_result = await Contract.deploy_contract_v3( + class_hash=cairo1_hello_starknet_class_hash, + account=account, + abi=abi, + l1_resource_bounds=ResourceBounds( + max_amount=int(1e5), max_price_per_unit=int(1e13) + ), + cairo_version=1, + ) + # docs-end: deploy_contract_v3 + await deploy_result.wait_for_acceptance() + + contract = deploy_result.deployed_contract + assert isinstance(contract.address, int) + assert len(contract.functions) != 0 + + transaction = await account.client.get_transaction(tx_hash=deploy_result.hash) + assert isinstance(transaction, InvokeTransactionV3) + + class_hash = await account.client.get_class_hash_at( + contract_address=contract.address + ) + assert class_hash == cairo1_hello_starknet_class_hash + + def test_compute_address(custom_proxy): compiled_contract = custom_proxy # docs-start: compute_address From fe344d5ac379dc075e985384a704f93c0e2aef0c Mon Sep 17 00:00:00 2001 From: Franciszek Job <54181625+franciszekjob@users.noreply.github.com> Date: Wed, 17 Jul 2024 16:38:27 +0200 Subject: [PATCH 10/15] Update starknet_py/tests/e2e/docs/code_examples/test_contract.py Co-authored-by: ddoktorski <45050160+ddoktorski@users.noreply.github.com> --- starknet_py/tests/e2e/docs/code_examples/test_contract.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 9d424e877..141273c24 100644 --- a/starknet_py/tests/e2e/docs/code_examples/test_contract.py +++ b/starknet_py/tests/e2e/docs/code_examples/test_contract.py @@ -69,7 +69,7 @@ async def test_declare_v2(account): contract_name="TestContract", version=ContractVersion.V1 ) # docs-start: declare_v2 - # here contract is a dict containing sierra and casm artifacts + # here `compiled_contract` is a dict containing sierra and casm artifacts declare_result = await Contract.declare_v2( account, compiled_contract=compiled_contract["sierra"], From 2cf8f3b4fda5c07ab61b833a260d3afe83b6f874 Mon Sep 17 00:00:00 2001 From: Fiiranek Date: Thu, 18 Jul 2024 13:11:53 +0200 Subject: [PATCH 11/15] Add comment and remove `cairo_version` param in declare v3 example --- starknet_py/tests/e2e/docs/code_examples/test_contract.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 9d424e877..0866138a3 100644 --- a/starknet_py/tests/e2e/docs/code_examples/test_contract.py +++ b/starknet_py/tests/e2e/docs/code_examples/test_contract.py @@ -89,6 +89,7 @@ async def test_declare_v2(account): async def test_declare_v3(account): contract = load_contract(contract_name="TestContract", version=ContractVersion.V2) # docs-start: declare_v3 + # here contract is a dict containing sierra and casm artifacts declare_result = await Contract.declare_v3( account, compiled_contract=contract["sierra"], @@ -154,7 +155,6 @@ async def test_deploy_contract_v3(account, cairo1_hello_starknet_class_hash: int l1_resource_bounds=ResourceBounds( max_amount=int(1e5), max_price_per_unit=int(1e13) ), - cairo_version=1, ) # docs-end: deploy_contract_v3 await deploy_result.wait_for_acceptance() From 456cd9ea6c415298f75f5489b9bcbc810e48c48c Mon Sep 17 00:00:00 2001 From: Franciszek Job <54181625+franciszekjob@users.noreply.github.com> Date: Thu, 18 Jul 2024 13:14:35 +0200 Subject: [PATCH 12/15] Update starknet_py/tests/e2e/docs/code_examples/test_contract.py Co-authored-by: ddoktorski <45050160+ddoktorski@users.noreply.github.com> --- starknet_py/tests/e2e/docs/code_examples/test_contract.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 9a931dddb..42d995739 100644 --- a/starknet_py/tests/e2e/docs/code_examples/test_contract.py +++ b/starknet_py/tests/e2e/docs/code_examples/test_contract.py @@ -147,9 +147,10 @@ async def test_deploy_contract_v3(account, cairo1_hello_starknet_class_hash: int abi = create_sierra_compiled_contract( compiled_contract=compiled_contract ).parsed_abi + class_hash = cairo1_hello_starknet_class_hash # docs-start: deploy_contract_v3 deploy_result = await Contract.deploy_contract_v3( - class_hash=cairo1_hello_starknet_class_hash, + class_hash=class_hash, account=account, abi=abi, l1_resource_bounds=ResourceBounds( From 96d1db041b61bb6fd49bc1d0ab420dd719368731 Mon Sep 17 00:00:00 2001 From: Fiiranek Date: Thu, 18 Jul 2024 13:40:08 +0200 Subject: [PATCH 13/15] Include creation of abi in `test_deploy_contract_v3` --- starknet_py/tests/e2e/docs/code_examples/test_contract.py | 2 ++ 1 file changed, 2 insertions(+) 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 42d995739..7f8130985 100644 --- a/starknet_py/tests/e2e/docs/code_examples/test_contract.py +++ b/starknet_py/tests/e2e/docs/code_examples/test_contract.py @@ -144,9 +144,11 @@ 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): 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 # docs-start: deploy_contract_v3 deploy_result = await Contract.deploy_contract_v3( From 9d2e4f9f4f9b208abf877f4c108c37b5bb07f029 Mon Sep 17 00:00:00 2001 From: Fiiranek Date: Thu, 18 Jul 2024 13:50:17 +0200 Subject: [PATCH 14/15] Add `test_execute_v3` --- .../e2e/docs/code_examples/test_account.py | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/starknet_py/tests/e2e/docs/code_examples/test_account.py b/starknet_py/tests/e2e/docs/code_examples/test_account.py index c9a7f92b6..ab40386c1 100644 --- a/starknet_py/tests/e2e/docs/code_examples/test_account.py +++ b/starknet_py/tests/e2e/docs/code_examples/test_account.py @@ -6,7 +6,7 @@ from starknet_py.constants import FEE_CONTRACT_ADDRESS from starknet_py.hash.selector import get_selector_from_name from starknet_py.net.account.account import Account -from starknet_py.net.client_models import Call +from starknet_py.net.client_models import Call, ResourceBounds from starknet_py.net.full_node_client import FullNodeClient from starknet_py.net.models import StarknetChainId from starknet_py.net.models.typed_data import TypedDataDict @@ -47,6 +47,31 @@ async def test_execute_v1(account, contract_address): # docs-end: execute_v1 +@pytest.mark.asyncio +async def test_execute_v3(account, contract_address): + # docs-start: execute_v3 + resp = await account.execute_v3( + Call( + to_addr=contract_address, + selector=get_selector_from_name("increase_balance"), + calldata=[123], + ), + l1_resource_bounds=ResourceBounds( + max_amount=int(1e5), max_price_per_unit=int(1e13) + ), + ) + # or + # docs-end: execute_v3 + call1 = call2 = Call( + to_addr=contract_address, + selector=get_selector_from_name("increase_balance"), + calldata=[123], + ) + # docs-start: execute_v3 + resp = await account.execute_v3(calls=[call1, call2], auto_estimate=True) + # docs-end: execute_v3 + + @pytest.mark.asyncio @patch( "starknet_py.net.account.account.Account.get_balance", From 530d541426fb23e92515b62d0884ba8552d50964 Mon Sep 17 00:00:00 2001 From: Franciszek Job <54181625+franciszekjob@users.noreply.github.com> Date: Thu, 18 Jul 2024 15:38:35 +0200 Subject: [PATCH 15/15] Update starknet_py/tests/e2e/docs/code_examples/test_contract.py Co-authored-by: ddoktorski <45050160+ddoktorski@users.noreply.github.com> --- starknet_py/tests/e2e/docs/code_examples/test_contract.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 7f8130985..e969794cd 100644 --- a/starknet_py/tests/e2e/docs/code_examples/test_contract.py +++ b/starknet_py/tests/e2e/docs/code_examples/test_contract.py @@ -89,7 +89,7 @@ async def test_declare_v2(account): async def test_declare_v3(account): contract = load_contract(contract_name="TestContract", version=ContractVersion.V2) # docs-start: declare_v3 - # here contract is a dict containing sierra and casm artifacts + # here `contract` is a dict containing sierra and casm artifacts declare_result = await Contract.declare_v3( account, compiled_contract=contract["sierra"],