1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Ensure that gas fee inputs fallback to tx params values if api is down (#11775)

* Ensure that gas fee inputs fallback to tx params values if down

* ensure getGasFeeEstimate fallback is a string
This commit is contained in:
Dan J Miller 2021-08-05 08:33:49 -02:30 committed by GitHub
parent 9fcd93191b
commit 01262d33a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -90,11 +90,12 @@ function getGasFeeEstimate(
gasFeeEstimates, gasFeeEstimates,
gasEstimateType, gasEstimateType,
estimateToUse, estimateToUse,
fallback = '0',
) { ) {
if (gasEstimateType === GAS_ESTIMATE_TYPES.FEE_MARKET) { if (gasEstimateType === GAS_ESTIMATE_TYPES.FEE_MARKET) {
return gasFeeEstimates?.[estimateToUse]?.[field] ?? '0'; return gasFeeEstimates?.[estimateToUse]?.[field] ?? String(fallback);
} }
return '0'; return String(fallback);
} }
/** /**
@ -280,6 +281,7 @@ export function useGasFeeInputs(
gasFeeEstimates, gasFeeEstimates,
gasEstimateType, gasEstimateType,
estimateToUse, estimateToUse,
initialMaxFeePerGas,
); );
const maxPriorityFeePerGasToUse = const maxPriorityFeePerGasToUse =
@ -289,6 +291,7 @@ export function useGasFeeInputs(
gasFeeEstimates, gasFeeEstimates,
gasEstimateType, gasEstimateType,
estimateToUse, estimateToUse,
initialMaxPriorityFeePerGas,
); );
const [initialGasPriceEstimates] = useState(gasFeeEstimates); const [initialGasPriceEstimates] = useState(gasFeeEstimates);