diff --git a/common/components/TXMetaDataPanel/components/SimpleGas.tsx b/common/components/TXMetaDataPanel/components/SimpleGas.tsx index 5469b29c..f8686da6 100644 --- a/common/components/TXMetaDataPanel/components/SimpleGas.tsx +++ b/common/components/TXMetaDataPanel/components/SimpleGas.tsx @@ -40,14 +40,22 @@ interface ActionProps { type Props = OwnProps & StateProps & ActionProps; +interface State { + hasSetRecommendedGasPrice: boolean; +} + class SimpleGas extends React.Component { + public state: State = { + hasSetRecommendedGasPrice: false + }; + public componentDidMount() { - this.fixGasPrice(); this.props.fetchGasEstimates(); } public componentWillReceiveProps(nextProps: Props) { - if (!this.props.gasEstimates && nextProps.gasEstimates) { + if (!this.state.hasSetRecommendedGasPrice && nextProps.gasEstimates) { + this.setState({ hasSetRecommendedGasPrice: true }); this.props.setGasPrice(nextProps.gasEstimates.fast.toString()); } } @@ -121,21 +129,6 @@ class SimpleGas extends React.Component { this.props.inputGasPrice(gasGwei.toString()); }; - private fixGasPrice() { - const { gasPrice, gasEstimates } = this.props; - if (!gasEstimates) { - return; - } - - // If the gas price is above or below our minimum, bring it in line - const gasPriceGwei = this.getGasPriceGwei(gasPrice.value); - if (gasPriceGwei < gasEstimates.safeLow) { - this.props.setGasPrice(gasEstimates.safeLow.toString()); - } else if (gasPriceGwei > gasEstimates.fastest) { - this.props.setGasPrice(gasEstimates.fastest.toString()); - } - } - private getGasPriceGwei(gasPriceValue: Wei) { return parseFloat(fromWei(gasPriceValue, 'gwei')); }