mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Add Optimism's L1 fee for an approval tx into total L1 fee in Swaps (#16929)
This commit is contained in:
parent
75177c5998
commit
a6da5fd4c3
@ -113,6 +113,7 @@ import {
|
|||||||
hexWEIToDecGWEI,
|
hexWEIToDecGWEI,
|
||||||
toPrecisionWithoutTrailingZeros,
|
toPrecisionWithoutTrailingZeros,
|
||||||
} from '../../../../shared/lib/transactions-controller-utils';
|
} from '../../../../shared/lib/transactions-controller-utils';
|
||||||
|
import { addHexPrefix } from '../../../../app/scripts/lib/util';
|
||||||
import { calcTokenValue } from '../../../../shared/lib/swaps-utils';
|
import { calcTokenValue } from '../../../../shared/lib/swaps-utils';
|
||||||
import fetchEstimatedL1Fee from '../../../helpers/utils/optimism/fetchEstimatedL1Fee';
|
import fetchEstimatedL1Fee from '../../../helpers/utils/optimism/fetchEstimatedL1Fee';
|
||||||
import { sumHexes } from '../../../helpers/utils/transactions.util';
|
import { sumHexes } from '../../../helpers/utils/transactions.util';
|
||||||
@ -895,18 +896,30 @@ export default function ViewQuote() {
|
|||||||
}
|
}
|
||||||
const getEstimatedL1Fee = async () => {
|
const getEstimatedL1Fee = async () => {
|
||||||
try {
|
try {
|
||||||
const result = await fetchEstimatedL1Fee(global.eth, {
|
const l1TradeFeeTotal = await fetchEstimatedL1Fee(global.eth, {
|
||||||
txParams: unsignedTransaction,
|
txParams: unsignedTransaction,
|
||||||
chainId,
|
chainId,
|
||||||
});
|
});
|
||||||
setMultiLayerL1FeeTotal(result);
|
let l1ApprovalFeeTotal = '0x0';
|
||||||
|
if (approveTxParams) {
|
||||||
|
l1ApprovalFeeTotal = await fetchEstimatedL1Fee(global.eth, {
|
||||||
|
txParams: {
|
||||||
|
...approveTxParams,
|
||||||
|
gasPrice: addHexPrefix(approveTxParams.gasPrice),
|
||||||
|
value: '0x0', // For approval txs we need to use "0x0" here.
|
||||||
|
},
|
||||||
|
chainId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const l1FeeTotal = sumHexes(l1TradeFeeTotal, l1ApprovalFeeTotal);
|
||||||
|
setMultiLayerL1FeeTotal(l1FeeTotal);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
captureException(e);
|
captureException(e);
|
||||||
setMultiLayerL1FeeTotal(null);
|
setMultiLayerL1FeeTotal(null);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
getEstimatedL1Fee();
|
getEstimatedL1Fee();
|
||||||
}, [unsignedTransaction, isMultiLayerFeeNetwork, chainId]);
|
}, [unsignedTransaction, approveTxParams, isMultiLayerFeeNetwork, chainId]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (currentSmartTransactionsEnabled && smartTransactionsOptInStatus) {
|
if (currentSmartTransactionsEnabled && smartTransactionsOptInStatus) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user