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
+9 -9
View File
@@ -139,9 +139,9 @@ pub const VOTER_SET_SIZE: usize = 64;
/// NUmber of approvals grouped in one chunk.
pub const APPROVAL_SET_SIZE: usize = 8;
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;
type NegativeImbalanceOf<T> =
<<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::NegativeImbalance;
<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::NegativeImbalance;
/// Index used to access chunks.
type SetIndex = u32;
@@ -152,8 +152,8 @@ type ApprovalFlag = u32;
/// Number of approval flags that can fit into [`ApprovalFlag`] type.
const APPROVAL_FLAG_LEN: usize = 32;
pub trait Trait: frame_system::Trait {
type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
pub trait Config: frame_system::Config {
type Event: From<Event<Self>> + Into<<Self as frame_system::Config>::Event>;
/// Identifier for the elections pallet's lock
type ModuleId: Get<LockIdentifier>;
@@ -218,7 +218,7 @@ pub trait Trait: frame_system::Trait {
}
decl_storage! {
trait Store for Module<T: Trait> as Elections {
trait Store for Module<T: Config> as Elections {
// ---- parameters
/// How long to give each top candidate to present themselves after the vote ends.
@@ -286,7 +286,7 @@ decl_storage! {
decl_error! {
/// Error for the elections module.
pub enum Error for Module<T: Trait> {
pub enum Error for Module<T: Config> {
/// Reporter must be a voter.
NotVoter,
/// Target for inactivity cleanup must be active.
@@ -345,7 +345,7 @@ decl_error! {
}
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>;
/// How much should be locked up in order to submit one's candidacy. A reasonable
@@ -706,7 +706,7 @@ decl_module! {
}
decl_event!(
pub enum Event<T> where <T as frame_system::Trait>::AccountId {
pub enum Event<T> where <T as frame_system::Config>::AccountId {
/// Reaped \[voter, reaper\].
VoterReaped(AccountId, AccountId),
/// Slashed \[reaper\].
@@ -719,7 +719,7 @@ decl_event!(
}
);
impl<T: Trait> Module<T> {
impl<T: Config> Module<T> {
// exposed immutables.
/// True if we're currently in a presentation period.
+3 -3
View File
@@ -37,7 +37,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 = ();
type Origin = Origin;
type Call = Call;
@@ -68,7 +68,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 DustRemoval = ();
@@ -110,7 +110,7 @@ parameter_types!{
pub const ElectionModuleId: LockIdentifier = *b"py/elect";
}
impl elections::Trait for Test {
impl elections::Config for Test {
type Event = Event;
type Currency = Balances;
type BadPresentation = ();
+2 -2
View File
@@ -680,8 +680,8 @@ fn retracting_active_voter_should_slash_reporter() {
assert_ok!(Elections::end_block(System::block_number()));
assert_eq!(Elections::vote_index(), 2);
assert_eq!(<Test as Trait>::InactiveGracePeriod::get(), 1);
assert_eq!(<Test as Trait>::VotingPeriod::get(), 4);
assert_eq!(<Test as Config>::InactiveGracePeriod::get(), 1);
assert_eq!(<Test as Config>::VotingPeriod::get(), 4);
assert_eq!(Elections::voter_info(4), Some(VoterInfo { last_win: 1, last_active: 0, stake: 40, pot: 0 }));
assert_ok!(Elections::reap_inactive_voter(Origin::signed(4),