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
+10 -10
View File
@@ -37,10 +37,10 @@ use frame_support::traits::{Currency, ReservableCurrency, Get, BalanceStatus::Re
use frame_system::{ensure_signed, ensure_root};
pub use weights::WeightInfo;
type BalanceOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
type BalanceOf<T> = <<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
/// The module's config trait.
pub trait Trait: frame_system::Trait {
pub trait Config: frame_system::Config {
/// Type used for storing an account's index; implies the maximum number of accounts the system
/// can hold.
type AccountIndex: Parameter + Member + Codec + Default + AtLeast32Bit + Copy;
@@ -52,14 +52,14 @@ pub trait Trait: frame_system::Trait {
type Deposit: Get<BalanceOf<Self>>;
/// The overarching event type.
type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
type Event: From<Event<Self>> + Into<<Self as frame_system::Config>::Event>;
/// Weight information for extrinsics in this pallet.
type WeightInfo: WeightInfo;
}
decl_storage! {
trait Store for Module<T: Trait> as Indices {
trait Store for Module<T: Config> as Indices {
/// The lookup from index to account.
pub Accounts build(|config: &GenesisConfig<T>|
config.indices.iter()
@@ -75,8 +75,8 @@ decl_storage! {
decl_event!(
pub enum Event<T> where
<T as frame_system::Trait>::AccountId,
<T as Trait>::AccountIndex
<T as frame_system::Config>::AccountId,
<T as Config>::AccountIndex
{
/// A account index was assigned. \[index, who\]
IndexAssigned(AccountId, AccountIndex),
@@ -88,7 +88,7 @@ decl_event!(
);
decl_error! {
pub enum Error for Module<T: Trait> {
pub enum Error for Module<T: Config> {
/// The index was not already assigned.
NotAssigned,
/// The index is assigned to another account.
@@ -103,7 +103,7 @@ decl_error! {
}
decl_module! {
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system = frame_system {
pub struct Module<T: Config> for enum Call where origin: T::Origin, system = frame_system {
/// The deposit needed for reserving an index.
const Deposit: BalanceOf<T> = T::Deposit::get();
@@ -275,7 +275,7 @@ decl_module! {
}
}
impl<T: Trait> Module<T> {
impl<T: Config> Module<T> {
// PUBLIC IMMUTABLES
/// Lookup an T::AccountIndex to get an Id, if there's one there.
@@ -295,7 +295,7 @@ impl<T: Trait> Module<T> {
}
}
impl<T: Trait> StaticLookup for Module<T> {
impl<T: Config> StaticLookup for Module<T> {
type Source = MultiAddress<T::AccountId, T::AccountIndex>;
type Target = T::AccountId;
+4 -4
View File
@@ -23,7 +23,7 @@ use sp_runtime::testing::Header;
use sp_runtime::Perbill;
use sp_core::H256;
use frame_support::{impl_outer_origin, impl_outer_event, parameter_types, weights::Weight};
use crate::{self as indices, Module, Trait};
use crate::{self as indices, Module, Config};
use frame_system as system;
use pallet_balances as balances;
@@ -49,7 +49,7 @@ parameter_types! {
pub const AvailableBlockRatio: Perbill = Perbill::one();
}
impl frame_system::Trait for Test {
impl frame_system::Config for Test {
type BaseCallFilter = ();
type Origin = Origin;
type Call = ();
@@ -81,7 +81,7 @@ parameter_types! {
pub const ExistentialDeposit: u64 = 1;
}
impl pallet_balances::Trait for Test {
impl pallet_balances::Config for Test {
type MaxLocks = ();
type Balance = u64;
type DustRemoval = ();
@@ -95,7 +95,7 @@ parameter_types! {
pub const Deposit: u64 = 1;
}
impl Trait for Test {
impl Config for Test {
type AccountIndex = u64;
type Currency = Balances;
type Deposit = Deposit;
+1 -1
View File
@@ -53,7 +53,7 @@ pub trait WeightInfo {
/// Weights for pallet_indices 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 claim() -> Weight {
(53_799_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))