Skip to content

Commit

Permalink
Rename
Browse files Browse the repository at this point in the history
  • Loading branch information
Dinonard committed Dec 4, 2024
1 parent 4b7f604 commit 66ae204
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions primitives/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,20 +156,23 @@ impl<Address> UnifiedAddress<Address> {
/// Two separate `OnUnbalanced` handers are used:
/// - `UOF` for the fee
/// - `OUT` for the tip
pub struct EVMFungibleAdapterWrapper<F, OUF, OUT>(core::marker::PhantomData<(F, OUF, OUT)>);
impl<T, F, OUF, OUT> OnChargeEVMTransaction<T> for EVMFungibleAdapterWrapper<F, OUF, OUT>
pub struct EVMFungibleAdapterWrapper<F, FeeHandler, TipHandler>(
core::marker::PhantomData<(F, FeeHandler, TipHandler)>,
);
impl<T, F, FeeHandler, TipHandler> OnChargeEVMTransaction<T>
for EVMFungibleAdapterWrapper<F, FeeHandler, TipHandler>
where
T: pallet_evm::Config,
F: Balanced<T::AccountId>,
OUF: OnUnbalanced<Credit<T::AccountId, F>>,
OUT: OnUnbalanced<Credit<T::AccountId, F>>,
FeeHandler: OnUnbalanced<Credit<T::AccountId, F>>,
TipHandler: OnUnbalanced<Credit<T::AccountId, F>>,
U256: UniqueSaturatedInto<<F as Inspect<<T as frame_system::Config>::AccountId>>::Balance>,
{
// Kept type as Option to satisfy bound of Default
type LiquidityInfo = Option<Credit<T::AccountId, F>>;

fn withdraw_fee(who: &H160, fee: U256) -> Result<Self::LiquidityInfo, pallet_evm::Error<T>> {
pallet_evm::EVMFungibleAdapter::<F, OUF>::withdraw_fee(who, fee)
pallet_evm::EVMFungibleAdapter::<F, FeeHandler>::withdraw_fee(who, fee)
}

fn correct_and_deposit_fee(
Expand All @@ -178,7 +181,7 @@ where
base_fee: U256,
already_withdrawn: Self::LiquidityInfo,
) -> Self::LiquidityInfo {
<pallet_evm::EVMFungibleAdapter::<F, OUF> as OnChargeEVMTransaction<T>>::correct_and_deposit_fee(
<pallet_evm::EVMFungibleAdapter::<F, FeeHandler> as OnChargeEVMTransaction<T>>::correct_and_deposit_fee(
who,
corrected_fee,
base_fee,
Expand All @@ -188,7 +191,7 @@ where

fn pay_priority_fee(tip: Self::LiquidityInfo) {
if let Some(tip) = tip {
OUT::on_unbalanceds(Some(tip).into_iter());
TipHandler::on_unbalanceds(Some(tip).into_iter());
}
}
}

0 comments on commit 66ae204

Please sign in to comment.