Skip to content

Commit

Permalink
implement basic structs and traits for uint256, uint128, uint160
Browse files Browse the repository at this point in the history
  • Loading branch information
jakelang committed Aug 16, 2018
1 parent 22155d2 commit 91dbe23
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,53 @@ fn unsafe_alloc_buffer(len: usize) -> Vec<u8> {
ret
}

#[derive(Copy, Clone)]
pub struct Uint160 {
bytes: [u8; 20],
}

#[derive(Copy, Clone)]
pub struct Uint256 {
bytes: [u8; 32],
}

#[derive(Copy, Clone)]
pub struct Uint128 {
bytes: [u8; 16],
}

trait EwasmType {
fn new() -> Self;
}

type Address = Uint160;
type Hash = Uint256;
type Value = Uint128;

impl EwasmType for Address {
fn new() -> Self {
Address {
bytes: [0; 20],
}
}
}

impl EwasmType for Value {
fn new() -> Self {
Value {
bytes: [0; 16],
}
}
}

impl EwasmType for Hash {
fn new() -> Self {
Hash {
bytes: [0; 32],
}
}
}

pub enum CallResult {
Successful,
Failure,
Expand Down

0 comments on commit 91dbe23

Please sign in to comment.