mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 03:31:05 +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
@@ -34,21 +34,21 @@ const MAX_REFERENDUMS: u32 = 99;
|
||||
const MAX_SECONDERS: u32 = 100;
|
||||
const MAX_BYTES: u32 = 16_384;
|
||||
|
||||
fn assert_last_event<T: Trait>(generic_event: <T as Trait>::Event) {
|
||||
fn assert_last_event<T: Config>(generic_event: <T as Config>::Event) {
|
||||
let events = System::<T>::events();
|
||||
let system_event: <T as frame_system::Trait>::Event = generic_event.into();
|
||||
let system_event: <T as frame_system::Config>::Event = generic_event.into();
|
||||
// compare to the last event record
|
||||
let EventRecord { event, .. } = &events[events.len() - 1];
|
||||
assert_eq!(event, &system_event);
|
||||
}
|
||||
|
||||
fn funded_account<T: Trait>(name: &'static str, index: u32) -> T::AccountId {
|
||||
fn funded_account<T: Config>(name: &'static str, index: u32) -> T::AccountId {
|
||||
let caller: T::AccountId = account(name, index, SEED);
|
||||
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
|
||||
caller
|
||||
}
|
||||
|
||||
fn add_proposal<T: Trait>(n: u32) -> Result<T::Hash, &'static str> {
|
||||
fn add_proposal<T: Config>(n: u32) -> Result<T::Hash, &'static str> {
|
||||
let other = funded_account::<T>("proposer", n);
|
||||
let value = T::MinimumDeposit::get();
|
||||
let proposal_hash: T::Hash = T::Hashing::hash_of(&n);
|
||||
@@ -62,7 +62,7 @@ fn add_proposal<T: Trait>(n: u32) -> Result<T::Hash, &'static str> {
|
||||
Ok(proposal_hash)
|
||||
}
|
||||
|
||||
fn add_referendum<T: Trait>(n: u32) -> Result<ReferendumIndex, &'static str> {
|
||||
fn add_referendum<T: Config>(n: u32) -> Result<ReferendumIndex, &'static str> {
|
||||
let proposal_hash: T::Hash = T::Hashing::hash_of(&n);
|
||||
let vote_threshold = VoteThreshold::SimpleMajority;
|
||||
|
||||
@@ -84,7 +84,7 @@ fn add_referendum<T: Trait>(n: u32) -> Result<ReferendumIndex, &'static str> {
|
||||
Ok(referendum_index)
|
||||
}
|
||||
|
||||
fn account_vote<T: Trait>(b: BalanceOf<T>) -> AccountVote<BalanceOf<T>> {
|
||||
fn account_vote<T: Config>(b: BalanceOf<T>) -> AccountVote<BalanceOf<T>> {
|
||||
let v = Vote {
|
||||
aye: true,
|
||||
conviction: Conviction::Locked1x,
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
//! # Democracy Pallet
|
||||
//!
|
||||
//! - [`democracy::Trait`](./trait.Trait.html)
|
||||
//! - [`democracy::Config`](./trait.Config.html)
|
||||
//! - [`Call`](./enum.Call.html)
|
||||
//!
|
||||
//! ## Overview
|
||||
@@ -199,13 +199,13 @@ pub type PropIndex = u32;
|
||||
/// A referendum index.
|
||||
pub type ReferendumIndex = u32;
|
||||
|
||||
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;
|
||||
|
||||
pub trait Trait: frame_system::Trait + Sized {
|
||||
pub trait Config: frame_system::Config + Sized {
|
||||
type Proposal: Parameter + Dispatchable<Origin=Self::Origin> + From<Call<Self>>;
|
||||
type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
|
||||
type Event: From<Event<Self>> + Into<<Self as frame_system::Config>::Event>;
|
||||
|
||||
/// Currency type for this module.
|
||||
type Currency: ReservableCurrency<Self::AccountId>
|
||||
@@ -338,7 +338,7 @@ enum Releases {
|
||||
}
|
||||
|
||||
decl_storage! {
|
||||
trait Store for Module<T: Trait> as Democracy {
|
||||
trait Store for Module<T: Config> as Democracy {
|
||||
// TODO: Refactor public proposal queue into its own pallet.
|
||||
// https://github.com/paritytech/substrate/issues/5322
|
||||
/// The number of (public) proposals that have been made so far.
|
||||
@@ -413,9 +413,9 @@ decl_storage! {
|
||||
decl_event! {
|
||||
pub enum Event<T> where
|
||||
Balance = BalanceOf<T>,
|
||||
<T as frame_system::Trait>::AccountId,
|
||||
<T as frame_system::Trait>::Hash,
|
||||
<T as frame_system::Trait>::BlockNumber,
|
||||
<T as frame_system::Config>::AccountId,
|
||||
<T as frame_system::Config>::Hash,
|
||||
<T as frame_system::Config>::BlockNumber,
|
||||
{
|
||||
/// A motion has been proposed by a public account. \[proposal_index, deposit\]
|
||||
Proposed(PropIndex, Balance),
|
||||
@@ -461,7 +461,7 @@ decl_event! {
|
||||
}
|
||||
|
||||
decl_error! {
|
||||
pub enum Error for Module<T: Trait> {
|
||||
pub enum Error for Module<T: Config> {
|
||||
/// Value too low
|
||||
ValueLow,
|
||||
/// Proposal does not exist
|
||||
@@ -537,7 +537,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>;
|
||||
|
||||
/// The minimum period of locking and the period between a proposal being approved and enacted.
|
||||
@@ -1168,7 +1168,7 @@ decl_module! {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Trait> Module<T> {
|
||||
impl<T: Config> Module<T> {
|
||||
// exposed immutables.
|
||||
|
||||
/// Get the amount locked in support of `proposal`; `None` if proposal isn't a valid proposal
|
||||
|
||||
@@ -92,7 +92,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 = BaseFilter;
|
||||
type Origin = Origin;
|
||||
type Index = u64;
|
||||
@@ -122,7 +122,7 @@ impl frame_system::Trait for Test {
|
||||
parameter_types! {
|
||||
pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * MaximumBlockWeight::get();
|
||||
}
|
||||
impl pallet_scheduler::Trait for Test {
|
||||
impl pallet_scheduler::Config for Test {
|
||||
type Event = Event;
|
||||
type Origin = Origin;
|
||||
type PalletsOrigin = OriginCaller;
|
||||
@@ -135,7 +135,7 @@ impl pallet_scheduler::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 = Event;
|
||||
@@ -173,7 +173,7 @@ impl Contains<u64> for OneToFive {
|
||||
fn add(_m: &u64) {}
|
||||
}
|
||||
|
||||
impl super::Trait for Test {
|
||||
impl super::Config for Test {
|
||||
type Proposal = Call;
|
||||
type Event = Event;
|
||||
type Currency = pallet_balances::Module<Self>;
|
||||
@@ -242,7 +242,7 @@ fn set_balance_proposal(value: u64) -> Vec<u8> {
|
||||
fn set_balance_proposal_is_correctly_filtered_out() {
|
||||
for i in 0..10 {
|
||||
let call = Call::decode(&mut &set_balance_proposal(i)[..]).unwrap();
|
||||
assert!(!<Test as frame_system::Trait>::BaseCallFilter::filter(&call));
|
||||
assert!(!<Test as frame_system::Config>::BaseCallFilter::filter(&call));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ pub trait WeightInfo {
|
||||
|
||||
/// Weights for pallet_democracy 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 propose() -> Weight {
|
||||
(87_883_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(3 as Weight))
|
||||
|
||||
Reference in New Issue
Block a user