Skip to content

Commit 7c66c5f

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 7b2c0e2 commit 7c66c5f

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

src/lib.rs

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

1818
//! # Sudo Module
1919
//!
20-
//! - [`sudo::Trait`](./trait.Trait.html)
20+
//! - [`sudo::Config`](./trait.Config.html)
2121
//! - [`Call`](./enum.Call.html)
2222
//!
2323
//! ## Overview
@@ -55,10 +55,10 @@
5555
//! use frame_support::{decl_module, dispatch};
5656
//! use frame_system::ensure_root;
5757
//!
58-
//! pub trait Trait: frame_system::Trait {}
58+
//! pub trait Config: frame_system::Config {}
5959
//!
6060
//! decl_module! {
61-
//! pub struct Module<T: Trait> for enum Call where origin: T::Origin {
61+
//! pub struct Module<T: Config> for enum Call where origin: T::Origin {
6262
//! #[weight = 0]
6363
//! pub fn privileged_function(origin) -> dispatch::DispatchResult {
6464
//! ensure_root(origin)?;
@@ -82,7 +82,7 @@
8282
//! * [Democracy](../pallet_democracy/index.html)
8383
//!
8484
//! [`Call`]: ./enum.Call.html
85-
//! [`Trait`]: ./trait.Trait.html
85+
//! [`Config`]: ./trait.Config.html
8686
//! [`Origin`]: https://docs.substrate.dev/docs/substrate-types
8787
8888
#![cfg_attr(not(feature = "std"), no_std)]
@@ -105,17 +105,17 @@ mod mock;
105105
#[cfg(test)]
106106
mod tests;
107107

108-
pub trait Trait: frame_system::Trait {
108+
pub trait Config: frame_system::Config {
109109
/// The overarching event type.
110-
type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
110+
type Event: From<Event<Self>> + Into<<Self as frame_system::Config>::Event>;
111111

112112
/// A sudo-able call.
113113
type Call: Parameter + UnfilteredDispatchable<Origin=Self::Origin> + GetDispatchInfo;
114114
}
115115

116116
decl_module! {
117117
/// Sudo module declaration.
118-
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
118+
pub struct Module<T: Config> for enum Call where origin: T::Origin {
119119
type Error = Error<T>;
120120

121121
fn deposit_event() = default;
@@ -131,7 +131,7 @@ decl_module! {
131131
/// - Weight of derivative `call` execution + 10,000.
132132
/// # </weight>
133133
#[weight = (call.get_dispatch_info().weight + 10_000, call.get_dispatch_info().class)]
134-
fn sudo(origin, call: Box<<T as Trait>::Call>) -> DispatchResultWithPostInfo {
134+
fn sudo(origin, call: Box<<T as Config>::Call>) -> DispatchResultWithPostInfo {
135135
// This is a public call, so we ensure that the origin is some signed account.
136136
let sender = ensure_signed(origin)?;
137137
ensure!(sender == Self::key(), Error::<T>::RequireSudo);
@@ -153,7 +153,7 @@ decl_module! {
153153
/// - The weight of this call is defined by the caller.
154154
/// # </weight>
155155
#[weight = (*_weight, call.get_dispatch_info().class)]
156-
fn sudo_unchecked_weight(origin, call: Box<<T as Trait>::Call>, _weight: Weight) -> DispatchResultWithPostInfo {
156+
fn sudo_unchecked_weight(origin, call: Box<<T as Config>::Call>, _weight: Weight) -> DispatchResultWithPostInfo {
157157
// This is a public call, so we ensure that the origin is some signed account.
158158
let sender = ensure_signed(origin)?;
159159
ensure!(sender == Self::key(), Error::<T>::RequireSudo);
@@ -206,7 +206,7 @@ decl_module! {
206206
)]
207207
fn sudo_as(origin,
208208
who: <T::Lookup as StaticLookup>::Source,
209-
call: Box<<T as Trait>::Call>
209+
call: Box<<T as Config>::Call>
210210
) -> DispatchResultWithPostInfo {
211211
// This is a public call, so we ensure that the origin is some signed account.
212212
let sender = ensure_signed(origin)?;
@@ -224,7 +224,7 @@ decl_module! {
224224
}
225225

226226
decl_event!(
227-
pub enum Event<T> where AccountId = <T as frame_system::Trait>::AccountId {
227+
pub enum Event<T> where AccountId = <T as frame_system::Config>::AccountId {
228228
/// A sudo just took place. \[result\]
229229
Sudid(DispatchResult),
230230
/// The \[sudoer\] just switched identity; the old key is supplied.
@@ -235,15 +235,15 @@ decl_event!(
235235
);
236236

237237
decl_storage! {
238-
trait Store for Module<T: Trait> as Sudo {
238+
trait Store for Module<T: Config> as Sudo {
239239
/// The `AccountId` of the sudo key.
240240
Key get(fn key) config(): T::AccountId;
241241
}
242242
}
243243

244244
decl_error! {
245245
/// Error for the Sudo module
246-
pub enum Error for Module<T: Trait> {
246+
pub enum Error for Module<T: Config> {
247247
/// Sender must be the Sudo account
248248
RequireSudo,
249249
}

src/mock.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,26 @@ pub mod logger {
3333
use super::*;
3434
use frame_system::ensure_root;
3535

36-
pub trait Trait: frame_system::Trait {
37-
type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
36+
pub trait Config: frame_system::Config {
37+
type Event: From<Event<Self>> + Into<<Self as frame_system::Config>::Event>;
3838
}
3939

4040
decl_storage! {
41-
trait Store for Module<T: Trait> as Logger {
41+
trait Store for Module<T: Config> as Logger {
4242
AccountLog get(fn account_log): Vec<T::AccountId>;
4343
I32Log get(fn i32_log): Vec<i32>;
4444
}
4545
}
4646

4747
decl_event! {
48-
pub enum Event<T> where AccountId = <T as frame_system::Trait>::AccountId {
48+
pub enum Event<T> where AccountId = <T as frame_system::Config>::AccountId {
4949
AppendI32(i32, Weight),
5050
AppendI32AndAccount(AccountId, i32, Weight),
5151
}
5252
}
5353

5454
decl_module! {
55-
pub struct Module<T: Trait> for enum Call where origin: <T as frame_system::Trait>::Origin {
55+
pub struct Module<T: Config> for enum Call where origin: <T as frame_system::Config>::Origin {
5656
fn deposit_event() = default;
5757

5858
#[weight = *weight]
@@ -118,7 +118,7 @@ impl Filter<Call> for BlockEverything {
118118
}
119119
}
120120

121-
impl frame_system::Trait for Test {
121+
impl frame_system::Config for Test {
122122
type BaseCallFilter = BlockEverything;
123123
type Origin = Origin;
124124
type Call = Call;
@@ -146,13 +146,13 @@ impl frame_system::Trait for Test {
146146
type SystemWeightInfo = ();
147147
}
148148

149-
// Implement the logger module's `Trait` on the Test runtime.
150-
impl logger::Trait for Test {
149+
// Implement the logger module's `Config` on the Test runtime.
150+
impl logger::Config for Test {
151151
type Event = TestEvent;
152152
}
153153

154-
// Implement the sudo module's `Trait` on the Test runtime.
155-
impl Trait for Test {
154+
// Implement the sudo module's `Config` on the Test runtime.
155+
impl Config for Test {
156156
type Event = TestEvent;
157157
type Call = Call;
158158
}

0 commit comments

Comments
 (0)