diff --git a/Cargo.lock b/Cargo.lock index 093126e5ce8c3..1ba23af1747da 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9427,6 +9427,7 @@ dependencies = [ name = "substrate-frame-cli" version = "3.0.0" dependencies = [ + "frame-support", "frame-system", "sc-cli", "sp-core", diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 448867b25cb17..956675175a746 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -40,7 +40,7 @@ use frame_system::{ EnsureRoot, EnsureOneOf, limits::{BlockWeights, BlockLength} }; -use frame_support::traits::InstanceFilter; +use frame_support::{traits::InstanceFilter, PalletId}; use codec::{Encode, Decode}; use sp_core::{ crypto::KeyTypeId, @@ -52,7 +52,7 @@ use node_primitives::{AccountIndex, Balance, BlockNumber, Hash, Index, Moment}; use sp_api::impl_runtime_apis; use sp_runtime::{ Permill, Perbill, Perquintill, Percent, ApplyExtrinsicResult, impl_opaque_keys, generic, - create_runtime_str, ModuleId, FixedPointNumber, + create_runtime_str, FixedPointNumber, }; use sp_runtime::curve::PiecewiseLinear; use sp_runtime::transaction_validity::{TransactionValidity, TransactionSource, TransactionPriority}; @@ -634,7 +634,7 @@ parameter_types! { pub const TermDuration: BlockNumber = 7 * DAYS; pub const DesiredMembers: u32 = 13; pub const DesiredRunnersUp: u32 = 7; - pub const ElectionsPhragmenModuleId: LockIdentifier = *b"phrelect"; + pub const ElectionsPhragmenPalletId: LockIdentifier = *b"phrelect"; } // Make sure that there are no more than `MaxMembers` members elected via elections-phragmen. @@ -642,7 +642,7 @@ const_assert!(DesiredMembers::get() <= CouncilMaxMembers::get()); impl pallet_elections_phragmen::Config for Runtime { type Event = Event; - type ModuleId = ElectionsPhragmenModuleId; + type PalletId = ElectionsPhragmenPalletId; type Currency = Balances; type ChangeMembers = Council; // NOTE: this implies that council's genesis members cannot be set directly and must come from @@ -705,7 +705,7 @@ parameter_types! { pub const DataDepositPerByte: Balance = 1 * CENTS; pub const BountyDepositBase: Balance = 1 * DOLLARS; pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS; - pub const TreasuryModuleId: ModuleId = ModuleId(*b"py/trsry"); + pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry"); pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS; pub const MaximumReasonLength: u32 = 16384; pub const BountyCuratorDeposit: Permill = Permill::from_percent(50); @@ -713,7 +713,7 @@ parameter_types! { } impl pallet_treasury::Config for Runtime { - type ModuleId = TreasuryModuleId; + type PalletId = TreasuryPalletId; type Currency = Balances; type ApproveOrigin = EnsureOneOf< AccountId, @@ -970,12 +970,12 @@ parameter_types! { pub const MaxLockDuration: BlockNumber = 36 * 30 * DAYS; pub const ChallengePeriod: BlockNumber = 7 * DAYS; pub const MaxCandidateIntake: u32 = 10; - pub const SocietyModuleId: ModuleId = ModuleId(*b"py/socie"); + pub const SocietyPalletId: PalletId = PalletId(*b"py/socie"); } impl pallet_society::Config for Runtime { type Event = Event; - type ModuleId = SocietyModuleId; + type PalletId = SocietyPalletId; type Currency = Balances; type Randomness = RandomnessCollectiveFlip; type CandidateDeposit = CandidateDeposit; @@ -1013,13 +1013,13 @@ impl pallet_mmr::Config for Runtime { } parameter_types! { - pub const LotteryModuleId: ModuleId = ModuleId(*b"py/lotto"); + pub const LotteryPalletId: PalletId = PalletId(*b"py/lotto"); pub const MaxCalls: usize = 10; pub const MaxGenerateRandom: u32 = 10; } impl pallet_lottery::Config for Runtime { - type ModuleId = LotteryModuleId; + type PalletId = LotteryPalletId; type Call = Call; type Currency = Balances; type Randomness = RandomnessCollectiveFlip; diff --git a/frame/bounties/src/lib.rs b/frame/bounties/src/lib.rs index dafa7cd61d054..419713ab5eff5 100644 --- a/frame/bounties/src/lib.rs +++ b/frame/bounties/src/lib.rs @@ -677,14 +677,14 @@ impl Module { /// This actually does computation. If you need to keep using it, then make sure you cache the /// value and only call this once. pub fn account_id() -> T::AccountId { - T::ModuleId::get().into_account() + T::PalletId::get().into_account() } /// The account ID of a bounty account pub fn bounty_account_id(id: BountyIndex) -> T::AccountId { // only use two byte prefix to support 16 byte account id (used by test) // "modl" ++ "py/trsry" ++ "bt" is 14 bytes, and two bytes remaining for bounty index - T::ModuleId::get().into_sub_account(("bt", id)) + T::PalletId::get().into_sub_account(("bt", id)) } fn create_bounty( diff --git a/frame/bounties/src/tests.rs b/frame/bounties/src/tests.rs index d676c940f5afe..6cef52cc1064b 100644 --- a/frame/bounties/src/tests.rs +++ b/frame/bounties/src/tests.rs @@ -24,12 +24,13 @@ use super::*; use std::cell::RefCell; use frame_support::{ - assert_noop, assert_ok, parameter_types, weights::Weight, traits::OnInitialize + assert_noop, assert_ok, parameter_types, weights::Weight, traits::OnInitialize, + PalletId }; use sp_core::H256; use sp_runtime::{ - Perbill, ModuleId, + Perbill, testing::Header, traits::{BlakeTwo256, IdentityLookup, BadOrigin}, }; @@ -103,11 +104,11 @@ parameter_types! { pub const SpendPeriod: u64 = 2; pub const Burn: Permill = Permill::from_percent(50); pub const DataDepositPerByte: u64 = 1; - pub const TreasuryModuleId: ModuleId = ModuleId(*b"py/trsry"); + pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry"); } // impl pallet_treasury::Config for Test { impl pallet_treasury::Config for Test { - type ModuleId = TreasuryModuleId; + type PalletId = TreasuryPalletId; type Currency = pallet_balances::Pallet; type ApproveOrigin = frame_system::EnsureRoot; type RejectOrigin = frame_system::EnsureRoot; diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index 4c84c72b0b305..6317bcebacce8 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -175,7 +175,7 @@ pub trait Config: frame_system::Config { type Event: From> + Into<::Event>; /// Identifier for the elections-phragmen pallet's lock - type ModuleId: Get; + type PalletId: Get; /// The currency that people are electing with. type Currency: @@ -375,7 +375,7 @@ decl_module! { const DesiredMembers: u32 = T::DesiredMembers::get(); const DesiredRunnersUp: u32 = T::DesiredRunnersUp::get(); const TermDuration: T::BlockNumber = T::TermDuration::get(); - const ModuleId: LockIdentifier = T::ModuleId::get(); + const PalletId: LockIdentifier = T::PalletId::get(); /// Vote for a set of candidates for the upcoming round of election. This can be called to /// set the initial votes, or update already existing votes. @@ -452,7 +452,7 @@ decl_module! { // Amount to be locked up. let locked_stake = value.min(T::Currency::total_balance(&who)); T::Currency::set_lock( - T::ModuleId::get(), + T::PalletId::get(), &who, locked_stake, WithdrawReasons::all(), @@ -807,7 +807,7 @@ impl Module { let Voter { deposit, .. } = >::take(who); // remove storage, lock and unreserve. - T::Currency::remove_lock(T::ModuleId::get(), who); + T::Currency::remove_lock(T::PalletId::get(), who); // NOTE: we could check the deposit amount before removing and skip if zero, but it will be // a noop anyhow. @@ -1158,11 +1158,11 @@ mod tests { } parameter_types! { - pub const ElectionsPhragmenModuleId: LockIdentifier = *b"phrelect"; + pub const ElectionsPhragmenPalletId: LockIdentifier = *b"phrelect"; } impl Config for Test { - type ModuleId = ElectionsPhragmenModuleId; + type PalletId = ElectionsPhragmenPalletId; type Event = Event; type Currency = Balances; type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote; @@ -1313,7 +1313,7 @@ mod tests { .get(0) .cloned() .map(|lock| { - assert_eq!(lock.id, ElectionsPhragmenModuleId::get()); + assert_eq!(lock.id, ElectionsPhragmenPalletId::get()); lock.amount }) .unwrap_or_default() diff --git a/frame/elections/src/lib.rs b/frame/elections/src/lib.rs index d6b68bbf5a043..46ec62bf75174 100644 --- a/frame/elections/src/lib.rs +++ b/frame/elections/src/lib.rs @@ -156,7 +156,7 @@ pub trait Config: frame_system::Config { type Event: From> + Into<::Event>; /// Identifier for the elections pallet's lock - type ModuleId: Get; + type PalletId: Get; /// The currency that people are electing with. type Currency: @@ -391,7 +391,7 @@ decl_module! { /// The chunk size of the approval vector. const APPROVAL_SET_SIZE: u32 = APPROVAL_SET_SIZE as u32; - const ModuleId: LockIdentifier = T::ModuleId::get(); + const PalletId: LockIdentifier = T::PalletId::get(); fn deposit_event() = default; @@ -491,7 +491,7 @@ decl_module! { ); T::Currency::remove_lock( - T::ModuleId::get(), + T::PalletId::get(), if valid { &who } else { &reporter } ); @@ -529,7 +529,7 @@ decl_module! { Self::remove_voter(&who, index); T::Currency::unreserve(&who, T::VotingBond::get()); - T::Currency::remove_lock(T::ModuleId::get(), &who); + T::Currency::remove_lock(T::PalletId::get(), &who); } /// Submit oneself for candidacy. @@ -890,7 +890,7 @@ impl Module { } T::Currency::set_lock( - T::ModuleId::get(), + T::PalletId::get(), &who, locked_balance, WithdrawReasons::all(), diff --git a/frame/elections/src/mock.rs b/frame/elections/src/mock.rs index 3a9cca41ff0e9..896fd40020e41 100644 --- a/frame/elections/src/mock.rs +++ b/frame/elections/src/mock.rs @@ -103,7 +103,7 @@ impl ChangeMembers for TestChangeMembers { } parameter_types!{ - pub const ElectionModuleId: LockIdentifier = *b"py/elect"; + pub const ElectionPalletId: LockIdentifier = *b"py/elect"; } impl elections::Config for Test { @@ -123,7 +123,7 @@ impl elections::Config for Test { type InactiveGracePeriod = InactiveGracePeriod; type VotingPeriod = VotingPeriod; type DecayRatio = DecayRatio; - type ModuleId = ElectionModuleId; + type PalletId = ElectionPalletId; } pub type Block = sp_runtime::generic::Block; diff --git a/frame/lottery/src/lib.rs b/frame/lottery/src/lib.rs index fb675ad83519b..a37238a2d9f85 100644 --- a/frame/lottery/src/lib.rs +++ b/frame/lottery/src/lib.rs @@ -56,7 +56,7 @@ pub mod weights; use sp_std::prelude::*; use sp_runtime::{ - DispatchError, ModuleId, + DispatchError, traits::{AccountIdConversion, Saturating, Zero}, }; use frame_support::{ @@ -66,7 +66,7 @@ use frame_support::{ Currency, ReservableCurrency, Get, EnsureOrigin, ExistenceRequirement::KeepAlive, Randomness, }, }; -use frame_support::weights::Weight; +use frame_support::{weights::Weight, PalletId}; use frame_system::ensure_signed; use codec::{Encode, Decode}; pub use weights::WeightInfo; @@ -76,7 +76,7 @@ type BalanceOf = <::Currency as Currency<; + type PalletId: Get; /// A dispatchable call. type Call: Parameter + Dispatchable + GetDispatchInfo + From>; @@ -211,7 +211,7 @@ decl_module! { pub struct Module for enum Call where origin: T::Origin, system = frame_system { type Error = Error; - const ModuleId: ModuleId = T::ModuleId::get(); + const PalletId: PalletId = T::PalletId::get(); const MaxCalls: u32 = T::MaxCalls::get() as u32; fn deposit_event() = default; @@ -361,7 +361,7 @@ impl Module { /// This actually does computation. If you need to keep using it, then make sure you cache the /// value and only call this once. pub fn account_id() -> T::AccountId { - T::ModuleId::get().into_account() + T::PalletId::get().into_account() } /// Return the pot account and amount of money in the pot. @@ -449,7 +449,7 @@ impl Module { // TODO: deal with randomness freshness // https://github.com/paritytech/substrate/issues/8311 fn generate_random_number(seed: u32) -> u32 { - let (random_seed, _) = T::Randomness::random(&(T::ModuleId::get(), seed).encode()); + let (random_seed, _) = T::Randomness::random(&(T::PalletId::get(), seed).encode()); let random_number = ::decode(&mut random_seed.as_ref()) .expect("secure hashes should always be bigger than u32; qed"); random_number diff --git a/frame/lottery/src/mock.rs b/frame/lottery/src/mock.rs index 9015de5b0853a..ca372cc37e24e 100644 --- a/frame/lottery/src/mock.rs +++ b/frame/lottery/src/mock.rs @@ -96,13 +96,13 @@ impl pallet_balances::Config for Test { } parameter_types! { - pub const LotteryModuleId: ModuleId = ModuleId(*b"py/lotto"); + pub const LotteryPalletId: PalletId = PalletId(*b"py/lotto"); pub const MaxCalls: usize = 2; pub const MaxGenerateRandom: u32 = 10; } impl Config for Test { - type ModuleId = LotteryModuleId; + type PalletId = LotteryPalletId; type Call = Call; type Currency = Balances; type Randomness = TestRandomness; diff --git a/frame/society/src/lib.rs b/frame/society/src/lib.rs index 64caf328002af..37f32ce45714d 100644 --- a/frame/society/src/lib.rs +++ b/frame/society/src/lib.rs @@ -254,13 +254,13 @@ mod tests; use rand_chacha::{rand_core::{RngCore, SeedableRng}, ChaChaRng}; use sp_std::prelude::*; use codec::{Encode, Decode}; -use sp_runtime::{Percent, ModuleId, RuntimeDebug, +use sp_runtime::{Percent, RuntimeDebug, traits::{ StaticLookup, AccountIdConversion, Saturating, Zero, IntegerSquareRoot, Hash, TrailingZeroInput, CheckedSub } }; -use frame_support::{decl_error, decl_module, decl_storage, decl_event, ensure, dispatch::DispatchResult}; +use frame_support::{decl_error, decl_module, decl_storage, decl_event, ensure, dispatch::DispatchResult, PalletId}; use frame_support::weights::Weight; use frame_support::traits::{ Currency, ReservableCurrency, Randomness, Get, ChangeMembers, BalanceStatus, @@ -277,7 +277,7 @@ pub trait Config: system::Config { type Event: From> + Into<::Event>; /// The societies's module id - type ModuleId: Get; + type PalletId: Get; /// The currency type used for bidding. type Currency: ReservableCurrency; @@ -498,7 +498,7 @@ decl_module! { const ChallengePeriod: T::BlockNumber = T::ChallengePeriod::get(); /// The societies's module id - const ModuleId: ModuleId = T::ModuleId::get(); + const PalletId: PalletId = T::PalletId::get(); /// Maximum candidate intake per round. const MaxCandidateIntake: u32 = T::MaxCandidateIntake::get(); @@ -1600,7 +1600,7 @@ impl, I: Instance> Module { /// This actually does computation. If you need to keep using it, then make sure you cache the /// value and only call this once. pub fn account_id() -> T::AccountId { - T::ModuleId::get().into_account() + T::PalletId::get().into_account() } /// The account ID of the payouts pot. This is where payouts are made from. @@ -1608,7 +1608,7 @@ impl, I: Instance> Module { /// This actually does computation. If you need to keep using it, then make sure you cache the /// value and only call this once. pub fn payouts() -> T::AccountId { - T::ModuleId::get().into_sub_account(b"payouts") + T::PalletId::get().into_sub_account(b"payouts") } /// Return the duration of the lock, in blocks, with the given number of members. diff --git a/frame/society/src/mock.rs b/frame/society/src/mock.rs index f2d16423f3cc5..aa46d40a14ae9 100644 --- a/frame/society/src/mock.rs +++ b/frame/society/src/mock.rs @@ -58,7 +58,7 @@ parameter_types! { pub const BlockHashCount: u64 = 250; pub const ExistentialDeposit: u64 = 1; pub const MaxCandidateIntake: u32 = 10; - pub const SocietyModuleId: ModuleId = ModuleId(*b"py/socie"); + pub const SocietyPalletId: PalletId = PalletId(*b"py/socie"); pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::simple_max(1024); } @@ -119,7 +119,7 @@ impl Config for Test { type SuspensionJudgementOrigin = EnsureSignedBy; type ChallengePeriod = ChallengePeriod; type MaxCandidateIntake = MaxCandidateIntake; - type ModuleId = SocietyModuleId; + type PalletId = SocietyPalletId; } pub struct EnvBuilder { diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index 362c4c5a0a73b..865819c7555f5 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -80,6 +80,9 @@ pub use self::storage::{ pub use self::dispatch::{Parameter, Callable}; pub use sp_runtime::{self, ConsensusEngineId, print, traits::Printable}; +use codec::{Encode, Decode}; +use sp_runtime::TypeId; + /// A unified log target for support operations. pub const LOG_TARGET: &'static str = "runtime::frame-support"; @@ -87,6 +90,14 @@ pub const LOG_TARGET: &'static str = "runtime::frame-support"; #[derive(Debug, PartialEq, Eq, Clone)] pub enum Never {} +/// A pallet identifier. These are per pallet and should be stored in a registry somewhere. +#[derive(Clone, Copy, Eq, PartialEq, Encode, Decode)] +pub struct PalletId(pub [u8; 8]); + +impl TypeId for PalletId { + const TYPE_ID: [u8; 4] = *b"modl"; +} + /// Generate a new type alias for [`storage::types::value::StorageValue`], /// [`storage::types::value::StorageMap`] and [`storage::types::value::StorageDoubleMap`]. /// diff --git a/frame/tips/src/lib.rs b/frame/tips/src/lib.rs index 015163ef6b513..10b2b016837c0 100644 --- a/frame/tips/src/lib.rs +++ b/frame/tips/src/lib.rs @@ -444,7 +444,7 @@ impl Module { /// This actually does computation. If you need to keep using it, then make sure you cache the /// value and only call this once. pub fn account_id() -> T::AccountId { - T::ModuleId::get().into_account() + T::PalletId::get().into_account() } /// Given a mutable reference to an `OpenTip`, insert the tip into it and check whether it diff --git a/frame/tips/src/tests.rs b/frame/tips/src/tests.rs index c57c427810d05..9524c136aafdb 100644 --- a/frame/tips/src/tests.rs +++ b/frame/tips/src/tests.rs @@ -22,11 +22,15 @@ use crate as tips; use super::*; use std::cell::RefCell; -use frame_support::{assert_noop, assert_ok, parameter_types, weights::Weight, traits::Contains}; +use frame_support::{ + assert_noop, assert_ok, parameter_types, + weights::Weight, traits::Contains, + PalletId +}; use sp_runtime::Permill; use sp_core::H256; use sp_runtime::{ - Perbill, ModuleId, + Perbill, testing::Header, traits::{BlakeTwo256, IdentityLookup, BadOrigin}, }; @@ -121,11 +125,11 @@ parameter_types! { pub const SpendPeriod: u64 = 2; pub const Burn: Permill = Permill::from_percent(50); pub const DataDepositPerByte: u64 = 1; - pub const TreasuryModuleId: ModuleId = ModuleId(*b"py/trsry"); + pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry"); pub const MaximumReasonLength: u32 = 16384; } impl pallet_treasury::Config for Test { - type ModuleId = TreasuryModuleId; + type PalletId = TreasuryPalletId; type Currency = pallet_balances::Pallet; type ApproveOrigin = frame_system::EnsureRoot; type RejectOrigin = frame_system::EnsureRoot; diff --git a/frame/treasury/src/lib.rs b/frame/treasury/src/lib.rs index cef50706b5173..85e9d40951d8c 100644 --- a/frame/treasury/src/lib.rs +++ b/frame/treasury/src/lib.rs @@ -66,14 +66,17 @@ pub mod weights; #[cfg(feature = "std")] use serde::{Serialize, Deserialize}; use sp_std::prelude::*; -use frame_support::{decl_module, decl_storage, decl_event, ensure, print, decl_error}; +use frame_support::{decl_module, decl_storage, decl_event, ensure, print, decl_error, PalletId}; use frame_support::traits::{ - Currency, Get, Imbalance, OnUnbalanced, ExistenceRequirement::{KeepAlive}, + Currency, Get, Imbalance, OnUnbalanced, ExistenceRequirement::KeepAlive, ReservableCurrency, WithdrawReasons }; -use sp_runtime::{Permill, ModuleId, RuntimeDebug, traits::{ - Zero, StaticLookup, AccountIdConversion, Saturating -}}; +use sp_runtime::{ + Permill, RuntimeDebug, + traits::{ + Zero, StaticLookup, AccountIdConversion, Saturating + } +}; use frame_support::weights::{Weight, DispatchClass}; use frame_support::traits::{EnsureOrigin}; use codec::{Encode, Decode}; @@ -89,7 +92,7 @@ pub type NegativeImbalanceOf = pub trait Config: frame_system::Config { /// The treasury's module id, used for deriving its sovereign account ID. - type ModuleId: Get; + type PalletId: Get; /// The staking balance. type Currency: Currency + ReservableCurrency; @@ -249,7 +252,7 @@ decl_module! { const Burn: Permill = T::Burn::get(); /// The treasury's module id, used for deriving its sovereign account ID. - const ModuleId: ModuleId = T::ModuleId::get(); + const PalletId: PalletId = T::PalletId::get(); type Error = Error; @@ -349,7 +352,7 @@ impl, I: Instance> Module { /// This actually does computation. If you need to keep using it, then make sure you cache the /// value and only call this once. pub fn account_id() -> T::AccountId { - T::ModuleId::get().into_account() + T::PalletId::get().into_account() } /// The needed bond for a proposal whose spend is `value`. diff --git a/frame/treasury/src/tests.rs b/frame/treasury/src/tests.rs index 25bfc6af81dea..3ff9d63b1096a 100644 --- a/frame/treasury/src/tests.rs +++ b/frame/treasury/src/tests.rs @@ -24,12 +24,11 @@ use super::*; use std::cell::RefCell; use frame_support::{ assert_noop, assert_ok, parameter_types, - traits::OnInitialize, + traits::OnInitialize, PalletId }; use sp_core::H256; use sp_runtime::{ - ModuleId, testing::Header, traits::{BlakeTwo256, IdentityLookup}, }; @@ -99,13 +98,13 @@ parameter_types! { pub const ProposalBondMinimum: u64 = 1; pub const SpendPeriod: u64 = 2; pub const Burn: Permill = Permill::from_percent(50); - pub const TreasuryModuleId: ModuleId = ModuleId(*b"py/trsry"); + pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry"); pub const BountyUpdatePeriod: u32 = 20; pub const BountyCuratorDeposit: Permill = Permill::from_percent(50); pub const BountyValueMinimum: u64 = 1; } impl Config for Test { - type ModuleId = TreasuryModuleId; + type PalletId = TreasuryPalletId; type Currency = pallet_balances::Pallet; type ApproveOrigin = frame_system::EnsureRoot; type RejectOrigin = frame_system::EnsureRoot; diff --git a/primitives/runtime/src/lib.rs b/primitives/runtime/src/lib.rs index 9f900bef9b108..51b89d484e6ce 100644 --- a/primitives/runtime/src/lib.rs +++ b/primitives/runtime/src/lib.rs @@ -158,14 +158,6 @@ impl From for Justifications { use traits::{Verify, Lazy}; -/// A module identifier. These are per module and should be stored in a registry somewhere. -#[derive(Clone, Copy, Eq, PartialEq, Encode, Decode)] -pub struct ModuleId(pub [u8; 8]); - -impl TypeId for ModuleId { - const TYPE_ID: [u8; 4] = *b"modl"; -} - #[cfg(feature = "std")] pub use serde::{Serialize, Deserialize, de::DeserializeOwned}; use crate::traits::IdentifyAccount; diff --git a/utils/frame/frame-utilities-cli/Cargo.toml b/utils/frame/frame-utilities-cli/Cargo.toml index cb37119edf0b2..1fdf4e4cd9a97 100644 --- a/utils/frame/frame-utilities-cli/Cargo.toml +++ b/utils/frame/frame-utilities-cli/Cargo.toml @@ -16,6 +16,7 @@ sc-cli = { version = "0.9.0", path = "../../../client/cli" } sp-runtime = { version = "3.0.0", path = "../../../primitives/runtime" } structopt = "0.3.8" frame-system = { version = "3.0.0", path = "../../../frame/system" } +frame-support = { version = "3.0.0", path = "../../../frame/support" } [dev-dependencies] diff --git a/utils/frame/frame-utilities-cli/src/lib.rs b/utils/frame/frame-utilities-cli/src/lib.rs index 2d6bf4ab9d8f1..83f3e9ea00d45 100644 --- a/utils/frame/frame-utilities-cli/src/lib.rs +++ b/utils/frame/frame-utilities-cli/src/lib.rs @@ -17,7 +17,7 @@ //! frame-system CLI utilities -mod module_id; +mod pallet_id; -pub use module_id::ModuleIdCmd; +pub use pallet_id::PalletIdCmd; diff --git a/utils/frame/frame-utilities-cli/src/module_id.rs b/utils/frame/frame-utilities-cli/src/pallet_id.rs similarity index 88% rename from utils/frame/frame-utilities-cli/src/module_id.rs rename to utils/frame/frame-utilities-cli/src/pallet_id.rs index 187c2de1dd6d5..09304979cb09f 100644 --- a/utils/frame/frame-utilities-cli/src/module_id.rs +++ b/utils/frame/frame-utilities-cli/src/pallet_id.rs @@ -15,25 +15,25 @@ // See the License for the specific language governing permissions and // limitations under the License. -//! Implementation of the `moduleid` subcommand +//! Implementation of the `palletid` subcommand use sc_cli::{ Error, utils::print_from_uri, CryptoSchemeFlag, OutputTypeFlag, KeystoreParams, with_crypto_scheme, }; -use sp_runtime::ModuleId; use sp_runtime::traits::AccountIdConversion; use sp_core::crypto::{Ss58Codec, Ss58AddressFormat}; use std::convert::{TryInto, TryFrom}; use structopt::StructOpt; +use frame_support::PalletId; -/// The `moduleid` command +/// The `palletid` command #[derive(Debug, StructOpt)] #[structopt( - name = "moduleid", + name = "palletid", about = "Inspect a module ID address" )] -pub struct ModuleIdCmd { +pub struct PalletIdCmd { /// The module ID used to derive the account id: String, @@ -60,7 +60,7 @@ pub struct ModuleIdCmd { pub keystore_params: KeystoreParams, } -impl ModuleIdCmd { +impl PalletIdCmd { /// runs the command pub fn run(&self) -> Result<(), Error> where @@ -74,9 +74,9 @@ impl ModuleIdCmd { let id_fixed_array: [u8; 8] = self.id.as_bytes() .try_into() - .map_err(|_| "Cannot convert argument to moduleid: argument should be 8-character string")?; + .map_err(|_| "Cannot convert argument to palletid: argument should be 8-character string")?; - let account_id: R::AccountId = ModuleId(id_fixed_array).into_account(); + let account_id: R::AccountId = PalletId(id_fixed_array).into_account(); with_crypto_scheme!( self.crypto_scheme.scheme,