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
+2 -2
View File
@@ -677,14 +677,14 @@ 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 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(
+5 -4
View File
@@ -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<Test>;
type ApproveOrigin = frame_system::EnsureRoot<u128>;
type RejectOrigin = frame_system::EnsureRoot<u128>;