ModuleId to PalletId (#2864)

* lock substrate version for testing

* `ModuleId` to `PalletId`

* release substrate version

* Update Cargo.lock

Co-authored-by: Xavier Lau <c.estlavie@icloud.com>
This commit is contained in:
Shawn Tabrizi
2021-04-09 12:33:21 +02:00
committed by GitHub
parent bc7761a3da
commit 322e1f3dff
7 changed files with 187 additions and 183 deletions
+8 -8
View File
@@ -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
@@ -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,
},
@@ -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>>;
@@ -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();
@@ -631,7 +631,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 {
@@ -900,7 +900,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;
}
@@ -909,7 +909,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;
+4 -4
View File
@@ -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,
};
@@ -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 {
@@ -155,7 +155,7 @@ mod tests {
type SpendPeriod = ();
type Burn = ();
type BurnDestination = ();
type ModuleId = TreasuryModuleId;
type PalletId = TreasuryPalletId;
type SpendFunds = ();
type WeightInfo = ();
}
@@ -20,7 +20,6 @@ use sp_std::sync::Arc;
use sp_io::TestExternalities;
use sp_core::{H256, crypto::KeyTypeId};
use sp_runtime::{
ModuleId,
traits::{
BlakeTwo256, IdentityLookup, One,
},
@@ -28,7 +27,7 @@ use sp_runtime::{
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},
};
@@ -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;
@@ -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;