Merge pull request #3808 from MetaMask/txMeta-origin

transactions - add origin to txMeta
This commit is contained in:
kumavis 2018-03-30 16:09:00 -07:00 committed by GitHub
commit e99a707e3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 16 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 = {}) {
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

24
package-lock.json generated
View File

@ -5747,7 +5747,7 @@
"ethereumjs-vm": "2.3.2",
"through2": "2.0.3",
"treeify": "1.1.0",
"web3-provider-engine": "13.6.0"
"web3-provider-engine": "13.8.0"
}
},
"ethereum-common": {
@ -19306,9 +19306,9 @@
}
},
"solc": {
"version": "0.4.20",
"resolved": "https://registry.npmjs.org/solc/-/solc-0.4.20.tgz",
"integrity": "sha512-LrP3Jp4FS3y8sduIR67y8Ss1riR3fggk5sMnx4OSCcU88Ro0e51+KVXyfH3NP6ghLo7COrLx/lGUaDDugCzdgA==",
"version": "0.4.21",
"resolved": "https://registry.npmjs.org/solc/-/solc-0.4.21.tgz",
"integrity": "sha512-8lJmimVjOG9AJOQRWS2ph4rSctPMsPGZ4H360HLs5iI+euUlt7iAvUxSLeFZZzwk0kas4Qta7HmlMXNU3yYwhw==",
"requires": {
"fs-extra": "0.30.0",
"memorystream": "0.3.1",
@ -22309,9 +22309,9 @@
}
},
"web3-provider-engine": {
"version": "13.6.0",
"resolved": "https://registry.npmjs.org/web3-provider-engine/-/web3-provider-engine-13.6.0.tgz",
"integrity": "sha512-iCsAlAeLWHxgx6EXuBm5GNg5VBqKtzmnrhEOfJBv8Cetukush7yOvo4RPjDZIynKxg9jfAlMmWqCk6wLxA6coQ==",
"version": "13.8.0",
"resolved": "https://registry.npmjs.org/web3-provider-engine/-/web3-provider-engine-13.8.0.tgz",
"integrity": "sha512-fZXhX5VWwWpoFfrfocslyg6P7cN3YWPG/ASaevNfeO80R+nzgoPUBXcWQekSGSsNDkeRTis4aMmpmofYf1TNtQ==",
"requires": {
"async": "2.6.0",
"clone": "2.1.1",
@ -22319,7 +22319,7 @@
"eth-sig-util": "1.4.2",
"ethereumjs-block": "1.7.0",
"ethereumjs-tx": "1.3.3",
"ethereumjs-util": "5.1.4",
"ethereumjs-util": "5.1.5",
"ethereumjs-vm": "2.3.2",
"fetch-ponyfill": "4.1.0",
"json-rpc-error": "2.0.0",
@ -22328,16 +22328,16 @@
"readable-stream": "2.3.3",
"request": "2.83.0",
"semaphore": "1.1.0",
"solc": "0.4.20",
"solc": "0.4.21",
"tape": "4.8.0",
"xhr": "2.4.1",
"xtend": "4.0.1"
},
"dependencies": {
"ethereumjs-util": {
"version": "5.1.4",
"resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.1.4.tgz",
"integrity": "sha512-wbeTc5prEzIWFSQUcEsCAZbqubtJKy6yS+oZMY1cGG6GLYzLjm4YhC2RNrWIg8hRYnclWpnZmx2zkiufQkmd3w==",
"version": "5.1.5",
"resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.1.5.tgz",
"integrity": "sha512-xPaSEATYJpMTCGowIt0oMZwFP4R1bxd6QsWgkcDvFL0JtXsr39p32WEcD14RscCjfP41YXZPCVWA4yAg0nrJmw==",
"requires": {
"bn.js": "4.11.8",
"create-hash": "1.1.3",

View File

@ -185,7 +185,7 @@
"valid-url": "^1.0.9",
"vreme": "^3.0.2",
"web3": "^0.20.1",
"web3-provider-engine": "^13.5.6",
"web3-provider-engine": "^13.8.0",
"web3-stream-provider": "^3.0.1",
"xtend": "^4.0.1"
},