diff options
author | Dan Finlay <dan@danfinlay.com> | 2017-02-24 08:00:43 +0800 |
---|---|---|
committer | Dan Finlay <dan@danfinlay.com> | 2017-02-24 08:02:58 +0800 |
commit | 961a83769bd46334f5ecf72d00a32730d19866c3 (patch) | |
tree | 5d7397ec9e83c90e7c56ab9a1b9c62d9aa052ffe /app | |
parent | 1d1d296a1eec2fc66927dd80bf0f1bbd1a6841cf (diff) | |
download | tangerine-wallet-browser-961a83769bd46334f5ecf72d00a32730d19866c3.tar tangerine-wallet-browser-961a83769bd46334f5ecf72d00a32730d19866c3.tar.gz tangerine-wallet-browser-961a83769bd46334f5ecf72d00a32730d19866c3.tar.bz2 tangerine-wallet-browser-961a83769bd46334f5ecf72d00a32730d19866c3.tar.lz tangerine-wallet-browser-961a83769bd46334f5ecf72d00a32730d19866c3.tar.xz tangerine-wallet-browser-961a83769bd46334f5ecf72d00a32730d19866c3.tar.zst tangerine-wallet-browser-961a83769bd46334f5ecf72d00a32730d19866c3.zip |
Fix cancel msg signing behavior.
Diffstat (limited to 'app')
-rw-r--r-- | app/scripts/metamask-controller.js | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index c301e2035..eace72c24 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -139,6 +139,7 @@ module.exports = class MetamaskController extends EventEmitter { this.ethStore.subscribe(this.sendUpdate.bind(this)) this.txManager.memStore.subscribe(this.sendUpdate.bind(this)) this.messageManager.memStore.subscribe(this.sendUpdate.bind(this)) + this.personalMessageManager.memStore.subscribe(this.sendUpdate.bind(this)) this.keyringController.memStore.subscribe(this.sendUpdate.bind(this)) this.preferencesController.store.subscribe(this.sendUpdate.bind(this)) this.currencyController.store.subscribe(this.sendUpdate.bind(this)) @@ -239,8 +240,6 @@ module.exports = class MetamaskController extends EventEmitter { const keyringController = this.keyringController const preferencesController = this.preferencesController const txManager = this.txManager - const messageManager = this.messageManager - const personalMessageManager = this.personalMessageManager const noticeController = this.noticeController return { @@ -283,11 +282,11 @@ module.exports = class MetamaskController extends EventEmitter { // messageManager signMessage: nodeify(this.signMessage).bind(this), - cancelMessage: messageManager.rejectMsg.bind(messageManager), + cancelMessage: this.cancelMessage.bind(this), // personalMessageManager signPersonalMessage: nodeify(this.signPersonalMessage).bind(this), - cancelPersonalMessage: personalMessageManager.rejectMsg.bind(personalMessageManager), + cancelPersonalMessage: this.cancelPersonalMessage.bind(this), // notices checkNotices: noticeController.updateNoticesList.bind(noticeController), @@ -437,7 +436,7 @@ module.exports = class MetamaskController extends EventEmitter { case 'signed': return cb(null, data.rawSig) case 'rejected': - return cb(new Error('MetaMask Message Signature: User denied transaction signature.')) + return cb(new Error('MetaMask Message Signature: User denied message signature.')) default: return cb(new Error(`MetaMask Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`)) } @@ -445,6 +444,10 @@ module.exports = class MetamaskController extends EventEmitter { } newUnsignedPersonalMessage (msgParams, cb) { + if (!msgParams.from) { + return cb(new Error('MetaMask Message Signature: from field is required.')) + } + let msgId = this.personalMessageManager.addUnapprovedMessage(msgParams) this.sendUpdate() this.opts.showUnconfirmedMessage() @@ -453,7 +456,7 @@ module.exports = class MetamaskController extends EventEmitter { case 'signed': return cb(null, data.rawSig) case 'rejected': - return cb(new Error('MetaMask Message Signature: User denied transaction signature.')) + return cb(new Error('MetaMask Message Signature: User denied message signature.')) default: return cb(new Error(`MetaMask Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`)) } @@ -479,6 +482,14 @@ module.exports = class MetamaskController extends EventEmitter { }) } + cancelMessage(msgId, cb) { + const messageManager = this.messageManager + messageManager.rejectMsg(msgId) + if (cb && typeof cb === 'function') { + cb(null, this.getState()) + } + } + // Prefixed Style Message Signing Methods: approvePersonalMessage (msgParams, cb) { let msgId = this.personalMessageManager.addUnapprovedMessage(msgParams) @@ -514,6 +525,14 @@ module.exports = class MetamaskController extends EventEmitter { }) } + cancelPersonalMessage(msgId, cb) { + const messageManager = this.personalMessageManager + messageManager.rejectMsg(msgId) + if (cb && typeof cb === 'function') { + cb(null, this.getState()) + } + } + recoverPersonalMessage (msgParams) { const keyringController = this.keyringController return keyringController.recoverPersonalMessage(msgParams) |