diff options
author | Dan Finlay <flyswatter@users.noreply.github.com> | 2017-01-06 03:22:15 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-06 03:22:15 +0800 |
commit | 3727cad0c4bbcac31030cf67a5836729e08a56d8 (patch) | |
tree | 23496c117bd4205f7799a51443b52f01d9c69a70 /app/scripts/metamask-controller.js | |
parent | 70816d7cb0cf4850d03956801bb6d3ca04158f9f (diff) | |
parent | 73ee0ae766485cb15b28fcf5dadd1035cc2ea842 (diff) | |
download | tangerine-wallet-browser-3727cad0c4bbcac31030cf67a5836729e08a56d8.tar tangerine-wallet-browser-3727cad0c4bbcac31030cf67a5836729e08a56d8.tar.gz tangerine-wallet-browser-3727cad0c4bbcac31030cf67a5836729e08a56d8.tar.bz2 tangerine-wallet-browser-3727cad0c4bbcac31030cf67a5836729e08a56d8.tar.lz tangerine-wallet-browser-3727cad0c4bbcac31030cf67a5836729e08a56d8.tar.xz tangerine-wallet-browser-3727cad0c4bbcac31030cf67a5836729e08a56d8.tar.zst tangerine-wallet-browser-3727cad0c4bbcac31030cf67a5836729e08a56d8.zip |
Merge pull request #967 from MetaMask/fixTxManager
Fix tx manager
Diffstat (limited to 'app/scripts/metamask-controller.js')
-rw-r--r-- | app/scripts/metamask-controller.js | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 8bfb85370..961130dfd 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -165,7 +165,6 @@ module.exports = class MetamaskController { sendUpdate () { this.getState() .then((state) => { - this.listeners.forEach((remote) => { remote.sendUpdate(state) }) @@ -185,10 +184,23 @@ module.exports = class MetamaskController { }, // tx signing approveTransaction: this.newUnsignedTransaction.bind(this), - signTransaction: (...args) => { - this.setupSigningListners(...args) - this.txManager.formatTxForSigining(...args) - this.sendUpdate() + signTransaction: (txParams, cb) => { + this.txManager.formatTxForSigining(txParams) + .then(({ethTx, address, txId}) => { + return this.keyringController.signTransaction(ethTx, address, txId) + }) + .then(({tx, txId}) => { + return this.txManager.resolveSignedTransaction({tx, txId}) + }) + .then((rawTx) => { + cb(null, rawTx) + this.sendUpdate() + this.txManager.emit(`${txParams.metamaskId}:signingComplete`) + }) + .catch((err) => { + console.error(err) + cb(err) + }) }, // msg signing @@ -266,13 +278,6 @@ module.exports = class MetamaskController { }) } - setupSigningListners (txParams) { - var txId = txParams.metamaskId - // apply event listeners for signing and formating events - this.txManager.once(`${txId}:formatted`, this.keyringController.signTransaction.bind(this.keyringController)) - this.keyringController.once(`${txId}:signed`, this.txManager.resolveSignedTransaction.bind(this.txManager)) - } - enforceTxValidations (txParams) { if (('value' in txParams) && txParams.value.indexOf('-') === 0) { const msg = `Invalid transaction value of ${txParams.value} not a positive number.` @@ -453,7 +458,7 @@ module.exports = class MetamaskController { return this.state.network } - markAccountsFound(cb) { + markAccountsFound (cb) { this.configManager.setLostAccounts([]) this.sendUpdate() cb(null, this.getState()) |