@@ -113,6 +113,8 @@ pub mod pallet {
113113
114114 #[ pallet:: config]
115115 pub trait Config : frame_system:: Config + pallet_transaction_payment:: Config {
116+ /// The overarching event type.
117+ type Event : From < Event < Self > > + IsType < <Self as frame_system:: Config >:: Event > ;
116118 /// The fungibles instance used to pay for transactions in assets.
117119 type Fungibles : Balanced < Self :: AccountId > ;
118120 /// The actual transaction charging logic that charges the fees.
@@ -122,6 +124,19 @@ pub mod pallet {
122124 #[ pallet:: pallet]
123125 #[ pallet:: generate_store( pub ( super ) trait Store ) ]
124126 pub struct Pallet < T > ( _ ) ;
127+
128+ #[ pallet:: event]
129+ #[ pallet:: generate_deposit( pub ( super ) fn deposit_event) ]
130+ pub enum Event < T : Config > {
131+ /// A transaction fee `actual_fee`, of which `tip` was added to the minimum inclusion fee,
132+ /// has been paid by `who` in an asset `asset_id`.
133+ AssetTxFeePaid {
134+ who : T :: AccountId ,
135+ actual_fee : BalanceOf < T > ,
136+ tip : BalanceOf < T > ,
137+ asset_id : Option < ChargeAssetIdOf < T > > ,
138+ } ,
139+ }
125140}
126141
127142/// Require the transactor pay for themselves and maybe include a tip to gain additional priority
@@ -213,6 +228,8 @@ where
213228 Self :: AccountId ,
214229 // imbalance resulting from withdrawing the fee
215230 InitialPayment < T > ,
231+ // asset_id for the transaction payment
232+ Option < ChargeAssetIdOf < T > > ,
216233 ) ;
217234
218235 fn additional_signed ( & self ) -> sp_std:: result:: Result < ( ) , TransactionValidityError > {
@@ -240,7 +257,7 @@ where
240257 len : usize ,
241258 ) -> Result < Self :: Pre , TransactionValidityError > {
242259 let ( _fee, initial_payment) = self . withdraw_fee ( who, call, info, len) ?;
243- Ok ( ( self . tip , who. clone ( ) , initial_payment) )
260+ Ok ( ( self . tip , who. clone ( ) , initial_payment, self . asset_id ) )
244261 }
245262
246263 fn post_dispatch (
@@ -250,7 +267,7 @@ where
250267 len : usize ,
251268 result : & DispatchResult ,
252269 ) -> Result < ( ) , TransactionValidityError > {
253- if let Some ( ( tip, who, initial_payment) ) = pre {
270+ if let Some ( ( tip, who, initial_payment, asset_id ) ) = pre {
254271 match initial_payment {
255272 InitialPayment :: Native ( already_withdrawn) => {
256273 pallet_transaction_payment:: ChargeTransactionPayment :: < T > :: post_dispatch (
@@ -273,6 +290,12 @@ where
273290 tip. into ( ) ,
274291 already_withdrawn. into ( ) ,
275292 ) ?;
293+ Pallet :: < T > :: deposit_event ( Event :: < T > :: AssetTxFeePaid {
294+ who,
295+ actual_fee,
296+ tip,
297+ asset_id,
298+ } ) ;
276299 } ,
277300 InitialPayment :: Nothing => {
278301 // `actual_fee` should be zero here for any signed extrinsic. It would be
0 commit comments