Skip to content

Commit 5ba387d

Browse files
authored
Update default cairo version (#1352)
1 parent 345b0ba commit 5ba387d

File tree

11 files changed

+33
-16
lines changed

11 files changed

+33
-16
lines changed

starknet_py/contract.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def parsed_abi(self) -> Union[AbiV0, AbiV1, AbiV2]:
8080
return AbiParserV0(self.abi).parse()
8181

8282
@staticmethod
83-
def from_abi(address: int, abi: ABI, cairo_version: int = 0) -> ContractData:
83+
def from_abi(address: int, abi: ABI, cairo_version: int = 1) -> ContractData:
8484
"""
8585
Create ContractData from ABI.
8686
@@ -162,7 +162,7 @@ class DeclareResult(SentTransaction):
162162
"""
163163

164164
_account: BaseAccount = None # pyright: ignore
165-
_cairo_version: int = 0
165+
_cairo_version: int = 1
166166

167167
class_hash: int = None # pyright: ignore
168168
"""Class hash of the declared contract."""
@@ -524,7 +524,7 @@ def __init__(
524524
contract_data: ContractData,
525525
client: Client,
526526
account: Optional[BaseAccount],
527-
cairo_version: int = 0,
527+
cairo_version: int = 1,
528528
*,
529529
interface_name: Optional[str] = None,
530530
):
@@ -729,7 +729,7 @@ def __init__(
729729
abi: list,
730730
provider: Union[BaseAccount, Client],
731731
*,
732-
cairo_version: int = 0,
732+
cairo_version: int = 1,
733733
):
734734
"""
735735
Should be used instead of ``from_address`` when ABI is known statically.
@@ -1067,10 +1067,10 @@ def compute_address(
10671067
deployer_address: int = 0,
10681068
) -> int:
10691069
"""
1070-
Computes address for given contract.
1070+
Computes address for given Cairo 0 contract.
10711071
10721072
:param salt: int
1073-
:param compiled_contract: String containing compiled contract.
1073+
:param compiled_contract: String containing compiled Cairo 0 contract.
10741074
:param constructor_args: A ``list`` or ``dict`` of arguments for the constructor.
10751075
:param deployer_address: Address of the deployer (if not provided default 0 is used).
10761076
@@ -1079,7 +1079,9 @@ def compute_address(
10791079

10801080
compiled = create_compiled_contract(compiled_contract)
10811081
assert compiled.abi is not None
1082-
translated_args = translate_constructor_args(compiled.abi, constructor_args)
1082+
translated_args = translate_constructor_args(
1083+
compiled.abi, constructor_args, cairo_version=0
1084+
)
10831085
return compute_address(
10841086
salt=salt,
10851087
class_hash=compute_class_hash(compiled),
@@ -1105,7 +1107,7 @@ def _make_functions(
11051107
contract_data: ContractData,
11061108
client: Client,
11071109
account: Optional[BaseAccount],
1108-
cairo_version: int = 0,
1110+
cairo_version: int = 1,
11091111
) -> FunctionsRepository:
11101112
repository = {}
11111113
implemented_interfaces = [

starknet_py/net/udc_deployer/deployer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def create_contract_deployment(
6161
*,
6262
salt: Optional[int] = None,
6363
abi: Optional[List] = None,
64-
cairo_version: int = 0,
64+
cairo_version: int = 1,
6565
calldata: Optional[Union[List, dict]] = None,
6666
) -> ContractDeployment:
6767
"""

starknet_py/tests/e2e/account/account_test.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ async def test_balance_when_token_specified(account, erc20_contract):
6767
@pytest.mark.asyncio
6868
async def test_estimated_fee_greater_than_zero(account, erc20_contract):
6969
erc20_contract = Contract(
70-
address=erc20_contract.address, abi=erc20_contract.data.abi, provider=account
70+
address=erc20_contract.address,
71+
abi=erc20_contract.data.abi,
72+
provider=account,
73+
cairo_version=0,
7174
)
7275

7376
estimated_fee = (

starknet_py/tests/e2e/deploy/deployer_test.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ async def test_throws_when_calldata_not_provided(constructor_with_arguments_abi)
4343
match="Provided contract has a constructor and no arguments were provided.",
4444
):
4545
deployer.create_contract_deployment(
46-
class_hash=1234, abi=constructor_with_arguments_abi
46+
class_hash=1234, abi=constructor_with_arguments_abi, cairo_version=0
4747
)
4848

4949

@@ -72,6 +72,7 @@ async def test_constructor_arguments_contract_deploy(
7272
class_hash=constructor_with_arguments_class_hash,
7373
abi=constructor_with_arguments_abi,
7474
calldata=calldata,
75+
cairo_version=0,
7576
)
7677

7778
deploy_invoke_transaction = await account.sign_invoke_v1(
@@ -84,6 +85,7 @@ async def test_constructor_arguments_contract_deploy(
8485
address=contract_address,
8586
abi=constructor_with_arguments_abi,
8687
provider=account,
88+
cairo_version=0,
8789
)
8890

8991
result = await contract.functions["get"].call(block_number="latest")
@@ -145,7 +147,7 @@ async def test_create_deployment_call_raw(
145147
deployer = Deployer(account_address=account.address)
146148

147149
raw_calldata = translate_constructor_args(
148-
abi=constructor_with_arguments_abi, constructor_args=calldata
150+
abi=constructor_with_arguments_abi, constructor_args=calldata, cairo_version=0
149151
)
150152

151153
(
@@ -182,7 +184,9 @@ async def test_create_deployment_call_raw_supports_seed_0(
182184
deployer = Deployer()
183185

184186
raw_calldata = translate_constructor_args(
185-
abi=constructor_with_arguments_abi, constructor_args=sample_calldata
187+
abi=constructor_with_arguments_abi,
188+
constructor_args=sample_calldata,
189+
cairo_version=0,
186190
)
187191

188192
expected_address = compute_address(

starknet_py/tests/e2e/docs/code_examples/test_contract.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def test_init():
2626
key_pair=KeyPair(12, 34),
2727
chain=StarknetChainId.SEPOLIA,
2828
),
29+
cairo_version=0,
2930
)
3031
# docs-end: init
3132

starknet_py/tests/e2e/docs/guide/test_deploying_in_multicall.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ async def test_deploying_in_multicall(account, map_class_hash, map_compiled_cont
2323
# docs: start
2424

2525
# Address of the `map` contract is known here, so we can create its instance!
26-
map_contract = Contract(address=address, abi=map_abi, provider=account)
26+
map_contract = Contract(
27+
address=address, abi=map_abi, provider=account, cairo_version=0
28+
)
2729

2830
# And now we can prepare a call
2931
put_call = map_contract.functions["put"].prepare_invoke_v1(key=10, value=20)

starknet_py/tests/e2e/docs/guide/test_deploying_with_udc.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ async def test_deploying_with_udc(
5656
deploy_call, address = deployer.create_contract_deployment(
5757
class_hash=contract_with_constructor_class_hash,
5858
abi=contract_with_constructor_abi,
59+
cairo_version=0,
5960
calldata={
6061
"single_value": 10,
6162
"tuple": (1, (2, 3)),
@@ -77,6 +78,7 @@ async def test_deploying_with_udc(
7778
"arr": [1],
7879
"dict": {"value": 12, "nested_struct": {"value": 99}},
7980
},
81+
cairo_version=0,
8082
)
8183
# docs: start
8284
# Or signed and send with an account

starknet_py/tests/e2e/docs/guide/test_using_existing_contracts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ async def test_using_existing_contracts(account, erc20_contract):
3232
address = "0x00178130dd6286a9a0e031e4c73b2bd04ffa92804264a25c1c08c1612559f458"
3333

3434
# When ABI is known statically just use the Contract constructor
35-
contract = Contract(address=address, abi=abi, provider=account)
35+
contract = Contract(address=address, abi=abi, provider=account, cairo_version=0)
3636
# or if it is not known
3737
# Contract.from_address makes additional request to fetch the ABI
3838
# docs: end

starknet_py/tests/e2e/docs/quickstart/test_using_contract.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ async def test_using_contract(account, map_contract):
3434
address=contract_address,
3535
abi=abi,
3636
provider=account,
37+
cairo_version=0,
3738
)
3839

3940
# All exposed functions are available at contract.functions.

starknet_py/tests/e2e/fixtures/contracts.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ def eth_fee_contract(account: BaseAccount, fee_contract_abi) -> Contract:
238238
address=FEE_CONTRACT_ADDRESS,
239239
abi=fee_contract_abi,
240240
provider=account,
241+
cairo_version=0,
241242
)
242243

243244

@@ -251,6 +252,7 @@ def strk_fee_contract(account: BaseAccount, fee_contract_abi) -> Contract:
251252
address=STRK_FEE_CONTRACT_ADDRESS,
252253
abi=fee_contract_abi,
253254
provider=account,
255+
cairo_version=0,
254256
)
255257

256258

0 commit comments

Comments
 (0)