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
+3 -3
View File
@@ -29,7 +29,7 @@ use crate::Module as Multisig;
const SEED: u32 = 0;
fn setup_multi<T: Trait>(s: u32, z: u32)
fn setup_multi<T: Config>(s: u32, z: u32)
-> Result<(Vec<T::AccountId>, Vec<u8>), &'static str>
{
let mut signatories: Vec<T::AccountId> = Vec::new();
@@ -42,7 +42,7 @@ fn setup_multi<T: Trait>(s: u32, z: u32)
}
signatories.sort();
// Must first convert to outer call type.
let call: <T as Trait>::Call = frame_system::Call::<T>::remark(vec![0; z as usize]).into();
let call: <T as Config>::Call = frame_system::Call::<T>::remark(vec![0; z as usize]).into();
let call_data = call.encode();
return Ok((signatories, call_data))
}
@@ -55,7 +55,7 @@ benchmarks! {
let z in 0 .. 10_000;
let max_signatories = T::MaxSignatories::get().into();
let (mut signatories, _) = setup_multi::<T>(max_signatories, z)?;
let call: <T as Trait>::Call = frame_system::Call::<T>::remark(vec![0; z as usize]).into();
let call: <T as Config>::Call = frame_system::Call::<T>::remark(vec![0; z as usize]).into();
let call_hash = call.using_encoded(blake2_256);
let multi_account_id = Multisig::<T>::multi_account_id(&signatories, 1);
let caller = signatories.pop().ok_or("signatories should have len 2 or more")?;
+13 -13
View File
@@ -18,7 +18,7 @@
//! # Multisig Module
//! A module for doing multisig dispatch.
//!
//! - [`multisig::Trait`](./trait.Trait.html)
//! - [`multisig::Config`](./trait.Config.html)
//! - [`Call`](./enum.Call.html)
//!
//! ## Overview
@@ -41,7 +41,7 @@
//! * `cancel_as_multi` - Cancel a call from a composite origin.
//!
//! [`Call`]: ./enum.Call.html
//! [`Trait`]: ./trait.Trait.html
//! [`Config`]: ./trait.Config.html
// Ensure we're `no_std` when compiling for Wasm.
#![cfg_attr(not(feature = "std"), no_std)]
@@ -62,14 +62,14 @@ use frame_system::{self as system, ensure_signed, RawOrigin};
use sp_runtime::{DispatchError, DispatchResult, traits::{Dispatchable, Zero}};
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;
/// Just a bunch of bytes, but they should decode to a valid `Call`.
pub type OpaqueCall = Vec<u8>;
/// Configuration trait.
pub trait Trait: frame_system::Trait {
pub trait Config: frame_system::Config {
/// 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>;
/// The overarching call type.
type Call: Parameter + Dispatchable<Origin=Self::Origin, PostInfo=PostDispatchInfo>
@@ -123,7 +123,7 @@ pub struct Multisig<BlockNumber, Balance, AccountId> {
}
decl_storage! {
trait Store for Module<T: Trait> as Multisig {
trait Store for Module<T: Config> as Multisig {
/// The set of open multisig operations.
pub Multisigs: double_map
hasher(twox_64_concat) T::AccountId, hasher(blake2_128_concat) [u8; 32]
@@ -134,7 +134,7 @@ decl_storage! {
}
decl_error! {
pub enum Error for Module<T: Trait> {
pub enum Error for Module<T: Config> {
/// Threshold must be 2 or greater.
MinimumThreshold,
/// Call is already approved by this signatory.
@@ -169,8 +169,8 @@ decl_error! {
decl_event! {
/// Events type.
pub enum Event<T> where
AccountId = <T as system::Trait>::AccountId,
BlockNumber = <T as system::Trait>::BlockNumber,
AccountId = <T as system::Config>::AccountId,
BlockNumber = <T as system::Config>::BlockNumber,
CallHash = [u8; 32]
{
/// A new multisig operation has begun. \[approving, multisig, call_hash\]
@@ -191,7 +191,7 @@ enum CallOrHash {
}
decl_module! {
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
pub struct Module<T: Config> for enum Call where origin: T::Origin {
type Error = Error<T>;
/// Deposit one of this module's events by using the default implementation.
@@ -232,7 +232,7 @@ decl_module! {
)]
fn as_multi_threshold_1(origin,
other_signatories: Vec<T::AccountId>,
call: Box<<T as Trait>::Call>,
call: Box<<T as Config>::Call>,
) -> DispatchResultWithPostInfo {
let who = ensure_signed(origin)?;
let max_sigs = T::MaxSignatories::get() as usize;
@@ -443,7 +443,7 @@ decl_module! {
}
}
impl<T: Trait> Module<T> {
impl<T: Config> Module<T> {
/// Derive a multi-account ID from the sorted list of accounts and the threshold that are
/// required.
///
@@ -615,7 +615,7 @@ impl<T: Trait> Module<T> {
}
/// Attempt to decode and return the call, provided by the user or from storage.
fn get_call(hash: &[u8; 32], maybe_known: Option<&[u8]>) -> Option<(<T as Trait>::Call, usize)> {
fn get_call(hash: &[u8; 32], maybe_known: Option<&[u8]>) -> Option<(<T as Config>::Call, usize)> {
maybe_known.map_or_else(|| {
Calls::<T>::get(hash).and_then(|(data, ..)| {
Decode::decode(&mut &data[..]).ok().map(|d| (d, data.len()))
+3 -3
View File
@@ -59,7 +59,7 @@ parameter_types! {
pub const MaximumBlockLength: u32 = 2 * 1024;
pub const AvailableBlockRatio: Perbill = Perbill::one();
}
impl frame_system::Trait for Test {
impl frame_system::Config for Test {
type BaseCallFilter = TestBaseCallFilter;
type Origin = Origin;
type Index = u64;
@@ -89,7 +89,7 @@ impl frame_system::Trait for Test {
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 Event = TestEvent;
@@ -114,7 +114,7 @@ impl Filter<Call> for TestBaseCallFilter {
}
}
}
impl Trait for Test {
impl Config for Test {
type Event = TestEvent;
type Call = Call;
type Currency = Balances;
+1 -1
View File
@@ -58,7 +58,7 @@ pub trait WeightInfo {
/// Weights for pallet_multisig 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 as_multi_threshold_1(z: u32, ) -> Weight {
(14_183_000 as Weight)
.saturating_add((1_000 as Weight).saturating_mul(z as Weight))