#[macro_export]
macro_rules! impl_on_charge_evm_transaction {
{} => {
type CurrencyAccountId<T> = <T as frame_system::Config>::AccountId;
type BalanceFor<T> =
<<T as pallet_evm::Config>::Currency as frame_support::traits::Currency<CurrencyAccountId<T>>>::Balance;
type PositiveImbalanceFor<T> =
<<T as pallet_evm::Config>::Currency as frame_support::traits::Currency<CurrencyAccountId<T>>>::PositiveImbalance;
type NegativeImbalanceFor<T> =
<<T as pallet_evm::Config>::Currency as frame_support::traits::Currency<CurrencyAccountId<T>>>::NegativeImbalance;
pub struct OnChargeEVMTransaction<OU>(sp_std::marker::PhantomData<OU>);
impl<T, OU> pallet_evm::OnChargeEVMTransaction<T> for OnChargeEVMTransaction<OU>
where
T: pallet_evm::Config,
PositiveImbalanceFor<T>: frame_support::traits::Imbalance<BalanceFor<T>, Opposite = NegativeImbalanceFor<T>>,
NegativeImbalanceFor<T>: frame_support::traits::Imbalance<BalanceFor<T>, Opposite = PositiveImbalanceFor<T>>,
OU: OnUnbalanced<NegativeImbalanceFor<T>>,
U256: sp_runtime::traits::UniqueSaturatedInto<BalanceFor<T>>
{
type LiquidityInfo = Option<NegativeImbalanceFor<T>>;
fn withdraw_fee(who: &sp_core::H160, fee: sp_core::U256) -> Result<Self::LiquidityInfo, pallet_evm::Error<T>> {
pallet_evm::EVMCurrencyAdapter::<<T as pallet_evm::Config>::Currency, ()>::withdraw_fee(who, fee)
}
fn correct_and_deposit_fee(
who: &sp_core::H160,
corrected_fee: sp_core::U256,
base_fee: sp_core::U256,
already_withdrawn: Self::LiquidityInfo,
) -> Self::LiquidityInfo {
<pallet_evm::EVMCurrencyAdapter<<T as pallet_evm::Config>::Currency, OU> as OnChargeEVMTransactionT<
T,
>>::correct_and_deposit_fee(who, corrected_fee, base_fee, already_withdrawn)
}
fn pay_priority_fee(tip: Self::LiquidityInfo) {
if let Some(tip) = tip {
OU::on_unbalanced(tip);
}
}
}
}
}