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

fix: update dependencies, add storage_read & fix tests #2

Merged
merged 2 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 4 additions & 5 deletions Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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"]
4 changes: 2 additions & 2 deletions scripts/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions src/resolver.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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<ContractState>;

#[storage]
struct Storage {
public_key: felt252,
uri: LegacyMap<felt252, felt252>,
#[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<felt252>) {
self.public_key.write(_public_key);
Expand Down
2 changes: 1 addition & 1 deletion src/tests.cairo
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
mod utils;
mod resolver;
mod resolver;
1 change: 1 addition & 0 deletions src/tests/resolver.cairo
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
mod test_resolver;
mod test_hash;
mod erc20;
32 changes: 32 additions & 0 deletions src/tests/resolver/erc20.cairo
Original file line number Diff line number Diff line change
@@ -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<ContractState>;
#[abi(embed_v0)]
impl ERC20CamelOnlyImpl = ERC20Component::ERC20CamelOnlyImpl<ContractState>;

#[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,
}
}
12 changes: 6 additions & 6 deletions src/tests/resolver/test_resolver.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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}
};
Expand All @@ -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]
);
Expand Down
Loading