Skip to content

Commit d96d86b

Browse files
committed
Use gasLimitNoBuffer on network fee estimation
1 parent 768716d commit d96d86b

File tree

4 files changed

+41
-6
lines changed

4 files changed

+41
-6
lines changed

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,8 @@
249249
"secp256k1@npm:^4.0.0": "4.0.4",
250250
"secp256k1@npm:^4.0.1": "4.0.4",
251251
"secp256k1@npm:4.0.2": "4.0.4",
252-
"secp256k1@npm:4.0.3": "4.0.4"
252+
"secp256k1@npm:4.0.3": "4.0.4",
253+
"@metamask/transaction-controller@npm:^42.1.0": "npm:@metamask-previews/[email protected]"
253254
},
254255
"dependencies": {
255256
"@babel/runtime": "patch:@babel/runtime@npm%3A7.25.9#~/.yarn/patches/@babel-runtime-npm-7.25.9-fe8c62510a.patch",

ui/pages/confirmations/components/confirm/info/hooks/useFeeCalculations.test.ts

+31
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,37 @@ describe('useFeeCalculations', () => {
6565
`);
6666
});
6767

68+
it('picks up gasLimitNoBuffer for minimum network fee on estimations', () => {
69+
const transactionMeta = genUnapprovedContractInteractionConfirmation({
70+
address: CONTRACT_INTERACTION_SENDER_ADDRESS,
71+
}) as TransactionMeta;
72+
73+
// txParams.gas is 0xab77
74+
transactionMeta.gasLimitNoBuffer = '0x9b77';
75+
76+
const { result } = renderHookWithProvider(
77+
() => useFeeCalculations(transactionMeta),
78+
mockState,
79+
);
80+
81+
expect(result.current).toMatchInlineSnapshot(`
82+
{
83+
"estimatedFeeFiat": "$0.03",
84+
"estimatedFeeFiatWith18SignificantDigits": null,
85+
"estimatedFeeNative": "0.0001 ETH",
86+
"l1FeeFiat": "",
87+
"l1FeeFiatWith18SignificantDigits": "",
88+
"l1FeeNative": "",
89+
"l2FeeFiat": "",
90+
"l2FeeFiatWith18SignificantDigits": "",
91+
"l2FeeNative": "",
92+
"maxFeeFiat": "$0.07",
93+
"maxFeeFiatWith18SignificantDigits": null,
94+
"maxFeeNative": "0.0001 ETH",
95+
}
96+
`);
97+
});
98+
6899
it('returns the correct estimate for a transaction with layer1GasFee', () => {
69100
const transactionMeta = genUnapprovedContractInteractionConfirmation({
70101
address: CONTRACT_INTERACTION_SENDER_ADDRESS,

ui/pages/confirmations/components/confirm/info/hooks/useFeeCalculations.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,12 @@ export function useFeeCalculations(transactionMeta: TransactionMeta) {
157157
minimumFeePerGas = decimalToHex(maxFeePerGas);
158158
}
159159

160+
// We want to pick gasLimitNoBuffer to show minimum network fee
161+
const minimumGasLimit = transactionMeta?.gasLimitNoBuffer || gasLimit;
162+
160163
const estimatedFee = multiplyHexes(
161164
supportsEIP1559 ? (minimumFeePerGas as Hex) : (gasPrice as Hex),
162-
gasLimit as Hex,
165+
minimumGasLimit as Hex,
163166
);
164167

165168
return getFeesFromHex(estimatedFee);

yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -6446,9 +6446,9 @@ __metadata:
64466446
languageName: node
64476447
linkType: hard
64486448

6449-
"@metamask/transaction-controller@npm:^42.1.0":
6450-
version: 42.1.0
6451-
resolution: "@metamask/transaction-controller@npm:42.1.0"
6449+
"@metamask/transaction-controller@npm:@metamask-previews/transaction-controller@42.1.0-preview-981e1d0":
6450+
version: 42.1.0-preview-981e1d0
6451+
resolution: "@metamask-previews/transaction-controller@npm:42.1.0-preview-981e1d0"
64526452
dependencies:
64536453
"@ethereumjs/common": "npm:^3.2.0"
64546454
"@ethereumjs/tx": "npm:^4.2.0"
@@ -6476,7 +6476,7 @@ __metadata:
64766476
"@metamask/eth-block-tracker": ">=9"
64776477
"@metamask/gas-fee-controller": ^22.0.0
64786478
"@metamask/network-controller": ^22.0.0
6479-
checksum: 10/9f842e2b68e84cbffdda301a0e15faab08226fd8e22eb954690ed41df60fe92c24acffdd9186b4c9f1da911a368cbe22cdb9ee046fc02d079c53f76100c66755
6479+
checksum: 10/55f79c9e3596f9c70e014159cb8d125fedaae82e944b9004fa9d64118d825c7ffebabdada6da63f2a2b4260a59322e3bbece0d782e1f1d70e2a64c5b29c1a279
64806480
languageName: node
64816481
linkType: hard
64826482

0 commit comments

Comments
 (0)