chore(cockpit/estimator): always return an integer for getGasPrice

This commit is contained in:
Jonathan Rainville 2019-02-26 10:01:23 -05:00
parent 1759aac8aa
commit c708bad8bb
3 changed files with 4 additions and 3 deletions

View File

@ -63,7 +63,8 @@ class ContractFunction extends Component {
autoSetGasPrice(e) { autoSetGasPrice(e) {
e.preventDefault(); e.preventDefault();
const newInputs = this.state.inputs; 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}); this.setState({inputs: newInputs});
} }

View File

@ -52,7 +52,7 @@ class GasStation extends Component {
getCurrentGas() { getCurrentGas() {
const formattedGas = this.getGasOracleFormatted(); const formattedGas = this.getGasOracleFormatted();
if (!formattedGas.length) { if (!formattedGas.length) {
return 'Too few blocks'; return -1;
} }
return this.getGasOracleFormatted()[this.state.gasOracleSliderIndex].gasPrice / this.PRICE_UNIT_DIVIDER; return this.getGasOracleFormatted()[this.state.gasOracleSliderIndex].gasPrice / this.PRICE_UNIT_DIVIDER;
} }

View File

@ -20,7 +20,7 @@ class GasStationContainer extends Component {
getCurrentGas() { getCurrentGas() {
if (!this.gasStation) { if (!this.gasStation) {
return 'Unavailable'; return -1;
} }
return this.gasStation.getCurrentGas(); return this.gasStation.getCurrentGas();
} }