From 3ae3a18f31c56faa88a8cf84bc8342df4867ed68 Mon Sep 17 00:00:00 2001 From: Shaopeng Wang Date: Thu, 25 Jun 2020 13:24:15 +1200 Subject: [PATCH 1/6] Use frame_system as default ident. --- bin/node-template/pallets/template/src/lib.rs | 8 ++++---- frame/assets/src/lib.rs | 4 ++-- frame/contracts/src/lib.rs | 2 +- frame/scored-pool/src/lib.rs | 4 ++-- frame/session/src/lib.rs | 8 ++++---- frame/sudo/src/lib.rs | 4 ++-- frame/support/procedural/src/construct_runtime/mod.rs | 2 +- frame/support/src/dispatch.rs | 4 ++-- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/bin/node-template/pallets/template/src/lib.rs b/bin/node-template/pallets/template/src/lib.rs index 1f82857c43e47..7514a46c1c0f4 100644 --- a/bin/node-template/pallets/template/src/lib.rs +++ b/bin/node-template/pallets/template/src/lib.rs @@ -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; @@ -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> + Into<::Event>; + type Event: From> + Into<::Event>; } // This pallet's storage items. @@ -41,7 +41,7 @@ decl_storage! { // The pallet's events decl_event!( - pub enum Event where AccountId = ::AccountId { + pub enum Event where AccountId = ::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 diff --git a/frame/assets/src/lib.rs b/frame/assets/src/lib.rs index d428f435b6ad3..8af61909fcc1e 100644 --- a/frame/assets/src/lib.rs +++ b/frame/assets/src/lib.rs @@ -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 { } //! @@ -135,7 +135,7 @@ use frame_support::{Parameter, decl_module, decl_event, decl_storage, decl_error, ensure}; use sp_runtime::traits::{Member, AtLeast32Bit, Zero, StaticLookup}; -use frame_system::{self as system, ensure_signed}; +use frame_system::ensure_signed; use sp_runtime::traits::One; /// The module configuration trait. diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 4db77a078e92d..182c6cd3300d2 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -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; diff --git a/frame/scored-pool/src/lib.rs b/frame/scored-pool/src/lib.rs index 5131a663e0e61..e75ef7e3ea811 100644 --- a/frame/scored-pool/src/lib.rs +++ b/frame/scored-pool/src/lib.rs @@ -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 {} @@ -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 = <>::Currency as Currency<::AccountId>>::Balance; diff --git a/frame/session/src/lib.rs b/frame/session/src/lib.rs index 6f5630adf9ecf..0cd77af7c88e5 100644 --- a/frame/session/src/lib.rs +++ b/frame/session/src/lib.rs @@ -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; @@ -434,7 +434,7 @@ decl_storage! { for (account, val, keys) in config.keys.iter().cloned() { >::inner_set_keys(&val, keys) .expect("genesis config must not contain duplicates; qed"); - system::Module::::inc_ref(&account); + frame_system::Module::::inc_ref(&account); } let initial_validators_0 = T::SessionManager::new_session(0) @@ -692,7 +692,7 @@ impl Module { let old_keys = Self::inner_set_keys(&who, keys)?; if old_keys.is_none() { - system::Module::::inc_ref(&account); + frame_system::Module::::inc_ref(&account); } Ok(()) @@ -740,7 +740,7 @@ impl Module { let key_data = old_keys.get_raw(*id); Self::clear_key_owner(*id, key_data); } - system::Module::::dec_ref(&account); + frame_system::Module::::dec_ref(&account); Ok(()) } diff --git a/frame/sudo/src/lib.rs b/frame/sudo/src/lib.rs index 233e75e869006..cf55d9e67f31b 100644 --- a/frame/sudo/src/lib.rs +++ b/frame/sudo/src/lib.rs @@ -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 {} //! @@ -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; diff --git a/frame/support/procedural/src/construct_runtime/mod.rs b/frame/support/procedural/src/construct_runtime/mod.rs index cac75490621aa..52eb17fb06d66 100644 --- a/frame/support/procedural/src/construct_runtime/mod.rs +++ b/frame/support/procedural/src/construct_runtime/mod.rs @@ -59,7 +59,7 @@ fn construct_runtime_parsed(definition: RuntimeDefinition) -> Result},`", + Please add this line: `System: frame_system::{Module, Call, Storage, Config, Event},`", )) } }; diff --git a/frame/support/src/dispatch.rs b/frame/support/src/dispatch.rs index d9a3561802c8f..53426b5cddafd 100644 --- a/frame/support/src/dispatch.rs +++ b/frame/support/src/dispatch.rs @@ -292,7 +292,7 @@ macro_rules! decl_module { pub struct $mod_type< $trait_instance: $trait_name $(, 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 ),* } {} {} @@ -2337,7 +2337,7 @@ mod tests { } decl_module! { - pub struct Module for enum Call where origin: T::Origin, T::AccountId: From { + pub struct Module for enum Call where origin: T::Origin, system = system, T::AccountId: From { /// Hi, this is a comment. #[weight = 0] fn aux_0(_origin) -> DispatchResult { unreachable!() } From c7c92bdc39879e93f64e6fd841285c32481f6b0d Mon Sep 17 00:00:00 2001 From: Shaopeng Wang Date: Thu, 25 Jun 2020 15:17:43 +1200 Subject: [PATCH 2/6] Remove unused 'frame_system' to 'system' renaming. --- frame/elections-phragmen/src/lib.rs | 5 ++--- frame/elections/src/lib.rs | 2 +- frame/evm/src/lib.rs | 4 ++-- frame/example/src/lib.rs | 2 +- frame/generic-asset/src/lib.rs | 2 +- frame/grandpa/src/lib.rs | 2 +- frame/identity/src/lib.rs | 2 +- frame/im-online/src/lib.rs | 4 ++-- frame/membership/src/lib.rs | 2 +- frame/nicks/src/lib.rs | 2 +- frame/offences/src/lib.rs | 1 - frame/staking/src/lib.rs | 2 +- frame/sudo/src/mock.rs | 1 + frame/support/src/dispatch.rs | 8 ++++---- frame/support/src/error.rs | 2 +- frame/support/src/weights.rs | 12 ++++++------ frame/support/test/tests/instance.rs | 4 ++-- frame/timestamp/src/lib.rs | 2 +- frame/utility/src/lib.rs | 2 +- frame/utility/src/tests.rs | 1 + frame/vesting/src/lib.rs | 2 +- 21 files changed, 32 insertions(+), 32 deletions(-) diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index 9436a15d5c749..63824dbf9c13e 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -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; @@ -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; @@ -1225,7 +1224,7 @@ mod tests { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: system::{Module, Call, Event}, + System: frame_system::{Module, Call, Event}, Balances: pallet_balances::{Module, Call, Event, Config}, Elections: elections_phragmen::{Module, Call, Event, Config}, } diff --git a/frame/elections/src/lib.rs b/frame/elections/src/lib.rs index 171a2dbb8ba91..c9d3c5455fc78 100644 --- a/frame/elections/src/lib.rs +++ b/frame/elections/src/lib.rs @@ -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; diff --git a/frame/evm/src/lib.rs b/frame/evm/src/lib.rs index 72392629d6efb..f3f0a5a529a06 100644 --- a/frame/evm/src/lib.rs +++ b/frame/evm/src/lib.rs @@ -32,7 +32,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::{ @@ -159,7 +159,7 @@ decl_storage! { trait Store for Module as EVM { Accounts get(fn accounts): map hasher(blake2_128_concat) H160 => Account; AccountCodes get(fn account_codes): map hasher(blake2_128_concat) H160 => Vec; - AccountStorages get(fn account_storages): + AccountStorages get(fn account_storages): double_map hasher(blake2_128_concat) H160, hasher(blake2_128_concat) H256 => H256; } diff --git a/frame/example/src/lib.rs b/frame/example/src/lib.rs index c8799cb62cb33..3433cf95bde03 100644 --- a/frame/example/src/lib.rs +++ b/frame/example/src/lib.rs @@ -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::{ diff --git a/frame/generic-asset/src/lib.rs b/frame/generic-asset/src/lib.rs index 403d9f8444673..4c209abb0aa5f 100644 --- a/frame/generic-asset/src/lib.rs +++ b/frame/generic-asset/src/lib.rs @@ -170,7 +170,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; diff --git a/frame/grandpa/src/lib.rs b/frame/grandpa/src/lib.rs index 3432c1102008b..ab3d0aff9d704 100644 --- a/frame/grandpa/src/lib.rs +++ b/frame/grandpa/src/lib.rs @@ -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, diff --git a/frame/identity/src/lib.rs b/frame/identity/src/lib.rs index d657e3d793741..4725f2052c27c 100644 --- a/frame/identity/src/lib.rs +++ b/frame/identity/src/lib.rs @@ -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; diff --git a/frame/im-online/src/lib.rs b/frame/im-online/src/lib.rs index c1c93910ece22..5ffdaa0f25371 100644 --- a/frame/im-online/src/lib.rs +++ b/frame/im-online/src/lib.rs @@ -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 {} @@ -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, diff --git a/frame/membership/src/lib.rs b/frame/membership/src/lib.rs index 62b1217c83500..afd9fae68733f 100644 --- a/frame/membership/src/lib.rs +++ b/frame/membership/src/lib.rs @@ -28,7 +28,7 @@ use frame_support::{ decl_module, decl_storage, decl_event, decl_error, traits::{ChangeMembers, InitializeMembers, EnsureOrigin}, }; -use frame_system::{self as system, ensure_signed}; +use frame_system::ensure_signed; pub trait Trait: frame_system::Trait { /// The overarching event type. diff --git a/frame/nicks/src/lib.rs b/frame/nicks/src/lib.rs index 8a130da2ae255..6582afe9f7ec4 100644 --- a/frame/nicks/src/lib.rs +++ b/frame/nicks/src/lib.rs @@ -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 = <::Currency as Currency<::AccountId>>::Balance; type NegativeImbalanceOf = <::Currency as Currency<::AccountId>>::NegativeImbalance; diff --git a/frame/offences/src/lib.rs b/frame/offences/src/lib.rs index a42f09697e3b4..14ab94d5c0b4d 100644 --- a/frame/offences/src/lib.rs +++ b/frame/offences/src/lib.rs @@ -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; diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index de61b25483d01..333fe0a67ec37 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -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 {} diff --git a/frame/sudo/src/mock.rs b/frame/sudo/src/mock.rs index 3bf67f581b6e1..5c88c1971e962 100644 --- a/frame/sudo/src/mock.rs +++ b/frame/sudo/src/mock.rs @@ -29,6 +29,7 @@ use sp_runtime::{Perbill, traits::{BlakeTwo256, IdentityLookup}, testing::Header use sp_io; use crate as sudo; use frame_support::traits::Filter; +use frame_system as system; // Logger module to track execution. pub mod logger { diff --git a/frame/support/src/dispatch.rs b/frame/support/src/dispatch.rs index 53426b5cddafd..04664fa7a382c 100644 --- a/frame/support/src/dispatch.rs +++ b/frame/support/src/dispatch.rs @@ -70,7 +70,7 @@ impl 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 for enum Call where origin: T::Origin { /// @@ -112,7 +112,7 @@ impl 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 for enum Call where origin: T::Origin { /// #[weight = 0] @@ -147,7 +147,7 @@ impl 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 for enum Call where origin: T::Origin { /// #[weight = 1_000_000] @@ -175,7 +175,7 @@ impl 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 for enum Call where origin: T::Origin { /// #[weight = 0] diff --git a/frame/support/src/error.rs b/frame/support/src/error.rs index 456ef3c461970..d758ad52e72b3 100644 --- a/frame/support/src/error.rs +++ b/frame/support/src/error.rs @@ -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. diff --git a/frame/support/src/weights.rs b/frame/support/src/weights.rs index 810bd2fcb6416..a93cd5f6f8710 100644 --- a/frame/support/src/weights.rs +++ b/frame/support/src/weights.rs @@ -39,7 +39,7 @@ //! `Yes`**. //! //! ``` -//! # use frame_system::{self as system, Trait}; +//! # use frame_system::Trait; //! frame_support::decl_module! { //! pub struct Module for enum Call where origin: T::Origin { //! #[weight = 1000] @@ -52,7 +52,7 @@ //! 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; //! frame_support::decl_module! { //! pub struct Module for enum Call where origin: T::Origin { @@ -66,7 +66,7 @@ //! 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; //! frame_support::decl_module! { //! pub struct Module for enum Call where origin: T::Origin { @@ -80,7 +80,7 @@ //! 3. Define all 3 parameters. //! //! ``` -//! # use frame_system::{self as system, Trait}; +//! # use frame_system::Trait; //! # use frame_support::weights::{DispatchClass, Pays}; //! frame_support::decl_module! { //! pub struct Module for enum Call where origin: T::Origin { @@ -100,7 +100,7 @@ //! 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}; //! frame_support::decl_module! { //! pub struct Module 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| { 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. let frac = args.coeff_frac * w; let integer = args.coeff_integer.saturating_mul(w); diff --git a/frame/support/test/tests/instance.rs b/frame/support/test/tests/instance.rs index 920554346f73e..a3207b944c699 100644 --- a/frame/support/test/tests/instance.rs +++ b/frame/support/test/tests/instance.rs @@ -49,7 +49,7 @@ mod module1 { frame_support::decl_module! { pub struct Module, I: InstantiableThing> for enum Call where - origin: ::Origin, + origin: ::Origin, system = system, T::BlockNumber: From { fn offchain_worker() {} @@ -128,7 +128,7 @@ mod module2 { frame_support::decl_module! { pub struct Module, I: Instance=DefaultInstance> for enum Call where - origin: ::Origin + origin: ::Origin, system = system { fn deposit_event() = default; } diff --git a/frame/timestamp/src/lib.rs b/frame/timestamp/src/lib.rs index 63456100a5e02..db15166e17b70 100644 --- a/frame/timestamp/src/lib.rs +++ b/frame/timestamp/src/lib.rs @@ -64,7 +64,7 @@ //! ``` //! use frame_support::{decl_module, dispatch}; //! # use pallet_timestamp as timestamp; -//! use frame_system::{self as system, ensure_signed}; +//! use frame_system::ensure_signed; //! //! pub trait Trait: timestamp::Trait {} //! diff --git a/frame/utility/src/lib.rs b/frame/utility/src/lib.rs index 3759a2afcd814..95d9153b059ad 100644 --- a/frame/utility/src/lib.rs +++ b/frame/utility/src/lib.rs @@ -59,7 +59,7 @@ use frame_support::{ traits::{OriginTrait, UnfilteredDispatchable}, 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}; mod tests; diff --git a/frame/utility/src/tests.rs b/frame/utility/src/tests.rs index e0f8426d28941..454d72ea8e53d 100644 --- a/frame/utility/src/tests.rs +++ b/frame/utility/src/tests.rs @@ -25,6 +25,7 @@ use frame_support::{ assert_ok, assert_noop, impl_outer_origin, parameter_types, impl_outer_dispatch, weights::Weight, impl_outer_event, dispatch::DispatchError, traits::Filter, storage, }; +use frame_system as system; use sp_core::H256; use sp_runtime::{Perbill, traits::{BlakeTwo256, IdentityLookup}, testing::Header}; use crate as utility; diff --git a/frame/vesting/src/lib.rs b/frame/vesting/src/lib.rs index 8308c84f917a1..c478d950017e9 100644 --- a/frame/vesting/src/lib.rs +++ b/frame/vesting/src/lib.rs @@ -58,7 +58,7 @@ use frame_support::traits::{ Currency, LockableCurrency, VestingSchedule, WithdrawReason, LockIdentifier, ExistenceRequirement, Get }; -use frame_system::{self as system, ensure_signed, ensure_root}; +use frame_system::{ensure_signed, ensure_root}; mod benchmarking; From 77d66b9efe956f938d80a5ed6872cee5638cba47 Mon Sep 17 00:00:00 2001 From: Shaopeng Wang Date: Thu, 25 Jun 2020 16:25:19 +1200 Subject: [PATCH 3/6] Fix construct_runtime_ui tests. --- .../tests/construct_runtime_ui/missing_system_module.stderr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/support/test/tests/construct_runtime_ui/missing_system_module.stderr b/frame/support/test/tests/construct_runtime_ui/missing_system_module.stderr index 442af9c01fa34..2ebe0721eb381 100644 --- a/frame/support/test/tests/construct_runtime_ui/missing_system_module.stderr +++ b/frame/support/test/tests/construct_runtime_ui/missing_system_module.stderr @@ -1,4 +1,4 @@ -error: `System` module declaration is missing. Please add this line: `System: system::{Module, Call, Storage, Config, Event},` +error: `System` module declaration is missing. Please add this line: `System: frame_system::{Module, Call, Storage, Config, Event},` --> $DIR/missing_system_module.rs:8:2 | 8 | { From 638d423607db5890bbbf900a426a1083086654b4 Mon Sep 17 00:00:00 2001 From: Shaopeng Wang Date: Fri, 26 Jun 2020 10:13:18 +1200 Subject: [PATCH 4/6] Rename system to frame_system in sudo/utility pallet test. --- frame/sudo/src/mock.rs | 11 +++++------ frame/utility/src/tests.rs | 5 ++--- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/frame/sudo/src/mock.rs b/frame/sudo/src/mock.rs index 5c88c1971e962..74612fa8798fe 100644 --- a/frame/sudo/src/mock.rs +++ b/frame/sudo/src/mock.rs @@ -29,15 +29,14 @@ use sp_runtime::{Perbill, traits::{BlakeTwo256, IdentityLookup}, testing::Header use sp_io; use crate as sudo; use frame_support::traits::Filter; -use frame_system as system; // Logger module to track execution. pub mod logger { use super::*; use frame_system::ensure_root; - pub trait Trait: system::Trait { - type Event: From> + Into<::Event>; + pub trait Trait: frame_system::Trait { + type Event: From> + Into<::Event>; } decl_storage! { @@ -55,7 +54,7 @@ pub mod logger { } decl_module! { - pub struct Module for enum Call where origin: ::Origin { + pub struct Module for enum Call where origin: ::Origin { fn deposit_event() = default; #[weight = *weight] @@ -88,7 +87,7 @@ mod test_events { impl_outer_event! { pub enum TestEvent for Test { - system, + frame_system, sudo, logger, } @@ -162,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; pub type Logger = logger::Module; -pub type System = system::Module; +pub type System = frame_system::Module; // New types for dispatchable functions. pub type SudoCall = sudo::Call; diff --git a/frame/utility/src/tests.rs b/frame/utility/src/tests.rs index 454d72ea8e53d..40c1ff8946707 100644 --- a/frame/utility/src/tests.rs +++ b/frame/utility/src/tests.rs @@ -25,7 +25,6 @@ use frame_support::{ assert_ok, assert_noop, impl_outer_origin, parameter_types, impl_outer_dispatch, weights::Weight, impl_outer_event, dispatch::DispatchError, traits::Filter, storage, }; -use frame_system as system; use sp_core::H256; use sp_runtime::{Perbill, traits::{BlakeTwo256, IdentityLookup}, testing::Header}; use crate as utility; @@ -35,7 +34,7 @@ impl_outer_origin! { } impl_outer_event! { pub enum TestEvent for Test { - system, + frame_system, pallet_balances, utility, } @@ -131,7 +130,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { } fn last_event() -> TestEvent { - system::Module::::events().pop().map(|e| e.event).expect("Event expected") + frame_system::Module::::events().pop().map(|e| e.event).expect("Event expected") } fn expect_event>(e: E) { From 41eb742fdc8bce9804c9753b9c1be5f2c7db7041 Mon Sep 17 00:00:00 2001 From: Shaopeng Wang Date: Fri, 26 Jun 2020 10:17:41 +1200 Subject: [PATCH 5/6] Bump runtime impl_version. --- bin/node/runtime/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index e3c9c2b95f0bd..c5c11fe577a3f 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -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: 254, - impl_version: 0, + impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1, }; From 9063b153c9cccecb09d9611d6d5f03fd8f01cc25 Mon Sep 17 00:00:00 2001 From: Shaopeng Wang Date: Thu, 2 Jul 2020 10:40:18 +1200 Subject: [PATCH 6/6] Update formatting. --- frame/support/test/tests/instance.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frame/support/test/tests/instance.rs b/frame/support/test/tests/instance.rs index a3207b944c699..f1d837bcdfb49 100644 --- a/frame/support/test/tests/instance.rs +++ b/frame/support/test/tests/instance.rs @@ -49,7 +49,8 @@ mod module1 { frame_support::decl_module! { pub struct Module, I: InstantiableThing> for enum Call where - origin: ::Origin, system = system, + origin: ::Origin, + system = system, T::BlockNumber: From { fn offchain_worker() {} @@ -128,7 +129,8 @@ mod module2 { frame_support::decl_module! { pub struct Module, I: Instance=DefaultInstance> for enum Call where - origin: ::Origin, system = system + origin: ::Origin, + system = system { fn deposit_event() = default; }