Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

decl_module! macro: use 'frame_system' instead of system as default ident #6500

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions bin/node-template/pallets/template/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/// 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_system::{self as system, ensure_signed};
use frame_system::ensure_signed;

#[cfg(test)]
mod mock;
Expand All @@ -19,11 +19,11 @@ mod mock;
mod tests;

/// 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.

/// 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.
Expand All @@ -41,7 +41,7 @@ decl_storage! {

// The pallet's events
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.
/// 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
Expand Down
2 changes: 1 addition & 1 deletion bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
// implementation changes and behavior does not, then leave spec_version as
// is and increment impl_version.
spec_version: 255,
impl_version: 0,
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
};
Expand Down
4 changes: 2 additions & 2 deletions frame/assets/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
//! ```rust,ignore
//! use pallet_assets as assets;
//! 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 { }
//!
Expand Down Expand Up @@ -135,7 +135,7 @@

use frame_support::{Parameter, decl_module, decl_event, decl_storage, decl_error, ensure};
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;

/// The module configuration trait.
Expand Down
2 changes: 1 addition & 1 deletion frame/contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ use frame_support::{
dispatch::{DispatchResult, DispatchResultWithPostInfo},
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 frame_support::weights::Weight;

Expand Down
5 changes: 2 additions & 3 deletions frame/elections-phragmen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ use frame_support::{
}
};
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;

Expand Down Expand Up @@ -1060,7 +1060,6 @@ mod tests {
traits::{BlakeTwo256, IdentityLookup, Block as BlockT},
};
use crate as elections_phragmen;
use frame_system as system;

parameter_types! {
pub const BlockHashCount: u64 = 250;
Expand Down Expand Up @@ -1225,7 +1224,7 @@ mod tests {
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic
{
System: system::{Module, Call, Event<T>},
System: frame_system::{Module, Call, Event<T>},
Balances: pallet_balances::{Module, Call, Event<T>, Config<T>},
Elections: elections_phragmen::{Module, Call, Event<T>, Config<T>},
}
Expand Down
2 changes: 1 addition & 1 deletion frame/elections/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use frame_support::{
}
};
use codec::{Encode, Decode};
use frame_system::{self as system, ensure_signed, ensure_root};
use frame_system::{ensure_signed, ensure_root};

mod mock;
mod tests;
Expand Down
2 changes: 1 addition & 1 deletion frame/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use serde::{Serialize, Deserialize};
use frame_support::{ensure, decl_module, decl_storage, decl_event, decl_error};
use frame_support::weights::Weight;
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_core::{U256, H256, H160, Hasher};
use sp_runtime::{
Expand Down
2 changes: 1 addition & 1 deletion frame/example/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ use frame_support::{
weights::{DispatchClass, ClassifyDispatch, WeighData, Weight, PaysFee, Pays},
};
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 sp_runtime::{
traits::{
Expand Down
2 changes: 1 addition & 1 deletion frame/generic-asset/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ use frame_support::{
},
Parameter, StorageMap,
};
use frame_system::{self as system, ensure_signed, ensure_root};
use frame_system::{ensure_signed, ensure_root};

mod mock;
mod tests;
Expand Down
2 changes: 1 addition & 1 deletion frame/grandpa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ use frame_support::{
decl_error, decl_event, decl_module, decl_storage, storage, traits::KeyOwnerProofSystem,
Parameter,
};
use frame_system::{self as system, ensure_signed, DigestOf};
use frame_system::{ensure_signed, DigestOf};
use sp_runtime::{
generic::{DigestItem, OpaqueDigestItemId},
traits::Zero,
Expand Down
2 changes: 1 addition & 1 deletion frame/identity/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ use frame_support::{
traits::{Currency, ReservableCurrency, OnUnbalanced, Get, BalanceStatus, EnsureOrigin},
weights::Weight,
};
use frame_system::{self as system, ensure_signed};
use frame_system::ensure_signed;

mod benchmarking;

Expand Down
4 changes: 2 additions & 2 deletions frame/im-online/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
//!
//! ```
//! 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};
//!
//! pub trait Trait: im_online::Trait {}
Expand Down Expand Up @@ -97,7 +97,7 @@ use frame_support::{
traits::Get,
weights::Weight,
};
use frame_system::{self as system, ensure_none};
use frame_system::ensure_none;
use frame_system::offchain::{
SendTransactionTypes,
SubmitTransaction,
Expand Down
2 changes: 1 addition & 1 deletion frame/membership/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use frame_support::{
decl_module, decl_storage, decl_event, decl_error,
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 {
/// The overarching event type.
Expand Down
2 changes: 1 addition & 1 deletion frame/nicks/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ use frame_support::{
decl_module, decl_event, decl_storage, ensure, decl_error,
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 NegativeImbalanceOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::NegativeImbalance;
Expand Down
1 change: 0 additions & 1 deletion frame/offences/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ use sp_staking::{
offence::{Offence, ReportOffence, Kind, OnOffenceHandler, OffenceDetails, OffenceError},
};
use codec::{Encode, Decode};
use frame_system as system;

/// A binary blob which represents a SCALE codec-encoded `O::TimeSlot`.
type OpaqueTimeSlot = Vec<u8>;
Expand Down
4 changes: 2 additions & 2 deletions frame/scored-pool/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
//!
//! ```
//! 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};
//!
//! pub trait Trait: scored_pool::Trait {}
Expand Down Expand Up @@ -100,7 +100,7 @@ use frame_support::{
traits::{EnsureOrigin, ChangeMembers, InitializeMembers, Currency, Get, ReservableCurrency},
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};

type BalanceOf<T, I> = <<T as Trait<I>>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
Expand Down
8 changes: 4 additions & 4 deletions frame/session/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ use frame_support::{
dispatch::{self, DispatchResult, DispatchError},
weights::Weight,
};
use frame_system::{self as system, ensure_signed};
use frame_system::ensure_signed;

#[cfg(test)]
mod mock;
Expand Down Expand Up @@ -434,7 +434,7 @@ decl_storage! {
for (account, val, keys) in config.keys.iter().cloned() {
<Module<T>>::inner_set_keys(&val, keys)
.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)
Expand Down Expand Up @@ -692,7 +692,7 @@ impl<T: Trait> Module<T> {

let old_keys = Self::inner_set_keys(&who, keys)?;
if old_keys.is_none() {
system::Module::<T>::inc_ref(&account);
frame_system::Module::<T>::inc_ref(&account);
}

Ok(())
Expand Down Expand Up @@ -740,7 +740,7 @@ impl<T: Trait> Module<T> {
let key_data = old_keys.get_raw(*id);
Self::clear_key_owner(*id, key_data);
}
system::Module::<T>::dec_ref(&account);
frame_system::Module::<T>::dec_ref(&account);

Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion frame/staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
//!
//! ```
//! 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};
//!
//! pub trait Trait: staking::Trait {}
Expand Down
4 changes: 2 additions & 2 deletions frame/sudo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
//!
//! ```
//! 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 {}
//!
Expand Down Expand Up @@ -94,7 +94,7 @@ use frame_support::{
Parameter, decl_module, decl_event, decl_storage, decl_error, ensure,
};
use frame_support::{weights::{Weight, GetDispatchInfo}, traits::UnfilteredDispatchable};
use frame_system::{self as system, ensure_signed};
use frame_system::ensure_signed;

#[cfg(test)]
mod mock;
Expand Down
10 changes: 5 additions & 5 deletions frame/sudo/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ pub mod logger {
use super::*;
use frame_system::ensure_root;

pub trait Trait: system::Trait {
type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
pub trait Trait: frame_system::Trait {
type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
}

decl_storage! {
Expand All @@ -54,7 +54,7 @@ pub mod logger {
}

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;

#[weight = *weight]
Expand Down Expand Up @@ -87,7 +87,7 @@ mod test_events {

impl_outer_event! {
pub enum TestEvent for Test {
system<T>,
frame_system<T>,
sudo<T>,
logger<T>,
}
Expand Down Expand Up @@ -161,7 +161,7 @@ impl Trait for Test {
// Assign back to type variables in order to make dispatched calls of these modules later.
pub type Sudo = 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.
pub type SudoCall = sudo::Call<Test>;
Expand Down
2 changes: 1 addition & 1 deletion frame/support/procedural/src/construct_runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fn construct_runtime_parsed(definition: RuntimeDefinition) -> Result<TokenStream
return Err(syn::Error::new(
modules_token.span,
"`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>},`",
))
}
};
Expand Down
12 changes: 6 additions & 6 deletions frame/support/src/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl<T> Parameter for T where T: Codec + EncodeLike + Clone + Eq + fmt::Debug {}
/// # #[macro_use]
/// # extern crate frame_support;
/// # use frame_support::dispatch;
/// # use frame_system::{self as system, Trait, ensure_signed};
/// # use frame_system::{Trait, ensure_signed};
/// decl_module! {
/// pub struct Module<T: Trait> for enum Call where origin: T::Origin {
///
Expand Down Expand Up @@ -112,7 +112,7 @@ impl<T> Parameter for T where T: Codec + EncodeLike + Clone + Eq + fmt::Debug {}
/// # #[macro_use]
/// # extern crate frame_support;
/// # use frame_support::dispatch;
/// # use frame_system::{self as system, Trait, ensure_signed};
/// # use frame_system::{Trait, ensure_signed};
/// decl_module! {
/// pub struct Module<T: Trait> for enum Call where origin: T::Origin {
/// #[weight = 0]
Expand Down Expand Up @@ -147,7 +147,7 @@ impl<T> Parameter for T where T: Codec + EncodeLike + Clone + Eq + fmt::Debug {}
/// # #[macro_use]
/// # extern crate frame_support;
/// # use frame_support::dispatch::{DispatchResultWithPostInfo, WithPostDispatchInfo};
/// # use frame_system::{self as system, Trait, ensure_signed};
/// # use frame_system::{Trait, ensure_signed};
/// decl_module! {
/// pub struct Module<T: Trait> for enum Call where origin: T::Origin {
/// #[weight = 1_000_000]
Expand Down Expand Up @@ -175,7 +175,7 @@ impl<T> Parameter for T where T: Codec + EncodeLike + Clone + Eq + fmt::Debug {}
/// # #[macro_use]
/// # extern crate frame_support;
/// # 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! {
/// pub struct Module<T: Trait> for enum Call where origin: T::Origin {
/// #[weight = 0]
Expand Down Expand Up @@ -292,7 +292,7 @@ macro_rules! decl_module {
pub struct $mod_type<
$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 ),* }
{}
{}
Expand Down Expand Up @@ -2339,7 +2339,7 @@ mod tests {
}

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.
#[weight = 0]
fn aux_0(_origin) -> DispatchResult { unreachable!() }
Expand Down
2 changes: 1 addition & 1 deletion frame/support/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
/// // exported in the metadata.
Expand Down
Loading