1#![no_std]
4
5pub mod asm;
6mod event;
7pub mod num;
8pub mod primitives;
9pub mod storage;
10pub use self::{event::Event, num::Numeric, storage::Value};
11pub use storage::{DoubleKeyMapping, Mapping, Storage, TransientStorage};
12pub use zink_codegen::{assert, external, revert, storage, transient_storage, Event, Storage};
13
14#[cfg(feature = "abi-import")]
15pub use zabi_codegen::import;
16
17#[cfg(not(target_family = "wasm"))]
18extern crate alloc;
19
20#[cfg(not(target_family = "wasm"))]
22pub fn keccak256(input: &[u8]) -> [u8; 32] {
23 use tiny_keccak::{Hasher, Keccak};
24 let mut hasher = Keccak::v256();
25 let mut output = [0; 32];
26 hasher.update(input);
27 hasher.finalize(&mut output);
28 output
29}
30
31#[cfg(not(target_family = "wasm"))]
33pub fn to_bytes32(src: &[u8]) -> [u8; 32] {
34 use alloc::vec::Vec;
35 let mut bytes = [0u8; 32];
36 let ls_bytes = {
37 src.iter()
38 .cloned()
39 .rev()
40 .skip_while(|b| *b == 0)
41 .collect::<Vec<_>>()
42 .into_iter()
43 .rev()
44 .collect::<Vec<_>>()
45 };
46
47 bytes[(32 - ls_bytes.len())..].copy_from_slice(&ls_bytes);
48 bytes
49}
50
51#[cfg(target_arch = "wasm32")]
53#[panic_handler]
54fn panic(_info: &core::panic::PanicInfo) -> ! {
55 loop {}
56}