Skip to content

Commit 94321d3

Browse files
authored
Remove cairo_version parameter from BaseAccount (#1221)
* Remove cairo_version parameter from BaseAccount * Fix formatting * Remove some failing tests due to disable of gateway feeder on integration * Add info about the change to migration guide
1 parent 2924e15 commit 94321d3

File tree

5 files changed

+19
-151
lines changed

5 files changed

+19
-151
lines changed

docs/migration_guide.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Version 0.18.3 of **starknet.py** comes with support for RPC 0.5.0!
2828

2929
3. :class:`PendingStarknetBlock` field ``parent_hash`` is now named ``parent_block_hash``.
3030
4. :class:`FunctionInvocation` fields ``events`` and ``messages`` have been changed from ``List[Event]`` and ``List[L2toL1Message]`` to ``List[OrderedEvent]`` and ``List[OrderedMessage]`` respectively.
31-
31+
5. ``cairo_version`` parameter in :meth:`Account.sign_invoke_transaction` and :meth:`Account.execute` has been removed.
3232

3333
0.18.3 Minor changes
3434
--------------------

starknet_py/net/account/account.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -273,17 +273,7 @@ async def sign_invoke_transaction(
273273
nonce: Optional[int] = None,
274274
max_fee: Optional[int] = None,
275275
auto_estimate: bool = False,
276-
# TODO (#1184): remove that
277-
cairo_version: Optional[int] = None,
278276
) -> Invoke:
279-
# TODO (#1184): remove that
280-
if cairo_version is not None:
281-
warnings.warn(
282-
"Parameter 'cairo_version' has been deprecated. It is calculated automatically based on your account's "
283-
"contract class.",
284-
category=DeprecationWarning,
285-
)
286-
287277
execute_tx = await self._prepare_invoke(
288278
calls,
289279
nonce=nonce,
@@ -415,17 +405,7 @@ async def execute(
415405
nonce: Optional[int] = None,
416406
max_fee: Optional[int] = None,
417407
auto_estimate: bool = False,
418-
# TODO (#1184): remove that
419-
cairo_version: Optional[int] = None,
420408
) -> SentTransactionResponse:
421-
# TODO (#1184): remove that
422-
if cairo_version is not None:
423-
warnings.warn(
424-
"Parameter 'cairo_version' has been deprecated. It is calculated automatically based on your account's "
425-
"contract class.",
426-
category=DeprecationWarning,
427-
)
428-
429409
execute_transaction = await self.sign_invoke_transaction(
430410
calls,
431411
nonce=nonce,

starknet_py/net/account/base_account.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ async def sign_invoke_transaction(
109109
nonce: Optional[int] = None,
110110
max_fee: Optional[int] = None,
111111
auto_estimate: bool = False,
112-
# TODO (#1184): remove that and docstring
113-
cairo_version: Optional[int] = None,
114112
) -> Invoke:
115113
"""
116114
Takes calls and creates signed Invoke.
@@ -119,12 +117,6 @@ async def sign_invoke_transaction(
119117
:param nonce: Nonce of the transaction.
120118
:param max_fee: Max amount of Wei to be paid when executing transaction.
121119
:param auto_estimate: Use automatic fee estimation, not recommend as it may lead to high costs.
122-
:param cairo_version:
123-
Cairo version of the account used.
124-
125-
.. deprecated:: 0.18.2
126-
Parameter `cairo_version` has been deprecated - it is calculated automatically based on
127-
your account's contract class.
128120
:return: Invoke created from the calls.
129121
"""
130122

@@ -203,8 +195,6 @@ async def execute(
203195
nonce: Optional[int] = None,
204196
max_fee: Optional[int] = None,
205197
auto_estimate: bool = False,
206-
# TODO (#1184): remove that and docstring
207-
cairo_version: Optional[int] = None,
208198
) -> SentTransactionResponse:
209199
"""
210200
Takes calls and executes transaction.
@@ -213,12 +203,6 @@ async def execute(
213203
:param nonce: Nonce of the transaction.
214204
:param max_fee: Max amount of Wei to be paid when executing transaction.
215205
:param auto_estimate: Use automatic fee estimation, not recommend as it may lead to high costs.
216-
:param cairo_version:
217-
Cairo version of the account used.
218-
219-
.. deprecated:: 0.18.2
220-
Parameter `cairo_version` has been deprecated - it is calculated automatically based on
221-
your account's contract class.
222206
:return: SentTransactionResponse.
223207
"""
224208

starknet_py/tests/e2e/account/account_test.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -666,27 +666,3 @@ async def test_argent_cairo1_account_execute(
666666
)
667667

668668
assert get_balance[0] == value
669-
670-
671-
# TODO (#1184): remove that
672-
@pytest.mark.asyncio
673-
async def test_cairo1_account_deprecations(
674-
deployed_balance_contract,
675-
argent_cairo1_account: BaseAccount,
676-
):
677-
call = Call(
678-
to_addr=deployed_balance_contract.address,
679-
selector=get_selector_from_name("increase_balance"),
680-
calldata=[20],
681-
)
682-
with pytest.warns(
683-
DeprecationWarning,
684-
match="Parameter 'cairo_version' has been deprecated. It is calculated automatically based on your account's "
685-
"contract class.",
686-
):
687-
_ = await argent_cairo1_account.execute(
688-
calls=call, max_fee=int(1e16), cairo_version=1
689-
)
690-
_ = await argent_cairo1_account.sign_invoke_transaction(
691-
calls=call, max_fee=int(1e16), cairo_version=1
692-
)

starknet_py/tests/e2e/tests_on_networks/client_test.py

Lines changed: 18 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,8 @@
1616
TransactionStatus,
1717
)
1818
from starknet_py.net.gateway_client import GatewayClient
19-
from starknet_py.tests.e2e.fixtures.constants import (
20-
PREDEPLOYED_EMPTY_CONTRACT_ADDRESS,
21-
PREDEPLOYED_MAP_CONTRACT_ADDRESS,
22-
)
23-
from starknet_py.transaction_errors import (
24-
TransactionRejectedError,
25-
TransactionRevertedError,
26-
)
19+
from starknet_py.tests.e2e.fixtures.constants import PREDEPLOYED_EMPTY_CONTRACT_ADDRESS
20+
from starknet_py.transaction_errors import TransactionRevertedError
2721

2822

2923
@pytest.mark.parametrize(
@@ -53,7 +47,7 @@ async def test_get_transaction_receipt(client_integration, transaction_hash):
5347
# Same thing could happen when you run tests locally and then push to run them on CI.
5448
@pytest.mark.skipif(
5549
condition="--client=gateway" in sys.argv,
56-
reason="Separate FullNode tests from Gateway ones.",
50+
reason="Gateway client has been disabled on integration network.",
5751
)
5852
@pytest.mark.asyncio
5953
async def test_wait_for_tx_reverted_full_node(full_node_account_integration):
@@ -71,71 +65,10 @@ async def test_wait_for_tx_reverted_full_node(full_node_account_integration):
7165
await account.client.wait_for_tx(tx_hash=invoke.transaction_hash)
7266

7367

74-
@pytest.mark.skipif(
75-
condition="--client=full_node" in sys.argv,
76-
reason="Separate FullNode tests from Gateway ones.",
77-
)
78-
@pytest.mark.asyncio
79-
async def test_wait_for_tx_reverted_gateway(gateway_account_integration):
80-
account = gateway_account_integration
81-
# Calldata too long for the function (it has no parameters) to trigger REVERTED status
82-
call = Call(
83-
to_addr=int(PREDEPLOYED_EMPTY_CONTRACT_ADDRESS, 0),
84-
selector=get_selector_from_name("empty"),
85-
calldata=[0x1, 0x2, 0x3, 0x4, 0x5],
86-
)
87-
sign_invoke = await account.sign_invoke_transaction(calls=call, max_fee=int(1e16))
88-
invoke = await account.client.send_transaction(sign_invoke)
89-
90-
with pytest.raises(TransactionRevertedError, match="Input too long for arguments"):
91-
await account.client.wait_for_tx(tx_hash=invoke.transaction_hash)
92-
93-
94-
# No same test for full_node, because nodes don't know about rejected transactions
95-
# https://community.starknet.io/t/efficient-utilization-of-sequencer-capacity-in-starknet-v0-12-1/95607#api-changes-3
96-
@pytest.mark.skipif(
97-
condition="--client=full_node" in sys.argv,
98-
reason="Separate FullNode tests from Gateway ones.",
99-
)
100-
@pytest.mark.asyncio
101-
async def test_wait_for_tx_rejected_gateway(gateway_account_integration):
102-
account = gateway_account_integration
103-
call = Call(
104-
to_addr=int(PREDEPLOYED_MAP_CONTRACT_ADDRESS, 0),
105-
selector=get_selector_from_name("put"),
106-
calldata=[0x102, 0x125],
107-
)
108-
call2 = Call(
109-
to_addr=int(
110-
"0x05cd21d6b3952a869fda11fa9a5bd2657bd68080d3da255655ded47a81c8bd53", 0
111-
),
112-
selector=get_selector_from_name("put"),
113-
calldata=[0x103, 0x126],
114-
)
115-
sign_invoke = await account.sign_invoke_transaction(calls=call, max_fee=int(1e16))
116-
sign_invoke2 = await account.sign_invoke_transaction(calls=call2, max_fee=int(1e16))
117-
# same nonces to trigger REJECTED error
118-
assert sign_invoke2.nonce == sign_invoke.nonce
119-
120-
# this one should pass
121-
invoke = await account.client.send_transaction(sign_invoke)
122-
# this should be rejected
123-
invoke2 = await account.client.send_transaction(sign_invoke2)
124-
125-
with pytest.raises(TransactionRejectedError):
126-
_ = await account.client.wait_for_tx(tx_hash=invoke2.transaction_hash)
127-
128-
invoke2_receipt = await account.client.get_transaction_receipt(
129-
tx_hash=invoke2.transaction_hash
130-
)
131-
132-
assert invoke2_receipt.execution_status == TransactionExecutionStatus.REJECTED
133-
134-
13568
# Same here as in comment above 'test_wait_for_tx_reverted_full_node'
13669
@pytest.mark.skipif(
13770
condition="--client=gateway" in sys.argv,
138-
reason="Separate FullNode tests from Gateway ones.",
71+
reason="Gateway client has been disabled on integration network.",
13972
)
14073
@pytest.mark.asyncio
14174
async def test_wait_for_tx_full_node_accepted(full_node_account_integration):
@@ -155,26 +88,9 @@ async def test_wait_for_tx_full_node_accepted(full_node_account_integration):
15588

15689

15790
@pytest.mark.skipif(
158-
condition="--client=full_node" in sys.argv,
159-
reason="Separate FullNode tests from Gateway ones.",
91+
condition="--client=gateway" in sys.argv,
92+
reason="Gateway client has been disabled on integration network.",
16093
)
161-
@pytest.mark.asyncio
162-
async def test_wait_for_tx_gateway_accepted(gateway_account_integration):
163-
account = gateway_account_integration
164-
call = Call(
165-
to_addr=int(PREDEPLOYED_EMPTY_CONTRACT_ADDRESS, 0),
166-
selector=get_selector_from_name("empty"),
167-
calldata=[],
168-
)
169-
sign_invoke = await account.sign_invoke_transaction(calls=call, max_fee=int(1e16))
170-
invoke = await account.client.send_transaction(sign_invoke)
171-
172-
result = await account.client.wait_for_tx(tx_hash=invoke.transaction_hash)
173-
174-
assert result.execution_status == TransactionExecutionStatus.SUCCEEDED
175-
assert result.finality_status == TransactionFinalityStatus.ACCEPTED_ON_L2
176-
177-
17894
@pytest.mark.asyncio
17995
async def test_transaction_not_received_max_fee_too_small(account_integration):
18096
account = account_integration
@@ -192,6 +108,10 @@ async def test_transaction_not_received_max_fee_too_small(account_integration):
192108
_ = await account.client.send_transaction(sign_invoke)
193109

194110

111+
@pytest.mark.skipif(
112+
condition="--client=gateway" in sys.argv,
113+
reason="Gateway client has been disabled on integration network.",
114+
)
195115
@pytest.mark.asyncio
196116
async def test_transaction_not_received_max_fee_too_big(account_integration):
197117
account = account_integration
@@ -209,6 +129,10 @@ async def test_transaction_not_received_max_fee_too_big(account_integration):
209129
_ = await account.client.send_transaction(sign_invoke)
210130

211131

132+
@pytest.mark.skipif(
133+
condition="--client=gateway" in sys.argv,
134+
reason="Gateway client has been disabled on integration network.",
135+
)
212136
@pytest.mark.asyncio
213137
async def test_transaction_not_received_invalid_nonce(account_integration):
214138
account = account_integration
@@ -225,6 +149,10 @@ async def test_transaction_not_received_invalid_nonce(account_integration):
225149
_ = await account.client.send_transaction(sign_invoke)
226150

227151

152+
@pytest.mark.skipif(
153+
condition="--client=gateway" in sys.argv,
154+
reason="Gateway client has been disabled on integration network.",
155+
)
228156
@pytest.mark.asyncio
229157
async def test_transaction_not_received_invalid_signature(account_integration):
230158
account = account_integration

0 commit comments

Comments
 (0)