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
+14 -14
View File
@@ -17,7 +17,7 @@
//! # Aura Module
//!
//! - [`aura::Trait`](./trait.Trait.html)
//! - [`aura::Config`](./trait.Config.html)
//! - [`Module`](./struct.Module.html)
//!
//! ## Overview
@@ -66,13 +66,13 @@ use sp_consensus_aura::{
mod mock;
mod tests;
pub trait Trait: pallet_timestamp::Trait {
pub trait Config: pallet_timestamp::Config {
/// The identifier type for an authority.
type AuthorityId: Member + Parameter + RuntimeAppPublic + Default;
}
decl_storage! {
trait Store for Module<T: Trait> as Aura {
trait Store for Module<T: Config> as Aura {
/// The last timestamp.
LastTimestamp get(fn last): T::Moment;
@@ -86,10 +86,10 @@ decl_storage! {
}
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 { }
}
impl<T: Trait> Module<T> {
impl<T: Config> Module<T> {
fn change_authorities(new: Vec<T::AuthorityId>) {
<Authorities<T>>::put(&new);
@@ -108,11 +108,11 @@ impl<T: Trait> Module<T> {
}
}
impl<T: Trait> sp_runtime::BoundToRuntimeAppPublic for Module<T> {
impl<T: Config> sp_runtime::BoundToRuntimeAppPublic for Module<T> {
type Public = T::AuthorityId;
}
impl<T: Trait> pallet_session::OneSessionHandler<T::AccountId> for Module<T> {
impl<T: Config> pallet_session::OneSessionHandler<T::AccountId> for Module<T> {
type Key = T::AuthorityId;
fn on_genesis_session<'a, I: 'a>(validators: I)
@@ -145,7 +145,7 @@ impl<T: Trait> pallet_session::OneSessionHandler<T::AccountId> for Module<T> {
}
}
impl<T: Trait> FindAuthor<u32> for Module<T> {
impl<T: Config> FindAuthor<u32> for Module<T> {
fn find_author<'a, I>(digests: I) -> Option<u32> where
I: 'a + IntoIterator<Item=(ConsensusEngineId, &'a [u8])>
{
@@ -167,7 +167,7 @@ impl<T: Trait> FindAuthor<u32> for Module<T> {
#[doc(hidden)]
pub struct FindAccountFromAuthorIndex<T, Inner>(sp_std::marker::PhantomData<(T, Inner)>);
impl<T: Trait, Inner: FindAuthor<u32>> FindAuthor<T::AuthorityId>
impl<T: Config, Inner: FindAuthor<u32>> FindAuthor<T::AuthorityId>
for FindAccountFromAuthorIndex<T, Inner>
{
fn find_author<'a, I>(digests: I) -> Option<T::AuthorityId>
@@ -183,7 +183,7 @@ impl<T: Trait, Inner: FindAuthor<u32>> FindAuthor<T::AuthorityId>
/// Find the authority ID of the Aura authority who authored the current block.
pub type AuraAuthorId<T> = FindAccountFromAuthorIndex<T, Module<T>>;
impl<T: Trait> IsMember<T::AuthorityId> for Module<T> {
impl<T: Config> IsMember<T::AuthorityId> for Module<T> {
fn is_member(authority_id: &T::AuthorityId) -> bool {
Self::authorities()
.iter()
@@ -191,12 +191,12 @@ impl<T: Trait> IsMember<T::AuthorityId> for Module<T> {
}
}
impl<T: Trait> Module<T> {
impl<T: Config> Module<T> {
/// Determine the Aura slot-duration based on the Timestamp module configuration.
pub fn slot_duration() -> T::Moment {
// we double the minimum block-period so each author can always propose within
// the majority of its slot.
<T as pallet_timestamp::Trait>::MinimumPeriod::get().saturating_mul(2u32.into())
<T as pallet_timestamp::Config>::MinimumPeriod::get().saturating_mul(2u32.into())
}
fn on_timestamp_set(now: T::Moment, slot_duration: T::Moment) {
@@ -218,13 +218,13 @@ impl<T: Trait> Module<T> {
}
}
impl<T: Trait> OnTimestampSet<T::Moment> for Module<T> {
impl<T: Config> OnTimestampSet<T::Moment> for Module<T> {
fn on_timestamp_set(moment: T::Moment) {
Self::on_timestamp_set(moment, Self::slot_duration())
}
}
impl<T: Trait> ProvideInherent for Module<T> {
impl<T: Config> ProvideInherent for Module<T> {
type Call = pallet_timestamp::Call<T>;
type Error = MakeFatalError<sp_inherents::Error>;
const INHERENT_IDENTIFIER: InherentIdentifier = INHERENT_IDENTIFIER;
+4 -4
View File
@@ -19,7 +19,7 @@
#![cfg(test)]
use crate::{Trait, Module, GenesisConfig};
use crate::{Config, Module, GenesisConfig};
use sp_consensus_aura::ed25519::AuthorityId;
use sp_runtime::{
traits::IdentityLookup, Perbill,
@@ -45,7 +45,7 @@ parameter_types! {
pub const MinimumPeriod: u64 = 1;
}
impl frame_system::Trait for Test {
impl frame_system::Config for Test {
type BaseCallFilter = ();
type Origin = Origin;
type Index = u64;
@@ -73,14 +73,14 @@ impl frame_system::Trait for Test {
type SystemWeightInfo = ();
}
impl pallet_timestamp::Trait for Test {
impl pallet_timestamp::Config for Test {
type Moment = u64;
type OnTimestampSet = Aura;
type MinimumPeriod = MinimumPeriod;
type WeightInfo = ();
}
impl Trait for Test {
impl Config for Test {
type AuthorityId = AuthorityId;
}