Skip to content

Commit 0b8aa02

Browse files
authored
Rename pallet trait Trait to Config (#7599)
* rename Trait to Config * add test asserting using Trait is still valid. * fix ui tests
1 parent 0baa702 commit 0b8aa02

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/lib.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
//!
2020
//! The Timestamp module provides functionality to get and set the on-chain time.
2121
//!
22-
//! - [`timestamp::Trait`](./trait.Trait.html)
22+
//! - [`timestamp::Config`](./trait.Config.html)
2323
//! - [`Call`](./enum.Call.html)
2424
//! - [`Module`](./struct.Module.html)
2525
//!
@@ -46,7 +46,7 @@
4646
//! * `get` - Gets the current time for the current block. If this function is called prior to
4747
//! setting the timestamp, it will return the timestamp of the previous block.
4848
//!
49-
//! ### Trait Getters
49+
//! ### Config Getters
5050
//!
5151
//! * `MinimumPeriod` - Gets the minimum (and advised) period between blocks for the chain.
5252
//!
@@ -66,10 +66,10 @@
6666
//! # use pallet_timestamp as timestamp;
6767
//! use frame_system::ensure_signed;
6868
//!
69-
//! pub trait Trait: timestamp::Trait {}
69+
//! pub trait Config: timestamp::Config {}
7070
//!
7171
//! decl_module! {
72-
//! pub struct Module<T: Trait> for enum Call where origin: T::Origin {
72+
//! pub struct Module<T: Config> for enum Call where origin: T::Origin {
7373
//! #[weight = 0]
7474
//! pub fn get_time(origin) -> dispatch::DispatchResult {
7575
//! let _sender = ensure_signed(origin)?;
@@ -118,7 +118,7 @@ use sp_timestamp::{
118118
pub use weights::WeightInfo;
119119

120120
/// The module configuration trait
121-
pub trait Trait: frame_system::Trait {
121+
pub trait Config: frame_system::Config {
122122
/// Type used for expressing timestamp.
123123
type Moment: Parameter + Default + AtLeast32Bit
124124
+ Scale<Self::BlockNumber, Output = Self::Moment> + Copy;
@@ -137,7 +137,7 @@ pub trait Trait: frame_system::Trait {
137137
}
138138

139139
decl_module! {
140-
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
140+
pub struct Module<T: Config> for enum Call where origin: T::Origin {
141141
/// The minimum period between blocks. Beware that this is different to the *expected* period
142142
/// that the block production apparatus provides. Your chosen consensus system will generally
143143
/// work with this to determine a sensible block time. e.g. For Aura, it will be double this
@@ -194,7 +194,7 @@ decl_module! {
194194
}
195195

196196
decl_storage! {
197-
trait Store for Module<T: Trait> as Timestamp {
197+
trait Store for Module<T: Config> as Timestamp {
198198
/// Current time for the current block.
199199
pub Now get(fn now): T::Moment;
200200

@@ -203,7 +203,7 @@ decl_storage! {
203203
}
204204
}
205205

206-
impl<T: Trait> Module<T> {
206+
impl<T: Config> Module<T> {
207207
/// Get the current time for the current block.
208208
///
209209
/// NOTE: if this function is called prior to setting the timestamp,
@@ -225,7 +225,7 @@ fn extract_inherent_data(data: &InherentData) -> Result<InherentType, RuntimeStr
225225
.ok_or_else(|| "Timestamp inherent data is not provided.".into())
226226
}
227227

228-
impl<T: Trait> ProvideInherent for Module<T> {
228+
impl<T: Config> ProvideInherent for Module<T> {
229229
type Call = Call<T>;
230230
type Error = InherentError;
231231
const INHERENT_IDENTIFIER: InherentIdentifier = INHERENT_IDENTIFIER;
@@ -260,7 +260,7 @@ impl<T: Trait> ProvideInherent for Module<T> {
260260
}
261261
}
262262

263-
impl<T: Trait> Time for Module<T> {
263+
impl<T: Config> Time for Module<T> {
264264
type Moment = T::Moment;
265265

266266
/// Before the first set of now with inherent the value returned is zero.
@@ -272,7 +272,7 @@ impl<T: Trait> Time for Module<T> {
272272
/// Before the timestamp inherent is applied, it returns the time of previous block.
273273
///
274274
/// On genesis the time returned is not valid.
275-
impl<T: Trait> UnixTime for Module<T> {
275+
impl<T: Config> UnixTime for Module<T> {
276276
fn now() -> core::time::Duration {
277277
// now is duration since unix epoch in millisecond as documented in
278278
// `sp_timestamp::InherentDataProvider`.
@@ -314,7 +314,7 @@ mod tests {
314314
pub const MaximumBlockLength: u32 = 2 * 1024;
315315
pub const AvailableBlockRatio: Perbill = Perbill::one();
316316
}
317-
impl frame_system::Trait for Test {
317+
impl frame_system::Config for Test {
318318
type BaseCallFilter = ();
319319
type Origin = Origin;
320320
type Index = u64;
@@ -344,7 +344,7 @@ mod tests {
344344
parameter_types! {
345345
pub const MinimumPeriod: u64 = 5;
346346
}
347-
impl Trait for Test {
347+
impl Config for Test {
348348
type Moment = u64;
349349
type OnTimestampSet = ();
350350
type MinimumPeriod = MinimumPeriod;

src/weights.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub trait WeightInfo {
5050

5151
/// Weights for pallet_timestamp using the Substrate node and recommended hardware.
5252
pub struct SubstrateWeight<T>(PhantomData<T>);
53-
impl<T: frame_system::Trait> WeightInfo for SubstrateWeight<T> {
53+
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
5454
fn set() -> Weight {
5555
(11_650_000 as Weight)
5656
.saturating_add(T::DbWeight::get().reads(2 as Weight))

0 commit comments

Comments
 (0)