Skip to content

Commit

Permalink
fix(token): enable erc20 mod on tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfertel committed Mar 20, 2024
1 parent 866fe3f commit 5f7653a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
4 changes: 2 additions & 2 deletions contracts/token/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "token"
categories = ["cryptography", "algorithms", "no-std", "wasm"]
description = "Cryptography Utilities"
categories = ["no-std", "wasm"]
description = "Token Standards for Stylus"
edition.workspace = true
keywords.workspace = true
license.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion contracts/token/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ extern crate alloc;
#[global_allocator]
static ALLOC: mini_alloc::MiniAlloc = mini_alloc::MiniAlloc::INIT;

#[cfg(erc20)]
#[cfg(any(test, erc20))]
pub mod erc20;

#[cfg(not(any(test, target_arch = "wasm32-unknown-unknown")))]
Expand Down
15 changes: 15 additions & 0 deletions lib/wavm-shims/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@ use tiny_keccak::{Hasher, Keccak};
pub const WORD_BYTES: usize = 32;
pub type Bytes32 = [u8; WORD_BYTES];

#[no_mangle]
pub extern "C" fn native_keccak256(
bytes: *const u8,
len: usize,
output: *mut u8,
) {
let mut hasher = Keccak::v256();

let data = unsafe { slice::from_raw_parts(bytes, len) };
hasher.update(data);

let output = unsafe { slice::from_raw_parts_mut(output, WORD_BYTES) };
hasher.finalize(output);
}

pub static STORAGE: Lazy<Mutex<HashMap<Bytes32, Bytes32>>> =
Lazy::new(|| Mutex::new(HashMap::new()));

Expand Down

0 comments on commit 5f7653a

Please sign in to comment.