From e67e16f2639488200d7c94585820edf3cb7e0fc2 Mon Sep 17 00:00:00 2001 From: Fiiranek Date: Fri, 5 Dec 2025 11:58:29 +0100 Subject: [PATCH 01/17] Bump devnet to 0.7.0 --- .github/workflows/checks.yml | 2 +- starknet_py/net/schemas/common.py | 2 +- .../net/schemas/rpc/executables_api.py | 6 ++- starknet_py/tests/e2e/account/account_test.py | 13 +----- starknet_py/tests/e2e/client/client_test.py | 3 -- .../tests/e2e/client/full_node_test.py | 11 +---- .../tests/e2e/client/websocket_client_test.py | 4 -- .../code_examples/test_full_node_client.py | 1 - .../code_examples/test_websocket_client.py | 4 -- .../e2e/docs/guide/test_cairo1_contract.py | 4 +- .../tests/e2e/fixtures/contracts_v1.py | 45 ++++--------------- .../e2e/tests_on_networks/client_test.py | 1 - starknet_py/tests/install_devnet.sh | 4 +- 13 files changed, 21 insertions(+), 79 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 3c8c657f8..43230fc1b 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -3,7 +3,7 @@ name: Checks env: CAIRO_LANG_VERSION: "0.13.1" # TODO(#1611) - DEVNET_SHA: e7ae78e59aaed289c081ab602328349d296ea4db # v0.5.1 + DEVNET_SHA: b761edef5b89a4faa7a972d7172a324cd646d612 # v0.7.0 LEDGER_APP_SHA: 768a7b47b0da681b28112342edd76e2c9b292c4e # v2.3.1 LEDGER_APP_DEV_TOOLS_SHA: a845b2ab0b5dd824133f73858f6f373edea85ec1bd828245bf50ce9700f33bcb # v4.5.0 diff --git a/starknet_py/net/schemas/common.py b/starknet_py/net/schemas/common.py index 7f296a847..72a6025f7 100644 --- a/starknet_py/net/schemas/common.py +++ b/starknet_py/net/schemas/common.py @@ -49,7 +49,7 @@ def _serialize(self, value: Any, attr: Optional[str], obj: Any, **kwargs): if self._is_str_and_valid_pattern(value): return value - + print("xxx", value) raise ValidationError( f"Invalid value provided for {self.__class__.__name__}: {value}" ) diff --git a/starknet_py/net/schemas/rpc/executables_api.py b/starknet_py/net/schemas/rpc/executables_api.py index a382b47a9..fe438d9c4 100644 --- a/starknet_py/net/schemas/rpc/executables_api.py +++ b/starknet_py/net/schemas/rpc/executables_api.py @@ -2,6 +2,7 @@ from marshmallow import ValidationError, fields, post_load, validate +from starknet_py.constants import FIELD_PRIME from starknet_py.net.executable_models import ( AllocConstantSize, AllocConstantSizeInner, @@ -147,7 +148,10 @@ class ImmediateSchema(Schema): @post_load def make_dataclass(self, data, **kwargs) -> Immediate: - return Immediate(**data) + # Normalizacja modulo FIELD_PRIME + print("xxx", data) + value = data["immediate"] % FIELD_PRIME + return Immediate(immediate=value) class BinOpBField(fields.Field): diff --git a/starknet_py/tests/e2e/account/account_test.py b/starknet_py/tests/e2e/account/account_test.py index b07f9b60b..60351e571 100644 --- a/starknet_py/tests/e2e/account/account_test.py +++ b/starknet_py/tests/e2e/account/account_test.py @@ -8,7 +8,6 @@ from starknet_py.constants import ARGENT_V040_CLASS_HASH from starknet_py.hash.address import compute_address from starknet_py.hash.casm_class_hash import compute_casm_class_hash -from starknet_py.hash.hash_method import HashMethod from starknet_py.hash.selector import get_selector_from_name from starknet_py.net.account.account import Account from starknet_py.net.account.base_account import BaseAccount @@ -758,11 +757,7 @@ async def test_declare_v3_with_tip(account): tip = 12345 signed_tx = await account.sign_declare_v3( compiled_contract["sierra"], - compute_casm_class_hash( - # TODO(#1659): Use blake - create_casm_class(compiled_contract["casm"]), - HashMethod.POSEIDON, - ), + compute_casm_class_hash(create_casm_class(compiled_contract["casm"])), resource_bounds=MAX_RESOURCE_BOUNDS, tip=tip, ) @@ -785,11 +780,7 @@ async def test_declare_v3_auto_estimate_tip( mocked_block_with_txs.return_value = block_with_tips_mock signed_tx = await account.sign_declare_v3( compiled_contract["sierra"], - compute_casm_class_hash( - # TODO(#1659): Use blake - create_casm_class(compiled_contract["casm"]), - HashMethod.POSEIDON, - ), + compute_casm_class_hash(create_casm_class(compiled_contract["casm"])), resource_bounds=MAX_RESOURCE_BOUNDS, auto_estimate_tip=True, ) diff --git a/starknet_py/tests/e2e/client/client_test.py b/starknet_py/tests/e2e/client/client_test.py index e5b0f5f0c..e725f2732 100644 --- a/starknet_py/tests/e2e/client/client_test.py +++ b/starknet_py/tests/e2e/client/client_test.py @@ -641,7 +641,6 @@ async def test_state_update_declared_contract_hashes( assert class_hash in state_update.state_diff.deprecated_declared_classes -@pytest.mark.skip(reason="TODO(#1659)") @pytest.mark.run_on_devnet @pytest.mark.asyncio async def test_state_update_storage_diffs( @@ -659,7 +658,6 @@ async def test_state_update_storage_diffs( assert isinstance(state_update, BlockStateUpdate) -@pytest.mark.skip(reason="TODO(#1659)") @pytest.mark.run_on_devnet @pytest.mark.asyncio async def test_state_update_deployed_contracts( @@ -754,7 +752,6 @@ async def test_get_block_with_declare_v3( # TODO (#1219): add assert for replaced_class once it is fixed in devnet -@pytest.mark.skip(reason="TODO(#1659)") @pytest.mark.asyncio async def test_get_new_state_update( client, diff --git a/starknet_py/tests/e2e/client/full_node_test.py b/starknet_py/tests/e2e/client/full_node_test.py index 44e71f7ef..071024a45 100644 --- a/starknet_py/tests/e2e/client/full_node_test.py +++ b/starknet_py/tests/e2e/client/full_node_test.py @@ -8,7 +8,6 @@ from starknet_py.contract import Contract from starknet_py.hash.address import compute_address from starknet_py.hash.casm_class_hash import compute_casm_class_hash -from starknet_py.hash.hash_method import HashMethod from starknet_py.hash.selector import get_selector_from_name from starknet_py.hash.storage import get_storage_var_address from starknet_py.net.account.account import Account @@ -146,7 +145,6 @@ async def test_get_storage_at_incorrect_address_full_node_client(client): "--contract_dir=v1" in sys.argv, reason="Contract exists only in v2 directory", ) -@pytest.mark.skip("TODO(#1659)") @pytest.mark.run_on_devnet @pytest.mark.asyncio async def test_get_events_without_following_continuation_token( @@ -176,7 +174,6 @@ async def test_get_events_without_following_continuation_token( "--contract_dir=v1" in sys.argv, reason="Contract exists only in v2 directory", ) -@pytest.mark.skip("TODO(#1659)") @pytest.mark.run_on_devnet @pytest.mark.asyncio async def test_get_events_follow_continuation_token( @@ -233,7 +230,6 @@ async def test_get_events_nonexistent_event_name( "--contract_dir=v1" in sys.argv, reason="Contract exists only in v2 directory", ) -@pytest.mark.skip("TODO(#1659)") @pytest.mark.run_on_devnet @pytest.mark.asyncio async def test_get_events_with_two_events( @@ -287,7 +283,6 @@ async def test_get_events_with_two_events( "--contract_dir=v1" in sys.argv, reason="Contract exists only in v2 directory", ) -@pytest.mark.skip("TODO(#1659)") @pytest.mark.run_on_devnet @pytest.mark.asyncio async def test_get_events_start_from_continuation_token( @@ -319,7 +314,6 @@ async def test_get_events_start_from_continuation_token( "--contract_dir=v1" in sys.argv, reason="Contract exists only in v2 directory", ) -@pytest.mark.skip("TODO(#1659)") @pytest.mark.run_on_devnet @pytest.mark.asyncio async def test_get_events_no_params( @@ -476,7 +470,6 @@ async def test_simulate_transactions_skip_fee_charge( assert simulated_txs is not None -@pytest.mark.skip(reason="TODO(#1659)") @pytest.mark.asyncio async def test_simulate_transactions_invoke(account, deployed_balance_contract): assert isinstance(deployed_balance_contract, Contract) @@ -507,7 +500,6 @@ async def test_simulate_transactions_invoke(account, deployed_balance_contract): assert simulated_txs[0].transaction_trace.execution_resources is not None -@pytest.mark.skip(reason="TODO(#1659)") @pytest.mark.asyncio async def test_simulate_transactions_two_txs(account, deployed_balance_contract): assert isinstance(deployed_balance_contract, Contract) @@ -523,8 +515,7 @@ async def test_simulate_transactions_two_txs(account, deployed_balance_contract) ) casm_class = create_casm_class(contract["casm"]) - # TODO(#1659): Use blake - casm_class_hash = compute_casm_class_hash(casm_class, HashMethod.POSEIDON) + casm_class_hash = compute_casm_class_hash(casm_class) declare_v3_tx = await account.sign_declare_v3( compiled_contract=contract["sierra"], diff --git a/starknet_py/tests/e2e/client/websocket_client_test.py b/starknet_py/tests/e2e/client/websocket_client_test.py index 328cc78e5..232d4fe8c 100644 --- a/starknet_py/tests/e2e/client/websocket_client_test.py +++ b/starknet_py/tests/e2e/client/websocket_client_test.py @@ -131,7 +131,6 @@ async def test_unsubscribe_with_non_existing_id( assert unsubscribe_result is False -@pytest.mark.skip(reason="TODO(#1659)") @pytest.mark.asyncio async def test_subscribe_events_with_finality_status( websocket_client: WebsocketClient, @@ -174,7 +173,6 @@ def handler(new_events_notification: NewEventsNotification): assert unsubscribe_result is True -@pytest.mark.skip(reason="TODO(#1659)") @pytest.mark.asyncio async def test_subscribe_new_transactions_with_finality_status( websocket_client: WebsocketClient, @@ -214,7 +212,6 @@ def handler(new_tx_notification: NewTransactionNotification): assert unsubscribe_result is True -@pytest.mark.skip(reason="TODO(#1659)") @pytest.mark.asyncio async def test_subscribe_new_transaction_receipts_with_finality_status( websocket_client: WebsocketClient, @@ -254,7 +251,6 @@ def handler(new_tx_receipt: NewTransactionReceiptsNotification): assert unsubscribe_result is True -@pytest.mark.skip("TODO(#1659)") @pytest.mark.asyncio async def test_subscribe_events_with_all_filters( client: FullNodeClient, 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 3ed913820..624d92299 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 @@ -42,7 +42,6 @@ async def test_get_block(client, block_with_declare_hash): # docs-end: get_block -@pytest.mark.skip(reason="TODO(#1659)") @pytest.mark.asyncio async def test_get_state_update( client, declare_transaction_hash diff --git a/starknet_py/tests/e2e/docs/code_examples/test_websocket_client.py b/starknet_py/tests/e2e/docs/code_examples/test_websocket_client.py index 3fea01785..fc9c26a8d 100644 --- a/starknet_py/tests/e2e/docs/code_examples/test_websocket_client.py +++ b/starknet_py/tests/e2e/docs/code_examples/test_websocket_client.py @@ -85,7 +85,6 @@ def handler(new_heads_notification: NewHeadsNotification): assert unsubscribe_result is True -@pytest.mark.skip("TODO(#1659)") @pytest.mark.asyncio async def test_subscribe_events( websocket_client: WebsocketClient, @@ -139,7 +138,6 @@ def handler(new_events_notification: NewEventsNotification): assert unsubscribe_result is True -@pytest.mark.skip("TODO(#1659)") @pytest.mark.asyncio async def test_subscribe_transaction_status( websocket_client: WebsocketClient, @@ -204,7 +202,6 @@ def handler(transaction_status_notification: TransactionStatusNotification): assert unsubscribe_result is True -@pytest.mark.skip("TODO(#1659)") @pytest.mark.asyncio async def test_subscribe_new_transaction_receipts( websocket_client: WebsocketClient, @@ -268,7 +265,6 @@ def handler( assert unsubscribe_result is True -@pytest.mark.skip("TODO(#1659)") @pytest.mark.asyncio async def test_on_chain_reorg( websocket_client: WebsocketClient, diff --git a/starknet_py/tests/e2e/docs/guide/test_cairo1_contract.py b/starknet_py/tests/e2e/docs/guide/test_cairo1_contract.py index 148669a46..cf3bece38 100644 --- a/starknet_py/tests/e2e/docs/guide/test_cairo1_contract.py +++ b/starknet_py/tests/e2e/docs/guide/test_cairo1_contract.py @@ -2,7 +2,6 @@ import pytest -from starknet_py.hash.hash_method import HashMethod from starknet_py.net.client_models import SierraContractClass from starknet_py.net.udc_deployer.deployer import _get_random_salt from starknet_py.tests.e2e.fixtures.constants import MAX_RESOURCE_BOUNDS @@ -31,9 +30,8 @@ async def test_cairo1_contract( # contract_compiled_casm is a string containing the content of the starknet-sierra-compile (.casm file) casm_class = create_casm_class(contract_compiled_casm) - # TODO(#1659): Use blake # Compute Casm class hash - casm_class_hash = compute_casm_class_hash(casm_class, HashMethod.POSEIDON) + casm_class_hash = compute_casm_class_hash(casm_class) # docs: end assert casm_class_hash == compiled_class_hash diff --git a/starknet_py/tests/e2e/fixtures/contracts_v1.py b/starknet_py/tests/e2e/fixtures/contracts_v1.py index 0d6bc5d4a..39abf02d5 100644 --- a/starknet_py/tests/e2e/fixtures/contracts_v1.py +++ b/starknet_py/tests/e2e/fixtures/contracts_v1.py @@ -19,11 +19,7 @@ async def declare_contract( account: BaseAccount, compiled_contract: str, compiled_contract_casm: str ) -> Tuple[int, int]: - casm_class_hash = compute_casm_class_hash( - # TODO(#1659): Use blake - create_casm_class(compiled_contract_casm), - HashMethod.POSEIDON, - ) + casm_class_hash = compute_casm_class_hash(create_casm_class(compiled_contract_casm)) declare_tx = await account.sign_declare_v3( compiled_contract=compiled_contract, @@ -71,11 +67,7 @@ def constructor_with_arguments_abi() -> List: @pytest_asyncio.fixture(scope="package") async def declare_v3_hello_starknet(account: BaseAccount) -> DeclareV3: contract = load_contract("HelloStarknet") - casm_class_hash = compute_casm_class_hash( - # TODO(#1659): Use blake - create_casm_class(contract["casm"]), - HashMethod.POSEIDON, - ) + casm_class_hash = compute_casm_class_hash(create_casm_class(contract["casm"])) declare_tx = await account.sign_declare_v3( contract["sierra"], casm_class_hash, resource_bounds=MAX_RESOURCE_BOUNDS @@ -241,11 +233,7 @@ def map_compiled_contract_and_class_hash() -> Tuple[str, int]: return ( contract["sierra"], - compute_casm_class_hash( - # TODO(#1659): Use blake - create_casm_class(contract["casm"]), - HashMethod.POSEIDON, - ), + compute_casm_class_hash(create_casm_class(contract["casm"])), ) @@ -255,11 +243,7 @@ def map_compiled_contract_and_class_hash_copy_1() -> Tuple[str, int]: return ( contract["sierra"], - compute_casm_class_hash( - # TODO(#1659): Use blake - create_casm_class(contract["casm"]), - HashMethod.POSEIDON, - ), + compute_casm_class_hash(create_casm_class(contract["casm"])), ) @@ -269,11 +253,7 @@ def map_compiled_contract_and_class_hash_copy_2() -> Tuple[str, int]: return ( contract["sierra"], - compute_casm_class_hash( - # TODO(#1659): Use blake - create_casm_class(contract["casm"]), - HashMethod.POSEIDON, - ), + compute_casm_class_hash(create_casm_class(contract["casm"])), ) @@ -325,11 +305,7 @@ def sierra_minimal_compiled_contract_and_class_hash() -> Tuple[str, int]: return ( contract["sierra"], - compute_casm_class_hash( - # TODO(#1659): Use blake - create_casm_class(contract["casm"]), - HashMethod.POSEIDON, - ), + compute_casm_class_hash(create_casm_class(contract["casm"])), ) @@ -342,11 +318,7 @@ def abi_types_compiled_contract_and_class_hash() -> Tuple[str, int]: return ( contract["sierra"], - compute_casm_class_hash( - # TODO(#1659): Use blake - create_casm_class(contract["casm"]), - HashMethod.POSEIDON, - ), + compute_casm_class_hash(create_casm_class(contract["casm"])), ) @@ -378,8 +350,7 @@ async def account_declare_class_hash( """ casm_class = create_casm_class(compiled_account_contract_casm) - # TODO(#1659): Use blake - casm_class_hash = compute_casm_class_hash(casm_class, HashMethod.POSEIDON) + casm_class_hash = compute_casm_class_hash(casm_class) declare_v3_transaction = await account.sign_declare_v3( compiled_contract=compiled_account_contract, compiled_class_hash=casm_class_hash, diff --git a/starknet_py/tests/e2e/tests_on_networks/client_test.py b/starknet_py/tests/e2e/tests_on_networks/client_test.py index f3c186c48..ef3742fa7 100644 --- a/starknet_py/tests/e2e/tests_on_networks/client_test.py +++ b/starknet_py/tests/e2e/tests_on_networks/client_test.py @@ -468,7 +468,6 @@ async def test_get_chain_id_sepolia_testnet(client_sepolia_testnet): assert chain_id == hex(StarknetChainId.SEPOLIA.value) -@pytest.mark.skip("TODO(#1659)") @pytest.mark.asyncio async def test_get_events_sepolia_testnet(client_sepolia_testnet): events_chunk = await client_sepolia_testnet.get_events( diff --git a/starknet_py/tests/install_devnet.sh b/starknet_py/tests/install_devnet.sh index b20ebaaaa..db9298a0c 100755 --- a/starknet_py/tests/install_devnet.sh +++ b/starknet_py/tests/install_devnet.sh @@ -2,8 +2,8 @@ set -e DEVNET_INSTALL_DIR="$(git rev-parse --show-toplevel)/starknet_py/tests/e2e/devnet/bin" -DEVNET_REPO="https://github.com/0xSpaceShard/starknet-devnet-rs" -DEVNET_VERSION="v0.5.1" +DEVNET_REPO="https://github.com/0xSpaceShard/starknet-devnet" +DEVNET_VERSION="v0.7.0" require_cmd() { if ! command -v "$1" >/dev/null 2>&1; then From bdf54181c8598798919b91582cb2ffc91c42a166 Mon Sep 17 00:00:00 2001 From: Fiiranek Date: Fri, 5 Dec 2025 12:08:57 +0100 Subject: [PATCH 02/17] Support RPC 0.10.0 --- docs/migration_guide.rst | 14 +++++++++++++ starknet_py/net/client_models.py | 7 +++++++ starknet_py/net/schemas/rpc/block.py | 15 +++++++++++++- starknet_py/tests/e2e/fixtures/misc.py | 7 +++++++ .../e2e/tests_on_networks/client_test.py | 20 +++++++++++++++++++ 5 files changed, 62 insertions(+), 1 deletion(-) diff --git a/docs/migration_guide.rst b/docs/migration_guide.rst index ab3f503c1..f1b6df1ee 100644 --- a/docs/migration_guide.rst +++ b/docs/migration_guide.rst @@ -1,6 +1,20 @@ Migration guide =============== +************************ +0.29.0-0 Migration guide +************************ + +Version 0.29.0 of **starknet.py** comes with full support for RPC 0.10.0. + +0.29.0 Targeted versions +------------------------ +- Starknet - `0.14.1 `_ +- RPC - `0.10.0 `_ + +.. py:currentmodule:: starknet_py.net.client_models +1. :class:`BlockHeader`: Added new fields: ``event_commitment``, ``transaction_commitment``, ``receipt_commitment``, ``state_diff_commitment``, ``event_count``, ``transaction_count``, ``state_diff_length``. + **************************** 0.29.0-rc.2 Migration guide **************************** diff --git a/starknet_py/net/client_models.py b/starknet_py/net/client_models.py index daa9f1b9f..bcbb8cbd0 100644 --- a/starknet_py/net/client_models.py +++ b/starknet_py/net/client_models.py @@ -609,6 +609,13 @@ class BlockHeader: l1_data_gas_price: ResourcePrice l1_da_mode: L1DAMode starknet_version: str + event_commitment: int + transaction_commitment: int + receipt_commitment: int + state_diff_commitment: int + event_count: int + transaction_count: int + state_diff_length: int @dataclass diff --git a/starknet_py/net/schemas/rpc/block.py b/starknet_py/net/schemas/rpc/block.py index 8dd134e92..bb3375a53 100644 --- a/starknet_py/net/schemas/rpc/block.py +++ b/starknet_py/net/schemas/rpc/block.py @@ -1,4 +1,4 @@ -from marshmallow import fields, post_load +from marshmallow import fields, post_load, validate from starknet_py.net.client_models import ( BlockHashAndNumber, @@ -78,6 +78,19 @@ class BlockHeaderSchema(Schema): ) l1_da_mode = L1DAModeField(data_key="l1_da_mode", required=True) starknet_version = fields.String(data_key="starknet_version", required=True) + event_commitment = Felt(data_key="event_commitment", required=True) + transaction_commitment = Felt(data_key="transaction_commitment", required=True) + receipt_commitment = Felt(data_key="receipt_commitment", required=True) + state_diff_commitment = Felt(data_key="state_diff_commitment", required=True) + event_count = fields.Integer( + data_key="event_count", required=True, validate=validate.Range(min=0) + ) + transaction_count = fields.Integer( + data_key="transaction_count", required=True, validate=validate.Range(min=0) + ) + state_diff_length = fields.Integer( + data_key="state_diff_length", required=True, validate=validate.Range(min=0) + ) @post_load def make_dataclass(self, data, **kwargs) -> BlockHeader: diff --git a/starknet_py/tests/e2e/fixtures/misc.py b/starknet_py/tests/e2e/fixtures/misc.py index af17c8303..309301473 100644 --- a/starknet_py/tests/e2e/fixtures/misc.py +++ b/starknet_py/tests/e2e/fixtures/misc.py @@ -124,6 +124,13 @@ def starknet_block_mock() -> StarknetBlock: starknet_version="0.14.0", status=BlockStatus.ACCEPTED_ON_L2, transactions=[], + event_commitment=0, + transaction_commitment=0, + receipt_commitment=0, + state_diff_commitment=0, + event_count=0, + transaction_count=0, + state_diff_length=0, ) diff --git a/starknet_py/tests/e2e/tests_on_networks/client_test.py b/starknet_py/tests/e2e/tests_on_networks/client_test.py index ef3742fa7..5f6e3dba8 100644 --- a/starknet_py/tests/e2e/tests_on_networks/client_test.py +++ b/starknet_py/tests/e2e/tests_on_networks/client_test.py @@ -403,6 +403,16 @@ async def test_get_block_new_header_fields(client_sepolia_testnet): assert block.starknet_version is not None assert block.l1_gas_price is not None assert block.l1_gas_price.price_in_wei > 0 + assert block.event_commitment is not None + assert block.transaction_commitment is not None + assert block.receipt_commitment is not None + assert block.state_diff_commitment is not None + assert block.event_count is not None + assert block.transaction_count is not None + assert block.state_diff_length is not None + assert block.event_count >= 0 + assert block.transaction_count >= 0 + assert block.state_diff_length >= 0 pre_confirmed_block = await client_sepolia_testnet.get_block_with_txs( block_number="pre_confirmed" @@ -422,6 +432,16 @@ async def test_get_block_with_tx_hashes_new_header_fields(client_sepolia_testnet assert block.starknet_version is not None assert block.l1_gas_price is not None assert block.l1_gas_price.price_in_wei > 0 + assert block.event_commitment is not None + assert block.transaction_commitment is not None + assert block.receipt_commitment is not None + assert block.state_diff_commitment is not None + assert block.event_count is not None + assert block.transaction_count is not None + assert block.state_diff_length is not None + assert block.event_count >= 0 + assert block.transaction_count >= 0 + assert block.state_diff_length >= 0 pre_confirmed_block = await client_sepolia_testnet.get_block_with_tx_hashes( block_number="pre_confirmed" From e19dd15c1bfd30a66da57866393c360a2c513358 Mon Sep 17 00:00:00 2001 From: Fiiranek Date: Fri, 5 Dec 2025 12:10:05 +0100 Subject: [PATCH 03/17] Update `EXPECTED_RPC_VERSION` --- starknet_py/constants.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/starknet_py/constants.py b/starknet_py/constants.py index 9de318e89..e6656606c 100644 --- a/starknet_py/constants.py +++ b/starknet_py/constants.py @@ -53,7 +53,7 @@ class OutsideExecutionInterfaceID(IntEnum): V2 = 0x1D1144BB2138366FF28D8E9AB57456B1D332AC42196230C3A602003C89872 -EXPECTED_RPC_VERSION = "0.10.0-rc.1" +EXPECTED_RPC_VERSION = "0.10.0" ARGENT_V040_CLASS_HASH = ( 0x036078334509B514626504EDC9FB252328D1A240E4E948BEF8D0C08DFF45927F From a5363bd5b4f56c32d09d18381765e7c2bf15432d Mon Sep 17 00:00:00 2001 From: Fiiranek Date: Fri, 5 Dec 2025 12:29:59 +0100 Subject: [PATCH 04/17] Use blake in `account_with_validate_deploy_class_hash` --- starknet_py/tests/e2e/fixtures/contracts_v1.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/starknet_py/tests/e2e/fixtures/contracts_v1.py b/starknet_py/tests/e2e/fixtures/contracts_v1.py index 39abf02d5..88b214f38 100644 --- a/starknet_py/tests/e2e/fixtures/contracts_v1.py +++ b/starknet_py/tests/e2e/fixtures/contracts_v1.py @@ -8,7 +8,6 @@ from starknet_py.common import create_casm_class, create_sierra_compiled_contract from starknet_py.contract import Contract from starknet_py.hash.casm_class_hash import compute_casm_class_hash -from starknet_py.hash.hash_method import HashMethod from starknet_py.net.account.base_account import BaseAccount from starknet_py.net.models import DeclareV3 from starknet_py.net.udc_deployer.deployer import Deployer @@ -367,7 +366,7 @@ async def account_with_validate_deploy_class_hash( ) -> int: contract = load_contract("Account") casm_class_hash = compute_casm_class_hash( - create_casm_class(contract["casm"]), HashMethod.POSEIDON + create_casm_class(contract["casm"]) ) return await declare_account( From a81af5c371deb7a73ea6cfff8ff82434283abb3a Mon Sep 17 00:00:00 2001 From: Fiiranek Date: Fri, 5 Dec 2025 12:30:19 +0100 Subject: [PATCH 05/17] Fix formatting --- starknet_py/tests/e2e/fixtures/contracts_v1.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/starknet_py/tests/e2e/fixtures/contracts_v1.py b/starknet_py/tests/e2e/fixtures/contracts_v1.py index 88b214f38..fc7abb0f0 100644 --- a/starknet_py/tests/e2e/fixtures/contracts_v1.py +++ b/starknet_py/tests/e2e/fixtures/contracts_v1.py @@ -365,9 +365,7 @@ 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"]) - ) + 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 From f05c215546206c000a99653b4b8e689a55db1f69 Mon Sep 17 00:00:00 2001 From: Fiiranek Date: Fri, 5 Dec 2025 12:46:26 +0100 Subject: [PATCH 06/17] Remove change --- starknet_py/net/schemas/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/starknet_py/net/schemas/common.py b/starknet_py/net/schemas/common.py index 72a6025f7..7f296a847 100644 --- a/starknet_py/net/schemas/common.py +++ b/starknet_py/net/schemas/common.py @@ -49,7 +49,7 @@ def _serialize(self, value: Any, attr: Optional[str], obj: Any, **kwargs): if self._is_str_and_valid_pattern(value): return value - print("xxx", value) + raise ValidationError( f"Invalid value provided for {self.__class__.__name__}: {value}" ) From 6cafcc152b71400b4f8a08e39bd02fa6e99946f0 Mon Sep 17 00:00:00 2001 From: Fiiranek Date: Fri, 5 Dec 2025 12:51:24 +0100 Subject: [PATCH 07/17] Make `migrated_compiled_classes` optional --- starknet_py/net/client_models.py | 2 +- starknet_py/net/schemas/rpc/block.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/starknet_py/net/client_models.py b/starknet_py/net/client_models.py index bcbb8cbd0..4545bd46d 100644 --- a/starknet_py/net/client_models.py +++ b/starknet_py/net/client_models.py @@ -799,7 +799,7 @@ class StateDiff: storage_diffs: List[StorageDiffItem] deprecated_declared_classes: List[int] declared_classes: List[DeclaredContractHash] - migrated_compiled_classes: List[MigratedClass] + migrated_compiled_classes: Optional[List[MigratedClass]] deployed_contracts: List[DeployedContract] replaced_classes: List[ReplacedClass] nonces: List[ContractsNonce] diff --git a/starknet_py/net/schemas/rpc/block.py b/starknet_py/net/schemas/rpc/block.py index bb3375a53..0cf29e23b 100644 --- a/starknet_py/net/schemas/rpc/block.py +++ b/starknet_py/net/schemas/rpc/block.py @@ -183,7 +183,7 @@ class StateDiffSchema(Schema): migrated_compiled_classes = fields.List( fields.Nested(MigratedClassSchema()), data_key="migrated_compiled_classes", - required=True, + required=False, ) deployed_contracts = fields.List( fields.Nested(DeployedContractSchema()), From 68797130680a0fe92793e49b72057a45b38fc1f6 Mon Sep 17 00:00:00 2001 From: Fiiranek Date: Fri, 5 Dec 2025 12:55:08 +0100 Subject: [PATCH 08/17] Fix `StateDiff` model --- starknet_py/net/client_models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/starknet_py/net/client_models.py b/starknet_py/net/client_models.py index 4545bd46d..f15d6413e 100644 --- a/starknet_py/net/client_models.py +++ b/starknet_py/net/client_models.py @@ -799,10 +799,10 @@ class StateDiff: storage_diffs: List[StorageDiffItem] deprecated_declared_classes: List[int] declared_classes: List[DeclaredContractHash] - migrated_compiled_classes: Optional[List[MigratedClass]] deployed_contracts: List[DeployedContract] replaced_classes: List[ReplacedClass] nonces: List[ContractsNonce] + migrated_compiled_classes: Optional[List[MigratedClass]] = None @dataclass From 49fc759e5600e755e3eef347796a6ef1bec1d638 Mon Sep 17 00:00:00 2001 From: Fiiranek Date: Fri, 5 Dec 2025 12:59:24 +0100 Subject: [PATCH 09/17] Fix docs --- docs/migration_guide.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/migration_guide.rst b/docs/migration_guide.rst index f1b6df1ee..b5ed2b2fc 100644 --- a/docs/migration_guide.rst +++ b/docs/migration_guide.rst @@ -9,10 +9,12 @@ Version 0.29.0 of **starknet.py** comes with full support for RPC 0.10.0. 0.29.0 Targeted versions ------------------------ + - Starknet - `0.14.1 `_ - RPC - `0.10.0 `_ .. py:currentmodule:: starknet_py.net.client_models + 1. :class:`BlockHeader`: Added new fields: ``event_commitment``, ``transaction_commitment``, ``receipt_commitment``, ``state_diff_commitment``, ``event_count``, ``transaction_count``, ``state_diff_length``. **************************** From e0dc3711a1a43c07b398af84da65d36d4b56dda7 Mon Sep 17 00:00:00 2001 From: Fiiranek Date: Fri, 5 Dec 2025 13:11:16 +0100 Subject: [PATCH 10/17] Fix test --- starknet_py/tests/e2e/account/account_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/starknet_py/tests/e2e/account/account_test.py b/starknet_py/tests/e2e/account/account_test.py index 60351e571..1e019fc60 100644 --- a/starknet_py/tests/e2e/account/account_test.py +++ b/starknet_py/tests/e2e/account/account_test.py @@ -163,7 +163,7 @@ async def test_sending_multicall(account, map_contract, key, val): async def test_rejection_reason_in_transaction_receipt(map_contract): with pytest.raises( ClientError, - match="The transaction's resources don't cover validation or the minimal transaction fee", + match="Client failed with code -1. Message: Resource bounds were not satisfied", ): resource_bounds = ResourceBoundsMapping( l1_gas=ResourceBounds(max_amount=1, max_price_per_unit=1), From 04b93a1880def4a898a37b50d915f672b0c887fc Mon Sep 17 00:00:00 2001 From: Fiiranek Date: Fri, 5 Dec 2025 15:31:22 +0100 Subject: [PATCH 11/17] Remove unnecessary change --- starknet_py/net/schemas/rpc/executables_api.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/starknet_py/net/schemas/rpc/executables_api.py b/starknet_py/net/schemas/rpc/executables_api.py index fe438d9c4..5ba6ee792 100644 --- a/starknet_py/net/schemas/rpc/executables_api.py +++ b/starknet_py/net/schemas/rpc/executables_api.py @@ -148,10 +148,7 @@ class ImmediateSchema(Schema): @post_load def make_dataclass(self, data, **kwargs) -> Immediate: - # Normalizacja modulo FIELD_PRIME - print("xxx", data) - value = data["immediate"] % FIELD_PRIME - return Immediate(immediate=value) + return Immediate(immediate=data) class BinOpBField(fields.Field): From af4ff582525c4951050e6c50c325d5ccc7278a87 Mon Sep 17 00:00:00 2001 From: Fiiranek Date: Fri, 5 Dec 2025 15:40:33 +0100 Subject: [PATCH 12/17] Fix tests --- .../test_deploy_prefunded_account.py | 7 +++---- starknet_py/tests/e2e/fixtures/accounts.py | 17 ++++------------- .../tests/unit/signer/test_ledger_signer.py | 11 ++++------- 3 files changed, 11 insertions(+), 24 deletions(-) diff --git a/starknet_py/tests/e2e/docs/account_creation/test_deploy_prefunded_account.py b/starknet_py/tests/e2e/docs/account_creation/test_deploy_prefunded_account.py index 6e9324ac5..1949563d6 100644 --- a/starknet_py/tests/e2e/docs/account_creation/test_deploy_prefunded_account.py +++ b/starknet_py/tests/e2e/docs/account_creation/test_deploy_prefunded_account.py @@ -1,8 +1,7 @@ import pytest +from starknet_py.devnet_utils.devnet_client import DevnetClient from starknet_py.net.client import Client -from starknet_py.net.client_models import PriceUnit -from starknet_py.tests.e2e.fixtures.accounts import mint_token_on_devnet from starknet_py.tests.e2e.utils import _get_random_private_key_unsafe @@ -47,8 +46,8 @@ async def test_deploy_prefunded_account( # docs: end client = full_node_client_fixture - client_url = client.url.replace("/rpc", "") - await mint_token_on_devnet(client_url, address, int(1e24), PriceUnit.FRI.value) + devnet_client = DevnetClient(client.url) + await devnet_client.mint(address, int(1e24)) # docs: start diff --git a/starknet_py/tests/e2e/fixtures/accounts.py b/starknet_py/tests/e2e/fixtures/accounts.py index 6a258420a..225adf40a 100644 --- a/starknet_py/tests/e2e/fixtures/accounts.py +++ b/starknet_py/tests/e2e/fixtures/accounts.py @@ -7,12 +7,12 @@ from starknet_py.constants import ARGENT_V040_CLASS_HASH from starknet_py.contract import Contract +from starknet_py.devnet_utils.devnet_client import DevnetClient from starknet_py.hash.address import compute_address from starknet_py.net.account.account import Account from starknet_py.net.account.base_account import BaseAccount from starknet_py.net.client_models import PriceUnit from starknet_py.net.full_node_client import FullNodeClient -from starknet_py.net.http_client import HttpMethod, RpcHttpClient from starknet_py.net.models import AddressRepresentation, StarknetChainId from starknet_py.net.signer.eth_signer import EthSigner from starknet_py.net.signer.key_pair import KeyPair @@ -42,7 +42,6 @@ class AccountPrerequisites: async def devnet_account_details( client: FullNodeClient, class_hash: int, - devnet, ) -> Tuple[str, str]: """ Deploys an Account and adds fee tokens to its balance (only on devnet). @@ -59,8 +58,9 @@ async def devnet_account_details( deployer_address=0, ) - await mint_token_on_devnet(devnet, address, int(1e30), PriceUnit.WEI.value) - await mint_token_on_devnet(devnet, address, int(1e30), PriceUnit.FRI.value) + devnet_client = DevnetClient(client.url) + await devnet_client.mint(address, int(1e30), PriceUnit.WEI) + await devnet_client.mint(address, int(1e30), PriceUnit.FRI) deploy_account_tx = await get_deploy_account_transaction( address=address, @@ -82,15 +82,6 @@ async def devnet_account_details( return hex(address), hex(key_pair.private_key) -async def mint_token_on_devnet(url: str, address: int, amount: int, unit: str): - http_client = RpcHttpClient(url) - await http_client.request( - http_method=HttpMethod.POST, - address=f"{url}/mint", - payload={"address": hex(address), "amount": amount, "unit": unit}, - ) - - @pytest.fixture(name="account", scope="package") def full_node_account(client: FullNodeClient) -> BaseAccount: """ diff --git a/starknet_py/tests/unit/signer/test_ledger_signer.py b/starknet_py/tests/unit/signer/test_ledger_signer.py index c7d15a6e7..ceb9e9554 100644 --- a/starknet_py/tests/unit/signer/test_ledger_signer.py +++ b/starknet_py/tests/unit/signer/test_ledger_signer.py @@ -4,12 +4,12 @@ import pytest from starknet_py.constants import STRK_FEE_CONTRACT_ADDRESS +from starknet_py.devnet_utils.devnet_client import DevnetClient from starknet_py.hash.selector import get_selector_from_name from starknet_py.net.client_models import Call from starknet_py.net.full_node_client import FullNodeClient from starknet_py.net.models import DeclareV3, DeployAccountV3, InvokeV3, StarknetChainId from starknet_py.net.signer.ledger_signer import BlindSigningModeWarning -from starknet_py.tests.e2e.fixtures.accounts import mint_token_on_devnet from starknet_py.tests.e2e.fixtures.constants import MAX_RESOURCE_BOUNDS_SEPOLIA LEDGER_ACCOUNT_ADDRESS_SEPOLIA = ( @@ -232,12 +232,9 @@ async def test_deploy_account_and_transfer(client): # Remember to prefund the account # docs-deploy-account-and-transfer: end # Here we prefund the devnet account for test purposes - await mint_token_on_devnet( - url=rpc_client.url.replace("/rpc", ""), - address=address, - amount=5000000000000000000000, - unit="FRI", - ) + # await mint_token_on_devnet( + devnet_client = DevnetClient(rpc_client.url) + await devnet_client.mint(address, int(1e24)) # docs-deploy-account-and-transfer: start signed_tx = await account.sign_deploy_account_v3( class_hash=class_hash, From c443796ac980090e606a33a1fb1a4d843549faa2 Mon Sep 17 00:00:00 2001 From: Fiiranek Date: Fri, 5 Dec 2025 15:42:07 +0100 Subject: [PATCH 13/17] Fix `test_warning_on_incompatible_node_spec_version` --- starknet_py/tests/e2e/tests_on_networks/client_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/starknet_py/tests/e2e/tests_on_networks/client_test.py b/starknet_py/tests/e2e/tests_on_networks/client_test.py index 5f6e3dba8..8a2928a6a 100644 --- a/starknet_py/tests/e2e/tests_on_networks/client_test.py +++ b/starknet_py/tests/e2e/tests_on_networks/client_test.py @@ -595,7 +595,7 @@ async def test_get_compiled_casm(client_sepolia_testnet): @pytest.mark.asyncio async def test_warning_on_incompatible_node_spec_version(client_sepolia_testnet): - old_rpc_url = client_sepolia_testnet.url.replace("v0_9", "v0_8") + old_rpc_url = client_sepolia_testnet.url.replace("v0_10", "v0_8") node = FullNodeClient(old_rpc_url) pattern = ( From 227bc05efbd30c5d616cb650dc85bcef857bc23f Mon Sep 17 00:00:00 2001 From: Fiiranek Date: Fri, 5 Dec 2025 15:52:28 +0100 Subject: [PATCH 14/17] Fix `Immediate` cration --- starknet_py/net/schemas/rpc/executables_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/starknet_py/net/schemas/rpc/executables_api.py b/starknet_py/net/schemas/rpc/executables_api.py index 5ba6ee792..3086a1040 100644 --- a/starknet_py/net/schemas/rpc/executables_api.py +++ b/starknet_py/net/schemas/rpc/executables_api.py @@ -148,7 +148,7 @@ class ImmediateSchema(Schema): @post_load def make_dataclass(self, data, **kwargs) -> Immediate: - return Immediate(immediate=data) + return Immediate(**data) class BinOpBField(fields.Field): From 6d08ebd6b8cc708169a8278009aa09a5950a3259 Mon Sep 17 00:00:00 2001 From: Fiiranek Date: Fri, 5 Dec 2025 16:08:53 +0100 Subject: [PATCH 15/17] Fix tests --- starknet_py/tests/e2e/client/full_node_test.py | 13 ++++++------- .../test_deploy_prefunded_account.py | 2 +- .../e2e/docs/code_examples/test_websocket_client.py | 2 +- starknet_py/tests/e2e/fixtures/accounts.py | 2 +- starknet_py/tests/e2e/utils.py | 9 --------- starknet_py/tests/unit/signer/test_ledger_signer.py | 6 ++---- 6 files changed, 11 insertions(+), 23 deletions(-) diff --git a/starknet_py/tests/e2e/client/full_node_test.py b/starknet_py/tests/e2e/client/full_node_test.py index 071024a45..d1631590f 100644 --- a/starknet_py/tests/e2e/client/full_node_test.py +++ b/starknet_py/tests/e2e/client/full_node_test.py @@ -28,7 +28,6 @@ from starknet_py.net.models import StarknetChainId from starknet_py.tests.e2e.fixtures.constants import MAX_RESOURCE_BOUNDS from starknet_py.tests.e2e.fixtures.misc import ContractVersion, load_contract -from starknet_py.tests.e2e.utils import create_empty_block def _parse_event_name(event: str) -> str: @@ -355,30 +354,30 @@ async def test_get_events_nonexistent_starting_block( @pytest.mark.asyncio -async def test_get_block_number(client): +async def test_get_block_number(client, devnet_client): # pylint: disable=protected-access - await create_empty_block(client._client) + await devnet_client.create_block() block_number = await client.get_block_number() # pylint: disable=protected-access - await create_empty_block(client._client) + await devnet_client.create_block() new_block_number = await client.get_block_number() assert new_block_number == block_number + 1 @pytest.mark.asyncio -async def test_get_block_hash_and_number(client): +async def test_get_block_hash_and_number(client, devnet_client): # pylint: disable=protected-access - await create_empty_block(client._client) + await devnet_client.create_block() block_hash_and_number = await client.get_block_hash_and_number() assert isinstance(block_hash_and_number, BlockHashAndNumber) # pylint: disable=protected-access - await create_empty_block(client._client) + await devnet_client.create_block() new_block_hash_and_number = await client.get_block_hash_and_number() diff --git a/starknet_py/tests/e2e/docs/account_creation/test_deploy_prefunded_account.py b/starknet_py/tests/e2e/docs/account_creation/test_deploy_prefunded_account.py index 1949563d6..2260f5f40 100644 --- a/starknet_py/tests/e2e/docs/account_creation/test_deploy_prefunded_account.py +++ b/starknet_py/tests/e2e/docs/account_creation/test_deploy_prefunded_account.py @@ -9,6 +9,7 @@ async def test_deploy_prefunded_account( account_with_validate_deploy_class_hash: int, client: Client, + devnet_client: DevnetClient, ): # pylint: disable=import-outside-toplevel, too-many-locals, unused-variable full_node_client_fixture = client @@ -46,7 +47,6 @@ async def test_deploy_prefunded_account( # docs: end client = full_node_client_fixture - devnet_client = DevnetClient(client.url) await devnet_client.mint(address, int(1e24)) # docs: start diff --git a/starknet_py/tests/e2e/docs/code_examples/test_websocket_client.py b/starknet_py/tests/e2e/docs/code_examples/test_websocket_client.py index fc9c26a8d..b524cbb90 100644 --- a/starknet_py/tests/e2e/docs/code_examples/test_websocket_client.py +++ b/starknet_py/tests/e2e/docs/code_examples/test_websocket_client.py @@ -74,7 +74,7 @@ def handler(new_heads_notification: NewHeadsNotification): # ... # docs-end: subscribe_new_heads new_block_hash = await devnet_client.create_block() - + await asyncio.sleep(5) assert received_block is not None assert int(new_block_hash, 16) == received_block.block_hash # docs-start: subscribe_new_heads diff --git a/starknet_py/tests/e2e/fixtures/accounts.py b/starknet_py/tests/e2e/fixtures/accounts.py index 225adf40a..03d1bca36 100644 --- a/starknet_py/tests/e2e/fixtures/accounts.py +++ b/starknet_py/tests/e2e/fixtures/accounts.py @@ -42,6 +42,7 @@ class AccountPrerequisites: async def devnet_account_details( client: FullNodeClient, class_hash: int, + devnet_client: DevnetClient, ) -> Tuple[str, str]: """ Deploys an Account and adds fee tokens to its balance (only on devnet). @@ -58,7 +59,6 @@ async def devnet_account_details( deployer_address=0, ) - devnet_client = DevnetClient(client.url) await devnet_client.mint(address, int(1e30), PriceUnit.WEI) await devnet_client.mint(address, int(1e30), PriceUnit.FRI) diff --git a/starknet_py/tests/e2e/utils.py b/starknet_py/tests/e2e/utils.py index c0a86433e..c6ea220e5 100644 --- a/starknet_py/tests/e2e/utils.py +++ b/starknet_py/tests/e2e/utils.py @@ -6,7 +6,6 @@ from starknet_py.hash.address import compute_address from starknet_py.net.account.account import Account from starknet_py.net.client import Client -from starknet_py.net.http_client import HttpClient, HttpMethod from starknet_py.net.models import DeployAccountV3, StarknetChainId from starknet_py.net.signer.key_pair import KeyPair from starknet_py.net.udc_deployer.deployer import _get_random_salt @@ -82,11 +81,3 @@ def _get_random_private_key_unsafe() -> int: This is not a safe way of generating private keys and should be used only in tests. """ return random.randint(1, EC_ORDER - 1) - - -async def create_empty_block(http_client: HttpClient) -> None: - url = http_client.url[:-4] if http_client.url.endswith("/rpc") else http_client.url - await http_client.request( - address=f"{url}/create_block", - http_method=HttpMethod.POST, - ) diff --git a/starknet_py/tests/unit/signer/test_ledger_signer.py b/starknet_py/tests/unit/signer/test_ledger_signer.py index ceb9e9554..1b295d289 100644 --- a/starknet_py/tests/unit/signer/test_ledger_signer.py +++ b/starknet_py/tests/unit/signer/test_ledger_signer.py @@ -4,7 +4,6 @@ import pytest from starknet_py.constants import STRK_FEE_CONTRACT_ADDRESS -from starknet_py.devnet_utils.devnet_client import DevnetClient from starknet_py.hash.selector import get_selector_from_name from starknet_py.net.client_models import Call from starknet_py.net.full_node_client import FullNodeClient @@ -197,7 +196,7 @@ async def _get_account_balance_strk(client: FullNodeClient, address: int): platform == "win32", reason="Testing Ledger is skipped on Windows due to different Speculos setup.", ) -async def test_deploy_account_and_transfer(client): +async def test_deploy_account_and_transfer(client, devnet_client): # pylint: disable=import-outside-toplevel, reimported, redefined-outer-name, too-many-locals # docs-deploy-account-and-transfer: start from starknet_py.contract import Contract @@ -232,8 +231,7 @@ async def test_deploy_account_and_transfer(client): # Remember to prefund the account # docs-deploy-account-and-transfer: end # Here we prefund the devnet account for test purposes - # await mint_token_on_devnet( - devnet_client = DevnetClient(rpc_client.url) + await devnet_client.mint(address, int(1e24)) # docs-deploy-account-and-transfer: start signed_tx = await account.sign_deploy_account_v3( From 788cb8fa3747ddbc88c09453ce47f30567f00386 Mon Sep 17 00:00:00 2001 From: Fiiranek Date: Fri, 5 Dec 2025 16:22:06 +0100 Subject: [PATCH 16/17] Add sleep in `test_subscribe_new_heads_with_block_hash` --- starknet_py/tests/e2e/client/websocket_client_test.py | 1 + 1 file changed, 1 insertion(+) diff --git a/starknet_py/tests/e2e/client/websocket_client_test.py b/starknet_py/tests/e2e/client/websocket_client_test.py index 232d4fe8c..d58ce0dc3 100644 --- a/starknet_py/tests/e2e/client/websocket_client_test.py +++ b/starknet_py/tests/e2e/client/websocket_client_test.py @@ -52,6 +52,7 @@ def handler(new_heads_notification: NewHeadsNotification): ) new_block_hash = await devnet_client.create_block() + await asyncio.sleep(5) assert received_block is not None assert int(new_block_hash, 16) == received_block.block_hash From 5f0bcd666f2be6152c1905683bfd8d736e820881 Mon Sep 17 00:00:00 2001 From: Fiiranek Date: Fri, 5 Dec 2025 16:53:37 +0100 Subject: [PATCH 17/17] Add sleep in `test_subscribe_new_heads_with_block_number` --- starknet_py/tests/e2e/client/websocket_client_test.py | 1 + 1 file changed, 1 insertion(+) diff --git a/starknet_py/tests/e2e/client/websocket_client_test.py b/starknet_py/tests/e2e/client/websocket_client_test.py index d58ce0dc3..a926ccbc2 100644 --- a/starknet_py/tests/e2e/client/websocket_client_test.py +++ b/starknet_py/tests/e2e/client/websocket_client_test.py @@ -81,6 +81,7 @@ def handler(new_heads_notification: NewHeadsNotification): ) new_block_hash = await devnet_client.create_block() + await asyncio.sleep(5) assert received_block is not None assert int(new_block_hash, 16) == received_block.block_hash