diff --git a/substrate/core/sr-std/with_std.rs b/substrate/core/sr-std/with_std.rs index 443fea1a61..0e809e67d8 100644 --- a/substrate/core/sr-std/with_std.rs +++ b/substrate/core/sr-std/with_std.rs @@ -29,7 +29,6 @@ pub use std::ops; pub use std::ptr; pub use std::rc; pub use std::slice; -pub use std::string; pub use std::vec; pub use std::result; diff --git a/substrate/core/sr-std/without_std.rs b/substrate/core/sr-std/without_std.rs index bfa9020504..981c02c025 100644 --- a/substrate/core/sr-std/without_std.rs +++ b/substrate/core/sr-std/without_std.rs @@ -47,7 +47,6 @@ mod __impl { pub use alloc::boxed; pub use alloc::rc; pub use alloc::vec; -pub use alloc::string; pub use core::borrow; pub use core::cell; pub use core::clone; @@ -63,6 +62,9 @@ pub use core::ops; pub use core::ptr; pub use core::slice; pub use core::result; +// We are trying to avoid certain things here, such as `core::string` +// (if you need `String` you most probably doing something wrong, since +// runtime doesn't require anything human readable). pub mod collections { pub use alloc::collections::btree_map; diff --git a/substrate/srml/contract/src/vm/env_def/macros.rs b/substrate/srml/contract/src/vm/env_def/macros.rs index 40651749eb..628da0b56d 100644 --- a/substrate/srml/contract/src/vm/env_def/macros.rs +++ b/substrate/srml/contract/src/vm/env_def/macros.rs @@ -280,6 +280,6 @@ mod tests { ); let env = init_env::(); - assert!(env.funcs.get("ext_gas").is_some()); + assert!(env.funcs.get(&b"ext_gas"[..]).is_some()); } } diff --git a/substrate/srml/contract/src/vm/env_def/mod.rs b/substrate/srml/contract/src/vm/env_def/mod.rs index 3b208ebf9b..bd2c98668c 100644 --- a/substrate/srml/contract/src/vm/env_def/mod.rs +++ b/substrate/srml/contract/src/vm/env_def/mod.rs @@ -18,7 +18,6 @@ use super::{SpecialTrap, BalanceOf, CreateReceipt, Ext, GasMeterResult, Runtime} use codec::{Encode, Decode}; use parity_wasm::elements::{FunctionType, ValueType}; use rstd::prelude::*; -use rstd::string::String; use rstd::collections::btree_map::BTreeMap; use runtime_primitives::traits::{As, CheckedMul}; use sandbox::{self, TypedValue}; @@ -75,7 +74,7 @@ impl ConvertibleToWasm for u64 { /// which can be imported and called by the module. pub(crate) struct HostFunctionSet { /// Functions which defined in the environment. - pub funcs: BTreeMap>, + pub funcs: BTreeMap, HostFunction>, } impl HostFunctionSet { pub fn new() -> Self { diff --git a/substrate/srml/contract/src/vm/prepare.rs b/substrate/srml/contract/src/vm/prepare.rs index b15f9cbc3a..7c1b7c3d41 100644 --- a/substrate/srml/contract/src/vm/prepare.rs +++ b/substrate/srml/contract/src/vm/prepare.rs @@ -138,7 +138,7 @@ impl<'a, T: Trait> ContractModule<'a, T> { let ext_func = env .funcs - .get(import.field()) + .get(import.field().as_bytes()) .ok_or_else(|| Error::Instantiate)?; if !ext_func.func_type_matches(func_ty) { return Err(Error::Instantiate);