diff --git a/substrate/node/runtime/src/lib.rs b/substrate/node/runtime/src/lib.rs index 627f4b6731..a8999576a7 100644 --- a/substrate/node/runtime/src/lib.rs +++ b/substrate/node/runtime/src/lib.rs @@ -391,6 +391,7 @@ parameter_types! { impl contracts::Trait for Runtime { type Currency = Balances; + type Time = Timestamp; type Call = Call; type Event = Event; type DetermineContractAddress = contracts::SimpleAddressDeterminator; diff --git a/substrate/srml/contracts/Cargo.toml b/substrate/srml/contracts/Cargo.toml index de6ee96197..646dcd8b5b 100644 --- a/substrate/srml/contracts/Cargo.toml +++ b/substrate/srml/contracts/Cargo.toml @@ -17,13 +17,13 @@ rstd = { package = "sr-std", path = "../../core/sr-std", default-features = fals sandbox = { package = "sr-sandbox", path = "../../core/sr-sandbox", default-features = false } support = { package = "srml-support", path = "../support", default-features = false } system = { package = "srml-system", path = "../system", default-features = false } -timestamp = { package = "srml-timestamp", path = "../timestamp", default-features = false } [dev-dependencies] wabt = "~0.7.4" assert_matches = "1.1" hex-literal = "0.2.0" balances = { package = "srml-balances", path = "../balances" } +timestamp = { package = "srml-timestamp", path = "../timestamp" } hex = "0.3" [features] @@ -38,7 +38,6 @@ std = [ "sandbox/std", "support/std", "system/std", - "timestamp/std", "parity-wasm/std", "pwasm-utils/std", "wasmi-validation/std", diff --git a/substrate/srml/contracts/src/exec.rs b/substrate/srml/contracts/src/exec.rs index 65fe89ed34..94343c5fb9 100644 --- a/substrate/srml/contracts/src/exec.rs +++ b/substrate/srml/contracts/src/exec.rs @@ -22,12 +22,11 @@ use crate::rent; use rstd::prelude::*; use sr_primitives::traits::{Bounded, CheckedAdd, CheckedSub, Zero}; -use support::traits::{WithdrawReason, Currency}; -use timestamp; +use support::traits::{WithdrawReason, Currency, Time}; pub type AccountIdOf = ::AccountId; pub type CallOf = ::Call; -pub type MomentOf = ::Moment; +pub type MomentOf = <::Time as Time>::Moment; pub type SeedOf = ::Hash; pub type BlockNumberOf = ::BlockNumber; @@ -271,7 +270,7 @@ pub struct ExecutionContext<'a, T: Trait + 'a, V, L> { pub config: &'a Config, pub vm: &'a V, pub loader: &'a L, - pub timestamp: T::Moment, + pub timestamp: MomentOf, pub block_number: T::BlockNumber, } @@ -296,7 +295,7 @@ where config: &cfg, vm: &vm, loader: &loader, - timestamp: >::now(), + timestamp: T::Time::now(), block_number: >::block_number(), } } @@ -665,7 +664,7 @@ struct CallContext<'a, 'b: 'a, T: Trait + 'b, V: Vm + 'b, L: Loader> { ctx: &'a mut ExecutionContext<'b, T, V, L>, caller: T::AccountId, value_transferred: BalanceOf, - timestamp: T::Moment, + timestamp: MomentOf, block_number: T::BlockNumber, } @@ -757,7 +756,7 @@ where system::Module::::random(subject) } - fn now(&self) -> &T::Moment { + fn now(&self) -> &MomentOf { &self.timestamp } diff --git a/substrate/srml/contracts/src/lib.rs b/substrate/srml/contracts/src/lib.rs index 8343f39bc7..918d0838c4 100644 --- a/substrate/srml/contracts/src/lib.rs +++ b/substrate/srml/contracts/src/lib.rs @@ -124,10 +124,9 @@ use support::{ Parameter, decl_module, decl_event, decl_storage, storage::child, parameter_types, }; -use support::{traits::{OnFreeBalanceZero, OnUnbalanced, Currency, Get}, IsSubType}; +use support::{traits::{OnFreeBalanceZero, OnUnbalanced, Currency, Get, Time}, IsSubType}; use system::{ensure_signed, RawOrigin, ensure_root}; use primitives::storage::well_known_keys::CHILD_STORAGE_KEY_PREFIX; -use timestamp; pub type CodeHash = ::Hash; pub type TrieId = Vec; @@ -333,8 +332,9 @@ parameter_types! { pub const DefaultBlockGasLimit: u32 = 10_000_000; } -pub trait Trait: timestamp::Trait { +pub trait Trait: system::Trait { type Currency: Currency; + type Time: Time; /// The outer call dispatch type. type Call: Parameter + Dispatchable::Origin> + IsSubType, Self>; diff --git a/substrate/srml/contracts/src/tests.rs b/substrate/srml/contracts/src/tests.rs index 2dfdce33eb..f2ef8a275d 100644 --- a/substrate/srml/contracts/src/tests.rs +++ b/substrate/srml/contracts/src/tests.rs @@ -161,6 +161,7 @@ parameter_types! { } impl Trait for Test { type Currency = Balances; + type Time = Timestamp; type Call = Call; type DetermineContractAddress = DummyContractAddressFor; type Event = MetaEvent; @@ -186,6 +187,7 @@ impl Trait for Test { } type Balances = balances::Module; +type Timestamp = timestamp::Module; type Contract = Module; type System = system::Module;