diff options
author | Chi Kei Chan <chikeichan@gmail.com> | 2017-09-29 08:39:53 +0800 |
---|---|---|
committer | Chi Kei Chan <chikeichan@gmail.com> | 2017-09-29 08:39:53 +0800 |
commit | 67ee5b21e6f64ac22e65f2712ae13dd8c09ed113 (patch) | |
tree | e422bcdec00cc0e921f37cad39223b6ef2e1828b /ui | |
parent | 4f106854ba6bbfd22b49598f9ef019aa620f5b4f (diff) | |
download | tangerine-wallet-browser-67ee5b21e6f64ac22e65f2712ae13dd8c09ed113.tar tangerine-wallet-browser-67ee5b21e6f64ac22e65f2712ae13dd8c09ed113.tar.gz tangerine-wallet-browser-67ee5b21e6f64ac22e65f2712ae13dd8c09ed113.tar.bz2 tangerine-wallet-browser-67ee5b21e6f64ac22e65f2712ae13dd8c09ed113.tar.lz tangerine-wallet-browser-67ee5b21e6f64ac22e65f2712ae13dd8c09ed113.tar.xz tangerine-wallet-browser-67ee5b21e6f64ac22e65f2712ae13dd8c09ed113.tar.zst tangerine-wallet-browser-67ee5b21e6f64ac22e65f2712ae13dd8c09ed113.zip |
Query for gas estimates
Diffstat (limited to 'ui')
-rw-r--r-- | ui/app/actions.js | 4 | ||||
-rw-r--r-- | ui/app/components/send-token/index.js | 18 | ||||
-rw-r--r-- | ui/app/send.js | 7 |
3 files changed, 24 insertions, 5 deletions
diff --git a/ui/app/actions.js b/ui/app/actions.js index 0b860ee63..ff3240abf 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -453,10 +453,10 @@ function signTx (txData) { } } -function estimateGas () { +function estimateGas (params = {}) { return (dispatch) => { return new Promise((resolve, reject) => { - global.ethQuery.estimateGas({}, (err, data) => { + global.ethQuery.estimateGas(params, (err, data) => { if (err) { dispatch(actions.displayWarning(err.message)) return reject(err) diff --git a/ui/app/components/send-token/index.js b/ui/app/components/send-token/index.js index 6e4c909be..a95a0a6d8 100644 --- a/ui/app/components/send-token/index.js +++ b/ui/app/components/send-token/index.js @@ -2,6 +2,7 @@ const Component = require('react').Component const connect = require('react-redux').connect const h = require('react-hyperscript') const classnames = require('classnames') +const abi = require('ethereumjs-abi') const inherits = require('util').inherits const actions = require('../../actions') const selectors = require('../../selectors') @@ -57,7 +58,7 @@ function mapDispatchToProps (dispatch) { dispatch(actions.signTokenTx(tokenAddress, toAddress, amount, txData)) ), updateTokenExchangeRate: token => dispatch(actions.updateTokenExchangeRate(token)), - estimateGas: () => dispatch(actions.estimateGas()), + estimateGas: params => dispatch(actions.estimateGas(params)), getGasPrice: () => dispatch(actions.getGasPrice()), } } @@ -83,15 +84,28 @@ SendTokenScreen.prototype.componentWillMount = function () { selectedToken: { symbol }, getGasPrice, estimateGas, + selectedAddress, } = this.props updateTokenExchangeRate(symbol) + const data = Array.prototype.map.call( + abi.rawEncode(['address', 'uint256'], [selectedAddress, '0x0']), + x => ('00' + x.toString(16)).slice(-2) + ).join('') + + console.log(data) Promise.all([ getGasPrice(), - estimateGas(), + estimateGas({ + from: selectedAddress, + value: '0x0', + gas: '746a528800', + data, + }), ]) .then(([blockGasPrice, estimatedGas]) => { + console.log({ blockGasPrice, estimatedGas}) this.setState({ gasPrice: blockGasPrice, gasLimit: estimatedGas, diff --git a/ui/app/send.js b/ui/app/send.js index d92a6f2d5..2e6409f32 100644 --- a/ui/app/send.js +++ b/ui/app/send.js @@ -100,12 +100,17 @@ function SendTransactionScreen () { SendTransactionScreen.prototype.componentWillMount = function () { const { newTx } = this.state + const { address } = this.props Promise.all([ this.props.dispatch(getGasPrice()), - this.props.dispatch(estimateGas()), + this.props.dispatch(estimateGas({ + from: address, + gas: '746a528800', + })), ]) .then(([blockGasPrice, estimatedGas]) => { + console.log({ blockGasPrice, estimatedGas}) this.setState({ newTx: { ...newTx, |