From 99723616047f2077d6891f98f407a125d1fddd85 Mon Sep 17 00:00:00 2001 From: Darlington02 Date: Mon, 30 Sep 2024 15:47:18 +0100 Subject: [PATCH] chore: upgrade contracts to `v2.8.3` --- .github/workflows/test_contracts.yml | 2 +- README.md | 4 +- Scarb.lock | 69 +++++++++++++------ Scarb.toml | 8 +-- src/components/account.cairo | 2 - src/components/account/account.cairo | 11 +-- src/components/lockable/lockable.cairo | 5 -- .../permissionable/permissionable.cairo | 8 +-- src/components/signatory/signatory.cairo | 2 +- src/components/upgradeable/upgradeable.cairo | 4 +- src/interfaces/IAccount.cairo | 2 - src/interfaces/ILockable.cairo | 2 - src/interfaces/ISRC6.cairo | 2 - src/registry/registry.cairo | 5 +- src/test_helper/simple_account.cairo | 7 +- tests/test_account_component.cairo | 49 ++++++------- tests/test_account_v3.cairo | 37 +++++----- tests/test_lockable_component.cairo | 32 +++------ tests/test_permissionable_component.cairo | 31 ++++----- tests/test_registry.cairo | 25 +++---- tests/test_signatory_component.cairo | 30 +++----- tests/test_upgradeable.cairo | 34 ++++----- 22 files changed, 158 insertions(+), 213 deletions(-) diff --git a/.github/workflows/test_contracts.yml b/.github/workflows/test_contracts.yml index 378c468..332976a 100644 --- a/.github/workflows/test_contracts.yml +++ b/.github/workflows/test_contracts.yml @@ -11,6 +11,6 @@ jobs: - uses: software-mansion/setup-scarb@v1 - uses: foundry-rs/setup-snfoundry@v3 with: - starknet-foundry-version: 0.27.0 + starknet-foundry-version: 0.31.0 - name: Run cairo tests run: snforge test \ No newline at end of file diff --git a/README.md b/README.md index 826724a..ac0135a 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# ERC-6551 Reference Implementation on Starknet (SNIP-14) +# ERC-6551 Implementation on Starknet (SNIP-14) This repository contains the reference implementation of ERC-6551 on Starknet. -**NB:** This project is under active development and may undergo changes until SNIP-14 is finalized. +**NB:** This project is under active development and may undergo changes until [SNIP-14](https://github.com/starknet-io/SNIPs/blob/main/SNIPS/snip-14.md) is finalized. ## The Tokenbound Standard This proposal defines a system which assigns contract accounts to Non-fungible tokens (ERC-721s). diff --git a/Scarb.lock b/Scarb.lock index b0245e3..1b6e8d4 100644 --- a/Scarb.lock +++ b/Scarb.lock @@ -3,13 +3,15 @@ version = 1 [[package]] name = "openzeppelin" -version = "0.15.1" -source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.15.1#2f8a93d762858714095a1d391afffa9e21df6983" +version = "0.17.0" +source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.17.0#bf5d02c25c989ccc24f3ab42ec649617d3f21289" dependencies = [ "openzeppelin_access", "openzeppelin_account", + "openzeppelin_finance", "openzeppelin_governance", "openzeppelin_introspection", + "openzeppelin_merkle_tree", "openzeppelin_presets", "openzeppelin_security", "openzeppelin_token", @@ -19,8 +21,8 @@ dependencies = [ [[package]] name = "openzeppelin_access" -version = "0.15.1" -source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.15.1#2f8a93d762858714095a1d391afffa9e21df6983" +version = "0.17.0" +source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.17.0#bf5d02c25c989ccc24f3ab42ec649617d3f21289" dependencies = [ "openzeppelin_introspection", "openzeppelin_utils", @@ -28,17 +30,26 @@ dependencies = [ [[package]] name = "openzeppelin_account" -version = "0.15.1" -source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.15.1#2f8a93d762858714095a1d391afffa9e21df6983" +version = "0.17.0" +source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.17.0#bf5d02c25c989ccc24f3ab42ec649617d3f21289" dependencies = [ "openzeppelin_introspection", "openzeppelin_utils", ] +[[package]] +name = "openzeppelin_finance" +version = "0.17.0" +source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.17.0#bf5d02c25c989ccc24f3ab42ec649617d3f21289" +dependencies = [ + "openzeppelin_access", + "openzeppelin_token", +] + [[package]] name = "openzeppelin_governance" -version = "0.15.1" -source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.15.1#2f8a93d762858714095a1d391afffa9e21df6983" +version = "0.17.0" +source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.17.0#bf5d02c25c989ccc24f3ab42ec649617d3f21289" dependencies = [ "openzeppelin_access", "openzeppelin_introspection", @@ -46,16 +57,22 @@ dependencies = [ [[package]] name = "openzeppelin_introspection" -version = "0.15.1" -source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.15.1#2f8a93d762858714095a1d391afffa9e21df6983" +version = "0.17.0" +source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.17.0#bf5d02c25c989ccc24f3ab42ec649617d3f21289" + +[[package]] +name = "openzeppelin_merkle_tree" +version = "0.17.0" +source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.17.0#bf5d02c25c989ccc24f3ab42ec649617d3f21289" [[package]] name = "openzeppelin_presets" -version = "0.15.1" -source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.15.1#2f8a93d762858714095a1d391afffa9e21df6983" +version = "0.17.0" +source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.17.0#bf5d02c25c989ccc24f3ab42ec649617d3f21289" dependencies = [ "openzeppelin_access", "openzeppelin_account", + "openzeppelin_finance", "openzeppelin_introspection", "openzeppelin_token", "openzeppelin_upgrades", @@ -63,13 +80,13 @@ dependencies = [ [[package]] name = "openzeppelin_security" -version = "0.15.1" -source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.15.1#2f8a93d762858714095a1d391afffa9e21df6983" +version = "0.17.0" +source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.17.0#bf5d02c25c989ccc24f3ab42ec649617d3f21289" [[package]] name = "openzeppelin_token" -version = "0.15.1" -source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.15.1#2f8a93d762858714095a1d391afffa9e21df6983" +version = "0.17.0" +source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.17.0#bf5d02c25c989ccc24f3ab42ec649617d3f21289" dependencies = [ "openzeppelin_account", "openzeppelin_governance", @@ -78,18 +95,26 @@ dependencies = [ [[package]] name = "openzeppelin_upgrades" -version = "0.15.1" -source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.15.1#2f8a93d762858714095a1d391afffa9e21df6983" +version = "0.17.0" +source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.17.0#bf5d02c25c989ccc24f3ab42ec649617d3f21289" [[package]] name = "openzeppelin_utils" -version = "0.15.1" -source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.15.1#2f8a93d762858714095a1d391afffa9e21df6983" +version = "0.17.0" +source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.17.0#bf5d02c25c989ccc24f3ab42ec649617d3f21289" + +[[package]] +name = "snforge_scarb_plugin" +version = "0.31.0" +source = "git+https://github.com/foundry-rs/starknet-foundry.git?tag=v0.31.0#72ea785ca354e9e506de3e5d687da9fb2c1b3c67" [[package]] name = "snforge_std" -version = "0.27.0" -source = "git+https://github.com/foundry-rs/starknet-foundry.git?tag=v0.27.0#2d99b7c00678ef0363881ee0273550c44a9263de" +version = "0.31.0" +source = "git+https://github.com/foundry-rs/starknet-foundry.git?tag=v0.31.0#72ea785ca354e9e506de3e5d687da9fb2c1b3c67" +dependencies = [ + "snforge_scarb_plugin", +] [[package]] name = "token_bound_accounts" diff --git a/Scarb.toml b/Scarb.toml index 7ea7911..aa3c4d3 100644 --- a/Scarb.toml +++ b/Scarb.toml @@ -8,7 +8,7 @@ repository = "https://github.com/horuslabsio/TBA/blob/main/Scarb.toml" license-file = "LICENSE" keywords = ["ERC6551", "tokenbound", "cairo", "contracts", "starknet", "standards"] readme = "README.md" -cairo_version = "2.7.0" +cairo_version = "2.8.2" homepage = "https://www.tbaexplorer.com/" documentation = "https://github.com/horuslabsio/TBA-SDK" @@ -22,11 +22,11 @@ casm = true [lib] [dependencies] -starknet = "2.7.0" -openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", tag = "v0.15.1" } +starknet = "2.8.2" +openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", tag = "v0.17.0" } [dev-dependencies] -snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry.git", tag = "v0.27.0" } +snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry.git", tag = "v0.31.0" } [tool.snforge] # exit_first = true diff --git a/src/components/account.cairo b/src/components/account.cairo index 28477ca..b0edc6c 100644 --- a/src/components/account.cairo +++ b/src/components/account.cairo @@ -1,3 +1 @@ pub mod account; - -use account::AccountComponent; diff --git a/src/components/account/account.cairo b/src/components/account/account.cairo index f42a862..45bad05 100644 --- a/src/components/account/account.cairo +++ b/src/components/account/account.cairo @@ -8,15 +8,10 @@ pub mod AccountComponent { result::ResultTrait, hash::HashStateTrait, pedersen::PedersenTrait, num::traits::zero::Zero }; use starknet::{ - get_tx_info, get_caller_address, get_contract_address, get_block_timestamp, ContractAddress, - account::Call, syscalls::call_contract_syscall, syscalls::replace_class_syscall, ClassHash, - SyscallResultTrait, storage::StoragePointerWriteAccess - }; - - use token_bound_accounts::interfaces::IERC721::{IERC721DispatcherTrait, IERC721Dispatcher}; - use token_bound_accounts::interfaces::IAccount::{ - IAccount, IAccountDispatcherTrait, IAccountDispatcher, TBA_INTERFACE_ID + get_tx_info, get_contract_address, ContractAddress, account::Call, + syscalls::call_contract_syscall, storage::StoragePointerWriteAccess }; + use token_bound_accounts::interfaces::IAccount::{IAccount, TBA_INTERFACE_ID}; use openzeppelin::introspection::src5::SRC5Component; use openzeppelin::introspection::src5::SRC5Component::{SRC5Impl, InternalImpl}; diff --git a/src/components/lockable/lockable.cairo b/src/components/lockable/lockable.cairo index 30233d1..cf1d4a6 100644 --- a/src/components/lockable/lockable.cairo +++ b/src/components/lockable/lockable.cairo @@ -8,12 +8,7 @@ pub mod LockableComponent { use starknet::{ContractAddress, get_caller_address, get_block_timestamp}; use token_bound_accounts::components::account::account::AccountComponent; - use token_bound_accounts::interfaces::IAccount::{IAccount, IAccountDispatcherTrait}; use token_bound_accounts::components::account::account::AccountComponent::AccountPrivateImpl; - use token_bound_accounts::interfaces::ILockable::{ - ILockable, ILockableDispatcher, ILockableDispatcherTrait - }; - use openzeppelin::introspection::src5::SRC5Component; // ************************************************************************* diff --git a/src/components/permissionable/permissionable.cairo b/src/components/permissionable/permissionable.cairo index f530a29..4e0b982 100644 --- a/src/components/permissionable/permissionable.cairo +++ b/src/components/permissionable/permissionable.cairo @@ -4,15 +4,11 @@ pub mod PermissionableComponent { // IMPORTS // ************************************************************************* use starknet::storage::{Map, StorageMapReadAccess, StorageMapWriteAccess}; - use starknet::{ContractAddress, get_caller_address, get_block_timestamp}; + use starknet::{ContractAddress, get_caller_address}; use token_bound_accounts::components::account::account::AccountComponent; - use token_bound_accounts::interfaces::IAccount::{IAccount, IAccountDispatcherTrait}; + use token_bound_accounts::interfaces::IAccount::IAccount; use token_bound_accounts::components::account::account::AccountComponent::AccountPrivateImpl; - use token_bound_accounts::interfaces::IPermissionable::{ - IPermissionable, IPermissionableDispatcher, IPermissionableDispatcherTrait - }; - use openzeppelin::introspection::src5::SRC5Component; // ************************************************************************* diff --git a/src/components/signatory/signatory.cairo b/src/components/signatory/signatory.cairo index 4481151..4ea2277 100644 --- a/src/components/signatory/signatory.cairo +++ b/src/components/signatory/signatory.cairo @@ -3,7 +3,7 @@ pub mod SignatoryComponent { // ************************************************************************* // IMPORTS // ************************************************************************* - use starknet::{get_caller_address, get_contract_address, ContractAddress}; + use starknet::ContractAddress; use token_bound_accounts::components::account::account::AccountComponent; use token_bound_accounts::components::account::account::AccountComponent::AccountPrivateImpl; use token_bound_accounts::components::account::account::AccountComponent::AccountImpl; diff --git a/src/components/upgradeable/upgradeable.cairo b/src/components/upgradeable/upgradeable.cairo index e4a9fe0..2af41dc 100644 --- a/src/components/upgradeable/upgradeable.cairo +++ b/src/components/upgradeable/upgradeable.cairo @@ -3,9 +3,7 @@ pub mod UpgradeableComponent { // ************************************************************************* // IMPORTS // ************************************************************************* - use starknet::{ - ClassHash, SyscallResultTrait, get_caller_address, get_contract_address, ContractAddress - }; + use starknet::{ClassHash, SyscallResultTrait, get_contract_address, ContractAddress}; use core::num::traits::zero::Zero; use token_bound_accounts::components::account::account::AccountComponent; diff --git a/src/interfaces/IAccount.cairo b/src/interfaces/IAccount.cairo index 0a55f22..d220f04 100644 --- a/src/interfaces/IAccount.cairo +++ b/src/interfaces/IAccount.cairo @@ -2,8 +2,6 @@ // BASE ACCOUNT INTERFACE // ************************************************************************* use starknet::ContractAddress; -use starknet::ClassHash; -use starknet::account::Call; // SRC5 interface pub const TBA_INTERFACE_ID: felt252 = diff --git a/src/interfaces/ILockable.cairo b/src/interfaces/ILockable.cairo index d893e39..4267ba5 100644 --- a/src/interfaces/ILockable.cairo +++ b/src/interfaces/ILockable.cairo @@ -1,8 +1,6 @@ // ************************************************************************* // LOCKABLE INTERFACE // ************************************************************************* -use starknet::ContractAddress; - #[starknet::interface] pub trait ILockable { fn lock(ref self: TContractState, lock_until: u64); diff --git a/src/interfaces/ISRC6.cairo b/src/interfaces/ISRC6.cairo index 49e0982..6d411ad 100644 --- a/src/interfaces/ISRC6.cairo +++ b/src/interfaces/ISRC6.cairo @@ -1,5 +1,3 @@ -use starknet::ContractAddress; -use starknet::ClassHash; use starknet::account::Call; #[starknet::interface] diff --git a/src/registry/registry.cairo b/src/registry/registry.cairo index b2f0720..5908b95 100644 --- a/src/registry/registry.cairo +++ b/src/registry/registry.cairo @@ -11,11 +11,8 @@ pub mod Registry { use core::pedersen::PedersenTrait; use starknet::{ ContractAddress, get_caller_address, get_contract_address, - syscalls::{call_contract_syscall, deploy_syscall}, class_hash::ClassHash, - SyscallResultTrait, storage::Map + syscalls::{call_contract_syscall, deploy_syscall}, class_hash::ClassHash, SyscallResultTrait }; - - use token_bound_accounts::interfaces::IERC721::{IERC721DispatcherTrait, IERC721Dispatcher}; use token_bound_accounts::interfaces::IRegistry::IRegistry; // ************************************************************************* diff --git a/src/test_helper/simple_account.cairo b/src/test_helper/simple_account.cairo index 1439cd9..787d201 100644 --- a/src/test_helper/simple_account.cairo +++ b/src/test_helper/simple_account.cairo @@ -1,4 +1,4 @@ -use starknet::{account::Call, ContractAddress, ClassHash}; +use starknet::account::Call; #[starknet::interface] pub trait ISimpleAccount { @@ -18,9 +18,8 @@ pub mod SimpleAccount { use starknet::storage::StoragePointerWriteAccess; use starknet::storage::StoragePointerReadAccess; use starknet::{ - get_tx_info, get_caller_address, get_contract_address, ContractAddress, account::Call, - syscalls::call_contract_syscall, syscalls::replace_class_syscall, ClassHash, - SyscallResultTrait + get_tx_info, get_caller_address, get_contract_address, account::Call, + syscalls::call_contract_syscall }; use core::ecdsa::check_ecdsa_signature; use core::num::traits::zero::Zero; diff --git a/tests/test_account_component.cairo b/tests/test_account_component.cairo index df015d8..9b2f728 100644 --- a/tests/test_account_component.cairo +++ b/tests/test_account_component.cairo @@ -3,28 +3,21 @@ // ************************************************************************* use starknet::{ContractAddress, account::Call}; use snforge_std::{ - declare, start_cheat_caller_address, stop_cheat_caller_address, - start_cheat_account_contract_address, stop_cheat_account_contract_address, - start_cheat_transaction_hash, start_cheat_nonce, spy_events, EventSpyAssertionsTrait, - ContractClassTrait, ContractClass + declare, start_cheat_caller_address, start_cheat_transaction_hash, start_cheat_nonce, + spy_events, EventSpyAssertionsTrait, ContractClass, ContractClassTrait, DeclareResultTrait }; use core::hash::HashStateTrait; use core::pedersen::PedersenTrait; -use token_bound_accounts::interfaces::IRegistry::{IRegistryDispatcherTrait, IRegistryDispatcher}; use token_bound_accounts::interfaces::IAccount::{IAccountDispatcher, IAccountDispatcherTrait}; use token_bound_accounts::interfaces::IExecutable::{ IExecutableDispatcher, IExecutableDispatcherTrait }; use token_bound_accounts::interfaces::IERC721::{IERC721Dispatcher, IERC721DispatcherTrait}; -use token_bound_accounts::components::presets::account_preset::AccountPreset; use token_bound_accounts::components::account::account::AccountComponent; -use token_bound_accounts::registry::registry::Registry; use token_bound_accounts::test_helper::{ - hello_starknet::{IHelloStarknetDispatcher, IHelloStarknetDispatcherTrait, HelloStarknet}, - simple_account::{ISimpleAccountDispatcher, ISimpleAccountDispatcherTrait, SimpleAccount}, - erc721_helper::ERC721 + hello_starknet::{IHelloStarknetDispatcher, IHelloStarknetDispatcherTrait}, }; const ACCOUNT: felt252 = 1234; @@ -38,14 +31,14 @@ fn __setup__() -> ( ContractAddress, ContractAddress, ContractAddress, ContractClass, ContractClass ) { // deploy erc721 helper contract - let erc721_contract = declare("ERC721").unwrap(); + let erc721_contract = declare("ERC721").unwrap().contract_class(); let mut erc721_constructor_calldata = array!['tokenbound', 'TBA']; let (erc721_contract_address, _) = erc721_contract .deploy(@erc721_constructor_calldata) .unwrap(); // deploy recipient contract - let recipient_contract_class = declare("SimpleAccount").unwrap(); + let recipient_contract_class = declare("SimpleAccount").unwrap().contract_class(); let (recipient, _) = recipient_contract_class .deploy( @array![883045738439352841478194533192765345509759306772397516907181243450667673002] @@ -57,17 +50,17 @@ fn __setup__() -> ( dispatcher.mint(recipient, 1.try_into().unwrap()); // deploy registry contract - let registry_contract = declare("Registry").unwrap(); + let registry_contract = declare("Registry").unwrap().contract_class(); let (registry_contract_address, _) = registry_contract.deploy(@array![]).unwrap(); // deploy account contract - let account_contract_class = declare("AccountPreset").unwrap(); - let mut acct_constructor_calldata = array![ + let account_contract_class = declare("AccountPreset").unwrap().contract_class(); + let mut acct_constructor_calldata: Array = array![ erc721_contract_address.try_into().unwrap(), 1, 0, registry_contract_address.try_into().unwrap(), - account_contract_class.class_hash.into(), + (*account_contract_class.class_hash).into(), 20 ]; let (account_contract_address, _) = account_contract_class @@ -78,8 +71,8 @@ fn __setup__() -> ( account_contract_address, erc721_contract_address, registry_contract_address, - recipient_contract_class, - account_contract_class + *recipient_contract_class, + *account_contract_class ) } @@ -99,8 +92,8 @@ fn test_constructor() { #[test] fn test_event_is_emitted_on_initialization() { - // deploy erc721 contract - let erc721_contract = declare("ERC721").unwrap(); + // deploy erc721 helper contract + let erc721_contract = declare("ERC721").unwrap().contract_class(); let mut erc721_constructor_calldata = array!['tokenbound', 'TBA']; let (erc721_contract_address, _) = erc721_contract .deploy(@erc721_constructor_calldata) @@ -114,17 +107,17 @@ fn test_event_is_emitted_on_initialization() { let mut spy = spy_events(); // deploy registry contract - let registry_contract = declare("Registry").unwrap(); + let registry_contract = declare("Registry").unwrap().contract_class(); let (registry_contract_address, _) = registry_contract.deploy(@array![]).unwrap(); // deploy account contract - let account_contract = declare("AccountPreset").unwrap(); + let account_contract = declare("AccountPreset").unwrap().contract_class(); let mut acct_constructor_calldata = array![ erc721_contract_address.try_into().unwrap(), 1, 0, registry_contract_address.try_into().unwrap(), - account_contract.class_hash.into(), + (*account_contract.class_hash).into(), 20 ]; let (account_contract_address, _) = account_contract @@ -156,7 +149,7 @@ fn test_execute() { let dispatcher = IExecutableDispatcher { contract_address }; // deploy `HelloStarknet` contract for testing - let test_contract = declare("HelloStarknet").unwrap(); + let test_contract = declare("HelloStarknet").unwrap().contract_class(); let (test_address, _) = test_contract.deploy(@array![]).unwrap(); // craft calldata for call array @@ -190,7 +183,7 @@ fn test_execute_multicall() { let dispatcher = IExecutableDispatcher { contract_address }; // deploy `HelloStarknet` contract for testing - let test_contract = declare("HelloStarknet").unwrap(); + let test_contract = declare("HelloStarknet").unwrap().contract_class(); let (test_address, _) = test_contract.deploy(@array![]).unwrap(); // craft calldata and create call array @@ -231,7 +224,7 @@ fn test_execution_fails_if_invalid_signer() { let dispatcher = IExecutableDispatcher { contract_address }; // deploy `HelloStarknet` contract for testing - let test_contract = declare("HelloStarknet").unwrap(); + let test_contract = declare("HelloStarknet").unwrap().contract_class(); let (test_address, _) = test_contract.deploy(@array![]).unwrap(); // craft calldata for call array @@ -256,7 +249,7 @@ fn test_execution_emits_event() { let dispatcher = IExecutableDispatcher { contract_address }; // deploy `HelloStarknet` contract for testing - let test_contract = declare("HelloStarknet").unwrap(); + let test_contract = declare("HelloStarknet").unwrap().contract_class(); let (test_address, _) = test_contract.deploy(@array![]).unwrap(); // craft calldata for call array @@ -307,7 +300,7 @@ fn test_execution_updates_state() { let account_dispatcher = IAccountDispatcher { contract_address }; // deploy `HelloStarknet` contract for testing - let test_contract = declare("HelloStarknet").unwrap(); + let test_contract = declare("HelloStarknet").unwrap().contract_class(); let (test_address, _) = test_contract.deploy(@array![]).unwrap(); // craft calldata for call array diff --git a/tests/test_account_v3.cairo b/tests/test_account_v3.cairo index c3b492c..feec69e 100644 --- a/tests/test_account_v3.cairo +++ b/tests/test_account_v3.cairo @@ -1,14 +1,9 @@ use starknet::{ContractAddress, account::Call}; use snforge_std::{ - declare, start_cheat_caller_address, stop_cheat_caller_address, start_cheat_transaction_hash, - start_cheat_nonce, spy_events, EventSpyAssertionsTrait, ContractClassTrait, ContractClass, - start_cheat_chain_id, stop_cheat_chain_id, start_cheat_chain_id_global, - stop_cheat_chain_id_global, + declare, start_cheat_caller_address, stop_cheat_caller_address, start_cheat_chain_id_global, + ContractClassTrait, DeclareResultTrait }; -use core::hash::HashStateTrait; -use core::pedersen::PedersenTrait; -use token_bound_accounts::interfaces::IRegistry::{IRegistryDispatcherTrait, IRegistryDispatcher}; use token_bound_accounts::interfaces::IERC721::{ IERC721Dispatcher, IERC721DispatcherTrait, IERC721SafeDispatcher, IERC721SafeDispatcherTrait }; @@ -26,10 +21,8 @@ use token_bound_accounts::interfaces::IPermissionable::{ use token_bound_accounts::interfaces::ISignatory::{ISignatoryDispatcher, ISignatoryDispatcherTrait}; use token_bound_accounts::interfaces::IAccountV3::{IAccountV3Dispatcher, IAccountV3DispatcherTrait}; use token_bound_accounts::test_helper::{ - hello_starknet::{IHelloStarknetDispatcher, IHelloStarknetDispatcherTrait, HelloStarknet}, - simple_account::{ISimpleAccountDispatcher, ISimpleAccountDispatcherTrait, SimpleAccount}, - account_upgrade::{IUpgradedAccountDispatcher, IUpgradedAccountDispatcherTrait, UpgradedAccount}, - erc721_helper::ERC721 + hello_starknet::{IHelloStarknetDispatcher, IHelloStarknetDispatcherTrait}, + account_upgrade::{IUpgradedAccountDispatcher, IUpgradedAccountDispatcherTrait} }; @@ -46,14 +39,14 @@ const SALT: felt252 = 123; // ************************************************************************* fn __setup__() -> (ContractAddress, ContractAddress, ContractAddress, ContractAddress, felt252) { // deploy erc721 helper contract - let erc721_contract = declare("ERC721").unwrap(); + let erc721_contract = declare("ERC721").unwrap().contract_class(); let mut erc721_constructor_calldata = array!['tokenbound', 'TBA']; let (erc721_contract_address, _) = erc721_contract .deploy(@erc721_constructor_calldata) .unwrap(); // deploy recipient contract - let recipient_contract_class = declare("SimpleAccount").unwrap(); + let recipient_contract_class = declare("SimpleAccount").unwrap().contract_class(); let (recipient, _) = recipient_contract_class .deploy( @array![883045738439352841478194533192765345509759306772397516907181243450667673002] @@ -66,17 +59,17 @@ fn __setup__() -> (ContractAddress, ContractAddress, ContractAddress, ContractAd dispatcher.mint(recipient, 2.try_into().unwrap()); // deploy registry contract - let registry_contract = declare("Registry").unwrap(); + let registry_contract = declare("Registry").unwrap().contract_class(); let (registry_contract_address, _) = registry_contract.deploy(@array![]).unwrap(); // deploy account V3 contract - let account_v3_contract_class = declare("AccountV3").unwrap(); + let account_v3_contract_class = declare("AccountV3").unwrap().contract_class(); let mut acct_constructor_calldata = array![ erc721_contract_address.try_into().unwrap(), 1, 0, registry_contract_address.try_into().unwrap(), - account_v3_contract_class.class_hash.into(), + (*account_v3_contract_class.class_hash).into(), 20 ]; let (account_v3_contract_address, _) = account_v3_contract_class @@ -88,7 +81,7 @@ fn __setup__() -> (ContractAddress, ContractAddress, ContractAddress, ContractAd recipient, account_v3_contract_address, registry_contract_address, - account_v3_contract_class.class_hash.into() + (*account_v3_contract_class.class_hash).into() ) } @@ -191,7 +184,7 @@ fn test_owner_and_any_permissioned_account_can_execute() { permissionable_dispatcher.set_permission(permissioned_addresses, permissions); // deploy `HelloStarknet` contract for testing - let test_contract = declare("HelloStarknet").unwrap(); + let test_contract = declare("HelloStarknet").unwrap().contract_class(); let (test_address, _) = test_contract.deploy(@array![]).unwrap(); // craft calldata for call array @@ -238,7 +231,7 @@ fn test_locked_account_cannot_execute() { lockable_dispatcher.lock(lock_duration); // deploy `HelloStarknet` contract for testing - let test_contract = declare("HelloStarknet").unwrap(); + let test_contract = declare("HelloStarknet").unwrap().contract_class(); let (test_address, _) = test_contract.deploy(@array![]).unwrap(); // craft calldata for call array @@ -304,7 +297,8 @@ fn test_owner_can_upgrade() { let (_, _, account_v3_contract_address, _, _,) = __setup__(); let acct_dispatcher = IAccountDispatcher { contract_address: account_v3_contract_address }; let dispatcher = IUpgradeableDispatcher { contract_address: account_v3_contract_address }; - let new_class_hash = declare("UpgradedAccount").unwrap().class_hash; + let upgraded_account_class = declare("UpgradedAccount").unwrap().contract_class(); + let new_class_hash = *upgraded_account_class.class_hash; // get owner let owner = acct_dispatcher.owner(); @@ -331,7 +325,8 @@ fn test_permissioned_accounts_cannot_upgrade() { contract_address: account_v3_contract_address }; let dispatcher = IUpgradeableDispatcher { contract_address: account_v3_contract_address }; - let new_class_hash = declare("UpgradedAccount").unwrap().class_hash; + let upgraded_account_class = declare("UpgradedAccount").unwrap().contract_class(); + let new_class_hash = *upgraded_account_class.class_hash; let owner = acct_dispatcher.owner(); // create array of permissioned addresses and permissions diff --git a/tests/test_lockable_component.cairo b/tests/test_lockable_component.cairo index 241586c..392484e 100644 --- a/tests/test_lockable_component.cairo +++ b/tests/test_lockable_component.cairo @@ -3,14 +3,10 @@ // ************************************************************************* use starknet::{ContractAddress, account::Call, get_block_timestamp}; use snforge_std::{ - declare, start_cheat_caller_address, stop_cheat_caller_address, start_cheat_transaction_hash, - start_cheat_nonce, spy_events, EventSpyAssertionsTrait, ContractClassTrait, ContractClass, - start_cheat_block_timestamp, stop_cheat_block_timestamp + declare, start_cheat_caller_address, stop_cheat_caller_address, spy_events, + EventSpyAssertionsTrait, ContractClassTrait, DeclareResultTrait, start_cheat_block_timestamp, + stop_cheat_block_timestamp }; -use core::hash::HashStateTrait; -use core::pedersen::PedersenTrait; - -use token_bound_accounts::interfaces::IRegistry::{IRegistryDispatcherTrait, IRegistryDispatcher}; use token_bound_accounts::interfaces::IAccount::{IAccountDispatcher, IAccountDispatcherTrait}; use token_bound_accounts::interfaces::ILockable::{ILockableDispatcher, ILockableDispatcherTrait}; use token_bound_accounts::interfaces::IExecutable::{ @@ -20,15 +16,8 @@ use token_bound_accounts::interfaces::IUpgradeable::{ IUpgradeableDispatcher, IUpgradeableDispatcherTrait }; use token_bound_accounts::interfaces::IERC721::{IERC721Dispatcher, IERC721DispatcherTrait}; -use token_bound_accounts::components::presets::account_preset::AccountPreset; use token_bound_accounts::components::lockable::lockable::LockableComponent; -use token_bound_accounts::test_helper::{ - hello_starknet::{IHelloStarknetDispatcher, IHelloStarknetDispatcherTrait, HelloStarknet}, - simple_account::{ISimpleAccountDispatcher, ISimpleAccountDispatcherTrait, SimpleAccount}, - erc721_helper::ERC721 -}; - const ACCOUNT2: felt252 = 5729; // ************************************************************************* @@ -36,14 +25,14 @@ const ACCOUNT2: felt252 = 5729; // ************************************************************************* fn __setup__() -> (ContractAddress, ContractAddress) { // deploy erc721 helper contract - let erc721_contract = declare("ERC721").unwrap(); + let erc721_contract = declare("ERC721").unwrap().contract_class(); let mut erc721_constructor_calldata = array!['tokenbound', 'TBA']; let (erc721_contract_address, _) = erc721_contract .deploy(@erc721_constructor_calldata) .unwrap(); // deploy recipient contract - let account_contract = declare("SimpleAccount").unwrap(); + let account_contract = declare("SimpleAccount").unwrap().contract_class(); let (recipient, _) = account_contract .deploy( @array![883045738439352841478194533192765345509759306772397516907181243450667673002] @@ -55,17 +44,17 @@ fn __setup__() -> (ContractAddress, ContractAddress) { dispatcher.mint(recipient, 1.try_into().unwrap()); // deploy registry contract - let registry_contract = declare("Registry").unwrap(); + let registry_contract = declare("Registry").unwrap().contract_class(); let (registry_contract_address, _) = registry_contract.deploy(@array![]).unwrap(); // deploy account contract - let account_contract = declare("AccountPreset").unwrap(); + let account_contract = declare("AccountPreset").unwrap().contract_class(); let mut acct_constructor_calldata = array![ erc721_contract_address.try_into().unwrap(), 1, 0, registry_contract_address.try_into().unwrap(), - account_contract.class_hash.into(), + (*account_contract.class_hash).into(), 20 ]; let (account_contract_address, _) = account_contract @@ -137,7 +126,7 @@ fn test_execute_should_fail_when_locked() { stop_cheat_caller_address(contract_address); // deploy `HelloStarknet` contract for testing - let test_contract = declare("HelloStarknet").unwrap(); + let test_contract = declare("HelloStarknet").unwrap().contract_class(); let (test_address, _) = test_contract.deploy(@array![]).unwrap(); // craft calldata for call array @@ -157,7 +146,8 @@ fn test_execute_should_fail_when_locked() { fn test_upgrade_should_fail_when_locked() { let (contract_address, _) = __setup__(); let acct_dispatcher = IAccountDispatcher { contract_address: contract_address }; - let new_class_hash = declare("UpgradedAccount").unwrap().class_hash; + let upgraded_account_class = declare("UpgradedAccount").unwrap().contract_class(); + let new_class_hash = *upgraded_account_class.class_hash; let owner = acct_dispatcher.owner(); let lock_duration = 30_u64; diff --git a/tests/test_permissionable_component.cairo b/tests/test_permissionable_component.cairo index b7d1d91..2d4d99c 100644 --- a/tests/test_permissionable_component.cairo +++ b/tests/test_permissionable_component.cairo @@ -1,16 +1,11 @@ // ************************************************************************* // PERMISSIONABLE COMPONENT TEST // ************************************************************************* -use starknet::{ContractAddress, account::Call, get_block_timestamp}; +use starknet::{ContractAddress, account::Call}; use snforge_std::{ - declare, start_cheat_caller_address, stop_cheat_caller_address, start_cheat_transaction_hash, - start_cheat_nonce, spy_events, EventSpyAssertionsTrait, ContractClassTrait, ContractClass, - start_cheat_block_timestamp, stop_cheat_block_timestamp + declare, start_cheat_caller_address, stop_cheat_caller_address, spy_events, + EventSpyAssertionsTrait, ContractClassTrait, DeclareResultTrait }; -use core::hash::HashStateTrait; -use core::pedersen::PedersenTrait; - -use token_bound_accounts::interfaces::IRegistry::{IRegistryDispatcherTrait, IRegistryDispatcher}; use token_bound_accounts::interfaces::IAccount::{IAccountDispatcher, IAccountDispatcherTrait}; use token_bound_accounts::interfaces::IPermissionable::{ IPermissionableDispatcher, IPermissionableDispatcherTrait @@ -23,13 +18,10 @@ use token_bound_accounts::interfaces::IUpgradeable::{ IUpgradeableDispatcher, IUpgradeableDispatcherTrait }; use token_bound_accounts::interfaces::IERC721::{IERC721Dispatcher, IERC721DispatcherTrait}; -use token_bound_accounts::components::presets::account_preset::AccountPreset; use token_bound_accounts::components::permissionable::permissionable::PermissionableComponent; use token_bound_accounts::test_helper::{ - hello_starknet::{IHelloStarknetDispatcher, IHelloStarknetDispatcherTrait, HelloStarknet}, - simple_account::{ISimpleAccountDispatcher, ISimpleAccountDispatcherTrait, SimpleAccount}, - erc721_helper::ERC721 + hello_starknet::{IHelloStarknetDispatcher, IHelloStarknetDispatcherTrait} }; const ACCOUNT1: felt252 = 5729; @@ -42,14 +34,14 @@ const ACCOUNT4: felt252 = 4697; // ************************************************************************* fn __setup__() -> (ContractAddress, ContractAddress) { // deploy erc721 helper contract - let erc721_contract = declare("ERC721").unwrap(); + let erc721_contract = declare("ERC721").unwrap().contract_class(); let mut erc721_constructor_calldata = array!['tokenbound', 'TBA']; let (erc721_contract_address, _) = erc721_contract .deploy(@erc721_constructor_calldata) .unwrap(); // deploy recipient contract - let account_contract = declare("SimpleAccount").unwrap(); + let account_contract = declare("SimpleAccount").unwrap().contract_class(); let (recipient, _) = account_contract .deploy( @array![883045738439352841478194533192765345509759306772397516907181243450667673002] @@ -61,17 +53,17 @@ fn __setup__() -> (ContractAddress, ContractAddress) { dispatcher.mint(recipient, 1.try_into().unwrap()); // deploy registry contract - let registry_contract = declare("Registry").unwrap(); + let registry_contract = declare("Registry").unwrap().contract_class(); let (registry_contract_address, _) = registry_contract.deploy(@array![]).unwrap(); // deploy account contract - let account_contract = declare("AccountPreset").unwrap(); + let account_contract = declare("AccountPreset").unwrap().contract_class(); let mut acct_constructor_calldata = array![ erc721_contract_address.try_into().unwrap(), 1, 0, registry_contract_address.try_into().unwrap(), - account_contract.class_hash.into(), + (*account_contract.class_hash).into(), 20 ]; let (account_contract_address, _) = account_contract @@ -242,7 +234,7 @@ fn test_permissioned_accounts_can_execute() { assert(has_permission2 == true, 'Account: permitted'); // deploy `HelloStarknet` contract for testing - let test_contract = declare("HelloStarknet").unwrap(); + let test_contract = declare("HelloStarknet").unwrap().contract_class(); let (test_address, _) = test_contract.deploy(@array![]).unwrap(); // craft calldata for call array @@ -290,7 +282,8 @@ fn test_permissioned_accounts_can_upgrade() { stop_cheat_caller_address(contract_address); - let new_class_hash = declare("UpgradedAccount").unwrap().class_hash; + let upgraded_account_class = declare("UpgradedAccount").unwrap().contract_class(); + let new_class_hash = *upgraded_account_class.class_hash; // call the upgrade function let dispatcher = IUpgradeableDispatcher { contract_address }; diff --git a/tests/test_registry.cairo b/tests/test_registry.cairo index 3a8d04c..f3dd91a 100644 --- a/tests/test_registry.cairo +++ b/tests/test_registry.cairo @@ -4,21 +4,14 @@ use starknet::ContractAddress; use snforge_std::{ declare, start_cheat_caller_address, stop_cheat_caller_address, spy_events, - EventSpyAssertionsTrait, ContractClassTrait, ContractClass + EventSpyAssertionsTrait, ContractClassTrait, DeclareResultTrait }; use token_bound_accounts::interfaces::IRegistry::{IRegistryDispatcherTrait, IRegistryDispatcher}; use token_bound_accounts::interfaces::IAccount::{IAccountDispatcher, IAccountDispatcherTrait}; use token_bound_accounts::interfaces::IERC721::{IERC721Dispatcher, IERC721DispatcherTrait}; -use token_bound_accounts::components::presets::account_preset::AccountPreset; use token_bound_accounts::registry::registry::Registry; -use token_bound_accounts::test_helper::{ - hello_starknet::{IHelloStarknetDispatcher, IHelloStarknetDispatcherTrait, HelloStarknet}, - simple_account::{ISimpleAccountDispatcher, ISimpleAccountDispatcherTrait, SimpleAccount}, - erc721_helper::ERC721 -}; - const ACCOUNT: felt252 = 1234; // ************************************************************************* @@ -26,7 +19,7 @@ const ACCOUNT: felt252 = 1234; // ************************************************************************* fn __setup__() -> (ContractAddress, ContractAddress) { // deploy erc721 helper contract - let erc721_contract = declare("ERC721").unwrap(); + let erc721_contract = declare("ERC721").unwrap().contract_class(); let (erc721_contract_address, _) = erc721_contract .deploy(@array!['tokenbound', 'TBA']) .unwrap(); @@ -37,7 +30,7 @@ fn __setup__() -> (ContractAddress, ContractAddress) { dispatcher.mint(recipient, 1.try_into().unwrap()); // deploy registry contract - let registry_contract = declare("Registry").unwrap(); + let registry_contract = declare("Registry").unwrap().contract_class(); let (registry_contract_address, _) = registry_contract.deploy(@array![]).unwrap(); (registry_contract_address, erc721_contract_address) @@ -57,7 +50,8 @@ fn test_create_account() { start_cheat_caller_address(registry_contract_address, token_owner); // create account - let acct_class_hash = declare("AccountPreset").unwrap().class_hash; + let account_class = declare("AccountPreset").unwrap().contract_class(); + let acct_class_hash = *account_class.class_hash; let account_address = registry_dispatcher .create_account( acct_class_hash.into(), @@ -81,7 +75,8 @@ fn test_create_account_should_fail_if_not_nft_owner() { let registry_dispatcher = IRegistryDispatcher { contract_address: registry_contract_address }; // create account - let acct_class_hash = declare("AccountPreset").unwrap().class_hash; + let account_class = declare("AccountPreset").unwrap().contract_class(); + let acct_class_hash = *account_class.class_hash; registry_dispatcher .create_account( acct_class_hash.into(), @@ -106,7 +101,8 @@ fn test_create_account_emits_event() { start_cheat_caller_address(registry_contract_address, token_owner); // create account - let acct_class_hash = declare("AccountPreset").unwrap().class_hash; + let account_class = declare("AccountPreset").unwrap().contract_class(); + let acct_class_hash = *account_class.class_hash; let account_address = registry_dispatcher .create_account( acct_class_hash.into(), @@ -146,7 +142,8 @@ fn test_get_account() { start_cheat_caller_address(registry_contract_address, token_owner); // deploy account - let acct_class_hash = declare("AccountPreset").unwrap().class_hash; + let account_class = declare("AccountPreset").unwrap().contract_class(); + let acct_class_hash = *account_class.class_hash; let account_address = registry_dispatcher .create_account( acct_class_hash.into(), diff --git a/tests/test_signatory_component.cairo b/tests/test_signatory_component.cairo index 03448d5..e233e46 100644 --- a/tests/test_signatory_component.cairo +++ b/tests/test_signatory_component.cairo @@ -1,30 +1,16 @@ // ************************************************************************* // COMPONENT COMPONENT TEST // ************************************************************************* -use starknet::{ContractAddress, account::Call, get_block_timestamp}; +use starknet::ContractAddress; use snforge_std::{ - declare, start_cheat_caller_address, stop_cheat_caller_address, start_cheat_transaction_hash, - start_cheat_nonce, spy_events, EventSpyAssertionsTrait, ContractClassTrait, ContractClass, - start_cheat_block_timestamp, stop_cheat_block_timestamp + declare, start_cheat_caller_address, stop_cheat_caller_address, ContractClassTrait, + DeclareResultTrait }; -use core::hash::HashStateTrait; -use core::pedersen::PedersenTrait; - -use token_bound_accounts::interfaces::IRegistry::{IRegistryDispatcherTrait, IRegistryDispatcher}; -use token_bound_accounts::interfaces::IAccount::{IAccountDispatcher, IAccountDispatcherTrait}; use token_bound_accounts::interfaces::IPermissionable::{ IPermissionableDispatcher, IPermissionableDispatcherTrait }; use token_bound_accounts::interfaces::ISignatory::{ISignatoryDispatcher, ISignatoryDispatcherTrait}; use token_bound_accounts::interfaces::IERC721::{IERC721Dispatcher, IERC721DispatcherTrait}; -use token_bound_accounts::components::presets::account_preset::AccountPreset; -use token_bound_accounts::components::signatory::signatory::SignatoryComponent; - -use token_bound_accounts::test_helper::{ - hello_starknet::{IHelloStarknetDispatcher, IHelloStarknetDispatcherTrait, HelloStarknet}, - simple_account::{ISimpleAccountDispatcher, ISimpleAccountDispatcherTrait, SimpleAccount}, - erc721_helper::ERC721 -}; const ACCOUNT1: felt252 = 5729; const ACCOUNT2: felt252 = 1234; @@ -55,14 +41,14 @@ fn SIGNED_TX_DATA() -> SignedTransactionData { // ************************************************************************* fn __setup__() -> (ContractAddress, ContractAddress) { // deploy erc721 helper contract - let erc721_contract = declare("ERC721").unwrap(); + let erc721_contract = declare("ERC721").unwrap().contract_class(); let mut erc721_constructor_calldata = array!['tokenbound', 'TBA']; let (erc721_contract_address, _) = erc721_contract .deploy(@erc721_constructor_calldata) .unwrap(); // deploy recipient contract - let account_contract = declare("SimpleAccount").unwrap(); + let account_contract = declare("SimpleAccount").unwrap().contract_class(); let (recipient, _) = account_contract .deploy( @array![883045738439352841478194533192765345509759306772397516907181243450667673002] @@ -75,17 +61,17 @@ fn __setup__() -> (ContractAddress, ContractAddress) { dispatcher.mint(recipient, 2.try_into().unwrap()); // deploy registry contract - let registry_contract = declare("Registry").unwrap(); + let registry_contract = declare("Registry").unwrap().contract_class(); let (registry_contract_address, _) = registry_contract.deploy(@array![]).unwrap(); // deploy account contract - let account_contract = declare("AccountPreset").unwrap(); + let account_contract = declare("AccountPreset").unwrap().contract_class(); let mut acct_constructor_calldata = array![ erc721_contract_address.try_into().unwrap(), 1, 0, registry_contract_address.try_into().unwrap(), - account_contract.class_hash.into(), + (*account_contract.class_hash).into(), 20 ]; let (account_contract_address, _) = account_contract diff --git a/tests/test_upgradeable.cairo b/tests/test_upgradeable.cairo index cfb0bdb..ca0873a 100644 --- a/tests/test_upgradeable.cairo +++ b/tests/test_upgradeable.cairo @@ -1,28 +1,19 @@ // ************************************************************************* // UPGRADEABLE COMPONENT TEST // ************************************************************************* -use starknet::{ContractAddress, account::Call}; +use starknet::ContractAddress; use snforge_std::{ declare, start_cheat_caller_address, stop_cheat_caller_address, spy_events, - EventSpyAssertionsTrait, ContractClassTrait, ContractClass + EventSpyAssertionsTrait, ContractClassTrait, DeclareResultTrait }; -use core::hash::HashStateTrait; -use core::pedersen::PedersenTrait; - -use token_bound_accounts::interfaces::IRegistry::{IRegistryDispatcherTrait, IRegistryDispatcher}; -use token_bound_accounts::interfaces::IAccount::{IAccountDispatcher, IAccountDispatcherTrait}; use token_bound_accounts::interfaces::IUpgradeable::{ IUpgradeableDispatcher, IUpgradeableDispatcherTrait }; use token_bound_accounts::interfaces::IERC721::{IERC721Dispatcher, IERC721DispatcherTrait}; -use token_bound_accounts::components::presets::account_preset::AccountPreset; use token_bound_accounts::components::upgradeable::upgradeable::UpgradeableComponent; use token_bound_accounts::test_helper::{ - hello_starknet::{IHelloStarknetDispatcher, IHelloStarknetDispatcherTrait, HelloStarknet}, - simple_account::{ISimpleAccountDispatcher, ISimpleAccountDispatcherTrait, SimpleAccount}, - account_upgrade::{IUpgradedAccountDispatcher, IUpgradedAccountDispatcherTrait, UpgradedAccount}, - erc721_helper::ERC721 + account_upgrade::{IUpgradedAccountDispatcher, IUpgradedAccountDispatcherTrait} }; const ACCOUNT: felt252 = 1234; @@ -33,14 +24,14 @@ const ACCOUNT2: felt252 = 5729; // ************************************************************************* fn __setup__() -> (ContractAddress, ContractAddress) { // deploy erc721 helper contract - let erc721_contract = declare("ERC721").unwrap(); + let erc721_contract = declare("ERC721").unwrap().contract_class(); let mut erc721_constructor_calldata = array!['tokenbound', 'TBA']; let (erc721_contract_address, _) = erc721_contract .deploy(@erc721_constructor_calldata) .unwrap(); // deploy recipient contract - let account_contract = declare("SimpleAccount").unwrap(); + let account_contract = declare("SimpleAccount").unwrap().contract_class(); let (recipient, _) = account_contract .deploy( @array![883045738439352841478194533192765345509759306772397516907181243450667673002] @@ -52,17 +43,17 @@ fn __setup__() -> (ContractAddress, ContractAddress) { dispatcher.mint(recipient, 1.try_into().unwrap()); // deploy registry contract - let registry_contract = declare("Registry").unwrap(); + let registry_contract = declare("Registry").unwrap().contract_class(); let (registry_contract_address, _) = registry_contract.deploy(@array![]).unwrap(); // deploy account contract - let account_contract = declare("AccountPreset").unwrap(); + let account_contract = declare("AccountPreset").unwrap().contract_class(); let mut acct_constructor_calldata = array![ erc721_contract_address.try_into().unwrap(), 1, 0, registry_contract_address.try_into().unwrap(), - account_contract.class_hash.into(), + (*account_contract.class_hash).into(), 20 ]; let (account_contract_address, _) = account_contract @@ -78,7 +69,8 @@ fn __setup__() -> (ContractAddress, ContractAddress) { #[test] fn test_upgrade() { let (contract_address, erc721_contract_address) = __setup__(); - let new_class_hash = declare("UpgradedAccount").unwrap().class_hash; + let upgraded_account_class = declare("UpgradedAccount").unwrap().contract_class(); + let new_class_hash = *upgraded_account_class.class_hash; // get token owner let token_dispatcher = IERC721Dispatcher { contract_address: erc721_contract_address }; @@ -100,7 +92,8 @@ fn test_upgrade() { #[should_panic(expected: ('Account: unauthorized',))] fn test_upgrade_with_unauthorized() { let (contract_address, _) = __setup__(); - let new_class_hash = declare("UpgradedAccount").unwrap().class_hash; + let upgraded_account_class = declare("UpgradedAccount").unwrap().contract_class(); + let new_class_hash = *upgraded_account_class.class_hash; // call upgrade function with an unauthorized address start_cheat_caller_address(contract_address, ACCOUNT2.try_into().unwrap()); @@ -111,7 +104,8 @@ fn test_upgrade_with_unauthorized() { #[test] fn test_upgrade_emits_event() { let (contract_address, erc721_contract_address) = __setup__(); - let new_class_hash = declare("UpgradedAccount").unwrap().class_hash; + let upgraded_account_class = declare("UpgradedAccount").unwrap().contract_class(); + let new_class_hash = *upgraded_account_class.class_hash; // get token owner let token_dispatcher = IERC721Dispatcher { contract_address: erc721_contract_address };