Skip to content

Commit

Permalink
Add is_account_empty as experimental method
Browse files Browse the repository at this point in the history
  • Loading branch information
s1na authored and axic committed May 29, 2019
1 parent 07229ce commit 890ce49
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/).

Expand Down
18 changes: 18 additions & 0 deletions src/experimental.rs
Original file line number Diff line number Diff line change
@@ -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
}
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -52,6 +52,7 @@ pub mod debug;

#[cfg(feature = "experimental")]
pub mod bignum;
pub mod experimental;

#[cfg(not(feature = "std"))]
pub mod convert;
Expand All @@ -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`,
Expand Down

0 comments on commit 890ce49

Please sign in to comment.