Skip to content

Commit

Permalink
Improvement: gas limit fallback (#633)
Browse files Browse the repository at this point in the history
* gas limit estimation fallback

* log
  • Loading branch information
estebanmino authored May 2, 2019
1 parent 787e4c6 commit 31cc060
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion app/components/UI/CustomGas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 31cc060

Please sign in to comment.