Skip to content

Commit

Permalink
Add is_account_empty
Browse files Browse the repository at this point in the history
  • Loading branch information
s1na committed May 22, 2019
1 parent 9cc0d51 commit 506e110
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -604,3 +604,12 @@ pub fn selfdestruct(address: &Address) -> ! {
native::ethereum_selfDestruct(address.bytes.as_ptr() as *const u32);
}
}

pub fn is_account_empty(address: &Address) -> bool {
let ret = unsafe { native::ethereum_isAccountEmpty(address.bytes.as_ptr() as *const u32) };
if ret != 0 && ret != 1 {
panic!();
}

ret == 1
}
1 change: 1 addition & 0 deletions src/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,5 @@ extern "C" {
pub fn ethereum_storageLoad(keyOffset: *const u32, resultOffset: *const u32);
pub fn ethereum_storageStore(keyOffset: *const u32, valueOffset: *const u32);
pub fn ethereum_selfDestruct(addressOffset: *const u32) -> !;
pub fn ethereum_isAccountEmpty(addressOffset: *const u32) -> u32;
}

0 comments on commit 506e110

Please sign in to comment.