@@ -58,14 +58,16 @@ pub trait OnChargeAssetTransaction<T: Config> {
5858 /// the corrected amount.
5959 ///
6060 /// Note: The `fee` already includes the `tip`.
61+ ///
62+ /// Returns the fee and tip in the asset used for payment as (fee, tip).
6163 fn correct_and_deposit_fee (
6264 who : & T :: AccountId ,
6365 dispatch_info : & DispatchInfoOf < T :: RuntimeCall > ,
6466 post_info : & PostDispatchInfoOf < T :: RuntimeCall > ,
6567 corrected_fee : Self :: Balance ,
6668 tip : Self :: Balance ,
6769 already_withdrawn : Self :: LiquidityInfo ,
68- ) -> Result < ( ) , TransactionValidityError > ;
70+ ) -> Result < ( AssetBalanceOf < T > , AssetBalanceOf < T > ) , TransactionValidityError > ;
6971}
7072
7173/// Allows specifying what to do with the withdrawn asset fees.
@@ -132,26 +134,31 @@ where
132134 /// Since the predicted fee might have been too high, parts of the fee may be refunded.
133135 ///
134136 /// Note: The `corrected_fee` already includes the `tip`.
137+ ///
138+ /// Returns the fee and tip in the asset used for payment as (fee, tip).
135139 fn correct_and_deposit_fee (
136140 who : & T :: AccountId ,
137141 _dispatch_info : & DispatchInfoOf < T :: RuntimeCall > ,
138142 _post_info : & PostDispatchInfoOf < T :: RuntimeCall > ,
139143 corrected_fee : Self :: Balance ,
140- _tip : Self :: Balance ,
144+ tip : Self :: Balance ,
141145 paid : Self :: LiquidityInfo ,
142- ) -> Result < ( ) , TransactionValidityError > {
146+ ) -> Result < ( AssetBalanceOf < T > , AssetBalanceOf < T > ) , TransactionValidityError > {
143147 let min_converted_fee = if corrected_fee. is_zero ( ) { Zero :: zero ( ) } else { One :: one ( ) } ;
144- // Convert the corrected fee into the asset used for payment.
148+ // Convert the corrected fee and tip into the asset used for payment.
145149 let converted_fee = CON :: to_asset_balance ( corrected_fee, paid. asset ( ) )
146150 . map_err ( |_| -> TransactionValidityError { InvalidTransaction :: Payment . into ( ) } ) ?
147151 . max ( min_converted_fee) ;
152+ let converted_tip = CON :: to_asset_balance ( tip, paid. asset ( ) )
153+ . map_err ( |_| -> TransactionValidityError { InvalidTransaction :: Payment . into ( ) } ) ?;
154+
148155 // Calculate how much refund we should return.
149156 let ( final_fee, refund) = paid. split ( converted_fee) ;
150157 // Refund to the account that paid the fees. If this fails, the account might have dropped
151158 // below the existential balance. In that case we don't refund anything.
152159 let _ = <T :: Fungibles as Balanced < T :: AccountId > >:: resolve ( who, refund) ;
153160 // Handle the final fee, e.g. by transferring to the block author or burning.
154161 HC :: handle_credit ( final_fee) ;
155- Ok ( ( ) )
162+ Ok ( ( converted_fee , converted_tip ) )
156163 }
157164}
0 commit comments