Skip to content

Commit bb176bd

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 fbb6742 commit bb176bd

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

src/lib.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ use frame_support::traits::{Currency, ReservableCurrency, Get, BalanceStatus::Re
3737
use frame_system::{ensure_signed, ensure_root};
3838
pub use weights::WeightInfo;
3939

40-
type BalanceOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
40+
type BalanceOf<T> = <<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
4141

4242
/// The module's config trait.
43-
pub trait Trait: frame_system::Trait {
43+
pub trait Config: frame_system::Config {
4444
/// Type used for storing an account's index; implies the maximum number of accounts the system
4545
/// can hold.
4646
type AccountIndex: Parameter + Member + Codec + Default + AtLeast32Bit + Copy;
@@ -52,14 +52,14 @@ pub trait Trait: frame_system::Trait {
5252
type Deposit: Get<BalanceOf<Self>>;
5353

5454
/// The overarching event type.
55-
type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
55+
type Event: From<Event<Self>> + Into<<Self as frame_system::Config>::Event>;
5656

5757
/// Weight information for extrinsics in this pallet.
5858
type WeightInfo: WeightInfo;
5959
}
6060

6161
decl_storage! {
62-
trait Store for Module<T: Trait> as Indices {
62+
trait Store for Module<T: Config> as Indices {
6363
/// The lookup from index to account.
6464
pub Accounts build(|config: &GenesisConfig<T>|
6565
config.indices.iter()
@@ -75,8 +75,8 @@ decl_storage! {
7575

7676
decl_event!(
7777
pub enum Event<T> where
78-
<T as frame_system::Trait>::AccountId,
79-
<T as Trait>::AccountIndex
78+
<T as frame_system::Config>::AccountId,
79+
<T as Config>::AccountIndex
8080
{
8181
/// A account index was assigned. \[index, who\]
8282
IndexAssigned(AccountId, AccountIndex),
@@ -88,7 +88,7 @@ decl_event!(
8888
);
8989

9090
decl_error! {
91-
pub enum Error for Module<T: Trait> {
91+
pub enum Error for Module<T: Config> {
9292
/// The index was not already assigned.
9393
NotAssigned,
9494
/// The index is assigned to another account.
@@ -103,7 +103,7 @@ decl_error! {
103103
}
104104

105105
decl_module! {
106-
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system = frame_system {
106+
pub struct Module<T: Config> for enum Call where origin: T::Origin, system = frame_system {
107107
/// The deposit needed for reserving an index.
108108
const Deposit: BalanceOf<T> = T::Deposit::get();
109109

@@ -275,7 +275,7 @@ decl_module! {
275275
}
276276
}
277277

278-
impl<T: Trait> Module<T> {
278+
impl<T: Config> Module<T> {
279279
// PUBLIC IMMUTABLES
280280

281281
/// Lookup an T::AccountIndex to get an Id, if there's one there.
@@ -295,7 +295,7 @@ impl<T: Trait> Module<T> {
295295
}
296296
}
297297

298-
impl<T: Trait> StaticLookup for Module<T> {
298+
impl<T: Config> StaticLookup for Module<T> {
299299
type Source = MultiAddress<T::AccountId, T::AccountIndex>;
300300
type Target = T::AccountId;
301301

src/mock.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use sp_runtime::testing::Header;
2323
use sp_runtime::Perbill;
2424
use sp_core::H256;
2525
use frame_support::{impl_outer_origin, impl_outer_event, parameter_types, weights::Weight};
26-
use crate::{self as indices, Module, Trait};
26+
use crate::{self as indices, Module, Config};
2727
use frame_system as system;
2828
use pallet_balances as balances;
2929

@@ -49,7 +49,7 @@ parameter_types! {
4949
pub const AvailableBlockRatio: Perbill = Perbill::one();
5050
}
5151

52-
impl frame_system::Trait for Test {
52+
impl frame_system::Config for Test {
5353
type BaseCallFilter = ();
5454
type Origin = Origin;
5555
type Call = ();
@@ -81,7 +81,7 @@ parameter_types! {
8181
pub const ExistentialDeposit: u64 = 1;
8282
}
8383

84-
impl pallet_balances::Trait for Test {
84+
impl pallet_balances::Config for Test {
8585
type MaxLocks = ();
8686
type Balance = u64;
8787
type DustRemoval = ();
@@ -95,7 +95,7 @@ parameter_types! {
9595
pub const Deposit: u64 = 1;
9696
}
9797

98-
impl Trait for Test {
98+
impl Config for Test {
9999
type AccountIndex = u64;
100100
type Currency = Balances;
101101
type Deposit = Deposit;

src/weights.rs

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

5454
/// Weights for pallet_indices using the Substrate node and recommended hardware.
5555
pub struct SubstrateWeight<T>(PhantomData<T>);
56-
impl<T: frame_system::Trait> WeightInfo for SubstrateWeight<T> {
56+
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
5757
fn claim() -> Weight {
5858
(53_799_000 as Weight)
5959
.saturating_add(T::DbWeight::get().reads(1 as Weight))

0 commit comments

Comments
 (0)