transactions - put the origing on the txMeta to help with debugging

This commit is contained in:
frankiebee 2018-03-30 15:25:13 -07:00
parent 5ec4286966
commit 03b123a85d
2 changed files with 8 additions and 3 deletions

View File

@ -161,9 +161,11 @@ module.exports = class TransactionController extends EventEmitter {
this.emit(`${txMeta.id}:unapproved`, txMeta)
}
async newUnapprovedTransaction (txParams) {
async newUnapprovedTransaction (txParams, opts = {origin: 'metamask'}) {
log.debug(`MetaMaskController newUnapprovedTransaction ${JSON.stringify(txParams)}`)
const initialTxMeta = await this.addUnapprovedTransaction(txParams)
initialTxMeta.origin = opts.origin
this.txStateManager.updateTx(initialTxMeta, '#newUnapprovedTransaction - adding the origin')
// listen for tx completion (success, fail)
return new Promise((resolve, reject) => {
this.txStateManager.once(`${initialTxMeta.id}:finished`, (finishedTxMeta) => {

View File

@ -57,7 +57,6 @@ module.exports = class MetamaskController extends EventEmitter {
this.defaultMaxListeners = 20
this.sendUpdate = debounce(this.privateSendUpdate.bind(this), 200)
this.opts = opts
const initState = opts.initState || {}
this.recordFirstTimeInfo(initState)
@ -242,6 +241,11 @@ module.exports = class MetamaskController extends EventEmitter {
static: {
eth_syncing: false,
web3_clientVersion: `MetaMask/v${version}`,
eth_sendTransaction: (payload, next, end) => {
const origin = payload.origin
const txParams = payload.params[0]
nodeify(this.txController.newUnapprovedTransaction, this.txController)(txParams, { origin }, end)
},
},
// account mgmt
getAccounts: (cb) => {
@ -256,7 +260,6 @@ module.exports = class MetamaskController extends EventEmitter {
cb(null, result)
},
// tx signing
processTransaction: nodeify(async (txParams) => await this.txController.newUnapprovedTransaction(txParams), this),
// old style msg signing
processMessage: this.newUnsignedMessage.bind(this),
// personal_sign msg signing