From 31cc060fdb46c56a92dd7e229f3db00ee88a6656 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20Mi=C3=B1o?= Date: Thu, 2 May 2019 18:23:44 -0400 Subject: [PATCH] Improvement: gas limit fallback (#633) * gas limit estimation fallback * log --- app/components/UI/CustomGas/index.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/components/UI/CustomGas/index.js b/app/components/UI/CustomGas/index.js index 53c7ede815a..a7760e12704 100644 --- a/app/components/UI/CustomGas/index.js +++ b/app/components/UI/CustomGas/index.js @@ -13,6 +13,11 @@ import { } from '../../../util/custom-gas'; import { BN } from 'ethereumjs-util'; import { fromWei } from '../../../util/number'; +import Logger from '../../../util/Logger'; + +const AVERAGE_GAS = 20; +const LOW_GAS = 10; +const FAST_GAS = 40; const styles = StyleSheet.create({ selectors: { @@ -203,7 +208,13 @@ class CustomGas extends Component { handleFetchBasicEstimates = async () => { this.setState({ ready: false }); - const basicGasEstimates = await fetchBasicGasEstimates(); + let basicGasEstimates; + try { + basicGasEstimates = await fetchBasicGasEstimates(); + } catch (error) { + Logger.log('Error while trying to get gas limit estimates', error); + basicGasEstimates = { average: AVERAGE_GAS, safeLow: LOW_GAS, fast: FAST_GAS }; + } const { average, fast, safeLow } = basicGasEstimates; this.setState({ averageGwei: convertApiValueToGWEI(average),