mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-15 11:31:05 +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
@@ -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<Runtime>;
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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