Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

feature: ethers-core wasm32 arch compatibility #38

Merged
merged 2 commits into from
Jun 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions ethers-core/src/utils/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
/// Utilities for launching a ganache-cli testnet instance
#[cfg(not(target_arch = "wasm32"))]
mod ganache;
#[cfg(not(target_arch = "wasm32"))]
pub use ganache::{Ganache, GanacheInstance};

/// Solidity compiler bindings
#[cfg(not(target_arch = "wasm32"))]
mod solc;

#[cfg(not(target_arch = "wasm32"))]
pub use solc::{CompiledContract, Solc};

mod hash;
Expand All @@ -15,8 +20,8 @@ pub use rlp;
use crate::types::{Address, Bytes, U256};
use std::convert::TryInto;

/// 1 Ether = 1e18 Wei
pub const WEI_IN_ETHER: usize = 1000000000000000000;
/// 1 Ether = 1e18 Wei == 0x0de0b6b3a7640000 Wei
pub const WEI_IN_ETHER: U256 = U256([0x0de0b6b3a7640000, 0x0, 0x0, 0x0]);

/// Format the output for the user which prefer to see values
/// in ether (instead of wei)
Expand Down Expand Up @@ -100,6 +105,11 @@ mod tests {
use super::*;
use rustc_hex::FromHex;

#[test]
fn wei_in_ether() {
assert_eq!(WEI_IN_ETHER.as_u64(), 1e18 as u64);
}

#[test]
fn contract_address() {
// http://ethereum.stackexchange.com/questions/760/how-is-the-address-of-an-ethereum-contract-computed
Expand Down