25
25
//! chance to be included by the transaction queue.
26
26
//!
27
27
//! Additionally, this module allows one to configure:
28
- //! - The mapping between one unit of weight to one unit of fee via [`Trait ::WeightToFee`].
28
+ //! - The mapping between one unit of weight to one unit of fee via [`Config ::WeightToFee`].
29
29
//! - A means of updating the fee for the next block, via defining a multiplier, based on the
30
30
//! final state of the chain at the end of the previous block. This can be configured via
31
- //! [`Trait ::FeeMultiplierUpdate`]
32
- //! - How the fees are paid via [`Trait ::OnChargeTransaction`].
31
+ //! [`Config ::FeeMultiplierUpdate`]
32
+ //! - How the fees are paid via [`Config ::OnChargeTransaction`].
33
33
34
34
#![ cfg_attr( not( feature = "std" ) , no_std) ]
35
35
@@ -63,7 +63,7 @@ pub use payment::*;
63
63
pub type Multiplier = FixedU128 ;
64
64
65
65
type BalanceOf < T > =
66
- <<T as Trait >:: OnChargeTransaction as OnChargeTransaction < T > >:: Balance ;
66
+ <<T as Config >:: OnChargeTransaction as OnChargeTransaction < T > >:: Balance ;
67
67
68
68
/// A struct to update the weight multiplier per block. It implements `Convert<Multiplier,
69
69
/// Multiplier>`, meaning that it can convert the previous multiplier to the next one. This should
@@ -135,7 +135,7 @@ impl MultiplierUpdate for () {
135
135
}
136
136
137
137
impl < T , S , V , M > MultiplierUpdate for TargetedFeeAdjustment < T , S , V , M >
138
- where T : frame_system:: Trait , S : Get < Perquintill > , V : Get < Multiplier > , M : Get < Multiplier > ,
138
+ where T : frame_system:: Config , S : Get < Perquintill > , V : Get < Multiplier > , M : Get < Multiplier > ,
139
139
{
140
140
fn min ( ) -> Multiplier {
141
141
M :: get ( )
@@ -149,7 +149,7 @@ impl<T, S, V, M> MultiplierUpdate for TargetedFeeAdjustment<T, S, V, M>
149
149
}
150
150
151
151
impl < T , S , V , M > Convert < Multiplier , Multiplier > for TargetedFeeAdjustment < T , S , V , M >
152
- where T : frame_system:: Trait , S : Get < Perquintill > , V : Get < Multiplier > , M : Get < Multiplier > ,
152
+ where T : frame_system:: Config , S : Get < Perquintill > , V : Get < Multiplier > , M : Get < Multiplier > ,
153
153
{
154
154
fn convert ( previous : Multiplier ) -> Multiplier {
155
155
// Defensive only. The multiplier in storage should always be at most positive. Nonetheless
@@ -160,8 +160,8 @@ impl<T, S, V, M> Convert<Multiplier, Multiplier> for TargetedFeeAdjustment<T, S,
160
160
161
161
// the computed ratio is only among the normal class.
162
162
let normal_max_weight =
163
- <T as frame_system:: Trait >:: AvailableBlockRatio :: get ( ) *
164
- <T as frame_system:: Trait >:: MaximumBlockWeight :: get ( ) ;
163
+ <T as frame_system:: Config >:: AvailableBlockRatio :: get ( ) *
164
+ <T as frame_system:: Config >:: MaximumBlockWeight :: get ( ) ;
165
165
let normal_block_weight =
166
166
<frame_system:: Module < T > >:: block_weight ( )
167
167
. get ( frame_support:: weights:: DispatchClass :: Normal )
@@ -213,7 +213,7 @@ impl Default for Releases {
213
213
}
214
214
}
215
215
216
- pub trait Trait : frame_system:: Trait {
216
+ pub trait Config : frame_system:: Config {
217
217
/// Handler for withdrawing, refunding and depositing the transaction fee.
218
218
/// Transaction fees are withdrawn before the transaction is executed.
219
219
/// After the transaction was executed the transaction weight can be
@@ -233,15 +233,15 @@ pub trait Trait: frame_system::Trait {
233
233
}
234
234
235
235
decl_storage ! {
236
- trait Store for Module <T : Trait > as TransactionPayment {
236
+ trait Store for Module <T : Config > as TransactionPayment {
237
237
pub NextFeeMultiplier get( fn next_fee_multiplier) : Multiplier = Multiplier :: saturating_from_integer( 1 ) ;
238
238
239
239
StorageVersion build( |_: & GenesisConfig | Releases :: V2 ) : Releases ;
240
240
}
241
241
}
242
242
243
243
decl_module ! {
244
- pub struct Module <T : Trait > for enum Call where origin: T :: Origin {
244
+ pub struct Module <T : Config > for enum Call where origin: T :: Origin {
245
245
/// The fee to be paid for making a transaction; the per-byte portion.
246
246
const TransactionByteFee : BalanceOf <T > = T :: TransactionByteFee :: get( ) ;
247
247
@@ -263,7 +263,7 @@ decl_module! {
263
263
assert!(
264
264
<Multiplier as sp_runtime:: traits:: Bounded >:: max_value( ) >=
265
265
Multiplier :: checked_from_integer(
266
- <T as frame_system:: Trait >:: MaximumBlockWeight :: get( ) . try_into( ) . unwrap( )
266
+ <T as frame_system:: Config >:: MaximumBlockWeight :: get( ) . try_into( ) . unwrap( )
267
267
) . unwrap( ) ,
268
268
) ;
269
269
@@ -296,7 +296,7 @@ decl_module! {
296
296
}
297
297
}
298
298
299
- impl < T : Trait > Module < T > where
299
+ impl < T : Config > Module < T > where
300
300
BalanceOf < T > : FixedPointOperand
301
301
{
302
302
/// Query the data that we know about the fee of a given `call`.
@@ -407,13 +407,13 @@ impl<T: Trait> Module<T> where
407
407
fn weight_to_fee ( weight : Weight ) -> BalanceOf < T > {
408
408
// cap the weight to the maximum defined in runtime, otherwise it will be the
409
409
// `Bounded` maximum of its data type, which is not desired.
410
- let capped_weight = weight. min ( <T as frame_system:: Trait >:: MaximumBlockWeight :: get ( ) ) ;
410
+ let capped_weight = weight. min ( <T as frame_system:: Config >:: MaximumBlockWeight :: get ( ) ) ;
411
411
T :: WeightToFee :: calc ( & capped_weight)
412
412
}
413
413
}
414
414
415
415
impl < T > Convert < Weight , BalanceOf < T > > for Module < T > where
416
- T : Trait ,
416
+ T : Config ,
417
417
BalanceOf < T > : FixedPointOperand ,
418
418
{
419
419
/// Compute the fee for the specified weight.
@@ -429,9 +429,9 @@ impl<T> Convert<Weight, BalanceOf<T>> for Module<T> where
429
429
/// Require the transactor pay for themselves and maybe include a tip to gain additional priority
430
430
/// in the queue.
431
431
#[ derive( Encode , Decode , Clone , Eq , PartialEq ) ]
432
- pub struct ChargeTransactionPayment < T : Trait + Send + Sync > ( #[ codec( compact) ] BalanceOf < T > ) ;
432
+ pub struct ChargeTransactionPayment < T : Config + Send + Sync > ( #[ codec( compact) ] BalanceOf < T > ) ;
433
433
434
- impl < T : Trait + Send + Sync > ChargeTransactionPayment < T > where
434
+ impl < T : Config + Send + Sync > ChargeTransactionPayment < T > where
435
435
T :: Call : Dispatchable < Info =DispatchInfo , PostInfo =PostDispatchInfo > ,
436
436
BalanceOf < T > : Send + Sync + FixedPointOperand ,
437
437
{
@@ -449,14 +449,14 @@ impl<T: Trait + Send + Sync> ChargeTransactionPayment<T> where
449
449
) -> Result <
450
450
(
451
451
BalanceOf < T > ,
452
- <<T as Trait >:: OnChargeTransaction as OnChargeTransaction < T > >:: LiquidityInfo ,
452
+ <<T as Config >:: OnChargeTransaction as OnChargeTransaction < T > >:: LiquidityInfo ,
453
453
) ,
454
454
TransactionValidityError ,
455
455
> {
456
456
let tip = self . 0 ;
457
457
let fee = Module :: < T > :: compute_fee ( len as u32 , info, tip) ;
458
458
459
- <<T as Trait >:: OnChargeTransaction as OnChargeTransaction < T > >:: withdraw_fee ( who, call, info, fee, tip)
459
+ <<T as Config >:: OnChargeTransaction as OnChargeTransaction < T > >:: withdraw_fee ( who, call, info, fee, tip)
460
460
. map ( |i| ( fee, i) )
461
461
}
462
462
@@ -478,7 +478,7 @@ impl<T: Trait + Send + Sync> ChargeTransactionPayment<T> where
478
478
}
479
479
}
480
480
481
- impl < T : Trait + Send + Sync > sp_std:: fmt:: Debug for ChargeTransactionPayment < T > {
481
+ impl < T : Config + Send + Sync > sp_std:: fmt:: Debug for ChargeTransactionPayment < T > {
482
482
#[ cfg( feature = "std" ) ]
483
483
fn fmt ( & self , f : & mut sp_std:: fmt:: Formatter ) -> sp_std:: fmt:: Result {
484
484
write ! ( f, "ChargeTransactionPayment<{:?}>" , self . 0 )
@@ -489,7 +489,7 @@ impl<T: Trait + Send + Sync> sp_std::fmt::Debug for ChargeTransactionPayment<T>
489
489
}
490
490
}
491
491
492
- impl < T : Trait + Send + Sync > SignedExtension for ChargeTransactionPayment < T > where
492
+ impl < T : Config + Send + Sync > SignedExtension for ChargeTransactionPayment < T > where
493
493
BalanceOf < T > : Send + Sync + From < u64 > + FixedPointOperand ,
494
494
T :: Call : Dispatchable < Info =DispatchInfo , PostInfo =PostDispatchInfo > ,
495
495
{
@@ -503,7 +503,7 @@ impl<T: Trait + Send + Sync> SignedExtension for ChargeTransactionPayment<T> whe
503
503
// who paid the fee
504
504
Self :: AccountId ,
505
505
// imbalance resulting from withdrawing the fee
506
- <<T as Trait >:: OnChargeTransaction as OnChargeTransaction < T > >:: LiquidityInfo ,
506
+ <<T as Config >:: OnChargeTransaction as OnChargeTransaction < T > >:: LiquidityInfo ,
507
507
) ;
508
508
fn additional_signed ( & self ) -> sp_std:: result:: Result < ( ) , TransactionValidityError > { Ok ( ( ) ) }
509
509
@@ -573,7 +573,7 @@ mod tests {
573
573
} ;
574
574
use smallvec:: smallvec;
575
575
576
- const CALL : & <Runtime as frame_system:: Trait >:: Call =
576
+ const CALL : & <Runtime as frame_system:: Config >:: Call =
577
577
& Call :: Balances ( BalancesCall :: transfer ( 2 , 69 ) ) ;
578
578
579
579
impl_outer_dispatch ! {
@@ -608,7 +608,7 @@ mod tests {
608
608
pub static WeightToFee : u64 = 1 ;
609
609
}
610
610
611
- impl frame_system:: Trait for Runtime {
611
+ impl frame_system:: Config for Runtime {
612
612
type BaseCallFilter = ( ) ;
613
613
type Origin = Origin ;
614
614
type Index = u64 ;
@@ -640,7 +640,7 @@ mod tests {
640
640
pub const ExistentialDeposit : u64 = 1 ;
641
641
}
642
642
643
- impl pallet_balances:: Trait for Runtime {
643
+ impl pallet_balances:: Config for Runtime {
644
644
type Balance = u64 ;
645
645
type Event = Event ;
646
646
type DustRemoval = ( ) ;
@@ -663,7 +663,7 @@ mod tests {
663
663
}
664
664
}
665
665
666
- impl Trait for Runtime {
666
+ impl Config for Runtime {
667
667
type OnChargeTransaction = CurrencyAdapter < Balances , ( ) > ;
668
668
type TransactionByteFee = TransactionByteFee ;
669
669
type WeightToFee = WeightToFee ;
@@ -841,7 +841,7 @@ mod tests {
841
841
// fee will be proportional to what is the actual maximum weight in the runtime.
842
842
assert_eq ! (
843
843
Balances :: free_balance( & 1 ) ,
844
- ( 10000 - <Runtime as frame_system:: Trait >:: MaximumBlockWeight :: get( ) ) as u64
844
+ ( 10000 - <Runtime as frame_system:: Config >:: MaximumBlockWeight :: get( ) ) as u64
845
845
) ;
846
846
} ) ;
847
847
}
0 commit comments