mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-21 08:35:40 +00:00
refactor contracts to use Time trait (#3717)
* refactor contracts to use Time trait * bump version
This commit is contained in:
committed by
Sergei Pepyakin
parent
667ee95f5d
commit
d4650c4739
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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<T> = <T as system::Trait>::Hash;
|
||||
pub type TrieId = Vec<u8>;
|
||||
@@ -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<Self::AccountId>;
|
||||
type Time: Time;
|
||||
|
||||
/// The outer call dispatch type.
|
||||
type Call: Parameter + Dispatchable<Origin=<Self as system::Trait>::Origin> + IsSubType<Module<Self>, Self>;
|
||||
|
||||
@@ -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<Test>;
|
||||
type Timestamp = timestamp::Module<Test>;
|
||||
type Contract = Module<Test>;
|
||||
type System = system::Module<Test>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user