@@ -106,7 +106,7 @@ use frame_support::{
106106 weights:: Weight ,
107107 BoundedVec , PalletId ,
108108} ;
109- use frame_system:: pallet_prelude:: BlockNumberFor ;
109+ use frame_system:: pallet_prelude:: BlockNumberFor as SystemBlockNumberFor ;
110110
111111pub use pallet:: * ;
112112pub use weights:: WeightInfo ;
@@ -122,6 +122,8 @@ pub type NegativeImbalanceOf<T, I = ()> = <<T as Config<I>>::Currency as Currenc
122122> >:: NegativeImbalance ;
123123type AccountIdLookupOf < T > = <<T as frame_system:: Config >:: Lookup as StaticLookup >:: Source ;
124124type BeneficiaryLookupOf < T , I > = <<T as Config < I > >:: BeneficiaryLookup as StaticLookup >:: Source ;
125+ pub type BlockNumberFor < T , I = ( ) > =
126+ <<T as Config < I > >:: BlockNumberProvider as BlockNumberProvider >:: BlockNumber ;
125127
126128/// A trait to allow the Treasury Pallet to spend it's funds for other purposes.
127129/// There is an expectation that the implementer of this trait will correctly manage
@@ -202,7 +204,7 @@ pub mod pallet {
202204 pallet_prelude:: * ,
203205 traits:: tokens:: { ConversionFromAssetBalance , PaymentStatus } ,
204206 } ;
205- use frame_system:: pallet_prelude:: * ;
207+ use frame_system:: pallet_prelude:: { ensure_signed , OriginFor } ;
206208
207209 #[ pallet:: pallet]
208210 pub struct Pallet < T , I = ( ) > ( PhantomData < ( T , I ) > ) ;
@@ -221,7 +223,7 @@ pub mod pallet {
221223
222224 /// Period between successive spends.
223225 #[ pallet:: constant]
224- type SpendPeriod : Get < BlockNumberFor < Self > > ;
226+ type SpendPeriod : Get < BlockNumberFor < Self , I > > ;
225227
226228 /// Percentage of spare funds (if any) that are burnt per spend period.
227229 #[ pallet:: constant]
@@ -277,14 +279,14 @@ pub mod pallet {
277279
278280 /// The period during which an approved treasury spend has to be claimed.
279281 #[ pallet:: constant]
280- type PayoutPeriod : Get < BlockNumberFor < Self > > ;
282+ type PayoutPeriod : Get < BlockNumberFor < Self , I > > ;
281283
282284 /// Helper type for benchmarks.
283285 #[ cfg( feature = "runtime-benchmarks" ) ]
284286 type BenchmarkHelper : ArgumentsFactory < Self :: AssetKind , Self :: Beneficiary > ;
285287
286288 /// Provider for the block number. Normally this is the `frame_system` pallet.
287- type BlockNumberProvider : BlockNumberProvider < BlockNumber = BlockNumberFor < Self > > ;
289+ type BlockNumberProvider : BlockNumberProvider ;
288290 }
289291
290292 /// DEPRECATED: associated with `spend_local` call and will be removed in May 2025.
@@ -335,15 +337,15 @@ pub mod pallet {
335337 T :: AssetKind ,
336338 AssetBalanceOf < T , I > ,
337339 T :: Beneficiary ,
338- BlockNumberFor < T > ,
340+ BlockNumberFor < T , I > ,
339341 <T :: Paymaster as Pay >:: Id ,
340342 > ,
341343 OptionQuery ,
342344 > ;
343345
344346 /// The blocknumber for the last triggered spend period.
345347 #[ pallet:: storage]
346- pub ( crate ) type LastSpendPeriod < T , I = ( ) > = StorageValue < _ , BlockNumberFor < T > , OptionQuery > ;
348+ pub ( crate ) type LastSpendPeriod < T , I = ( ) > = StorageValue < _ , BlockNumberFor < T , I > , OptionQuery > ;
347349
348350 #[ pallet:: genesis_config]
349351 #[ derive( frame_support:: DefaultNoBound ) ]
@@ -391,8 +393,8 @@ pub mod pallet {
391393 asset_kind : T :: AssetKind ,
392394 amount : AssetBalanceOf < T , I > ,
393395 beneficiary : T :: Beneficiary ,
394- valid_from : BlockNumberFor < T > ,
395- expire_at : BlockNumberFor < T > ,
396+ valid_from : BlockNumberFor < T , I > ,
397+ expire_at : BlockNumberFor < T , I > ,
396398 } ,
397399 /// An approved spend was voided.
398400 AssetSpendVoided { index : SpendIndex } ,
@@ -434,10 +436,10 @@ pub mod pallet {
434436 }
435437
436438 #[ pallet:: hooks]
437- impl < T : Config < I > , I : ' static > Hooks < BlockNumberFor < T > > for Pallet < T , I > {
439+ impl < T : Config < I > , I : ' static > Hooks < SystemBlockNumberFor < T > > for Pallet < T , I > {
438440 /// ## Complexity
439441 /// - `O(A)` where `A` is the number of approvals
440- fn on_initialize ( _do_not_use_local_block_number : BlockNumberFor < T > ) -> Weight {
442+ fn on_initialize ( _do_not_use_local_block_number : SystemBlockNumberFor < T > ) -> Weight {
441443 let block_number = T :: BlockNumberProvider :: current_block_number ( ) ;
442444 let pot = Self :: pot ( ) ;
443445 let deactivated = Deactivated :: < T , I > :: get ( ) ;
@@ -458,23 +460,23 @@ pub mod pallet {
458460 // empty.
459461 . unwrap_or_else ( || Self :: update_last_spend_period ( ) ) ;
460462 let blocks_since_last_spend_period = block_number. saturating_sub ( last_spend_period) ;
461- let safe_spend_period = T :: SpendPeriod :: get ( ) . max ( BlockNumberFor :: < T > :: one ( ) ) ;
463+ let safe_spend_period = T :: SpendPeriod :: get ( ) . max ( BlockNumberFor :: < T , I > :: one ( ) ) ;
462464
463465 // Safe because of `max(1)` above.
464466 let ( spend_periods_passed, extra_blocks) = (
465467 blocks_since_last_spend_period / safe_spend_period,
466468 blocks_since_last_spend_period % safe_spend_period,
467469 ) ;
468470 let new_last_spend_period = block_number. saturating_sub ( extra_blocks) ;
469- if spend_periods_passed > BlockNumberFor :: < T > :: zero ( ) {
471+ if spend_periods_passed > BlockNumberFor :: < T , I > :: zero ( ) {
470472 Self :: spend_funds ( spend_periods_passed, new_last_spend_period)
471473 } else {
472474 Weight :: zero ( )
473475 }
474476 }
475477
476478 #[ cfg( feature = "try-runtime" ) ]
477- fn try_state ( _: BlockNumberFor < T > ) -> Result < ( ) , sp_runtime:: TryRuntimeError > {
479+ fn try_state ( _: SystemBlockNumberFor < T > ) -> Result < ( ) , sp_runtime:: TryRuntimeError > {
478480 Self :: do_try_state ( ) ?;
479481 Ok ( ( ) )
480482 }
@@ -638,7 +640,7 @@ pub mod pallet {
638640 asset_kind : Box < T :: AssetKind > ,
639641 #[ pallet:: compact] amount : AssetBalanceOf < T , I > ,
640642 beneficiary : Box < BeneficiaryLookupOf < T , I > > ,
641- valid_from : Option < BlockNumberFor < T > > ,
643+ valid_from : Option < BlockNumberFor < T , I > > ,
642644 ) -> DispatchResult {
643645 let max_amount = T :: SpendOrigin :: ensure_origin ( origin) ?;
644646 let beneficiary = T :: BeneficiaryLookup :: lookup ( * beneficiary) ?;
@@ -844,9 +846,9 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
844846 // Backfill the `LastSpendPeriod` storage, assuming that no configuration has changed
845847 // since introducing this code. Used specifically for a migration-less switch to populate
846848 // `LastSpendPeriod`.
847- fn update_last_spend_period ( ) -> BlockNumberFor < T > {
849+ fn update_last_spend_period ( ) -> BlockNumberFor < T , I > {
848850 let block_number = T :: BlockNumberProvider :: current_block_number ( ) ;
849- let spend_period = T :: SpendPeriod :: get ( ) . max ( BlockNumberFor :: < T > :: one ( ) ) ;
851+ let spend_period = T :: SpendPeriod :: get ( ) . max ( BlockNumberFor :: < T , I > :: one ( ) ) ;
850852 let time_since_last_spend = block_number % spend_period;
851853 // If it happens that this logic runs directly on a spend period block, we need to backdate
852854 // to the last spend period so a spend still occurs this block.
@@ -889,8 +891,8 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
889891
890892 /// Spend some money! returns number of approvals before spend.
891893 pub fn spend_funds (
892- spend_periods_passed : BlockNumberFor < T > ,
893- new_last_spend_period : BlockNumberFor < T > ,
894+ spend_periods_passed : BlockNumberFor < T , I > ,
895+ new_last_spend_period : BlockNumberFor < T , I > ,
894896 ) -> Weight {
895897 LastSpendPeriod :: < T , I > :: put ( new_last_spend_period) ;
896898 let mut total_weight = Weight :: zero ( ) ;
0 commit comments