mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 19:11:04 +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
@@ -19,7 +19,7 @@
|
||||
//!
|
||||
//! The Staking module is used to manage funds at stake by network maintainers.
|
||||
//!
|
||||
//! - [`staking::Trait`](./trait.Trait.html)
|
||||
//! - [`staking::Config`](./trait.Config.html)
|
||||
//! - [`Call`](./enum.Call.html)
|
||||
//! - [`Module`](./struct.Module.html)
|
||||
//!
|
||||
@@ -107,7 +107,7 @@
|
||||
//!
|
||||
//! Rewards must be claimed for each era before it gets too old by `$HISTORY_DEPTH` using the
|
||||
//! `payout_stakers` call. Any account can call `payout_stakers`, which pays the reward to the
|
||||
//! validator as well as its nominators. Only the [`Trait::MaxNominatorRewardedPerValidator`]
|
||||
//! validator as well as its nominators. Only the [`Config::MaxNominatorRewardedPerValidator`]
|
||||
//! biggest stakers can claim their reward. This is to limit the i/o cost to mutate storage for each
|
||||
//! nominator's account.
|
||||
//!
|
||||
@@ -154,10 +154,10 @@
|
||||
//! use frame_system::ensure_signed;
|
||||
//! use pallet_staking::{self as staking};
|
||||
//!
|
||||
//! pub trait Trait: staking::Trait {}
|
||||
//! pub trait Config: staking::Config {}
|
||||
//!
|
||||
//! 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 {
|
||||
//! /// Reward a validator.
|
||||
//! #[weight = 0]
|
||||
//! pub fn reward_myself(origin) -> dispatch::DispatchResult {
|
||||
@@ -175,7 +175,7 @@
|
||||
//! ### Era payout
|
||||
//!
|
||||
//! The era payout is computed using yearly inflation curve defined at
|
||||
//! [`T::RewardCurve`](./trait.Trait.html#associatedtype.RewardCurve) as such:
|
||||
//! [`T::RewardCurve`](./trait.Config.html#associatedtype.RewardCurve) as such:
|
||||
//!
|
||||
//! ```nocompile
|
||||
//! staker_payout = yearly_inflation(npos_token_staked / total_tokens) * total_tokens / era_per_year
|
||||
@@ -186,7 +186,7 @@
|
||||
//! remaining_payout = max_yearly_inflation * total_tokens / era_per_year - staker_payout
|
||||
//! ```
|
||||
//! The remaining reward is send to the configurable end-point
|
||||
//! [`T::RewardRemainder`](./trait.Trait.html#associatedtype.RewardRemainder).
|
||||
//! [`T::RewardRemainder`](./trait.Config.html#associatedtype.RewardRemainder).
|
||||
//!
|
||||
//! ### Reward Calculation
|
||||
//!
|
||||
@@ -232,7 +232,7 @@
|
||||
//!
|
||||
//! The controller account can free a portion (or all) of the funds using the
|
||||
//! [`unbond`](enum.Call.html#variant.unbond) call. Note that the funds are not immediately
|
||||
//! accessible. Instead, a duration denoted by [`BondingDuration`](./trait.Trait.html#associatedtype.BondingDuration)
|
||||
//! accessible. Instead, a duration denoted by [`BondingDuration`](./trait.Config.html#associatedtype.BondingDuration)
|
||||
//! (in number of eras) must pass until the funds can actually be removed. Once the
|
||||
//! `BondingDuration` is over, the [`withdraw_unbonded`](./enum.Call.html#variant.withdraw_unbonded)
|
||||
//! call can be used to actually withdraw the funds.
|
||||
@@ -385,12 +385,12 @@ pub type OffchainAccuracy = PerU16;
|
||||
|
||||
/// The balance type of this module.
|
||||
pub type BalanceOf<T> =
|
||||
<<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
|
||||
<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
|
||||
|
||||
type PositiveImbalanceOf<T> =
|
||||
<<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::PositiveImbalance;
|
||||
<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::PositiveImbalance;
|
||||
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;
|
||||
|
||||
/// Information regarding the active era (era in used in session).
|
||||
#[derive(Encode, Decode, RuntimeDebug)]
|
||||
@@ -732,8 +732,8 @@ impl<BlockNumber> Default for ElectionStatus<BlockNumber> {
|
||||
|
||||
/// Means for interacting with a specialized version of the `session` trait.
|
||||
///
|
||||
/// This is needed because `Staking` sets the `ValidatorIdOf` of the `pallet_session::Trait`
|
||||
pub trait SessionInterface<AccountId>: frame_system::Trait {
|
||||
/// This is needed because `Staking` sets the `ValidatorIdOf` of the `pallet_session::Config`
|
||||
pub trait SessionInterface<AccountId>: frame_system::Config {
|
||||
/// Disable a given validator by stash ID.
|
||||
///
|
||||
/// Returns `true` if new era should be forced at the end of this session.
|
||||
@@ -746,22 +746,22 @@ pub trait SessionInterface<AccountId>: frame_system::Trait {
|
||||
fn prune_historical_up_to(up_to: SessionIndex);
|
||||
}
|
||||
|
||||
impl<T: Trait> SessionInterface<<T as frame_system::Trait>::AccountId> for T where
|
||||
T: pallet_session::Trait<ValidatorId = <T as frame_system::Trait>::AccountId>,
|
||||
T: pallet_session::historical::Trait<
|
||||
FullIdentification = Exposure<<T as frame_system::Trait>::AccountId, BalanceOf<T>>,
|
||||
impl<T: Config> SessionInterface<<T as frame_system::Config>::AccountId> for T where
|
||||
T: pallet_session::Config<ValidatorId = <T as frame_system::Config>::AccountId>,
|
||||
T: pallet_session::historical::Config<
|
||||
FullIdentification = Exposure<<T as frame_system::Config>::AccountId, BalanceOf<T>>,
|
||||
FullIdentificationOf = ExposureOf<T>,
|
||||
>,
|
||||
T::SessionHandler: pallet_session::SessionHandler<<T as frame_system::Trait>::AccountId>,
|
||||
T::SessionManager: pallet_session::SessionManager<<T as frame_system::Trait>::AccountId>,
|
||||
T::SessionHandler: pallet_session::SessionHandler<<T as frame_system::Config>::AccountId>,
|
||||
T::SessionManager: pallet_session::SessionManager<<T as frame_system::Config>::AccountId>,
|
||||
T::ValidatorIdOf:
|
||||
Convert<<T as frame_system::Trait>::AccountId, Option<<T as frame_system::Trait>::AccountId>>,
|
||||
Convert<<T as frame_system::Config>::AccountId, Option<<T as frame_system::Config>::AccountId>>,
|
||||
{
|
||||
fn disable_validator(validator: &<T as frame_system::Trait>::AccountId) -> Result<bool, ()> {
|
||||
fn disable_validator(validator: &<T as frame_system::Config>::AccountId) -> Result<bool, ()> {
|
||||
<pallet_session::Module<T>>::disable(validator)
|
||||
}
|
||||
|
||||
fn validators() -> Vec<<T as frame_system::Trait>::AccountId> {
|
||||
fn validators() -> Vec<<T as frame_system::Config>::AccountId> {
|
||||
<pallet_session::Module<T>>::validators()
|
||||
}
|
||||
|
||||
@@ -770,7 +770,7 @@ impl<T: Trait> SessionInterface<<T as frame_system::Trait>::AccountId> for T whe
|
||||
}
|
||||
}
|
||||
|
||||
pub trait Trait: frame_system::Trait + SendTransactionTypes<Call<Self>> {
|
||||
pub trait Config: frame_system::Config + SendTransactionTypes<Call<Self>> {
|
||||
/// The staking balance.
|
||||
type Currency: LockableCurrency<Self::AccountId, Moment=Self::BlockNumber>;
|
||||
|
||||
@@ -792,7 +792,7 @@ pub trait Trait: frame_system::Trait + SendTransactionTypes<Call<Self>> {
|
||||
type RewardRemainder: OnUnbalanced<NegativeImbalanceOf<Self>>;
|
||||
|
||||
/// 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>;
|
||||
|
||||
/// Handler for the unbalanced reduction when slashing a staker.
|
||||
type Slash: OnUnbalanced<NegativeImbalanceOf<Self>>;
|
||||
@@ -904,7 +904,7 @@ impl Default for Releases {
|
||||
}
|
||||
|
||||
decl_storage! {
|
||||
trait Store for Module<T: Trait> as Staking {
|
||||
trait Store for Module<T: Config> as Staking {
|
||||
/// Number of eras to keep in history.
|
||||
///
|
||||
/// Information is kept for eras in `[current_era - history_depth; current_era]`.
|
||||
@@ -1121,7 +1121,7 @@ decl_storage! {
|
||||
}
|
||||
|
||||
decl_event!(
|
||||
pub enum Event<T> where Balance = BalanceOf<T>, <T as frame_system::Trait>::AccountId {
|
||||
pub enum Event<T> where Balance = BalanceOf<T>, <T as frame_system::Config>::AccountId {
|
||||
/// The era payout has been set; the first balance is the validator-payout; the second is
|
||||
/// the remainder from the maximum amount of reward.
|
||||
/// \[era_index, validator_payout, remainder\]
|
||||
@@ -1153,7 +1153,7 @@ decl_event!(
|
||||
|
||||
decl_error! {
|
||||
/// Error for the staking module.
|
||||
pub enum Error for Module<T: Trait> {
|
||||
pub enum Error for Module<T: Config> {
|
||||
/// Not a controller account.
|
||||
NotController,
|
||||
/// Not a stash account.
|
||||
@@ -1223,7 +1223,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 {
|
||||
/// Number of sessions per era.
|
||||
const SessionsPerEra: SessionIndex = T::SessionsPerEra::get();
|
||||
|
||||
@@ -2159,7 +2159,7 @@ decl_module! {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Trait> Module<T> {
|
||||
impl<T: Config> Module<T> {
|
||||
/// The total balance that can be slashed from a stash account as of right now.
|
||||
pub fn slashable_balance_of(stash: &T::AccountId) -> BalanceOf<T> {
|
||||
// Weight note: consider making the stake accessible through stash.
|
||||
@@ -3083,7 +3083,7 @@ impl<T: Trait> Module<T> {
|
||||
///
|
||||
/// Once the first new_session is planned, all session must start and then end in order, though
|
||||
/// some session can lag in between the newest session planned and the latest session started.
|
||||
impl<T: Trait> pallet_session::SessionManager<T::AccountId> for Module<T> {
|
||||
impl<T: Config> pallet_session::SessionManager<T::AccountId> for Module<T> {
|
||||
fn new_session(new_index: SessionIndex) -> Option<Vec<T::AccountId>> {
|
||||
Self::new_session(new_index)
|
||||
}
|
||||
@@ -3095,7 +3095,7 @@ impl<T: Trait> pallet_session::SessionManager<T::AccountId> for Module<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Trait> historical::SessionManager<T::AccountId, Exposure<T::AccountId, BalanceOf<T>>> for Module<T> {
|
||||
impl<T: Config> historical::SessionManager<T::AccountId, Exposure<T::AccountId, BalanceOf<T>>> for Module<T> {
|
||||
fn new_session(new_index: SessionIndex)
|
||||
-> Option<Vec<(T::AccountId, Exposure<T::AccountId, BalanceOf<T>>)>>
|
||||
{
|
||||
@@ -3124,7 +3124,7 @@ impl<T: Trait> historical::SessionManager<T::AccountId, Exposure<T::AccountId, B
|
||||
/// * 1 point to the producer of each referenced uncle block.
|
||||
impl<T> pallet_authorship::EventHandler<T::AccountId, T::BlockNumber> for Module<T>
|
||||
where
|
||||
T: Trait + pallet_authorship::Trait + pallet_session::Trait
|
||||
T: Config + pallet_authorship::Config + pallet_session::Config
|
||||
{
|
||||
fn note_author(author: T::AccountId) {
|
||||
Self::reward_by_ids(vec![(author, 20)])
|
||||
@@ -3141,7 +3141,7 @@ impl<T> pallet_authorship::EventHandler<T::AccountId, T::BlockNumber> for Module
|
||||
/// if any.
|
||||
pub struct StashOf<T>(sp_std::marker::PhantomData<T>);
|
||||
|
||||
impl<T: Trait> Convert<T::AccountId, Option<T::AccountId>> for StashOf<T> {
|
||||
impl<T: Config> Convert<T::AccountId, Option<T::AccountId>> for StashOf<T> {
|
||||
fn convert(controller: T::AccountId) -> Option<T::AccountId> {
|
||||
<Module<T>>::ledger(&controller).map(|l| l.stash)
|
||||
}
|
||||
@@ -3154,7 +3154,7 @@ impl<T: Trait> Convert<T::AccountId, Option<T::AccountId>> for StashOf<T> {
|
||||
/// `active_era`. It can differ from the latest planned exposure in `current_era`.
|
||||
pub struct ExposureOf<T>(sp_std::marker::PhantomData<T>);
|
||||
|
||||
impl<T: Trait> Convert<T::AccountId, Option<Exposure<T::AccountId, BalanceOf<T>>>>
|
||||
impl<T: Config> Convert<T::AccountId, Option<Exposure<T::AccountId, BalanceOf<T>>>>
|
||||
for ExposureOf<T>
|
||||
{
|
||||
fn convert(validator: T::AccountId) -> Option<Exposure<T::AccountId, BalanceOf<T>>> {
|
||||
@@ -3167,19 +3167,19 @@ impl<T: Trait> Convert<T::AccountId, Option<Exposure<T::AccountId, BalanceOf<T>>
|
||||
}
|
||||
|
||||
/// This is intended to be used with `FilterHistoricalOffences`.
|
||||
impl <T: Trait>
|
||||
impl <T: Config>
|
||||
OnOffenceHandler<T::AccountId, pallet_session::historical::IdentificationTuple<T>, Weight>
|
||||
for Module<T> where
|
||||
T: pallet_session::Trait<ValidatorId = <T as frame_system::Trait>::AccountId>,
|
||||
T: pallet_session::historical::Trait<
|
||||
FullIdentification = Exposure<<T as frame_system::Trait>::AccountId, BalanceOf<T>>,
|
||||
T: pallet_session::Config<ValidatorId = <T as frame_system::Config>::AccountId>,
|
||||
T: pallet_session::historical::Config<
|
||||
FullIdentification = Exposure<<T as frame_system::Config>::AccountId, BalanceOf<T>>,
|
||||
FullIdentificationOf = ExposureOf<T>,
|
||||
>,
|
||||
T::SessionHandler: pallet_session::SessionHandler<<T as frame_system::Trait>::AccountId>,
|
||||
T::SessionManager: pallet_session::SessionManager<<T as frame_system::Trait>::AccountId>,
|
||||
T::SessionHandler: pallet_session::SessionHandler<<T as frame_system::Config>::AccountId>,
|
||||
T::SessionManager: pallet_session::SessionManager<<T as frame_system::Config>::AccountId>,
|
||||
T::ValidatorIdOf: Convert<
|
||||
<T as frame_system::Trait>::AccountId,
|
||||
Option<<T as frame_system::Trait>::AccountId>,
|
||||
<T as frame_system::Config>::AccountId,
|
||||
Option<<T as frame_system::Config>::AccountId>,
|
||||
>,
|
||||
{
|
||||
fn on_offence(
|
||||
@@ -3310,7 +3310,7 @@ pub struct FilterHistoricalOffences<T, R> {
|
||||
|
||||
impl<T, Reporter, Offender, R, O> ReportOffence<Reporter, Offender, O>
|
||||
for FilterHistoricalOffences<Module<T>, R> where
|
||||
T: Trait,
|
||||
T: Config,
|
||||
R: ReportOffence<Reporter, Offender, O>,
|
||||
O: Offence<Offender>,
|
||||
{
|
||||
@@ -3335,7 +3335,7 @@ impl<T, Reporter, Offender, R, O> ReportOffence<Reporter, Offender, O>
|
||||
}
|
||||
|
||||
#[allow(deprecated)]
|
||||
impl<T: Trait> frame_support::unsigned::ValidateUnsigned for Module<T> {
|
||||
impl<T: Config> frame_support::unsigned::ValidateUnsigned for Module<T> {
|
||||
type Call = Call<T>;
|
||||
fn validate_unsigned(source: TransactionSource, call: &Self::Call) -> TransactionValidity {
|
||||
if let Call::submit_election_solution_unsigned(
|
||||
|
||||
Reference in New Issue
Block a user