diff options
author | Dan <danjm.com@gmail.com> | 2017-09-27 08:21:45 +0800 |
---|---|---|
committer | Chi Kei Chan <chikeichan@gmail.com> | 2017-09-27 09:43:26 +0800 |
commit | 541b69dda9a5ddbb0ea4e4c0df805e886f53645c (patch) | |
tree | 127748f60dd8d195c72f9642a0d3f85aa451576e /ui/app/send.js | |
parent | 25c2865076784f3e5346f7e34cbf80b9fe210ade (diff) | |
download | tangerine-wallet-browser-541b69dda9a5ddbb0ea4e4c0df805e886f53645c.tar tangerine-wallet-browser-541b69dda9a5ddbb0ea4e4c0df805e886f53645c.tar.gz tangerine-wallet-browser-541b69dda9a5ddbb0ea4e4c0df805e886f53645c.tar.bz2 tangerine-wallet-browser-541b69dda9a5ddbb0ea4e4c0df805e886f53645c.tar.lz tangerine-wallet-browser-541b69dda9a5ddbb0ea4e4c0df805e886f53645c.tar.xz tangerine-wallet-browser-541b69dda9a5ddbb0ea4e4c0df805e886f53645c.tar.zst tangerine-wallet-browser-541b69dda9a5ddbb0ea4e4c0df805e886f53645c.zip |
Gets gas and price estimates when send components mount.
Diffstat (limited to 'ui/app/send.js')
-rw-r--r-- | ui/app/send.js | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/ui/app/send.js b/ui/app/send.js index 8791e9124..dc7e7c8ec 100644 --- a/ui/app/send.js +++ b/ui/app/send.js @@ -93,7 +93,6 @@ function SendTransactionScreen () { this.getAmountToSend = this.getAmountToSend.bind(this) this.setErrorsFor = this.setErrorsFor.bind(this) this.clearErrorsFor = this.clearErrorsFor.bind(this) - this.estimateGasAndPrice = this.estimateGasAndPrice.bind(this) this.renderFromInput = this.renderFromInput.bind(this) this.renderToInput = this.renderToInput.bind(this) @@ -103,6 +102,19 @@ function SendTransactionScreen () { this.renderErrorMessage = this.renderErrorMessage.bind(this) } +SendTransactionScreen.prototype.componentWillMount = function () { + Promise.all([ + this.props.dispatch(getGasPrice()), + this.props.dispatch(estimateGas()), + ]) + .then(([blockGasPrice, estimatedGas]) => { + this.setState({ + blockGasPrice, + estimatedGas, + }) + }) +} + SendTransactionScreen.prototype.renderErrorMessage = function(errorType, warning) { const { errors } = this.state const errorMessage = errors[errorType]; @@ -171,7 +183,6 @@ SendTransactionScreen.prototype.renderToInput = function (to, identities, addres }, onBlur: () => { this.setErrorsFor('to') - this.estimateGasAndPrice() }, onFocus: event => { this.clearErrorsFor('to') @@ -230,7 +241,6 @@ SendTransactionScreen.prototype.renderAmountInput = function (activeCurrency) { }, onBlur: () => { this.setErrorsFor('amount') - this.estimateGasAndPrice() }, onFocus: () => this.clearErrorsFor('amount'), }), @@ -383,23 +393,6 @@ SendTransactionScreen.prototype.setActiveCurrency = function (newCurrency) { this.setState({ activeCurrency: newCurrency }) } -SendTransactionScreen.prototype.estimateGasAndPrice = function () { - const { errors, sendAmount, newTx } = this.state - - if (!errors.to && !errors.amount && newTx.amount > 0) { - Promise.all([ - this.props.dispatch(getGasPrice()), - this.props.dispatch(estimateGas({ to: newTx.to, amount: sendAmount })), - ]) - .then(([blockGasPrice, estimatedGas]) => { - this.setState({ - blockGasPrice, - estimatedGas, - }) - }) - } -} - SendTransactionScreen.prototype.back = function () { var address = this.props.address this.props.dispatch(backToAccountDetail(address)) |