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
+10 -7
View File
@@ -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,
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<T, I=DefaultInstance> =
pub trait Config<I=DefaultInstance>: frame_system::Config {
/// The treasury's module id, used for deriving its sovereign account ID.
type ModuleId: Get<ModuleId>;
type PalletId: Get<PalletId>;
/// The staking balance.
type Currency: Currency<Self::AccountId> + ReservableCurrency<Self::AccountId>;
@@ -246,7 +249,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<T, I>;
@@ -346,7 +349,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 needed bond for a proposal whose spend is `value`.
+3 -4
View File
@@ -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<Test>;
type ApproveOrigin = frame_system::EnsureRoot<u128>;
type RejectOrigin = frame_system::EnsureRoot<u128>;