From f6cd702f1b1436f4f18ea318f8d03bccb31140b6 Mon Sep 17 00:00:00 2001 From: Dan J Miller Date: Wed, 18 Aug 2021 07:24:53 -0230 Subject: [PATCH] Dont default gas limit in gas popover when non is available on transaction params (#11872) * Dont default gas limit when non is available on transaction params * Fix unit tests --- ui/hooks/useGasFeeInputs.js | 2 +- ui/hooks/useGasFeeInputs.test.js | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ui/hooks/useGasFeeInputs.js b/ui/hooks/useGasFeeInputs.js index 47fcd38a3..7441bb07f 100644 --- a/ui/hooks/useGasFeeInputs.js +++ b/ui/hooks/useGasFeeInputs.js @@ -229,7 +229,7 @@ export function useGasFeeInputs( initialGasPrice && initialFeeParamsAreCustom ? initialGasPrice : null, ); const [gasLimit, setGasLimit] = useState( - Number(hexToDecimal(transaction?.txParams?.gas ?? minimumGasLimit)), + Number(hexToDecimal(transaction?.txParams?.gas ?? '0x0')), ); const userPrefersAdvancedGas = useSelector(getAdvancedInlineGasShown); diff --git a/ui/hooks/useGasFeeInputs.test.js b/ui/hooks/useGasFeeInputs.test.js index b321c130a..60972dbe4 100644 --- a/ui/hooks/useGasFeeInputs.test.js +++ b/ui/hooks/useGasFeeInputs.test.js @@ -323,7 +323,12 @@ describe('useGasFeeInputs', () => { }); it('should return true', () => { - const { result } = renderHook(() => useGasFeeInputs()); + const { result } = renderHook(() => + useGasFeeInputs(null, { + userFeeLevel: 'medium', + txParams: { gas: '0x5208' }, + }), + ); expect(result.current.balanceError).toBe(true); }); });