ModuleId to PalletId - part of #8372 (#8477)

* `ModuleId` to `PalletId` - part of #8372

* fix doc

* move `PalletId` to `frame-support`

* fix compile

* fix tests

* `ModuleId` to `PalletId`

* subcommand `moduleid` to `palletid`
This commit is contained in:
Xavier Lau
2021-04-09 17:15:40 +08:00
committed by GitHub
parent c675310227
commit d6f0ce0551
20 changed files with 92 additions and 80 deletions
+6 -6
View File
@@ -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<I = DefaultInstance>: system::Config {
type Event: From<Event<Self, I>> + Into<<Self as system::Config>::Event>;
/// The societies's module id
type ModuleId: Get<ModuleId>;
type PalletId: Get<PalletId>;
/// The currency type used for bidding.
type Currency: ReservableCurrency<Self::AccountId>;
@@ -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();
@@ -1601,7 +1601,7 @@ impl<T: Config<I>, I: Instance> Module<T, I> {
/// 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.
@@ -1609,7 +1609,7 @@ impl<T: Config<I>, I: Instance> Module<T, I> {
/// 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.
+2 -2
View File
@@ -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<SuspensionJudgementSetAccount, u128>;
type ChallengePeriod = ChallengePeriod;
type MaxCandidateIntake = MaxCandidateIntake;
type ModuleId = SocietyModuleId;
type PalletId = SocietyPalletId;
}
pub struct EnvBuilder {