refactor contracts to use Time trait (#3717)

* refactor contracts to use Time trait

* bump version
This commit is contained in:
Xiliang Chen
2019-09-29 06:07:21 +13:00
committed by Sergei Pepyakin
parent 667ee95f5d
commit d4650c4739
5 changed files with 13 additions and 12 deletions
+6 -7
View File
@@ -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<T> = <T as system::Trait>::AccountId;
pub type CallOf<T> = <T as Trait>::Call;
pub type MomentOf<T> = <T as timestamp::Trait>::Moment;
pub type MomentOf<T> = <<T as Trait>::Time as Time>::Moment;
pub type SeedOf<T> = <T as system::Trait>::Hash;
pub type BlockNumberOf<T> = <T as system::Trait>::BlockNumber;
@@ -271,7 +270,7 @@ pub struct ExecutionContext<'a, T: Trait + 'a, V, L> {
pub config: &'a Config<T>,
pub vm: &'a V,
pub loader: &'a L,
pub timestamp: T::Moment,
pub timestamp: MomentOf<T>,
pub block_number: T::BlockNumber,
}
@@ -296,7 +295,7 @@ where
config: &cfg,
vm: &vm,
loader: &loader,
timestamp: <timestamp::Module<T>>::now(),
timestamp: T::Time::now(),
block_number: <system::Module<T>>::block_number(),
}
}
@@ -665,7 +664,7 @@ struct CallContext<'a, 'b: 'a, T: Trait + 'b, V: Vm<T> + 'b, L: Loader<T>> {
ctx: &'a mut ExecutionContext<'b, T, V, L>,
caller: T::AccountId,
value_transferred: BalanceOf<T>,
timestamp: T::Moment,
timestamp: MomentOf<T>,
block_number: T::BlockNumber,
}
@@ -757,7 +756,7 @@ where
system::Module::<T>::random(subject)
}
fn now(&self) -> &T::Moment {
fn now(&self) -> &MomentOf<T> {
&self.timestamp
}