diff options
author | kumavis <kumavis@users.noreply.github.com> | 2017-08-03 10:57:16 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-03 10:57:16 +0800 |
commit | 8a9d0073b1d6b959e9374180e2f52d12ea8319ca (patch) | |
tree | d1718624781338be20181aa40d461d99304e274d /app/scripts/metamask-controller.js | |
parent | 2c37d438885865fb9b93769a6dee9fb32f8d82aa (diff) | |
parent | 5ac4c2de6fa3a83709eeefc71d5afc0857a28445 (diff) | |
download | tangerine-wallet-browser-8a9d0073b1d6b959e9374180e2f52d12ea8319ca.tar tangerine-wallet-browser-8a9d0073b1d6b959e9374180e2f52d12ea8319ca.tar.gz tangerine-wallet-browser-8a9d0073b1d6b959e9374180e2f52d12ea8319ca.tar.bz2 tangerine-wallet-browser-8a9d0073b1d6b959e9374180e2f52d12ea8319ca.tar.lz tangerine-wallet-browser-8a9d0073b1d6b959e9374180e2f52d12ea8319ca.tar.xz tangerine-wallet-browser-8a9d0073b1d6b959e9374180e2f52d12ea8319ca.tar.zst tangerine-wallet-browser-8a9d0073b1d6b959e9374180e2f52d12ea8319ca.zip |
Merge pull request #1848 from MetaMask/transactionControllerRefractor
Transaction controller refractor part 1: promises for everyone and more tests!
Diffstat (limited to 'app/scripts/metamask-controller.js')
-rw-r--r-- | app/scripts/metamask-controller.js | 30 |
1 files changed, 4 insertions, 26 deletions
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 6d6cb85ab..a007d6fc5 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -113,6 +113,7 @@ module.exports = class MetamaskController extends EventEmitter { ethQuery: this.ethQuery, ethStore: this.ethStore, }) + this.txController.on('newUnaprovedTx', opts.showUnapprovedTx.bind(opts)) // notices this.noticeController = new NoticeController({ @@ -203,7 +204,7 @@ module.exports = class MetamaskController extends EventEmitter { cb(null, result) }, // tx signing - processTransaction: (txParams, cb) => this.newUnapprovedTransaction(txParams, cb), + processTransaction: nodeify(async (txParams) => await this.txController.newUnapprovedTransaction(txParams), this), // old style msg signing processMessage: this.newUnsignedMessage.bind(this), @@ -316,7 +317,7 @@ module.exports = class MetamaskController extends EventEmitter { exportAccount: nodeify(keyringController.exportAccount, keyringController), // txController - cancelTransaction: txController.cancelTransaction.bind(txController), + cancelTransaction: nodeify(txController.cancelTransaction, txController), updateAndApproveTransaction: nodeify(txController.updateAndApproveTransaction, txController), // messageManager @@ -461,27 +462,6 @@ module.exports = class MetamaskController extends EventEmitter { // Identity Management // - newUnapprovedTransaction (txParams, cb) { - log.debug(`MetaMaskController newUnapprovedTransaction ${JSON.stringify(txParams)}`) - const self = this - self.txController.addUnapprovedTransaction(txParams, (err, txMeta) => { - if (err) return cb(err) - self.sendUpdate() - self.opts.showUnapprovedTx(txMeta) - // listen for tx completion (success, fail) - self.txController.once(`${txMeta.id}:finished`, (completedTx) => { - switch (completedTx.status) { - case 'submitted': - return cb(null, completedTx.hash) - case 'rejected': - return cb(new Error('MetaMask Tx Signature: User denied transaction signature.')) - default: - return cb(new Error(`MetaMask Tx Signature: Unknown problem: ${JSON.stringify(completedTx.txParams)}`)) - } - }) - }) - } - newUnsignedMessage (msgParams, cb) { const msgId = this.messageManager.addUnapprovedMessage(msgParams) this.sendUpdate() @@ -667,6 +647,4 @@ module.exports = class MetamaskController extends EventEmitter { return Promise.resolve(rpcTarget) }) } - - -} +}
\ No newline at end of file |