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
+19 -19
View File
@@ -20,7 +20,7 @@
//! The System module provides low-level access to core types and cross-cutting utilities.
//! It acts as the base layer for other pallets to interact with the Substrate framework components.
//!
//! - [`system::Trait`](./trait.Trait.html)
//! - [`system::Config`](./trait.Config.html)
//!
//! ## Overview
//!
@@ -74,10 +74,10 @@
//! use frame_support::{decl_module, dispatch};
//! use frame_system::{self as system, ensure_signed};
//!
//! pub trait Trait: system::Trait {}
//! pub trait Config: system::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 system_module_example(origin) -> dispatch::DispatchResult {
//! let _sender = ensure_signed(origin)?;
@@ -160,7 +160,7 @@ pub fn extrinsics_data_root<H: Hash>(xts: Vec<Vec<u8>>) -> H::Output {
H::ordered_trie_root(xts)
}
pub trait Trait: 'static + Eq + Clone {
pub trait Config: 'static + Eq + Clone {
/// The basic call filter to use in Origin. All origins are built with this filter as base,
/// except Root.
type BaseCallFilter: Filter<Self::Call>;
@@ -270,8 +270,8 @@ pub trait Trait: 'static + Eq + Clone {
type SystemWeightInfo: WeightInfo;
}
pub type DigestOf<T> = generic::Digest<<T as Trait>::Hash>;
pub type DigestItemOf<T> = generic::DigestItem<<T as Trait>::Hash>;
pub type DigestOf<T> = generic::Digest<<T as Config>::Hash>;
pub type DigestItemOf<T> = generic::DigestItem<<T as Config>::Hash>;
pub type Key = Vec<u8>;
pub type KeyValue = (Vec<u8>, Vec<u8>);
@@ -329,7 +329,7 @@ impl<AccountId> From<Option<AccountId>> for RawOrigin<AccountId> {
}
/// Exposed trait-generic origin type.
pub type Origin<T> = RawOrigin<<T as Trait>::AccountId>;
pub type Origin<T> = RawOrigin<<T as Config>::AccountId>;
// Create a Hash with 69 for each byte,
// only used to build genesis config.
@@ -390,7 +390,7 @@ impl From<sp_version::RuntimeVersion> for LastRuntimeUpgradeInfo {
}
decl_storage! {
trait Store for Module<T: Trait> as System {
trait Store for Module<T: Config> as System {
/// The full account information for a particular account ID.
pub Account get(fn account):
map hasher(blake2_128_concat) T::AccountId => AccountInfo<T::Index, T::AccountData>;
@@ -478,7 +478,7 @@ decl_storage! {
decl_event!(
/// Event for the System module.
pub enum Event<T> where AccountId = <T as Trait>::AccountId {
pub enum Event<T> where AccountId = <T as Config>::AccountId {
/// An extrinsic completed successfully. \[info\]
ExtrinsicSuccess(DispatchInfo),
/// An extrinsic failed. \[error, info\]
@@ -494,7 +494,7 @@ decl_event!(
decl_error! {
/// Error for the System module
pub enum Error for Module<T: Trait> {
pub enum Error for Module<T: Config> {
/// The name of specification does not match between the current runtime
/// and the new runtime.
InvalidSpecName,
@@ -513,7 +513,7 @@ decl_error! {
}
decl_module! {
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=self {
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=self {
type Error = Error<T>;
/// The maximum number of blocks to allow in mortal eras.
@@ -897,7 +897,7 @@ pub enum RefStatus {
Unreferenced,
}
impl<T: Trait> Module<T> {
impl<T: Config> Module<T> {
/// Deposits an event into this block's event record.
pub fn deposit_event(event: impl Into<T::Event>) {
Self::deposit_event_indexed(&[], event.into());
@@ -1252,7 +1252,7 @@ impl<T: Trait> Module<T> {
/// Event handler which calls on_created_account when it happens.
pub struct CallOnCreatedAccount<T>(PhantomData<T>);
impl<T: Trait> Happened<T::AccountId> for CallOnCreatedAccount<T> {
impl<T: Config> Happened<T::AccountId> for CallOnCreatedAccount<T> {
fn happened(who: &T::AccountId) {
Module::<T>::on_created_account(who.clone());
}
@@ -1260,15 +1260,15 @@ impl<T: Trait> Happened<T::AccountId> for CallOnCreatedAccount<T> {
/// Event handler which calls kill_account when it happens.
pub struct CallKillAccount<T>(PhantomData<T>);
impl<T: Trait> Happened<T::AccountId> for CallKillAccount<T> {
impl<T: Config> Happened<T::AccountId> for CallKillAccount<T> {
fn happened(who: &T::AccountId) {
Module::<T>::kill_account(who)
}
}
impl<T: Trait> BlockNumberProvider for Module<T>
impl<T: Config> BlockNumberProvider for Module<T>
{
type BlockNumber = <T as Trait>::BlockNumber;
type BlockNumber = <T as Config>::BlockNumber;
fn current_block_number() -> Self::BlockNumber {
Module::<T>::block_number()
@@ -1278,7 +1278,7 @@ impl<T: Trait> BlockNumberProvider for Module<T>
// Implement StoredMap for a simple single-item, kill-account-on-remove system. This works fine for
// storing a single item which is required to not be empty/default for the account to exist.
// Anything more complex will need more sophisticated logic.
impl<T: Trait> StoredMap<T::AccountId, T::AccountData> for Module<T> {
impl<T: Config> StoredMap<T::AccountId, T::AccountData> for Module<T> {
fn get(k: &T::AccountId) -> T::AccountData {
Account::<T>::get(k).data
}
@@ -1345,7 +1345,7 @@ pub fn split_inner<T, R, S>(option: Option<T>, splitter: impl FnOnce(T) -> (R, S
}
impl<T: Trait> IsDeadAccount<T::AccountId> for Module<T> {
impl<T: Config> IsDeadAccount<T::AccountId> for Module<T> {
fn is_dead_account(who: &T::AccountId) -> bool {
!Account::<T>::contains_key(who)
}
@@ -1358,7 +1358,7 @@ impl<T> Default for ChainContext<T> {
}
}
impl<T: Trait> Lookup for ChainContext<T> {
impl<T: Config> Lookup for ChainContext<T> {
type Source = <T::Lookup as StaticLookup>::Source;
type Target = <T::Lookup as StaticLookup>::Target;