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,9 +29,9 @@ use crate::Module as Vesting;
const SEED: u32 = 0;
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;
fn add_locks<T: Trait>(who: &T::AccountId, n: u8) {
fn add_locks<T: Config>(who: &T::AccountId, n: u8) {
for id in 0..n {
let lock_id = [id; 8];
let locked = 100u32;
@@ -40,7 +40,7 @@ fn add_locks<T: Trait>(who: &T::AccountId, n: u8) {
}
}
fn add_vesting_schedule<T: Trait>(who: &T::AccountId) -> Result<(), &'static str> {
fn add_vesting_schedule<T: Config>(who: &T::AccountId) -> Result<(), &'static str> {
let locked = 100u32;
let per_block = 10u32;
let starting_block = 1u32;
+15 -15
View File
@@ -17,7 +17,7 @@
//! # Vesting Module
//!
//! - [`vesting::Trait`](./trait.Trait.html)
//! - [`vesting::Config`](./trait.Config.html)
//! - [`Call`](./enum.Call.html)
//!
//! ## Overview
@@ -43,7 +43,7 @@
//! "vested" so far.
//!
//! [`Call`]: ./enum.Call.html
//! [`Trait`]: ./trait.Trait.html
//! [`Config`]: ./trait.Config.html
#![cfg_attr(not(feature = "std"), no_std)]
@@ -64,12 +64,12 @@ use frame_support::traits::{
use frame_system::{ensure_signed, ensure_root};
pub use weights::WeightInfo;
type BalanceOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
type MaxLocksOf<T> = <<T as Trait>::Currency as LockableCurrency<<T as frame_system::Trait>::AccountId>>::MaxLocks;
type BalanceOf<T> = <<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
type MaxLocksOf<T> = <<T as Config>::Currency as LockableCurrency<<T as frame_system::Config>::AccountId>>::MaxLocks;
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 currency trait.
type Currency: LockableCurrency<Self::AccountId>;
@@ -120,7 +120,7 @@ impl<
}
decl_storage! {
trait Store for Module<T: Trait> as Vesting {
trait Store for Module<T: Config> as Vesting {
/// Information regarding the vesting of a given account.
pub Vesting get(fn vesting):
map hasher(blake2_128_concat) T::AccountId
@@ -156,7 +156,7 @@ decl_storage! {
}
decl_event!(
pub enum Event<T> where AccountId = <T as frame_system::Trait>::AccountId, Balance = BalanceOf<T> {
pub enum Event<T> where AccountId = <T as frame_system::Config>::AccountId, Balance = BalanceOf<T> {
/// The amount vested has been updated. This could indicate more funds are available. The
/// balance given is the amount which is left unvested (and thus locked).
/// \[account, unvested\]
@@ -168,7 +168,7 @@ decl_event!(
decl_error! {
/// Error for the vesting module.
pub enum Error for Module<T: Trait> {
pub enum Error for Module<T: Config> {
/// The account given is not vesting.
NotVesting,
/// An existing vesting schedule already exists for this account that cannot be clobbered.
@@ -180,7 +180,7 @@ decl_error! {
decl_module! {
/// Vesting module declaration.
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>;
/// The minimum amount to be transferred to create a new vesting schedule.
@@ -309,7 +309,7 @@ decl_module! {
}
}
impl<T: Trait> Module<T> {
impl<T: Config> Module<T> {
/// (Re)set or remove the module's currency lock on `who`'s account in accordance with their
/// current unvested amount.
fn update_lock(who: T::AccountId) -> DispatchResult {
@@ -330,7 +330,7 @@ impl<T: Trait> Module<T> {
}
}
impl<T: Trait> VestingSchedule<T::AccountId> for Module<T> where
impl<T: Config> VestingSchedule<T::AccountId> for Module<T> where
BalanceOf<T>: MaybeSerializeDeserialize + Debug
{
type Moment = T::BlockNumber;
@@ -413,7 +413,7 @@ mod tests {
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 = ();
type Origin = Origin;
type Index = u64;
@@ -443,7 +443,7 @@ mod tests {
parameter_types! {
pub const MaxLocks: u32 = 10;
}
impl pallet_balances::Trait for Test {
impl pallet_balances::Config for Test {
type Balance = u64;
type DustRemoval = ();
type Event = ();
@@ -456,7 +456,7 @@ mod tests {
pub const MinVestedTransfer: u64 = 256 * 2;
pub static ExistentialDeposit: u64 = 0;
}
impl Trait for Test {
impl Config for Test {
type Event = ();
type Currency = Balances;
type BlockNumberToBalance = Identity;
+1 -1
View File
@@ -54,7 +54,7 @@ pub trait WeightInfo {
/// Weights for pallet_vesting 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 vest_locked(l: u32, ) -> Weight {
(57_472_000 as Weight)
.saturating_add((155_000 as Weight).saturating_mul(l as Weight))