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

Commit cc24950

Browse files
authored
Replace 'Module' with 'Pallet' in construct_runtime macro (#8372)
* Use 'Pallet' struct in construct_runtime. * Fix genesis and metadata macro. * Fix 'Pallet' type alias. * Replace 'Module' with 'Pallet' for all construct_runtime use cases. * Replace more deprecated 'Module' struct. * Bring back AllModules and AllPalletsWithSystem type, but deprecate them. * Replace deprecated 'Module' struct from merge master. * Minor fix. * Fix UI tests. * Revert UI override in derive_no_bound. * Fix more deprecated 'Module' use from master branch. * Fix more deprecated 'Module' use from master branch.
1 parent 46ea7e7 commit cc24950

File tree

157 files changed

+881
-864
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

157 files changed

+881
-864
lines changed

bin/node-template/pallets/template/src/mock.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use sp_runtime::{
77
use frame_system as system;
88

99
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
10-
type Block = frame_system::mocking::MockBlock<Test>;
10+
type Block = frame_system::mocking::MockBlock<Test>;
1111

1212
// Configure a mock runtime to test the pallet.
1313
frame_support::construct_runtime!(
@@ -16,8 +16,8 @@ frame_support::construct_runtime!(
1616
NodeBlock = Block,
1717
UncheckedExtrinsic = UncheckedExtrinsic,
1818
{
19-
System: frame_system::{Module, Call, Config, Storage, Event<T>},
20-
TemplateModule: pallet_template::{Module, Call, Storage, Event<T>},
19+
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
20+
TemplateModule: pallet_template::{Pallet, Call, Storage, Event<T>},
2121
}
2222
);
2323

bin/node-template/runtime/src/lib.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -270,16 +270,16 @@ construct_runtime!(
270270
NodeBlock = opaque::Block,
271271
UncheckedExtrinsic = UncheckedExtrinsic
272272
{
273-
System: frame_system::{Module, Call, Config, Storage, Event<T>},
274-
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},
275-
Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},
276-
Aura: pallet_aura::{Module, Config<T>},
277-
Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event},
278-
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
279-
TransactionPayment: pallet_transaction_payment::{Module, Storage},
280-
Sudo: pallet_sudo::{Module, Call, Config<T>, Storage, Event<T>},
273+
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
274+
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Call, Storage},
275+
Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},
276+
Aura: pallet_aura::{Pallet, Config<T>},
277+
Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event},
278+
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
279+
TransactionPayment: pallet_transaction_payment::{Pallet, Storage},
280+
Sudo: pallet_sudo::{Pallet, Call, Config<T>, Storage, Event<T>},
281281
// Include the custom logic from the template pallet in the runtime.
282-
TemplateModule: template::{Module, Call, Storage, Event<T>},
282+
TemplateModule: template::{Pallet, Call, Storage, Event<T>},
283283
}
284284
);
285285

@@ -313,7 +313,7 @@ pub type Executive = frame_executive::Executive<
313313
Block,
314314
frame_system::ChainContext<Runtime>,
315315
Runtime,
316-
AllModules,
316+
AllPallets,
317317
>;
318318

319319
impl_runtime_apis! {
@@ -453,7 +453,7 @@ impl_runtime_apis! {
453453
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
454454
use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};
455455

456-
use frame_system_benchmarking::Module as SystemBench;
456+
use frame_system_benchmarking::Pallet as SystemBench;
457457
impl frame_system_benchmarking::Config for Runtime {}
458458

459459
let whitelist: Vec<TrackedStorageKey> = vec![

bin/node/executor/tests/basic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,13 +600,13 @@ fn deploying_wasm_contract_should_work() {
600600
let transfer_code = wat::parse_str(CODE_TRANSFER).unwrap();
601601
let transfer_ch = <Runtime as frame_system::Config>::Hashing::hash(&transfer_code);
602602

603-
let addr = pallet_contracts::Module::<Runtime>::contract_address(
603+
let addr = pallet_contracts::Pallet::<Runtime>::contract_address(
604604
&charlie(),
605605
&transfer_ch,
606606
&[],
607607
);
608608

609-
let subsistence = pallet_contracts::Module::<Runtime>::subsistence_threshold();
609+
let subsistence = pallet_contracts::Pallet::<Runtime>::subsistence_threshold();
610610

611611
let time = 42 * 1000;
612612
let b = construct_block(

bin/node/runtime/src/lib.rs

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ impl pallet_balances::Config for Runtime {
379379
type DustRemoval = ();
380380
type Event = Event;
381381
type ExistentialDeposit = ExistentialDeposit;
382-
type AccountStore = frame_system::Module<Runtime>;
382+
type AccountStore = frame_system::Pallet<Runtime>;
383383
type WeightInfo = pallet_balances::weights::SubstrateWeight<Runtime>;
384384
}
385385

@@ -1005,7 +1005,7 @@ impl pallet_mmr::Config for Runtime {
10051005
const INDEXING_PREFIX: &'static [u8] = b"mmr";
10061006
type Hashing = <Runtime as frame_system::Config>::Hashing;
10071007
type Hash = <Runtime as frame_system::Config>::Hash;
1008-
type LeafData = frame_system::Module<Self>;
1008+
type LeafData = frame_system::Pallet<Self>;
10091009
type OnNewRoot = ();
10101010
type WeightInfo = ();
10111011
}
@@ -1086,44 +1086,44 @@ construct_runtime!(
10861086
NodeBlock = node_primitives::Block,
10871087
UncheckedExtrinsic = UncheckedExtrinsic
10881088
{
1089-
System: frame_system::{Module, Call, Config, Storage, Event<T>},
1090-
Utility: pallet_utility::{Module, Call, Event},
1091-
Babe: pallet_babe::{Module, Call, Storage, Config, ValidateUnsigned},
1092-
Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},
1093-
Authorship: pallet_authorship::{Module, Call, Storage, Inherent},
1094-
Indices: pallet_indices::{Module, Call, Storage, Config<T>, Event<T>},
1095-
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
1096-
TransactionPayment: pallet_transaction_payment::{Module, Storage},
1097-
ElectionProviderMultiPhase: pallet_election_provider_multi_phase::{Module, Call, Storage, Event<T>, ValidateUnsigned},
1098-
Staking: pallet_staking::{Module, Call, Config<T>, Storage, Event<T>, ValidateUnsigned},
1099-
Session: pallet_session::{Module, Call, Storage, Event, Config<T>},
1100-
Democracy: pallet_democracy::{Module, Call, Storage, Config, Event<T>},
1101-
Council: pallet_collective::<Instance1>::{Module, Call, Storage, Origin<T>, Event<T>, Config<T>},
1102-
TechnicalCommittee: pallet_collective::<Instance2>::{Module, Call, Storage, Origin<T>, Event<T>, Config<T>},
1103-
Elections: pallet_elections_phragmen::{Module, Call, Storage, Event<T>, Config<T>},
1104-
TechnicalMembership: pallet_membership::<Instance1>::{Module, Call, Storage, Event<T>, Config<T>},
1105-
Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event, ValidateUnsigned},
1106-
Treasury: pallet_treasury::{Module, Call, Storage, Config, Event<T>},
1107-
Contracts: pallet_contracts::{Module, Call, Config<T>, Storage, Event<T>},
1108-
Sudo: pallet_sudo::{Module, Call, Config<T>, Storage, Event<T>},
1109-
ImOnline: pallet_im_online::{Module, Call, Storage, Event<T>, ValidateUnsigned, Config<T>},
1110-
AuthorityDiscovery: pallet_authority_discovery::{Module, Call, Config},
1111-
Offences: pallet_offences::{Module, Call, Storage, Event},
1112-
Historical: pallet_session_historical::{Module},
1113-
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},
1114-
Identity: pallet_identity::{Module, Call, Storage, Event<T>},
1115-
Society: pallet_society::{Module, Call, Storage, Event<T>, Config<T>},
1116-
Recovery: pallet_recovery::{Module, Call, Storage, Event<T>},
1117-
Vesting: pallet_vesting::{Module, Call, Storage, Event<T>, Config<T>},
1118-
Scheduler: pallet_scheduler::{Module, Call, Storage, Event<T>},
1119-
Proxy: pallet_proxy::{Module, Call, Storage, Event<T>},
1120-
Multisig: pallet_multisig::{Module, Call, Storage, Event<T>},
1121-
Bounties: pallet_bounties::{Module, Call, Storage, Event<T>},
1122-
Tips: pallet_tips::{Module, Call, Storage, Event<T>},
1123-
Assets: pallet_assets::{Module, Call, Storage, Event<T>},
1124-
Mmr: pallet_mmr::{Module, Storage},
1125-
Lottery: pallet_lottery::{Module, Call, Storage, Event<T>},
1126-
Gilt: pallet_gilt::{Module, Call, Storage, Event<T>, Config},
1089+
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
1090+
Utility: pallet_utility::{Pallet, Call, Event},
1091+
Babe: pallet_babe::{Pallet, Call, Storage, Config, ValidateUnsigned},
1092+
Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},
1093+
Authorship: pallet_authorship::{Pallet, Call, Storage, Inherent},
1094+
Indices: pallet_indices::{Pallet, Call, Storage, Config<T>, Event<T>},
1095+
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
1096+
TransactionPayment: pallet_transaction_payment::{Pallet, Storage},
1097+
ElectionProviderMultiPhase: pallet_election_provider_multi_phase::{Pallet, Call, Storage, Event<T>, ValidateUnsigned},
1098+
Staking: pallet_staking::{Pallet, Call, Config<T>, Storage, Event<T>, ValidateUnsigned},
1099+
Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>},
1100+
Democracy: pallet_democracy::{Pallet, Call, Storage, Config, Event<T>},
1101+
Council: pallet_collective::<Instance1>::{Pallet, Call, Storage, Origin<T>, Event<T>, Config<T>},
1102+
TechnicalCommittee: pallet_collective::<Instance2>::{Pallet, Call, Storage, Origin<T>, Event<T>, Config<T>},
1103+
Elections: pallet_elections_phragmen::{Pallet, Call, Storage, Event<T>, Config<T>},
1104+
TechnicalMembership: pallet_membership::<Instance1>::{Pallet, Call, Storage, Event<T>, Config<T>},
1105+
Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event, ValidateUnsigned},
1106+
Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>},
1107+
Contracts: pallet_contracts::{Pallet, Call, Config<T>, Storage, Event<T>},
1108+
Sudo: pallet_sudo::{Pallet, Call, Config<T>, Storage, Event<T>},
1109+
ImOnline: pallet_im_online::{Pallet, Call, Storage, Event<T>, ValidateUnsigned, Config<T>},
1110+
AuthorityDiscovery: pallet_authority_discovery::{Pallet, Call, Config},
1111+
Offences: pallet_offences::{Pallet, Call, Storage, Event},
1112+
Historical: pallet_session_historical::{Pallet},
1113+
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Call, Storage},
1114+
Identity: pallet_identity::{Pallet, Call, Storage, Event<T>},
1115+
Society: pallet_society::{Pallet, Call, Storage, Event<T>, Config<T>},
1116+
Recovery: pallet_recovery::{Pallet, Call, Storage, Event<T>},
1117+
Vesting: pallet_vesting::{Pallet, Call, Storage, Event<T>, Config<T>},
1118+
Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event<T>},
1119+
Proxy: pallet_proxy::{Pallet, Call, Storage, Event<T>},
1120+
Multisig: pallet_multisig::{Pallet, Call, Storage, Event<T>},
1121+
Bounties: pallet_bounties::{Pallet, Call, Storage, Event<T>},
1122+
Tips: pallet_tips::{Pallet, Call, Storage, Event<T>},
1123+
Assets: pallet_assets::{Pallet, Call, Storage, Event<T>},
1124+
Mmr: pallet_mmr::{Pallet, Storage},
1125+
Lottery: pallet_lottery::{Pallet, Call, Storage, Event<T>},
1126+
Gilt: pallet_gilt::{Pallet, Call, Storage, Event<T>, Config},
11271127
}
11281128
);
11291129

@@ -1163,7 +1163,7 @@ pub type Executive = frame_executive::Executive<
11631163
Block,
11641164
frame_system::ChainContext<Runtime>,
11651165
Runtime,
1166-
AllModules,
1166+
AllPallets,
11671167
(),
11681168
>;
11691169

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

14421442
impl pallet_session_benchmarking::Config for Runtime {}
14431443
impl pallet_offences_benchmarking::Config for Runtime {}

frame/assets/src/benchmarking.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use frame_benchmarking::{
2929
use frame_support::traits::Get;
3030
use frame_support::{traits::EnsureOrigin, dispatch::UnfilteredDispatchable};
3131

32-
use crate::Module as Assets;
32+
use crate::Pallet as Assets;
3333

3434
const SEED: u32 = 0;
3535

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

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

frame/assets/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,11 +1375,11 @@ impl<T: Config> Pallet<T> {
13751375
) -> Result<bool, DispatchError> {
13761376
let accounts = d.accounts.checked_add(1).ok_or(Error::<T>::Overflow)?;
13771377
let is_sufficient = if d.is_sufficient {
1378-
frame_system::Module::<T>::inc_sufficients(who);
1378+
frame_system::Pallet::<T>::inc_sufficients(who);
13791379
d.sufficients += 1;
13801380
true
13811381
} else {
1382-
frame_system::Module::<T>::inc_consumers(who).map_err(|_| Error::<T>::NoProvider)?;
1382+
frame_system::Pallet::<T>::inc_consumers(who).map_err(|_| Error::<T>::NoProvider)?;
13831383
false
13841384
};
13851385
d.accounts = accounts;
@@ -1393,9 +1393,9 @@ impl<T: Config> Pallet<T> {
13931393
) {
13941394
if sufficient {
13951395
d.sufficients = d.sufficients.saturating_sub(1);
1396-
frame_system::Module::<T>::dec_sufficients(who);
1396+
frame_system::Pallet::<T>::dec_sufficients(who);
13971397
} else {
1398-
frame_system::Module::<T>::dec_consumers(who);
1398+
frame_system::Pallet::<T>::dec_consumers(who);
13991399
}
14001400
d.accounts = d.accounts.saturating_sub(1);
14011401
}

frame/assets/src/mock.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ construct_runtime!(
3333
NodeBlock = Block,
3434
UncheckedExtrinsic = UncheckedExtrinsic,
3535
{
36-
System: frame_system::{Module, Call, Config, Storage, Event<T>},
37-
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
38-
Assets: pallet_assets::{Module, Call, Storage, Event<T>},
36+
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
37+
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
38+
Assets: pallet_assets::{Pallet, Call, Storage, Event<T>},
3939
}
4040
);
4141

frame/assets/src/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use frame_support::{assert_ok, assert_noop, traits::Currency};
2323
use pallet_balances::Error as BalancesError;
2424

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

2929
#[test]

frame/atomic-swap/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ decl_event!(
191191
{
192192
/// Swap created. \[account, proof, swap\]
193193
NewSwap(AccountId, HashedProof, PendingSwap),
194-
/// Swap claimed. The last parameter indicates whether the execution succeeds.
194+
/// Swap claimed. The last parameter indicates whether the execution succeeds.
195195
/// \[account, proof, success\]
196196
SwapClaimed(AccountId, HashedProof, bool),
197197
/// Swap cancelled. \[account, proof\]
@@ -237,7 +237,7 @@ decl_module! {
237237
let swap = PendingSwap {
238238
source,
239239
action,
240-
end_block: frame_system::Module::<T>::block_number() + duration,
240+
end_block: frame_system::Pallet::<T>::block_number() + duration,
241241
};
242242
PendingSwaps::<T>::insert(target.clone(), hashed_proof.clone(), swap.clone());
243243

@@ -307,7 +307,7 @@ decl_module! {
307307
Error::<T>::SourceMismatch,
308308
);
309309
ensure!(
310-
frame_system::Module::<T>::block_number() >= swap.end_block,
310+
frame_system::Pallet::<T>::block_number() >= swap.end_block,
311311
Error::<T>::DurationNotPassed,
312312
);
313313

frame/atomic-swap/src/tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ frame_support::construct_runtime!(
1919
NodeBlock = Block,
2020
UncheckedExtrinsic = UncheckedExtrinsic,
2121
{
22-
System: frame_system::{Module, Call, Config, Storage, Event<T>},
23-
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
24-
AtomicSwap: pallet_atomic_swap::{Module, Call, Event<T>},
22+
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
23+
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
24+
AtomicSwap: pallet_atomic_swap::{Pallet, Call, Event<T>},
2525
}
2626
);
2727

0 commit comments

Comments
 (0)