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.
This commit is contained in:
Shaun Wang
2021-03-18 21:50:08 +13:00
committed by GitHub
parent 05f24931a9
commit 2e5522444a
157 changed files with 881 additions and 864 deletions
@@ -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!(
@@ -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>},
}
);
+11 -11
View File
@@ -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>},
}
);
@@ -313,7 +313,7 @@ pub type Executive = frame_executive::Executive<
Block,
frame_system::ChainContext<Runtime>,
Runtime,
AllModules,
AllPallets,
>;
impl_runtime_apis! {
@@ -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![
+2 -2
View File
@@ -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(
+44 -44
View File
@@ -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>;
}
@@ -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 = ();
}
@@ -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},
}
);
@@ -1163,7 +1163,7 @@ pub type Executive = frame_executive::Executive<
Block,
frame_system::ChainContext<Runtime>,
Runtime,
AllModules,
AllPallets,
(),
>;
@@ -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 {}
+3 -3
View File
@@ -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;
@@ -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];
@@ -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());
}
+4 -4
View File
@@ -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;
@@ -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);
}
+3 -3
View File
@@ -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>},
}
);
+1 -1
View File
@@ -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]
+3 -3
View File
@@ -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\]
@@ -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());
@@ -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,
);
+3 -3
View File
@@ -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>},
}
);
+2 -2
View File
@@ -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]) {
@@ -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());
}
}
+3 -3
View File
@@ -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>},
}
);
@@ -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},
}
);
+7 -7
View File
@@ -234,7 +234,7 @@ impl<T: Config> Module<T> {
return author;
}
let digest = <frame_system::Module<T>>::digest();
let digest = <frame_system::Pallet<T>>::digest();
let pre_runtime_digests = digest.logs.iter().filter_map(|d| d.as_pre_runtime());
if let Some(author) = T::FindAuthor::find_author(pre_runtime_digests) {
<Self as Store>::Author::put(&author);
@@ -245,7 +245,7 @@ impl<T: Config> Module<T> {
}
fn verify_and_import_uncles(new_uncles: Vec<T::Header>) -> dispatch::DispatchResult {
let now = <frame_system::Module<T>>::block_number();
let now = <frame_system::Pallet<T>>::block_number();
let mut uncles = <Self as Store>::Uncles::get();
uncles.push(UncleEntryItem::InclusionHeight(now));
@@ -278,7 +278,7 @@ impl<T: Config> Module<T> {
accumulator: &mut <T::FilterUncle as FilterUncle<T::Header, T::AccountId>>::Accumulator,
) -> Result<Option<T::AccountId>, dispatch::DispatchError>
{
let now = <frame_system::Module<T>>::block_number();
let now = <frame_system::Pallet<T>>::block_number();
let (minimum_height, maximum_height) = {
let uncle_generations = T::UncleGenerations::get();
@@ -303,7 +303,7 @@ impl<T: Config> Module<T> {
{
let parent_number = uncle.number().clone() - One::one();
let parent_hash = <frame_system::Module<T>>::block_hash(&parent_number);
let parent_hash = <frame_system::Pallet<T>>::block_hash(&parent_number);
if &parent_hash != uncle.parent_hash() {
return Err(Error::<T>::InvalidUncleParent.into());
}
@@ -314,7 +314,7 @@ impl<T: Config> Module<T> {
}
let duplicate = existing_uncles.into_iter().find(|h| **h == hash).is_some();
let in_chain = <frame_system::Module<T>>::block_hash(uncle.number()) == hash;
let in_chain = <frame_system::Pallet<T>>::block_hash(uncle.number()) == hash;
if duplicate || in_chain {
return Err(Error::<T>::UncleAlreadyIncluded.into())
@@ -413,8 +413,8 @@ mod tests {
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Module, Call, Config, Storage, Event<T>},
Authorship: pallet_authorship::{Module, Call, Storage, Inherent},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Authorship: pallet_authorship::{Pallet, Call, Storage, Inherent},
}
);
+1 -1
View File
@@ -536,7 +536,7 @@ impl<T: Config> Pallet<T> {
// Update the start blocks of the previous and new current epoch.
<EpochStart<T>>::mutate(|(previous_epoch_start_block, current_epoch_start_block)| {
*previous_epoch_start_block = sp_std::mem::take(current_epoch_start_block);
*current_epoch_start_block = <frame_system::Module<T>>::block_number();
*current_epoch_start_block = <frame_system::Pallet<T>>::block_number();
});
// After we update the current epoch, we signal the *next* epoch change
+10 -10
View File
@@ -51,14 +51,14 @@ 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>},
Historical: pallet_session_historical::{Module},
Offences: pallet_offences::{Module, Call, Storage, Event},
Babe: pallet_babe::{Module, Call, Storage, Config, ValidateUnsigned},
Staking: pallet_staking::{Module, Call, Storage, Config<T>, Event<T>},
Session: pallet_session::{Module, Call, Storage, Event, Config<T>},
Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Historical: pallet_session_historical::{Pallet},
Offences: pallet_offences::{Pallet, Call, Storage, Event},
Babe: pallet_babe::{Pallet, Call, Storage, Config, ValidateUnsigned},
Staking: pallet_staking::{Pallet, Call, Storage, Config<T>, Event<T>},
Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>},
Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},
}
);
@@ -104,7 +104,7 @@ where
impl_opaque_keys! {
pub struct MockSessionKeys {
pub babe_authority: super::Module<Test>,
pub babe_authority: super::Pallet<Test>,
}
}
@@ -204,7 +204,7 @@ impl pallet_staking::Config for Test {
type SlashDeferDuration = SlashDeferDuration;
type SlashCancelOrigin = frame_system::EnsureRoot<Self::AccountId>;
type SessionInterface = Self;
type UnixTime = pallet_timestamp::Module<Test>;
type UnixTime = pallet_timestamp::Pallet<Test>;
type EraPayout = pallet_staking::ConvertCurve<RewardCurve>;
type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
type NextNewSession = Session;
+1 -1
View File
@@ -143,6 +143,6 @@ impl<T: Config> RandomnessT<Option<T::Hash>, T::BlockNumber> for CurrentBlockRan
T::Hashing::hash(&subject[..])
});
(random, <frame_system::Module<T>>::block_number())
(random, <frame_system::Pallet<T>>::block_number())
}
}
+1 -1
View File
@@ -25,7 +25,7 @@ use frame_system::RawOrigin;
use frame_benchmarking::{benchmarks_instance_pallet, account, whitelisted_caller, impl_benchmark_test_suite};
use sp_runtime::traits::Bounded;
use crate::Module as Balances;
use crate::Pallet as Balances;
const SEED: u32 = 0;
// existential deposit multiplier
+1 -1
View File
@@ -624,7 +624,7 @@ pub struct DustCleaner<T: Config<I>, I: 'static = ()>(Option<(T::AccountId, Nega
impl<T: Config<I>, I: 'static> Drop for DustCleaner<T, I> {
fn drop(&mut self) {
if let Some((who, dust)) = self.0.take() {
Module::<T, I>::deposit_event(Event::DustLost(who, dust.peek()));
Pallet::<T, I>::deposit_event(Event::DustLost(who, dust.peek()));
T::DustRemoval::on_unbalanced(dust);
}
}
+1 -1
View File
@@ -55,7 +55,7 @@ macro_rules! decl_tests {
}
fn last_event() -> Event {
system::Module::<Test>::events().pop().expect("Event expected").event
system::Pallet::<Test>::events().pop().expect("Event expected").event
}
#[test]
@@ -30,7 +30,7 @@ use frame_support::weights::{Weight, DispatchInfo, IdentityFee};
use pallet_transaction_payment::CurrencyAdapter;
use crate::{
self as pallet_balances,
Module, Config, decl_tests,
Pallet, Config, decl_tests,
};
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>;
@@ -41,8 +41,8 @@ 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>},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
}
);
@@ -80,7 +80,7 @@ parameter_types! {
pub const TransactionByteFee: u64 = 1;
}
impl pallet_transaction_payment::Config for Test {
type OnChargeTransaction = CurrencyAdapter<Module<Test>, ()>;
type OnChargeTransaction = CurrencyAdapter<Pallet<Test>, ()>;
type TransactionByteFee = TransactionByteFee;
type WeightToFee = IdentityFee<u64>;
type FeeMultiplierUpdate = ();
+4 -4
View File
@@ -30,7 +30,7 @@ use frame_support::traits::StorageMapShim;
use frame_support::weights::{Weight, DispatchInfo, IdentityFee};
use crate::{
self as pallet_balances,
Module, Config, decl_tests,
Pallet, Config, decl_tests,
};
use pallet_transaction_payment::CurrencyAdapter;
@@ -43,8 +43,8 @@ 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>},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
}
);
@@ -82,7 +82,7 @@ parameter_types! {
pub const TransactionByteFee: u64 = 1;
}
impl pallet_transaction_payment::Config for Test {
type OnChargeTransaction = CurrencyAdapter<Module<Test>, ()>;
type OnChargeTransaction = CurrencyAdapter<Pallet<Test>, ()>;
type TransactionByteFee = TransactionByteFee;
type WeightToFee = IdentityFee<u64>;
type FeeMultiplierUpdate = ();
@@ -30,7 +30,7 @@ use frame_support::traits::StorageMapShim;
use frame_support::weights::{IdentityFee};
use crate::{
self as pallet_balances,
Module, Config,
Pallet, Config,
};
use pallet_transaction_payment::CurrencyAdapter;
@@ -47,7 +47,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>;
fn last_event() -> Event {
system::Module::<Test>::events().pop().expect("Event expected").event
system::Pallet::<Test>::events().pop().expect("Event expected").event
}
frame_support::construct_runtime!(
@@ -56,8 +56,8 @@ 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>},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
}
);
@@ -95,7 +95,7 @@ parameter_types! {
pub const TransactionByteFee: u64 = 1;
}
impl pallet_transaction_payment::Config for Test {
type OnChargeTransaction = CurrencyAdapter<Module<Test>, ()>;
type OnChargeTransaction = CurrencyAdapter<Pallet<Test>, ()>;
type TransactionByteFee = TransactionByteFee;
type WeightToFee = IdentityFee<u64>;
type FeeMultiplierUpdate = ();
+9 -9
View File
@@ -676,7 +676,7 @@ macro_rules! impl_benchmark {
( $( $name_extra:ident ),* )
) => {
impl<T: Config $(<$instance>, $instance: $instance_bound )? >
$crate::Benchmarking<$crate::BenchmarkResults> for Module<T $(, $instance)? >
$crate::Benchmarking<$crate::BenchmarkResults> for Pallet<T $(, $instance)? >
where T: frame_system::Config, $( $where_clause )*
{
fn benchmarks(extra: bool) -> $crate::Vec<&'static [u8]> {
@@ -744,8 +744,8 @@ macro_rules! impl_benchmark {
>::instance(&selected_benchmark, c, verify)?;
// Set the block number to at least 1 so events are deposited.
if $crate::Zero::is_zero(&frame_system::Module::<T>::block_number()) {
frame_system::Module::<T>::set_block_number(1u32.into());
if $crate::Zero::is_zero(&frame_system::Pallet::<T>::block_number()) {
frame_system::Pallet::<T>::set_block_number(1u32.into());
}
// Commit the externalities to the database, flushing the DB cache.
@@ -915,8 +915,8 @@ macro_rules! impl_benchmark_test {
>::instance(&selected_benchmark, &c, true)?;
// Set the block number to at least 1 so events are deposited.
if $crate::Zero::is_zero(&frame_system::Module::<T>::block_number()) {
frame_system::Module::<T>::set_block_number(1u32.into());
if $crate::Zero::is_zero(&frame_system::Pallet::<T>::block_number()) {
frame_system::Pallet::<T>::set_block_number(1u32.into());
}
// Run execution + verification
@@ -961,7 +961,7 @@ macro_rules! impl_benchmark_test {
/// When called in `pallet_example` as
///
/// ```rust,ignore
/// impl_benchmark_test_suite!(Module, crate::tests::new_test_ext(), crate::tests::Test);
/// impl_benchmark_test_suite!(Pallet, crate::tests::new_test_ext(), crate::tests::Test);
/// ```
///
/// It expands to the equivalent of:
@@ -1019,11 +1019,11 @@ macro_rules! impl_benchmark_test {
/// }
///
/// mod tests {
/// // because of macro syntax limitations, neither Module nor benches can be paths, but both have
/// // because of macro syntax limitations, neither Pallet nor benches can be paths, but both have
/// // to be idents in the scope of `impl_benchmark_test_suite`.
/// use crate::{benches, Module};
/// use crate::{benches, Pallet};
///
/// impl_benchmark_test_suite!(Module, new_test_ext(), Test, benchmarks_path = benches);
/// impl_benchmark_test_suite!(Pallet, new_test_ext(), Test, benchmarks_path = benches);
///
/// // new_test_ext and the Test item are defined later in this module
/// }
+3 -3
View File
@@ -76,8 +76,8 @@ frame_support::construct_runtime!(
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Module, Call, Config, Storage, Event<T>},
TestPallet: pallet_test::{Module, Call, Storage},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
TestPallet: pallet_test::{Pallet, Call, Storage},
}
);
@@ -133,7 +133,7 @@ mod benchmarks {
use crate::{BenchmarkingSetup, BenchmarkParameter, account};
// Additional used internally by the benchmark macro.
use super::pallet_test::{Call, Config, Module};
use super::pallet_test::{Call, Config, Pallet};
crate::benchmarks!{
where_clause {
+3 -3
View File
@@ -84,7 +84,7 @@ fn setup_pot_account<T: Config>() {
}
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 EventRecord { event, .. } = &events[events.len() - 1];
@@ -122,7 +122,7 @@ benchmarks! {
let (curator_lookup, bounty_id) = create_bounty::<T>()?;
Bounties::<T>::on_initialize(T::BlockNumber::zero());
let bounty_id = BountyCount::get() - 1;
frame_system::Module::<T>::set_block_number(T::BountyUpdatePeriod::get() + 1u32.into());
frame_system::Pallet::<T>::set_block_number(T::BountyUpdatePeriod::get() + 1u32.into());
let caller = whitelisted_caller();
}: _(RawOrigin::Signed(caller), bounty_id)
@@ -159,7 +159,7 @@ benchmarks! {
let beneficiary = T::Lookup::unlookup(beneficiary_account.clone());
Bounties::<T>::award_bounty(RawOrigin::Signed(curator.clone()).into(), bounty_id, beneficiary)?;
frame_system::Module::<T>::set_block_number(T::BountyDepositPayoutDelay::get());
frame_system::Pallet::<T>::set_block_number(T::BountyDepositPayoutDelay::get());
ensure!(T::Currency::free_balance(&beneficiary_account).is_zero(), "Beneficiary already has balance");
}: _(RawOrigin::Signed(curator), bounty_id)
+5 -5
View File
@@ -424,7 +424,7 @@ decl_module! {
// If the sender is not the curator, and the curator is inactive,
// slash the curator.
if sender != *curator {
let block_number = system::Module::<T>::block_number();
let block_number = system::Pallet::<T>::block_number();
if *update_due < block_number {
slash_curator(curator, &mut bounty.curator_deposit);
// Continue to change bounty status below...
@@ -479,7 +479,7 @@ decl_module! {
T::Currency::reserve(curator, deposit)?;
bounty.curator_deposit = deposit;
let update_due = system::Module::<T>::block_number() + T::BountyUpdatePeriod::get();
let update_due = system::Pallet::<T>::block_number() + T::BountyUpdatePeriod::get();
bounty.status = BountyStatus::Active { curator: curator.clone(), update_due };
Ok(())
@@ -518,7 +518,7 @@ decl_module! {
bounty.status = BountyStatus::PendingPayout {
curator: signer,
beneficiary: beneficiary.clone(),
unlock_at: system::Module::<T>::block_number() + T::BountyDepositPayoutDelay::get(),
unlock_at: system::Pallet::<T>::block_number() + T::BountyDepositPayoutDelay::get(),
};
Ok(())
@@ -543,7 +543,7 @@ decl_module! {
Bounties::<T>::try_mutate_exists(bounty_id, |maybe_bounty| -> DispatchResult {
let bounty = maybe_bounty.take().ok_or(Error::<T>::InvalidIndex)?;
if let BountyStatus::PendingPayout { curator, beneficiary, unlock_at } = bounty.status {
ensure!(system::Module::<T>::block_number() >= unlock_at, Error::<T>::Premature);
ensure!(system::Pallet::<T>::block_number() >= unlock_at, Error::<T>::Premature);
let bounty_account = Self::bounty_account_id(bounty_id);
let balance = T::Currency::free_balance(&bounty_account);
let fee = bounty.fee.min(balance); // just to be safe
@@ -649,7 +649,7 @@ decl_module! {
match bounty.status {
BountyStatus::Active { ref curator, ref mut update_due } => {
ensure!(*curator == signer, Error::<T>::RequireCurator);
*update_due = (system::Module::<T>::block_number() + T::BountyUpdatePeriod::get()).max(*update_due);
*update_due = (system::Pallet::<T>::block_number() + T::BountyUpdatePeriod::get()).max(*update_due);
},
_ => return Err(Error::<T>::UnexpectedStatus.into()),
}
+5 -5
View File
@@ -43,10 +43,10 @@ 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>},
Bounties: pallet_bounties::{Module, Call, Storage, Event<T>},
Treasury: pallet_treasury::{Module, Call, Storage, Config, Event<T>},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Bounties: pallet_bounties::{Pallet, Call, Storage, Event<T>},
Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>},
}
);
@@ -107,7 +107,7 @@ parameter_types! {
// impl pallet_treasury::Config for Test {
impl pallet_treasury::Config for Test {
type ModuleId = TreasuryModuleId;
type Currency = pallet_balances::Module<Test>;
type Currency = pallet_balances::Pallet<Test>;
type ApproveOrigin = frame_system::EnsureRoot<u128>;
type RejectOrigin = frame_system::EnsureRoot<u128>;
type Event = Event;
@@ -31,7 +31,7 @@ use sp_runtime::traits::Bounded;
use sp_std::mem::size_of;
use frame_system::Call as SystemCall;
use frame_system::Module as System;
use frame_system::Pallet as System;
use crate::Module as Collective;
const SEED: u32 = 0;
+6 -6
View File
@@ -472,7 +472,7 @@ decl_module! {
let index = Self::proposal_count();
<ProposalCount<I>>::mutate(|i| *i += 1);
<ProposalOf<T, I>>::insert(proposal_hash, *proposal);
let end = system::Module::<T>::block_number() + T::MotionDuration::get();
let end = system::Pallet::<T>::block_number() + T::MotionDuration::get();
let votes = Votes { index, threshold, ayes: vec![who.clone()], nays: vec![], end };
<Voting<T, I>>::insert(proposal_hash, votes);
@@ -647,7 +647,7 @@ decl_module! {
}
// Only allow actual closing of the proposal after the voting period has ended.
ensure!(system::Module::<T>::block_number() >= voting.end, Error::<T, I>::TooEarly);
ensure!(system::Pallet::<T>::block_number() >= voting.end, Error::<T, I>::TooEarly);
let prime_vote = Self::prime().map(|who| voting.ayes.iter().any(|a| a == &who));
@@ -1045,10 +1045,10 @@ mod tests {
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic
{
System: system::{Module, Call, Event<T>},
Collective: collective::<Instance1>::{Module, Call, Event<T>, Origin<T>, Config<T>},
CollectiveMajority: collective::<Instance2>::{Module, Call, Event<T>, Origin<T>, Config<T>},
DefaultCollective: collective::{Module, Call, Event<T>, Origin<T>, Config<T>},
System: system::{Pallet, Call, Event<T>},
Collective: collective::<Instance1>::{Pallet, Call, Event<T>, Origin<T>, Config<T>},
CollectiveMajority: collective::<Instance2>::{Pallet, Call, Event<T>, Origin<T>, Config<T>},
DefaultCollective: collective::{Pallet, Call, Event<T>, Origin<T>, Config<T>},
}
);
+1 -1
View File
@@ -176,7 +176,7 @@ Before a call or instantiate can be performed the execution context must be init
For the first call or instantiation in the handling of an extrinsic, this involves two calls:
1. `<timestamp::Module<T>>::now()`
2. `<system::Module<T>>::block_number()`
2. `<system::Pallet<T>>::block_number()`
The complexity of initialization depends on the complexity of these functions. In the current
implementation they just involve a DB read.
@@ -25,7 +25,7 @@
//! compiles it down into a `WasmModule` that can be used as a contract's code.
use crate::Config;
use crate::Module as Contracts;
use crate::Pallet as Contracts;
use parity_wasm::elements::{
Instruction, Instructions, FuncBody, ValueType, BlockType, Section, CustomSection,
@@ -23,7 +23,7 @@ mod code;
mod sandbox;
use crate::{
*, Module as Contracts,
*, Pallet as Contracts,
exec::StorageKey,
rent::Rent,
schedule::{API_BENCHMARK_BATCH_SIZE, INSTR_BENCHMARK_BATCH_SIZE},
@@ -37,7 +37,7 @@ use self::{
sandbox::Sandbox,
};
use frame_benchmarking::{benchmarks, account, whitelisted_caller, impl_benchmark_test_suite};
use frame_system::{Module as System, RawOrigin};
use frame_system::{Pallet as System, RawOrigin};
use parity_wasm::elements::{Instruction, ValueType, BlockType};
use sp_runtime::traits::{Hash, Bounded, Zero};
use sp_std::{default::Default, convert::{TryInto}, vec::Vec, vec};
+4 -4
View File
@@ -16,7 +16,7 @@
// limitations under the License.
use crate::{
CodeHash, Event, Config, Module as Contracts,
CodeHash, Event, Config, Pallet as Contracts,
TrieId, BalanceOf, ContractInfo, gas::GasMeter, rent::Rent, storage::{self, Storage},
Error, ContractInfoOf, Schedule, AliveContractInfo,
};
@@ -384,7 +384,7 @@ where
depth: 0,
schedule,
timestamp: T::Time::now(),
block_number: <frame_system::Module<T>>::block_number(),
block_number: <frame_system::Pallet<T>>::block_number(),
_phantom: Default::default(),
}
}
@@ -909,7 +909,7 @@ fn deposit_event<T: Config>(
topics: Vec<T::Hash>,
event: Event<T>,
) {
<frame_system::Module<T>>::deposit_event_indexed(
<frame_system::Pallet<T>>::deposit_event_indexed(
&*topics,
<T as Config>::Event::from(event).into(),
)
@@ -961,7 +961,7 @@ mod tests {
}
fn events() -> Vec<Event<Test>> {
<frame_system::Module<Test>>::events()
<frame_system::Pallet<Test>>::events()
.into_iter()
.filter_map(|meta| match meta.event {
MetaEvent::pallet_contracts(contract_event) => Some(contract_event),
+9 -9
View File
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! # Contract Module
//! # Contract Pallet
//!
//! The Contract module provides functionality for the runtime to deploy and execute WebAssembly smart-contracts.
//!
@@ -124,7 +124,7 @@ use frame_support::{
traits::{OnUnbalanced, Currency, Get, Time, Randomness},
weights::{Weight, PostDispatchInfo, WithPostDispatchInfo},
};
use frame_system::Module as System;
use frame_system::Pallet as System;
use pallet_contracts_primitives::{
RentProjectionResult, GetStorageResult, ContractAccessError, ContractExecResult,
};
@@ -290,7 +290,7 @@ pub mod pallet {
schedule: Schedule<T>
) -> DispatchResultWithPostInfo {
ensure_root(origin)?;
if <Module<T>>::current_schedule().version > schedule.version {
if <Pallet<T>>::current_schedule().version > schedule.version {
Err(Error::<T>::InvalidScheduleVersion)?
}
Self::deposit_event(Event::ScheduleUpdated(schedule.version));
@@ -316,7 +316,7 @@ pub mod pallet {
let origin = ensure_signed(origin)?;
let dest = T::Lookup::lookup(dest)?;
let mut gas_meter = GasMeter::new(gas_limit);
let schedule = <Module<T>>::current_schedule();
let schedule = <Pallet<T>>::current_schedule();
let mut ctx = ExecutionContext::<T, PrefabWasmModule<T>>::top_level(origin, &schedule);
let (result, code_len) = match ctx.call(dest, value, &mut gas_meter, data) {
Ok((output, len)) => (Ok(output), len),
@@ -365,7 +365,7 @@ pub mod pallet {
let code_len = code.len() as u32;
ensure!(code_len <= T::MaxCodeSize::get(), Error::<T>::CodeTooLarge);
let mut gas_meter = GasMeter::new(gas_limit);
let schedule = <Module<T>>::current_schedule();
let schedule = <Pallet<T>>::current_schedule();
let executable = PrefabWasmModule::from_code(code, &schedule)?;
let code_len = executable.code_len();
ensure!(code_len <= T::MaxCodeSize::get(), Error::<T>::CodeTooLarge);
@@ -397,7 +397,7 @@ pub mod pallet {
) -> DispatchResultWithPostInfo {
let origin = ensure_signed(origin)?;
let mut gas_meter = GasMeter::new(gas_limit);
let schedule = <Module<T>>::current_schedule();
let schedule = <Pallet<T>>::current_schedule();
let executable = PrefabWasmModule::from_storage(code_hash, &schedule, &mut gas_meter)?;
let mut ctx = ExecutionContext::<T, PrefabWasmModule<T>>::top_level(origin, &schedule);
let code_len = executable.code_len();
@@ -665,7 +665,7 @@ pub mod pallet {
}
}
impl<T: Config> Module<T>
impl<T: Config> Pallet<T>
where
T::AccountId: UncheckedFrom<T::Hash> + AsRef<[u8]>,
{
@@ -683,7 +683,7 @@ where
input_data: Vec<u8>,
) -> ContractExecResult {
let mut gas_meter = GasMeter::new(gas_limit);
let schedule = <Module<T>>::current_schedule();
let schedule = <Pallet<T>>::current_schedule();
let mut ctx = ExecutionContext::<T, PrefabWasmModule<T>>::top_level(origin, &schedule);
let result = ctx.call(dest, value, &mut gas_meter, input_data);
let gas_consumed = gas_meter.gas_spent();
@@ -746,7 +746,7 @@ where
/// Store code for benchmarks which does not check nor instrument the code.
#[cfg(feature = "runtime-benchmarks")]
fn store_code_raw(code: Vec<u8>) -> frame_support::dispatch::DispatchResult {
let schedule = <Module<T>>::current_schedule();
let schedule = <Pallet<T>>::current_schedule();
PrefabWasmModule::store_code_unchecked(code, &schedule)?;
Ok(())
}
+7 -7
View File
@@ -18,7 +18,7 @@
//! A module responsible for computing the right amount of weight and charging it.
use crate::{
AliveContractInfo, BalanceOf, ContractInfo, ContractInfoOf, Module, Event,
AliveContractInfo, BalanceOf, ContractInfo, ContractInfoOf, Pallet, Event,
TombstoneContractInfo, Config, CodeHash, Error,
storage::Storage, wasm::PrefabWasmModule, exec::Executable,
};
@@ -124,7 +124,7 @@ where
free_balance: &BalanceOf<T>,
contract: &AliveContractInfo<T>,
) -> Option<BalanceOf<T>> {
let subsistence_threshold = Module::<T>::subsistence_threshold();
let subsistence_threshold = Pallet::<T>::subsistence_threshold();
// Reserved balance contributes towards the subsistence threshold to stay consistent
// with the existential deposit where the reserved balance is also counted.
if *total_balance < subsistence_threshold {
@@ -268,7 +268,7 @@ where
let tombstone_info = ContractInfo::Tombstone(tombstone);
<ContractInfoOf<T>>::insert(account, &tombstone_info);
code.drop_from_storage();
<Module<T>>::deposit_event(Event::Evicted(account.clone()));
<Pallet<T>>::deposit_event(Event::Evicted(account.clone()));
Ok(None)
}
(Verdict::Evict { amount: _ }, None) => {
@@ -298,7 +298,7 @@ where
contract: AliveContractInfo<T>,
code_size: u32,
) -> Result<Option<AliveContractInfo<T>>, DispatchError> {
let current_block_number = <frame_system::Module<T>>::block_number();
let current_block_number = <frame_system::Pallet<T>>::block_number();
let verdict = Self::consider_case(
account,
current_block_number,
@@ -333,7 +333,7 @@ where
};
let module = PrefabWasmModule::<T>::from_storage_noinstr(contract.code_hash)?;
let code_len = module.code_len();
let current_block_number = <frame_system::Module<T>>::block_number();
let current_block_number = <frame_system::Pallet<T>>::block_number();
let verdict = Self::consider_case(
account,
current_block_number,
@@ -384,7 +384,7 @@ where
let module = PrefabWasmModule::from_storage_noinstr(alive_contract_info.code_hash)
.map_err(|_| IsTombstone)?;
let code_size = module.occupied_storage();
let current_block_number = <frame_system::Module<T>>::block_number();
let current_block_number = <frame_system::Pallet<T>>::block_number();
let verdict = Self::consider_case(
account,
current_block_number,
@@ -465,7 +465,7 @@ where
let child_trie_info = origin_contract.child_trie_info();
let current_block = <frame_system::Module<T>>::block_number();
let current_block = <frame_system::Pallet<T>>::block_number();
if origin_contract.last_write == Some(current_block) {
return Err((Error::<T>::InvalidContractOrigin.into(), 0, 0));
+2 -2
View File
@@ -117,7 +117,7 @@ where
.and_then(|val| val.checked_add(new_value_len))
.ok_or_else(|| Error::<T>::StorageExhausted)?;
new_info.last_write = Some(<frame_system::Module<T>>::block_number());
new_info.last_write = Some(<frame_system::Pallet<T>>::block_number());
<ContractInfoOf<T>>::insert(&account, ContractInfo::Alive(new_info));
// Finally, perform the change on the storage.
@@ -176,7 +176,7 @@ where
// We want to charge rent for the first block in advance. Therefore we
// treat the contract as if it was created in the last block and then
// charge rent for it during instantiation.
<frame_system::Module<T>>::block_number().saturating_sub(1u32.into()),
<frame_system::Pallet<T>>::block_number().saturating_sub(1u32.into()),
rent_allowance: <BalanceOf<T>>::max_value(),
rent_payed: <BalanceOf<T>>::zero(),
pair_count: 0,
+25 -25
View File
@@ -16,7 +16,7 @@
// limitations under the License.
use crate::{
BalanceOf, ContractInfo, ContractInfoOf, Module,
BalanceOf, ContractInfo, ContractInfoOf, Pallet,
RawAliveContractInfo, Config, Schedule,
Error, storage::Storage,
chain_extension::{
@@ -57,11 +57,11 @@ 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>},
Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},
Randomness: pallet_randomness_collective_flip::{Module, Call, Storage},
Contracts: pallet_contracts::{Module, Call, Config<T>, Storage, Event<T>},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},
Randomness: pallet_randomness_collective_flip::{Pallet, Call, Storage},
Contracts: pallet_contracts::{Pallet, Call, Config<T>, Storage, Event<T>},
}
);
@@ -72,7 +72,7 @@ pub mod test_utils {
ContractInfoOf, CodeHash,
storage::Storage,
exec::{StorageKey, AccountIdOf},
Module as Contracts,
Pallet as Contracts,
};
use frame_support::traits::Currency;
@@ -457,7 +457,7 @@ fn instantiate_and_call_and_deposit_event() {
.build()
.execute_with(|| {
let _ = Balances::deposit_creating(&ALICE, 1_000_000);
let subsistence = Module::<Test>::subsistence_threshold();
let subsistence = Pallet::<Test>::subsistence_threshold();
// Check at the end to get hash on error easily
let creation = Contracts::instantiate_with_code(
@@ -572,7 +572,7 @@ fn deposit_event_max_value_limit() {
#[test]
fn run_out_of_gas() {
let (wasm, code_hash) = compile_module::<Test>("run_out_of_gas").unwrap();
let subsistence = Module::<Test>::subsistence_threshold();
let subsistence = Pallet::<Test>::subsistence_threshold();
ExtBuilder::default()
.existential_deposit(50)
@@ -908,7 +908,7 @@ fn removals(trigger_call: impl Fn(AccountIdOf<Test>) -> bool) {
.unwrap().get_alive().unwrap().rent_allowance;
let balance = Balances::free_balance(&addr);
let subsistence_threshold = Module::<Test>::subsistence_threshold();
let subsistence_threshold = Pallet::<Test>::subsistence_threshold();
// Trigger rent must have no effect
assert!(!trigger_call(addr.clone()));
@@ -997,7 +997,7 @@ fn removals(trigger_call: impl Fn(AccountIdOf<Test>) -> bool) {
.build()
.execute_with(|| {
// Create
let subsistence_threshold = Module::<Test>::subsistence_threshold();
let subsistence_threshold = Pallet::<Test>::subsistence_threshold();
let _ = Balances::deposit_creating(&ALICE, subsistence_threshold * 1000);
assert_ok!(Contracts::instantiate_with_code(
Origin::signed(ALICE),
@@ -1878,7 +1878,7 @@ fn crypto_hashes() {
// We offset data in the contract tables by 1.
let mut params = vec![(n + 1) as u8];
params.extend_from_slice(input);
let result = <Module<Test>>::bare_call(
let result = <Pallet<Test>>::bare_call(
ALICE,
addr.clone(),
0,
@@ -1896,7 +1896,7 @@ fn crypto_hashes() {
fn transfer_return_code() {
let (wasm, code_hash) = compile_module::<Test>("transfer_return_code").unwrap();
ExtBuilder::default().existential_deposit(50).build().execute_with(|| {
let subsistence = Module::<Test>::subsistence_threshold();
let subsistence = Pallet::<Test>::subsistence_threshold();
let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence);
assert_ok!(
@@ -1943,7 +1943,7 @@ fn call_return_code() {
let (caller_code, caller_hash) = compile_module::<Test>("call_return_code").unwrap();
let (callee_code, callee_hash) = compile_module::<Test>("ok_trap_revert").unwrap();
ExtBuilder::default().existential_deposit(50).build().execute_with(|| {
let subsistence = Module::<Test>::subsistence_threshold();
let subsistence = Pallet::<Test>::subsistence_threshold();
let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence);
let _ = Balances::deposit_creating(&CHARLIE, 1000 * subsistence);
@@ -2036,7 +2036,7 @@ fn instantiate_return_code() {
let (caller_code, caller_hash) = compile_module::<Test>("instantiate_return_code").unwrap();
let (callee_code, callee_hash) = compile_module::<Test>("ok_trap_revert").unwrap();
ExtBuilder::default().existential_deposit(50).build().execute_with(|| {
let subsistence = Module::<Test>::subsistence_threshold();
let subsistence = Pallet::<Test>::subsistence_threshold();
let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence);
let _ = Balances::deposit_creating(&CHARLIE, 1000 * subsistence);
let callee_hash = callee_hash.as_ref().to_vec();
@@ -2127,7 +2127,7 @@ fn instantiate_return_code() {
fn disabled_chain_extension_wont_deploy() {
let (code, _hash) = compile_module::<Test>("chain_extension").unwrap();
ExtBuilder::default().existential_deposit(50).build().execute_with(|| {
let subsistence = Module::<Test>::subsistence_threshold();
let subsistence = Pallet::<Test>::subsistence_threshold();
let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence);
TestExtension::disable();
assert_err_ignore_postinfo!(
@@ -2148,7 +2148,7 @@ fn disabled_chain_extension_wont_deploy() {
fn disabled_chain_extension_errors_on_call() {
let (code, hash) = compile_module::<Test>("chain_extension").unwrap();
ExtBuilder::default().existential_deposit(50).build().execute_with(|| {
let subsistence = Module::<Test>::subsistence_threshold();
let subsistence = Pallet::<Test>::subsistence_threshold();
let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence);
assert_ok!(
Contracts::instantiate_with_code(
@@ -2179,7 +2179,7 @@ fn disabled_chain_extension_errors_on_call() {
fn chain_extension_works() {
let (code, hash) = compile_module::<Test>("chain_extension").unwrap();
ExtBuilder::default().existential_deposit(50).build().execute_with(|| {
let subsistence = Module::<Test>::subsistence_threshold();
let subsistence = Pallet::<Test>::subsistence_threshold();
let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence);
assert_ok!(
Contracts::instantiate_with_code(
@@ -2248,7 +2248,7 @@ fn chain_extension_works() {
fn lazy_removal_works() {
let (code, hash) = compile_module::<Test>("self_destruct").unwrap();
ExtBuilder::default().existential_deposit(50).build().execute_with(|| {
let subsistence = Module::<Test>::subsistence_threshold();
let subsistence = Pallet::<Test>::subsistence_threshold();
let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence);
assert_ok!(
@@ -2308,7 +2308,7 @@ fn lazy_removal_partial_remove_works() {
let mut ext = ExtBuilder::default().existential_deposit(50).build();
let trie = ext.execute_with(|| {
let subsistence = Module::<Test>::subsistence_threshold();
let subsistence = Pallet::<Test>::subsistence_threshold();
let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence);
assert_ok!(
@@ -2389,7 +2389,7 @@ fn lazy_removal_partial_remove_works() {
fn lazy_removal_does_no_run_on_full_block() {
let (code, hash) = compile_module::<Test>("self_destruct").unwrap();
ExtBuilder::default().existential_deposit(50).build().execute_with(|| {
let subsistence = Module::<Test>::subsistence_threshold();
let subsistence = Pallet::<Test>::subsistence_threshold();
let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence);
assert_ok!(
@@ -2473,7 +2473,7 @@ fn lazy_removal_does_no_run_on_full_block() {
fn lazy_removal_does_not_use_all_weight() {
let (code, hash) = compile_module::<Test>("self_destruct").unwrap();
ExtBuilder::default().existential_deposit(50).build().execute_with(|| {
let subsistence = Module::<Test>::subsistence_threshold();
let subsistence = Pallet::<Test>::subsistence_threshold();
let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence);
assert_ok!(
@@ -2543,7 +2543,7 @@ fn lazy_removal_does_not_use_all_weight() {
fn deletion_queue_full() {
let (code, hash) = compile_module::<Test>("self_destruct").unwrap();
ExtBuilder::default().existential_deposit(50).build().execute_with(|| {
let subsistence = Module::<Test>::subsistence_threshold();
let subsistence = Pallet::<Test>::subsistence_threshold();
let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence);
assert_ok!(
@@ -2669,7 +2669,7 @@ fn refcounter() {
let (wasm, code_hash) = compile_module::<Test>("self_destruct").unwrap();
ExtBuilder::default().existential_deposit(50).build().execute_with(|| {
let _ = Balances::deposit_creating(&ALICE, 1_000_000);
let subsistence = Module::<Test>::subsistence_threshold();
let subsistence = Pallet::<Test>::subsistence_threshold();
// Create two contracts with the same code and check that they do in fact share it.
assert_ok!(Contracts::instantiate_with_code(
@@ -2741,7 +2741,7 @@ fn reinstrument_does_charge() {
let (wasm, code_hash) = compile_module::<Test>("return_with_data").unwrap();
ExtBuilder::default().existential_deposit(50).build().execute_with(|| {
let _ = Balances::deposit_creating(&ALICE, 1_000_000);
let subsistence = Module::<Test>::subsistence_threshold();
let subsistence = Pallet::<Test>::subsistence_threshold();
let zero = 0u32.to_le_bytes().encode();
let code_len = wasm.len() as u32;
@@ -29,7 +29,7 @@
use crate::{
CodeHash, CodeStorage, PristineCode, Schedule, Config, Error, Weight,
wasm::{prepare, PrefabWasmModule}, Module as Contracts, Event,
wasm::{prepare, PrefabWasmModule}, Pallet as Contracts, Event,
gas::{GasMeter, Token},
weights::WeightInfo,
};
+1 -1
View File
@@ -245,7 +245,7 @@ where
mod tests {
use super::*;
use crate::{
CodeHash, BalanceOf, Error, Module as Contracts,
CodeHash, BalanceOf, Error, Pallet as Contracts,
exec::{Ext, StorageKey, AccountIdOf, Executable, RentParams},
gas::GasMeter,
tests::{Test, Call, ALICE, BOB},
@@ -24,10 +24,10 @@ use frame_support::{
IterableStorageMap,
traits::{Currency, Get, EnsureOrigin, OnInitialize, UnfilteredDispatchable, schedule::DispatchTime},
};
use frame_system::{RawOrigin, Module as System, self, EventRecord};
use frame_system::{RawOrigin, Pallet as System, self, EventRecord};
use sp_runtime::traits::{Bounded, One};
use crate::Module as Democracy;
use crate::Pallet as Democracy;
const SEED: u32 = 0;
const MAX_REFERENDUMS: u32 = 99;
+11 -11
View File
@@ -596,7 +596,7 @@ decl_module! {
if let Some((until, _)) = <Blacklist<T>>::get(proposal_hash) {
ensure!(
<frame_system::Module<T>>::block_number() >= until,
<frame_system::Pallet<T>>::block_number() >= until,
Error::<T>::ProposalBlacklisted,
);
}
@@ -688,7 +688,7 @@ decl_module! {
ensure!(!<NextExternal<T>>::exists(), Error::<T>::DuplicateProposal);
if let Some((until, _)) = <Blacklist<T>>::get(proposal_hash) {
ensure!(
<frame_system::Module<T>>::block_number() >= until,
<frame_system::Pallet<T>>::block_number() >= until,
Error::<T>::ProposalBlacklisted,
);
}
@@ -776,7 +776,7 @@ decl_module! {
ensure!(proposal_hash == e_proposal_hash, Error::<T>::InvalidHash);
<NextExternal<T>>::kill();
let now = <frame_system::Module<T>>::block_number();
let now = <frame_system::Pallet<T>>::block_number();
Self::inject_referendum(now + voting_period, proposal_hash, threshold, delay);
}
@@ -806,7 +806,7 @@ decl_module! {
.err().ok_or(Error::<T>::AlreadyVetoed)?;
existing_vetoers.insert(insert_position, who.clone());
let until = <frame_system::Module<T>>::block_number() + T::CooloffPeriod::get();
let until = <frame_system::Pallet<T>>::block_number() + T::CooloffPeriod::get();
<Blacklist<T>>::insert(&proposal_hash, (until, existing_vetoers));
Self::deposit_event(RawEvent::Vetoed(who, proposal_hash, until));
@@ -1004,7 +1004,7 @@ decl_module! {
_ => None,
}).ok_or(Error::<T>::PreimageMissing)?;
let now = <frame_system::Module<T>>::block_number();
let now = <frame_system::Pallet<T>>::block_number();
let (voting, enactment) = (T::VotingPeriod::get(), T::EnactmentPeriod::get());
let additional = if who == provider { Zero::zero() } else { enactment };
ensure!(now >= since + voting + additional, Error::<T>::TooEarly);
@@ -1209,7 +1209,7 @@ impl<T: Config> Module<T> {
delay: T::BlockNumber
) -> ReferendumIndex {
<Module<T>>::inject_referendum(
<frame_system::Module<T>>::block_number() + T::VotingPeriod::get(),
<frame_system::Pallet<T>>::block_number() + T::VotingPeriod::get(),
proposal_hash,
threshold,
delay
@@ -1308,7 +1308,7 @@ impl<T: Config> Module<T> {
Some(ReferendumInfo::Finished{end, approved}) =>
if let Some((lock_periods, balance)) = votes[i].1.locked_if(approved) {
let unlock_at = end + T::EnactmentPeriod::get() * lock_periods.into();
let now = system::Module::<T>::block_number();
let now = system::Pallet::<T>::block_number();
if now < unlock_at {
ensure!(matches!(scope, UnvoteScope::Any), Error::<T>::NoPermission);
prior.accumulate(unlock_at, balance)
@@ -1435,7 +1435,7 @@ impl<T: Config> Module<T> {
} => {
// remove any delegation votes to our current target.
let votes = Self::reduce_upstream_delegation(&target, conviction.votes(balance));
let now = system::Module::<T>::block_number();
let now = system::Pallet::<T>::block_number();
let lock_periods = conviction.lock_periods().into();
prior.accumulate(now + T::EnactmentPeriod::get() * lock_periods, balance);
voting.set_common(delegations, prior);
@@ -1455,7 +1455,7 @@ impl<T: Config> Module<T> {
/// a security hole) but may be reduced from what they are currently.
fn update_lock(who: &T::AccountId) {
let lock_needed = VotingOf::<T>::mutate(who, |voting| {
voting.rejig(system::Module::<T>::block_number());
voting.rejig(system::Pallet::<T>::block_number());
voting.locked_balance()
});
if lock_needed.is_zero() {
@@ -1716,7 +1716,7 @@ impl<T: Config> Module<T> {
.saturating_mul(T::PreimageByteDeposit::get());
T::Currency::reserve(&who, deposit)?;
let now = <frame_system::Module<T>>::block_number();
let now = <frame_system::Pallet<T>>::block_number();
let a = PreimageStatus::Available {
data: encoded_proposal,
provider: who.clone(),
@@ -1738,7 +1738,7 @@ impl<T: Config> Module<T> {
let status = Preimages::<T>::get(&proposal_hash).ok_or(Error::<T>::NotImminent)?;
let expiry = status.to_missing_expiry().ok_or(Error::<T>::DuplicatePreimage)?;
let now = <frame_system::Module<T>>::block_number();
let now = <frame_system::Pallet<T>>::block_number();
let free = <BalanceOf<T>>::zero();
let a = PreimageStatus::Available {
data: encoded_proposal,
+5 -5
View File
@@ -60,10 +60,10 @@ 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>},
Scheduler: pallet_scheduler::{Module, Call, Storage, Config, Event<T>},
Democracy: pallet_democracy::{Module, Call, Storage, Config, Event<T>},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Scheduler: pallet_scheduler::{Pallet, Call, Storage, Config, Event<T>},
Democracy: pallet_democracy::{Pallet, Call, Storage, Config, Event<T>},
}
);
@@ -161,7 +161,7 @@ impl Contains<u64> for OneToFive {
impl Config for Test {
type Proposal = Call;
type Event = Event;
type Currency = pallet_balances::Module<Self>;
type Currency = pallet_balances::Pallet<Self>;
type EnactmentPeriod = EnactmentPeriod;
type LaunchPeriod = LaunchPeriod;
type VotingPeriod = VotingPeriod;
@@ -18,7 +18,7 @@
//! Two phase election pallet benchmarking.
use super::*;
use crate::Module as MultiPhase;
use crate::Pallet as MultiPhase;
use frame_benchmarking::impl_benchmark_test_suite;
use frame_support::{assert_ok, traits::OnInitialize};
use frame_system::RawOrigin;
@@ -25,7 +25,7 @@ macro_rules! log {
($level:tt, $pattern:expr $(, $values:expr)* $(,)?) => {
log::$level!(
target: $crate::LOG_TARGET,
concat!("[#{:?}] 🗳 ", $pattern), <frame_system::Module<T>>::block_number() $(, $values)*
concat!("[#{:?}] 🗳 ", $pattern), <frame_system::Pallet<T>>::block_number() $(, $values)*
)
};
}
@@ -52,9 +52,9 @@ frame_support::construct_runtime!(
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic
{
System: frame_system::{Module, Call, Event<T>, Config},
Balances: pallet_balances::{Module, Call, Event<T>, Config<T>},
MultiPhase: multi_phase::{Module, Call, Event<T>},
System: frame_system::{Pallet, Call, Event<T>, Config},
Balances: pallet_balances::{Pallet, Call, Event<T>, Config<T>},
MultiPhase: multi_phase::{Pallet, Call, Event<T>},
}
);
@@ -1096,7 +1096,7 @@ mod tests {
type Event = Event;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = frame_system::Module<Test>;
type AccountStore = frame_system::Pallet<Test>;
type MaxLocks = ();
type WeightInfo = ();
}
@@ -1187,9 +1187,9 @@ mod tests {
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic
{
System: frame_system::{Module, Call, Event<T>},
Balances: pallet_balances::{Module, Call, Event<T>, Config<T>},
Elections: elections_phragmen::{Module, Call, Event<T>, Config<T>},
System: frame_system::{Pallet, Call, Event<T>},
Balances: pallet_balances::{Pallet, Call, Event<T>, Config<T>},
Elections: elections_phragmen::{Pallet, Call, Event<T>, Config<T>},
}
);
+4 -4
View File
@@ -713,7 +713,7 @@ decl_event!(
BadReaperSlashed(AccountId),
/// A tally (for approval votes of \[seats\]) has started.
TallyStarted(u32),
/// A tally (for approval votes of seat(s)) has ended (with one or more new members).
/// A tally (for approval votes of seat(s)) has ended (with one or more new members).
/// \[incoming, outgoing\]
TallyFinalized(Vec<AccountId>, Vec<AccountId>),
}
@@ -759,7 +759,7 @@ impl<T: Config> Module<T> {
// if there's a tally in progress, then next tally can begin immediately afterwards
(tally_end, c.len() - leavers.len() + comers as usize, comers)
} else {
(<frame_system::Module<T>>::block_number(), c.len(), 0)
(<frame_system::Pallet<T>>::block_number(), c.len(), 0)
};
if count < desired_seats as usize {
Some(next_possible)
@@ -914,7 +914,7 @@ impl<T: Config> Module<T> {
fn start_tally() {
let members = Self::members();
let desired_seats = Self::desired_seats() as usize;
let number = <frame_system::Module<T>>::block_number();
let number = <frame_system::Pallet<T>>::block_number();
let expiring =
members.iter().take_while(|i| i.1 <= number).map(|i| i.0.clone()).collect::<Vec<_>>();
let retaining_seats = members.len() - expiring.len();
@@ -942,7 +942,7 @@ impl<T: Config> Module<T> {
.ok_or("finalize can only be called after a tally is started.")?;
let leaderboard: Vec<(BalanceOf<T>, T::AccountId)> = <Leaderboard<T>>::take()
.unwrap_or_default();
let new_expiry = <frame_system::Module<T>>::block_number() + Self::term_duration();
let new_expiry = <frame_system::Pallet<T>>::block_number() + Self::term_duration();
// return bond to winners.
let candidacy_bond = T::CandidacyBond::get();
+3 -3
View File
@@ -135,9 +135,9 @@ frame_support::construct_runtime!(
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic
{
System: system::{Module, Call, Event<T>},
Balances: pallet_balances::{Module, Call, Event<T>, Config<T>},
Elections: elections::{Module, Call, Event<T>, Config<T>},
System: system::{Pallet, Call, Event<T>},
Balances: pallet_balances::{Pallet, Call, Event<T>, Config<T>},
Elections: elections::{Pallet, Call, Event<T>, Config<T>},
}
);
@@ -49,8 +49,8 @@ frame_support::construct_runtime!(
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Module, Call, Config, Storage, Event<T>},
Example: example_offchain_worker::{Module, Call, Storage, Event<T>, ValidateUnsigned},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Example: example_offchain_worker::{Pallet, Call, Storage, Event<T>, ValidateUnsigned},
}
);
@@ -33,8 +33,8 @@ frame_support::construct_runtime!(
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Module, Call, Config, Storage, Event<T>},
Example: pallet_example_parallel::{Module, Call, Storage},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Example: pallet_example_parallel::{Pallet, Call, Storage},
}
);
+3 -3
View File
@@ -758,9 +758,9 @@ mod tests {
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Module, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
Example: pallet_example::{Module, Call, Storage, Config<T>, Event<T>},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Example: pallet_example::{Pallet, Call, Storage, Config<T>, Event<T>},
}
);
+2 -2
View File
@@ -35,7 +35,7 @@ The default Substrate node template declares the [`Executive`](https://docs.rs/f
```rust
#
/// Executive: handles dispatch to the various modules.
pub type Executive = executive::Executive<Runtime, Block, Context, Runtime, AllModules>;
pub type Executive = executive::Executive<Runtime, Block, Context, Runtime, AllPallets>;
```
### Custom `OnRuntimeUpgrade` logic
@@ -54,7 +54,7 @@ impl frame_support::traits::OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
}
}
pub type Executive = executive::Executive<Runtime, Block, Context, Runtime, AllModules, CustomOnRuntimeUpgrade>;
pub type Executive = executive::Executive<Runtime, Block, Context, Runtime, AllPallets, CustomOnRuntimeUpgrade>;
```
License: Apache-2.0
+64 -64
View File
@@ -59,7 +59,7 @@
//! # type Context = frame_system::ChainContext<Runtime>;
//! # pub type Block = generic::Block<Header, UncheckedExtrinsic>;
//! # pub type Balances = u64;
//! # pub type AllModules = u64;
//! # pub type AllPallets = u64;
//! # pub enum Runtime {};
//! # use sp_runtime::transaction_validity::{
//! # TransactionValidity, UnknownTransaction, TransactionSource,
@@ -73,7 +73,7 @@
//! # }
//! # }
//! /// Executive: handles dispatch to the various modules.
//! pub type Executive = executive::Executive<Runtime, Block, Context, Runtime, AllModules>;
//! pub type Executive = executive::Executive<Runtime, Block, Context, Runtime, AllPallets>;
//! ```
//!
//! ### Custom `OnRuntimeUpgrade` logic
@@ -90,7 +90,7 @@
//! # type Context = frame_system::ChainContext<Runtime>;
//! # pub type Block = generic::Block<Header, UncheckedExtrinsic>;
//! # pub type Balances = u64;
//! # pub type AllModules = u64;
//! # pub type AllPallets = u64;
//! # pub enum Runtime {};
//! # use sp_runtime::transaction_validity::{
//! # TransactionValidity, UnknownTransaction, TransactionSource,
@@ -111,7 +111,7 @@
//! }
//! }
//!
//! pub type Executive = executive::Executive<Runtime, Block, Context, Runtime, AllModules, CustomOnRuntimeUpgrade>;
//! pub type Executive = executive::Executive<Runtime, Block, Context, Runtime, AllPallets, CustomOnRuntimeUpgrade>;
//! ```
#![cfg_attr(not(feature = "std"), no_std)]
@@ -144,12 +144,12 @@ pub type OriginOf<E, C> = <CallOf<E, C> as Dispatchable>::Origin;
/// - `Block`: The block type of the runtime
/// - `Context`: The context that is used when checking an extrinsic.
/// - `UnsignedValidator`: The unsigned transaction validator of the runtime.
/// - `AllModules`: Tuple that contains all modules. Will be used to call e.g. `on_initialize`.
/// - `AllPallets`: Tuple that contains all modules. Will be used to call e.g. `on_initialize`.
/// - `OnRuntimeUpgrade`: Custom logic that should be called after a runtime upgrade. Modules are
/// already called by `AllModules`. It will be called before all modules will
/// already called by `AllPallets`. It will be called before all modules will
/// be called.
pub struct Executive<System, Block, Context, UnsignedValidator, AllModules, OnRuntimeUpgrade = ()>(
PhantomData<(System, Block, Context, UnsignedValidator, AllModules, OnRuntimeUpgrade)>
pub struct Executive<System, Block, Context, UnsignedValidator, AllPallets, OnRuntimeUpgrade = ()>(
PhantomData<(System, Block, Context, UnsignedValidator, AllPallets, OnRuntimeUpgrade)>
);
impl<
@@ -157,7 +157,7 @@ impl<
Block: traits::Block<Header=System::Header, Hash=System::Hash>,
Context: Default,
UnsignedValidator,
AllModules:
AllPallets:
OnRuntimeUpgrade +
OnInitialize<System::BlockNumber> +
OnIdle<System::BlockNumber> +
@@ -165,7 +165,7 @@ impl<
OffchainWorker<System::BlockNumber>,
COnRuntimeUpgrade: OnRuntimeUpgrade,
> ExecuteBlock<Block> for
Executive<System, Block, Context, UnsignedValidator, AllModules, COnRuntimeUpgrade>
Executive<System, Block, Context, UnsignedValidator, AllPallets, COnRuntimeUpgrade>
where
Block::Extrinsic: Checkable<Context> + Codec,
CheckedOf<Block::Extrinsic, Context>:
@@ -176,7 +176,7 @@ where
UnsignedValidator: ValidateUnsigned<Call=CallOf<Block::Extrinsic, Context>>,
{
fn execute_block(block: Block) {
Executive::<System, Block, Context, UnsignedValidator, AllModules>::execute_block(block);
Executive::<System, Block, Context, UnsignedValidator, AllPallets>::execute_block(block);
}
}
@@ -185,13 +185,13 @@ impl<
Block: traits::Block<Header = System::Header, Hash = System::Hash>,
Context: Default,
UnsignedValidator,
AllModules: OnRuntimeUpgrade
AllPallets: OnRuntimeUpgrade
+ OnInitialize<System::BlockNumber>
+ OnIdle<System::BlockNumber>
+ OnFinalize<System::BlockNumber>
+ OffchainWorker<System::BlockNumber>,
COnRuntimeUpgrade: OnRuntimeUpgrade,
> Executive<System, Block, Context, UnsignedValidator, AllModules, COnRuntimeUpgrade>
> Executive<System, Block, Context, UnsignedValidator, AllPallets, COnRuntimeUpgrade>
where
Block::Extrinsic: Checkable<Context> + Codec,
CheckedOf<Block::Extrinsic, Context>: Applyable + GetDispatchInfo,
@@ -204,10 +204,10 @@ where
pub fn execute_on_runtime_upgrade() -> frame_support::weights::Weight {
let mut weight = 0;
weight = weight.saturating_add(
<frame_system::Module<System> as OnRuntimeUpgrade>::on_runtime_upgrade(),
<frame_system::Pallet<System> as OnRuntimeUpgrade>::on_runtime_upgrade(),
);
weight = weight.saturating_add(COnRuntimeUpgrade::on_runtime_upgrade());
weight = weight.saturating_add(<AllModules as OnRuntimeUpgrade>::on_runtime_upgrade());
weight = weight.saturating_add(<AllPallets as OnRuntimeUpgrade>::on_runtime_upgrade());
weight
}
@@ -218,7 +218,7 @@ where
#[cfg(feature = "try-runtime")]
pub fn try_runtime_upgrade() -> Result<frame_support::weights::Weight, &'static str> {
<
(frame_system::Module::<System>, COnRuntimeUpgrade, AllModules)
(frame_system::Pallet::<System>, COnRuntimeUpgrade, AllPallets)
as
OnRuntimeUpgrade
>::pre_upgrade()?;
@@ -226,7 +226,7 @@ where
let weight = Self::execute_on_runtime_upgrade();
<
(frame_system::Module::<System>, COnRuntimeUpgrade, AllModules)
(frame_system::Pallet::<System>, COnRuntimeUpgrade, AllPallets)
as
OnRuntimeUpgrade
>::post_upgrade()?;
@@ -265,24 +265,24 @@ where
if Self::runtime_upgraded() {
weight = weight.saturating_add(Self::execute_on_runtime_upgrade());
}
<frame_system::Module<System>>::initialize(
<frame_system::Pallet<System>>::initialize(
block_number,
parent_hash,
digest,
frame_system::InitKind::Full,
);
weight = weight.saturating_add(
<frame_system::Module<System> as OnInitialize<System::BlockNumber>>::on_initialize(*block_number)
<frame_system::Pallet<System> as OnInitialize<System::BlockNumber>>::on_initialize(*block_number)
);
weight = weight.saturating_add(
<AllModules as OnInitialize<System::BlockNumber>>::on_initialize(*block_number)
<AllPallets as OnInitialize<System::BlockNumber>>::on_initialize(*block_number)
);
weight = weight.saturating_add(
<System::BlockWeights as frame_support::traits::Get<_>>::get().base_block
);
<frame_system::Module::<System>>::register_extra_weight_unchecked(weight, DispatchClass::Mandatory);
<frame_system::Pallet::<System>>::register_extra_weight_unchecked(weight, DispatchClass::Mandatory);
frame_system::Module::<System>::note_finished_initialize();
frame_system::Pallet::<System>::note_finished_initialize();
}
/// Returns if the runtime was upgraded since the last time this function was called.
@@ -308,7 +308,7 @@ where
let n = header.number().clone();
assert!(
n > System::BlockNumber::zero()
&& <frame_system::Module<System>>::block_hash(n - System::BlockNumber::one()) == *header.parent_hash(),
&& <frame_system::Pallet<System>>::block_hash(n - System::BlockNumber::one()) == *header.parent_hash(),
"Parent hash should be valid.",
);
}
@@ -350,7 +350,7 @@ where
});
// post-extrinsics book-keeping
<frame_system::Module<System>>::note_finished_extrinsics();
<frame_system::Pallet<System>>::note_finished_extrinsics();
Self::idle_and_finalize_hook(block_number);
}
@@ -360,36 +360,36 @@ where
pub fn finalize_block() -> System::Header {
sp_io::init_tracing();
sp_tracing::enter_span!( sp_tracing::Level::TRACE, "finalize_block" );
<frame_system::Module<System>>::note_finished_extrinsics();
let block_number = <frame_system::Module<System>>::block_number();
<frame_system::Pallet<System>>::note_finished_extrinsics();
let block_number = <frame_system::Pallet<System>>::block_number();
Self::idle_and_finalize_hook(block_number);
<frame_system::Module<System>>::finalize()
<frame_system::Pallet<System>>::finalize()
}
fn idle_and_finalize_hook(block_number: NumberFor<Block>) {
let weight = <frame_system::Module<System>>::block_weight();
let weight = <frame_system::Pallet<System>>::block_weight();
let max_weight = <System::BlockWeights as frame_support::traits::Get<_>>::get().max_block;
let mut remaining_weight = max_weight.saturating_sub(weight.total());
if remaining_weight > 0 {
let mut used_weight =
<frame_system::Module<System> as OnIdle<System::BlockNumber>>::on_idle(
<frame_system::Pallet<System> as OnIdle<System::BlockNumber>>::on_idle(
block_number,
remaining_weight
);
remaining_weight = remaining_weight.saturating_sub(used_weight);
used_weight = <AllModules as OnIdle<System::BlockNumber>>::on_idle(
used_weight = <AllPallets as OnIdle<System::BlockNumber>>::on_idle(
block_number,
remaining_weight
)
.saturating_add(used_weight);
<frame_system::Module::<System>>::register_extra_weight_unchecked(used_weight, DispatchClass::Mandatory);
<frame_system::Pallet::<System>>::register_extra_weight_unchecked(used_weight, DispatchClass::Mandatory);
}
<frame_system::Module<System> as OnFinalize<System::BlockNumber>>::on_finalize(block_number);
<AllModules as OnFinalize<System::BlockNumber>>::on_finalize(block_number);
<frame_system::Pallet<System> as OnFinalize<System::BlockNumber>>::on_finalize(block_number);
<AllPallets as OnFinalize<System::BlockNumber>>::on_finalize(block_number);
}
/// Apply extrinsic outside of the block execution function.
@@ -419,7 +419,7 @@ where
// We don't need to make sure to `note_extrinsic` only after we know it's going to be
// executed to prevent it from leaking in storage since at this point, it will either
// execute or panic (and revert storage changes).
<frame_system::Module<System>>::note_extrinsic(to_note);
<frame_system::Pallet<System>>::note_extrinsic(to_note);
// AUDIT: Under no circumstances may this function panic from here onwards.
@@ -427,7 +427,7 @@ where
let dispatch_info = xt.get_dispatch_info();
let r = Applyable::apply::<UnsignedValidator>(xt, &dispatch_info, encoded_len)?;
<frame_system::Module<System>>::note_applied_extrinsic(&r, dispatch_info);
<frame_system::Pallet<System>>::note_applied_extrinsic(&r, dispatch_info);
Ok(r.map(|_| ()).map_err(|e| e.error))
}
@@ -435,7 +435,7 @@ where
fn final_checks(header: &System::Header) {
sp_tracing::enter_span!(sp_tracing::Level::TRACE, "final_checks");
// remove temporaries
let new_header = <frame_system::Module<System>>::finalize();
let new_header = <frame_system::Pallet<System>>::finalize();
// check digest
assert_eq!(
@@ -499,7 +499,7 @@ where
// OffchainWorker RuntimeApi should skip initialization.
let digests = header.digest().clone();
<frame_system::Module<System>>::initialize(
<frame_system::Pallet<System>>::initialize(
header.number(),
header.parent_hash(),
&digests,
@@ -511,7 +511,7 @@ where
// as well.
frame_system::BlockHash::<System>::insert(header.number(), header.hash());
<AllModules as OffchainWorker<System::BlockNumber>>::offchain_worker(*header.number())
<AllPallets as OffchainWorker<System::BlockNumber>>::offchain_worker(*header.number())
}
}
@@ -628,9 +628,9 @@ mod tests {
NodeBlock = TestBlock,
UncheckedExtrinsic = TestUncheckedExtrinsic
{
System: frame_system::{Module, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
Custom: custom::{Module, Call, ValidateUnsigned},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Custom: custom::{Pallet, Call, ValidateUnsigned},
}
);
@@ -741,7 +741,7 @@ mod tests {
Block<TestXt>,
ChainContext<Runtime>,
Runtime,
AllModules,
AllPallets,
CustomOnRuntimeUpgrade
>;
@@ -780,8 +780,8 @@ mod tests {
));
let r = Executive::apply_extrinsic(xt);
assert!(r.is_ok());
assert_eq!(<pallet_balances::Module<Runtime>>::total_balance(&1), 142 - fee);
assert_eq!(<pallet_balances::Module<Runtime>>::total_balance(&2), 69);
assert_eq!(<pallet_balances::Pallet<Runtime>>::total_balance(&1), 142 - fee);
assert_eq!(<pallet_balances::Pallet<Runtime>>::total_balance(&2), 69);
});
}
@@ -857,7 +857,7 @@ mod tests {
Digest::default(),
));
assert!(Executive::apply_extrinsic(xt).is_err());
assert_eq!(<frame_system::Module<Runtime>>::extrinsic_index(), Some(0));
assert_eq!(<frame_system::Pallet<Runtime>>::extrinsic_index(), Some(0));
});
}
@@ -883,7 +883,7 @@ mod tests {
Digest::default(),
));
// Base block execution weight + `on_initialize` weight from the custom module.
assert_eq!(<frame_system::Module<Runtime>>::block_weight().total(), base_block_weight);
assert_eq!(<frame_system::Pallet<Runtime>>::block_weight().total(), base_block_weight);
for nonce in 0..=num_to_exhaust_block {
let xt = TestXt::new(
@@ -893,11 +893,11 @@ mod tests {
if nonce != num_to_exhaust_block {
assert!(res.is_ok());
assert_eq!(
<frame_system::Module<Runtime>>::block_weight().total(),
<frame_system::Pallet<Runtime>>::block_weight().total(),
//--------------------- on_initialize + block_execution + extrinsic_base weight
(encoded_len + 5) * (nonce + 1) + base_block_weight,
);
assert_eq!(<frame_system::Module<Runtime>>::extrinsic_index(), Some(nonce as u32 + 1));
assert_eq!(<frame_system::Pallet<Runtime>>::extrinsic_index(), Some(nonce as u32 + 1));
} else {
assert_eq!(res, Err(InvalidTransaction::ExhaustsResources.into()));
}
@@ -924,8 +924,8 @@ mod tests {
Digest::default(),
));
assert_eq!(<frame_system::Module<Runtime>>::block_weight().total(), base_block_weight);
assert_eq!(<frame_system::Module<Runtime>>::all_extrinsics_len(), 0);
assert_eq!(<frame_system::Pallet<Runtime>>::block_weight().total(), base_block_weight);
assert_eq!(<frame_system::Pallet<Runtime>>::all_extrinsics_len(), 0);
assert!(Executive::apply_extrinsic(xt.clone()).unwrap().is_ok());
assert!(Executive::apply_extrinsic(x1.clone()).unwrap().is_ok());
@@ -935,14 +935,14 @@ mod tests {
let extrinsic_weight = len as Weight + <Runtime as frame_system::Config>::BlockWeights
::get().get(DispatchClass::Normal).base_extrinsic;
assert_eq!(
<frame_system::Module<Runtime>>::block_weight().total(),
<frame_system::Pallet<Runtime>>::block_weight().total(),
base_block_weight + 3 * extrinsic_weight,
);
assert_eq!(<frame_system::Module<Runtime>>::all_extrinsics_len(), 3 * len);
assert_eq!(<frame_system::Pallet<Runtime>>::all_extrinsics_len(), 3 * len);
let _ = <frame_system::Module<Runtime>>::finalize();
let _ = <frame_system::Pallet<Runtime>>::finalize();
// All extrinsics length cleaned on `System::finalize`
assert_eq!(<frame_system::Module<Runtime>>::all_extrinsics_len(), 0);
assert_eq!(<frame_system::Pallet<Runtime>>::all_extrinsics_len(), 0);
// New Block
Executive::initialize_block(&Header::new(
@@ -954,7 +954,7 @@ mod tests {
));
// Block weight cleaned up on `System::initialize`
assert_eq!(<frame_system::Module<Runtime>>::block_weight().total(), base_block_weight);
assert_eq!(<frame_system::Pallet<Runtime>>::block_weight().total(), base_block_weight);
});
}
@@ -989,7 +989,7 @@ mod tests {
let execute_with_lock = |lock: WithdrawReasons| {
let mut t = new_test_ext(1);
t.execute_with(|| {
<pallet_balances::Module<Runtime> as LockableCurrency<Balance>>::set_lock(
<pallet_balances::Pallet<Runtime> as LockableCurrency<Balance>>::set_lock(
id,
&1,
110,
@@ -1017,13 +1017,13 @@ mod tests {
if lock == WithdrawReasons::except(WithdrawReasons::TRANSACTION_PAYMENT) {
assert!(Executive::apply_extrinsic(xt).unwrap().is_ok());
// tx fee has been deducted.
assert_eq!(<pallet_balances::Module<Runtime>>::total_balance(&1), 111 - fee);
assert_eq!(<pallet_balances::Pallet<Runtime>>::total_balance(&1), 111 - fee);
} else {
assert_eq!(
Executive::apply_extrinsic(xt),
Err(InvalidTransaction::Payment.into()),
);
assert_eq!(<pallet_balances::Module<Runtime>>::total_balance(&1), 111);
assert_eq!(<pallet_balances::Pallet<Runtime>>::total_balance(&1), 111);
}
});
};
@@ -1041,7 +1041,7 @@ mod tests {
// NOTE: might need updates over time if new weights are introduced.
// For now it only accounts for the base block execution weight and
// the `on_initialize` weight defined in the custom test module.
assert_eq!(<frame_system::Module<Runtime>>::block_weight().total(), 175 + 175 + 10);
assert_eq!(<frame_system::Pallet<Runtime>>::block_weight().total(), 175 + 175 + 10);
})
}
@@ -1159,16 +1159,16 @@ mod tests {
));
// All weights that show up in the `initialize_block_impl`
let frame_system_upgrade_weight = frame_system::Module::<Runtime>::on_runtime_upgrade();
let frame_system_upgrade_weight = frame_system::Pallet::<Runtime>::on_runtime_upgrade();
let custom_runtime_upgrade_weight = CustomOnRuntimeUpgrade::on_runtime_upgrade();
let runtime_upgrade_weight = <AllModules as OnRuntimeUpgrade>::on_runtime_upgrade();
let frame_system_on_initialize_weight = frame_system::Module::<Runtime>::on_initialize(block_number);
let on_initialize_weight = <AllModules as OnInitialize<u64>>::on_initialize(block_number);
let runtime_upgrade_weight = <AllPallets as OnRuntimeUpgrade>::on_runtime_upgrade();
let frame_system_on_initialize_weight = frame_system::Pallet::<Runtime>::on_initialize(block_number);
let on_initialize_weight = <AllPallets as OnInitialize<u64>>::on_initialize(block_number);
let base_block_weight = <Runtime as frame_system::Config>::BlockWeights::get().base_block;
// Weights are recorded correctly
assert_eq!(
frame_system::Module::<Runtime>::block_weight().total(),
frame_system::Pallet::<Runtime>::block_weight().total(),
frame_system_upgrade_weight +
custom_runtime_upgrade_weight +
runtime_upgrade_weight +
+2 -2
View File
@@ -446,7 +446,7 @@ pub mod pallet {
let gilt = Active::<T>::get(index).ok_or(Error::<T>::Unknown)?;
// If found, check the owner is `who`.
ensure!(gilt.who == who, Error::<T>::NotOwner);
let now = frame_system::Module::<T>::block_number();
let now = frame_system::Pallet::<T>::block_number();
ensure!(now >= gilt.expiry, Error::<T>::NotExpired);
// Remove it
Active::<T>::remove(index);
@@ -562,7 +562,7 @@ pub mod pallet {
let mut remaining = amount;
let mut bids_taken = 0;
let mut queues_hit = 0;
let now = frame_system::Module::<T>::block_number();
let now = frame_system::Pallet::<T>::block_number();
ActiveTotal::<T>::mutate(|totals| {
QueueTotals::<T>::mutate(|qs| {
+3 -3
View File
@@ -36,9 +36,9 @@ frame_support::construct_runtime!(
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Module, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Module, Call, Config<T>, Storage, Event<T>},
Gilt: pallet_gilt::{Module, Call, Config, Storage, Event<T>},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Config<T>, Storage, Event<T>},
Gilt: pallet_gilt::{Pallet, Call, Config, Storage, Event<T>},
}
);
+4 -4
View File
@@ -390,7 +390,7 @@ impl<T: Config> Module<T> {
/// Cannot be done when already paused.
pub fn schedule_pause(in_blocks: T::BlockNumber) -> DispatchResult {
if let StoredState::Live = <State<T>>::get() {
let scheduled_at = <frame_system::Module<T>>::block_number();
let scheduled_at = <frame_system::Pallet<T>>::block_number();
<State<T>>::put(StoredState::PendingPause {
delay: in_blocks,
scheduled_at,
@@ -405,7 +405,7 @@ impl<T: Config> Module<T> {
/// Schedule a resume of GRANDPA after pausing.
pub fn schedule_resume(in_blocks: T::BlockNumber) -> DispatchResult {
if let StoredState::Paused = <State<T>>::get() {
let scheduled_at = <frame_system::Module<T>>::block_number();
let scheduled_at = <frame_system::Pallet<T>>::block_number();
<State<T>>::put(StoredState::PendingResume {
delay: in_blocks,
scheduled_at,
@@ -437,7 +437,7 @@ impl<T: Config> Module<T> {
forced: Option<T::BlockNumber>,
) -> DispatchResult {
if !<PendingChange<T>>::exists() {
let scheduled_at = <frame_system::Module<T>>::block_number();
let scheduled_at = <frame_system::Pallet<T>>::block_number();
if let Some(_) = forced {
if Self::next_forced().map_or(false, |next| next > scheduled_at) {
@@ -465,7 +465,7 @@ impl<T: Config> Module<T> {
/// Deposit one of this module's logs.
fn deposit_log(log: ConsensusLog<T::BlockNumber>) {
let log: DigestItem<T::Hash> = DigestItem::Consensus(GRANDPA_ENGINE_ID, log.encode());
<frame_system::Module<T>>::deposit_log(log.into());
<frame_system::Pallet<T>>::deposit_log(log.into());
}
// Perform module initialization, abstracted so that it can be called either through genesis
+9 -9
View File
@@ -51,14 +51,14 @@ frame_support::construct_runtime!(
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Module, Call, Config, Storage, Event<T>},
Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
Staking: pallet_staking::{Module, Call, Config<T>, Storage, Event<T>, ValidateUnsigned},
Session: pallet_session::{Module, Call, Storage, Event, Config<T>},
Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event, ValidateUnsigned},
Offences: pallet_offences::{Module, Call, Storage, Event},
Historical: pallet_session_historical::{Module},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Staking: pallet_staking::{Pallet, Call, Config<T>, Storage, Event<T>, ValidateUnsigned},
Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>},
Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event, ValidateUnsigned},
Offences: pallet_offences::{Pallet, Call, Storage, Event},
Historical: pallet_session_historical::{Pallet},
}
);
@@ -210,7 +210,7 @@ impl pallet_staking::Config for Test {
type SlashDeferDuration = SlashDeferDuration;
type SlashCancelOrigin = frame_system::EnsureRoot<Self::AccountId>;
type SessionInterface = Self;
type UnixTime = pallet_timestamp::Module<Test>;
type UnixTime = pallet_timestamp::Pallet<Test>;
type EraPayout = pallet_staking::ConvertCurve<RewardCurve>;
type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
type NextNewSession = Session;
+2 -2
View File
@@ -25,12 +25,12 @@ use frame_system::{EventRecord, RawOrigin};
use frame_benchmarking::{benchmarks, account, whitelisted_caller, impl_benchmark_test_suite};
use sp_runtime::traits::Bounded;
use crate::Module as Identity;
use crate::Pallet as Identity;
const SEED: u32 = 0;
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 EventRecord { event, .. } = &events[events.len() - 1];
+3 -3
View File
@@ -37,9 +37,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>},
Identity: pallet_identity::{Module, Call, Storage, Event<T>},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Identity: pallet_identity::{Pallet, Call, Storage, Event<T>},
}
);
+1 -1
View File
@@ -668,7 +668,7 @@ impl<T: Config> OneSessionHandler<T::AccountId> for Module<T> {
// Tell the offchain worker to start making the next session's heartbeats.
// Since we consider producing blocks as being online,
// the heartbeat is deferred a bit to prevent spamming.
let block_number = <frame_system::Module<T>>::block_number();
let block_number = <frame_system::Pallet<T>>::block_number();
let half_session = T::NextSessionRotation::average_session_length() / 2u32.into();
<HeartbeatAfter<T>>::put(block_number + half_session);
+4 -4
View File
@@ -44,10 +44,10 @@ frame_support::construct_runtime!(
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Module, Call, Config, Storage, Event<T>},
Session: pallet_session::{Module, Call, Storage, Event, Config<T>},
ImOnline: imonline::{Module, Call, Storage, Config<T>, Event<T>},
Historical: pallet_session_historical::{Module},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>},
ImOnline: imonline::{Pallet, Call, Storage, Config<T>, Event<T>},
Historical: pallet_session_historical::{Pallet},
}
);
+3 -3
View File
@@ -33,9 +33,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>},
Indices: pallet_indices::{Module, Call, Storage, Config<T>, Event<T>},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Indices: pallet_indices::{Pallet, Call, Storage, Config<T>, Event<T>},
}
);
+2 -2
View File
@@ -277,7 +277,7 @@ decl_module! {
ensure!(lottery.is_none(), Error::<T>::InProgress);
let index = LotteryIndex::get();
let new_index = index.checked_add(1).ok_or(Error::<T>::Overflow)?;
let start = frame_system::Module::<T>::block_number();
let start = frame_system::Pallet::<T>::block_number();
// Use new_index to more easily track everything with the current state.
*lottery = Some(LotteryConfig {
price,
@@ -392,7 +392,7 @@ impl<T: Config> Module<T> {
fn do_buy_ticket(caller: &T::AccountId, call: &<T as Config>::Call) -> DispatchResult {
// Check the call is valid lottery
let config = Lottery::<T>::get().ok_or(Error::<T>::NotConfigured)?;
let block_number = frame_system::Module::<T>::block_number();
let block_number = frame_system::Pallet::<T>::block_number();
ensure!(block_number < config.start.saturating_add(config.length), Error::<T>::AlreadyEnded);
ensure!(T::ValidateCall::validate_call(call), Error::<T>::InvalidCall);
let call_index = Self::call_to_index(call)?;
+3 -3
View File
@@ -42,9 +42,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>},
Lottery: pallet_lottery::{Module, Call, Storage, Event<T>},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Lottery: pallet_lottery::{Pallet, Call, Storage, Event<T>},
}
);
+2 -2
View File
@@ -293,8 +293,8 @@ mod tests {
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Module, Call, Config, Storage, Event<T>},
Membership: pallet_membership::{Module, Call, Storage, Config<T>, Event<T>},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Membership: pallet_membership::{Pallet, Call, Storage, Config<T>, Event<T>},
}
);
@@ -51,10 +51,10 @@ impl LeafDataProvider for () {
/// so that any point in time in the future we can receive a proof about some past
/// blocks without using excessive on-chain storage.
///
/// Hence we implement the [LeafDataProvider] for [frame_system::Module]. Since the
/// Hence we implement the [LeafDataProvider] for [frame_system::Pallet]. Since the
/// current block hash is not available (since the block is not finished yet),
/// we use the `parent_hash` here along with parent block number.
impl<T: frame_system::Config> LeafDataProvider for frame_system::Module<T> {
impl<T: frame_system::Config> LeafDataProvider for frame_system::Pallet<T> {
type LeafData = (
<T as frame_system::Config>::BlockNumber,
<T as frame_system::Config>::Hash
@@ -40,8 +40,8 @@ frame_support::construct_runtime!(
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Module, Call, Config, Storage, Event<T>},
MMR: pallet_mmr::{Module, Call, Storage},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
MMR: pallet_mmr::{Pallet, Call, Storage},
}
);
@@ -78,7 +78,7 @@ impl Config for Test {
type Hashing = Keccak256;
type Hash = H256;
type LeafData = Compact<Keccak256, (frame_system::Module<Test>, LeafData)>;
type LeafData = Compact<Keccak256, (frame_system::Pallet<Test>, LeafData)>;
type OnNewRoot = ();
type WeightInfo = ();
}
@@ -39,11 +39,11 @@ fn register_offchain_ext(ext: &mut sp_io::TestExternalities) {
}
fn new_block() -> u64 {
let number = frame_system::Module::<Test>::block_number() + 1;
let number = frame_system::Pallet::<Test>::block_number() + 1;
let hash = H256::repeat_byte(number as u8);
LEAF_DATA.with(|r| r.borrow_mut().a = number);
frame_system::Module::<Test>::initialize(
frame_system::Pallet::<Test>::initialize(
&number,
&hash,
&Default::default(),
+2 -2
View File
@@ -638,8 +638,8 @@ impl<T: Config> Module<T> {
/// The current `Timepoint`.
pub fn timepoint() -> Timepoint<T::BlockNumber> {
Timepoint {
height: <system::Module<T>>::block_number(),
index: <system::Module<T>>::extrinsic_index().unwrap_or_default(),
height: <system::Pallet<T>>::block_number(),
index: <system::Pallet<T>>::extrinsic_index().unwrap_or_default(),
}
}
+4 -4
View File
@@ -37,9 +37,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>},
Multisig: pallet_multisig::{Module, Call, Storage, Event<T>},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Multisig: pallet_multisig::{Pallet, Call, Storage, Event<T>},
}
);
@@ -124,7 +124,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities {
}
fn last_event() -> Event {
system::Module::<Test>::events().pop().map(|e| e.event).expect("Event expected")
system::Pallet::<Test>::events().pop().map(|e| e.event).expect("Event expected")
}
fn expect_event<E: Into<Event>>(e: E) {
+3 -3
View File
@@ -257,9 +257,9 @@ mod tests {
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Module, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
Nicks: pallet_nicks::{Module, Call, Storage, Event<T>},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Nicks: pallet_nicks::{Pallet, Call, Storage, Event<T>},
}
);
@@ -37,9 +37,9 @@ frame_support::construct_runtime!(
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Module, Call, Config, Storage, Event<T>},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
NodeAuthorization: pallet_node_authorization::{
Module, Call, Storage, Config<T>, Event<T>,
Pallet, Call, Storage, Config<T>, Event<T>,
},
}
);
@@ -356,7 +356,7 @@ fn get_authorized_nodes_works() {
BTreeSet::from_iter(vec![test_node(5), test_node(15), test_node(25)])
);
let mut authorized_nodes = Module::<Test>::get_authorized_nodes(&test_node(20));
let mut authorized_nodes = Pallet::<Test>::get_authorized_nodes(&test_node(20));
authorized_nodes.sort();
assert_eq!(
authorized_nodes,
@@ -24,7 +24,7 @@ mod mock;
use sp_std::prelude::*;
use sp_std::vec;
use frame_system::{RawOrigin, Module as System, Config as SystemConfig};
use frame_system::{RawOrigin, Pallet as System, Config as SystemConfig};
use frame_benchmarking::{benchmarks, account, impl_benchmark_test_suite};
use frame_support::traits::{Currency, OnInitialize, ValidatorSet, ValidatorSetWithIdentification};
@@ -50,7 +50,7 @@ const MAX_OFFENDERS: u32 = 100;
const MAX_NOMINATORS: u32 = 100;
const MAX_DEFERRED_OFFENCES: u32 = 100;
pub struct Module<T: Config>(Offences<T>);
pub struct Pallet<T: Config>(Offences<T>);
pub trait Config:
SessionConfig
@@ -421,7 +421,7 @@ benchmarks! {
}
impl_benchmark_test_suite!(
Module,
Pallet,
crate::mock::new_test_ext(),
crate::mock::Test,
);
@@ -159,7 +159,7 @@ impl onchain::Config for Test {
impl pallet_staking::Config for Test {
type Currency = Balances;
type UnixTime = pallet_timestamp::Module<Self>;
type UnixTime = pallet_timestamp::Pallet<Self>;
type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote;
type RewardRemainder = ();
type Event = Event;
@@ -220,13 +220,13 @@ frame_support::construct_runtime!(
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic
{
System: system::{Module, Call, Event<T>},
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
Staking: pallet_staking::{Module, Call, Config<T>, Storage, Event<T>, ValidateUnsigned},
Session: pallet_session::{Module, Call, Storage, Event, Config<T>},
ImOnline: pallet_im_online::{Module, Call, Storage, Event<T>, ValidateUnsigned, Config<T>},
Offences: pallet_offences::{Module, Call, Storage, Event},
Historical: pallet_session_historical::{Module},
System: system::{Pallet, Call, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Staking: pallet_staking::{Pallet, Call, Config<T>, Storage, Event<T>, ValidateUnsigned},
Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>},
ImOnline: pallet_im_online::{Pallet, Call, Storage, Event<T>, ValidateUnsigned, Config<T>},
Offences: pallet_offences::{Pallet, Call, Storage, Event},
Historical: pallet_session_historical::{Pallet},
}
);
+2 -2
View File
@@ -91,8 +91,8 @@ frame_support::construct_runtime!(
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Module, Call, Config, Storage, Event<T>},
Offences: offences::{Module, Call, Storage, Event},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Offences: offences::{Pallet, Call, Storage, Event},
}
);
+7 -7
View File
@@ -23,12 +23,12 @@ use super::*;
use frame_system::{RawOrigin, EventRecord};
use frame_benchmarking::{benchmarks, account, whitelisted_caller, impl_benchmark_test_suite};
use sp_runtime::traits::Bounded;
use crate::Module as Proxy;
use crate::Pallet as Proxy;
const SEED: u32 = 0;
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 EventRecord { event, .. } = &events[events.len() - 1];
@@ -219,7 +219,7 @@ benchmarks! {
0
)
verify {
let anon_account = Module::<T>::anonymous_account(&caller, &T::ProxyType::default(), 0, None);
let anon_account = Pallet::<T>::anonymous_account(&caller, &T::ProxyType::default(), 0, None);
assert_last_event::<T>(Event::AnonymousCreated(
anon_account,
caller,
@@ -233,15 +233,15 @@ benchmarks! {
let caller: T::AccountId = whitelisted_caller();
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
Module::<T>::anonymous(
Pallet::<T>::anonymous(
RawOrigin::Signed(whitelisted_caller()).into(),
T::ProxyType::default(),
T::BlockNumber::zero(),
0
)?;
let height = system::Module::<T>::block_number();
let ext_index = system::Module::<T>::extrinsic_index().unwrap_or(0);
let anon = Module::<T>::anonymous_account(&caller, &T::ProxyType::default(), 0, None);
let height = system::Pallet::<T>::block_number();
let ext_index = system::Pallet::<T>::extrinsic_index().unwrap_or(0);
let anon = Pallet::<T>::anonymous_account(&caller, &T::ProxyType::default(), 0, None);
add_proxies::<T>(p, Some(anon.clone()))?;
ensure!(Proxies::<T>::contains_key(&anon), "anon proxy not created");
+5 -5
View File
@@ -394,7 +394,7 @@ pub mod pallet {
let announcement = Announcement {
real: real.clone(),
call_hash: call_hash.clone(),
height: system::Module::<T>::block_number(),
height: system::Pallet::<T>::block_number(),
};
Announcements::<T>::try_mutate(&who, |(ref mut pending, ref mut deposit)| {
@@ -510,7 +510,7 @@ pub mod pallet {
let def = Self::find_proxy(&real, &delegate, force_proxy_type)?;
let call_hash = T::CallHasher::hash_of(&call);
let now = system::Module::<T>::block_number();
let now = system::Pallet::<T>::block_number();
Self::edit_announcements(&delegate, |ann|
ann.real != real || ann.call_hash != call_hash || now.saturating_sub(ann.height) < def.delay
).map_err(|_| Error::<T>::Unannounced)?;
@@ -584,7 +584,7 @@ pub mod pallet {
}
impl<T: Config> Module<T> {
impl<T: Config> Pallet<T> {
/// Calculate the address of an anonymous account.
///
@@ -604,8 +604,8 @@ impl<T: Config> Module<T> {
maybe_when: Option<(T::BlockNumber, u32)>,
) -> T::AccountId {
let (height, ext_index) = maybe_when.unwrap_or_else(|| (
system::Module::<T>::block_number(),
system::Module::<T>::extrinsic_index().unwrap_or_default()
system::Pallet::<T>::block_number(),
system::Pallet::<T>::extrinsic_index().unwrap_or_default()
));
let entropy = (b"modlpy/proxy____", who, height, ext_index, proxy_type, index)
.using_encoded(blake2_256);
+8 -8
View File
@@ -38,10 +38,10 @@ 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>},
Proxy: proxy::{Module, Call, Storage, Event<T>},
Utility: pallet_utility::{Module, Call, Event},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Proxy: proxy::{Pallet, Call, Storage, Event<T>},
Utility: pallet_utility::{Pallet, Call, Event},
}
);
@@ -164,7 +164,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities {
}
fn last_event() -> Event {
system::Module::<Test>::events().pop().expect("Event expected").event
system::Pallet::<Test>::events().pop().expect("Event expected").event
}
fn expect_event<E: Into<Event>>(e: E) {
@@ -172,7 +172,7 @@ fn expect_event<E: Into<Event>>(e: E) {
}
fn last_events(n: usize) -> Vec<Event> {
system::Module::<Test>::events().into_iter().rev().take(n).rev().map(|e| e.event).collect()
system::Pallet::<Test>::events().into_iter().rev().take(n).rev().map(|e| e.event).collect()
}
fn expect_events(e: Vec<Event>) {
@@ -271,7 +271,7 @@ fn delayed_requires_pre_announcement() {
assert_noop!(Proxy::proxy_announced(Origin::signed(0), 2, 1, None, call.clone()), e);
let call_hash = BlakeTwo256::hash_of(&call);
assert_ok!(Proxy::announce(Origin::signed(2), 1, call_hash));
system::Module::<Test>::set_block_number(2);
system::Pallet::<Test>::set_block_number(2);
assert_ok!(Proxy::proxy_announced(Origin::signed(0), 2, 1, None, call.clone()));
});
}
@@ -289,7 +289,7 @@ fn proxy_announced_removes_announcement_and_returns_deposit() {
let e = Error::<Test>::Unannounced;
assert_noop!(Proxy::proxy_announced(Origin::signed(0), 3, 1, None, call.clone()), e);
system::Module::<Test>::set_block_number(2);
system::Pallet::<Test>::set_block_number(2);
assert_ok!(Proxy::proxy_announced(Origin::signed(0), 3, 1, None, call.clone()));
assert_eq!(Announcements::<Test>::get(3), (vec![Announcement {
real: 2,
@@ -76,7 +76,7 @@ fn block_number_to_index<T: Config>(block_number: T::BlockNumber) -> usize {
decl_module! {
pub struct Module<T: Config> for enum Call where origin: T::Origin {
fn on_initialize(block_number: T::BlockNumber) -> Weight {
let parent_hash = <frame_system::Module<T>>::parent_hash();
let parent_hash = <frame_system::Pallet<T>>::parent_hash();
<RandomMaterial<T>>::mutate(|ref mut values| if values.len() < RANDOM_MATERIAL_LEN as usize {
values.push(parent_hash)
@@ -111,7 +111,7 @@ impl<T: Config> Randomness<T::Hash, T::BlockNumber> for Module<T> {
/// and mean that all bits of the resulting value are entirely manipulatable by the author of
/// the parent block, who can determine the value of `parent_hash`.
fn random(subject: &[u8]) -> (T::Hash, T::BlockNumber) {
let block_number = <frame_system::Module<T>>::block_number();
let block_number = <frame_system::Pallet<T>>::block_number();
let index = block_number_to_index::<T>(block_number);
let hash_series = <RandomMaterial<T>>::get();
@@ -157,8 +157,8 @@ mod tests {
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Module, Call, Config, Storage, Event<T>},
CollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
CollectiveFlip: pallet_randomness_collective_flip::{Pallet, Call, Storage},
}
);
+4 -4
View File
@@ -496,7 +496,7 @@ decl_module! {
T::Currency::reserve(&who, recovery_deposit)?;
// Create an active recovery status
let recovery_status = ActiveRecovery {
created: <system::Module<T>>::block_number(),
created: <system::Pallet<T>>::block_number(),
deposit: recovery_deposit,
friends: vec![],
};
@@ -578,7 +578,7 @@ decl_module! {
let active_recovery = Self::active_recovery(&account, &who).ok_or(Error::<T>::NotStarted)?;
ensure!(!Proxy::<T>::contains_key(&who), Error::<T>::AlreadyProxy);
// Make sure the delay period has passed
let current_block_number = <system::Module<T>>::block_number();
let current_block_number = <system::Pallet<T>>::block_number();
let recoverable_block_number = active_recovery.created
.checked_add(&recovery_config.delay_period)
.ok_or(Error::<T>::Overflow)?;
@@ -588,7 +588,7 @@ decl_module! {
recovery_config.threshold as usize <= active_recovery.friends.len(),
Error::<T>::Threshold
);
system::Module::<T>::inc_consumers(&who).map_err(|_| Error::<T>::BadState)?;
system::Pallet::<T>::inc_consumers(&who).map_err(|_| Error::<T>::BadState)?;
// Create the recovery storage item
Proxy::<T>::insert(&who, &account);
Self::deposit_event(RawEvent::AccountRecovered(account, who));
@@ -677,7 +677,7 @@ decl_module! {
// Check `who` is allowed to make a call on behalf of `account`
ensure!(Self::proxy(&who) == Some(account), Error::<T>::NotAllowed);
Proxy::<T>::remove(&who);
system::Module::<T>::dec_consumers(&who);
system::Pallet::<T>::dec_consumers(&who);
}
}
}
+3 -3
View File
@@ -35,9 +35,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>},
Recovery: recovery::{Module, Call, Storage, Event<T>},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Recovery: recovery::{Pallet, Call, Storage, Event<T>},
}
);
@@ -26,7 +26,7 @@ use frame_support::{ensure, traits::OnInitialize};
use frame_benchmarking::{benchmarks, impl_benchmark_test_suite};
use crate::Module as Scheduler;
use frame_system::Module as System;
use frame_system::Pallet as System;
const BLOCK_NUMBER: u32 = 2;
+4 -4
View File
@@ -465,7 +465,7 @@ impl<T: Config> Module<T> {
}
fn resolve_time(when: DispatchTime<T::BlockNumber>) -> Result<T::BlockNumber, DispatchError> {
let now = frame_system::Module::<T>::block_number();
let now = frame_system::Pallet::<T>::block_number();
let when = match when {
DispatchTime::At(x) => x,
@@ -793,9 +793,9 @@ mod tests {
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Module, Call, Config, Storage, Event<T>},
Logger: logger::{Module, Call, Event},
Scheduler: scheduler::{Module, Call, Storage, Event<T>},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Logger: logger::{Pallet, Call, Event},
Scheduler: scheduler::{Pallet, Call, Storage, Event<T>},
}
);
+3 -3
View File
@@ -37,9 +37,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>},
ScoredPool: pallet_scored_pool::{Module, Call, Storage, Config<T>, Event<T>},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
ScoredPool: pallet_scored_pool::{Pallet, Call, Storage, Config<T>, Event<T>},
}
);
+2 -2
View File
@@ -24,8 +24,8 @@ use frame_support::{assert_ok, assert_noop, traits::OnInitialize};
use sp_runtime::traits::BadOrigin;
type ScoredPool = Module<Test>;
type System = frame_system::Module<Test>;
type Balances = pallet_balances::Module<Test>;
type System = frame_system::Pallet<Test>;
type Balances = pallet_balances::Pallet<Test>;
#[test]
fn query_membership_works() {
@@ -41,10 +41,10 @@ use sp_runtime::traits::{One, StaticLookup};
const MAX_VALIDATORS: u32 = 1000;
pub struct Module<T: Config>(pallet_session::Module<T>);
pub struct Pallet<T: Config>(pallet_session::Module<T>);
pub trait Config: pallet_session::Config + pallet_session::historical::Config + pallet_staking::Config {}
impl<T: Config> OnInitialize<T::BlockNumber> for Module<T> {
impl<T: Config> OnInitialize<T::BlockNumber> for Pallet<T> {
fn on_initialize(n: T::BlockNumber) -> frame_support::weights::Weight {
pallet_session::Module::<T>::on_initialize(n)
}
@@ -157,7 +157,7 @@ fn check_membership_proof_setup<T: Config>(
Session::<T>::set_keys(RawOrigin::Signed(controller).into(), keys, proof).unwrap();
}
Module::<T>::on_initialize(T::BlockNumber::one());
Pallet::<T>::on_initialize(T::BlockNumber::one());
// skip sessions until the new validator set is enacted
while Session::<T>::validators().len() < n as usize {
@@ -170,7 +170,7 @@ fn check_membership_proof_setup<T: Config>(
}
impl_benchmark_test_suite!(
Module,
Pallet,
crate::mock::new_test_ext(),
crate::mock::Test,
extra = false,
@@ -37,10 +37,10 @@ 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>},
Staking: pallet_staking::{Module, Call, Config<T>, Storage, Event<T>, ValidateUnsigned},
Session: pallet_session::{Module, Call, Storage, Event, Config<T>},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Staking: pallet_staking::{Pallet, Call, Config<T>, Storage, Event<T>, ValidateUnsigned},
Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>},
}
);
@@ -164,7 +164,7 @@ impl onchain::Config for Test {
impl pallet_staking::Config for Test {
type Currency = Balances;
type UnixTime = pallet_timestamp::Module<Self>;
type UnixTime = pallet_timestamp::Pallet<Self>;
type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote;
type RewardRemainder = ();
type Event = Event;
@@ -358,7 +358,7 @@ pub(crate) mod tests {
);
BasicExternalities::execute_with_storage(&mut t, || {
for (ref k, ..) in &keys {
frame_system::Module::<Test>::inc_providers(k);
frame_system::Pallet::<Test>::inc_providers(k);
}
});
crate::GenesisConfig::<Test> { keys }.assimilate_storage(&mut t).unwrap();
@@ -28,7 +28,7 @@
use sp_runtime::{offchain::storage::StorageValueRef, KeyTypeId};
use sp_session::MembershipProof;
use super::super::{Module as SessionModule, SessionIndex};
use super::super::{Pallet as SessionModule, SessionIndex};
use super::{IdentificationTuple, ProvingTrie, Config};
use super::shared;
@@ -167,7 +167,7 @@ mod tests {
);
BasicExternalities::execute_with_storage(&mut t, || {
for (ref k, ..) in &keys {
frame_system::Module::<Test>::inc_providers(k);
frame_system::Pallet::<Test>::inc_providers(k);
}
});
@@ -21,7 +21,7 @@ use codec::Encode;
use sp_runtime::traits::Convert;
use super::super::Config as SessionConfig;
use super::super::{Module as SessionModule, SessionIndex};
use super::super::{Pallet as SessionModule, SessionIndex};
use super::Config as HistoricalConfig;
use super::shared;
+4 -4
View File
@@ -442,7 +442,7 @@ decl_storage! {
for (account, val, keys) in config.keys.iter().cloned() {
<Module<T>>::inner_set_keys(&val, keys)
.expect("genesis config must not contain duplicates; qed");
assert!(frame_system::Module::<T>::inc_consumers(&account).is_ok());
assert!(frame_system::Pallet::<T>::inc_consumers(&account).is_ok());
}
let initial_validators_0 = T::SessionManager::new_session(0)
@@ -746,10 +746,10 @@ impl<T: Config> Module<T> {
let who = T::ValidatorIdOf::convert(account.clone())
.ok_or(Error::<T>::NoAssociatedValidatorId)?;
frame_system::Module::<T>::inc_consumers(&account).map_err(|_| Error::<T>::NoAccount)?;
frame_system::Pallet::<T>::inc_consumers(&account).map_err(|_| Error::<T>::NoAccount)?;
let old_keys = Self::inner_set_keys(&who, keys)?;
if old_keys.is_some() {
let _ = frame_system::Module::<T>::dec_consumers(&account);
let _ = frame_system::Pallet::<T>::dec_consumers(&account);
// ^^^ Defensive only; Consumers were incremented just before, so should never fail.
}
@@ -798,7 +798,7 @@ impl<T: Config> Module<T> {
let key_data = old_keys.get_raw(*id);
Self::clear_key_owner(*id, key_data);
}
frame_system::Module::<T>::dec_consumers(&account);
frame_system::Pallet::<T>::dec_consumers(&account);
Ok(())
}
+8 -8
View File
@@ -78,9 +78,9 @@ frame_support::construct_runtime!(
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Module, Call, Config, Storage, Event<T>},
Session: pallet_session::{Module, Call, Storage, Event, Config<T>},
Historical: pallet_session_historical::{Module},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>},
Historical: pallet_session_historical::{Pallet},
}
);
@@ -91,8 +91,8 @@ frame_support::construct_runtime!(
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Module, Call, Config, Storage, Event<T>},
Session: pallet_session::{Module, Call, Storage, Event, Config<T>},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>},
}
);
@@ -210,11 +210,11 @@ pub fn new_test_ext() -> sp_io::TestExternalities {
);
BasicExternalities::execute_with_storage(&mut t, || {
for (ref k, ..) in &keys {
frame_system::Module::<Test>::inc_providers(k);
frame_system::Pallet::<Test>::inc_providers(k);
}
frame_system::Module::<Test>::inc_providers(&4);
frame_system::Pallet::<Test>::inc_providers(&4);
// An additional identity that we use.
frame_system::Module::<Test>::inc_providers(&69);
frame_system::Pallet::<Test>::inc_providers(&69);
});
pallet_session::GenesisConfig::<Test> { keys }.assimilate_storage(&mut t).unwrap();
sp_io::TestExternalities::new(t)
+3 -3
View File
@@ -793,7 +793,7 @@ decl_module! {
let mut payouts = <Payouts<T, I>>::get(&who);
if let Some((when, amount)) = payouts.first() {
if when <= &<system::Module<T>>::block_number() {
if when <= &<system::Pallet<T>>::block_number() {
T::Currency::transfer(&Self::payouts(), &who, *amount, AllowDeath)?;
payouts.remove(0);
if payouts.is_empty() {
@@ -981,7 +981,7 @@ decl_module! {
// Reduce next pot by payout
<Pot<T, I>>::put(pot - value);
// Add payout for new candidate
let maturity = <system::Module<T>>::block_number()
let maturity = <system::Pallet<T>>::block_number()
+ Self::lock_duration(Self::members().len() as u32);
Self::pay_accepted_candidate(&who, value, kind, maturity);
}
@@ -1324,7 +1324,7 @@ impl<T: Config<I>, I: Instance> Module<T, I> {
// critical issues or side-effects. This is auto-correcting as members fall out of society.
members.reserve(candidates.len());
let maturity = <system::Module<T>>::block_number()
let maturity = <system::Pallet<T>>::block_number()
+ Self::lock_duration(members.len() as u32);
let mut rewardees = Vec::new();
+4 -4
View File
@@ -41,9 +41,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>},
Society: pallet_society::{Module, Call, Storage, Event<T>, Config<T>},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Society: pallet_society::{Pallet, Call, Storage, Event<T>, Config<T>},
}
);
@@ -104,7 +104,7 @@ impl pallet_balances::Config for Test {
impl Config for Test {
type Event = Event;
type Currency = pallet_balances::Module<Self>;
type Currency = pallet_balances::Pallet<Self>;
type Randomness = TestRandomness<Self>;
type CandidateDeposit = CandidateDeposit;
type WrongSideDeduction = WrongSideDeduction;
+6 -6
View File
@@ -33,11 +33,11 @@ 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>},
Staking: pallet_staking::{Module, Call, Config<T>, Storage, Event<T>, ValidateUnsigned},
Indices: pallet_indices::{Module, Call, Storage, Config<T>, Event<T>},
Session: pallet_session::{Module, Call, Storage, Event, Config<T>},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Staking: pallet_staking::{Pallet, Call, Config<T>, Storage, Event<T>, ValidateUnsigned},
Indices: pallet_indices::{Pallet, Call, Storage, Config<T>, Event<T>},
Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>},
}
);
@@ -174,7 +174,7 @@ impl frame_election_provider_support::ElectionProvider<AccountId, BlockNumber>
impl pallet_staking::Config for Test {
type Currency = Balances;
type UnixTime = pallet_timestamp::Module<Self>;
type UnixTime = pallet_timestamp::Pallet<Self>;
type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote;
type RewardRemainder = ();
type Event = Event;
+5 -5
View File
@@ -1552,7 +1552,7 @@ decl_module! {
Err(Error::<T>::InsufficientValue)?
}
system::Module::<T>::inc_consumers(&stash).map_err(|_| Error::<T>::BadState)?;
system::Pallet::<T>::inc_consumers(&stash).map_err(|_| Error::<T>::BadState)?;
// You're auto-bonded forever, here. We might improve this by only bonding when
// you actually validate/nominate and remove once you unbond __everything__.
@@ -3254,7 +3254,7 @@ impl<T: Config> Module<T> {
<Validators<T>>::remove(stash);
<Nominators<T>>::remove(stash);
system::Module::<T>::dec_consumers(stash);
system::Pallet::<T>::dec_consumers(stash);
Ok(())
}
@@ -3516,7 +3516,7 @@ impl<T: Config> pallet_session::SessionManager<T::AccountId> for Module<T> {
log!(
trace,
"[{:?}] planning new_session({})",
<frame_system::Module<T>>::block_number(),
<frame_system::Pallet<T>>::block_number(),
new_index,
);
CurrentPlannedSession::put(new_index);
@@ -3526,7 +3526,7 @@ impl<T: Config> pallet_session::SessionManager<T::AccountId> for Module<T> {
log!(
trace,
"[{:?}] starting start_session({})",
<frame_system::Module<T>>::block_number(),
<frame_system::Pallet<T>>::block_number(),
start_index,
);
Self::start_session(start_index)
@@ -3535,7 +3535,7 @@ impl<T: Config> pallet_session::SessionManager<T::AccountId> for Module<T> {
log!(
trace,
"[{:?}] ending end_session({})",
<frame_system::Module<T>>::block_number(),
<frame_system::Pallet<T>>::block_number(),
end_index,
);
Self::end_session(end_index)
+5 -5
View File
@@ -98,11 +98,11 @@ frame_support::construct_runtime!(
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Module, Call, Config, Storage, Event<T>},
Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
Staking: staking::{Module, Call, Config<T>, Storage, Event<T>, ValidateUnsigned},
Session: pallet_session::{Module, Call, Storage, Event, Config<T>},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Staking: staking::{Pallet, Call, Config<T>, Storage, Event<T>, ValidateUnsigned},
Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>},
}
);
+3 -3
View File
@@ -82,9 +82,9 @@ frame_support::construct_runtime!(
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Module, Call, Config, Storage, Event<T>},
Sudo: sudo::{Module, Call, Config<T>, Storage, Event<T>},
Logger: logger::{Module, Call, Storage, Event<T>},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Sudo: sudo::{Pallet, Call, Config<T>, Storage, Event<T>},
Logger: logger::{Pallet, Call, Storage, Event<T>},
}
);

Some files were not shown because too many files have changed in this diff Show More