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/components | |
parent | 25c2865076784f3e5346f7e34cbf80b9fe210ade (diff) | |
download | tangerine-wallet-browser-541b69dda9a5ddbb0ea4e4c0df805e886f53645c.tar.gz 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/components')
-rw-r--r-- | ui/app/components/send-token/index.js | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/ui/app/components/send-token/index.js b/ui/app/components/send-token/index.js index 379f63883..02423a348 100644 --- a/ui/app/components/send-token/index.js +++ b/ui/app/components/send-token/index.js @@ -57,9 +57,8 @@ function mapDispatchToProps (dispatch) { dispatch(actions.signTokenTx(tokenAddress, toAddress, amount, txData)) ), updateTokenExchangeRate: token => dispatch(actions.updateTokenExchangeRate(token)), - estimateGas: ({ to, amount }) => dispatch(actions.estimateGas({ to, amount })), + estimateGas: () => dispatch(actions.estimateGas()), getGasPrice: () => dispatch(actions.getGasPrice()), - } } @@ -82,27 +81,22 @@ SendTokenScreen.prototype.componentWillMount = function () { const { updateTokenExchangeRate, selectedToken: { symbol }, + getGasPrice, + estimateGas, } = this.props updateTokenExchangeRate(symbol) -} -SendTokenScreen.prototype.estimateGasAndPrice = function () { - const { selectedToken } = this.props - const { errors, amount, to } = this.state - - if (!errors.to && !errors.amount && amount > 0) { - Promise.all([ - this.props.getGasPrice(), - this.props.estimateGas({ to, amount: this.getAmountToSend(amount, selectedToken) }), - ]) - .then(([blockGasPrice, estimatedGas]) => { - this.setState({ - blockGasPrice, - estimatedGas, - }) + Promise.all([ + getGasPrice(), + estimateGas(), + ]) + .then(([blockGasPrice, estimatedGas]) => { + this.setState({ + blockGasPrice, + estimatedGas, }) - } + }) } SendTokenScreen.prototype.validate = function () { @@ -238,7 +232,6 @@ SendTokenScreen.prototype.renderToAddressInput = function () { }), onBlur: () => { this.setErrorsFor('to') - this.estimateGasAndPrice() }, onFocus: event => { if (to) event.target.select() @@ -300,7 +293,6 @@ SendTokenScreen.prototype.renderAmountInput = function () { }), onBlur: () => { this.setErrorsFor('amount') - this.estimateGasAndPrice() }, onFocus: () => this.clearErrorsFor('amount'), }), |