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.tsdiffbeforeafterboth18import {ApiPromise} from '@polkadot/api';18import {ApiPromise} from '@polkadot/api';19import {usingPlaygrounds, expect, itSub} from '@unique/test-utils/util.js';19import {usingPlaygrounds, expect, itSub} from '@unique/test-utils/util.js';20import type {u32} from '@polkadot/types-codec';20import type {u32} from '@polkadot/types-codec';21import { itEth } from '@unique/test-utils/eth/util.js';22import { ITransactionResult } from '@unique-nft/playgrounds/types';212322const TREASURY = '5EYCAe5ijiYfyeZ2JJCGq56LmPyNRAKzpG4QkoQkkQNB5e6Z';24const TREASURY = '5EYCAe5ijiYfyeZ2JJCGq56LmPyNRAKzpG4QkoQkkQNB5e6Z';23const saneMinimumFee = 0.05;25const saneMinimumFee = 0.05;164 expect(Math.abs(fee - expectedTransferFee)).to.be.lessThan(tolerance);166 expect(Math.abs(fee - expectedTransferFee)).to.be.lessThan(tolerance);165 });167 });168 169 itEth('Evm Transactions send fees to Treasury', async ({helper}) => {170 const value = helper.balance.getOneTokenNominal();171 const gasPrice = await helper.getWeb3().eth.getGasPrice();172 let result = null;173 174 const lambda = async () => {175 result = await helper.executeExtrinsic(alice, 'api.tx.evm.call', [176 helper.address.substrateToEth(alice.address),177 helper.address.substrateToEth(bob.address),178 '0x',179 value,180 25_000,181 gasPrice,182 null,183 null,184 [],185 ]);186 };187 188 const totalPaid = await helper.arrange.calculcateFee({ Substrate: alice.address }, lambda);189 const evmFees = totalPaid - value;190 191 const treasuryDepoosited = (result as unknown as ITransactionResult).result.events192 .filter(({ event: { method, section } }) => section == 'treasury' && method == 'Deposit')193 .map(({ event: { data } }) => data[0].toJSON());194 195 const deposit = BigInt(treasuryDepoosited[0]);196 197 expect(deposit).to.be.equal(evmFees);198 });199 166});200});167201pallets/evm-transaction-payment/src/lib.rsdiffbeforeafterboth--- 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) {
- <pallet_evm::EVMCurrencyAdapter<C, OU> as OnChargeEVMTransaction<T>>::pay_priority_fee(
- tip.0,
- )
+ let Some(imbalance) = tip.0 else { return };
+ OU::on_unbalanced(imbalance)
}
}
runtime/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>);