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

Enable deploying contracts without providing abi #1452

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
dd83220
Merge branch 'kkawula/1334-remove-unnecessary-cairo-0-tests'
kkawula Jul 30, 2024
7009e4f
Migrate tests to use cairo 1 ERC20 contract
kkawula Jul 30, 2024
9c1e645
Remove ERC20 contract cairo code and fixtures
kkawula Jul 30, 2024
9a01051
Adapt tests to the cairo 1
kkawula Aug 5, 2024
966f950
Merge 'development'
kkawula Aug 5, 2024
8c4418f
Merge 'development'
kkawula Aug 5, 2024
f43673a
Fix test in Serilization Guide
kkawula Aug 5, 2024
3b1658c
Fix typo in 'test_abi_parsing'
kkawula Aug 5, 2024
2adc084
Fix after merge
kkawula Aug 5, 2024
82e7242
Remove 'constructor_with_arguments.cairo' and 'constructor_without_ar…
kkawula Aug 5, 2024
301a8d4
Add 'constructor_with_arguments.cairo' contract and update test_throw…
kkawula Aug 6, 2024
74e9360
Update 'test_constructor_arguments_contract_deploy'
kkawula Aug 6, 2024
50bad80
Add skiping test while cairo v1 test dir is triggered
kkawula Aug 6, 2024
46f4e6e
Update 'test_create_deployment_call_raw_supports_seed_0' and 'test_cr…
kkawula Aug 6, 2024
ad05ad8
Remove old 'constructor_with_arguments' fixture
kkawula Aug 6, 2024
a0db46f
Update 'test_deploying_with_udc'
kkawula Aug 6, 2024
c735a0d
Update 'constructor_with_arguments_abi' and 'constructor_with_argumen…
kkawula Aug 6, 2024
02c1647
Update docs example
kkawula Aug 6, 2024
c7152f2
Add 'map' contract implementation in cairo 1
kkawula Aug 6, 2024
e1dceb2
Add fixtures for new contract
kkawula Aug 6, 2024
518eafa
Remove 'map_contract_declare_hahs' fixutre
kkawula Aug 6, 2024
a1c69b4
Replace old 'map_contract' fixture
kkawula Aug 6, 2024
e5d6b71
Replace old 'map_class_hash' fixture
kkawula Aug 6, 2024
964a289
Update a few tests
kkawula Aug 6, 2024
a7d664c
Update 'test_deploying_in_multicall'
kkawula Aug 6, 2024
2b8520b
Remove 'Simple declare and deploy' paragraph from docs
kkawula Aug 6, 2024
bf0be0d
Update docs example 'Quickstart - Using Account'
kkawula Aug 6, 2024
dc814a2
Update docs example 'Guide - test_simple_deploy
kkawula Aug 6, 2024
8e9b904
Remove fixtures 'map_source_code' and 'map_compiled_contract'
kkawula Aug 6, 2024
44fb7c2
Fix PriceUnit assertion in 'test_account_estimate_fee_for_declare_tra…
kkawula Aug 6, 2024
a02e663
Add docs test to skip because of redeclaration :(
kkawula Aug 6, 2024
04c5850
Remove map.cairo
kkawula Aug 6, 2024
6f57a8d
Remove 'replace_class.cairo' conatract and fixture
kkawula Aug 6, 2024
7d163b0
Remove unused fixture 'fixture_balance_contract'
kkawula Aug 6, 2024
adfc532
Upadte 'test_estimate_fee_for_multiple_transactions'
kkawula Aug 7, 2024
b01371f
Update 'test_simulate_transactions_declare'
kkawula Aug 7, 2024
7939061
Remove 'test_simulate_transactions_declare'
kkawula Aug 7, 2024
7506f57
Update 'simple_storage_with_event' contract to cairo 1
kkawula Aug 7, 2024
a134d21
Add test to skip reason='Some cairo 1 contracts compiled with v1 comp…
kkawula Aug 7, 2024
c27654a
Merge branch 'development' into kkawula/1334-replace-cairo-0-contracts
kkawula Aug 8, 2024
d4dd60b
Merge 'kkawula/1334-replace-cairo-0-contracts'
kkawula Aug 8, 2024
bc2f6a4
Remove deprecated cairo 0 fixture 'simple_storage_with_event_compiled…
kkawula Aug 8, 2024
823f96c
Remove cairo v1 version of 'simple_storage_with_event.cairo' contract
kkawula Aug 8, 2024
5e0ff7d
Remove cairo v1 contracts that have events
kkawula Aug 8, 2024
f6f15f0
Remove removed contracts from lib.cairo
kkawula Aug 8, 2024
73332dc
Fix 'test_deserialize_abi' v1
kkawula Aug 8, 2024
8995741
Fix 'test_evenet_serialization_v1'
kkawula Aug 8, 2024
1a5db99
Fix 'test_throws_when_cairo1_without_compiled_contract_casm_and_class…
kkawula Aug 8, 2024
dd2785e
Merge branch 'development' into kkawula/1334-replace-cairo-0-contracts
kkawula Aug 8, 2024
3656a44
Merge branch 'kkawula/1334-replace-cairo-0-contracts' into 'kkawula/1…
kkawula Aug 9, 2024
db09b19
Fix 'test_throws_when_cairo1_without_compiled_contract_casm_and_class…
kkawula Aug 9, 2024
a273e9f
Add 'Balance' contract implementation in cairo v1
kkawula Aug 9, 2024
c316414
Update test for new Balance contract
kkawula Aug 9, 2024
b9350b6
Merge branch 'refs/heads/kkawula/replace-cairo-0-contracts-vol2' into…
kkawula Aug 9, 2024
82ac7f6
Fix funny error
kkawula Aug 9, 2024
8cadc5e
Remove cairo 0 'balance' contract
kkawula Aug 9, 2024
ed4a922
Remove cairo 0 'balance_struct_event' contract
kkawula Aug 9, 2024
652e0ec
Add folder with cairo 0 contracs abi; Delete 'balance_struxt_event' a…
kkawula Aug 9, 2024
4a0ea80
Remove unused 'mock_account.cairo' contract
kkawula Aug 19, 2024
e2a5844
Remove unused 'contract.cairo' contract
kkawula Aug 19, 2024
362ac44
Remove unused cairo 0 openzeppelin contracts
kkawula Aug 19, 2024
2fbad1e
Remove unused 'Upgradable.cairo' contract
kkawula Aug 19, 2024
bc9a7f7
Remove usage of cairo 0 account contract; Add cairo 1 account contract
kkawula Aug 19, 2024
4a3c65c
Fix 'test_compute_sierra_class_hash'
kkawula Aug 19, 2024
9c4e3e6
Add 'test_simple_declare_and_deploy' to skip
kkawula Aug 19, 2024
4eb752c
Remove cairo 0 'account_with_validate_deploy' contract
kkawula Aug 19, 2024
67af1cc
Remove cairo 0 contracts compiling script and workflow
kkawula Aug 19, 2024
fd9c3d9
Fix github workflows checks
kkawula Aug 20, 2024
fef6821
Revert "Fix github workflows checks"
kkawula Aug 20, 2024
31e462f
Reapply "Fix github workflows checks"
kkawula Aug 20, 2024
3fd4e7b
Fix github workflows checks
kkawula Aug 20, 2024
fb2dd69
Fix workflows
kkawula Aug 20, 2024
11cf1d7
Revert "Fix github workflows checks"
kkawula Aug 20, 2024
c4dd18b
Add download
kkawula Aug 20, 2024
93554b3
Fix 'test_deploy_account_v1'
kkawula Aug 20, 2024
284e989
Skip 'test_deploy_account_v1' for contract from v1 directory
kkawula Aug 20, 2024
01dff1a
Remove 'test_sign_invoke_v1_for_fee_estimation' (sign_decalre_v1)
kkawula Aug 21, 2024
13699a0
Remove unused fixture 'deployed_balance_contract' (declare_v1)
kkawula Aug 21, 2024
836e6b0
Remove 'declare_v1' method from 'Contract' class
kkawula Aug 21, 2024
68eca27
Remove 'sign_declare_v1' method from 'Account' and 'BaseAccount' class
kkawula Aug 21, 2024
1f1f120
Update docs 'deploying_contracts' (remove declare_v1)
kkawula Aug 21, 2024
eb71ff9
Enable deploying contracts without providing abi
kkawula Aug 22, 2024
0738067
Fix 'test_deploy_contract_v3_without_abi' test
kkawula Aug 22, 2024
4045018
Update vaildating calldata
kkawula Aug 22, 2024
9bfdce4
Remove 'test_throws_when_calldata_provided_without_abi'
kkawula Aug 22, 2024
544d598
Create 'test_constructor_arguments_contract_deploy_without_abi'
kkawula Aug 22, 2024
0071703
Remove 'test_throws_when_calldata_not_provided'
kkawula Aug 23, 2024
d2174a1
Rename 'is_valid_calldata' to '_is_list_of_ints_or_strings'
kkawula Aug 23, 2024
264b447
Add 'test_throws_when_calldata_provided_without_abi'
kkawula Aug 23, 2024
5f953d0
Lint
kkawula Aug 23, 2024
3609c74
Update starknet_py/tests/e2e/docs/code_examples/test_contract.py
kkawula Aug 28, 2024
0a9282f
Update docstring for '_is_list_of_ints_or_strings'
kkawula Aug 28, 2024
c69d4ce
Update starknet_py/tests/e2e/deploy/deployer_test.py
kkawula Aug 28, 2024
168e868
Update starknet_py/net/udc_deployer/deployer.py
kkawula Aug 28, 2024
d054263
Update starknet_py/tests/e2e/deploy/deployer_test.py
kkawula Aug 28, 2024
37d3d43
Fix '_is_list_of_ints_or_strings' docstring
kkawula Aug 28, 2024
b9e790c
Fix abi conditions
kkawula Aug 29, 2024
781ea0b
Merge branch 'development' into kkawula/enable-contract-deploy-withou…
kkawula Aug 29, 2024
54f0f92
Add empty line for readability
kkawula Aug 29, 2024
b315707
Fix after merge
kkawula Aug 29, 2024
553fb8b
Fix 'create_contract_deployment' condition
kkawula Aug 29, 2024
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
Prev Previous commit
Next Next commit
Update 'simple_storage_with_event' contract to cairo 1
  • Loading branch information
kkawula committed Aug 7, 2024
commit 7506f57aabda72bccc44b99f5d1bb618f37994dd
6 changes: 3 additions & 3 deletions starknet_py/tests/e2e/client/full_node_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ def _parse_event_name(event: str) -> str:


FUNCTION_ONE_NAME = "put"
EVENT_ONE_PARSED_NAME = _parse_event_name("put_called")
EVENT_ONE_PARSED_NAME = _parse_event_name("PutCalled")
FUNCTION_TWO_NAME = "another_put"
EVENT_TWO_PARSED_NAME = _parse_event_name("another_put_called")
EVENT_TWO_PARSED_NAME = _parse_event_name("AnotherPutCalled")


@pytest.mark.run_on_devnet
Expand Down Expand Up @@ -147,7 +147,7 @@ async def test_get_events_without_following_continuation_token(
simple_storage_with_event_contract: Contract,
):
for i in range(4):
await simple_storage_with_event_contract.functions[FUNCTION_ONE_NAME].invoke_v1(
await simple_storage_with_event_contract.functions[FUNCTION_ONE_NAME].invoke_v3(
i, i, auto_estimate=True
)

Expand Down
37 changes: 1 addition & 36 deletions starknet_py/tests/e2e/fixtures/contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
import pytest
import pytest_asyncio

from starknet_py.common import (
create_casm_class,
create_compiled_contract,
create_sierra_compiled_contract,
)
from starknet_py.common import create_casm_class, create_sierra_compiled_contract
from starknet_py.constants import FEE_CONTRACT_ADDRESS
from starknet_py.contract import Contract
from starknet_py.hash.casm_class_hash import compute_casm_class_hash
Expand Down Expand Up @@ -127,21 +123,6 @@ async def deployed_balance_contract(
return deploy_result.deployed_contract


@pytest_asyncio.fixture(scope="function")
async def simple_storage_with_event_contract(
account: BaseAccount,
simple_storage_with_event_compiled_contract: str,
simple_storage_with_event_class_hash: int,
) -> Contract:
"""
Deploys storage contract with an events and returns its instance.
"""
abi = create_compiled_contract(
compiled_contract=simple_storage_with_event_compiled_contract
).abi
return await deploy_contract(account, simple_storage_with_event_class_hash, abi)


@pytest.fixture(scope="package")
def eth_fee_contract(account: BaseAccount, fee_contract_abi) -> Contract:
"""
Expand Down Expand Up @@ -260,19 +241,3 @@ async def argent_cairo1_account_class_hash(
compiled_account_contract=compiled_contract,
compiled_account_contract_casm=compiled_contract_casm,
)


@pytest_asyncio.fixture(scope="package")
async def simple_storage_with_event_class_hash(
account: BaseAccount, simple_storage_with_event_compiled_contract: str
):
"""
Returns class_hash of the simple_storage_with_event.cairo
"""
declare = await account.sign_declare_v1(
compiled_contract=simple_storage_with_event_compiled_contract,
max_fee=int(1e16),
)
res = await account.client.declare(declare)
await account.client.wait_for_tx(res.transaction_hash)
return res.class_hash
21 changes: 21 additions & 0 deletions starknet_py/tests/e2e/fixtures/contracts_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,24 @@ def map_compiled_contract_and_class_hash() -> Tuple[str, int]:
contract["sierra"],
compute_casm_class_hash(create_casm_class(contract["casm"])),
)


@pytest_asyncio.fixture(scope="package")
async def simple_storage_with_event_class_hash(account: BaseAccount) -> int:
contract = load_contract("SimpleStorageWithEvent")
class_hash, _ = await declare_cairo1_contract(
account, contract["sierra"], contract["casm"]
)
return class_hash


@pytest_asyncio.fixture(scope="function")
async def simple_storage_with_event_contract(
account: BaseAccount,
simple_storage_with_event_class_hash: int,
) -> Contract:
return await deploy_v1_contract(
account=account,
contract_name="SimpleStorageWithEvent",
class_hash=simple_storage_with_event_class_hash,
)

This file was deleted.

1 change: 1 addition & 0 deletions starknet_py/tests/e2e/mock/contracts_v1/src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ mod test_enum;
mod test_option;
mod token_bridge;
mod map;
mod simple_storage_with_event;
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@


#[contract]
mod SimpleStorageWithEvent {

struct Storage {
map: LegacyMap::<felt252, felt252>,
}

#[event]
fn PutCalled (
key: felt252,
prev_value: felt252,
value: felt252,
){}

#[event]
fn AnotherPutCalled(
key: felt252,
prev_value: felt252,
value: felt252,
additional_value: felt252,
){}

#[external]
fn put(key: felt252, value: felt252) {
let mut prev_value = map::read(key);
map::write(key, value);
PutCalled(key, prev_value, value);
}

#[external]
fn another_put(key: felt252, value: felt252) {
let mut prev_value = map::read(key);
map::write(key, value);
AnotherPutCalled(key, prev_value, value, value);
}

}
1 change: 1 addition & 0 deletions starknet_py/tests/e2e/mock/contracts_v2/src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ mod test_enum;
mod test_option;
mod token_bridge;
mod map;
mod simple_storage_with_event;
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#[starknet::interface]
trait ISimpleStorageWithEvent<TContractState> {
fn put(ref self: TContractState, key: felt252, value: felt252);
fn another_put(ref self: TContractState, key: felt252, value: felt252);
}

#[derive(Drop, Clone, starknet::Event)]
struct PutCalled {
key: felt252,
prev_value: felt252,
value: felt252,
}

#[derive(Drop, Clone, starknet::Event)]
struct AnotherPutCalled {
key: felt252,
prev_value: felt252,
value: felt252,
additional_value: felt252,
}

#[starknet::contract]
pub mod SimpleStorageWithEvent {
use super::{PutCalled, AnotherPutCalled};

#[storage]
struct Storage {
map: LegacyMap::<felt252, felt252>,
}

#[event]
#[derive(Drop, Clone, starknet::Event)]
pub enum Event {
PutCalled: PutCalled,
AnotherPutCalled: AnotherPutCalled,
}

#[abi(embed_v0)]
impl SimpleStorag of super::ISimpleStorageWithEvent<ContractState> {
fn put(ref self: ContractState, key: felt252, value: felt252) {
let mut prev_value = self.map.read(key);
self.map.write(key, value);
self.emit(PutCalled { key: key, prev_value: prev_value, value: value });
}

fn another_put(ref self: ContractState, key: felt252, value: felt252) {
let mut prev_value = self.map.read(key);
self.map.write(key, value);
self.emit(AnotherPutCalled { key: key, prev_value: prev_value, value: value, additional_value: value });
}
}
}
Loading