feature: ethers-core wasm32 arch compatibility (#38)

* feature: ethers-core wasm32 arch compatibility

* fix(core): set U256 array in correct order

Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
This commit is contained in:
James Prestwich 2020-06-23 00:15:33 -07:00 committed by GitHub
parent c1430fa04e
commit d218dba6df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 2 deletions

View File

@ -1,9 +1,14 @@
/// Utilities for launching a ganache-cli testnet instance /// Utilities for launching a ganache-cli testnet instance
#[cfg(not(target_arch = "wasm32"))]
mod ganache; mod ganache;
#[cfg(not(target_arch = "wasm32"))]
pub use ganache::{Ganache, GanacheInstance}; pub use ganache::{Ganache, GanacheInstance};
/// Solidity compiler bindings /// Solidity compiler bindings
#[cfg(not(target_arch = "wasm32"))]
mod solc; mod solc;
#[cfg(not(target_arch = "wasm32"))]
pub use solc::{CompiledContract, Solc}; pub use solc::{CompiledContract, Solc};
mod hash; mod hash;
@ -15,8 +20,8 @@ pub use rlp;
use crate::types::{Address, Bytes, U256}; use crate::types::{Address, Bytes, U256};
use std::convert::TryInto; use std::convert::TryInto;
/// 1 Ether = 1e18 Wei /// 1 Ether = 1e18 Wei == 0x0de0b6b3a7640000 Wei
pub const WEI_IN_ETHER: usize = 1000000000000000000; pub const WEI_IN_ETHER: U256 = U256([0x0de0b6b3a7640000, 0x0, 0x0, 0x0]);
/// Format the output for the user which prefer to see values /// Format the output for the user which prefer to see values
/// in ether (instead of wei) /// in ether (instead of wei)
@ -100,6 +105,11 @@ mod tests {
use super::*; use super::*;
use rustc_hex::FromHex; use rustc_hex::FromHex;
#[test]
fn wei_in_ether() {
assert_eq!(WEI_IN_ETHER.as_u64(), 1e18 as u64);
}
#[test] #[test]
fn contract_address() { fn contract_address() {
// http://ethereum.stackexchange.com/questions/760/how-is-the-address-of-an-ethereum-contract-computed // http://ethereum.stackexchange.com/questions/760/how-is-the-address-of-an-ethereum-contract-computed