@@ -26,7 +26,7 @@ use frame_support::{
26
26
use frame_system:: pallet_prelude:: * ;
27
27
use pallet_transaction_payment:: OnChargeTransaction ;
28
28
use sp_runtime:: {
29
- traits:: { Convert , DispatchInfoOf , Dispatchable , SignedExtension , Verify , Zero } ,
29
+ traits:: { Convert , Dispatchable , SignedExtension , Verify , Zero } ,
30
30
transaction_validity:: { TransactionValidity , TransactionValidityError } ,
31
31
AccountId32 , MultiSignature ,
32
32
} ;
@@ -149,6 +149,7 @@ pub mod module {
149
149
#[ pallet:: validate_unsigned]
150
150
impl < T : Config > ValidateUnsigned for Pallet < T >
151
151
where
152
+ BalanceOf < T > : Send + Sync + From < u64 > ,
152
153
<T as frame_system:: Config >:: RuntimeCall :
153
154
From < Call < T > > + Dispatchable < Info = DispatchInfo , PostInfo = PostDispatchInfo > ,
154
155
{
@@ -196,6 +197,7 @@ pub mod module {
196
197
197
198
impl < T : Config > Pallet < T >
198
199
where
200
+ BalanceOf < T > : Send + Sync + From < u64 > ,
199
201
<T as frame_system:: Config >:: RuntimeCall : From < Call < T > > + Dispatchable < Info = DispatchInfo > ,
200
202
{
201
203
fn filter_valid_calls ( call : & Call < T > ) -> Result < PasskeyPayload < T > , TransactionValidityError > {
@@ -316,6 +318,7 @@ pub struct ChargeTransactionPayment<T: Config>(pub T::AccountId, pub Call<T>);
316
318
317
319
impl < T : Config > ChargeTransactionPayment < T >
318
320
where
321
+ BalanceOf < T > : Send + Sync + From < u64 > ,
319
322
<T as frame_system:: Config >:: RuntimeCall :
320
323
From < Call < T > > + Dispatchable < Info = DispatchInfo , PostInfo = PostDispatchInfo > ,
321
324
{
@@ -326,7 +329,8 @@ where
326
329
let runtime_call: <T as frame_system:: Config >:: RuntimeCall =
327
330
<T as frame_system:: Config >:: RuntimeCall :: from ( self . 1 . clone ( ) ) ;
328
331
let who = self . 0 . clone ( ) ;
329
- self . withdraw_token_fee ( & who, & runtime_call, info, len, Zero :: zero ( ) ) ?;
332
+ pallet_transaction_payment:: ChargeTransactionPayment :: < T > :: from ( Zero :: zero ( ) )
333
+ . pre_dispatch ( & who, & runtime_call, info, len) ?;
330
334
Ok ( ( ) )
331
335
}
332
336
@@ -337,38 +341,12 @@ where
337
341
let runtime_call: <T as frame_system:: Config >:: RuntimeCall =
338
342
<T as frame_system:: Config >:: RuntimeCall :: from ( self . 1 . clone ( ) ) ;
339
343
let who = self . 0 . clone ( ) ;
340
- let fee = self . withdraw_token_fee ( & who, & runtime_call, info, len, Zero :: zero ( ) ) ?;
341
344
342
- let priority = pallet_transaction_payment:: ChargeTransactionPayment :: < T > :: get_priority (
345
+ pallet_transaction_payment:: ChargeTransactionPayment :: < T > :: from ( Zero :: zero ( ) ) . validate (
346
+ & who,
347
+ & runtime_call,
343
348
info,
344
349
len,
345
- Zero :: zero ( ) ,
346
- fee,
347
- ) ;
348
-
349
- Ok ( ValidTransaction { priority, ..Default :: default ( ) } )
350
- }
351
-
352
- /// Withdraws transaction fee paid with tokens.
353
- /// # Arguments
354
- /// * `who` - The account id of the payer
355
- /// * `call` - The call
356
- /// # Return
357
- /// * `Ok((fee, initial_payment))` if the fee is successfully withdrawn
358
- /// * `Err(InvalidTransaction::Payment)` if the fee cannot be withdrawn
359
- fn withdraw_token_fee (
360
- & self ,
361
- who : & T :: AccountId ,
362
- call : & <T as frame_system:: Config >:: RuntimeCall ,
363
- info : & DispatchInfoOf < <T as frame_system:: Config >:: RuntimeCall > ,
364
- len : usize ,
365
- tip : BalanceOf < T > ,
366
- ) -> Result < BalanceOf < T > , TransactionValidityError > {
367
- let fee = pallet_transaction_payment:: Pallet :: < T > :: compute_fee ( len as u32 , info, tip) ;
368
- <OnChargeTransactionOf < T > as OnChargeTransaction < T > >:: withdraw_fee (
369
- who, call, info, fee, tip,
370
350
)
371
- . map ( |_| ( fee) )
372
- . map_err ( |_| -> TransactionValidityError { InvalidTransaction :: Payment . into ( ) } )
373
351
}
374
352
}
0 commit comments