mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-15 06:51:07 +00:00
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:
committed by
GitHub
parent
dd3c84c362
commit
1cbfc9257f
@@ -24,22 +24,22 @@ mod mock;
|
||||
use sp_std::prelude::*;
|
||||
use sp_std::vec;
|
||||
|
||||
use frame_system::{RawOrigin, Module as System, Trait as SystemTrait};
|
||||
use frame_system::{RawOrigin, Module as System, Config as SystemTrait};
|
||||
use frame_benchmarking::{benchmarks, account};
|
||||
use frame_support::traits::{Currency, OnInitialize};
|
||||
|
||||
use sp_runtime::{Perbill, traits::{Convert, StaticLookup, Saturating, UniqueSaturatedInto}};
|
||||
use sp_staking::offence::{ReportOffence, Offence, OffenceDetails};
|
||||
|
||||
use pallet_balances::{Trait as BalancesTrait};
|
||||
use pallet_balances::{Config as BalancesTrait};
|
||||
use pallet_babe::BabeEquivocationOffence;
|
||||
use pallet_grandpa::{GrandpaEquivocationOffence, GrandpaTimeSlot};
|
||||
use pallet_im_online::{Trait as ImOnlineTrait, Module as ImOnline, UnresponsivenessOffence};
|
||||
use pallet_offences::{Trait as OffencesTrait, Module as Offences};
|
||||
use pallet_session::historical::{Trait as HistoricalTrait, IdentificationTuple};
|
||||
use pallet_session::{Trait as SessionTrait, SessionManager};
|
||||
use pallet_im_online::{Config as ImOnlineTrait, Module as ImOnline, UnresponsivenessOffence};
|
||||
use pallet_offences::{Config as OffencesTrait, Module as Offences};
|
||||
use pallet_session::historical::{Config as HistoricalTrait, IdentificationTuple};
|
||||
use pallet_session::{Config as SessionTrait, SessionManager};
|
||||
use pallet_staking::{
|
||||
Module as Staking, Trait as StakingTrait, RewardDestination, ValidatorPrefs,
|
||||
Module as Staking, Config as StakingTrait, RewardDestination, ValidatorPrefs,
|
||||
Exposure, IndividualExposure, ElectionStatus, MAX_NOMINATIONS, Event as StakingEvent
|
||||
};
|
||||
|
||||
@@ -50,9 +50,9 @@ const MAX_OFFENDERS: u32 = 100;
|
||||
const MAX_NOMINATORS: u32 = 100;
|
||||
const MAX_DEFERRED_OFFENCES: u32 = 100;
|
||||
|
||||
pub struct Module<T: Trait>(Offences<T>);
|
||||
pub struct Module<T: Config>(Offences<T>);
|
||||
|
||||
pub trait Trait:
|
||||
pub trait Config:
|
||||
SessionTrait
|
||||
+ StakingTrait
|
||||
+ OffencesTrait
|
||||
@@ -80,17 +80,17 @@ impl<T: HistoricalTrait + OffencesTrait> IdTupleConvert<T> for T where
|
||||
type LookupSourceOf<T> = <<T as SystemTrait>::Lookup as StaticLookup>::Source;
|
||||
type BalanceOf<T> = <<T as StakingTrait>::Currency as Currency<<T as SystemTrait>::AccountId>>::Balance;
|
||||
|
||||
struct Offender<T: Trait> {
|
||||
struct Offender<T: Config> {
|
||||
pub controller: T::AccountId,
|
||||
pub stash: T::AccountId,
|
||||
pub nominator_stashes: Vec<T::AccountId>,
|
||||
}
|
||||
|
||||
fn bond_amount<T: Trait>() -> BalanceOf<T> {
|
||||
fn bond_amount<T: Config>() -> BalanceOf<T> {
|
||||
T::Currency::minimum_balance().saturating_mul(10_000u32.into())
|
||||
}
|
||||
|
||||
fn create_offender<T: Trait>(n: u32, nominators: u32) -> Result<Offender<T>, &'static str> {
|
||||
fn create_offender<T: Config>(n: u32, nominators: u32) -> Result<Offender<T>, &'static str> {
|
||||
let stash: T::AccountId = account("stash", n, SEED);
|
||||
let controller: T::AccountId = account("controller", n, SEED);
|
||||
let controller_lookup: LookupSourceOf<T> = T::Lookup::unlookup(controller.clone());
|
||||
@@ -149,7 +149,7 @@ fn create_offender<T: Trait>(n: u32, nominators: u32) -> Result<Offender<T>, &'s
|
||||
Ok(Offender { controller, stash, nominator_stashes })
|
||||
}
|
||||
|
||||
fn make_offenders<T: Trait>(num_offenders: u32, num_nominators: u32) -> Result<
|
||||
fn make_offenders<T: Config>(num_offenders: u32, num_nominators: u32) -> Result<
|
||||
(Vec<IdentificationTuple<T>>, Vec<Offender<T>>),
|
||||
&'static str
|
||||
> {
|
||||
@@ -176,7 +176,7 @@ fn make_offenders<T: Trait>(num_offenders: u32, num_nominators: u32) -> Result<
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
fn check_events<T: Trait, I: Iterator<Item = <T as SystemTrait>::Event>>(expected: I) {
|
||||
fn check_events<T: Config, I: Iterator<Item = <T as SystemTrait>::Event>>(expected: I) {
|
||||
let events = System::<T>::events() .into_iter()
|
||||
.map(|frame_system::EventRecord { event, .. }| event).collect::<Vec<_>>();
|
||||
let expected = expected.collect::<Vec<_>>();
|
||||
|
||||
@@ -40,7 +40,7 @@ parameter_types! {
|
||||
pub const MaximumBlockWeight: Weight = 2 * WEIGHT_PER_SECOND;
|
||||
}
|
||||
|
||||
impl frame_system::Trait for Test {
|
||||
impl frame_system::Config for Test {
|
||||
type BaseCallFilter = ();
|
||||
type Origin = Origin;
|
||||
type Index = AccountIndex;
|
||||
@@ -70,7 +70,7 @@ impl frame_system::Trait for Test {
|
||||
parameter_types! {
|
||||
pub const ExistentialDeposit: Balance = 10;
|
||||
}
|
||||
impl pallet_balances::Trait for Test {
|
||||
impl pallet_balances::Config for Test {
|
||||
type MaxLocks = ();
|
||||
type Balance = Balance;
|
||||
type Event = Event;
|
||||
@@ -83,13 +83,13 @@ impl pallet_balances::Trait for Test {
|
||||
parameter_types! {
|
||||
pub const MinimumPeriod: u64 = 5;
|
||||
}
|
||||
impl pallet_timestamp::Trait for Test {
|
||||
impl pallet_timestamp::Config for Test {
|
||||
type Moment = u64;
|
||||
type OnTimestampSet = ();
|
||||
type MinimumPeriod = MinimumPeriod;
|
||||
type WeightInfo = ();
|
||||
}
|
||||
impl pallet_session::historical::Trait for Test {
|
||||
impl pallet_session::historical::Config for Test {
|
||||
type FullIdentification = pallet_staking::Exposure<AccountId, Balance>;
|
||||
type FullIdentificationOf = pallet_staking::ExposureOf<Test>;
|
||||
}
|
||||
@@ -120,7 +120,7 @@ parameter_types! {
|
||||
pub const Offset: u64 = 0;
|
||||
}
|
||||
|
||||
impl pallet_session::Trait for Test {
|
||||
impl pallet_session::Config for Test {
|
||||
type SessionManager = pallet_session::historical::NoteHistoricalRoot<Test, Staking>;
|
||||
type Keys = SessionKeys;
|
||||
type ShouldEndSession = pallet_session::PeriodicSessions<Period, Offset>;
|
||||
@@ -149,7 +149,7 @@ parameter_types! {
|
||||
|
||||
pub type Extrinsic = sp_runtime::testing::TestXt<Call, ()>;
|
||||
|
||||
impl pallet_staking::Trait for Test {
|
||||
impl pallet_staking::Config for Test {
|
||||
type Currency = Balances;
|
||||
type UnixTime = pallet_timestamp::Module<Self>;
|
||||
type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote;
|
||||
@@ -174,7 +174,7 @@ impl pallet_staking::Trait for Test {
|
||||
type WeightInfo = ();
|
||||
}
|
||||
|
||||
impl pallet_im_online::Trait for Test {
|
||||
impl pallet_im_online::Config for Test {
|
||||
type AuthorityId = UintAuthorityId;
|
||||
type Event = Event;
|
||||
type SessionDuration = Period;
|
||||
@@ -187,7 +187,7 @@ parameter_types! {
|
||||
pub OffencesWeightSoftLimit: Weight = Perbill::from_percent(60) * MaximumBlockWeight::get();
|
||||
}
|
||||
|
||||
impl pallet_offences::Trait for Test {
|
||||
impl pallet_offences::Config for Test {
|
||||
type Event = Event;
|
||||
type IdentificationTuple = pallet_session::historical::IdentificationTuple<Self>;
|
||||
type OnOffenceHandler = Staking;
|
||||
@@ -199,7 +199,7 @@ impl<T> frame_system::offchain::SendTransactionTypes<T> for Test where Call: Fro
|
||||
type OverarchingCall = Call;
|
||||
}
|
||||
|
||||
impl crate::Trait for Test {}
|
||||
impl crate::Config for Test {}
|
||||
|
||||
pub type Block = sp_runtime::generic::Block<Header, UncheckedExtrinsic>;
|
||||
pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic<u32, Call, u64, ()>;
|
||||
|
||||
Reference in New Issue
Block a user