1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 18:00:18 +01:00

Resolve a BigNumber issue (#13555)

* Do not call `decimalToHex` for `minimumGasLimit`, which is already in hex

* Add `0x` prefix when returning a gas estimate

* Fix UTs

Co-authored-by: Dan J Miller <danjm.com@gmail.com>
This commit is contained in:
Daniel 2022-02-08 19:14:50 +01:00 committed by Dan Miller
parent 58b93c501a
commit 0dcc8d050f
3 changed files with 6 additions and 4 deletions

View File

@ -55,7 +55,7 @@ function calculateGasEstimateWithRefund(
const gasEstimateWithRefund =
!isMaxGasMinusRefundNegative && maxGasMinusRefund.lt(estimatedGas, 16)
? maxGasMinusRefund.toString(16)
? `0x${maxGasMinusRefund.toString(16)}`
: estimatedGas;
return gasEstimateWithRefund;

View File

@ -372,7 +372,9 @@ describe('SwapsController', function () {
assert.strictEqual(gasEstimate, bufferedGasLimit);
assert.strictEqual(
gasEstimateWithRefund,
new BigNumber(maxGas, 10).minus(estimatedRefund, 10).toString(16),
`0x${new BigNumber(maxGas, 10)
.minus(estimatedRefund, 10)
.toString(16)}`,
);
});
@ -690,7 +692,7 @@ describe('SwapsController', function () {
isBestQuote: true,
// TODO: find a way to calculate these values dynamically
gasEstimate: 2000000,
gasEstimateWithRefund: 'b8cae',
gasEstimateWithRefund: '0xb8cae',
savings: {
fee: '0',
metaMaskFee: '0.5050505050505050505',

View File

@ -111,7 +111,7 @@ export function useGasEstimates({
const maximumCostInHexWei = getMaximumGasTotalInHexWei(gasSettings);
if (editGasMode === EDIT_GAS_MODES.SWAPS) {
gasSettings = { ...gasSettings, gasLimit: decimalToHex(minimumGasLimit) };
gasSettings = { ...gasSettings, gasLimit: minimumGasLimit };
}
// The minimum amount this transaction will cost