@@ -71,8 +71,8 @@ use frame_system::pallet_prelude::BlockNumberFor;
7171use scale_info:: TypeInfo ;
7272use sp_runtime:: {
7373 traits:: {
74- AtLeast32BitUnsigned , Bounded , Convert , MaybeSerializeDeserialize , One , Saturating ,
75- StaticLookup , Zero ,
74+ AtLeast32BitUnsigned , BlockNumberProvider , Bounded , Convert , MaybeSerializeDeserialize ,
75+ One , Saturating , StaticLookup , Zero ,
7676 } ,
7777 DispatchError , RuntimeDebug ,
7878} ;
@@ -176,6 +176,9 @@ pub mod pallet {
176176 /// the unvested amount.
177177 type UnvestedFundsAllowedWithdrawReasons : Get < WithdrawReasons > ;
178178
179+ /// Provider for the block number.
180+ type BlockNumberProvider : BlockNumberProvider < BlockNumber = BlockNumberFor < Self > > ;
181+
179182 /// Maximum number of vesting schedules an account may have at a given moment.
180183 const MAX_VESTING_SCHEDULES : u32 ;
181184 }
@@ -565,7 +568,7 @@ impl<T: Config> Pallet<T> {
565568 schedules : Vec < VestingInfo < BalanceOf < T > , BlockNumberFor < T > > > ,
566569 action : VestingAction ,
567570 ) -> ( Vec < VestingInfo < BalanceOf < T > , BlockNumberFor < T > > > , BalanceOf < T > ) {
568- let now = <frame_system :: Pallet < T > > :: block_number ( ) ;
571+ let now = T :: BlockNumberProvider :: current_block_number ( ) ;
569572
570573 let mut total_locked_now: BalanceOf < T > = Zero :: zero ( ) ;
571574 let filtered_schedules = action
@@ -649,7 +652,7 @@ impl<T: Config> Pallet<T> {
649652 let ( mut schedules, mut locked_now) =
650653 Self :: report_schedule_updates ( schedules. to_vec ( ) , action) ;
651654
652- let now = <frame_system :: Pallet < T > > :: block_number ( ) ;
655+ let now = T :: BlockNumberProvider :: current_block_number ( ) ;
653656 if let Some ( new_schedule) = Self :: merge_vesting_info ( now, schedule1, schedule2) {
654657 // Merging created a new schedule so we:
655658 // 1) need to add it to the accounts vesting schedule collection,
@@ -685,7 +688,7 @@ where
685688 /// Get the amount that is currently being vested and cannot be transferred out of this account.
686689 fn vesting_balance ( who : & T :: AccountId ) -> Option < BalanceOf < T > > {
687690 if let Some ( v) = Self :: vesting ( who) {
688- let now = <frame_system :: Pallet < T > > :: block_number ( ) ;
691+ let now = T :: BlockNumberProvider :: current_block_number ( ) ;
689692 let total_locked_now = v. iter ( ) . fold ( Zero :: zero ( ) , |total, schedule| {
690693 schedule. locked_at :: < T :: BlockNumberToBalance > ( now) . saturating_add ( total)
691694 } ) ;
0 commit comments