diff --git a/examples/mapping.rs b/examples/mapping.rs deleted file mode 100644 index b578e9830..000000000 --- a/examples/mapping.rs +++ /dev/null @@ -1,3 +0,0 @@ -//! Mapping example. -#![cfg_attr(target_arch = "wasm32", no_std)] -#![cfg_attr(target_arch = "wasm32", no_main)] diff --git a/zink/src/ffi.rs b/zink/src/ffi.rs deleted file mode 100644 index 7bd4364ca..000000000 --- a/zink/src/ffi.rs +++ /dev/null @@ -1,48 +0,0 @@ -//! Zink FFI. - -#[link(wasm_import_module = "zinkc")] -#[allow(improper_ctypes)] -extern "C" { - /// Emit ABI to host state. - pub fn emit_abi(ptr: u32, len: u32); - -} - -/// EVM interfaces. -pub mod evm { - #[link(wasm_import_module = "evm")] - #[allow(improper_ctypes)] - extern "C" { - /// Store a value in the storage - pub fn sstore(value: i32, key: i32); - - /// Load a value from the storage - pub fn sload(key: i32) -> i32; - - /// Append log record with no topics - pub fn log0(name: &'static [u8]); - - /// Append log record with one topics - pub fn log1(name: &'static [u8], topic1: &'static [u8]); - - /// Append log record with two topics - pub fn log2(name: &'static [u8], topic1: &'static [u8], topic2: &'static [u8]); - - /// Append log record with three topics - pub fn log3( - name: &'static [u8], - topic1: &'static [u8], - topic2: &'static [u8], - topic3: &'static [u8], - ); - - /// Append log record with four topics - pub fn log4( - name: &'static [u8], - topic1: &'static [u8], - topic2: &'static [u8], - topic3: &'static [u8], - topic4: &'static [u8], - ); - } -} diff --git a/zink/src/ffi/asm.rs b/zink/src/ffi/asm.rs new file mode 100644 index 000000000..95935825d --- /dev/null +++ b/zink/src/ffi/asm.rs @@ -0,0 +1,29 @@ +//! Assembly FFI. + +#[link(wasm_import_module = "zinkc")] +#[allow(improper_ctypes)] +extern "C" { + /// Push a 8-bit signed integer to the stack. + pub fn push_i8(val: i8); + + /// Push a 8-bit unsigned integer to the stack. + pub fn push_u8(val: u8); + + /// Push a 16-bit signed integer to the stack. + pub fn push_i16(val: i16); + + /// Push a 16-bit unsigned integer to the stack. + pub fn push_u16(val: u16); + + /// Push a 32-bit signed integer to the stack. + pub fn push_i32(val: i32); + + /// Push a 32-bit unsigned integer to the stack. + pub fn push_u32(val: u32); + + /// Push a 64-bit signed integer to the stack. + pub fn push_i64(val: i64); + + /// Push a 64-bit unsigned integer to the stack. + pub fn push_u64(val: u64); +} diff --git a/zink/src/ffi/evm.rs b/zink/src/ffi/evm.rs new file mode 100644 index 000000000..d2dd25f3c --- /dev/null +++ b/zink/src/ffi/evm.rs @@ -0,0 +1,136 @@ +//! EVM FFI + +#[link(wasm_import_module = "evm")] +#[allow(improper_ctypes)] +extern "C" { + /// Push 1 byte to the stack. + pub fn push0(); + + /// Push 1 byte to the stack. + pub fn push1(val: u8); + + /// Push 2 bytes to the stack. + pub fn push2(val: u8); + + /// Push 3 bytes to the stack. + pub fn push3(val: u8); + + /// Push 4 bytes to the stack. + pub fn push4(val: u8); + + /// Push 5 bytes to the stack. + pub fn push5(val: u8); + + /// Push 6 bytes to the stack. + pub fn push6(val: u8); + + /// Push 7 bytes to the stack. + pub fn push7(val: u8); + + /// Push 8 bytes to the stack. + pub fn push8(val: u8); + + /// Push 9 bytes to the stack. + pub fn push9(val: u8); + + /// Push 10 bytes to the stack. + pub fn push10(val: u8); + + /// Push 11 bytes to the stack. + pub fn push11(val: u8); + + /// Push 12 bytes to the stack. + pub fn push12(val: u8); + + /// Push 13 bytes to the stack. + pub fn push13(val: u8); + + /// Push 14 bytes to the stack. + pub fn push14(val: u8); + + /// Push 15 bytes to the stack. + pub fn push15(val: u8); + + /// Push 16 bytes to the stack. + pub fn push16(val: u8); + + /// Push 17 bytes to the stack. + pub fn push17(val: u8); + + /// Push 18 bytes to the stack. + pub fn push18(val: u8); + + /// Push 19 bytes to the stack. + pub fn push19(val: u8); + + /// Push 20 bytes to the stack. + pub fn push20(val: u8); + + /// Push 21 bytes to the stack. + pub fn push21(val: u8); + + /// Push 22 bytes to the stack. + pub fn push22(val: u8); + + /// Push 23 bytes to the stack. + pub fn push23(val: u8); + + /// Push 24 bytes to the stack. + pub fn push24(val: u8); + + /// Push 25 bytes to the stack. + pub fn push25(val: u8); + + /// Push 26 bytes to the stack. + pub fn push26(val: u8); + + /// Push 27 bytes to the stack. + pub fn push27(val: u8); + + /// Push 28 bytes to the stack. + pub fn push28(val: u8); + + /// Push 29 bytes to the stack. + pub fn push29(val: u8); + + /// Push 30 bytes to the stack. + pub fn push30(val: u8); + + /// Push 31 bytes to the stack. + pub fn push31(val: u8); + + /// Push 32 bytes to the stack. + pub fn push32(val: u8); + + /// Store a value in the storage + pub fn sstore(value: i32, key: i32); + + /// Load a value from the storage + pub fn sload(key: i32) -> i32; + + /// Append log record with no topics + pub fn log0(name: &'static [u8]); + + /// Append log record with one topics + pub fn log1(name: &'static [u8], topic1: &'static [u8]); + + /// Append log record with two topics + pub fn log2(name: &'static [u8], topic1: &'static [u8], topic2: &'static [u8]); + + /// Append log record with three topics + pub fn log3( + name: &'static [u8], + topic1: &'static [u8], + topic2: &'static [u8], + topic3: &'static [u8], + ); + + /// Append log record with four topics + pub fn log4( + name: &'static [u8], + topic1: &'static [u8], + topic2: &'static [u8], + topic3: &'static [u8], + topic4: &'static [u8], + ); +} diff --git a/zink/src/ffi/mod.rs b/zink/src/ffi/mod.rs new file mode 100644 index 000000000..f40d7d1e2 --- /dev/null +++ b/zink/src/ffi/mod.rs @@ -0,0 +1,12 @@ +//! Zink FFI. + +pub mod asm; +pub mod evm; + +#[link(wasm_import_module = "zinkc")] +#[allow(improper_ctypes)] +extern "C" { + /// Emit ABI to host state. + pub fn emit_abi(ptr: u32, len: u32); + +} diff --git a/zink/src/storage/mapping.rs b/zink/src/storage/mapping.rs index e69de29bb..b6113ccca 100644 --- a/zink/src/storage/mapping.rs +++ b/zink/src/storage/mapping.rs @@ -0,0 +1 @@ +//! Zink storage mapping implementation. diff --git a/zink/src/storage/mod.rs b/zink/src/storage/mod.rs index 97835d0fe..8f383c3e8 100644 --- a/zink/src/storage/mod.rs +++ b/zink/src/storage/mod.rs @@ -1,5 +1,7 @@ //! Zink storage implementation. +mod mapping; + /// Storage trait. Currently not for public use pub trait Storage { const STORAGE_KEY: i32;