mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-22 04:31:02 +00:00
This PR reverts #2280 which introduced `TransactionExtension` to replace `SignedExtension`. As a result of the discussion [here](https://github.com/paritytech/polkadot-sdk/pull/3623#issuecomment-1986789700), the changes will be reverted for now with plans to reintroduce the concept in the future. --------- Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
This commit is contained in:
@@ -20,7 +20,7 @@ use crate::Config;
|
||||
|
||||
use core::marker::PhantomData;
|
||||
use sp_runtime::{
|
||||
traits::{CheckedSub, DispatchInfoOf, PostDispatchInfoOf, Saturating, Zero},
|
||||
traits::{DispatchInfoOf, PostDispatchInfoOf, Saturating, Zero},
|
||||
transaction_validity::InvalidTransaction,
|
||||
};
|
||||
|
||||
@@ -51,17 +51,6 @@ pub trait OnChargeTransaction<T: Config> {
|
||||
tip: Self::Balance,
|
||||
) -> Result<Self::LiquidityInfo, TransactionValidityError>;
|
||||
|
||||
/// Check if the predicted fee from the transaction origin can be withdrawn.
|
||||
///
|
||||
/// Note: The `fee` already includes the `tip`.
|
||||
fn can_withdraw_fee(
|
||||
who: &T::AccountId,
|
||||
call: &T::RuntimeCall,
|
||||
dispatch_info: &DispatchInfoOf<T::RuntimeCall>,
|
||||
fee: Self::Balance,
|
||||
tip: Self::Balance,
|
||||
) -> Result<(), TransactionValidityError>;
|
||||
|
||||
/// After the transaction was executed the actual fee can be calculated.
|
||||
/// This function should refund any overpaid fees and optionally deposit
|
||||
/// the corrected amount.
|
||||
@@ -75,12 +64,6 @@ pub trait OnChargeTransaction<T: Config> {
|
||||
tip: Self::Balance,
|
||||
already_withdrawn: Self::LiquidityInfo,
|
||||
) -> Result<(), TransactionValidityError>;
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
fn endow_account(who: &T::AccountId, amount: Self::Balance);
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
fn minimum_balance() -> Self::Balance;
|
||||
}
|
||||
|
||||
/// Implements the transaction payment for a pallet implementing the `Currency`
|
||||
@@ -138,33 +121,6 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
/// Check if the predicted fee from the transaction origin can be withdrawn.
|
||||
///
|
||||
/// Note: The `fee` already includes the `tip`.
|
||||
fn can_withdraw_fee(
|
||||
who: &T::AccountId,
|
||||
_call: &T::RuntimeCall,
|
||||
_info: &DispatchInfoOf<T::RuntimeCall>,
|
||||
fee: Self::Balance,
|
||||
tip: Self::Balance,
|
||||
) -> Result<(), TransactionValidityError> {
|
||||
if fee.is_zero() {
|
||||
return Ok(())
|
||||
}
|
||||
|
||||
let withdraw_reason = if tip.is_zero() {
|
||||
WithdrawReasons::TRANSACTION_PAYMENT
|
||||
} else {
|
||||
WithdrawReasons::TRANSACTION_PAYMENT | WithdrawReasons::TIP
|
||||
};
|
||||
|
||||
let new_balance =
|
||||
C::free_balance(who).checked_sub(&fee).ok_or(InvalidTransaction::Payment)?;
|
||||
C::ensure_can_withdraw(who, fee, withdraw_reason, new_balance)
|
||||
.map(|_| ())
|
||||
.map_err(|_| InvalidTransaction::Payment.into())
|
||||
}
|
||||
|
||||
/// Hand the fee and the tip over to the `[OnUnbalanced]` implementation.
|
||||
/// Since the predicted fee might have been too high, parts of the fee may
|
||||
/// be refunded.
|
||||
@@ -197,14 +153,4 @@ where
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
fn endow_account(who: &T::AccountId, amount: Self::Balance) {
|
||||
let _ = C::deposit_creating(who, amount);
|
||||
}
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
fn minimum_balance() -> Self::Balance {
|
||||
C::minimum_balance()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user