diff --git a/Scarb.toml b/Scarb.toml index 9d8edc2..b7fa650 100644 --- a/Scarb.toml +++ b/Scarb.toml @@ -4,9 +4,10 @@ version = "0.1.0" [dependencies] starknet = "2.3.1" -naming = { git = "https://github.com/starknet-id/naming.git", branch = "feat/add_ccip" } -openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", tag = "v0.8.0-beta.0" } -identity = { git = "https://github.com/starknet-id/identity.git", rev = "2e8fecab0d9a971710e8efb21abc25fb7825ee09" } +naming = { git = "https://github.com/starknet-id/naming.git", rev = "6e45f7fc2bc9e8e9d874a1d2c2d46e3226a96f6d" } +openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", rev = "f3e2a5f0547a429c716f32471b06df729cbdfb9f" } +identity = { git = "https://github.com/starknet-id/identity.git", rev = "eb37846330b78e1410cf5e3e17a5dcca5652f921" } +storage_read = { git = "https://github.com/starknet-id/storage_read_component.git", rev = "c6c69e15d34abfc39ac51dc21b96724e2e19ff31" } [[target.starknet-contract]] # Enable Sierra codegen. @@ -17,5 +18,3 @@ casm = true # Emit Python-powered hints in order to run compiled CASM class with legacy Cairo VM. casm-add-pythonic-hints = true - -# build-external-contracts = ["identity::identity::main::Identity"] diff --git a/scripts/deploy.py b/scripts/deploy.py index 7cc7e91..b0c228a 100644 --- a/scripts/deploy.py +++ b/scripts/deploy.py @@ -34,8 +34,8 @@ async def main(): deployments = {} deployments["resolver_Resolver"] = await deploy_v2( "resolver_Resolver", - # public key, - [184555836509371486644303486690696490826338471053535799928930015955655750516, 1797578980074678282596] # external uri + 0x44f3346a082fe41ed51255efc0de47ad171b95e856f07170dd7c44c174ec1fa, + [184555836509371486644303486690696490826338471053535799928930015955655750516, 1797578980074678282596] ) # https://goerli.api.ccip-demo.st # arknet.id diff --git a/src/resolver.cairo b/src/resolver.cairo index 485094c..261dbfe 100644 --- a/src/resolver.cairo +++ b/src/resolver.cairo @@ -6,13 +6,29 @@ mod Resolver { use starknet::{ContractAddress, get_block_timestamp}; use ecdsa::check_ecdsa_signature; use resolver::interface::resolver::{IResolver, IResolverDispatcher, IResolverDispatcherTrait}; + use storage_read::{main::storage_read_component, interface::IStorageRead}; + + component!(path: storage_read_component, storage: storage_read, event: StorageReadEvent); + + #[abi(embed_v0)] + impl StorageReadImpl = storage_read_component::StorageRead; #[storage] struct Storage { public_key: felt252, uri: LegacyMap, + #[substorage(v0)] + storage_read: storage_read_component::Storage, } + #[event] + #[derive(Drop, starknet::Event)] + enum Event { + #[flat] + StorageReadEvent: storage_read_component::Event, + } + + #[constructor] fn constructor(ref self: ContractState, _public_key: felt252, uri: Span) { self.public_key.write(_public_key); diff --git a/src/tests.cairo b/src/tests.cairo index 115c495..95a1975 100644 --- a/src/tests.cairo +++ b/src/tests.cairo @@ -1,2 +1,2 @@ mod utils; -mod resolver; +mod resolver; \ No newline at end of file diff --git a/src/tests/resolver.cairo b/src/tests/resolver.cairo index 3afe80a..6022a6b 100644 --- a/src/tests/resolver.cairo +++ b/src/tests/resolver.cairo @@ -1,2 +1,3 @@ mod test_resolver; mod test_hash; +mod erc20; diff --git a/src/tests/resolver/erc20.cairo b/src/tests/resolver/erc20.cairo new file mode 100644 index 0000000..b22cdba --- /dev/null +++ b/src/tests/resolver/erc20.cairo @@ -0,0 +1,32 @@ +#[starknet::contract] +mod ERC20 { + use openzeppelin::token::erc20::erc20::ERC20Component::InternalTrait; + use openzeppelin::{token::erc20::{ERC20Component, dual20::DualCaseERC20Impl}}; + + component!(path: ERC20Component, storage: erc20, event: ERC20Event); + + #[abi(embed_v0)] + impl ERC20Impl = ERC20Component::ERC20Impl; + #[abi(embed_v0)] + impl ERC20CamelOnlyImpl = ERC20Component::ERC20CamelOnlyImpl; + + #[constructor] + fn constructor(ref self: ContractState) { + self.erc20.initializer('ether', 'ETH'); + let target = starknet::contract_address_const::<0x123>(); + self.erc20._mint(target, 0x100000000000000000000000000000000); + } + + #[storage] + struct Storage { + #[substorage(v0)] + erc20: ERC20Component::Storage, + } + + #[event] + #[derive(Drop, starknet::Event)] + enum Event { + #[flat] + ERC20Event: ERC20Component::Event, + } +} \ No newline at end of file diff --git a/src/tests/resolver/test_resolver.cairo b/src/tests/resolver/test_resolver.cairo index 170f0cb..5b904ce 100644 --- a/src/tests/resolver/test_resolver.cairo +++ b/src/tests/resolver/test_resolver.cairo @@ -10,9 +10,10 @@ use starknet::contract_address_const; use starknet::testing::{set_contract_address, set_block_timestamp}; use super::super::utils; -use openzeppelin::token::erc20::{ - erc20::ERC20, interface::{IERC20Camel, IERC20CamelDispatcher, IERC20CamelDispatcherTrait} +use openzeppelin::token::erc20::{ + interface::{IERC20Camel, IERC20CamelDispatcher, IERC20CamelDispatcherTrait} }; +use super::erc20::ERC20; use identity::{ identity::main::Identity, interface::identity::{IIdentityDispatcher, IIdentityDispatcherTrait} }; @@ -30,18 +31,17 @@ fn deploy() -> ( INamingDispatcher, IResolverDispatcher ) { + let admin = 0x123; //erc20 - // 0, 1 = low and high of ETH supply - let eth = utils::deploy(ERC20::TEST_CLASS_HASH, array!['ether', 'ETH', 0, 1, 0x123]); + let eth = utils::deploy(ERC20::TEST_CLASS_HASH, array![]); // pricing let pricing = utils::deploy(Pricing::TEST_CLASS_HASH, array![eth.into()]); // identity - let identity = utils::deploy(Identity::TEST_CLASS_HASH, array![0]); + let identity = utils::deploy(Identity::TEST_CLASS_HASH, array![admin, 0]); // naming - let admin = 0x123; let address = utils::deploy( Naming::TEST_CLASS_HASH, array![identity.into(), pricing.into(), 0, admin] );