Make SimpleGas default to recommended gas price on initial load (#2020)

* Add a check to make sure a network even exists on the web3Wallet instance

* Format snap files

* Prevent onChange from firing due to being out-of-bounds
This commit is contained in:
Connor Bryan 2018-07-06 14:07:34 -05:00 committed by Daniel Ternyak
parent 7ce2f72b8e
commit 062d25145c
1 changed files with 11 additions and 1 deletions

View File

@ -76,6 +76,16 @@ class SimpleGas extends React.Component<Props> {
min: gasEstimates ? gasEstimates.safeLow : gasPriceDefaults.min
};
/**
* @desc On retrieval of gas estimates,
* the current gas price may be lower than the lowest recommended price.
* `rc-slider` will force the onChange if the value is too low, so we
* ensure it at least passes the lower boundary.
* When this occurs, the logic in `UNSAFE_componentWillReceiveProps` fires,
* and it cannot happen again from that point forward.
*/
const actualGasPrice = Math.max(this.getGasPriceGwei(gasPrice.value), bounds.min);
return (
<div className="SimpleGas row form-group">
<div className="SimpleGas-title">
@ -103,7 +113,7 @@ class SimpleGas extends React.Component<Props> {
min={bounds.min}
max={bounds.max}
step={bounds.min < 1 ? 0.1 : 1}
value={this.getGasPriceGwei(gasPrice.value)}
value={actualGasPrice}
tipFormatter={this.formatTooltip}
disabled={isGasEstimating}
/>