1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Merge pull request #805 from MetaMask/i804

detect tx error - show warning and fix gasLimit
This commit is contained in:
kumavis 2016-11-11 00:37:09 -05:00 committed by GitHub
commit f88079c6b9
3 changed files with 26 additions and 2 deletions

View File

@ -1,6 +1,7 @@
# Changelog # Changelog
## Current Master ## Current Master
- Show a warning when a transaction fails during simulation.
- Fix bug where 20% of gas estimate was not being added properly. - Fix bug where 20% of gas estimate was not being added properly.
## 2.13.7 2016-11-8 ## 2.13.7 2016-11-8

View File

@ -259,10 +259,24 @@ IdentityStore.prototype.addUnconfirmedTransaction = function (txParams, onTxDone
} }
function estimateGas(cb){ function estimateGas(cb){
query.estimateGas(txParams, function(err, result){ var estimationParams = extend(txParams)
// 1 billion gas for estimation
var gasLimit = '0x3b9aca00'
estimationParams.gas = gasLimit
query.estimateGas(estimationParams, function(err, result){
if (err) return cb(err) if (err) return cb(err)
if (result === estimationParams.gas) {
txData.simulationFails = true
query.getBlockByNumber('latest', true, function(err, block){
if (err) return cb(err)
txData.estimatedGas = block.gasLimit
txData.txParams.gas = block.gasLimit
cb()
})
return
}
txData.estimatedGas = self.addGasBuffer(result) txData.estimatedGas = self.addGasBuffer(result)
txData.txParams.gasLimit = txData.estimatedGas txData.txParams.gas = txData.estimatedGas
cb() cb()
}) })
} }

View File

@ -30,6 +30,15 @@ PendingTx.prototype.render = function () {
} }
`), `),
txData.simulationFails ?
h('span.error', {
style: {
marginLeft: 50,
fontSize: '0.9em',
},
}, 'Transaction Error. Exception thrown in contract code.')
: null,
state.insufficientBalance ? state.insufficientBalance ?
h('span.error', { h('span.error', {
style: { style: {