From 39365f2cc419ee824988e6dad4e8a75e650ad1cc Mon Sep 17 00:00:00 2001 From: Dan Date: Tue, 26 Sep 2017 23:03:03 -0230 Subject: [PATCH] Update the correct values in state when estimates are received. --- ui/app/components/send-token/index.js | 14 ++++++-------- ui/app/send.js | 19 +++++++++---------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/ui/app/components/send-token/index.js b/ui/app/components/send-token/index.js index 02423a348..8a827e951 100644 --- a/ui/app/components/send-token/index.js +++ b/ui/app/components/send-token/index.js @@ -93,8 +93,8 @@ SendTokenScreen.prototype.componentWillMount = function () { ]) .then(([blockGasPrice, estimatedGas]) => { this.setState({ - blockGasPrice, - estimatedGas, + gasPrice: blockGasPrice, + gasLimit: estimatedGas, }) }) } @@ -305,8 +305,6 @@ SendTokenScreen.prototype.renderGasInput = function () { isGasTooltipOpen, gasPrice, gasLimit, - blockGasPrice, - estimatedGas, selectedCurrency, errors: { gasPrice: gasPriceErrorMessage, @@ -327,8 +325,8 @@ SendTokenScreen.prototype.renderGasInput = function () { }, [ isGasTooltipOpen && h(GasTooltip, { className: 'send-tooltip', - gasPrice: gasPrice || blockGasPrice || '0x0', - gasLimit: gasLimit || estimatedGas || '0x0', + gasPrice: gasPrice || '0x0', + gasLimit: gasLimit || '0x0', onClose: () => this.setState({ isGasTooltipOpen: false }), onFeeChange: ({ gasLimit, gasPrice }) => { this.setState({ gasLimit, gasPrice, errors: {} }) @@ -351,9 +349,9 @@ SendTokenScreen.prototype.renderGasInput = function () { h(GasFeeDisplay, { conversionRate, tokenExchangeRate, - gasPrice: gasPrice || blockGasPrice || '0x0', + gasPrice: gasPrice || '0x0', activeCurrency: selectedCurrency, - gas: gasLimit || estimatedGas || '0x0', + gas: gasLimit || '0x0', blockGasLimit: currentBlockGasLimit, }), h( diff --git a/ui/app/send.js b/ui/app/send.js index dc7e7c8ec..4d2a5f48d 100644 --- a/ui/app/send.js +++ b/ui/app/send.js @@ -35,8 +35,6 @@ function mapStateToProps (state) { addressBook, conversionRate, currentBlockGasLimit: blockGasLimit, - estimatedGas, - blockGasPrice, } = state.metamask const { warning } = state.appState const selectedIdentity = getSelectedIdentity(state) @@ -76,8 +74,6 @@ function SendTransactionScreen () { txData: null, memo: '', }, - blockGasPrice: null, - estimatedGas: null, activeCurrency: 'USD', tooltipIsOpen: false, errors: {}, @@ -103,14 +99,19 @@ function SendTransactionScreen () { } SendTransactionScreen.prototype.componentWillMount = function () { + const { newTx } = this.state + Promise.all([ this.props.dispatch(getGasPrice()), this.props.dispatch(estimateGas()), ]) .then(([blockGasPrice, estimatedGas]) => { this.setState({ - blockGasPrice, - estimatedGas, + newTx: { + ...newTx, + gasPrice: blockGasPrice, + gas: estimatedGas, + }, }) }) } @@ -329,8 +330,6 @@ SendTransactionScreen.prototype.render = function () { newTx, activeCurrency, isValid, - blockGasPrice, - estimatedGas, } = this.state const { gas, gasPrice } = newTx @@ -353,8 +352,8 @@ SendTransactionScreen.prototype.render = function () { this.renderAmountInput(activeCurrency), this.renderGasInput( - gasPrice || blockGasPrice || '0x0', - gas || estimatedGas || '0x0', + gasPrice || '0x0', + gas || '0x0', activeCurrency, conversionRate, blockGasLimit