From e9beea6878ff309dc57922d5fa7b5a6574a0b4de Mon Sep 17 00:00:00 2001 From: Thomas Marchand Date: Sat, 30 Sep 2023 16:09:54 +0700 Subject: [PATCH] update: identity dependency --- src/tests.cairo | 1 - src/tests/identity.cairo | 104 --------------------------- src/tests/naming/common.cairo | 3 +- src/tests/naming/test_abuses.cairo | 3 +- src/tests/naming/test_features.cairo | 3 +- src/tests/naming/test_usecases.cairo | 3 +- 6 files changed, 4 insertions(+), 113 deletions(-) delete mode 100644 src/tests/identity.cairo diff --git a/src/tests.cairo b/src/tests.cairo index d75c611..07c6c70 100644 --- a/src/tests.cairo +++ b/src/tests.cairo @@ -1,5 +1,4 @@ mod erc20; -mod identity; mod utils; mod test_pricing; mod naming; diff --git a/src/tests/identity.cairo b/src/tests/identity.cairo deleted file mode 100644 index c822bd4..0000000 --- a/src/tests/identity.cairo +++ /dev/null @@ -1,104 +0,0 @@ -use core::array::SpanTrait; -#[starknet::contract] -mod Identity { - use starknet::ContractAddress; - use starknet::contract_address::ContractAddressZeroable; - use starknet::{get_caller_address, get_contract_address}; - use traits::Into; - use array::{ArrayTrait, SpanTrait}; - use zeroable::Zeroable; - use starknet::class_hash::ClassHash; - use identity::interface::identity::{IIdentity, IIdentityDispatcher, IIdentityDispatcherTrait}; - use integer::{u256_safe_divmod, u256_as_non_zero}; - use core::pedersen; - use debug::PrintTrait; - - - #[storage] - struct Storage { - owner_by_id: LegacyMap, - user_data: LegacyMap<(u128, felt252), felt252>, - verifier_data: LegacyMap<(u128, felt252, ContractAddress), felt252>, - main_id_by_addr: LegacyMap, - } - - #[constructor] - fn constructor(ref self: ContractState) {} - - #[external(v0)] - impl IdentityImpl of IIdentity { - fn owner_of(self: @ContractState, id: u128) -> ContractAddress { - // todo: when components are ready, use ERC721 - self.owner_by_id.read(id) - } - - fn get_main_id(self: @ContractState, user: ContractAddress) -> u128 { - self.main_id_by_addr.read(user) - } - - fn get_user_data( - self: @ContractState, id: u128, field: felt252, domain: felt252 - ) -> felt252 { - // todo: when volition comes, check on the specified domain - self.user_data.read((id, field)) - } - - fn get_crosschecked_user_data(self: @ContractState, id: u128, field: felt252) -> felt252 { - // todo: when volition comes, check on domain 0, if empty, check on volition - self.user_data.read((id, field)) - } - - - fn get_verifier_data( - self: @ContractState, - id: u128, - field: felt252, - verifier: ContractAddress, - domain: felt252 - ) -> felt252 { - // todo: when volition comes, check on the specified domain - self.verifier_data.read((id, field, verifier)) - } - - - fn get_crosschecked_verifier_data( - self: @ContractState, id: u128, field: felt252, verifier: ContractAddress - ) -> felt252 { - // todo: when volition comes, check on domain 0, if empty, check on volition - self.verifier_data.read((id, field, verifier)) - } - - fn mint(ref self: ContractState, id: u128) { - // todo: when components are ready, use ERC721 - if self.owner_by_id.read(id).into() == 0 { - self.owner_by_id.write(id, get_caller_address()); - } - } - - fn set_main_id(ref self: ContractState, id: u128) { - // todo: add event - let caller = get_caller_address(); - assert(caller == self.owner_by_id.read(id), 'you don\'t own this id'); - self.main_id_by_addr.write(caller, id); - } - - fn reset_main_id(ref self: ContractState) { - // todo: add event - self.main_id_by_addr.write(get_caller_address(), 0); - } - - fn set_user_data( - ref self: ContractState, id: u128, field: felt252, data: felt252, domain: felt252 - ) { - // todo: when volition comes, handle the domain - self.user_data.write((id, field), data); - } - - fn set_verifier_data( - ref self: ContractState, id: u128, field: felt252, data: felt252, domain: felt252 - ) { - // todo: when volition comes, handle the domain - self.verifier_data.write((id, field, get_caller_address()), data); - } - } -} diff --git a/src/tests/naming/common.cairo b/src/tests/naming/common.cairo index 6b6ddc8..476f310 100644 --- a/src/tests/naming/common.cairo +++ b/src/tests/naming/common.cairo @@ -11,12 +11,11 @@ use starknet::contract_address_const; use starknet::testing::set_contract_address; use super::super::utils; use openzeppelin::token::erc20::interface::{IERC20, IERC20Dispatcher, IERC20DispatcherTrait}; -use identity::interface::identity::{IIdentityDispatcher, IIdentityDispatcherTrait}; +use identity::{identity::main::Identity, interface::identity::{IIdentityDispatcher, IIdentityDispatcherTrait}}; use naming::interface::naming::{INamingDispatcher, INamingDispatcherTrait}; use naming::interface::pricing::{IPricingDispatcher, IPricingDispatcherTrait}; use naming::naming::main::Naming; use naming::pricing::Pricing; -use super::super::identity::Identity; use super::super::erc20::ERC20; fn deploy() -> (IERC20Dispatcher, IPricingDispatcher, IIdentityDispatcher, INamingDispatcher) { diff --git a/src/tests/naming/test_abuses.cairo b/src/tests/naming/test_abuses.cairo index aa0f88e..705f2fe 100644 --- a/src/tests/naming/test_abuses.cairo +++ b/src/tests/naming/test_abuses.cairo @@ -11,12 +11,11 @@ use starknet::contract_address_const; use starknet::testing::set_contract_address; use super::super::utils; use openzeppelin::token::erc20::interface::{IERC20, IERC20Dispatcher, IERC20DispatcherTrait}; -use identity::interface::identity::{IIdentityDispatcher, IIdentityDispatcherTrait}; +use identity::{identity::main::Identity, interface::identity::{IIdentityDispatcher, IIdentityDispatcherTrait}}; use naming::interface::naming::{INamingDispatcher, INamingDispatcherTrait}; use naming::interface::pricing::{IPricingDispatcher, IPricingDispatcherTrait}; use naming::naming::main::Naming; use naming::pricing::Pricing; -use super::super::identity::Identity; use super::super::erc20::ERC20; use super::common::deploy; diff --git a/src/tests/naming/test_features.cairo b/src/tests/naming/test_features.cairo index 7868fa6..fb956cb 100644 --- a/src/tests/naming/test_features.cairo +++ b/src/tests/naming/test_features.cairo @@ -11,12 +11,11 @@ use starknet::contract_address_const; use starknet::testing::set_contract_address; use super::super::utils; use openzeppelin::token::erc20::interface::{IERC20, IERC20Dispatcher, IERC20DispatcherTrait}; -use identity::interface::identity::{IIdentityDispatcher, IIdentityDispatcherTrait}; +use identity::{identity::main::Identity, interface::identity::{IIdentityDispatcher, IIdentityDispatcherTrait}}; use naming::interface::naming::{INamingDispatcher, INamingDispatcherTrait}; use naming::interface::pricing::{IPricingDispatcher, IPricingDispatcherTrait}; use naming::naming::main::Naming; use naming::pricing::Pricing; -use super::super::identity::Identity; use super::super::erc20::ERC20; use super::common::deploy; diff --git a/src/tests/naming/test_usecases.cairo b/src/tests/naming/test_usecases.cairo index ca37f76..8900203 100644 --- a/src/tests/naming/test_usecases.cairo +++ b/src/tests/naming/test_usecases.cairo @@ -11,12 +11,11 @@ use starknet::contract_address_const; use starknet::testing::set_contract_address; use super::super::utils; use openzeppelin::token::erc20::interface::{IERC20, IERC20Dispatcher, IERC20DispatcherTrait}; -use identity::interface::identity::{IIdentityDispatcher, IIdentityDispatcherTrait}; +use identity::{identity::main::Identity, interface::identity::{IIdentityDispatcher, IIdentityDispatcherTrait}}; use naming::interface::naming::{INamingDispatcher, INamingDispatcherTrait}; use naming::interface::pricing::{IPricingDispatcher, IPricingDispatcherTrait}; use naming::naming::main::Naming; use naming::pricing::Pricing; -use super::super::identity::Identity; use super::super::erc20::ERC20; use super::common::deploy; use naming::naming::main::Naming::Discount;