Skip to content

Commit 890ce49

Browse files
s1naaxic
authored andcommitted
Add is_account_empty as experimental method
1 parent 07229ce commit 890ce49

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Other modules are available as well, outside of the prelude. Refer to the docume
2424
- `default`: Builds with `wee_alloc` as the global allocator and with the Rust standard library.
2525
- `qimalloc`: Builds with [qimalloc](https://github.com/wasmx/qimalloc) as the global allocator.
2626
- `debug`: Exposes the debugging interface.
27-
- `experimental`: Exposes the experimental bignum system library API.
27+
- `experimental`: Exposes the experimental APIs (bignum system library, evm2wasm EEI)
2828

2929
Further documentation is available [here](https://docs.rs/ewasm_api/).
3030

src/experimental.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//! Experimental methods.
2+
3+
use super::*;
4+
5+
mod native {
6+
extern "C" {
7+
pub fn experimental_isAccountEmpty(addressOffset: *const u32) -> u32;
8+
}
9+
}
10+
11+
pub fn is_account_empty(address: &Address) -> bool {
12+
let ret = unsafe { native::experimental_isAccountEmpty(address.bytes.as_ptr() as *const u32) };
13+
if ret != 0 && ret != 1 {
14+
panic!();
15+
}
16+
17+
ret == 1
18+
}

src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//! - `qimalloc`: Builds with [qimalloc](https://github.com/wasmx/qimalloc) as the global
1212
//! allocator.
1313
//! - `debug`: Exposes the debugging interface.
14-
//! - `experimental`: Exposes the experimental bignum system library API.
14+
//! - `experimental`: Exposes the experimental APIs (bignum system library, evm2wasm EEI)
1515
//!
1616
//! # Examples
1717
//! ```ignore
@@ -52,6 +52,7 @@ pub mod debug;
5252

5353
#[cfg(feature = "experimental")]
5454
pub mod bignum;
55+
pub mod experimental;
5556

5657
#[cfg(not(feature = "std"))]
5758
pub mod convert;
@@ -76,6 +77,7 @@ pub mod prelude {
7677

7778
#[cfg(feature = "experimental")]
7879
pub use crate::bignum;
80+
pub use crate::experimental;
7981
}
8082

8183
/// Enum representing an error code for EEI calls. Currently used by `codeCopy`, `callDataCopy`,

0 commit comments

Comments
 (0)