aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2016-11-30 04:44:42 +0800
committerDan Finlay <dan@danfinlay.com>2016-11-30 04:46:08 +0800
commit85d5b12f8dd4029bf93a7fb0b5f65b306cbaaa3c (patch)
treed9ffe94bc8126b74d471d814e4667bf72e19aa6f /app
parent4b6b1db4f0fddfe3a640656311a58429ed48753c (diff)
downloadtangerine-wallet-browser-85d5b12f8dd4029bf93a7fb0b5f65b306cbaaa3c.tar
tangerine-wallet-browser-85d5b12f8dd4029bf93a7fb0b5f65b306cbaaa3c.tar.gz
tangerine-wallet-browser-85d5b12f8dd4029bf93a7fb0b5f65b306cbaaa3c.tar.bz2
tangerine-wallet-browser-85d5b12f8dd4029bf93a7fb0b5f65b306cbaaa3c.tar.lz
tangerine-wallet-browser-85d5b12f8dd4029bf93a7fb0b5f65b306cbaaa3c.tar.xz
tangerine-wallet-browser-85d5b12f8dd4029bf93a7fb0b5f65b306cbaaa3c.tar.zst
tangerine-wallet-browser-85d5b12f8dd4029bf93a7fb0b5f65b306cbaaa3c.zip
Fix tx adding code
Broken in this commit: https://github.com/MetaMask/metamask-plugin/commit/bc39cd7b894ddf0f3724d4af3cfc30c2638e0939 Synchronous methods were added to an `async.waterfall` array. This commit also removes the delegate call checking, since we concluded it was misinformed.
Diffstat (limited to 'app')
-rw-r--r--app/scripts/keyring-controller.js28
1 files changed, 3 insertions, 25 deletions
diff --git a/app/scripts/keyring-controller.js b/app/scripts/keyring-controller.js
index e6a69d9ed..0045890be 100644
--- a/app/scripts/keyring-controller.js
+++ b/app/scripts/keyring-controller.js
@@ -1,7 +1,6 @@
const async = require('async')
const bind = require('ap').partial
const ethUtil = require('ethereumjs-util')
-const ethBinToOps = require('eth-bin-to-ops')
const EthQuery = require('eth-query')
const bip39 = require('bip39')
const Transaction = require('ethereumjs-tx')
@@ -369,30 +368,9 @@ module.exports = class KeyringController extends EventEmitter {
// calculate metadata for tx
async.parallel([
- analyzeForDelegateCall,
analyzeGasUsage,
], didComplete)
- // perform static analyis on the target contract code
- function analyzeForDelegateCall (cb) {
- if (txParams.to) {
- query.getCode(txParams.to, function (err, result) {
- if (err) return cb(err)
- var code = ethUtil.toBuffer(result)
- if (code !== '0x') {
- var ops = ethBinToOps(code)
- var containsDelegateCall = ops.some((op) => op.name === 'DELEGATECALL')
- txData.containsDelegateCall = containsDelegateCall
- cb()
- } else {
- cb()
- }
- })
- } else {
- cb()
- }
- }
-
function analyzeGasUsage (cb) {
query.getBlockByNumber('latest', true, function (err, block) {
if (err) return cb(err)
@@ -416,7 +394,7 @@ module.exports = class KeyringController extends EventEmitter {
query.estimateGas(txParams, cb)
}
- function checkForGasError (txData, estimatedGasHex) {
+ function checkForGasError (txData, estimatedGasHex, cb) {
txData.estimatedGas = estimatedGasHex
// all gas used - must be an error
if (estimatedGasHex === txData.txParams.gas) {
@@ -425,7 +403,7 @@ module.exports = class KeyringController extends EventEmitter {
cb()
}
- function setTxGas (txData, blockGasLimitHex) {
+ function setTxGas (txData, blockGasLimitHex, cb) {
const txParams = txData.txParams
// if OOG, nothing more to do
if (txData.simulationFails) {
@@ -443,7 +421,7 @@ module.exports = class KeyringController extends EventEmitter {
// try adding an additional gas buffer to our estimation for safety
const estimatedGasBn = new BN(ethUtil.stripHexPrefix(txData.estimatedGas), 16)
const blockGasLimitBn = new BN(ethUtil.stripHexPrefix(blockGasLimitHex), 16)
- const estimationWithBuffer = self.addGasBuffer(estimatedGasBn)
+ const estimationWithBuffer = new BN(self.addGasBuffer(estimatedGasBn), 16)
// added gas buffer is too high
if (estimationWithBuffer.gt(blockGasLimitBn)) {
txParams.gas = txData.estimatedGas