Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
ModuleId to PalletId
  • Loading branch information
aurexav committed Apr 7, 2021
commit 1e710d4e14cb36ba07e4bf61f162e9a53f7b45df
16 changes: 8 additions & 8 deletions runtime/common/src/crowdloan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
//! returned to the crowdloan account.

use frame_support::{
decl_module, decl_storage, decl_event, decl_error, ensure, Identity,
decl_module, decl_storage, decl_event, decl_error, ensure, Identity, PalletId,
storage::{child, ChildTriePrefixIterator},
traits::{
Currency, ReservableCurrency, Get, ExistenceRequirement::AllowDeath
Expand All @@ -59,7 +59,7 @@ use frame_support::{
};
use frame_system::{ensure_signed, ensure_root};
use sp_runtime::{
ModuleId, DispatchResult, RuntimeDebug, MultiSignature, MultiSigner,
DispatchResult, RuntimeDebug, MultiSignature, MultiSigner,
traits::{
AccountIdConversion, Hash, Saturating, Zero, One, CheckedAdd, Verify, IdentifyAccount,
},
Expand Down Expand Up @@ -107,8 +107,8 @@ impl WeightInfo for TestWeightInfo {
pub trait Config: frame_system::Config {
type Event: From<Event<Self>> + Into<<Self as frame_system::Config>::Event>;

/// ModuleID for the crowdloan module. An appropriate value could be ```ModuleId(*b"py/cfund")```
type ModuleId: Get<ModuleId>;
/// PalletId for the crowdloan module. An appropriate value could be ```PalletId(*b"py/cfund")```
type PalletId: Get<PalletId>;

/// The amount to be held on deposit by the depositor of a crowdloan.
type SubmissionDeposit: Get<BalanceOf<Self>>;
Expand Down Expand Up @@ -287,7 +287,7 @@ decl_module! {
pub struct Module<T: Config> for enum Call where origin: <T as frame_system::Config>::Origin {
type Error = Error<T>;

const ModuleId: ModuleId = T::ModuleId::get();
const PalletId: PalletId = T::PalletId::get();
const MinContribution: BalanceOf<T> = T::MinContribution::get();
const RemoveKeysLimit: u32 = T::RemoveKeysLimit::get();

Expand Down Expand Up @@ -626,7 +626,7 @@ impl<T: Config> Module<T> {
/// 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 fund_account_id(index: ParaId) -> T::AccountId {
T::ModuleId::get().into_sub_account(index)
T::PalletId::get().into_sub_account(index)
}

pub fn id_from_index(index: TrieIndex) -> child::ChildInfo {
Expand Down Expand Up @@ -895,7 +895,7 @@ mod tests {
parameter_types! {
pub const SubmissionDeposit: u64 = 1;
pub const MinContribution: u64 = 10;
pub const CrowdloanModuleId: ModuleId = ModuleId(*b"py/cfund");
pub const CrowdloanPalletId: PalletId = PalletId(*b"py/cfund");
pub const RemoveKeysLimit: u32 = 10;
pub const MaxMemoLength: u8 = 32;
}
Expand All @@ -904,7 +904,7 @@ mod tests {
type Event = Event;
type SubmissionDeposit = SubmissionDeposit;
type MinContribution = MinContribution;
type ModuleId = CrowdloanModuleId;
type PalletId = CrowdloanPalletId;
type RemoveKeysLimit = RemoveKeysLimit;
type Registrar = TestRegistrar<Test>;
type Auctioneer = TestAuctioneer;
Expand Down
8 changes: 4 additions & 4 deletions runtime/common/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ where
mod tests {
use super::*;
use frame_system::limits;
use frame_support::{parameter_types, weights::DispatchClass};
use frame_support::{parameter_types, PalletId, weights::DispatchClass};
use frame_support::traits::FindAuthor;
use sp_core::H256;
use sp_runtime::{
testing::Header, ModuleId,
testing::Header,
traits::{BlakeTwo256, IdentityLookup},
Perbill,
};
Expand Down Expand Up @@ -141,7 +141,7 @@ mod tests {
}

parameter_types! {
pub const TreasuryModuleId: ModuleId = ModuleId(*b"py/trsry");
pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry");
}

impl pallet_treasury::Config for Test {
Expand All @@ -155,7 +155,7 @@ mod tests {
type SpendPeriod = ();
type Burn = ();
type BurnDestination = ();
type ModuleId = TreasuryModuleId;
type PalletId = TreasuryPalletId;
type SpendFunds = ();
type WeightInfo = ();
}
Expand Down
7 changes: 3 additions & 4 deletions runtime/common/src/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@ use sp_std::sync::Arc;
use sp_io::TestExternalities;
use sp_core::{H256, crypto::KeyTypeId};
use sp_runtime::{
ModuleId,
traits::{
BlakeTwo256, IdentityLookup, One,
},
};
use sp_keystore::{KeystoreExt, testing::KeyStore};
use primitives::v1::{BlockNumber, Header, Id as ParaId, ValidationCode, HeadData};
use frame_support::{
parameter_types, assert_ok, assert_noop,
parameter_types, assert_ok, assert_noop, PalletId,
storage::StorageMap,
traits::{Currency, OnInitialize, OnFinalize, KeyOwnerProofSystem},
};
Expand Down Expand Up @@ -213,7 +212,7 @@ impl slots::Config for Test {
}

parameter_types! {
pub const CrowdloanId: ModuleId = ModuleId(*b"py/cfund");
pub const CrowdloanId: PalletId = PalletId(*b"py/cfund");
pub const SubmissionDeposit: Balance = 100;
pub const MinContribution: Balance = 1;
pub const RetirementPeriod: BlockNumber = 10;
Expand All @@ -223,7 +222,7 @@ parameter_types! {

impl crowdloan::Config for Test {
type Event = Event;
type ModuleId = CrowdloanId;
type PalletId = CrowdloanId;
type SubmissionDeposit = SubmissionDeposit;
type MinContribution = MinContribution;
type RemoveKeysLimit = RemoveKeysLimit;
Expand Down
16 changes: 8 additions & 8 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use runtime_common::{
ParachainSessionKeyPlaceholder, AssignmentSessionKeyPlaceholder,
};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys, ModuleId,
create_runtime_str, generic, impl_opaque_keys,
ApplyExtrinsicResult, KeyTypeId, Percent, Permill, Perbill,
transaction_validity::{TransactionValidity, TransactionSource, TransactionPriority},
curve::PiecewiseLinear,
Expand All @@ -56,7 +56,7 @@ use sp_version::NativeVersion;
use sp_core::OpaqueMetadata;
use sp_staking::SessionIndex;
use frame_support::{
parameter_types, construct_runtime, RuntimeDebug,
parameter_types, construct_runtime, RuntimeDebug, PalletId,
traits::{KeyOwnerProofSystem, Randomness, LockIdentifier, Filter, InstanceFilter},
weights::Weight,
};
Expand Down Expand Up @@ -494,7 +494,7 @@ parameter_types! {
pub const TermDuration: BlockNumber = 24 * HOURS;
pub const DesiredMembers: u32 = 19;
pub const DesiredRunnersUp: u32 = 19;
pub const ElectionsPhragmenModuleId: LockIdentifier = *b"phrelect";
pub const ElectionsPhragmenPalletId: LockIdentifier = *b"phrelect";
}

// Make sure that there are no more than MaxMembers members elected via phragmen.
Expand All @@ -514,7 +514,7 @@ impl pallet_elections_phragmen::Config for Runtime {
type DesiredMembers = DesiredMembers;
type DesiredRunnersUp = DesiredRunnersUp;
type TermDuration = TermDuration;
type ModuleId = ElectionsPhragmenModuleId;
type PalletId = ElectionsPhragmenPalletId;
type WeightInfo = weights::pallet_elections_phragmen::WeightInfo<Runtime>;
}

Expand Down Expand Up @@ -552,7 +552,7 @@ parameter_types! {
pub const ProposalBondMinimum: Balance = 20 * DOLLARS;
pub const SpendPeriod: BlockNumber = 6 * DAYS;
pub const Burn: Permill = Permill::from_perthousand(2);
pub const TreasuryModuleId: ModuleId = ModuleId(*b"py/trsry");
pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry");

pub const TipCountdown: BlockNumber = 1 * DAYS;
pub const TipFindersFee: Percent = Percent::from_percent(20);
Expand All @@ -573,7 +573,7 @@ type ApproveOrigin = EnsureOneOf<
>;

impl pallet_treasury::Config for Runtime {
type ModuleId = TreasuryModuleId;
type PalletId = TreasuryPalletId;
type Currency = Balances;
type ApproveOrigin = ApproveOrigin;
type RejectOrigin = MoreThanHalfCouncil;
Expand Down Expand Up @@ -805,7 +805,7 @@ parameter_types! {
pub const MaxLockDuration: BlockNumber = 36 * 30 * DAYS;
pub const ChallengePeriod: BlockNumber = 7 * DAYS;
pub const MaxCandidateIntake: u32 = 1;
pub const SocietyModuleId: ModuleId = ModuleId(*b"py/socie");
pub const SocietyPalletId: PalletId = PalletId(*b"py/socie");
}

impl pallet_society::Config for Runtime {
Expand All @@ -823,7 +823,7 @@ impl pallet_society::Config for Runtime {
type SuspensionJudgementOrigin = pallet_society::EnsureFounder<Runtime>;
type ChallengePeriod = ChallengePeriod;
type MaxCandidateIntake = MaxCandidateIntake;
type ModuleId = SocietyModuleId;
type PalletId = SocietyPalletId;
}

parameter_types! {
Expand Down
12 changes: 6 additions & 6 deletions runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use primitives::v1::{
InboundDownwardMessage, InboundHrmpMessage, SessionInfo,
};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys, ModuleId, ApplyExtrinsicResult,
create_runtime_str, generic, impl_opaque_keys, ApplyExtrinsicResult,
KeyTypeId, Percent, Permill, Perbill, curve::PiecewiseLinear,
transaction_validity::{TransactionValidity, TransactionSource, TransactionPriority},
traits::{
Expand All @@ -56,7 +56,7 @@ use sp_version::NativeVersion;
use sp_core::OpaqueMetadata;
use sp_staking::SessionIndex;
use frame_support::{
parameter_types, construct_runtime, RuntimeDebug,
parameter_types, construct_runtime, RuntimeDebug, PalletId,
traits::{KeyOwnerProofSystem, Randomness, LockIdentifier, Filter},
weights::Weight,
};
Expand Down Expand Up @@ -542,14 +542,14 @@ parameter_types! {
/// 13 members initially, to be increased to 23 eventually.
pub const DesiredMembers: u32 = 13;
pub const DesiredRunnersUp: u32 = 20;
pub const ElectionsPhragmenModuleId: LockIdentifier = *b"phrelect";
pub const ElectionsPhragmenPalletId: LockIdentifier = *b"phrelect";
}
// Make sure that there are no more than `MaxMembers` members elected via phragmen.
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;
type InitializeMembers = Council;
Expand Down Expand Up @@ -599,7 +599,7 @@ parameter_types! {
pub const ProposalBondMinimum: Balance = 100 * DOLLARS;
pub const SpendPeriod: BlockNumber = 24 * DAYS;
pub const Burn: Permill = Permill::from_percent(1);
pub const TreasuryModuleId: ModuleId = ModuleId(*b"py/trsry");
pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry");

pub const TipCountdown: BlockNumber = 1 * DAYS;
pub const TipFindersFee: Percent = Percent::from_percent(20);
Expand All @@ -620,7 +620,7 @@ type ApproveOrigin = EnsureOneOf<
>;

impl pallet_treasury::Config for Runtime {
type ModuleId = TreasuryModuleId;
type PalletId = TreasuryPalletId;
type Currency = Balances;
type ApproveOrigin = ApproveOrigin;
type RejectOrigin = MoreThanHalfCouncil;
Expand Down
13 changes: 9 additions & 4 deletions runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,15 @@ use runtime_parachains::{
self,
runtime_api_impl::v1 as runtime_api_impl,
};
use frame_support::{construct_runtime, parameter_types, traits::{Filter, KeyOwnerProofSystem, Randomness}, weights::Weight};
use frame_support::{
construct_runtime, parameter_types,
traits::{Filter, KeyOwnerProofSystem, Randomness},
weights::Weight,
PalletId
};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
ApplyExtrinsicResult, KeyTypeId, Perbill, ModuleId,
ApplyExtrinsicResult, KeyTypeId, Perbill,
transaction_validity::{TransactionValidity, TransactionSource, TransactionPriority},
traits::{
self, Keccak256, BlakeTwo256, Block as BlockT, OpaqueKeys, AccountIdLookup,
Expand Down Expand Up @@ -732,7 +737,7 @@ impl slots::Config for Runtime {
}

parameter_types! {
pub const CrowdloanId: ModuleId = ModuleId(*b"py/cfund");
pub const CrowdloanId: PalletId = PalletId(*b"py/cfund");
pub const SubmissionDeposit: Balance = 100 * DOLLARS;
pub const MinContribution: Balance = 1 * DOLLARS;
pub const RetirementPeriod: BlockNumber = 6 * HOURS;
Expand All @@ -743,7 +748,7 @@ parameter_types! {

impl crowdloan::Config for Runtime {
type Event = Event;
type ModuleId = CrowdloanId;
type PalletId = CrowdloanId;
type SubmissionDeposit = SubmissionDeposit;
type MinContribution = MinContribution;
type RemoveKeysLimit = RemoveKeysLimit;
Expand Down