aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/metamask-controller.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/scripts/metamask-controller.js')
-rw-r--r--app/scripts/metamask-controller.js31
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)