Skip to content

Commit 5f4141d

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 69a17bc commit 5f4141d

File tree

4 files changed

+27
-27
lines changed

4 files changed

+27
-27
lines changed

src/benchmarking.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ use crate::Module as Identity;
2929

3030
const SEED: u32 = 0;
3131

32-
fn assert_last_event<T: Trait>(generic_event: <T as Trait>::Event) {
32+
fn assert_last_event<T: Config>(generic_event: <T as Config>::Event) {
3333
let events = frame_system::Module::<T>::events();
34-
let system_event: <T as frame_system::Trait>::Event = generic_event.into();
34+
let system_event: <T as frame_system::Config>::Event = generic_event.into();
3535
// compare to the last event record
3636
let EventRecord { event, .. } = &events[events.len() - 1];
3737
assert_eq!(event, &system_event);
3838
}
3939

4040
// Adds `r` registrars to the Identity Pallet. These registrars will have set fees and fields.
41-
fn add_registrars<T: Trait>(r: u32) -> Result<(), &'static str> {
41+
fn add_registrars<T: Config>(r: u32) -> Result<(), &'static str> {
4242
for i in 0..r {
4343
let registrar: T::AccountId = account("registrar", i, SEED);
4444
let _ = T::Currency::make_free_balance_be(&registrar, BalanceOf::<T>::max_value());
@@ -57,7 +57,7 @@ fn add_registrars<T: Trait>(r: u32) -> Result<(), &'static str> {
5757

5858
// Create `s` sub-accounts for the identity of `who` and return them.
5959
// Each will have 32 bytes of raw data added to it.
60-
fn create_sub_accounts<T: Trait>(who: &T::AccountId, s: u32) -> Result<Vec<(T::AccountId, Data)>, &'static str> {
60+
fn create_sub_accounts<T: Config>(who: &T::AccountId, s: u32) -> Result<Vec<(T::AccountId, Data)>, &'static str> {
6161
let mut subs = Vec::new();
6262
let who_origin = RawOrigin::Signed(who.clone());
6363
let data = Data::Raw(vec![0; 32]);
@@ -77,7 +77,7 @@ fn create_sub_accounts<T: Trait>(who: &T::AccountId, s: u32) -> Result<Vec<(T::A
7777

7878
// Adds `s` sub-accounts to the identity of `who`. Each will have 32 bytes of raw data added to it.
7979
// This additionally returns the vector of sub-accounts so it can be modified if needed.
80-
fn add_sub_accounts<T: Trait>(who: &T::AccountId, s: u32) -> Result<Vec<(T::AccountId, Data)>, &'static str> {
80+
fn add_sub_accounts<T: Config>(who: &T::AccountId, s: u32) -> Result<Vec<(T::AccountId, Data)>, &'static str> {
8181
let who_origin = RawOrigin::Signed(who.clone());
8282
let subs = create_sub_accounts::<T>(who, s)?;
8383

@@ -88,7 +88,7 @@ fn add_sub_accounts<T: Trait>(who: &T::AccountId, s: u32) -> Result<Vec<(T::Acco
8888

8989
// This creates an `IdentityInfo` object with `num_fields` extra fields.
9090
// All data is pre-populated with some arbitrary bytes.
91-
fn create_identity_info<T: Trait>(num_fields: u32) -> IdentityInfo {
91+
fn create_identity_info<T: Config>(num_fields: u32) -> IdentityInfo {
9292
let data = Data::Raw(vec![0; 32]);
9393

9494
let info = IdentityInfo {
@@ -121,7 +121,7 @@ benchmarks! {
121121
// Create their main identity with x additional fields
122122
let info = create_identity_info::<T>(x);
123123
let caller: T::AccountId = whitelisted_caller();
124-
let caller_origin = <T as frame_system::Trait>::Origin::from(RawOrigin::Signed(caller));
124+
let caller_origin = <T as frame_system::Config>::Origin::from(RawOrigin::Signed(caller));
125125
Identity::<T>::set_identity(caller_origin, info)?;
126126
};
127127
}
@@ -143,7 +143,7 @@ benchmarks! {
143143
// The target user
144144
let caller: T::AccountId = whitelisted_caller();
145145
let caller_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(caller.clone());
146-
let caller_origin: <T as frame_system::Trait>::Origin = RawOrigin::Signed(caller.clone()).into();
146+
let caller_origin: <T as frame_system::Config>::Origin = RawOrigin::Signed(caller.clone()).into();
147147
let _ = T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
148148

149149
// Add an initial identity
@@ -200,7 +200,7 @@ benchmarks! {
200200

201201
clear_identity {
202202
let caller: T::AccountId = whitelisted_caller();
203-
let caller_origin = <T as frame_system::Trait>::Origin::from(RawOrigin::Signed(caller.clone()));
203+
let caller_origin = <T as frame_system::Config>::Origin::from(RawOrigin::Signed(caller.clone()));
204204
let caller_lookup = <T::Lookup as StaticLookup>::unlookup(caller.clone());
205205
let _ = T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
206206

@@ -237,7 +237,7 @@ benchmarks! {
237237

238238
cancel_request {
239239
let caller: T::AccountId = whitelisted_caller();
240-
let caller_origin = <T as frame_system::Trait>::Origin::from(RawOrigin::Signed(caller.clone()));
240+
let caller_origin = <T as frame_system::Config>::Origin::from(RawOrigin::Signed(caller.clone()));
241241
let _ = T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
242242

243243
let r in ...;
@@ -300,7 +300,7 @@ benchmarks! {
300300
provide_judgement {
301301
// The user
302302
let user: T::AccountId = account("user", r, SEED);
303-
let user_origin = <T as frame_system::Trait>::Origin::from(RawOrigin::Signed(user.clone()));
303+
let user_origin = <T as frame_system::Config>::Origin::from(RawOrigin::Signed(user.clone()));
304304
let user_lookup = <T::Lookup as StaticLookup>::unlookup(user.clone());
305305
let _ = T::Currency::make_free_balance_be(&user, BalanceOf::<T>::max_value());
306306

@@ -328,7 +328,7 @@ benchmarks! {
328328
let x in _ .. _ => {};
329329

330330
let target: T::AccountId = account("target", 0, SEED);
331-
let target_origin: <T as frame_system::Trait>::Origin = RawOrigin::Signed(target.clone()).into();
331+
let target_origin: <T as frame_system::Config>::Origin = RawOrigin::Signed(target.clone()).into();
332332
let target_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(target.clone());
333333
let _ = T::Currency::make_free_balance_be(&target, BalanceOf::<T>::max_value());
334334

src/lib.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
//! # Identity Module
1919
//!
20-
//! - [`identity::Trait`](./trait.Trait.html)
20+
//! - [`identity::Config`](./trait.Config.html)
2121
//! - [`Call`](./enum.Call.html)
2222
//!
2323
//! ## Overview
@@ -68,7 +68,7 @@
6868
//! * `kill_identity` - Forcibly remove the associated identity; the deposit is lost.
6969
//!
7070
//! [`Call`]: ./enum.Call.html
71-
//! [`Trait`]: ./trait.Trait.html
71+
//! [`Config`]: ./trait.Config.html
7272
7373
#![cfg_attr(not(feature = "std"), no_std)]
7474

@@ -91,12 +91,12 @@ use frame_support::{
9191
use frame_system::ensure_signed;
9292
pub use weights::WeightInfo;
9393

94-
type BalanceOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
95-
type NegativeImbalanceOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::NegativeImbalance;
94+
type BalanceOf<T> = <<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
95+
type NegativeImbalanceOf<T> = <<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::NegativeImbalance;
9696

97-
pub trait Trait: frame_system::Trait {
97+
pub trait Config: frame_system::Config {
9898
/// The overarching event type.
99-
type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
99+
type Event: From<Event<Self>> + Into<<Self as frame_system::Config>::Event>;
100100

101101
/// The currency trait.
102102
type Currency: ReservableCurrency<Self::AccountId>;
@@ -399,7 +399,7 @@ pub struct RegistrarInfo<
399399
}
400400

401401
decl_storage! {
402-
trait Store for Module<T: Trait> as Identity {
402+
trait Store for Module<T: Config> as Identity {
403403
/// Information that is pertinent to identify the entity behind an account.
404404
///
405405
/// TWOX-NOTE: OK ― `AccountId` is a secure hash.
@@ -428,7 +428,7 @@ decl_storage! {
428428
}
429429

430430
decl_event!(
431-
pub enum Event<T> where AccountId = <T as frame_system::Trait>::AccountId, Balance = BalanceOf<T> {
431+
pub enum Event<T> where AccountId = <T as frame_system::Config>::AccountId, Balance = BalanceOf<T> {
432432
/// A name was set or reset (which will remove all judgements). \[who\]
433433
IdentitySet(AccountId),
434434
/// A name was cleared, and the given balance returned. \[who, deposit\]
@@ -456,7 +456,7 @@ decl_event!(
456456

457457
decl_error! {
458458
/// Error for the identity module.
459-
pub enum Error for Module<T: Trait> {
459+
pub enum Error for Module<T: Config> {
460460
/// Too many subs-accounts.
461461
TooManySubAccounts,
462462
/// Account isn't found.
@@ -494,7 +494,7 @@ decl_error! {
494494

495495
decl_module! {
496496
/// Identity module declaration.
497-
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
497+
pub struct Module<T: Config> for enum Call where origin: T::Origin {
498498
/// The amount held on deposit for a registered identity.
499499
const BasicDeposit: BalanceOf<T> = T::BasicDeposit::get();
500500

@@ -1125,7 +1125,7 @@ decl_module! {
11251125
}
11261126
}
11271127

1128-
impl<T: Trait> Module<T> {
1128+
impl<T: Config> Module<T> {
11291129
/// Get the subs of an account.
11301130
pub fn subs(who: &T::AccountId) -> Vec<(T::AccountId, Data)> {
11311131
SubsOf::<T>::get(who).1

src/tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ parameter_types! {
4242
pub const MaximumBlockLength: u32 = 2 * 1024;
4343
pub const AvailableBlockRatio: Perbill = Perbill::one();
4444
}
45-
impl frame_system::Trait for Test {
45+
impl frame_system::Config for Test {
4646
type BaseCallFilter = ();
4747
type Origin = Origin;
4848
type Index = u64;
@@ -72,7 +72,7 @@ impl frame_system::Trait for Test {
7272
parameter_types! {
7373
pub const ExistentialDeposit: u64 = 1;
7474
}
75-
impl pallet_balances::Trait for Test {
75+
impl pallet_balances::Config for Test {
7676
type Balance = u64;
7777
type Event = ();
7878
type DustRemoval = ();
@@ -103,7 +103,7 @@ type EnsureTwoOrRoot = EnsureOneOf<
103103
EnsureRoot<u64>,
104104
EnsureSignedBy<Two, u64>
105105
>;
106-
impl Trait for Test {
106+
impl Config for Test {
107107
type Event = ();
108108
type Currency = Balances;
109109
type Slashed = ();

src/weights.rs

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

6565
/// Weights for pallet_identity using the Substrate node and recommended hardware.
6666
pub struct SubstrateWeight<T>(PhantomData<T>);
67-
impl<T: frame_system::Trait> WeightInfo for SubstrateWeight<T> {
67+
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
6868
fn add_registrar(r: u32, ) -> Weight {
6969
(28_965_000 as Weight)
7070
.saturating_add((421_000 as Weight).saturating_mul(r as Weight))

0 commit comments

Comments
 (0)