Rename pallet trait Trait to Config (#7599)

* rename Trait to Config

* add test asserting using Trait is still valid.

* fix ui tests
This commit is contained in:
Guillaume Thiolliere
2020-11-30 15:34:54 +01:00
committed by GitHub
parent dd3c84c362
commit 1cbfc9257f
200 changed files with 1767 additions and 1607 deletions
+13 -13
View File
@@ -19,7 +19,7 @@
//!
//! The Timestamp module provides functionality to get and set the on-chain time.
//!
//! - [`timestamp::Trait`](./trait.Trait.html)
//! - [`timestamp::Config`](./trait.Config.html)
//! - [`Call`](./enum.Call.html)
//! - [`Module`](./struct.Module.html)
//!
@@ -46,7 +46,7 @@
//! * `get` - Gets the current time for the current block. If this function is called prior to
//! setting the timestamp, it will return the timestamp of the previous block.
//!
//! ### Trait Getters
//! ### Config Getters
//!
//! * `MinimumPeriod` - Gets the minimum (and advised) period between blocks for the chain.
//!
@@ -66,10 +66,10 @@
//! # use pallet_timestamp as timestamp;
//! use frame_system::ensure_signed;
//!
//! pub trait Trait: timestamp::Trait {}
//! pub trait Config: timestamp::Config {}
//!
//! decl_module! {
//! pub struct Module<T: Trait> for enum Call where origin: T::Origin {
//! pub struct Module<T: Config> for enum Call where origin: T::Origin {
//! #[weight = 0]
//! pub fn get_time(origin) -> dispatch::DispatchResult {
//! let _sender = ensure_signed(origin)?;
@@ -118,7 +118,7 @@ use sp_timestamp::{
pub use weights::WeightInfo;
/// The module configuration trait
pub trait Trait: frame_system::Trait {
pub trait Config: frame_system::Config {
/// Type used for expressing timestamp.
type Moment: Parameter + Default + AtLeast32Bit
+ Scale<Self::BlockNumber, Output = Self::Moment> + Copy;
@@ -137,7 +137,7 @@ pub trait Trait: frame_system::Trait {
}
decl_module! {
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
pub struct Module<T: Config> for enum Call where origin: T::Origin {
/// The minimum period between blocks. Beware that this is different to the *expected* period
/// that the block production apparatus provides. Your chosen consensus system will generally
/// work with this to determine a sensible block time. e.g. For Aura, it will be double this
@@ -194,7 +194,7 @@ decl_module! {
}
decl_storage! {
trait Store for Module<T: Trait> as Timestamp {
trait Store for Module<T: Config> as Timestamp {
/// Current time for the current block.
pub Now get(fn now): T::Moment;
@@ -203,7 +203,7 @@ decl_storage! {
}
}
impl<T: Trait> Module<T> {
impl<T: Config> Module<T> {
/// Get the current time for the current block.
///
/// NOTE: if this function is called prior to setting the timestamp,
@@ -225,7 +225,7 @@ fn extract_inherent_data(data: &InherentData) -> Result<InherentType, RuntimeStr
.ok_or_else(|| "Timestamp inherent data is not provided.".into())
}
impl<T: Trait> ProvideInherent for Module<T> {
impl<T: Config> ProvideInherent for Module<T> {
type Call = Call<T>;
type Error = InherentError;
const INHERENT_IDENTIFIER: InherentIdentifier = INHERENT_IDENTIFIER;
@@ -260,7 +260,7 @@ impl<T: Trait> ProvideInherent for Module<T> {
}
}
impl<T: Trait> Time for Module<T> {
impl<T: Config> Time for Module<T> {
type Moment = T::Moment;
/// Before the first set of now with inherent the value returned is zero.
@@ -272,7 +272,7 @@ impl<T: Trait> Time for Module<T> {
/// Before the timestamp inherent is applied, it returns the time of previous block.
///
/// On genesis the time returned is not valid.
impl<T: Trait> UnixTime for Module<T> {
impl<T: Config> UnixTime for Module<T> {
fn now() -> core::time::Duration {
// now is duration since unix epoch in millisecond as documented in
// `sp_timestamp::InherentDataProvider`.
@@ -314,7 +314,7 @@ mod tests {
pub const MaximumBlockLength: u32 = 2 * 1024;
pub const AvailableBlockRatio: Perbill = Perbill::one();
}
impl frame_system::Trait for Test {
impl frame_system::Config for Test {
type BaseCallFilter = ();
type Origin = Origin;
type Index = u64;
@@ -344,7 +344,7 @@ mod tests {
parameter_types! {
pub const MinimumPeriod: u64 = 5;
}
impl Trait for Test {
impl Config for Test {
type Moment = u64;
type OnTimestampSet = ();
type MinimumPeriod = MinimumPeriod;
+1 -1
View File
@@ -50,7 +50,7 @@ pub trait WeightInfo {
/// Weights for pallet_timestamp using the Substrate node and recommended hardware.
pub struct SubstrateWeight<T>(PhantomData<T>);
impl<T: frame_system::Trait> WeightInfo for SubstrateWeight<T> {
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
fn set() -> Weight {
(11_650_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))