mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +01:00
Add stack traces both in errors and as a way to track txMetas
This commit is contained in:
parent
9b24ab0e70
commit
ab01358a48
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
## Current Master
|
## Current Master
|
||||||
|
|
||||||
|
- Include stack traces in txMeta's to better understand the life cycle of transactions
|
||||||
|
|
||||||
## 3.9.1 2017-7-19
|
## 3.9.1 2017-7-19
|
||||||
|
|
||||||
- No longer automatically request 1 ropsten ether for the first account in a new vault.
|
- No longer automatically request 1 ropsten ether for the first account in a new vault.
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
const EventEmitter = require('events')
|
const EventEmitter = require('events')
|
||||||
const async = require('async')
|
const async = require('async')
|
||||||
const extend = require('xtend')
|
const extend = require('xtend')
|
||||||
|
const clone = require('deep-clone')
|
||||||
const ObservableStore = require('obs-store')
|
const ObservableStore = require('obs-store')
|
||||||
const ethUtil = require('ethereumjs-util')
|
const ethUtil = require('ethereumjs-util')
|
||||||
const pify = require('pify')
|
const pify = require('pify')
|
||||||
const TxProviderUtil = require('../lib/tx-utils')
|
const TxProviderUtil = require('../lib/tx-utils')
|
||||||
|
const getStack = require('../lib/util').getStack
|
||||||
const createId = require('../lib/random-id')
|
const createId = require('../lib/random-id')
|
||||||
const NonceTracker = require('../lib/nonce-tracker')
|
const NonceTracker = require('../lib/nonce-tracker')
|
||||||
|
|
||||||
@ -117,9 +119,14 @@ module.exports = class TransactionController extends EventEmitter {
|
|||||||
|
|
||||||
//
|
//
|
||||||
updateTx (txMeta) {
|
updateTx (txMeta) {
|
||||||
|
const txMetaForHistory = clone(txMeta)
|
||||||
|
txMetaForHistory.stack = getStack()
|
||||||
var txId = txMeta.id
|
var txId = txMeta.id
|
||||||
var txList = this.getFullTxList()
|
var txList = this.getFullTxList()
|
||||||
var index = txList.findIndex(txData => txData.id === txId)
|
var index = txList.findIndex(txData => txData.id === txId)
|
||||||
|
if (!txMeta.history) txMeta.history = []
|
||||||
|
txMeta.history.push(txMetaForHistory)
|
||||||
|
|
||||||
txList[index] = txMeta
|
txList[index] = txMeta
|
||||||
this._saveTxList(txList)
|
this._saveTxList(txList)
|
||||||
this.emit('update')
|
this.emit('update')
|
||||||
@ -134,7 +141,7 @@ module.exports = class TransactionController extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addUnapprovedTransaction (txParams, done) {
|
addUnapprovedTransaction (txParams, done) {
|
||||||
let txMeta
|
let txMeta = {}
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
// validate
|
// validate
|
||||||
(cb) => this.txProviderUtils.validateTxParams(txParams, cb),
|
(cb) => this.txProviderUtils.validateTxParams(txParams, cb),
|
||||||
@ -146,6 +153,7 @@ module.exports = class TransactionController extends EventEmitter {
|
|||||||
status: 'unapproved',
|
status: 'unapproved',
|
||||||
metamaskNetworkId: this.getNetwork(),
|
metamaskNetworkId: this.getNetwork(),
|
||||||
txParams: txParams,
|
txParams: txParams,
|
||||||
|
history: [],
|
||||||
}
|
}
|
||||||
cb()
|
cb()
|
||||||
},
|
},
|
||||||
@ -165,6 +173,7 @@ module.exports = class TransactionController extends EventEmitter {
|
|||||||
txParams.value = txParams.value || '0x0'
|
txParams.value = txParams.value || '0x0'
|
||||||
if (!txParams.gasPrice) {
|
if (!txParams.gasPrice) {
|
||||||
this.query.gasPrice((err, gasPrice) => {
|
this.query.gasPrice((err, gasPrice) => {
|
||||||
|
|
||||||
if (err) return cb(err)
|
if (err) return cb(err)
|
||||||
// set gasPrice
|
// set gasPrice
|
||||||
txParams.gasPrice = gasPrice
|
txParams.gasPrice = gasPrice
|
||||||
@ -201,6 +210,7 @@ module.exports = class TransactionController extends EventEmitter {
|
|||||||
nonceLock.releaseLock()
|
nonceLock.releaseLock()
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.setTxStatusFailed(txId, {
|
this.setTxStatusFailed(txId, {
|
||||||
|
stack: err.stack || err.message,
|
||||||
errCode: err.errCode || err,
|
errCode: err.errCode || err,
|
||||||
message: err.message || 'Transaction failed during approval',
|
message: err.message || 'Transaction failed during approval',
|
||||||
})
|
})
|
||||||
@ -364,11 +374,11 @@ module.exports = class TransactionController extends EventEmitter {
|
|||||||
var txId = txMeta.id
|
var txId = txMeta.id
|
||||||
|
|
||||||
if (!txHash) {
|
if (!txHash) {
|
||||||
const errReason = {
|
return this.setTxStatusFailed(txId, {
|
||||||
|
stack: 'checkForTxInBlock: custom tx-controller error message Line# 368',
|
||||||
errCode: 'No hash was provided',
|
errCode: 'No hash was provided',
|
||||||
message: 'We had an error while submitting this transaction, please try again.',
|
message: 'We had an error while submitting this transaction, please try again.',
|
||||||
}
|
})
|
||||||
return this.setTxStatusFailed(txId, errReason)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
block.transactions.forEach((tx) => {
|
block.transactions.forEach((tx) => {
|
||||||
@ -452,6 +462,7 @@ module.exports = class TransactionController extends EventEmitter {
|
|||||||
if (isKnownTx) return
|
if (isKnownTx) return
|
||||||
// encountered real error - transition to error state
|
// encountered real error - transition to error state
|
||||||
this.setTxStatusFailed(txMeta.id, {
|
this.setTxStatusFailed(txMeta.id, {
|
||||||
|
stack: err.stack || err.message,
|
||||||
errCode: err.errCode || err,
|
errCode: err.errCode || err,
|
||||||
message: err.message,
|
message: err.message,
|
||||||
})
|
})
|
||||||
@ -466,7 +477,10 @@ module.exports = class TransactionController extends EventEmitter {
|
|||||||
// if the value of the transaction is greater then the balance, fail.
|
// if the value of the transaction is greater then the balance, fail.
|
||||||
if (!this.txProviderUtils.sufficientBalance(txMeta.txParams, balance)) {
|
if (!this.txProviderUtils.sufficientBalance(txMeta.txParams, balance)) {
|
||||||
const message = 'Insufficient balance.'
|
const message = 'Insufficient balance.'
|
||||||
this.setTxStatusFailed(txMeta.id, { message })
|
this.setTxStatusFailed(txMeta.id, {
|
||||||
|
stack: '_resubnitTx: custom tx-controller error line# 472',
|
||||||
|
message,
|
||||||
|
})
|
||||||
cb()
|
cb()
|
||||||
return log.error(message)
|
return log.error(message)
|
||||||
}
|
}
|
||||||
@ -501,11 +515,11 @@ module.exports = class TransactionController extends EventEmitter {
|
|||||||
// extra check in case there was an uncaught error during the
|
// extra check in case there was an uncaught error during the
|
||||||
// signature and submission process
|
// signature and submission process
|
||||||
if (!txHash) {
|
if (!txHash) {
|
||||||
const errReason = {
|
this.setTxStatusFailed(txId, {
|
||||||
|
stack: '_checkPendingTxs: custom tx-controller error message Line# 510',
|
||||||
errCode: 'No hash was provided',
|
errCode: 'No hash was provided',
|
||||||
message: 'We had an error while submitting this transaction, please try again.',
|
message: 'We had an error while submitting this transaction, please try again.',
|
||||||
}
|
})
|
||||||
this.setTxStatusFailed(txId, errReason)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// get latest transaction status
|
// get latest transaction status
|
||||||
|
8
app/scripts/lib/util.js
Normal file
8
app/scripts/lib/util.js
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
module.exports = {
|
||||||
|
getStack,
|
||||||
|
}
|
||||||
|
|
||||||
|
function getStack () {
|
||||||
|
const stack = new Error('Stack trace generator - not an error').stack
|
||||||
|
return stack
|
||||||
|
}
|
@ -57,6 +57,7 @@
|
|||||||
"clone": "^1.0.2",
|
"clone": "^1.0.2",
|
||||||
"copy-to-clipboard": "^2.0.0",
|
"copy-to-clipboard": "^2.0.0",
|
||||||
"debounce": "^1.0.0",
|
"debounce": "^1.0.0",
|
||||||
|
"deep-clone": "^3.0.2",
|
||||||
"deep-extend": "^0.4.1",
|
"deep-extend": "^0.4.1",
|
||||||
"detect-node": "^2.0.3",
|
"detect-node": "^2.0.3",
|
||||||
"disc": "^1.3.2",
|
"disc": "^1.3.2",
|
||||||
|
Loading…
Reference in New Issue
Block a user