mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 06:21:11 +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
@@ -30,7 +30,7 @@ use crate::Module as Treasury;
|
||||
const SEED: u32 = 0;
|
||||
|
||||
// Create the pre-requisite information needed to create a treasury `propose_spend`.
|
||||
fn setup_proposal<T: Trait<I>, I: Instance>(u: u32) -> (
|
||||
fn setup_proposal<T: Config<I>, I: Instance>(u: u32) -> (
|
||||
T::AccountId,
|
||||
BalanceOf<T, I>,
|
||||
<T::Lookup as StaticLookup>::Source,
|
||||
@@ -44,7 +44,7 @@ fn setup_proposal<T: Trait<I>, I: Instance>(u: u32) -> (
|
||||
}
|
||||
|
||||
// Create the pre-requisite information needed to create a `report_awesome`.
|
||||
fn setup_awesome<T: Trait<I>, I: Instance>(length: u32) -> (T::AccountId, Vec<u8>, T::AccountId) {
|
||||
fn setup_awesome<T: Config<I>, I: Instance>(length: u32) -> (T::AccountId, Vec<u8>, T::AccountId) {
|
||||
let caller = whitelisted_caller();
|
||||
let value = T::TipReportDepositBase::get()
|
||||
+ T::DataDepositPerByte::get() * length.into()
|
||||
@@ -56,7 +56,7 @@ fn setup_awesome<T: Trait<I>, I: Instance>(length: u32) -> (T::AccountId, Vec<u8
|
||||
}
|
||||
|
||||
// Create the pre-requisite information needed to call `tip_new`.
|
||||
fn setup_tip<T: Trait<I>, I: Instance>(r: u32, t: u32) ->
|
||||
fn setup_tip<T: Config<I>, I: Instance>(r: u32, t: u32) ->
|
||||
Result<(T::AccountId, Vec<u8>, T::AccountId, BalanceOf<T, I>), &'static str>
|
||||
{
|
||||
let tippers_count = T::Tippers::count();
|
||||
@@ -77,7 +77,7 @@ fn setup_tip<T: Trait<I>, I: Instance>(r: u32, t: u32) ->
|
||||
|
||||
// Create `t` new tips for the tip proposal with `hash`.
|
||||
// This function automatically makes the tip able to close.
|
||||
fn create_tips<T: Trait<I>, I: Instance>(t: u32, hash: T::Hash, value: BalanceOf<T, I>) ->
|
||||
fn create_tips<T: Config<I>, I: Instance>(t: u32, hash: T::Hash, value: BalanceOf<T, I>) ->
|
||||
Result<(), &'static str>
|
||||
{
|
||||
for i in 0 .. t {
|
||||
@@ -94,7 +94,7 @@ fn create_tips<T: Trait<I>, I: Instance>(t: u32, hash: T::Hash, value: BalanceOf
|
||||
}
|
||||
|
||||
// Create proposals that are approved for use in `on_initialize`.
|
||||
fn create_approved_proposals<T: Trait<I>, I: Instance>(n: u32) -> Result<(), &'static str> {
|
||||
fn create_approved_proposals<T: Config<I>, I: Instance>(n: u32) -> Result<(), &'static str> {
|
||||
for i in 0 .. n {
|
||||
let (caller, value, lookup) = setup_proposal::<T, I>(i);
|
||||
Treasury::<T, I>::propose_spend(
|
||||
@@ -110,7 +110,7 @@ fn create_approved_proposals<T: Trait<I>, I: Instance>(n: u32) -> Result<(), &'s
|
||||
}
|
||||
|
||||
// Create bounties that are approved for use in `on_initialize`.
|
||||
fn create_approved_bounties<T: Trait<I>, I: Instance>(n: u32) -> Result<(), &'static str> {
|
||||
fn create_approved_bounties<T: Config<I>, I: Instance>(n: u32) -> Result<(), &'static str> {
|
||||
for i in 0 .. n {
|
||||
let (caller, _curator, _fee, value, reason) = setup_bounty::<T, I>(i, MAX_BYTES);
|
||||
Treasury::<T, I>::propose_bounty(RawOrigin::Signed(caller).into(), value, reason)?;
|
||||
@@ -122,7 +122,7 @@ fn create_approved_bounties<T: Trait<I>, I: Instance>(n: u32) -> Result<(), &'st
|
||||
}
|
||||
|
||||
// Create the pre-requisite information needed to create a treasury `propose_bounty`.
|
||||
fn setup_bounty<T: Trait<I>, I: Instance>(u: u32, d: u32) -> (
|
||||
fn setup_bounty<T: Config<I>, I: Instance>(u: u32, d: u32) -> (
|
||||
T::AccountId,
|
||||
T::AccountId,
|
||||
BalanceOf<T, I>,
|
||||
@@ -140,7 +140,7 @@ fn setup_bounty<T: Trait<I>, I: Instance>(u: u32, d: u32) -> (
|
||||
(caller, curator, fee, value, reason)
|
||||
}
|
||||
|
||||
fn create_bounty<T: Trait<I>, I: Instance>() -> Result<(
|
||||
fn create_bounty<T: Config<I>, I: Instance>() -> Result<(
|
||||
<T::Lookup as StaticLookup>::Source,
|
||||
BountyIndex,
|
||||
), &'static str> {
|
||||
@@ -155,7 +155,7 @@ fn create_bounty<T: Trait<I>, I: Instance>() -> Result<(
|
||||
Ok((curator_lookup, bounty_id))
|
||||
}
|
||||
|
||||
fn setup_pod_account<T: Trait<I>, I: Instance>() {
|
||||
fn setup_pod_account<T: Config<I>, I: Instance>() {
|
||||
let pot_account = Treasury::<T, I>::account_id();
|
||||
let value = T::Currency::minimum_balance().saturating_mul(1_000_000_000u32.into());
|
||||
let _ = T::Currency::make_free_balance_be(&pot_account, value);
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
//! The Treasury module provides a "pot" of funds that can be managed by stakeholders in the
|
||||
//! system and a structure for making spending proposals from this pot.
|
||||
//!
|
||||
//! - [`treasury::Trait`](./trait.Trait.html)
|
||||
//! - [`treasury::Config`](./trait.Config.html)
|
||||
//! - [`Call`](./enum.Call.html)
|
||||
//!
|
||||
//! ## Overview
|
||||
@@ -38,7 +38,7 @@
|
||||
//! given without first having a pre-determined stakeholder group come to consensus on how much
|
||||
//! should be paid.
|
||||
//!
|
||||
//! A group of `Tippers` is determined through the config `Trait`. After half of these have declared
|
||||
//! A group of `Tippers` is determined through the config `Config`. After half of these have declared
|
||||
//! some amount that they believe a particular reported reason deserves, then a countdown period is
|
||||
//! entered where any remaining members can declare their tip amounts also. After the close of the
|
||||
//! countdown period, the median of all declared tips is paid to the reported beneficiary, along
|
||||
@@ -155,13 +155,13 @@ use frame_system::{self as system, ensure_signed};
|
||||
pub use weights::WeightInfo;
|
||||
|
||||
type BalanceOf<T, I> =
|
||||
<<T as Trait<I>>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
|
||||
<<T as Config<I>>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
|
||||
type PositiveImbalanceOf<T, I> =
|
||||
<<T as Trait<I>>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::PositiveImbalance;
|
||||
<<T as Config<I>>::Currency as Currency<<T as frame_system::Config>::AccountId>>::PositiveImbalance;
|
||||
type NegativeImbalanceOf<T, I> =
|
||||
<<T as Trait<I>>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::NegativeImbalance;
|
||||
<<T as Config<I>>::Currency as Currency<<T as frame_system::Config>::AccountId>>::NegativeImbalance;
|
||||
|
||||
pub trait Trait<I=DefaultInstance>: frame_system::Trait {
|
||||
pub trait Config<I=DefaultInstance>: frame_system::Config {
|
||||
/// The treasury's module id, used for deriving its sovereign account ID.
|
||||
type ModuleId: Get<ModuleId>;
|
||||
|
||||
@@ -192,7 +192,7 @@ pub trait Trait<I=DefaultInstance>: frame_system::Trait {
|
||||
type DataDepositPerByte: Get<BalanceOf<Self, I>>;
|
||||
|
||||
/// The overarching event type.
|
||||
type Event: From<Event<Self, I>> + Into<<Self as frame_system::Trait>::Event>;
|
||||
type Event: From<Event<Self, I>> + Into<<Self as frame_system::Config>::Event>;
|
||||
|
||||
/// Handler for the unbalanced decrease when slashing for a rejected proposal or bounty.
|
||||
type OnSlash: OnUnbalanced<NegativeImbalanceOf<Self, I>>;
|
||||
@@ -332,7 +332,7 @@ pub enum BountyStatus<AccountId, BlockNumber> {
|
||||
}
|
||||
|
||||
decl_storage! {
|
||||
trait Store for Module<T: Trait<I>, I: Instance=DefaultInstance> as Treasury {
|
||||
trait Store for Module<T: Config<I>, I: Instance=DefaultInstance> as Treasury {
|
||||
/// Number of proposals that have been made.
|
||||
ProposalCount get(fn proposal_count): ProposalIndex;
|
||||
|
||||
@@ -388,8 +388,8 @@ decl_event!(
|
||||
pub enum Event<T, I=DefaultInstance>
|
||||
where
|
||||
Balance = BalanceOf<T, I>,
|
||||
<T as frame_system::Trait>::AccountId,
|
||||
<T as frame_system::Trait>::Hash,
|
||||
<T as frame_system::Config>::AccountId,
|
||||
<T as frame_system::Config>::Hash,
|
||||
{
|
||||
/// New proposal. \[proposal_index\]
|
||||
Proposed(ProposalIndex),
|
||||
@@ -433,7 +433,7 @@ decl_event!(
|
||||
|
||||
decl_error! {
|
||||
/// Error for the treasury module.
|
||||
pub enum Error for Module<T: Trait<I>, I: Instance> {
|
||||
pub enum Error for Module<T: Config<I>, I: Instance> {
|
||||
/// Proposer's balance is too low.
|
||||
InsufficientProposersBalance,
|
||||
/// No proposal or bounty at that index.
|
||||
@@ -465,7 +465,7 @@ decl_error! {
|
||||
}
|
||||
|
||||
decl_module! {
|
||||
pub struct Module<T: Trait<I>, I: Instance=DefaultInstance>
|
||||
pub struct Module<T: Config<I>, I: Instance=DefaultInstance>
|
||||
for enum Call
|
||||
where origin: T::Origin
|
||||
{
|
||||
@@ -1159,7 +1159,7 @@ decl_module! {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Trait<I>, I: Instance> Module<T, I> {
|
||||
impl<T: Config<I>, I: Instance> Module<T, I> {
|
||||
// Add public immutables and private mutables.
|
||||
|
||||
/// The account ID of the treasury pot.
|
||||
@@ -1452,7 +1452,7 @@ impl<T: Trait<I>, I: Instance> Module<T, I> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Trait<I>, I: Instance> OnUnbalanced<NegativeImbalanceOf<T, I>> for Module<T, I> {
|
||||
impl<T: Config<I>, I: Instance> OnUnbalanced<NegativeImbalanceOf<T, I>> for Module<T, I> {
|
||||
fn on_nonzero_unbalanced(amount: NegativeImbalanceOf<T, I>) {
|
||||
let numeric_amount = amount.peek();
|
||||
|
||||
|
||||
@@ -59,7 +59,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 Index = u64;
|
||||
@@ -89,7 +89,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 Event = Event;
|
||||
@@ -140,7 +140,7 @@ parameter_types! {
|
||||
pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);
|
||||
pub const BountyValueMinimum: u64 = 1;
|
||||
}
|
||||
impl Trait for Test {
|
||||
impl Config for Test {
|
||||
type ModuleId = TreasuryModuleId;
|
||||
type Currency = pallet_balances::Module<Test>;
|
||||
type ApproveOrigin = frame_system::EnsureRoot<u128>;
|
||||
|
||||
@@ -68,7 +68,7 @@ pub trait WeightInfo {
|
||||
|
||||
/// Weights for pallet_treasury 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_spend() -> Weight {
|
||||
(56_844_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as Weight))
|
||||
|
||||
Reference in New Issue
Block a user