Skip to content

Commit

Permalink
feat: update identity compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Th0rgal committed Nov 16, 2023
1 parent 4180308 commit 14b137b
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 15 deletions.
6 changes: 3 additions & 3 deletions Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ version = "0.1.0"

[dependencies]
starknet = "2.3.1"
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" }
storage_read = { git = "https://github.com/starknet-id/storage_read_component", rev = "c6c69e15d34abfc39ac51dc21b96724e2e19ff31" }
openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", rev = "f3e2a5f0547a429c716f32471b06df729cbdfb9f" }
storage_read = { git = "https://github.com/starknet-id/storage_read_component.git", rev = "c6c69e15d34abfc39ac51dc21b96724e2e19ff31" }
identity = { git = "https://github.com/starknet-id/identity.git", rev = "eb37846330b78e1410cf5e3e17a5dcca5652f921" }

[[target.starknet-contract]]
# Enable Sierra codegen.
Expand Down
2 changes: 1 addition & 1 deletion src/naming/asserts.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl AssertionsImpl of AssertionsTrait {
ContractAddressZeroable::zero()
} else {
IIdentityDispatcher { contract_address: self.starknetid_contract.read() }
.owner_of(data.owner)
.owner_from_id(data.owner)
};

// if caller owns the starknet id, he owns the domain, we return the key
Expand Down
2 changes: 1 addition & 1 deletion src/naming/main.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ mod Naming {
return data.address;
};
IIdentityDispatcher { contract_address: self.starknetid_contract.read() }
.owner_of(self.domain_to_id(domain))
.owner_from_id(self.domain_to_id(domain))
}

// This returns the stored DomainData associated to this domain
Expand Down
42 changes: 39 additions & 3 deletions src/tests/naming/common.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use starknet::contract_address_const;
use starknet::testing::set_contract_address;
use super::super::utils;
use openzeppelin::token::erc20::{
erc20::ERC20, interface::{IERC20Camel, IERC20CamelDispatcher, IERC20CamelDispatcherTrait}
interface::{IERC20Camel, IERC20CamelDispatcher, IERC20CamelDispatcherTrait}
};
use identity::{
identity::main::Identity, interface::identity::{IIdentityDispatcher, IIdentityDispatcherTrait}
Expand All @@ -21,22 +21,58 @@ use naming::interface::pricing::{IPricingDispatcher, IPricingDispatcherTrait};
use naming::naming::main::Naming;
use naming::pricing::Pricing;


#[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,
}
}


fn deploy() -> (IERC20CamelDispatcher, IPricingDispatcher, IIdentityDispatcher, INamingDispatcher) {
//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![0x123, 0]);

// naming
let admin = 0x123;
let address = utils::deploy(
Naming::TEST_CLASS_HASH, array![identity.into(), pricing.into(), 0, admin]
);

(
IERC20CamelDispatcher { contract_address: eth },
IPricingDispatcher { contract_address: pricing },
Expand Down
2 changes: 1 addition & 1 deletion src/tests/naming/test_abuses.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use starknet::contract_address_const;
use starknet::testing::set_contract_address;
use super::super::utils;
use openzeppelin::token::erc20::{
erc20::ERC20, interface::{IERC20Camel, IERC20CamelDispatcher, IERC20CamelDispatcherTrait}
interface::{IERC20Camel, IERC20CamelDispatcher, IERC20CamelDispatcherTrait}
};
use identity::{
identity::main::Identity, interface::identity::{IIdentityDispatcher, IIdentityDispatcherTrait}
Expand Down
3 changes: 1 addition & 2 deletions src/tests/naming/test_custom_resolver.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use starknet::contract_address_const;
use starknet::testing::set_contract_address;
use super::super::utils;
use openzeppelin::token::erc20::{
erc20::ERC20, interface::{IERC20Camel, IERC20CamelDispatcher, IERC20CamelDispatcherTrait}
interface::{IERC20Camel, IERC20CamelDispatcher, IERC20CamelDispatcherTrait}
};
use identity::{
identity::main::Identity, interface::identity::{IIdentityDispatcher, IIdentityDispatcherTrait}
Expand Down Expand Up @@ -46,7 +46,6 @@ mod CustomResolver {
Option::None => { break; }
}
};
output.print();
output
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/tests/naming/test_features.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ use starknet::ContractAddress;
use starknet::contract_address::ContractAddressZeroable;
use starknet::contract_address_const;
use starknet::testing::set_contract_address;
use openzeppelin::token::erc20::{
erc20::ERC20, interface::{IERC20Camel, IERC20CamelDispatcher, IERC20CamelDispatcherTrait}
};
use identity::{
identity::main::Identity, interface::identity::{IIdentityDispatcher, IIdentityDispatcherTrait}
};
use openzeppelin::token::erc20::{
interface::{IERC20Camel, IERC20CamelDispatcher, IERC20CamelDispatcherTrait}
};
use naming::interface::naming::{INamingDispatcher, INamingDispatcherTrait};
use naming::interface::pricing::{IPricingDispatcher, IPricingDispatcherTrait};
use naming::naming::main::Naming;
Expand Down
2 changes: 1 addition & 1 deletion src/tests/naming/test_usecases.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use starknet::contract_address_const;
use starknet::testing::set_contract_address;
use super::super::utils;
use openzeppelin::token::erc20::{
erc20::ERC20, interface::{IERC20Camel, IERC20CamelDispatcher, IERC20CamelDispatcherTrait}
interface::{IERC20Camel, IERC20CamelDispatcher, IERC20CamelDispatcherTrait}
};
use identity::{
identity::main::Identity, interface::identity::{IIdentityDispatcher, IIdentityDispatcherTrait}
Expand Down

0 comments on commit 14b137b

Please sign in to comment.