From cfe81b80a881fb8d8f028960ad352a4d74013395 Mon Sep 17 00:00:00 2001 From: Shaun Wang Date: Wed, 24 Mar 2021 15:57:42 +1300 Subject: [PATCH 1/2] Fix mocks. --- auction/src/mock.rs | 4 ++-- authority/src/mock.rs | 6 +++--- benchmarking/src/tests.rs | 4 ++-- currencies/src/mock.rs | 8 ++++---- gradually-update/src/mock.rs | 5 ++--- nft/src/mock.rs | 4 ++-- oracle/src/mock.rs | 4 ++-- rewards/src/mock.rs | 4 ++-- tokens/src/mock.rs | 8 ++++---- unknown-tokens/src/mock.rs | 4 ++-- vesting/src/mock.rs | 6 +++--- 11 files changed, 28 insertions(+), 29 deletions(-) diff --git a/auction/src/mock.rs b/auction/src/mock.rs index ab409e6f0..25558c2eb 100644 --- a/auction/src/mock.rs +++ b/auction/src/mock.rs @@ -86,8 +86,8 @@ construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Storage, Config, Event}, - AuctionModule: auction::{Module, Storage, Call, Event}, + System: frame_system::{Pallet, Call, Storage, Config, Event}, + AuctionModule: auction::{Pallet, Storage, Call, Event}, } ); diff --git a/authority/src/mock.rs b/authority/src/mock.rs index a3f6fa02d..069f994a8 100644 --- a/authority/src/mock.rs +++ b/authority/src/mock.rs @@ -162,9 +162,9 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: frame_system::{Module, Call, Config, Event}, - Authority: authority::{Module, Call, Origin, Event}, - Scheduler: pallet_scheduler::{Module, Call, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Event}, + Authority: authority::{Pallet, Call, Origin, Event}, + Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event}, } ); diff --git a/benchmarking/src/tests.rs b/benchmarking/src/tests.rs index 2c015f329..5068c8146 100644 --- a/benchmarking/src/tests.rs +++ b/benchmarking/src/tests.rs @@ -97,8 +97,8 @@ construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Storage, Config, Event}, - Pallet: test::{Module, Call, Storage, Config}, + System: frame_system::{Pallet, Call, Storage, Config, Event}, + Pallet: test::{Pallet, Call, Storage, Config}, } ); diff --git a/currencies/src/mock.rs b/currencies/src/mock.rs index 621876964..a1fa4bcef 100644 --- a/currencies/src/mock.rs +++ b/currencies/src/mock.rs @@ -107,10 +107,10 @@ construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Storage, Config, Event}, - Currencies: currencies::{Module, Call, Event}, - Tokens: orml_tokens::{Module, Storage, Event, Config}, - PalletBalances: pallet_balances::{Module, Call, Storage, Config, Event}, + System: frame_system::{Pallet, Call, Storage, Config, Event}, + Currencies: currencies::{Pallet, Call, Event}, + Tokens: orml_tokens::{Pallet, Storage, Event, Config}, + PalletBalances: pallet_balances::{Pallet, Call, Storage, Config, Event}, } ); diff --git a/gradually-update/src/mock.rs b/gradually-update/src/mock.rs index 981492564..d837e6367 100644 --- a/gradually-update/src/mock.rs +++ b/gradually-update/src/mock.rs @@ -61,9 +61,8 @@ construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Storage, Config, Event}, - GraduallyUpdateModule: gradually_update::{Module, Storage, Call, Event}, - + System: frame_system::{Pallet, Call, Storage, Config, Event}, + GraduallyUpdateModule: gradually_update::{Pallet, Storage, Call, Event}, } ); diff --git a/nft/src/mock.rs b/nft/src/mock.rs index a8d1dae2a..cf4bac4f2 100644 --- a/nft/src/mock.rs +++ b/nft/src/mock.rs @@ -58,8 +58,8 @@ construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Storage, Config, Event}, - NonFungibleTokenModule: nft::{Module, Storage, Config}, + System: frame_system::{Pallet, Call, Storage, Config, Event}, + NonFungibleTokenModule: nft::{Pallet, Storage, Config}, } ); diff --git a/oracle/src/mock.rs b/oracle/src/mock.rs index b0173ac2b..c7ea7487f 100644 --- a/oracle/src/mock.rs +++ b/oracle/src/mock.rs @@ -92,8 +92,8 @@ construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Storage, Config, Event}, - ModuleOracle: oracle::{Module, Storage, Call, Config, Event}, + System: frame_system::{Pallet, Call, Storage, Config, Event}, + ModuleOracle: oracle::{Pallet, Storage, Call, Config, Event}, } ); diff --git a/rewards/src/mock.rs b/rewards/src/mock.rs index 1baf08c98..d088983b2 100644 --- a/rewards/src/mock.rs +++ b/rewards/src/mock.rs @@ -90,8 +90,8 @@ construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Storage, Config, Event}, - RewardsModule: rewards::{Module, Storage, Call}, + System: frame_system::{Pallet, Call, Storage, Config, Event}, + RewardsModule: rewards::{Pallet, Storage, Call}, } ); diff --git a/tokens/src/mock.rs b/tokens/src/mock.rs index a46a04667..bc430b16a 100644 --- a/tokens/src/mock.rs +++ b/tokens/src/mock.rs @@ -226,10 +226,10 @@ construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Storage, Config, Event}, - Tokens: tokens::{Module, Storage, Event, Config}, - Treasury: pallet_treasury::{Module, Call, Storage, Config, Event}, - ElectionsPhragmen: pallet_elections_phragmen::{Module, Call, Storage, Event}, + System: frame_system::{Pallet, Call, Storage, Config, Event}, + Tokens: tokens::{Pallet, Storage, Event, Config}, + Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event}, + ElectionsPhragmen: pallet_elections_phragmen::{Pallet, Call, Storage, Event}, } ); diff --git a/unknown-tokens/src/mock.rs b/unknown-tokens/src/mock.rs index ee1a68842..1a68d01c4 100644 --- a/unknown-tokens/src/mock.rs +++ b/unknown-tokens/src/mock.rs @@ -53,8 +53,8 @@ construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Storage, Config, Event}, - UnknownTokens: unknown_tokens::{Module, Storage, Event}, + System: frame_system::{Pallet, Call, Storage, Config, Event}, + UnknownTokens: unknown_tokens::{Pallet, Storage, Event}, } ); diff --git a/vesting/src/mock.rs b/vesting/src/mock.rs index 7274ef9c7..e3e28d787 100644 --- a/vesting/src/mock.rs +++ b/vesting/src/mock.rs @@ -92,9 +92,9 @@ construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Storage, Config, Event}, - Vesting: vesting::{Module, Storage, Call, Event, Config}, - PalletBalances: pallet_balances::{Module, Call, Storage, Config, Event}, + System: frame_system::{Pallet, Call, Storage, Config, Event}, + Vesting: vesting::{Pallet, Storage, Call, Event, Config}, + PalletBalances: pallet_balances::{Pallet, Call, Storage, Config, Event}, } ); From 7f53637941d188893badf484ef2638ad43cd255a Mon Sep 17 00:00:00 2001 From: Shaun Wang Date: Wed, 24 Mar 2021 16:59:28 +1300 Subject: [PATCH 2/2] Replace deprecated. --- auction/src/lib.rs | 2 +- authority/src/lib.rs | 6 +++--- benchmarking/src/lib.rs | 8 ++++---- currencies/src/mock.rs | 2 +- tokens/src/lib.rs | 8 ++++---- vesting/src/lib.rs | 2 +- vesting/src/mock.rs | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/auction/src/lib.rs b/auction/src/lib.rs index 115861bbf..65879960e 100644 --- a/auction/src/lib.rs +++ b/auction/src/lib.rs @@ -131,7 +131,7 @@ pub mod module { Auctions::::try_mutate_exists(id, |auction| -> DispatchResult { let mut auction = auction.as_mut().ok_or(Error::::AuctionNotExist)?; - let block_number = >::block_number(); + let block_number = >::block_number(); // make sure auction is started ensure!(block_number >= auction.start, Error::::AuctionNotStarted); diff --git a/authority/src/lib.rs b/authority/src/lib.rs index 01d45f920..6481a2c01 100644 --- a/authority/src/lib.rs +++ b/authority/src/lib.rs @@ -244,7 +244,7 @@ pub mod module { *id = id.checked_add(1).ok_or(Error::::Overflow)?; Ok(current_id) })?; - let now = frame_system::Module::::block_number(); + let now = frame_system::Pallet::::block_number(); let delay = match when { DispatchTime::At(x) => x.checked_sub(&now).ok_or(Error::::Overflow)?, DispatchTime::After(x) => x, @@ -283,7 +283,7 @@ pub mod module { task_id: ScheduleTaskIndex, when: DispatchTime, ) -> DispatchResultWithPostInfo { - let now = frame_system::Module::::block_number(); + let now = frame_system::Pallet::::block_number(); let new_delay = match when { DispatchTime::At(x) => x.checked_sub(&now).ok_or(Error::::Overflow)?, DispatchTime::After(x) => x, @@ -317,7 +317,7 @@ pub mod module { ) .map_err(|_| Error::::FailedToDelay)?; - let now = frame_system::Module::::block_number(); + let now = frame_system::Pallet::::block_number(); let dispatch_at = now.saturating_add(additional_delay); Self::deposit_event(Event::Delayed(initial_origin, task_id, dispatch_at)); diff --git a/benchmarking/src/lib.rs b/benchmarking/src/lib.rs index 71c6af4e7..75218e3e0 100644 --- a/benchmarking/src/lib.rs +++ b/benchmarking/src/lib.rs @@ -844,8 +844,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::<$runtime>::block_number()) { - frame_system::Module::<$runtime>::set_block_number(1u32.into()); + if $crate::Zero::is_zero(&frame_system::Pallet::<$runtime>::block_number()) { + frame_system::Pallet::<$runtime>::set_block_number(1u32.into()); } // Commit the externalities to the database, flushing the DB cache. @@ -990,8 +990,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::<$runtime>::block_number()) { - frame_system::Module::<$runtime>::set_block_number(1u32.into()); + if $crate::Zero::is_zero(&frame_system::Pallet::<$runtime>::block_number()) { + frame_system::Pallet::<$runtime>::set_block_number(1u32.into()); } // Run execution + verification diff --git a/currencies/src/mock.rs b/currencies/src/mock.rs index a1fa4bcef..a71a81f23 100644 --- a/currencies/src/mock.rs +++ b/currencies/src/mock.rs @@ -56,7 +56,7 @@ impl pallet_balances::Config for Runtime { type DustRemoval = (); type Event = Event; type ExistentialDeposit = ExistentialDeposit; - type AccountStore = frame_system::Module; + type AccountStore = frame_system::Pallet; type MaxLocks = (); type WeightInfo = (); } diff --git a/tokens/src/lib.rs b/tokens/src/lib.rs index 717698ff4..64ecb0f95 100644 --- a/tokens/src/lib.rs +++ b/tokens/src/lib.rs @@ -381,10 +381,10 @@ impl Pallet { // If existed before, decrease account provider. // Ignore the result, because if it failed means that these’s remain consumers, // and the account storage in frame_system shouldn't be repeaded. - let _ = frame_system::Module::::dec_providers(who); + let _ = frame_system::Pallet::::dec_providers(who); } else if !existed && exists { // if new, increase account provider - frame_system::Module::::inc_providers(who); + frame_system::Pallet::::inc_providers(who); } if let Some(dust_amount) = handle_dust { @@ -446,13 +446,13 @@ impl Pallet { >::remove(who, currency_id); if existed { // decrease account ref count when destruct lock - frame_system::Module::::dec_consumers(who); + frame_system::Pallet::::dec_consumers(who); } } else { >::insert(who, currency_id, locks); if !existed { // increase account ref count when initialize lock - if frame_system::Module::::inc_consumers(who).is_err() { + if frame_system::Pallet::::inc_consumers(who).is_err() { // No providers for the locks. This is impossible under normal circumstances // since the funds that are under the lock will themselves be stored in the // account and therefore will need a reference. diff --git a/vesting/src/lib.rs b/vesting/src/lib.rs index b314dfb0b..b913d0516 100644 --- a/vesting/src/lib.rs +++ b/vesting/src/lib.rs @@ -277,7 +277,7 @@ impl Pallet { /// Returns locked balance based on current block number. fn locked_balance(who: &T::AccountId) -> BalanceOf { - let now = >::block_number(); + let now = >::block_number(); >::mutate_exists(who, |maybe_schedules| { let total = if let Some(schedules) = maybe_schedules.as_mut() { let mut total: BalanceOf = Zero::zero(); diff --git a/vesting/src/mock.rs b/vesting/src/mock.rs index e3e28d787..c99f50059 100644 --- a/vesting/src/mock.rs +++ b/vesting/src/mock.rs @@ -52,7 +52,7 @@ impl pallet_balances::Config for Runtime { type DustRemoval = (); type Event = Event; type ExistentialDeposit = ExistentialDeposit; - type AccountStore = frame_system::Module; + type AccountStore = frame_system::Pallet; type MaxLocks = (); type WeightInfo = (); }