mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 15:07:59 +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
@@ -17,7 +17,7 @@
|
||||
|
||||
//! # Sudo Module
|
||||
//!
|
||||
//! - [`sudo::Trait`](./trait.Trait.html)
|
||||
//! - [`sudo::Config`](./trait.Config.html)
|
||||
//! - [`Call`](./enum.Call.html)
|
||||
//!
|
||||
//! ## Overview
|
||||
@@ -55,10 +55,10 @@
|
||||
//! use frame_support::{decl_module, dispatch};
|
||||
//! use frame_system::ensure_root;
|
||||
//!
|
||||
//! pub trait Trait: frame_system::Trait {}
|
||||
//! pub trait Config: frame_system::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 {
|
||||
//! #[weight = 0]
|
||||
//! pub fn privileged_function(origin) -> dispatch::DispatchResult {
|
||||
//! ensure_root(origin)?;
|
||||
@@ -82,7 +82,7 @@
|
||||
//! * [Democracy](../pallet_democracy/index.html)
|
||||
//!
|
||||
//! [`Call`]: ./enum.Call.html
|
||||
//! [`Trait`]: ./trait.Trait.html
|
||||
//! [`Config`]: ./trait.Config.html
|
||||
//! [`Origin`]: https://docs.substrate.dev/docs/substrate-types
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
@@ -105,9 +105,9 @@ mod mock;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
pub trait Trait: frame_system::Trait {
|
||||
pub trait Config: frame_system::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>;
|
||||
|
||||
/// A sudo-able call.
|
||||
type Call: Parameter + UnfilteredDispatchable<Origin=Self::Origin> + GetDispatchInfo;
|
||||
@@ -115,7 +115,7 @@ pub trait Trait: frame_system::Trait {
|
||||
|
||||
decl_module! {
|
||||
/// Sudo module declaration.
|
||||
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>;
|
||||
|
||||
fn deposit_event() = default;
|
||||
@@ -131,7 +131,7 @@ decl_module! {
|
||||
/// - Weight of derivative `call` execution + 10,000.
|
||||
/// # </weight>
|
||||
#[weight = (call.get_dispatch_info().weight + 10_000, call.get_dispatch_info().class)]
|
||||
fn sudo(origin, call: Box<<T as Trait>::Call>) -> DispatchResultWithPostInfo {
|
||||
fn sudo(origin, call: Box<<T as Config>::Call>) -> DispatchResultWithPostInfo {
|
||||
// This is a public call, so we ensure that the origin is some signed account.
|
||||
let sender = ensure_signed(origin)?;
|
||||
ensure!(sender == Self::key(), Error::<T>::RequireSudo);
|
||||
@@ -153,7 +153,7 @@ decl_module! {
|
||||
/// - The weight of this call is defined by the caller.
|
||||
/// # </weight>
|
||||
#[weight = (*_weight, call.get_dispatch_info().class)]
|
||||
fn sudo_unchecked_weight(origin, call: Box<<T as Trait>::Call>, _weight: Weight) -> DispatchResultWithPostInfo {
|
||||
fn sudo_unchecked_weight(origin, call: Box<<T as Config>::Call>, _weight: Weight) -> DispatchResultWithPostInfo {
|
||||
// This is a public call, so we ensure that the origin is some signed account.
|
||||
let sender = ensure_signed(origin)?;
|
||||
ensure!(sender == Self::key(), Error::<T>::RequireSudo);
|
||||
@@ -206,7 +206,7 @@ decl_module! {
|
||||
)]
|
||||
fn sudo_as(origin,
|
||||
who: <T::Lookup as StaticLookup>::Source,
|
||||
call: Box<<T as Trait>::Call>
|
||||
call: Box<<T as Config>::Call>
|
||||
) -> DispatchResultWithPostInfo {
|
||||
// This is a public call, so we ensure that the origin is some signed account.
|
||||
let sender = ensure_signed(origin)?;
|
||||
@@ -224,7 +224,7 @@ decl_module! {
|
||||
}
|
||||
|
||||
decl_event!(
|
||||
pub enum Event<T> where AccountId = <T as frame_system::Trait>::AccountId {
|
||||
pub enum Event<T> where AccountId = <T as frame_system::Config>::AccountId {
|
||||
/// A sudo just took place. \[result\]
|
||||
Sudid(DispatchResult),
|
||||
/// The \[sudoer\] just switched identity; the old key is supplied.
|
||||
@@ -235,7 +235,7 @@ decl_event!(
|
||||
);
|
||||
|
||||
decl_storage! {
|
||||
trait Store for Module<T: Trait> as Sudo {
|
||||
trait Store for Module<T: Config> as Sudo {
|
||||
/// The `AccountId` of the sudo key.
|
||||
Key get(fn key) config(): T::AccountId;
|
||||
}
|
||||
@@ -243,7 +243,7 @@ decl_storage! {
|
||||
|
||||
decl_error! {
|
||||
/// Error for the Sudo module
|
||||
pub enum Error for Module<T: Trait> {
|
||||
pub enum Error for Module<T: Config> {
|
||||
/// Sender must be the Sudo account
|
||||
RequireSudo,
|
||||
}
|
||||
|
||||
@@ -33,26 +33,26 @@ pub mod logger {
|
||||
use super::*;
|
||||
use frame_system::ensure_root;
|
||||
|
||||
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>;
|
||||
}
|
||||
|
||||
decl_storage! {
|
||||
trait Store for Module<T: Trait> as Logger {
|
||||
trait Store for Module<T: Config> as Logger {
|
||||
AccountLog get(fn account_log): Vec<T::AccountId>;
|
||||
I32Log get(fn i32_log): Vec<i32>;
|
||||
}
|
||||
}
|
||||
|
||||
decl_event! {
|
||||
pub enum Event<T> where AccountId = <T as frame_system::Trait>::AccountId {
|
||||
pub enum Event<T> where AccountId = <T as frame_system::Config>::AccountId {
|
||||
AppendI32(i32, Weight),
|
||||
AppendI32AndAccount(AccountId, i32, Weight),
|
||||
}
|
||||
}
|
||||
|
||||
decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: <T as frame_system::Trait>::Origin {
|
||||
pub struct Module<T: Config> for enum Call where origin: <T as frame_system::Config>::Origin {
|
||||
fn deposit_event() = default;
|
||||
|
||||
#[weight = *weight]
|
||||
@@ -118,7 +118,7 @@ impl Filter<Call> for BlockEverything {
|
||||
}
|
||||
}
|
||||
|
||||
impl frame_system::Trait for Test {
|
||||
impl frame_system::Config for Test {
|
||||
type BaseCallFilter = BlockEverything;
|
||||
type Origin = Origin;
|
||||
type Call = Call;
|
||||
@@ -146,13 +146,13 @@ impl frame_system::Trait for Test {
|
||||
type SystemWeightInfo = ();
|
||||
}
|
||||
|
||||
// Implement the logger module's `Trait` on the Test runtime.
|
||||
impl logger::Trait for Test {
|
||||
// Implement the logger module's `Config` on the Test runtime.
|
||||
impl logger::Config for Test {
|
||||
type Event = TestEvent;
|
||||
}
|
||||
|
||||
// Implement the sudo module's `Trait` on the Test runtime.
|
||||
impl Trait for Test {
|
||||
// Implement the sudo module's `Config` on the Test runtime.
|
||||
impl Config for Test {
|
||||
type Event = TestEvent;
|
||||
type Call = Call;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user