mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-15 18:31:05 +00:00
decl_module! macro: use 'frame_system' instead of system as default ident (#6500)
* Use frame_system as default ident. * Remove unused 'frame_system' to 'system' renaming. * Fix construct_runtime_ui tests. * Rename system to frame_system in sudo/utility pallet test. * Bump runtime impl_version. * Update formatting.
This commit is contained in:
@@ -10,7 +10,7 @@
|
|||||||
/// https://github.com/paritytech/substrate/blob/master/frame/example/src/lib.rs
|
/// https://github.com/paritytech/substrate/blob/master/frame/example/src/lib.rs
|
||||||
|
|
||||||
use frame_support::{decl_module, decl_storage, decl_event, decl_error, dispatch};
|
use frame_support::{decl_module, decl_storage, decl_event, decl_error, dispatch};
|
||||||
use frame_system::{self as system, ensure_signed};
|
use frame_system::ensure_signed;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod mock;
|
mod mock;
|
||||||
@@ -19,11 +19,11 @@ mod mock;
|
|||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
/// The pallet's configuration trait.
|
/// The pallet's configuration trait.
|
||||||
pub trait Trait: system::Trait {
|
pub trait Trait: frame_system::Trait {
|
||||||
// Add other types and constants required to configure this pallet.
|
// Add other types and constants required to configure this pallet.
|
||||||
|
|
||||||
/// The overarching event type.
|
/// The overarching event type.
|
||||||
type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
|
type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This pallet's storage items.
|
// This pallet's storage items.
|
||||||
@@ -41,7 +41,7 @@ decl_storage! {
|
|||||||
|
|
||||||
// The pallet's events
|
// The pallet's events
|
||||||
decl_event!(
|
decl_event!(
|
||||||
pub enum Event<T> where AccountId = <T as system::Trait>::AccountId {
|
pub enum Event<T> where AccountId = <T as frame_system::Trait>::AccountId {
|
||||||
/// Just a dummy event.
|
/// Just a dummy event.
|
||||||
/// Event `Something` is declared with a parameter of the type `u32` and `AccountId`
|
/// Event `Something` is declared with a parameter of the type `u32` and `AccountId`
|
||||||
/// To emit this event, we call the deposit function, from our runtime functions
|
/// To emit this event, we call the deposit function, from our runtime functions
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
|||||||
// implementation changes and behavior does not, then leave spec_version as
|
// implementation changes and behavior does not, then leave spec_version as
|
||||||
// is and increment impl_version.
|
// is and increment impl_version.
|
||||||
spec_version: 255,
|
spec_version: 255,
|
||||||
impl_version: 0,
|
impl_version: 1,
|
||||||
apis: RUNTIME_API_VERSIONS,
|
apis: RUNTIME_API_VERSIONS,
|
||||||
transaction_version: 1,
|
transaction_version: 1,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -87,7 +87,7 @@
|
|||||||
//! ```rust,ignore
|
//! ```rust,ignore
|
||||||
//! use pallet_assets as assets;
|
//! use pallet_assets as assets;
|
||||||
//! use frame_support::{decl_module, dispatch, ensure};
|
//! use frame_support::{decl_module, dispatch, ensure};
|
||||||
//! use frame_system::{self as system, ensure_signed};
|
//! use frame_system::ensure_signed;
|
||||||
//!
|
//!
|
||||||
//! pub trait Trait: assets::Trait { }
|
//! pub trait Trait: assets::Trait { }
|
||||||
//!
|
//!
|
||||||
@@ -135,7 +135,7 @@
|
|||||||
|
|
||||||
use frame_support::{Parameter, decl_module, decl_event, decl_storage, decl_error, ensure};
|
use frame_support::{Parameter, decl_module, decl_event, decl_storage, decl_error, ensure};
|
||||||
use sp_runtime::traits::{Member, AtLeast32Bit, AtLeast32BitUnsigned, Zero, StaticLookup};
|
use sp_runtime::traits::{Member, AtLeast32Bit, AtLeast32BitUnsigned, Zero, StaticLookup};
|
||||||
use frame_system::{self as system, ensure_signed};
|
use frame_system::ensure_signed;
|
||||||
use sp_runtime::traits::One;
|
use sp_runtime::traits::One;
|
||||||
|
|
||||||
/// The module configuration trait.
|
/// The module configuration trait.
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ use frame_support::{
|
|||||||
dispatch::{DispatchResult, DispatchResultWithPostInfo},
|
dispatch::{DispatchResult, DispatchResultWithPostInfo},
|
||||||
traits::{OnUnbalanced, Currency, Get, Time, Randomness},
|
traits::{OnUnbalanced, Currency, Get, Time, Randomness},
|
||||||
};
|
};
|
||||||
use frame_system::{self as system, ensure_signed, ensure_root};
|
use frame_system::{ensure_signed, ensure_root};
|
||||||
use pallet_contracts_primitives::{RentProjection, ContractAccessError};
|
use pallet_contracts_primitives::{RentProjection, ContractAccessError};
|
||||||
use frame_support::weights::Weight;
|
use frame_support::weights::Weight;
|
||||||
|
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ use frame_support::{
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
use sp_npos_elections::{build_support_map, ExtendedBalance, VoteWeight, ElectionResult};
|
use sp_npos_elections::{build_support_map, ExtendedBalance, VoteWeight, ElectionResult};
|
||||||
use frame_system::{self as system, ensure_signed, ensure_root};
|
use frame_system::{ensure_signed, ensure_root};
|
||||||
|
|
||||||
mod benchmarking;
|
mod benchmarking;
|
||||||
|
|
||||||
@@ -1060,7 +1060,6 @@ mod tests {
|
|||||||
traits::{BlakeTwo256, IdentityLookup, Block as BlockT},
|
traits::{BlakeTwo256, IdentityLookup, Block as BlockT},
|
||||||
};
|
};
|
||||||
use crate as elections_phragmen;
|
use crate as elections_phragmen;
|
||||||
use frame_system as system;
|
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub const BlockHashCount: u64 = 250;
|
pub const BlockHashCount: u64 = 250;
|
||||||
@@ -1225,7 +1224,7 @@ mod tests {
|
|||||||
NodeBlock = Block,
|
NodeBlock = Block,
|
||||||
UncheckedExtrinsic = UncheckedExtrinsic
|
UncheckedExtrinsic = UncheckedExtrinsic
|
||||||
{
|
{
|
||||||
System: system::{Module, Call, Event<T>},
|
System: frame_system::{Module, Call, Event<T>},
|
||||||
Balances: pallet_balances::{Module, Call, Event<T>, Config<T>},
|
Balances: pallet_balances::{Module, Call, Event<T>, Config<T>},
|
||||||
Elections: elections_phragmen::{Module, Call, Event<T>, Config<T>},
|
Elections: elections_phragmen::{Module, Call, Event<T>, Config<T>},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ use frame_support::{
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
use codec::{Encode, Decode};
|
use codec::{Encode, Decode};
|
||||||
use frame_system::{self as system, ensure_signed, ensure_root};
|
use frame_system::{ensure_signed, ensure_root};
|
||||||
|
|
||||||
mod mock;
|
mod mock;
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ use serde::{Serialize, Deserialize};
|
|||||||
use frame_support::{ensure, decl_module, decl_storage, decl_event, decl_error};
|
use frame_support::{ensure, decl_module, decl_storage, decl_event, decl_error};
|
||||||
use frame_support::weights::Weight;
|
use frame_support::weights::Weight;
|
||||||
use frame_support::traits::{Currency, WithdrawReason, ExistenceRequirement, Get};
|
use frame_support::traits::{Currency, WithdrawReason, ExistenceRequirement, Get};
|
||||||
use frame_system::{self as system, ensure_signed};
|
use frame_system::ensure_signed;
|
||||||
use sp_runtime::ModuleId;
|
use sp_runtime::ModuleId;
|
||||||
use sp_core::{U256, H256, H160, Hasher};
|
use sp_core::{U256, H256, H160, Hasher};
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
|
|||||||
@@ -260,7 +260,7 @@ use frame_support::{
|
|||||||
weights::{DispatchClass, ClassifyDispatch, WeighData, Weight, PaysFee, Pays},
|
weights::{DispatchClass, ClassifyDispatch, WeighData, Weight, PaysFee, Pays},
|
||||||
};
|
};
|
||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
use frame_system::{self as system, ensure_signed, ensure_root};
|
use frame_system::{ensure_signed, ensure_root};
|
||||||
use codec::{Encode, Decode};
|
use codec::{Encode, Decode};
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
traits::{
|
traits::{
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ use frame_support::{
|
|||||||
},
|
},
|
||||||
Parameter, StorageMap,
|
Parameter, StorageMap,
|
||||||
};
|
};
|
||||||
use frame_system::{self as system, ensure_signed, ensure_root};
|
use frame_system::{ensure_signed, ensure_root};
|
||||||
|
|
||||||
mod mock;
|
mod mock;
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ use frame_support::{
|
|||||||
decl_error, decl_event, decl_module, decl_storage, storage, traits::KeyOwnerProofSystem,
|
decl_error, decl_event, decl_module, decl_storage, storage, traits::KeyOwnerProofSystem,
|
||||||
Parameter,
|
Parameter,
|
||||||
};
|
};
|
||||||
use frame_system::{self as system, ensure_signed, DigestOf};
|
use frame_system::{ensure_signed, DigestOf};
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
generic::{DigestItem, OpaqueDigestItemId},
|
generic::{DigestItem, OpaqueDigestItemId},
|
||||||
traits::Zero,
|
traits::Zero,
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ use frame_support::{
|
|||||||
traits::{Currency, ReservableCurrency, OnUnbalanced, Get, BalanceStatus, EnsureOrigin},
|
traits::{Currency, ReservableCurrency, OnUnbalanced, Get, BalanceStatus, EnsureOrigin},
|
||||||
weights::Weight,
|
weights::Weight,
|
||||||
};
|
};
|
||||||
use frame_system::{self as system, ensure_signed};
|
use frame_system::ensure_signed;
|
||||||
|
|
||||||
mod benchmarking;
|
mod benchmarking;
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! use frame_support::{decl_module, dispatch};
|
//! use frame_support::{decl_module, dispatch};
|
||||||
//! use frame_system::{self as system, ensure_signed};
|
//! use frame_system::ensure_signed;
|
||||||
//! use pallet_im_online::{self as im_online};
|
//! use pallet_im_online::{self as im_online};
|
||||||
//!
|
//!
|
||||||
//! pub trait Trait: im_online::Trait {}
|
//! pub trait Trait: im_online::Trait {}
|
||||||
@@ -97,7 +97,7 @@ use frame_support::{
|
|||||||
traits::Get,
|
traits::Get,
|
||||||
weights::Weight,
|
weights::Weight,
|
||||||
};
|
};
|
||||||
use frame_system::{self as system, ensure_none};
|
use frame_system::ensure_none;
|
||||||
use frame_system::offchain::{
|
use frame_system::offchain::{
|
||||||
SendTransactionTypes,
|
SendTransactionTypes,
|
||||||
SubmitTransaction,
|
SubmitTransaction,
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ use frame_support::{
|
|||||||
decl_module, decl_storage, decl_event, decl_error,
|
decl_module, decl_storage, decl_event, decl_error,
|
||||||
traits::{ChangeMembers, InitializeMembers, EnsureOrigin, Contains},
|
traits::{ChangeMembers, InitializeMembers, EnsureOrigin, Contains},
|
||||||
};
|
};
|
||||||
use frame_system::{self as system, ensure_signed};
|
use frame_system::ensure_signed;
|
||||||
|
|
||||||
pub trait Trait<I=DefaultInstance>: frame_system::Trait {
|
pub trait Trait<I=DefaultInstance>: frame_system::Trait {
|
||||||
/// The overarching event type.
|
/// The overarching event type.
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ use frame_support::{
|
|||||||
decl_module, decl_event, decl_storage, ensure, decl_error,
|
decl_module, decl_event, decl_storage, ensure, decl_error,
|
||||||
traits::{Currency, EnsureOrigin, ReservableCurrency, OnUnbalanced, Get},
|
traits::{Currency, EnsureOrigin, ReservableCurrency, OnUnbalanced, Get},
|
||||||
};
|
};
|
||||||
use frame_system::{self as system, ensure_signed};
|
use frame_system::ensure_signed;
|
||||||
|
|
||||||
type BalanceOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
|
type BalanceOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
|
||||||
type NegativeImbalanceOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::NegativeImbalance;
|
type NegativeImbalanceOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::NegativeImbalance;
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ use sp_staking::{
|
|||||||
offence::{Offence, ReportOffence, Kind, OnOffenceHandler, OffenceDetails, OffenceError},
|
offence::{Offence, ReportOffence, Kind, OnOffenceHandler, OffenceDetails, OffenceError},
|
||||||
};
|
};
|
||||||
use codec::{Encode, Decode};
|
use codec::{Encode, Decode};
|
||||||
use frame_system as system;
|
|
||||||
|
|
||||||
/// A binary blob which represents a SCALE codec-encoded `O::TimeSlot`.
|
/// A binary blob which represents a SCALE codec-encoded `O::TimeSlot`.
|
||||||
type OpaqueTimeSlot = Vec<u8>;
|
type OpaqueTimeSlot = Vec<u8>;
|
||||||
|
|||||||
@@ -55,7 +55,7 @@
|
|||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! use frame_support::{decl_module, dispatch};
|
//! use frame_support::{decl_module, dispatch};
|
||||||
//! use frame_system::{self as system, ensure_signed};
|
//! use frame_system::ensure_signed;
|
||||||
//! use pallet_scored_pool::{self as scored_pool};
|
//! use pallet_scored_pool::{self as scored_pool};
|
||||||
//!
|
//!
|
||||||
//! pub trait Trait: scored_pool::Trait {}
|
//! pub trait Trait: scored_pool::Trait {}
|
||||||
@@ -100,7 +100,7 @@ use frame_support::{
|
|||||||
traits::{EnsureOrigin, ChangeMembers, InitializeMembers, Currency, Get, ReservableCurrency},
|
traits::{EnsureOrigin, ChangeMembers, InitializeMembers, Currency, Get, ReservableCurrency},
|
||||||
weights::Weight,
|
weights::Weight,
|
||||||
};
|
};
|
||||||
use frame_system::{self as system, ensure_root, ensure_signed};
|
use frame_system::{ensure_root, ensure_signed};
|
||||||
use sp_runtime::traits::{AtLeast32Bit, MaybeSerializeDeserialize, Zero, StaticLookup};
|
use sp_runtime::traits::{AtLeast32Bit, MaybeSerializeDeserialize, Zero, StaticLookup};
|
||||||
|
|
||||||
type BalanceOf<T, I> = <<T as Trait<I>>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
|
type BalanceOf<T, I> = <<T as Trait<I>>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ use frame_support::{
|
|||||||
dispatch::{self, DispatchResult, DispatchError},
|
dispatch::{self, DispatchResult, DispatchError},
|
||||||
weights::Weight,
|
weights::Weight,
|
||||||
};
|
};
|
||||||
use frame_system::{self as system, ensure_signed};
|
use frame_system::ensure_signed;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod mock;
|
mod mock;
|
||||||
@@ -434,7 +434,7 @@ decl_storage! {
|
|||||||
for (account, val, keys) in config.keys.iter().cloned() {
|
for (account, val, keys) in config.keys.iter().cloned() {
|
||||||
<Module<T>>::inner_set_keys(&val, keys)
|
<Module<T>>::inner_set_keys(&val, keys)
|
||||||
.expect("genesis config must not contain duplicates; qed");
|
.expect("genesis config must not contain duplicates; qed");
|
||||||
system::Module::<T>::inc_ref(&account);
|
frame_system::Module::<T>::inc_ref(&account);
|
||||||
}
|
}
|
||||||
|
|
||||||
let initial_validators_0 = T::SessionManager::new_session(0)
|
let initial_validators_0 = T::SessionManager::new_session(0)
|
||||||
@@ -692,7 +692,7 @@ impl<T: Trait> Module<T> {
|
|||||||
|
|
||||||
let old_keys = Self::inner_set_keys(&who, keys)?;
|
let old_keys = Self::inner_set_keys(&who, keys)?;
|
||||||
if old_keys.is_none() {
|
if old_keys.is_none() {
|
||||||
system::Module::<T>::inc_ref(&account);
|
frame_system::Module::<T>::inc_ref(&account);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -740,7 +740,7 @@ impl<T: Trait> Module<T> {
|
|||||||
let key_data = old_keys.get_raw(*id);
|
let key_data = old_keys.get_raw(*id);
|
||||||
Self::clear_key_owner(*id, key_data);
|
Self::clear_key_owner(*id, key_data);
|
||||||
}
|
}
|
||||||
system::Module::<T>::dec_ref(&account);
|
frame_system::Module::<T>::dec_ref(&account);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,7 +151,7 @@
|
|||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! use frame_support::{decl_module, dispatch};
|
//! use frame_support::{decl_module, dispatch};
|
||||||
//! use frame_system::{self as system, ensure_signed};
|
//! use frame_system::ensure_signed;
|
||||||
//! use pallet_staking::{self as staking};
|
//! use pallet_staking::{self as staking};
|
||||||
//!
|
//!
|
||||||
//! pub trait Trait: staking::Trait {}
|
//! pub trait Trait: staking::Trait {}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@
|
|||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! use frame_support::{decl_module, dispatch};
|
//! use frame_support::{decl_module, dispatch};
|
||||||
//! use frame_system::{self as system, ensure_root};
|
//! use frame_system::ensure_root;
|
||||||
//!
|
//!
|
||||||
//! pub trait Trait: frame_system::Trait {}
|
//! pub trait Trait: frame_system::Trait {}
|
||||||
//!
|
//!
|
||||||
@@ -94,7 +94,7 @@ use frame_support::{
|
|||||||
Parameter, decl_module, decl_event, decl_storage, decl_error, ensure,
|
Parameter, decl_module, decl_event, decl_storage, decl_error, ensure,
|
||||||
};
|
};
|
||||||
use frame_support::{weights::{Weight, GetDispatchInfo}, traits::UnfilteredDispatchable};
|
use frame_support::{weights::{Weight, GetDispatchInfo}, traits::UnfilteredDispatchable};
|
||||||
use frame_system::{self as system, ensure_signed};
|
use frame_system::ensure_signed;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod mock;
|
mod mock;
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ pub mod logger {
|
|||||||
use super::*;
|
use super::*;
|
||||||
use frame_system::ensure_root;
|
use frame_system::ensure_root;
|
||||||
|
|
||||||
pub trait Trait: system::Trait {
|
pub trait Trait: frame_system::Trait {
|
||||||
type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
|
type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
|
||||||
}
|
}
|
||||||
|
|
||||||
decl_storage! {
|
decl_storage! {
|
||||||
@@ -54,7 +54,7 @@ pub mod logger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
decl_module! {
|
decl_module! {
|
||||||
pub struct Module<T: Trait> for enum Call where origin: <T as system::Trait>::Origin {
|
pub struct Module<T: Trait> for enum Call where origin: <T as frame_system::Trait>::Origin {
|
||||||
fn deposit_event() = default;
|
fn deposit_event() = default;
|
||||||
|
|
||||||
#[weight = *weight]
|
#[weight = *weight]
|
||||||
@@ -87,7 +87,7 @@ mod test_events {
|
|||||||
|
|
||||||
impl_outer_event! {
|
impl_outer_event! {
|
||||||
pub enum TestEvent for Test {
|
pub enum TestEvent for Test {
|
||||||
system<T>,
|
frame_system<T>,
|
||||||
sudo<T>,
|
sudo<T>,
|
||||||
logger<T>,
|
logger<T>,
|
||||||
}
|
}
|
||||||
@@ -161,7 +161,7 @@ impl Trait for Test {
|
|||||||
// Assign back to type variables in order to make dispatched calls of these modules later.
|
// Assign back to type variables in order to make dispatched calls of these modules later.
|
||||||
pub type Sudo = Module<Test>;
|
pub type Sudo = Module<Test>;
|
||||||
pub type Logger = logger::Module<Test>;
|
pub type Logger = logger::Module<Test>;
|
||||||
pub type System = system::Module<Test>;
|
pub type System = frame_system::Module<Test>;
|
||||||
|
|
||||||
// New types for dispatchable functions.
|
// New types for dispatchable functions.
|
||||||
pub type SudoCall = sudo::Call<Test>;
|
pub type SudoCall = sudo::Call<Test>;
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ fn construct_runtime_parsed(definition: RuntimeDefinition) -> Result<TokenStream
|
|||||||
return Err(syn::Error::new(
|
return Err(syn::Error::new(
|
||||||
modules_token.span,
|
modules_token.span,
|
||||||
"`System` module declaration is missing. \
|
"`System` module declaration is missing. \
|
||||||
Please add this line: `System: system::{Module, Call, Storage, Config, Event<T>},`",
|
Please add this line: `System: frame_system::{Module, Call, Storage, Config, Event<T>},`",
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ impl<T> Parameter for T where T: Codec + EncodeLike + Clone + Eq + fmt::Debug {}
|
|||||||
/// # #[macro_use]
|
/// # #[macro_use]
|
||||||
/// # extern crate frame_support;
|
/// # extern crate frame_support;
|
||||||
/// # use frame_support::dispatch;
|
/// # use frame_support::dispatch;
|
||||||
/// # use frame_system::{self as system, Trait, ensure_signed};
|
/// # use frame_system::{Trait, ensure_signed};
|
||||||
/// decl_module! {
|
/// decl_module! {
|
||||||
/// pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
/// pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||||
///
|
///
|
||||||
@@ -112,7 +112,7 @@ impl<T> Parameter for T where T: Codec + EncodeLike + Clone + Eq + fmt::Debug {}
|
|||||||
/// # #[macro_use]
|
/// # #[macro_use]
|
||||||
/// # extern crate frame_support;
|
/// # extern crate frame_support;
|
||||||
/// # use frame_support::dispatch;
|
/// # use frame_support::dispatch;
|
||||||
/// # use frame_system::{self as system, Trait, ensure_signed};
|
/// # use frame_system::{Trait, ensure_signed};
|
||||||
/// decl_module! {
|
/// decl_module! {
|
||||||
/// pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
/// pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||||
/// #[weight = 0]
|
/// #[weight = 0]
|
||||||
@@ -147,7 +147,7 @@ impl<T> Parameter for T where T: Codec + EncodeLike + Clone + Eq + fmt::Debug {}
|
|||||||
/// # #[macro_use]
|
/// # #[macro_use]
|
||||||
/// # extern crate frame_support;
|
/// # extern crate frame_support;
|
||||||
/// # use frame_support::dispatch::{DispatchResultWithPostInfo, WithPostDispatchInfo};
|
/// # use frame_support::dispatch::{DispatchResultWithPostInfo, WithPostDispatchInfo};
|
||||||
/// # use frame_system::{self as system, Trait, ensure_signed};
|
/// # use frame_system::{Trait, ensure_signed};
|
||||||
/// decl_module! {
|
/// decl_module! {
|
||||||
/// pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
/// pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||||
/// #[weight = 1_000_000]
|
/// #[weight = 1_000_000]
|
||||||
@@ -175,7 +175,7 @@ impl<T> Parameter for T where T: Codec + EncodeLike + Clone + Eq + fmt::Debug {}
|
|||||||
/// # #[macro_use]
|
/// # #[macro_use]
|
||||||
/// # extern crate frame_support;
|
/// # extern crate frame_support;
|
||||||
/// # use frame_support::dispatch;
|
/// # use frame_support::dispatch;
|
||||||
/// # use frame_system::{self as system, Trait, ensure_signed, ensure_root};
|
/// # use frame_system::{Trait, ensure_signed, ensure_root};
|
||||||
/// decl_module! {
|
/// decl_module! {
|
||||||
/// pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
/// pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||||
/// #[weight = 0]
|
/// #[weight = 0]
|
||||||
@@ -292,7 +292,7 @@ macro_rules! decl_module {
|
|||||||
pub struct $mod_type<
|
pub struct $mod_type<
|
||||||
$trait_instance: $trait_name $(<I>, I: $instantiable $(= $module_default_instance)?)?
|
$trait_instance: $trait_name $(<I>, I: $instantiable $(= $module_default_instance)?)?
|
||||||
>
|
>
|
||||||
for enum $call_type where origin: $origin_type, system = system
|
for enum $call_type where origin: $origin_type, system = frame_system
|
||||||
{ $( $where_ty: $where_bound ),* }
|
{ $( $where_ty: $where_bound ),* }
|
||||||
{}
|
{}
|
||||||
{}
|
{}
|
||||||
@@ -2339,7 +2339,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
decl_module! {
|
decl_module! {
|
||||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, T::AccountId: From<u32> {
|
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system = system, T::AccountId: From<u32> {
|
||||||
/// Hi, this is a comment.
|
/// Hi, this is a comment.
|
||||||
#[weight = 0]
|
#[weight = 0]
|
||||||
fn aux_0(_origin) -> DispatchResult { unreachable!() }
|
fn aux_0(_origin) -> DispatchResult { unreachable!() }
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ pub use frame_metadata::{ModuleErrorMetadata, ErrorMetadata, DecodeDifferent};
|
|||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// # use frame_system::{self as system, Trait};
|
/// # use frame_system::Trait;
|
||||||
///
|
///
|
||||||
/// // You need to register the error type in `decl_module!` as well to make the error
|
/// // You need to register the error type in `decl_module!` as well to make the error
|
||||||
/// // exported in the metadata.
|
/// // exported in the metadata.
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
//! `Yes`**.
|
//! `Yes`**.
|
||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! # use frame_system::{self as system, Trait};
|
//! # use frame_system::Trait;
|
||||||
//! frame_support::decl_module! {
|
//! frame_support::decl_module! {
|
||||||
//! pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
//! pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||||
//! #[weight = 1000]
|
//! #[weight = 1000]
|
||||||
@@ -52,7 +52,7 @@
|
|||||||
//! 2.1 Define weight and class, **in which case `PaysFee` would be `Yes`**.
|
//! 2.1 Define weight and class, **in which case `PaysFee` would be `Yes`**.
|
||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! # use frame_system::{self as system, Trait};
|
//! # use frame_system::Trait;
|
||||||
//! # use frame_support::weights::DispatchClass;
|
//! # use frame_support::weights::DispatchClass;
|
||||||
//! frame_support::decl_module! {
|
//! frame_support::decl_module! {
|
||||||
//! pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
//! pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||||
@@ -66,7 +66,7 @@
|
|||||||
//! 2.2 Define weight and `PaysFee`, **in which case `ClassifyDispatch` would be `Normal`**.
|
//! 2.2 Define weight and `PaysFee`, **in which case `ClassifyDispatch` would be `Normal`**.
|
||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! # use frame_system::{self as system, Trait};
|
//! # use frame_system::Trait;
|
||||||
//! # use frame_support::weights::Pays;
|
//! # use frame_support::weights::Pays;
|
||||||
//! frame_support::decl_module! {
|
//! frame_support::decl_module! {
|
||||||
//! pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
//! pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||||
@@ -80,7 +80,7 @@
|
|||||||
//! 3. Define all 3 parameters.
|
//! 3. Define all 3 parameters.
|
||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! # use frame_system::{self as system, Trait};
|
//! # use frame_system::Trait;
|
||||||
//! # use frame_support::weights::{DispatchClass, Pays};
|
//! # use frame_support::weights::{DispatchClass, Pays};
|
||||||
//! frame_support::decl_module! {
|
//! frame_support::decl_module! {
|
||||||
//! pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
//! pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||||
@@ -100,7 +100,7 @@
|
|||||||
//! all 3 are static values, providing a raw tuple is easier.
|
//! all 3 are static values, providing a raw tuple is easier.
|
||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! # use frame_system::{self as system, Trait};
|
//! # use frame_system::Trait;
|
||||||
//! # use frame_support::weights::{DispatchClass, FunctionOf, Pays};
|
//! # use frame_support::weights::{DispatchClass, FunctionOf, Pays};
|
||||||
//! frame_support::decl_module! {
|
//! frame_support::decl_module! {
|
||||||
//! pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
//! pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||||
@@ -589,7 +589,7 @@ pub trait WeightToFeePolynomial {
|
|||||||
Self::polynomial().iter().fold(Self::Balance::saturated_from(0u32), |mut acc, args| {
|
Self::polynomial().iter().fold(Self::Balance::saturated_from(0u32), |mut acc, args| {
|
||||||
let w = Self::Balance::saturated_from(*weight).saturating_pow(args.degree.into());
|
let w = Self::Balance::saturated_from(*weight).saturating_pow(args.degree.into());
|
||||||
|
|
||||||
// The sum could get negative. Therefore we only sum with the accumulator.
|
// The sum could get negative. Therefore we only sum with the accumulator.
|
||||||
// The Perbill Mul implementation is non overflowing.
|
// The Perbill Mul implementation is non overflowing.
|
||||||
let frac = args.coeff_frac * w;
|
let frac = args.coeff_frac * w;
|
||||||
let integer = args.coeff_integer.saturating_mul(w);
|
let integer = args.coeff_integer.saturating_mul(w);
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
error: `System` module declaration is missing. Please add this line: `System: system::{Module, Call, Storage, Config, Event<T>},`
|
error: `System` module declaration is missing. Please add this line: `System: frame_system::{Module, Call, Storage, Config, Event<T>},`
|
||||||
--> $DIR/missing_system_module.rs:8:2
|
--> $DIR/missing_system_module.rs:8:2
|
||||||
|
|
|
|
||||||
8 | {
|
8 | {
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ mod module1 {
|
|||||||
frame_support::decl_module! {
|
frame_support::decl_module! {
|
||||||
pub struct Module<T: Trait<I>, I: InstantiableThing> for enum Call where
|
pub struct Module<T: Trait<I>, I: InstantiableThing> for enum Call where
|
||||||
origin: <T as system::Trait>::Origin,
|
origin: <T as system::Trait>::Origin,
|
||||||
|
system = system,
|
||||||
T::BlockNumber: From<u32>
|
T::BlockNumber: From<u32>
|
||||||
{
|
{
|
||||||
fn offchain_worker() {}
|
fn offchain_worker() {}
|
||||||
@@ -129,7 +130,8 @@ mod module2 {
|
|||||||
|
|
||||||
frame_support::decl_module! {
|
frame_support::decl_module! {
|
||||||
pub struct Module<T: Trait<I>, I: Instance=DefaultInstance> for enum Call where
|
pub struct Module<T: Trait<I>, I: Instance=DefaultInstance> for enum Call where
|
||||||
origin: <T as system::Trait>::Origin
|
origin: <T as system::Trait>::Origin,
|
||||||
|
system = system
|
||||||
{
|
{
|
||||||
fn deposit_event() = default;
|
fn deposit_event() = default;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,7 +64,7 @@
|
|||||||
//! ```
|
//! ```
|
||||||
//! use frame_support::{decl_module, dispatch};
|
//! use frame_support::{decl_module, dispatch};
|
||||||
//! # use pallet_timestamp as timestamp;
|
//! # use pallet_timestamp as timestamp;
|
||||||
//! use frame_system::{self as system, ensure_signed};
|
//! use frame_system::ensure_signed;
|
||||||
//!
|
//!
|
||||||
//! pub trait Trait: timestamp::Trait {}
|
//! pub trait Trait: timestamp::Trait {}
|
||||||
//!
|
//!
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ use frame_support::{
|
|||||||
traits::{OriginTrait, UnfilteredDispatchable},
|
traits::{OriginTrait, UnfilteredDispatchable},
|
||||||
weights::{Weight, GetDispatchInfo, DispatchClass}, dispatch::PostDispatchInfo,
|
weights::{Weight, GetDispatchInfo, DispatchClass}, dispatch::PostDispatchInfo,
|
||||||
};
|
};
|
||||||
use frame_system::{self as system, ensure_signed, ensure_root};
|
use frame_system::{ensure_signed, ensure_root};
|
||||||
use sp_runtime::{DispatchError, DispatchResult, traits::Dispatchable};
|
use sp_runtime::{DispatchError, DispatchResult, traits::Dispatchable};
|
||||||
|
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ impl_outer_origin! {
|
|||||||
}
|
}
|
||||||
impl_outer_event! {
|
impl_outer_event! {
|
||||||
pub enum TestEvent for Test {
|
pub enum TestEvent for Test {
|
||||||
system<T>,
|
frame_system<T>,
|
||||||
pallet_balances<T>,
|
pallet_balances<T>,
|
||||||
utility,
|
utility,
|
||||||
}
|
}
|
||||||
@@ -132,7 +132,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn last_event() -> TestEvent {
|
fn last_event() -> TestEvent {
|
||||||
system::Module::<Test>::events().pop().map(|e| e.event).expect("Event expected")
|
frame_system::Module::<Test>::events().pop().map(|e| e.event).expect("Event expected")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn expect_event<E: Into<TestEvent>>(e: E) {
|
fn expect_event<E: Into<TestEvent>>(e: E) {
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ use frame_support::traits::{
|
|||||||
Currency, LockableCurrency, VestingSchedule, WithdrawReason, LockIdentifier,
|
Currency, LockableCurrency, VestingSchedule, WithdrawReason, LockIdentifier,
|
||||||
ExistenceRequirement, Get
|
ExistenceRequirement, Get
|
||||||
};
|
};
|
||||||
use frame_system::{self as system, ensure_signed, ensure_root};
|
use frame_system::{ensure_signed, ensure_root};
|
||||||
|
|
||||||
mod benchmarking;
|
mod benchmarking;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user