Skip to content

Commit

Permalink
fix: use camelCase interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Th0rgal committed Oct 4, 2023
1 parent cb6976b commit 97bb938
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 256 deletions.
15 changes: 9 additions & 6 deletions src/naming/main.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ mod Naming {
use clone::Clone;
use array::ArrayTCloneImpl;
use identity::interface::identity::{IIdentity, IIdentityDispatcher, IIdentityDispatcherTrait};
use openzeppelin::token::erc20::interface::{IERC20, IERC20Dispatcher, IERC20DispatcherTrait};
use openzeppelin::token::erc20::interface::{
IERC20Camel, IERC20CamelDispatcher, IERC20CamelDispatcherTrait
};
use debug::PrintTrait;

#[event]
Expand Down Expand Up @@ -367,9 +369,10 @@ mod Naming {

fn claim_balance(ref self: ContractState, erc20: ContractAddress) {
assert(get_caller_address() == self._admin_address.read(), 'you are not admin');
let balance = IERC20Dispatcher { contract_address: erc20 }
.balance_of(get_contract_address());
IERC20Dispatcher { contract_address: erc20 }.transfer(get_caller_address(), balance);
let balance = IERC20CamelDispatcher { contract_address: erc20 }
.balanceOf(get_contract_address());
IERC20CamelDispatcher { contract_address: erc20 }
.transfer(get_caller_address(), balance);
}

fn set_discount(ref self: ContractState, discount_id: felt252, discount: Discount) {
Expand Down Expand Up @@ -558,8 +561,8 @@ mod Naming {
};

// pay the price
IERC20Dispatcher { contract_address: erc20 }
.transfer_from(get_caller_address(), get_contract_address(), discounted_price);
IERC20CamelDispatcher { contract_address: erc20 }
.transferFrom(get_caller_address(), get_contract_address(), discounted_price);
// add sponsor commission if eligible
if sponsor.into() != 0 {
IReferralDispatcher { contract_address: self._referral_contract.read() }
Expand Down
1 change: 0 additions & 1 deletion src/tests.cairo
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
mod erc20;
mod utils;
mod test_pricing;
mod naming;
232 changes: 0 additions & 232 deletions src/tests/erc20.cairo

This file was deleted.

13 changes: 8 additions & 5 deletions src/tests/naming/common.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@ use starknet::contract_address::ContractAddressZeroable;
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::{identity::main::Identity, interface::identity::{IIdentityDispatcher, IIdentityDispatcherTrait}};
use openzeppelin::token::erc20::{
erc20::ERC20, interface::{IERC20Camel, IERC20CamelDispatcher, IERC20CamelDispatcherTrait}
};
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::erc20::ERC20;

fn deploy() -> (IERC20Dispatcher, IPricingDispatcher, IIdentityDispatcher, INamingDispatcher) {
fn deploy() -> (IERC20CamelDispatcher, IPricingDispatcher, IIdentityDispatcher, INamingDispatcher) {
//erc20
let mut calldata = ArrayTrait::<felt252>::new();
// 0, 1 = low and high of ETH supply
Expand All @@ -36,7 +39,7 @@ fn deploy() -> (IERC20Dispatcher, IPricingDispatcher, IIdentityDispatcher, INami
Naming::TEST_CLASS_HASH, array![identity.into(), pricing.into(), 0, admin]
);
(
IERC20Dispatcher { contract_address: eth },
IERC20CamelDispatcher { contract_address: eth },
IPricingDispatcher { contract_address: pricing },
IIdentityDispatcher { contract_address: identity },
INamingDispatcher { contract_address: address }
Expand Down
9 changes: 6 additions & 3 deletions src/tests/naming/test_abuses.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ use starknet::contract_address::ContractAddressZeroable;
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::{identity::main::Identity, interface::identity::{IIdentityDispatcher, IIdentityDispatcherTrait}};
use openzeppelin::token::erc20::{
erc20::ERC20, interface::{IERC20Camel, IERC20CamelDispatcher, IERC20CamelDispatcherTrait}
};
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::erc20::ERC20;
use super::common::deploy;


Expand Down
15 changes: 9 additions & 6 deletions src/tests/naming/test_features.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ use starknet::contract_address::ContractAddressZeroable;
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::{identity::main::Identity, interface::identity::{IIdentityDispatcher, IIdentityDispatcherTrait}};
use openzeppelin::token::erc20::{
erc20::ERC20, interface::{IERC20Camel, IERC20CamelDispatcher, IERC20CamelDispatcherTrait}
};
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::erc20::ERC20;
use super::common::deploy;


Expand Down Expand Up @@ -104,11 +107,11 @@ fn test_claim_balance() {
id, th0rgal, 365, ContractAddressZeroable::zero(), ContractAddressZeroable::zero(), 0, 0
);

let contract_bal = eth.balance_of(naming.contract_address);
let admin_balance = eth.balance_of(caller);
let contract_bal = eth.balanceOf(naming.contract_address);
let admin_balance = eth.balanceOf(caller);
assert(contract_bal == price, 'naming has wrong balance');
naming.claim_balance(eth.contract_address);
assert(admin_balance + price == eth.balance_of(caller), 'balance didn\'t increase');
assert(admin_balance + price == eth.balanceOf(caller), 'balance didn\'t increase');
}


Expand Down
9 changes: 6 additions & 3 deletions src/tests/naming/test_usecases.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ use starknet::contract_address::ContractAddressZeroable;
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::{identity::main::Identity, interface::identity::{IIdentityDispatcher, IIdentityDispatcherTrait}};
use openzeppelin::token::erc20::{
erc20::ERC20, interface::{IERC20Camel, IERC20CamelDispatcher, IERC20CamelDispatcherTrait}
};
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::erc20::ERC20;
use super::common::deploy;
use naming::naming::main::Naming::Discount;

Expand Down

0 comments on commit 97bb938

Please sign in to comment.