Skip to content

Commit 74249a6

Browse files
Support RPC v0.6.0 (#1243)
* Modify transaction models and add hash computation logic * Create broadcasted v3 transactions * Add account sign and execute v3 * Fix models * Prepare devnet for tests with STRK * Run devnet with flag to keep states * Fix helper for deploy account * Add declare and deploy account tests * Add more tests * Fix client models * Update devnet env variables in github workflow * Fix typo in `TransactionV3` class * Add `auto_estimate` parameter to v3 sign methods * Add missing `account_deployment_data` * Rename `fee_contract` to `eth_fee_contract` * Align v3 common fields to match with the snip Co-authored-by: Maksim Zdobnikau <43750648+DelevoXDG@users.noreply.github.com> * Rename `get_common_tx_fields` Co-authored-by: Maksim Zdobnikau <43750648+DelevoXDG@users.noreply.github.com> * Fix lint and failing tests * Add docstrings for compute hash functions * Change `class_hash` and `contract_class` validation in compute_declare_v2_hash * Add `auto_estimate` to `execute_v3` and fix typos * Fix punctuation and typos in `_prepare_invoke_v3` docstring Co-authored-by: Maksim Zdobnikau <43750648+DelevoXDG@users.noreply.github.com> * Fix docs build * Disallow passing currently unused v3 fields to `init` * Add V1 postfix for deprecated transaction types * Add `DeprecatedTransaction` and `DeprecatedTransactionSchema` * Add intermediary `_DeprecatedAccountTransaction` class * Rename sign functions to have transaction version in names * Fix `simulate_transactions` description * Replace `resource_bounds` with `l1_resource_bounds` in sign methods * RPC v0.6.0 documentation (#1250) --------- Co-authored-by: Maksim Zdobnikau <43750648+DelevoXDG@users.noreply.github.com>
1 parent 9fc34be commit 74249a6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1867
-400
lines changed

.github/workflows/checks.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name: Checks
22

33
env:
4-
STARKNET_VERSION: "0.12.3"
5-
RPC_SPEC_VERSION: "0.5.1"
6-
DEVNET_SHA: "78527de"
4+
STARKNET_VERSION: "0.13.0"
5+
RPC_SPEC_VERSION: "0.6.0"
6+
DEVNET_SHA: "1bd447d"
77

88
on:
99
push:

docs/api/models.rst

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,25 @@ Module containing base models and functions to operate on them.
1313
:exclude-members: __init__, __new__
1414
:members:
1515

16-
.. autoclass:: DeployAccount
16+
.. autoclass:: DeployAccountV1
1717
:exclude-members: __init__, __new__
1818

19-
.. autoclass:: Declare
19+
.. autoclass:: DeployAccountV3
20+
:exclude-members: __init__, __new__
21+
22+
.. autoclass:: DeclareV1
2023
:exclude-members: __init__, __new__
2124

2225
.. autoclass:: DeclareV2
2326
:exclude-members: __init__, __new__
2427

25-
.. autoclass:: Invoke
28+
.. autoclass:: DeclareV3
29+
:exclude-members: __init__, __new__
30+
31+
.. autoclass:: InvokeV1
32+
:exclude-members: __init__, __new__
33+
34+
.. autoclass:: InvokeV3
2635
:exclude-members: __init__, __new__
2736

2837
.. autoenum:: StarknetChainId

docs/guide/deploying_contracts.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ Declaring Cairo1 contracts
7777

7878
| Starknet 0.11 introduced the ability to declare contracts written in Cairo1!
7979
80-
To declare a new contract, Declare v2 transaction has to be sent.
81-
You can see the structure of the new Declare transaction `here <https://docs.starknet.io/documentation/architecture_and_concepts/Network_Architecture/transactions/#declare_v2>`_.
80+
To declare a new contract, Declare v2 or Declare v3 transaction has to be sent.
81+
You can see the structure of these transactions `here <https://docs.starknet.io/documentation/architecture_and_concepts/Network_Architecture/transactions/#declare-transaction>`_.
8282

8383
The main differences in the structure of the transaction from its previous version are:
8484
- ``contract_class`` field is a ``SierraContractClass``

docs/migration_guide.rst

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,71 @@ Migration guide
55
0.19.0 Migration guide
66
**********************
77

8+
Version 0.19.0 of **starknet.py** comes with support for RPC 0.6.0!
9+
10+
.. currentmodule:: starknet_py.net.client_models
11+
12+
New classes added to mirror the recent changes in the RPC v0.6.0 specification include:
13+
:class:`ResourceBoundsMapping`, :class:`ResourceBounds`, :class:`PriceUnit`, :class:`FeePayment`, :class:`DAMode`.
14+
15+
Changes in the :class:`~starknet_py.net.account.account.Account`:
16+
17+
.. currentmodule:: starknet_py.net.account.account
18+
19+
- :meth:`~Account.execute_v3` has been added.
20+
- :meth:`~Account.sign_declare_v3_transaction`, :meth:`~Account.sign_deploy_account_v3_transaction` and :meth:`~Account.sign_invoke_v3_transaction` have been added.
21+
- :meth:`~Account.sign_declare_transaction`, :meth:`~Account.sign_deploy_account_transaction` and :meth:`~Account.sign_invoke_transaction` have been renamed to :meth:`~Account.sign_declare_v1_transaction`, :meth:`~Account.sign_deploy_account_v1_transaction` and :meth:`~Account.sign_invoke_v1_transaction` respectively.
22+
23+
All new functions with ``v3`` in their name operate similarly to their ``v1`` and ``v2`` counterparts.
24+
Unlike their ``v1`` counterparts, ``v3`` transaction fees are paid in Fri (10^-18 STRK). Therefore, ``max_fee`` parameter, which is typically set in Wei, is not applicable for ``v3`` functions. Instead, ``l1_resource_bounds`` parameter is utilized to limit the Fri amount used.
25+
26+
Changes in the :class:`~starknet_py.net.full_node_client.FullNodeClient`:
27+
28+
.. currentmodule:: starknet_py.net.full_node_client
29+
30+
- :meth:`~FullNodeClient.estimate_fee` has a new parameter ``skip_validate``.
31+
- :meth:`~FullNodeClient.declare` accepts ``transaction`` argument of the type :class:`~starknet_py.net.models.transaction.DeclareV3`
32+
- :meth:`~FullNodeClient.send_transaction` accepts ``transaction`` argument of the type :class:`~starknet_py.net.models.transaction.InvokeV3`
33+
- :meth:`~FullNodeClient.deploy_account` accepts ``transaction`` argument of the type :class:`~starknet_py.net.models.transaction.DeployAccountV3`
34+
35+
.. warning::
36+
:class:`~starknet_py.contract.Contract` class does not support V3 transactions in the pre-release.
37+
38+
39+
0.19.0 Targeted versions
40+
------------------------
41+
42+
- Starknet - `0.13.0 <https://docs.starknet.io/documentation/starknet_versions/version_notes/#version0.13.0>`_
43+
- RPC - `0.6.0 <https://github.com/starkware-libs/starknet-specs/releases/tag/v0.6.0>`_
44+
845
0.19.0 Breaking changes
946
-----------------------
1047

1148
.. currentmodule:: starknet_py.net.client_models
1249

1350
1. :class:`GatewayClient` all related classes and fields have been removed.
1451
2. Client ``net`` property has been removed.
15-
3. :class:`TransactionReceipt` field ``execution_resources`` has been changed from ``dict`` to :class:`ExecutionResources`.
16-
4. :class:`TransactionReceipt` fields ``status`` and ``rejection_reason`` have been removed.
17-
5. :class:`TransactionStatus`, :class:`TransactionExecutionStatus` and :class:`TransactionFinalityStatus` have been changed to have the same structure as in RPC specification.
52+
3. :class:`Declare`, :class:`DeployAccount` and :class:`Invoke` have been renamed to :class:`~starknet_py.net.models.transaction.DeclareV1`, :class:`~starknet_py.net.models.transaction.DeployAccountV1` and :class:`~starknet_py.net.models.transaction.InvokeV1` respectively.
53+
4. :class:`TransactionReceipt` field ``execution_resources`` has been changed from ``dict`` to :class:`ExecutionResources`.
54+
5. :class:`TransactionReceipt` fields ``status`` and ``rejection_reason`` have been removed.
55+
6. :class:`TransactionStatus`, :class:`TransactionExecutionStatus` and :class:`TransactionFinalityStatus` have been changed to have the same structure as in RPC specification.
56+
7. :class:`EstimatedFee` has a new required field ``unit``.
57+
8. :class:`EstimatedFee` field ``gas_usage`` has been renamed to ``gas_consumed``.
58+
9. :class:`FunctionInvocation` has a new required field ``execution_resources``.
59+
10. :class:`ResourcePrice` field ``price_in_strk`` has been renamed to ``price_in_fri`` and has now become required.
60+
11. :class:`ResourceLimits` class has been renamed to :class:`ResourceBounds`.
1861

1962
0.19.0 Minor changes
2063
--------------------
2164

2265
1. :class:`L1HandlerTransaction` field ``nonce`` is now required.
23-
2. :class:`TransactionReceipt` fields ``finality_status``, ``execution_status`` and ``execution_resources`` are now required.
66+
2. :class:`TransactionReceipt` fields ``actual_fee``, ``finality_status``, ``execution_status``, ``execution_resources`` and ``type`` are now required.
67+
68+
0.19.0 Development-related changes
69+
----------------------------------
70+
71+
Test execution has been transitioned to the new `starknet-devnet-rs <https://github.com/0xSpaceShard/starknet-devnet-rs>`_.
72+
To adapt to this change, it should be installed locally and added to the ``PATH``. Further information regarding this change can be found in the `Development <https://starknetpy.readthedocs.io/en/latest/development.html>`_ section.
2473

2574
**********************
2675
0.18.3 Migration guide

starknet_py/contract.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
from starknet_py.net.account.base_account import BaseAccount
3535
from starknet_py.net.client import Client
3636
from starknet_py.net.client_models import Call, EstimatedFee, Hash, Tag
37-
from starknet_py.net.models import AddressRepresentation, Invoke, parse_address
37+
from starknet_py.net.models import AddressRepresentation, InvokeV1, parse_address
3838
from starknet_py.net.udc_deployer.deployer import Deployer
3939
from starknet_py.proxy.contract_abi_resolver import (
4040
ContractAbiResolver,
@@ -153,7 +153,7 @@ class InvokeResult(SentTransaction):
153153
contract: ContractData = None # pyright: ignore
154154
"""Additional information about the Contract that made the transaction."""
155155

156-
invoke_transaction: Invoke = None # pyright: ignore
156+
invoke_transaction: InvokeV1 = None # pyright: ignore
157157
"""A InvokeTransaction instance used."""
158158

159159
def __post_init__(self):
@@ -357,7 +357,7 @@ async def invoke(
357357
if max_fee is not None:
358358
self.max_fee = max_fee
359359

360-
transaction = await self._account.sign_invoke_transaction(
360+
transaction = await self._account.sign_invoke_v1_transaction(
361361
calls=self,
362362
nonce=nonce,
363363
max_fee=self.max_fee,
@@ -391,7 +391,7 @@ async def estimate_fee(
391391
:param nonce: Nonce of the transaction.
392392
:return: Estimated amount of Wei executing specified transaction will cost.
393393
"""
394-
tx = await self._account.sign_invoke_transaction(
394+
tx = await self._account.sign_invoke_v1_transaction(
395395
calls=self, nonce=nonce, max_fee=0
396396
)
397397

@@ -668,7 +668,7 @@ async def declare(
668668
)
669669
else:
670670
cairo_version = 0
671-
declare_tx = await account.sign_declare_transaction(
671+
declare_tx = await account.sign_declare_v1_transaction(
672672
compiled_contract=compiled_contract,
673673
nonce=nonce,
674674
max_fee=max_fee,

0 commit comments

Comments
 (0)