1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 18:00:18 +01:00

Fix tx adding code

Broken in this commit:
bc39cd7b89

Synchronous methods were added to an `async.waterfall` array.

This commit also removes the delegate call checking, since we concluded it was misinformed.
This commit is contained in:
Dan Finlay 2016-11-29 12:44:42 -08:00
parent 4b6b1db4f0
commit 85d5b12f8d
2 changed files with 3 additions and 50 deletions

View File

@ -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

View File

@ -154,8 +154,6 @@ PTXP.render = function () {
]),
]), // End of Table
this.warnIfNeeded(),
])
)
}
@ -201,29 +199,6 @@ PTXP.miniAccountPanelForRecipient = function () {
}
}
// Should analyze if there is a DELEGATECALL opcode
// in the recipient contract, and show a warning if so.
PTXP.warnIfNeeded = function () {
const containsDelegateCall = !!this.props.txData.containsDelegateCall
if (!containsDelegateCall) {
return null
}
return h('span.error', {
style: {
fontFamily: 'Montserrat Light',
fontSize: '13px',
display: 'flex',
justifyContent: 'center',
},
}, [
h('i.fa.fa-lg.fa-info-circle', { style: { margin: '5px' } }),
h('span', ' Your identity may be used in other contracts!'),
])
}
function forwardCarrat () {
return (