From c708bad8bb02a41eb301fff5a941de2861627b5c Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Tue, 26 Feb 2019 10:01:23 -0500 Subject: [PATCH] chore(cockpit/estimator): always return an integer for getGasPrice --- packages/embark-ui/src/components/ContractOverview.js | 3 ++- packages/embark-ui/src/components/GasStation.js | 2 +- packages/embark-ui/src/containers/GasStationContainer.js | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/embark-ui/src/components/ContractOverview.js b/packages/embark-ui/src/components/ContractOverview.js index 2c21bb738..736525084 100644 --- a/packages/embark-ui/src/components/ContractOverview.js +++ b/packages/embark-ui/src/components/ContractOverview.js @@ -63,7 +63,8 @@ class ContractFunction extends Component { autoSetGasPrice(e) { e.preventDefault(); const newInputs = this.state.inputs; - newInputs.gasPrice = this.gasStation.getCurrentGas(); + const currentPrice = this.gasStation.getCurrentGas(); + newInputs.gasPrice = currentPrice >= 0 ? currentPrice : 'Estimate unavailable'; this.setState({inputs: newInputs}); } diff --git a/packages/embark-ui/src/components/GasStation.js b/packages/embark-ui/src/components/GasStation.js index 4b91c4738..52ade9b68 100644 --- a/packages/embark-ui/src/components/GasStation.js +++ b/packages/embark-ui/src/components/GasStation.js @@ -52,7 +52,7 @@ class GasStation extends Component { getCurrentGas() { const formattedGas = this.getGasOracleFormatted(); if (!formattedGas.length) { - return 'Too few blocks'; + return -1; } return this.getGasOracleFormatted()[this.state.gasOracleSliderIndex].gasPrice / this.PRICE_UNIT_DIVIDER; } diff --git a/packages/embark-ui/src/containers/GasStationContainer.js b/packages/embark-ui/src/containers/GasStationContainer.js index be99b5a5b..4168bbc09 100644 --- a/packages/embark-ui/src/containers/GasStationContainer.js +++ b/packages/embark-ui/src/containers/GasStationContainer.js @@ -20,7 +20,7 @@ class GasStationContainer extends Component { getCurrentGas() { if (!this.gasStation) { - return 'Unavailable'; + return -1; } return this.gasStation.getCurrentGas(); }