Skip to content

Commit

Permalink
implements camel case interface (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZackAttax authored Dec 2, 2024
1 parent 4669f56 commit 7a2af81
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion contracts/src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub mod oz16 {
mod interfaces;
pub use interfaces::{
IERC20, IERC20Dispatcher, IERC20DispatcherTrait, IOwnable, IOwnableDispatcher,
IOwnableDispatcherTrait, IERC20ReadOnly
IOwnableDispatcherTrait, IERC20ReadOnly, IERC20CamelOnly
};
}

Expand Down
15 changes: 15 additions & 0 deletions contracts/src/oz16/erc20.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub mod ERC20Component {
use core::num::traits::Bounded;
use core::num::traits::Zero;
use kudos::oz16::IERC20;
use kudos::oz16::IERC20CamelOnly;
use starknet::ContractAddress;
use starknet::get_caller_address;
use starknet::storage::{
Expand Down Expand Up @@ -177,6 +178,20 @@ pub mod ERC20Component {
}
}

/// Adds camelCase support for `IERC20`.
#[embeddable_as(ERC20CamelOnlyImpl)]
impl ERC20CamelOnly<
TContractState, +HasComponent<TContractState>, +ERC20HooksTrait<TContractState>
> of IERC20CamelOnly<ComponentState<TContractState>> {
fn totalSupply(self: @ComponentState<TContractState>) -> u256 {
ERC20::total_supply(self)
}

fn balanceOf(self: @ComponentState<TContractState>, account: ContractAddress) -> u256 {
ERC20::balance_of(self, account)
}
}

//
// Internal
//
Expand Down
6 changes: 6 additions & 0 deletions contracts/src/oz16/interfaces.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ pub trait IERC20ReadOnly<TState> {
fn balance_of(self: @TState, account: ContractAddress) -> u256;
}

#[starknet::interface]
pub trait IERC20CamelOnly<TState> {
fn totalSupply(self: @TState) -> u256;
fn balanceOf(self: @TState, account: ContractAddress) -> u256;
}

#[starknet::interface]
pub trait IOwnable<TState> {
fn owner(self: @TState) -> ContractAddress;
Expand Down

0 comments on commit 7a2af81

Please sign in to comment.