diff --git a/Scarb.lock b/Scarb.lock index a54f84e..7be1691 100644 --- a/Scarb.lock +++ b/Scarb.lock @@ -3,12 +3,12 @@ version = 1 [[package]] name = "snforge_std" -version = "0.20.1" -source = "git+https://github.com/foundry-rs/starknet-foundry.git?tag=v0.20.1#fea2db8f2b20148cc15ee34b08de12028eb42942" +version = "0.27.0" +source = "git+https://github.com/foundry-rs/starknet-foundry.git?tag=v0.27.0#2d99b7c00678ef0363881ee0273550c44a9263de" [[package]] name = "token_bound_accounts" -version = "0.2.1" +version = "0.3.0" dependencies = [ "snforge_std", ] diff --git a/src/account/account.cairo b/src/account/account.cairo index 8f117ac..578e36b 100644 --- a/src/account/account.cairo +++ b/src/account/account.cairo @@ -92,9 +92,7 @@ mod AccountComponent { } fn __validate_deploy__( - self: @ComponentState, - class_hash: felt252, - contract_address_salt: felt252, + ref self: ComponentState, token_contract: ContractAddress, token_id: u256 ) -> felt252 { self._validate_transaction() } diff --git a/src/components.cairo b/src/components.cairo new file mode 100644 index 0000000..7d35a1a --- /dev/null +++ b/src/components.cairo @@ -0,0 +1,3 @@ +mod lockable; +mod permissionable; +mod upgradeable; \ No newline at end of file diff --git a/src/components/lockable.cairo b/src/components/lockable.cairo new file mode 100644 index 0000000..d619986 --- /dev/null +++ b/src/components/lockable.cairo @@ -0,0 +1 @@ +mod lockable; \ No newline at end of file diff --git a/src/components/lockable/lockable.cairo b/src/components/lockable/lockable.cairo new file mode 100644 index 0000000..129aa87 --- /dev/null +++ b/src/components/lockable/lockable.cairo @@ -0,0 +1 @@ +// lockable component \ No newline at end of file diff --git a/src/components/permissionable.cairo b/src/components/permissionable.cairo new file mode 100644 index 0000000..938b7f2 --- /dev/null +++ b/src/components/permissionable.cairo @@ -0,0 +1 @@ +mod permissionable; \ No newline at end of file diff --git a/src/components/permissionable/permissionable.cairo b/src/components/permissionable/permissionable.cairo new file mode 100644 index 0000000..333a97c --- /dev/null +++ b/src/components/permissionable/permissionable.cairo @@ -0,0 +1 @@ +// permissionable component \ No newline at end of file diff --git a/src/components/upgradeable.cairo b/src/components/upgradeable.cairo new file mode 100644 index 0000000..892aaa5 --- /dev/null +++ b/src/components/upgradeable.cairo @@ -0,0 +1 @@ +mod upgradeable; diff --git a/src/upgradeable/upgradeable.cairo b/src/components/upgradeable/upgradeable.cairo similarity index 100% rename from src/upgradeable/upgradeable.cairo rename to src/components/upgradeable/upgradeable.cairo diff --git a/src/interfaces/IAccount.cairo b/src/interfaces/IAccount.cairo index efc4335..d810034 100644 --- a/src/interfaces/IAccount.cairo +++ b/src/interfaces/IAccount.cairo @@ -13,9 +13,7 @@ trait IAccount { fn is_valid_signer(self: @TContractState, signer: ContractAddress) -> felt252; fn __validate__(ref self: TContractState, calls: Array) -> felt252; fn __validate_declare__(self: @TContractState, class_hash: felt252) -> felt252; - fn __validate_deploy__( - self: @TContractState, class_hash: felt252, contract_address_salt: felt252 - ) -> felt252; + fn __validate_deploy__(ref self: TContractState, token_contract: ContractAddress, token_id: u256) -> felt252; fn __execute__(ref self: TContractState, calls: Array) -> Array>; fn token(self: @TContractState) -> (ContractAddress, u256); fn owner(self: @TContractState) -> ContractAddress; diff --git a/src/lib.cairo b/src/lib.cairo index e652203..bd38ddc 100644 --- a/src/lib.cairo +++ b/src/lib.cairo @@ -3,4 +3,4 @@ mod account; mod interfaces; mod presets; mod test_helper; -mod upgradeable; +mod components; diff --git a/src/presets/account.cairo b/src/presets/account.cairo index 4f31e41..4598324 100644 --- a/src/presets/account.cairo +++ b/src/presets/account.cairo @@ -6,7 +6,7 @@ mod Account { use starknet::{ContractAddress, get_caller_address}; use starknet::ClassHash; use token_bound_accounts::account::AccountComponent; - use token_bound_accounts::upgradeable::UpgradeableComponent; + use token_bound_accounts::components::upgradeable::upgradeable::UpgradeableComponent; use token_bound_accounts::interfaces::IUpgradeable::IUpgradeable; component!(path: AccountComponent, storage: account, event: AccountEvent); diff --git a/src/registry/registry.cairo b/src/registry/registry.cairo index c579da8..d9b3d51 100644 --- a/src/registry/registry.cairo +++ b/src/registry/registry.cairo @@ -8,14 +8,14 @@ mod Registry { use core::pedersen::PedersenTrait; use starknet::{ ContractAddress, get_caller_address, syscalls::call_contract_syscall, class_hash::ClassHash, - class_hash::Felt252TryIntoClassHash, syscalls::deploy_syscall, SyscallResultTrait + class_hash::Felt252TryIntoClassHash, syscalls::deploy_syscall, SyscallResultTrait, storage::Map }; use token_bound_accounts::interfaces::IERC721::{IERC721DispatcherTrait, IERC721Dispatcher}; use token_bound_accounts::interfaces::IRegistry::IRegistry; #[storage] struct Storage { - registry_deployed_accounts: LegacyMap< + registry_deployed_accounts: Map< (ContractAddress, u256), u8 >, // tracks no. of deployed accounts by registry for an NFT } diff --git a/src/test_helper/account_upgrade.cairo b/src/test_helper/account_upgrade.cairo index 9d90a6a..a58ca37 100644 --- a/src/test_helper/account_upgrade.cairo +++ b/src/test_helper/account_upgrade.cairo @@ -8,10 +8,10 @@ trait IUpgradedAccount { fn __validate__(ref self: TContractState, calls: Array) -> felt252; fn __validate_declare__(self: @TContractState, class_hash: felt252) -> felt252; fn __validate_deploy__( - self: @TContractState, - class_hash: felt252, - contract_address_salt: felt252, - public_key: felt252 + ref self: TContractState, + _public_key: felt252, + token_contract: ContractAddress, + token_id: u256 ) -> felt252; fn __execute__(ref self: TContractState, calls: Array) -> Array>; fn token(self: @TContractState) -> (ContractAddress, u256); @@ -107,10 +107,10 @@ mod UpgradedAccount { } fn __validate_deploy__( - self: @ContractState, - class_hash: felt252, - contract_address_salt: felt252, - public_key: felt252 + ref self: ContractState, + _public_key: felt252, + token_contract: ContractAddress, + token_id: u256 ) -> felt252 { self.validate_transaction() } diff --git a/src/test_helper/erc721_helper.cairo b/src/test_helper/erc721_helper.cairo index cb88290..2c5682e 100644 --- a/src/test_helper/erc721_helper.cairo +++ b/src/test_helper/erc721_helper.cairo @@ -27,17 +27,17 @@ mod ERC721 { use starknet::ContractAddress; use starknet::get_caller_address; use core::zeroable::Zeroable; - use starknet::contract_address_to_felt252; + use starknet::{contract_address_to_felt252, storage::Map}; #[storage] struct Storage { name: felt252, symbol: felt252, - owners: LegacyMap::, - balances: LegacyMap::, - token_approvals: LegacyMap::, - operator_approvals: LegacyMap::<(ContractAddress, ContractAddress), bool>, - token_uri: LegacyMap, + owners: Map::, + balances: Map::, + token_approvals: Map::, + operator_approvals: Map::<(ContractAddress, ContractAddress), bool>, + token_uri: Map, } #[event] diff --git a/src/test_helper/simple_account.cairo b/src/test_helper/simple_account.cairo index 3e0476c..0b982bd 100644 --- a/src/test_helper/simple_account.cairo +++ b/src/test_helper/simple_account.cairo @@ -9,12 +9,7 @@ trait ISimpleAccount { ) -> felt252; fn __validate__(ref self: TContractState, calls: Array) -> felt252; fn __validate_declare__(self: @TContractState, class_hash: felt252) -> felt252; - fn __validate_deploy__( - self: @TContractState, - class_hash: felt252, - contract_address_salt: felt252, - public_key: felt252 - ) -> felt252; + fn __validate_deploy__(ref self: TContractState, public_key: felt252) -> felt252; fn __execute__(ref self: TContractState, calls: Array) -> Array>; } @@ -33,8 +28,8 @@ mod SimpleAccount { } #[constructor] - fn constructor(ref self: ContractState, _public_key: felt252) { - self._public_key.write(_public_key); + fn constructor(ref self: ContractState, public_key: felt252) { + self._public_key.write(public_key); } #[abi(embed_v0)] @@ -54,12 +49,7 @@ mod SimpleAccount { self._is_valid_signature(hash, signature) } - fn __validate_deploy__( - self: @ContractState, - class_hash: felt252, - contract_address_salt: felt252, - public_key: felt252 - ) -> felt252 { + fn __validate_deploy__(ref self: ContractState, public_key: felt252) -> felt252 { self.validate_transaction() } diff --git a/src/upgradeable.cairo b/src/upgradeable.cairo deleted file mode 100644 index 9304e1d..0000000 --- a/src/upgradeable.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod upgradeable; - -use upgradeable::UpgradeableComponent;