|
|
@ -20,7 +20,6 @@ module.exports = class txProviderUtils { |
|
|
|
if (err) return cb(err) |
|
|
|
if (err) return cb(err) |
|
|
|
async.waterfall([ |
|
|
|
async.waterfall([ |
|
|
|
self.estimateTxGas.bind(self, txData, block.gasLimit), |
|
|
|
self.estimateTxGas.bind(self, txData, block.gasLimit), |
|
|
|
self.checkForTxGasError.bind(self, txData), |
|
|
|
|
|
|
|
self.setTxGas.bind(self, txData, block.gasLimit), |
|
|
|
self.setTxGas.bind(self, txData, block.gasLimit), |
|
|
|
], cb) |
|
|
|
], cb) |
|
|
|
}) |
|
|
|
}) |
|
|
@ -38,22 +37,10 @@ module.exports = class txProviderUtils { |
|
|
|
this.query.estimateGas(txParams, cb) |
|
|
|
this.query.estimateGas(txParams, cb) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
checkForTxGasError (txData, estimatedGasHex, cb) { |
|
|
|
setTxGas (txData, blockGasLimitHex, estimatedGasHex, cb) { |
|
|
|
txData.estimatedGas = estimatedGasHex |
|
|
|
txData.estimatedGas = estimatedGasHex |
|
|
|
// all gas used - must be an error
|
|
|
|
|
|
|
|
if (estimatedGasHex === txData.txParams.gas) { |
|
|
|
|
|
|
|
txData.simulationFails = true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
cb() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setTxGas (txData, blockGasLimitHex, cb) { |
|
|
|
|
|
|
|
const txParams = txData.txParams |
|
|
|
const txParams = txData.txParams |
|
|
|
// if OOG, nothing more to do
|
|
|
|
|
|
|
|
if (txData.simulationFails) { |
|
|
|
|
|
|
|
cb() |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// if gasLimit was specified and doesnt OOG,
|
|
|
|
// if gasLimit was specified and doesnt OOG,
|
|
|
|
// use original specified amount
|
|
|
|
// use original specified amount
|
|
|
|
if (txData.gasLimitSpecified) { |
|
|
|
if (txData.gasLimitSpecified) { |
|
|
|