difftreelog
fix evm fees burn & test (#1079)
in: master
* fix evm fees burn & test * fix tips handling
3 files changed
js-packages/tests/creditFeesToTreasury.seqtest.tsdiffbeforeafterboth--- 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);
+ });
+
});
pallets/evm-transaction-payment/src/lib.rsdiffbeforeafterboth287 }287 }288288289 fn pay_priority_fee(tip: Self::LiquidityInfo) {289 fn pay_priority_fee(tip: Self::LiquidityInfo) {290 <pallet_evm::EVMCurrencyAdapter<C, OU> as OnChargeEVMTransaction<T>>::pay_priority_fee(291 tip.0,290 let Some(imbalance) = tip.0 else { return };292 )291 OU::on_unbalanced(imbalance)293 }292 }294}293}295294runtime/common/mod.rsdiffbeforeafterboth--- a/runtime/common/mod.rs
+++ b/runtime/common/mod.rs
@@ -107,21 +107,7 @@
type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;
-pub struct DealWithFees;
-impl OnUnbalanced<NegativeImbalance> for DealWithFees {
- fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {
- 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<T>(sp_std::marker::PhantomData<T>);