mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +01:00
Query for gas estimates
This commit is contained in:
parent
4f106854ba
commit
67ee5b21e6
@ -74,8 +74,8 @@
|
||||
"end-of-stream": "^1.1.0",
|
||||
"ensnare": "^1.0.0",
|
||||
"eth-bin-to-ops": "^1.0.1",
|
||||
"eth-contract-metadata": "^1.1.5",
|
||||
"eth-block-tracker": "^2.2.0",
|
||||
"eth-contract-metadata": "^1.1.5",
|
||||
"eth-hd-keyring": "^1.1.1",
|
||||
"eth-json-rpc-filters": "^1.2.1",
|
||||
"eth-keyring-controller": "^2.0.0",
|
||||
@ -84,6 +84,7 @@
|
||||
"eth-sig-util": "^1.2.2",
|
||||
"eth-simple-keyring": "^1.1.1",
|
||||
"eth-token-tracker": "^1.1.4",
|
||||
"ethereumjs-abi": "^0.6.4",
|
||||
"ethereumjs-tx": "^1.3.0",
|
||||
"ethereumjs-util": "github:ethereumjs/ethereumjs-util#ac5d0908536b447083ea422b435da27f26615de9",
|
||||
"ethereumjs-wallet": "^0.6.0",
|
||||
@ -216,8 +217,8 @@
|
||||
"react-addons-test-utils": "^15.5.1",
|
||||
"react-test-renderer": "^15.5.4",
|
||||
"react-testutils-additions": "^15.2.0",
|
||||
"stylelint-config-standard": "^17.0.0",
|
||||
"sinon": "^4.0.0",
|
||||
"stylelint-config-standard": "^17.0.0",
|
||||
"tape": "^4.5.1",
|
||||
"testem": "^1.10.3",
|
||||
"uglifyify": "^4.0.2",
|
||||
|
@ -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)
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -397,7 +397,7 @@ async-eventemitter@^0.2.2:
|
||||
dependencies:
|
||||
async "^2.4.0"
|
||||
|
||||
"async-eventemitter@github:ahultgren/async-eventemitter#fa06e39e56786ba541c180061dbf2c0a5bbf951c":
|
||||
async-eventemitter@ahultgren/async-eventemitter#fa06e39e56786ba541c180061dbf2c0a5bbf951c:
|
||||
version "0.2.3"
|
||||
resolved "https://codeload.github.com/ahultgren/async-eventemitter/tar.gz/fa06e39e56786ba541c180061dbf2c0a5bbf951c"
|
||||
dependencies:
|
||||
@ -3510,6 +3510,13 @@ ethereum-ens-network-map@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/ethereum-ens-network-map/-/ethereum-ens-network-map-1.0.0.tgz#43cd7669ce950a789e151001118d4d65f210eeb7"
|
||||
|
||||
ethereumjs-abi@^0.6.4:
|
||||
version "0.6.4"
|
||||
resolved "https://registry.yarnpkg.com/ethereumjs-abi/-/ethereumjs-abi-0.6.4.tgz#9ba1bb056492d00c27279f6eccd4d58275912c1a"
|
||||
dependencies:
|
||||
bn.js "^4.10.0"
|
||||
ethereumjs-util "^4.3.0"
|
||||
|
||||
"ethereumjs-abi@git+https://github.com/ethereumjs/ethereumjs-abi.git":
|
||||
version "0.6.4"
|
||||
resolved "git+https://github.com/ethereumjs/ethereumjs-abi.git#ee6ded67235a98f3ef4ae2a338aee70a9f68fe20"
|
||||
|
Loading…
Reference in New Issue
Block a user