mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 07:27:55 +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
@@ -63,7 +63,7 @@
|
||||
//! // Include the following links that shows what trait needs to be implemented to use the pallet
|
||||
//! // and the supported dispatchables that are documented in the Call enum.
|
||||
//!
|
||||
//! - \[`<INSERT_CUSTOM_PALLET_NAME>::Trait`](./trait.Trait.html)
|
||||
//! - \[`<INSERT_CUSTOM_PALLET_NAME>::Config`](./trait.Config.html)
|
||||
//! - \[`Call`](./enum.Call.html)
|
||||
//! - \[`Module`](./struct.Module.html)
|
||||
//!
|
||||
@@ -212,7 +212,7 @@
|
||||
//! \```rust
|
||||
//! use <INSERT_CUSTOM_PALLET_NAME>;
|
||||
//!
|
||||
//! pub trait Trait: <INSERT_CUSTOM_PALLET_NAME>::Trait { }
|
||||
//! pub trait Config: <INSERT_CUSTOM_PALLET_NAME>::Config { }
|
||||
//! \```
|
||||
//!
|
||||
//! \### Simple Code Snippet
|
||||
@@ -286,9 +286,9 @@ use sp_runtime::{
|
||||
// - The final weight of each dispatch is calculated as the argument of the call multiplied by the
|
||||
// parameter given to the `WeightForSetDummy`'s constructor.
|
||||
// - assigns a dispatch class `operational` if the argument of the call is more than 1000.
|
||||
struct WeightForSetDummy<T: pallet_balances::Trait>(BalanceOf<T>);
|
||||
struct WeightForSetDummy<T: pallet_balances::Config>(BalanceOf<T>);
|
||||
|
||||
impl<T: pallet_balances::Trait> WeighData<(&BalanceOf<T>,)> for WeightForSetDummy<T>
|
||||
impl<T: pallet_balances::Config> WeighData<(&BalanceOf<T>,)> for WeightForSetDummy<T>
|
||||
{
|
||||
fn weigh_data(&self, target: (&BalanceOf<T>,)) -> Weight {
|
||||
let multiplier = self.0;
|
||||
@@ -296,7 +296,7 @@ impl<T: pallet_balances::Trait> WeighData<(&BalanceOf<T>,)> for WeightForSetDumm
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: pallet_balances::Trait> ClassifyDispatch<(&BalanceOf<T>,)> for WeightForSetDummy<T> {
|
||||
impl<T: pallet_balances::Config> ClassifyDispatch<(&BalanceOf<T>,)> for WeightForSetDummy<T> {
|
||||
fn classify_dispatch(&self, target: (&BalanceOf<T>,)) -> DispatchClass {
|
||||
if *target.0 > <BalanceOf<T>>::from(1000u32) {
|
||||
DispatchClass::Operational
|
||||
@@ -306,23 +306,23 @@ impl<T: pallet_balances::Trait> ClassifyDispatch<(&BalanceOf<T>,)> for WeightFor
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: pallet_balances::Trait> PaysFee<(&BalanceOf<T>,)> for WeightForSetDummy<T> {
|
||||
impl<T: pallet_balances::Config> PaysFee<(&BalanceOf<T>,)> for WeightForSetDummy<T> {
|
||||
fn pays_fee(&self, _target: (&BalanceOf<T>,)) -> Pays {
|
||||
Pays::Yes
|
||||
}
|
||||
}
|
||||
|
||||
/// A type alias for the balance type from this pallet's point of view.
|
||||
type BalanceOf<T> = <T as pallet_balances::Trait>::Balance;
|
||||
type BalanceOf<T> = <T as pallet_balances::Config>::Balance;
|
||||
|
||||
/// Our pallet's configuration trait. All our types and constants go in here. If the
|
||||
/// pallet is dependent on specific other pallets, then their configuration traits
|
||||
/// should be added to our implied traits list.
|
||||
///
|
||||
/// `frame_system::Trait` should always be included in our implied traits.
|
||||
pub trait Trait: pallet_balances::Trait {
|
||||
/// `frame_system::Config` should always be included in our implied traits.
|
||||
pub trait Config: pallet_balances::Config {
|
||||
/// 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>;
|
||||
}
|
||||
|
||||
decl_storage! {
|
||||
@@ -333,7 +333,7 @@ decl_storage! {
|
||||
// It is important to update your storage name so that your pallet's
|
||||
// storage items are isolated from other pallets.
|
||||
// ---------------------------------vvvvvvv
|
||||
trait Store for Module<T: Trait> as Example {
|
||||
trait Store for Module<T: Config> as Example {
|
||||
// Any storage declarations of the form:
|
||||
// `pub? Name get(fn getter_name)? [config()|config(myname)] [build(|_| {...})] : <type> (= <new_default_value>)?;`
|
||||
// where `<type>` is either:
|
||||
@@ -371,7 +371,7 @@ decl_event!(
|
||||
/// Events are a simple means of reporting specific conditions and
|
||||
/// circumstances that have happened that users, Dapps and/or chain explorers would find
|
||||
/// interesting and otherwise difficult to detect.
|
||||
pub enum Event<T> where B = <T as pallet_balances::Trait>::Balance {
|
||||
pub enum Event<T> where B = <T as pallet_balances::Config>::Balance {
|
||||
// Just a normal `enum`, here's a dummy event to ensure it compiles.
|
||||
/// Dummy event, just here so there's a generic type that's used.
|
||||
Dummy(B),
|
||||
@@ -414,7 +414,7 @@ decl_event!(
|
||||
// `ensure_root` and `ensure_none`.
|
||||
decl_module! {
|
||||
// Simple declaration of the `Module` type. Lets the macro know what its working on.
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin {
|
||||
/// Deposit one of this pallet's events by using the default implementation.
|
||||
/// It is also possible to provide a custom implementation.
|
||||
/// For non-generic events, the generic parameter just needs to be dropped, so that it
|
||||
@@ -548,7 +548,7 @@ decl_module! {
|
||||
// - Public interface. These are functions that are `pub` and generally fall into inspector
|
||||
// functions that do not write to storage and operation functions that do.
|
||||
// - Private functions. These are your usual private utilities unavailable to other pallets.
|
||||
impl<T: Trait> Module<T> {
|
||||
impl<T: Config> Module<T> {
|
||||
// Add public immutables and private mutables.
|
||||
#[allow(dead_code)]
|
||||
fn accumulate_foo(origin: T::Origin, increase_by: T::Balance) -> DispatchResult {
|
||||
@@ -571,7 +571,7 @@ impl<T: Trait> Module<T> {
|
||||
// decodable type that implements `SignedExtension`. See the trait definition for the full list of
|
||||
// bounds. As a convention, you can follow this approach to create an extension for your pallet:
|
||||
// - If the extension does not carry any data, then use a tuple struct with just a `marker`
|
||||
// (needed for the compiler to accept `T: Trait`) will suffice.
|
||||
// (needed for the compiler to accept `T: Config`) will suffice.
|
||||
// - Otherwise, create a tuple struct which contains the external data. Of course, for the entire
|
||||
// struct to be decodable, each individual item also needs to be decodable.
|
||||
//
|
||||
@@ -602,21 +602,21 @@ impl<T: Trait> Module<T> {
|
||||
/// Additionally, it drops any transaction with an encoded length higher than 200 bytes. No
|
||||
/// particular reason why, just to demonstrate the power of signed extensions.
|
||||
#[derive(Encode, Decode, Clone, Eq, PartialEq)]
|
||||
pub struct WatchDummy<T: Trait + Send + Sync>(PhantomData<T>);
|
||||
pub struct WatchDummy<T: Config + Send + Sync>(PhantomData<T>);
|
||||
|
||||
impl<T: Trait + Send + Sync> sp_std::fmt::Debug for WatchDummy<T> {
|
||||
impl<T: Config + Send + Sync> sp_std::fmt::Debug for WatchDummy<T> {
|
||||
fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result {
|
||||
write!(f, "WatchDummy")
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Trait + Send + Sync> SignedExtension for WatchDummy<T>
|
||||
impl<T: Config + Send + Sync> SignedExtension for WatchDummy<T>
|
||||
where
|
||||
<T as frame_system::Trait>::Call: IsSubType<Call<T>>,
|
||||
<T as frame_system::Config>::Call: IsSubType<Call<T>>,
|
||||
{
|
||||
const IDENTIFIER: &'static str = "WatchDummy";
|
||||
type AccountId = T::AccountId;
|
||||
type Call = <T as frame_system::Trait>::Call;
|
||||
type Call = <T as frame_system::Config>::Call;
|
||||
type AdditionalSigned = ();
|
||||
type Pre = ();
|
||||
|
||||
@@ -744,7 +744,7 @@ mod tests {
|
||||
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;
|
||||
@@ -774,7 +774,7 @@ mod tests {
|
||||
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 = ();
|
||||
@@ -783,7 +783,7 @@ mod tests {
|
||||
type AccountStore = System;
|
||||
type WeightInfo = ();
|
||||
}
|
||||
impl Trait for Test {
|
||||
impl Config for Test {
|
||||
type Event = ();
|
||||
}
|
||||
type System = frame_system::Module<Test>;
|
||||
|
||||
Reference in New Issue
Block a user