Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
virgil-serbanuta committed Nov 8, 2024
1 parent 1092bf4 commit 966945f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/ulm-contracts/erc_20_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ pub trait Erc20Token {
#[storage_mapper("balances")]
fn s_allowances(&self, account: u160, spender: u160) -> ::single_value_mapper::SingleValueMapper<u256>;

#[event("Transfer")]
fn transfer_event(&self, #[indexed] from: u160, #[indexed] to: u160, value: u256);

#[event("Approval")]
fn approval_event(&self, #[indexed] owner: u160, #[indexed] spender: u160, value: u256);

#[init]
fn init(&self) {}

Expand Down Expand Up @@ -76,6 +82,7 @@ pub trait Erc20Token {
::helpers::require(!::address::is_zero(from), "Invalid sender");
::helpers::require(!::address::is_zero(to), "Invalid receiver");
self._update(from, to, value);
self.transfer_event(from, to, value);
}

fn _update(&self, from: u160, to: u160, value: u256) {
Expand Down Expand Up @@ -104,6 +111,9 @@ pub trait Erc20Token {
::helpers::require(!::address::is_zero(owner), "Invalid approver");
::helpers::require(!::address::is_zero(spender), "Invalid spender");
self.s_allowances(owner, spender).set(value);
if emit_event {
self.approval_event(owner, spender, value);
}
}

fn _spend_allowance(&self, owner: u160, spender: u160, value: u256) {
Expand Down

0 comments on commit 966945f

Please sign in to comment.