aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/send.js
diff options
context:
space:
mode:
authorDan <danjm.com@gmail.com>2017-09-26 07:30:32 +0800
committerDan <danjm.com@gmail.com>2017-09-26 08:24:55 +0800
commit79bcb88db3946260c832402d97e0c800cdeba5a9 (patch)
tree26c3a2e562850a9a266177e77c5a57a4a47b8332 /ui/app/send.js
parent88c4226bf1dca8647a45f3921396daaa88bbf939 (diff)
downloadtangerine-wallet-browser-79bcb88db3946260c832402d97e0c800cdeba5a9.tar
tangerine-wallet-browser-79bcb88db3946260c832402d97e0c800cdeba5a9.tar.gz
tangerine-wallet-browser-79bcb88db3946260c832402d97e0c800cdeba5a9.tar.bz2
tangerine-wallet-browser-79bcb88db3946260c832402d97e0c800cdeba5a9.tar.lz
tangerine-wallet-browser-79bcb88db3946260c832402d97e0c800cdeba5a9.tar.xz
tangerine-wallet-browser-79bcb88db3946260c832402d97e0c800cdeba5a9.tar.zst
tangerine-wallet-browser-79bcb88db3946260c832402d97e0c800cdeba5a9.zip
Refactor to store estimated gas and price in local state, return promise from actions.
Diffstat (limited to 'ui/app/send.js')
-rw-r--r--ui/app/send.js37
1 files changed, 20 insertions, 17 deletions
diff --git a/ui/app/send.js b/ui/app/send.js
index 4ce7fc475..033692910 100644
--- a/ui/app/send.js
+++ b/ui/app/send.js
@@ -18,8 +18,6 @@ const {
signTx,
estimateGas,
getGasPrice,
- clearGasEstimate,
- clearGasPrice,
} = require('./actions')
const { stripHexPrefix, addHexPrefix } = require('ethereumjs-util')
const { isHex, numericBalance, isValidAddress, allNull } = require('./util')
@@ -52,8 +50,6 @@ function mapStateToProps (state) {
addressBook,
conversionRate,
blockGasLimit,
- blockGasPrice,
- estimatedGas,
warning,
selectedIdentity,
error: warning && warning.split('.')[0],
@@ -73,16 +69,15 @@ function SendTransactionScreen () {
newTx: {
from: '',
to: '',
- amount: 0,
amountToSend: '0x0',
gasPrice: null,
gas: null,
amount: '0x0',
- gasPrice: null,
- gas: null,
txData: null,
memo: '',
},
+ blockGasPrice: null,
+ estimatedGas: null,
activeCurrency: 'USD',
tooltipIsOpen: false,
errors: {},
@@ -108,11 +103,6 @@ function SendTransactionScreen () {
this.renderErrorMessage = this.renderErrorMessage.bind(this)
}
-SendTransactionScreen.prototype.componentWillMount = function() {
- this.props.dispatch(clearGasEstimate())
- this.props.dispatch(clearGasPrice())
-}
-
SendTransactionScreen.prototype.renderErrorMessage = function(errorType, warning) {
const { errors } = this.state
const errorMessage = errors[errorType];
@@ -316,11 +306,16 @@ SendTransactionScreen.prototype.render = function () {
identities,
addressBook,
conversionRate,
- estimatedGas,
- blockGasPrice,
} = props
- const { blockGasLimit, newTx, activeCurrency, isValid } = this.state
+ const {
+ blockGasLimit,
+ newTx,
+ activeCurrency,
+ isValid,
+ blockGasPrice,
+ estimatedGas,
+ } = this.state
const { gas, gasPrice } = newTx
return (
@@ -386,8 +381,16 @@ SendTransactionScreen.prototype.estimateGasAndPrice = function () {
const { errors, sendAmount, newTx } = this.state
if (!errors.to && !errors.amount && newTx.amount > 0) {
- this.props.dispatch(getGasPrice())
- this.props.dispatch(estimateGas({ to: newTx.to, amount: sendAmount }))
+ Promise.all([
+ this.props.dispatch(getGasPrice()),
+ this.props.dispatch(estimateGas({ to: newTx.to, amount: sendAmount })),
+ ])
+ .then(([blockGasPrice, estimatedGas]) => {
+ this.setState({
+ blockGasPrice,
+ estimatedGas,
+ })
+ })
}
}