Skip to content

Commit e70edd5

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 4159a7a commit e70edd5

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

src/benchmarking.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use crate::Module as Multisig;
2929

3030
const SEED: u32 = 0;
3131

32-
fn setup_multi<T: Trait>(s: u32, z: u32)
32+
fn setup_multi<T: Config>(s: u32, z: u32)
3333
-> Result<(Vec<T::AccountId>, Vec<u8>), &'static str>
3434
{
3535
let mut signatories: Vec<T::AccountId> = Vec::new();
@@ -42,7 +42,7 @@ fn setup_multi<T: Trait>(s: u32, z: u32)
4242
}
4343
signatories.sort();
4444
// Must first convert to outer call type.
45-
let call: <T as Trait>::Call = frame_system::Call::<T>::remark(vec![0; z as usize]).into();
45+
let call: <T as Config>::Call = frame_system::Call::<T>::remark(vec![0; z as usize]).into();
4646
let call_data = call.encode();
4747
return Ok((signatories, call_data))
4848
}
@@ -55,7 +55,7 @@ benchmarks! {
5555
let z in 0 .. 10_000;
5656
let max_signatories = T::MaxSignatories::get().into();
5757
let (mut signatories, _) = setup_multi::<T>(max_signatories, z)?;
58-
let call: <T as Trait>::Call = frame_system::Call::<T>::remark(vec![0; z as usize]).into();
58+
let call: <T as Config>::Call = frame_system::Call::<T>::remark(vec![0; z as usize]).into();
5959
let call_hash = call.using_encoded(blake2_256);
6060
let multi_account_id = Multisig::<T>::multi_account_id(&signatories, 1);
6161
let caller = signatories.pop().ok_or("signatories should have len 2 or more")?;

src/lib.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
//! # Multisig Module
1919
//! A module for doing multisig dispatch.
2020
//!
21-
//! - [`multisig::Trait`](./trait.Trait.html)
21+
//! - [`multisig::Config`](./trait.Config.html)
2222
//! - [`Call`](./enum.Call.html)
2323
//!
2424
//! ## Overview
@@ -41,7 +41,7 @@
4141
//! * `cancel_as_multi` - Cancel a call from a composite origin.
4242
//!
4343
//! [`Call`]: ./enum.Call.html
44-
//! [`Trait`]: ./trait.Trait.html
44+
//! [`Config`]: ./trait.Config.html
4545
4646
// Ensure we're `no_std` when compiling for Wasm.
4747
#![cfg_attr(not(feature = "std"), no_std)]
@@ -62,14 +62,14 @@ use frame_system::{self as system, ensure_signed, RawOrigin};
6262
use sp_runtime::{DispatchError, DispatchResult, traits::{Dispatchable, Zero}};
6363
pub use weights::WeightInfo;
6464

65-
type BalanceOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
65+
type BalanceOf<T> = <<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
6666
/// Just a bunch of bytes, but they should decode to a valid `Call`.
6767
pub type OpaqueCall = Vec<u8>;
6868

6969
/// Configuration trait.
70-
pub trait Trait: frame_system::Trait {
70+
pub trait Config: frame_system::Config {
7171
/// The overarching event type.
72-
type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
72+
type Event: From<Event<Self>> + Into<<Self as frame_system::Config>::Event>;
7373

7474
/// The overarching call type.
7575
type Call: Parameter + Dispatchable<Origin=Self::Origin, PostInfo=PostDispatchInfo>
@@ -123,7 +123,7 @@ pub struct Multisig<BlockNumber, Balance, AccountId> {
123123
}
124124

125125
decl_storage! {
126-
trait Store for Module<T: Trait> as Multisig {
126+
trait Store for Module<T: Config> as Multisig {
127127
/// The set of open multisig operations.
128128
pub Multisigs: double_map
129129
hasher(twox_64_concat) T::AccountId, hasher(blake2_128_concat) [u8; 32]
@@ -134,7 +134,7 @@ decl_storage! {
134134
}
135135

136136
decl_error! {
137-
pub enum Error for Module<T: Trait> {
137+
pub enum Error for Module<T: Config> {
138138
/// Threshold must be 2 or greater.
139139
MinimumThreshold,
140140
/// Call is already approved by this signatory.
@@ -169,8 +169,8 @@ decl_error! {
169169
decl_event! {
170170
/// Events type.
171171
pub enum Event<T> where
172-
AccountId = <T as system::Trait>::AccountId,
173-
BlockNumber = <T as system::Trait>::BlockNumber,
172+
AccountId = <T as system::Config>::AccountId,
173+
BlockNumber = <T as system::Config>::BlockNumber,
174174
CallHash = [u8; 32]
175175
{
176176
/// A new multisig operation has begun. \[approving, multisig, call_hash\]
@@ -191,7 +191,7 @@ enum CallOrHash {
191191
}
192192

193193
decl_module! {
194-
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
194+
pub struct Module<T: Config> for enum Call where origin: T::Origin {
195195
type Error = Error<T>;
196196

197197
/// Deposit one of this module's events by using the default implementation.
@@ -232,7 +232,7 @@ decl_module! {
232232
)]
233233
fn as_multi_threshold_1(origin,
234234
other_signatories: Vec<T::AccountId>,
235-
call: Box<<T as Trait>::Call>,
235+
call: Box<<T as Config>::Call>,
236236
) -> DispatchResultWithPostInfo {
237237
let who = ensure_signed(origin)?;
238238
let max_sigs = T::MaxSignatories::get() as usize;
@@ -443,7 +443,7 @@ decl_module! {
443443
}
444444
}
445445

446-
impl<T: Trait> Module<T> {
446+
impl<T: Config> Module<T> {
447447
/// Derive a multi-account ID from the sorted list of accounts and the threshold that are
448448
/// required.
449449
///
@@ -615,7 +615,7 @@ impl<T: Trait> Module<T> {
615615
}
616616

617617
/// Attempt to decode and return the call, provided by the user or from storage.
618-
fn get_call(hash: &[u8; 32], maybe_known: Option<&[u8]>) -> Option<(<T as Trait>::Call, usize)> {
618+
fn get_call(hash: &[u8; 32], maybe_known: Option<&[u8]>) -> Option<(<T as Config>::Call, usize)> {
619619
maybe_known.map_or_else(|| {
620620
Calls::<T>::get(hash).and_then(|(data, ..)| {
621621
Decode::decode(&mut &data[..]).ok().map(|d| (d, data.len()))

src/tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ parameter_types! {
5959
pub const MaximumBlockLength: u32 = 2 * 1024;
6060
pub const AvailableBlockRatio: Perbill = Perbill::one();
6161
}
62-
impl frame_system::Trait for Test {
62+
impl frame_system::Config for Test {
6363
type BaseCallFilter = TestBaseCallFilter;
6464
type Origin = Origin;
6565
type Index = u64;
@@ -89,7 +89,7 @@ impl frame_system::Trait for Test {
8989
parameter_types! {
9090
pub const ExistentialDeposit: u64 = 1;
9191
}
92-
impl pallet_balances::Trait for Test {
92+
impl pallet_balances::Config for Test {
9393
type MaxLocks = ();
9494
type Balance = u64;
9595
type Event = TestEvent;
@@ -114,7 +114,7 @@ impl Filter<Call> for TestBaseCallFilter {
114114
}
115115
}
116116
}
117-
impl Trait for Test {
117+
impl Config for Test {
118118
type Event = TestEvent;
119119
type Call = Call;
120120
type Currency = Balances;

src/weights.rs

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

5959
/// Weights for pallet_multisig using the Substrate node and recommended hardware.
6060
pub struct SubstrateWeight<T>(PhantomData<T>);
61-
impl<T: frame_system::Trait> WeightInfo for SubstrateWeight<T> {
61+
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
6262
fn as_multi_threshold_1(z: u32, ) -> Weight {
6363
(14_183_000 as Weight)
6464
.saturating_add((1_000 as Weight).saturating_mul(z as Weight))

0 commit comments

Comments
 (0)