Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support websockets API #1515

Merged
merged 287 commits into from
Apr 8, 2025
Merged
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
287 commits
Select commit Hold shift + click to select a range
2c9c736
Fix cyclic imports test
franciszekjob Nov 4, 2024
9164275
Add ws-related dataclasses and schemas
franciszekjob Nov 6, 2024
4124537
Add `WSClient` and `RpcWSClient`
franciszekjob Nov 6, 2024
2f1a660
Add `FullNodeWSClient`
franciszekjob Nov 7, 2024
067e583
Cleanup `FullNodeWSClient`
franciszekjob Nov 7, 2024
3648885
Refactor `FullNodeWSClient._handle_received_message()`
franciszekjob Nov 7, 2024
ebaa859
Fix circular imports
franciszekjob Nov 7, 2024
5fdda6e
Merge branch 'franciszekjob/1498-2-get-compiled-casm' of https://gith…
franciszekjob Nov 7, 2024
9ea6c90
Add `ReorgNotificationSchema`
franciszekjob Nov 7, 2024
e845e50
Add `devnet_ws` fixture
franciszekjob Nov 8, 2024
bd9d693
Fix `resource_bounds` params name
franciszekjob Nov 8, 2024
b8748e0
Add default values in `get_storage_proof()`
franciszekjob Nov 8, 2024
03fa3f2
Merge branch 'franciszekjob/1498-rpc-0.8.0' of https://github.com/sof…
franciszekjob Nov 8, 2024
b62540b
Merge branch 'franciszekjob/1498-2-get-compiled-casm' of https://gith…
franciszekjob Nov 8, 2024
71ff6a4
Add `devnet_ws_client` fixture
franciszekjob Nov 8, 2024
faa97ec
Add `ws_client` and `full_node_ws_client` fixtures
franciszekjob Nov 8, 2024
7b4dd76
Move `devnet_ws` to separate file
franciszekjob Nov 8, 2024
9ebc171
Refactor `FullNodeWSClient._handle_received_message()`; Fix typechecks
franciszekjob Nov 8, 2024
ddcfc06
Fix formatting and linting
franciszekjob Nov 8, 2024
a5854da
Resolve conflicts with `development`
franciszekjob Jan 24, 2025
98165e5
Fix linting
franciszekjob Jan 24, 2025
6590944
Update `resource_bounds` params description
franciszekjob Jan 24, 2025
605b2b3
Apply other code review suggestions
franciszekjob Jan 24, 2025
14dcb5b
Fix description in migration guide
franciszekjob Jan 24, 2025
ba403dd
Fix example snippets in readme
franciszekjob Jan 24, 2025
6a3301b
Add mocked values in tests
franciszekjob Jan 24, 2025
34896b3
Add setup devnet workflow
franciszekjob Jan 24, 2025
8050a22
Change `devnet.yml` to be composite action
franciszekjob Jan 24, 2025
d8a901d
Rename `l1_transaction_hash` to `transaction_hash` in `starknet_getMe…
franciszekjob Jan 27, 2025
c12908b
Move `devnet.yml` to `composite-actions` dir
franciszekjob Jan 27, 2025
7233e65
Format
franciszekjob Jan 27, 2025
6945fbc
Rename devnet composite action
franciszekjob Jan 27, 2025
a62ebdc
Update devnet action path
franciszekjob Jan 27, 2025
819321e
Add missing `shell` property
franciszekjob Jan 27, 2025
e4b947c
Refactor devnet installation action; Add temporary workflow which wil…
franciszekjob Jan 27, 2025
667d5b3
Add inputs to steps using devnet action
franciszekjob Jan 27, 2025
dc09de0
Add missing checkout step
franciszekjob Jan 27, 2025
871499b
Add missing `devnet_sha` input to devnet setup workflow
franciszekjob Jan 27, 2025
22192f8
Fix devnet installation action - use `devnet_sha` input
franciszekjob Jan 27, 2025
44fe1ff
Trgigger CI
franciszekjob Jan 27, 2025
d45b63e
Remove `install_devnet.yml` workflow
franciszekjob Jan 27, 2025
480862c
Add todo in `checks.yml`
franciszekjob Jan 27, 2025
1c56dcf
Remove temporary step for showing dirs
franciszekjob Jan 27, 2025
90877d4
Move `parsed_abi_v2` into `test_event_serialization_v2`
franciszekjob Jan 27, 2025
1bffab1
Fix formatting
franciszekjob Jan 27, 2025
54da25a
Add echo for displaying contracts v2 directory contents
franciszekjob Jan 27, 2025
9e8e356
Fix displaying contents of contracts v2 directory
franciszekjob Jan 27, 2025
1431174
Temporary change for displaying directory contents
franciszekjob Jan 27, 2025
4c3bbf0
Temporarily list contract v2 directory
franciszekjob Jan 27, 2025
2ad7fe7
Temporarily display owd
franciszekjob Jan 27, 2025
a71dc33
Revert "Temporarily display owd"
franciszekjob Jan 27, 2025
cd64e4b
Include Python 3.9 in `Setup Tests` job
franciszekjob Jan 27, 2025
a081bd0
Remove CI changes apart from modified devnet installation
franciszekjob Jan 27, 2025
53945e8
Temporarily display directory with compiled contracts
franciszekjob Jan 27, 2025
c9af96a
Fix ls
franciszekjob Jan 27, 2025
25df9be
Fix ls
franciszekjob Jan 27, 2025
34dddd4
Unconditionally compile contracts v1 and v2
franciszekjob Jan 27, 2025
9e353c2
Use asdf action
franciszekjob Jan 27, 2025
09503e1
Implement `test_get_transaction_status_with_failure_reason`; Code cle…
franciszekjob Jan 27, 2025
b72068d
Fix linting; Tests cleanup
franciszekjob Jan 27, 2025
b78fe68
Update regex in `test_rejection_reason_in_transaction_receipt`
franciszekjob Jan 27, 2025
43c303c
Skip `test_compute_deploy_account_v3_transaction_hash`
franciszekjob Jan 27, 2025
97ccdef
Format
franciszekjob Jan 27, 2025
6e2ccc7
Skip `test_block_with_receipts_latest`
franciszekjob Jan 27, 2025
424e122
Fix failing docs tests
franciszekjob Jan 27, 2025
a0f3671
Fix linting
franciszekjob Jan 27, 2025
993508b
Remove contracts conditional compilation on CI
franciszekjob Jan 27, 2025
bd09a44
Add contracts compilation steps in docs tests
franciszekjob Jan 27, 2025
685b466
Skip `test_get_transaction_by_block_id`; Add todo
franciszekjob Jan 27, 2025
acaa392
Skip `test_get_transaction_by_block_id`; Add todo
franciszekjob Jan 27, 2025
9a16fdc
Skip `test_using_full_node_client`; Add todo
franciszekjob Jan 27, 2025
680317a
Skip `test_get_transaction_by_block_id`; Add todo
franciszekjob Jan 27, 2025
4bd520b
Add todos
franciszekjob Jan 28, 2025
8ad1d75
Add todos in workflow
franciszekjob Jan 29, 2025
bf1274b
Update resource bounds params
franciszekjob Jan 29, 2025
68adca7
Minor refactor of resource bounds params usage
franciszekjob Jan 30, 2025
20ad81a
Update resource bounds params
franciszekjob Jan 30, 2025
c7fb9bd
Apply code review suggestion
franciszekjob Jan 30, 2025
24a1357
Add `storage_root` field to `ContractLeafData`
franciszekjob Jan 30, 2025
c1dcbcb
Merge branch 'franciszekjob/1498-2-get-compiled-casm' of https://gith…
franciszekjob Jan 30, 2025
2ebead7
Rename `block` to `block_id` param in ws methods
franciszekjob Jan 30, 2025
372609f
Add `is_reverted` field to `FunctionInvocation`
franciszekjob Jan 30, 2025
706196a
Add todo
franciszekjob Jan 30, 2025
ceb1706
Remove `block_id` param from `starknet_subscribeTransactionStatus` en…
franciszekjob Jan 30, 2025
7819a66
Merge branch 'franciszekjob/1498-rpc-0.8.0' of https://github.com/sof…
franciszekjob Jan 30, 2025
bde997d
Remove `contracts_storage_proof` field from `ContractsProof`
franciszekjob Jan 30, 2025
f868364
Fix `storage_root` data key
franciszekjob Jan 30, 2025
0edf8d1
Implement `test_get_messages_status`
franciszekjob Jan 30, 2025
8b7a4c1
Fix `test_latest_resource_bounds_take_precedence`
franciszekjob Feb 26, 2025
c0da326
Fix `test_deploy_prefunded_account`
franciszekjob Feb 26, 2025
4ea1317
Remove mocks from full node client
franciszekjob Feb 26, 2025
dd195ac
Add `l1_data_gas` to `ExecutionResources`
franciszekjob Feb 26, 2025
9c2b3c2
Update `CommonTransactionV3Fields.compute_resource_bounds_for_fee`
franciszekjob Feb 26, 2025
cae0da3
Add `l1_data_gas` to ExecutionResourcesSchema`
franciszekjob Feb 26, 2025
d7914ea
Fix `FullNodeClient.estimate_fee`
franciszekjob Feb 26, 2025
e7e8b64
Fix contract tests
franciszekjob Feb 26, 2025
4c39b2b
Temporarily skip some tests; Fix other tests
franciszekjob Feb 27, 2025
b4189eb
Update devnet sha
franciszekjob Feb 27, 2025
8ff797a
Remove code, tests and docs for old txs
franciszekjob Feb 27, 2025
1702e0e
Fix lint and typecheck
franciszekjob Feb 27, 2025
4d13bfc
Fix formatting
franciszekjob Feb 27, 2025
f2392e5
Fix lint and typecheck
franciszekjob Feb 27, 2025
ca2acab
Remove old txs usages, adjust tests and docs
franciszekjob Feb 27, 2025
093f956
Fix tests
franciszekjob Feb 27, 2025
7c49192
Remove todos
franciszekjob Feb 27, 2025
0774348
Remove `test_account_get_balance_eth`
franciszekjob Feb 27, 2025
ddafd39
Fix other tests
franciszekjob Feb 27, 2025
fd351ca
Skip test
franciszekjob Feb 28, 2025
73f2692
Adjust devnet
franciszekjob Feb 28, 2025
9475a36
Fix skip mark
franciszekjob Feb 28, 2025
2b2d7a5
Remove skip marks; Fix tests
franciszekjob Feb 28, 2025
e019506
Update ledger app sha
franciszekjob Feb 28, 2025
8152c21
Refactor assertion in test
franciszekjob Feb 28, 2025
1e3643b
Restore original `test_ci_v2`
franciszekjob Feb 28, 2025
d359e9b
Remove `ResourceBounds.init_with_l1_gas_only`
franciszekjob Feb 28, 2025
8c1a4c3
Add todos
franciszekjob Feb 28, 2025
f3a83cb
Formatting
franciszekjob Feb 28, 2025
ad110dc
Merge branch 'franciszekjob/1498-rpc-0.8.0' of https://github.com/sof…
franciszekjob Feb 28, 2025
4da960f
Pull main
franciszekjob Feb 28, 2025
c3b3366
Merge branch 'franciszekjob/1498-rpc-0.8.0' of https://github.com/sof…
franciszekjob Feb 28, 2025
061a17e
Adjust todos and fixmes
franciszekjob Feb 28, 2025
240c8ad
Use `argent_account_class_hash` in `test_deploy_account_and_transfer`
franciszekjob Feb 28, 2025
d4c2eed
Fix `test_deploy_account_and_transfer`
franciszekjob Feb 28, 2025
df36664
Revert "Fix `test_deploy_account_and_transfer`"
franciszekjob Feb 28, 2025
f67ad37
Revert "Use `argent_account_class_hash` in `test_deploy_account_and_t…
franciszekjob Feb 28, 2025
2468055
Skip and add todo for `test_deploy_account_and_transfer`
franciszekjob Feb 28, 2025
db6b342
Update skip message for `test_get_transaction_by_block_id`
franciszekjob Feb 28, 2025
6a943fd
Update todo
franciszekjob Feb 28, 2025
d9a2091
Remove `--initial-balance` flag for devnet start
franciszekjob Feb 28, 2025
dd9a037
Revert "Remove `--initial-balance` flag for devnet start"
franciszekjob Feb 28, 2025
a34ece9
Fix models and schemas for `get_storage_proof`; Add tests
franciszekjob Feb 28, 2025
7eb95b0
Add storage proof response json
franciszekjob Feb 28, 2025
c9027fa
Restore values in storage proof response json
franciszekjob Feb 28, 2025
d7f9afa
Use shorter example response for `get_storage_proof` test
franciszekjob Feb 28, 2025
2293012
Adjust storage proof tests
franciszekjob Feb 28, 2025
d6dd873
Merge branch 'franciszekjob/1498-rpc-0.8.0' of https://github.com/sof…
franciszekjob Feb 28, 2025
2ea844e
Remove helper function
franciszekjob Feb 28, 2025
b61bc4a
Update migration guide
franciszekjob Feb 28, 2025
eadc306
Merge branch 'franciszekjob/1498-rpc-0.8.0' of https://github.com/sof…
franciszekjob Feb 28, 2025
3472c77
Update migration guide
franciszekjob Feb 28, 2025
c3f1280
Fix linting
franciszekjob Feb 28, 2025
825d2b3
Fix formatting
franciszekjob Feb 28, 2025
dfa2565
Pull changes from upstream
franciszekjob Feb 28, 2025
26ae3b2
Remove unused imports
franciszekjob Feb 28, 2025
965ddfb
Add file with `ContractsStorageKeysSchema`
franciszekjob Feb 28, 2025
005df53
Merge branch 'franciszekjob/1498-rpc-0.8.0' of https://github.com/sof…
franciszekjob Feb 28, 2025
b1324fb
Pull changes from upstream
franciszekjob Feb 28, 2025
2c9ace9
Fix `test_get_storage_proof`
franciszekjob Feb 28, 2025
91df2ae
Merge branch 'franciszekjob/1498-rpc-0.8.0' of https://github.com/sof…
franciszekjob Feb 28, 2025
00ae4bc
Merge branch 'franciszekjob/1498-remove-old-txs' of https://github.co…
franciszekjob Feb 28, 2025
b2341f6
Remove multipliers from `EstimatedFee.to_resource_bounds`
franciszekjob Feb 28, 2025
3471fd0
Merge branch 'franciszekjob/1498-rpc-0.8.0' of https://github.com/sof…
franciszekjob Feb 28, 2025
53c6720
Merge branch 'franciszekjob/1498-remove-old-txs' of https://github.co…
franciszekjob Feb 28, 2025
554c506
update todo
franciszekjob Feb 28, 2025
edf6244
Fix and update network tests
franciszekjob Mar 3, 2025
9a24a3a
Fix devnet client tests
franciszekjob Mar 3, 2025
874d549
Fix CI
franciszekjob Mar 3, 2025
88eae81
Use asdf action
franciszekjob Mar 3, 2025
6a08d7a
Restore `Download contracts` step in CI
franciszekjob Mar 3, 2025
d3ee384
Temporarily list contracts dir
franciszekjob Mar 3, 2025
a0da29a
Update listing dirs
franciszekjob Mar 3, 2025
ab7201a
Update listing dirs
franciszekjob Mar 3, 2025
95b6612
Temporary CI change
franciszekjob Mar 3, 2025
ad3092a
Display compiled contracts path
franciszekjob Mar 3, 2025
09582cb
Compile contract before running tests in CI
franciszekjob Mar 3, 2025
afc276d
Merge branch 'franciszekjob/1498-fix-network-tests' of https://github…
franciszekjob Mar 3, 2025
6919c41
Partially implement `test_get_compiled_casm`
franciszekjob Mar 3, 2025
bf40c24
Fix params in `FullNodeClient.get_compiled_casm`
franciszekjob Mar 3, 2025
334ae73
Update dependencies
franciszekjob Mar 3, 2025
98102b2
Restore read api for txs other than v3
franciszekjob Mar 3, 2025
9130912
Merge branch 'franciszekjob/1498-remove-old-txs' of https://github.co…
franciszekjob Mar 3, 2025
403acda
Refactor broadcasted txn schemas
franciszekjob Mar 3, 2025
be1d06c
Add todo as skip reason
franciszekjob Mar 3, 2025
96437db
Add `test_sign_invoke_v3_auto_estimate`
franciszekjob Mar 3, 2025
6e89aeb
Merge branch 'franciszekjob/1498-remove-old-txs' of https://github.co…
franciszekjob Mar 3, 2025
ff9e751
Run `poetry lock`
franciszekjob Mar 3, 2025
504a4bf
Merge branch 'franciszekjob/1498-remove-old-txs' of https://github.co…
franciszekjob Mar 3, 2025
149b3e7
Restore test values in `test_get_transaction_by_block_id_and_index`
franciszekjob Mar 3, 2025
8dff862
Fix docs
franciszekjob Mar 3, 2025
e769188
Merge branch 'franciszekjob/1498-remove-old-txs' of https://github.co…
franciszekjob Mar 3, 2025
4560095
Docstrings formatting
franciszekjob Mar 3, 2025
425a1ab
Merge branch 'franciszekjob/1498-remove-old-txs' of https://github.co…
franciszekjob Mar 3, 2025
4b30550
Merge branch 'franciszekjob/1498-fix-network-tests' of https://github…
franciszekjob Mar 3, 2025
bd795f2
Add todos
franciszekjob Mar 4, 2025
f2c8725
Merge branch 'franciszekjob/1498-remove-old-txs' of https://github.co…
franciszekjob Mar 4, 2025
555c0f2
Merge branch 'franciszekjob/1498-fix-network-tests' of https://github…
franciszekjob Mar 4, 2025
b9c8f54
Remove old transactions (#1557)
franciszekjob Mar 4, 2025
7b6c1cf
Fix `test_transaction_not_received_max_fee_too_big`
franciszekjob Mar 4, 2025
7e2482b
Resolve merge conflicts
franciszekjob Mar 4, 2025
b859d78
Merge branch 'franciszekjob/1498-fix-network-tests' of https://github…
franciszekjob Mar 4, 2025
9d6b269
Fix and update network tests (#1563)
franciszekjob Mar 4, 2025
6839a41
Add rust toolchain installation
franciszekjob Mar 4, 2025
e204733
Merge branch 'franciszekjob/1498-rpc-0.8.0' of https://github.com/sof…
franciszekjob Mar 4, 2025
f02a234
Add `HintSchema`; Rename fields
franciszekjob Mar 4, 2025
8911fca
Update field names in models
franciszekjob Mar 4, 2025
d135bc5
Add tests for `get_compiled_casm`
franciszekjob Mar 4, 2025
86dee4d
Merge branch 'franciszekjob/1498-rpc-0.8.0' of https://github.com/sof…
franciszekjob Mar 4, 2025
7ccbf0e
Move models and schema from executables api to separate files
franciszekjob Mar 4, 2025
b4da6f5
Add docs
franciszekjob Mar 4, 2025
eff757e
Fix migration guide
franciszekjob Mar 4, 2025
5484105
Pull changes from upstream
franciszekjob Mar 4, 2025
d097214
Rename file
franciszekjob Mar 4, 2025
e0ecdf5
Fix `test_get_compiled_casm` for devnet
franciszekjob Mar 4, 2025
90b1060
Remove unused import
franciszekjob Mar 4, 2025
a8ad3c6
Add `STARKNET_PY_MARSHMALLOW_UNKNOWN_EXCLUDE` to CI
franciszekjob Mar 4, 2025
c1d9235
Change `index_delta_minus_1` to `index_delta_minus1`
franciszekjob Mar 4, 2025
01fe3df
Add fixes in executables schemas and models
franciszekjob Mar 5, 2025
3e7578f
Use schema with excluding unknown fields for `CasmClassSchema`
franciszekjob Mar 5, 2025
57a3ec2
Update todos
franciszekjob Mar 5, 2025
d6750e4
Merge branch 'franciszekjob/1498-2-get-compiled-casm' of https://gith…
franciszekjob Mar 5, 2025
1bd395d
Support `starknet_getCompiledCasm` (#1514)
franciszekjob Mar 5, 2025
23381b5
Merge branch 'franciszekjob/1498-rpc-0.8.0' of https://github.com/sof…
franciszekjob Mar 5, 2025
5103bf8
Add todos
franciszekjob Mar 5, 2025
855f30b
Merge branch 'franciszekjob/1498-rpc-0.8.0' of https://github.com/sof…
franciszekjob Mar 5, 2025
a9af3cc
Merge branch 'development' of https://github.com/software-mansion/sta…
franciszekjob Mar 30, 2025
41f3a06
Add missing websocket API methods; Add tests
franciszekjob Apr 1, 2025
ab9fa6a
Fix formatting
franciszekjob Apr 1, 2025
12e242a
Remove composite action
franciszekjob Apr 1, 2025
830f831
Format and lint
franciszekjob Apr 1, 2025
132ae58
Add more tests
franciszekjob Apr 1, 2025
f55c041
Further improvements of websocket client
franciszekjob Apr 1, 2025
8ed4671
Remove api docs (will be added in subsequent PR)
franciszekjob Apr 2, 2025
1236dc7
Run `poetry lock`
franciszekjob Apr 2, 2025
9e7168e
Update docstrings
franciszekjob Apr 2, 2025
d57cc18
Add `WebsocketClientError`
franciszekjob Apr 2, 2025
991eb79
Fix `pytest_plugins`
franciszekjob Apr 2, 2025
a611bec
Remove unused schemas; Refactor passing block number and block hash p…
franciszekjob Apr 2, 2025
70a38ba
Remove unused `WSClient`
franciszekjob Apr 2, 2025
2ea58e8
Add `devnet_ws` fixture
franciszekjob Apr 2, 2025
423d10f
Add `test_new_heads_subscription_block_not_found`
franciszekjob Apr 2, 2025
a165e45
Remove prints
franciszekjob Apr 2, 2025
7eec2fa
Fix passing block id
franciszekjob Apr 2, 2025
74659d1
Update websocket schemas
franciszekjob Apr 2, 2025
315e68e
Add devnet websocket fixture
franciszekjob Apr 2, 2025
d11e2e5
Remove `test_new_heads_subscription_block_not_found`
franciszekjob Apr 2, 2025
cd1bfaf
Restructure files; Add new tests
franciszekjob Apr 2, 2025
9b57962
Remove unused model
franciszekjob Apr 2, 2025
5ddd91a
Add missing docstrings
franciszekjob Apr 2, 2025
96e2106
Update subscription id type to `str` (RPC 0.8.1)
franciszekjob Apr 2, 2025
22bb883
Fix formatting
franciszekjob Apr 2, 2025
591acca
Remove unused schema
franciszekjob Apr 2, 2025
c9a026b
Add `is_connected` property; Add connection test
franciszekjob Apr 2, 2025
652657b
Little comments cleanup
franciszekjob Apr 2, 2025
385495c
Rename `reorg_notification_handler` to `on_chain_reorg`
franciszekjob Apr 2, 2025
0746a0f
Fix formatting
franciszekjob Apr 2, 2025
4648c20
Fix serialize method in `PendingTransactionsNotificationResultField`
franciszekjob Apr 3, 2025
83f84d5
Merge branch 'development' of https://github.com/software-mansion/sta…
franciszekjob Apr 6, 2025
ff17d73
Apply code review suggestions
franciszekjob Apr 7, 2025
382a837
Change subscription id type to int
franciszekjob Apr 8, 2025
ffbde39
Change type of subscription id to str
franciszekjob Apr 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 81 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ dependencies = [
"aiohttp>=3.8.4,<4.0.0",
"pycryptodome>=3.17,<4.0",
"crypto-cpp-py==1.4.5",
"eth-keyfile>=0.8.1,<1.0.0"
"eth-keyfile>=0.8.1,<1.0.0",
"websockets>=15.0.1,<16.0.0",
]

[project.optional-dependencies]
Expand Down
1 change: 1 addition & 0 deletions starknet_py/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"starknet_py.tests.e2e.fixtures.contracts_v1",
"starknet_py.tests.e2e.fixtures.misc",
"starknet_py.tests.e2e.fixtures.devnet",
"starknet_py.tests.e2e.fixtures.devnet_ws",
"starknet_py.tests.e2e.fixtures.constants",
"starknet_py.tests.e2e.client.fixtures.transactions",
"starknet_py.tests.e2e.client.fixtures.prepare_network",
Expand Down
1 change: 1 addition & 0 deletions starknet_py/net/client_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

Hash = Union[int, str]
Tag = Literal["pending", "latest"]
LatestTag = Literal["latest"]


@dataclass
Expand Down
34 changes: 33 additions & 1 deletion starknet_py/net/client_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import re
from typing import Dict, Union, cast
from typing import Dict, Optional, Union, cast

from typing_extensions import get_args

Expand Down Expand Up @@ -86,3 +86,35 @@ def _create_broadcasted_txn(transaction: AccountTransaction) -> dict:
Dict,
BroadcastedTransactionSchema().dump(obj=transaction),
)


def get_block_identifier(
block_hash: Optional[Union[Hash, Tag]] = None,
block_number: Optional[Union[int, Tag]] = None,
default_tag: Optional[Tag] = "pending",
) -> dict:
return {
"block_id": _get_raw_block_identifier(block_hash, block_number, default_tag)
}


def _get_raw_block_identifier(
block_hash: Optional[Union[Hash, Tag]] = None,
block_number: Optional[Union[int, Tag]] = None,
default_tag: Optional[Tag] = "pending",
) -> Union[dict, Hash, Tag, None]:
if block_hash is not None and block_number is not None:
raise ValueError(
"Arguments block_hash and block_number are mutually exclusive."
)

if block_hash in ("latest", "pending") or block_number in ("latest", "pending"):
return block_hash or block_number

if block_hash is not None:
return {"block_hash": _to_rpc_felt(block_hash)}

if block_number is not None:
return {"block_number": block_number}

return default_tag
Comment on lines +91 to +120
Copy link
Collaborator Author

@franciszekjob franciszekjob Apr 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Moved it to it doesn't sit in full node client's file. It could be theoretically placed in a file which is not client specific or we could rename this file to e.g. rpc_utils.py.

30 changes: 2 additions & 28 deletions starknet_py/net/full_node_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@
)
from starknet_py.net.client_utils import (
_create_broadcasted_txn,
_get_raw_block_identifier,
_is_valid_eth_address,
_to_rpc_felt,
_to_storage_key,
encode_l1_message,
get_block_identifier,
)
from starknet_py.net.executable_models import CasmClass
from starknet_py.net.http_client import RpcHttpClient
Expand Down Expand Up @@ -862,31 +864,3 @@ async def trace_block_transactions(
List[BlockTransactionTrace],
BlockTransactionTraceSchema().load(res, many=True),
)


def get_block_identifier(
block_hash: Optional[Union[Hash, Tag]] = None,
block_number: Optional[Union[int, Tag]] = None,
) -> dict:
return {"block_id": _get_raw_block_identifier(block_hash, block_number)}


def _get_raw_block_identifier(
block_hash: Optional[Union[Hash, Tag]] = None,
block_number: Optional[Union[int, Tag]] = None,
) -> Union[dict, Hash, Tag, None]:
if block_hash is not None and block_number is not None:
raise ValueError(
"Arguments block_hash and block_number are mutually exclusive."
)

if block_hash in ("latest", "pending") or block_number in ("latest", "pending"):
return block_hash or block_number

if block_hash is not None:
return {"block_hash": _to_rpc_felt(block_hash)}

if block_number is not None:
return {"block_number": block_number}

return "pending"
5 changes: 5 additions & 0 deletions starknet_py/net/schemas/rpc/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from starknet_py.net.client_models import (
BlockHashAndNumber,
BlockHeader,
BlockStateUpdate,
ContractsNonce,
DeclaredContractHash,
Expand Down Expand Up @@ -77,6 +78,10 @@ class BlockHeaderSchema(Schema):
l1_da_mode = L1DAModeField(data_key="l1_da_mode", required=True)
starknet_version = fields.String(data_key="starknet_version", required=True)

@post_load
def make_dataclass(self, data, **kwargs) -> BlockHeader:
return BlockHeader(**data)

Comment on lines +81 to +84
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: It was missing.


class BlockHashAndNumberSchema(Schema):
block_hash = Felt(data_key="block_hash", required=True)
Expand Down
Loading