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
@@ -175,7 +175,7 @@ pub trait Config: frame_system::Config {
type Event: From<Event<Self>> + Into<<Self as frame_system::Config>::Event>;
/// Identifier for the elections-phragmen pallet's lock
type ModuleId: Get<LockIdentifier>;
type PalletId: Get<LockIdentifier>;
/// 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<T: Config> Module<T> {
let Voter { deposit, .. } = <Voting<T>>::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()