--- a/js-packages/tests/creditFeesToTreasury.seqtest.ts +++ b/js-packages/tests/creditFeesToTreasury.seqtest.ts @@ -18,6 +18,8 @@ import {ApiPromise} from '@polkadot/api'; import {usingPlaygrounds, expect, itSub} from '@unique/test-utils/util.js'; import type {u32} from '@polkadot/types-codec'; +import { itEth } from '@unique/test-utils/eth/util.js'; +import { ITransactionResult } from '@unique-nft/playgrounds/types'; const TREASURY = '5EYCAe5ijiYfyeZ2JJCGq56LmPyNRAKzpG4QkoQkkQNB5e6Z'; const saneMinimumFee = 0.05; @@ -163,4 +165,36 @@ expect(Math.abs(fee - expectedTransferFee)).to.be.lessThan(tolerance); }); + + itEth('Evm Transactions send fees to Treasury', async ({helper}) => { + const value = helper.balance.getOneTokenNominal(); + const gasPrice = await helper.getWeb3().eth.getGasPrice(); + let result = null; + + const lambda = async () => { + result = await helper.executeExtrinsic(alice, 'api.tx.evm.call', [ + helper.address.substrateToEth(alice.address), + helper.address.substrateToEth(bob.address), + '0x', + value, + 25_000, + gasPrice, + null, + null, + [], + ]); + }; + + const totalPaid = await helper.arrange.calculcateFee({ Substrate: alice.address }, lambda); + const evmFees = totalPaid - value; + + const treasuryDepoosited = (result as unknown as ITransactionResult).result.events + .filter(({ event: { method, section } }) => section == 'treasury' && method == 'Deposit') + .map(({ event: { data } }) => data[0].toJSON()); + + const deposit = BigInt(treasuryDepoosited[0]); + + expect(deposit).to.be.equal(evmFees); + }); + }); --- a/pallets/evm-transaction-payment/src/lib.rs +++ b/pallets/evm-transaction-payment/src/lib.rs @@ -287,8 +287,7 @@ } fn pay_priority_fee(tip: Self::LiquidityInfo) { - as OnChargeEVMTransaction>::pay_priority_fee( - tip.0, - ) + let Some(imbalance) = tip.0 else { return }; + OU::on_unbalanced(imbalance) } } --- a/runtime/common/mod.rs +++ b/runtime/common/mod.rs @@ -107,21 +107,7 @@ type NegativeImbalance = >::NegativeImbalance; -pub struct DealWithFees; -impl OnUnbalanced for DealWithFees { - fn on_unbalanceds(mut fees_then_tips: impl Iterator) { - if let Some(fees) = fees_then_tips.next() { - // for fees, 100% to treasury - let mut split = fees.ration(100, 0); - if let Some(tips) = fees_then_tips.next() { - // for tips, if any, 100% to treasury - tips.ration_merge_into(100, 0, &mut split); - } - Treasury::on_unbalanced(split.0); - // Author::on_unbalanced(split.1); - } - } -} +pub(crate) type DealWithFees = Treasury; pub struct RelayChainBlockNumberProvider(sp_std::marker::PhantomData);