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
@@ -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;