diff --git a/README.md b/README.md index 8ddf7d4..437a036 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Other modules are available as well, outside of the prelude. Refer to the docume - `default`: Builds with `wee_alloc` as the global allocator and with the Rust standard library. - `qimalloc`: Builds with [qimalloc](https://github.com/wasmx/qimalloc) as the global allocator. - `debug`: Exposes the debugging interface. -- `experimental`: Exposes the experimental bignum system library API. +- `experimental`: Exposes the experimental APIs (bignum system library, evm2wasm EEI) Further documentation is available [here](https://docs.rs/ewasm_api/). diff --git a/src/experimental.rs b/src/experimental.rs new file mode 100644 index 0000000..66b4178 --- /dev/null +++ b/src/experimental.rs @@ -0,0 +1,18 @@ +//! Experimental methods. + +use super::*; + +mod native { + extern "C" { + pub fn experimental_isAccountEmpty(addressOffset: *const u32) -> u32; + } +} + +pub fn is_account_empty(address: &Address) -> bool { + let ret = unsafe { native::experimental_isAccountEmpty(address.bytes.as_ptr() as *const u32) }; + if ret != 0 && ret != 1 { + panic!(); + } + + ret == 1 +} diff --git a/src/lib.rs b/src/lib.rs index 08cb9fc..b013c9e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,7 +11,7 @@ //! - `qimalloc`: Builds with [qimalloc](https://github.com/wasmx/qimalloc) as the global //! allocator. //! - `debug`: Exposes the debugging interface. -//! - `experimental`: Exposes the experimental bignum system library API. +//! - `experimental`: Exposes the experimental APIs (bignum system library, evm2wasm EEI) //! //! # Examples //! ```ignore @@ -52,6 +52,7 @@ pub mod debug; #[cfg(feature = "experimental")] pub mod bignum; +pub mod experimental; #[cfg(not(feature = "std"))] pub mod convert; @@ -76,6 +77,7 @@ pub mod prelude { #[cfg(feature = "experimental")] pub use crate::bignum; + pub use crate::experimental; } /// Enum representing an error code for EEI calls. Currently used by `codeCopy`, `callDataCopy`,