Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Replace 'Module' with 'Pallet' in construct_runtime macro #8372

Merged
16 commits merged into from
Mar 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions bin/node-template/pallets/template/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use sp_runtime::{
use frame_system as system;

type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>;
type Block = frame_system::mocking::MockBlock<Test>;

// Configure a mock runtime to test the pallet.
frame_support::construct_runtime!(
Expand All @@ -16,8 +16,8 @@ frame_support::construct_runtime!(
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Module, Call, Config, Storage, Event<T>},
TemplateModule: pallet_template::{Module, Call, Storage, Event<T>},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
TemplateModule: pallet_template::{Pallet, Call, Storage, Event<T>},
}
);

Expand Down
22 changes: 11 additions & 11 deletions bin/node-template/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,16 +270,16 @@ construct_runtime!(
NodeBlock = opaque::Block,
UncheckedExtrinsic = UncheckedExtrinsic
{
System: frame_system::{Module, Call, Config, Storage, Event<T>},
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},
Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},
Aura: pallet_aura::{Module, Config<T>},
Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event},
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
TransactionPayment: pallet_transaction_payment::{Module, Storage},
Sudo: pallet_sudo::{Module, Call, Config<T>, Storage, Event<T>},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Call, Storage},
Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},
Aura: pallet_aura::{Pallet, Config<T>},
Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
TransactionPayment: pallet_transaction_payment::{Pallet, Storage},
Sudo: pallet_sudo::{Pallet, Call, Config<T>, Storage, Event<T>},
// Include the custom logic from the template pallet in the runtime.
TemplateModule: template::{Module, Call, Storage, Event<T>},
TemplateModule: template::{Pallet, Call, Storage, Event<T>},
}
);

Expand Down Expand Up @@ -313,7 +313,7 @@ pub type Executive = frame_executive::Executive<
Block,
frame_system::ChainContext<Runtime>,
Runtime,
AllModules,
AllPallets,
>;

impl_runtime_apis! {
Expand Down Expand Up @@ -453,7 +453,7 @@ impl_runtime_apis! {
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};

use frame_system_benchmarking::Module as SystemBench;
use frame_system_benchmarking::Pallet as SystemBench;
impl frame_system_benchmarking::Config for Runtime {}

let whitelist: Vec<TrackedStorageKey> = vec![
Expand Down
4 changes: 2 additions & 2 deletions bin/node/executor/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -600,13 +600,13 @@ fn deploying_wasm_contract_should_work() {
let transfer_code = wat::parse_str(CODE_TRANSFER).unwrap();
let transfer_ch = <Runtime as frame_system::Config>::Hashing::hash(&transfer_code);

let addr = pallet_contracts::Module::<Runtime>::contract_address(
let addr = pallet_contracts::Pallet::<Runtime>::contract_address(
&charlie(),
&transfer_ch,
&[],
);

let subsistence = pallet_contracts::Module::<Runtime>::subsistence_threshold();
let subsistence = pallet_contracts::Pallet::<Runtime>::subsistence_threshold();

let time = 42 * 1000;
let b = construct_block(
Expand Down
88 changes: 44 additions & 44 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ impl pallet_balances::Config for Runtime {
type DustRemoval = ();
type Event = Event;
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = frame_system::Module<Runtime>;
type AccountStore = frame_system::Pallet<Runtime>;
type WeightInfo = pallet_balances::weights::SubstrateWeight<Runtime>;
}

Expand Down Expand Up @@ -1005,7 +1005,7 @@ impl pallet_mmr::Config for Runtime {
const INDEXING_PREFIX: &'static [u8] = b"mmr";
type Hashing = <Runtime as frame_system::Config>::Hashing;
type Hash = <Runtime as frame_system::Config>::Hash;
type LeafData = frame_system::Module<Self>;
type LeafData = frame_system::Pallet<Self>;
type OnNewRoot = ();
type WeightInfo = ();
}
Expand Down Expand Up @@ -1086,44 +1086,44 @@ construct_runtime!(
NodeBlock = node_primitives::Block,
UncheckedExtrinsic = UncheckedExtrinsic
{
System: frame_system::{Module, Call, Config, Storage, Event<T>},
Utility: pallet_utility::{Module, Call, Event},
Babe: pallet_babe::{Module, Call, Storage, Config, ValidateUnsigned},
Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},
Authorship: pallet_authorship::{Module, Call, Storage, Inherent},
Indices: pallet_indices::{Module, Call, Storage, Config<T>, Event<T>},
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
TransactionPayment: pallet_transaction_payment::{Module, Storage},
ElectionProviderMultiPhase: pallet_election_provider_multi_phase::{Module, Call, Storage, Event<T>, ValidateUnsigned},
Staking: pallet_staking::{Module, Call, Config<T>, Storage, Event<T>, ValidateUnsigned},
Session: pallet_session::{Module, Call, Storage, Event, Config<T>},
Democracy: pallet_democracy::{Module, Call, Storage, Config, Event<T>},
Council: pallet_collective::<Instance1>::{Module, Call, Storage, Origin<T>, Event<T>, Config<T>},
TechnicalCommittee: pallet_collective::<Instance2>::{Module, Call, Storage, Origin<T>, Event<T>, Config<T>},
Elections: pallet_elections_phragmen::{Module, Call, Storage, Event<T>, Config<T>},
TechnicalMembership: pallet_membership::<Instance1>::{Module, Call, Storage, Event<T>, Config<T>},
Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event, ValidateUnsigned},
Treasury: pallet_treasury::{Module, Call, Storage, Config, Event<T>},
Contracts: pallet_contracts::{Module, Call, Config<T>, Storage, Event<T>},
Sudo: pallet_sudo::{Module, Call, Config<T>, Storage, Event<T>},
ImOnline: pallet_im_online::{Module, Call, Storage, Event<T>, ValidateUnsigned, Config<T>},
AuthorityDiscovery: pallet_authority_discovery::{Module, Call, Config},
Offences: pallet_offences::{Module, Call, Storage, Event},
Historical: pallet_session_historical::{Module},
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},
Identity: pallet_identity::{Module, Call, Storage, Event<T>},
Society: pallet_society::{Module, Call, Storage, Event<T>, Config<T>},
Recovery: pallet_recovery::{Module, Call, Storage, Event<T>},
Vesting: pallet_vesting::{Module, Call, Storage, Event<T>, Config<T>},
Scheduler: pallet_scheduler::{Module, Call, Storage, Event<T>},
Proxy: pallet_proxy::{Module, Call, Storage, Event<T>},
Multisig: pallet_multisig::{Module, Call, Storage, Event<T>},
Bounties: pallet_bounties::{Module, Call, Storage, Event<T>},
Tips: pallet_tips::{Module, Call, Storage, Event<T>},
Assets: pallet_assets::{Module, Call, Storage, Event<T>},
Mmr: pallet_mmr::{Module, Storage},
Lottery: pallet_lottery::{Module, Call, Storage, Event<T>},
Gilt: pallet_gilt::{Module, Call, Storage, Event<T>, Config},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Utility: pallet_utility::{Pallet, Call, Event},
Babe: pallet_babe::{Pallet, Call, Storage, Config, ValidateUnsigned},
Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},
Authorship: pallet_authorship::{Pallet, Call, Storage, Inherent},
Indices: pallet_indices::{Pallet, Call, Storage, Config<T>, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
TransactionPayment: pallet_transaction_payment::{Pallet, Storage},
ElectionProviderMultiPhase: pallet_election_provider_multi_phase::{Pallet, Call, Storage, Event<T>, ValidateUnsigned},
Staking: pallet_staking::{Pallet, Call, Config<T>, Storage, Event<T>, ValidateUnsigned},
Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>},
Democracy: pallet_democracy::{Pallet, Call, Storage, Config, Event<T>},
Council: pallet_collective::<Instance1>::{Pallet, Call, Storage, Origin<T>, Event<T>, Config<T>},
TechnicalCommittee: pallet_collective::<Instance2>::{Pallet, Call, Storage, Origin<T>, Event<T>, Config<T>},
Elections: pallet_elections_phragmen::{Pallet, Call, Storage, Event<T>, Config<T>},
TechnicalMembership: pallet_membership::<Instance1>::{Pallet, Call, Storage, Event<T>, Config<T>},
Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event, ValidateUnsigned},
Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>},
Contracts: pallet_contracts::{Pallet, Call, Config<T>, Storage, Event<T>},
Sudo: pallet_sudo::{Pallet, Call, Config<T>, Storage, Event<T>},
ImOnline: pallet_im_online::{Pallet, Call, Storage, Event<T>, ValidateUnsigned, Config<T>},
AuthorityDiscovery: pallet_authority_discovery::{Pallet, Call, Config},
Offences: pallet_offences::{Pallet, Call, Storage, Event},
Historical: pallet_session_historical::{Pallet},
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Call, Storage},
Identity: pallet_identity::{Pallet, Call, Storage, Event<T>},
Society: pallet_society::{Pallet, Call, Storage, Event<T>, Config<T>},
Recovery: pallet_recovery::{Pallet, Call, Storage, Event<T>},
Vesting: pallet_vesting::{Pallet, Call, Storage, Event<T>, Config<T>},
Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event<T>},
Proxy: pallet_proxy::{Pallet, Call, Storage, Event<T>},
Multisig: pallet_multisig::{Pallet, Call, Storage, Event<T>},
Bounties: pallet_bounties::{Pallet, Call, Storage, Event<T>},
Tips: pallet_tips::{Pallet, Call, Storage, Event<T>},
Assets: pallet_assets::{Pallet, Call, Storage, Event<T>},
Mmr: pallet_mmr::{Pallet, Storage},
Lottery: pallet_lottery::{Pallet, Call, Storage, Event<T>},
Gilt: pallet_gilt::{Pallet, Call, Storage, Event<T>, Config},
}
);

Expand Down Expand Up @@ -1163,7 +1163,7 @@ pub type Executive = frame_executive::Executive<
Block,
frame_system::ChainContext<Runtime>,
Runtime,
AllModules,
AllPallets,
(),
>;

Expand Down Expand Up @@ -1435,9 +1435,9 @@ impl_runtime_apis! {
// Trying to add benchmarks directly to the Session Pallet caused cyclic dependency
// issues. To get around that, we separated the Session benchmarks into its own crate,
// which is why we need these two lines below.
use pallet_session_benchmarking::Module as SessionBench;
use pallet_offences_benchmarking::Module as OffencesBench;
use frame_system_benchmarking::Module as SystemBench;
use pallet_session_benchmarking::Pallet as SessionBench;
use pallet_offences_benchmarking::Pallet as OffencesBench;
use frame_system_benchmarking::Pallet as SystemBench;

impl pallet_session_benchmarking::Config for Runtime {}
impl pallet_offences_benchmarking::Config for Runtime {}
Expand Down
6 changes: 3 additions & 3 deletions frame/assets/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use frame_benchmarking::{
use frame_support::traits::Get;
use frame_support::{traits::EnsureOrigin, dispatch::UnfilteredDispatchable};

use crate::Module as Assets;
use crate::Pallet as Assets;

const SEED: u32 = 0;

Expand Down Expand Up @@ -120,7 +120,7 @@ fn add_approvals<T: Config>(minter: T::AccountId, n: u32) {
}

fn assert_last_event<T: Config>(generic_event: <T as Config>::Event) {
let events = frame_system::Module::<T>::events();
let events = frame_system::Pallet::<T>::events();
let system_event: <T as frame_system::Config>::Event = generic_event.into();
// compare to the last event record
let frame_system::EventRecord { event, .. } = &events[events.len() - 1];
Expand Down Expand Up @@ -193,7 +193,7 @@ benchmarks! {
let target_lookup = T::Lookup::unlookup(target.clone());
}: _(SystemOrigin::Signed(caller.clone()), Default::default(), target_lookup, amount)
verify {
assert!(frame_system::Module::<T>::account_exists(&caller));
assert!(frame_system::Pallet::<T>::account_exists(&caller));
assert_last_event::<T>(Event::Transferred(Default::default(), caller, target, amount).into());
}

Expand Down
8 changes: 4 additions & 4 deletions frame/assets/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1375,11 +1375,11 @@ impl<T: Config> Pallet<T> {
) -> Result<bool, DispatchError> {
let accounts = d.accounts.checked_add(1).ok_or(Error::<T>::Overflow)?;
let is_sufficient = if d.is_sufficient {
frame_system::Module::<T>::inc_sufficients(who);
frame_system::Pallet::<T>::inc_sufficients(who);
d.sufficients += 1;
true
} else {
frame_system::Module::<T>::inc_consumers(who).map_err(|_| Error::<T>::NoProvider)?;
frame_system::Pallet::<T>::inc_consumers(who).map_err(|_| Error::<T>::NoProvider)?;
false
};
d.accounts = accounts;
Expand All @@ -1393,9 +1393,9 @@ impl<T: Config> Pallet<T> {
) {
if sufficient {
d.sufficients = d.sufficients.saturating_sub(1);
frame_system::Module::<T>::dec_sufficients(who);
frame_system::Pallet::<T>::dec_sufficients(who);
} else {
frame_system::Module::<T>::dec_consumers(who);
frame_system::Pallet::<T>::dec_consumers(who);
}
d.accounts = d.accounts.saturating_sub(1);
}
Expand Down
6 changes: 3 additions & 3 deletions frame/assets/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ construct_runtime!(
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Module, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
Assets: pallet_assets::{Module, Call, Storage, Event<T>},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Assets: pallet_assets::{Pallet, Call, Storage, Event<T>},
}
);

Expand Down
2 changes: 1 addition & 1 deletion frame/assets/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use frame_support::{assert_ok, assert_noop, traits::Currency};
use pallet_balances::Error as BalancesError;

fn last_event() -> mock::Event {
frame_system::Module::<Test>::events().pop().expect("Event expected").event
frame_system::Pallet::<Test>::events().pop().expect("Event expected").event
}

#[test]
Expand Down
6 changes: 3 additions & 3 deletions frame/atomic-swap/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ decl_event!(
{
/// Swap created. \[account, proof, swap\]
NewSwap(AccountId, HashedProof, PendingSwap),
/// Swap claimed. The last parameter indicates whether the execution succeeds.
/// Swap claimed. The last parameter indicates whether the execution succeeds.
/// \[account, proof, success\]
SwapClaimed(AccountId, HashedProof, bool),
/// Swap cancelled. \[account, proof\]
Expand Down Expand Up @@ -237,7 +237,7 @@ decl_module! {
let swap = PendingSwap {
source,
action,
end_block: frame_system::Module::<T>::block_number() + duration,
end_block: frame_system::Pallet::<T>::block_number() + duration,
};
PendingSwaps::<T>::insert(target.clone(), hashed_proof.clone(), swap.clone());

Expand Down Expand Up @@ -307,7 +307,7 @@ decl_module! {
Error::<T>::SourceMismatch,
);
ensure!(
frame_system::Module::<T>::block_number() >= swap.end_block,
frame_system::Pallet::<T>::block_number() >= swap.end_block,
Error::<T>::DurationNotPassed,
);

Expand Down
6 changes: 3 additions & 3 deletions frame/atomic-swap/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ frame_support::construct_runtime!(
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Module, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
AtomicSwap: pallet_atomic_swap::{Module, Call, Event<T>},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
AtomicSwap: pallet_atomic_swap::{Pallet, Call, Event<T>},
}
);

Expand Down
4 changes: 2 additions & 2 deletions frame/aura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl<T: Config> Pallet<T> {
AURA_ENGINE_ID,
ConsensusLog::AuthoritiesChange(new).encode()
);
<frame_system::Module<T>>::deposit_log(log.into());
<frame_system::Pallet<T>>::deposit_log(log.into());
}

fn initialize_authorities(authorities: &[T::AuthorityId]) {
Expand Down Expand Up @@ -194,7 +194,7 @@ impl<T: Config> OneSessionHandler<T::AccountId> for Pallet<T> {
ConsensusLog::<T::AuthorityId>::OnDisabled(i as AuthorityIndex).encode(),
);

<frame_system::Module<T>>::deposit_log(log.into());
<frame_system::Pallet<T>>::deposit_log(log.into());
}
}

Expand Down
6 changes: 3 additions & 3 deletions frame/aura/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ frame_support::construct_runtime!(
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Module, Call, Config, Storage, Event<T>},
Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},
Aura: pallet_aura::{Module, Call, Storage, Config<T>},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},
Aura: pallet_aura::{Pallet, Call, Storage, Config<T>},
}
);

Expand Down
6 changes: 3 additions & 3 deletions frame/authority-discovery/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ mod tests {
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Module, Call, Config, Storage, Event<T>},
Session: pallet_session::{Module, Call, Storage, Event, Config<T>},
AuthorityDiscovery: pallet_authority_discovery::{Module, Call, Config},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>},
AuthorityDiscovery: pallet_authority_discovery::{Pallet, Call, Config},
}
);

Expand Down
Loading