From d755b66e204277ac6a904ba432f7b10a340c9288 Mon Sep 17 00:00:00 2001 From: kumavis Date: Fri, 13 Jan 2017 15:51:08 -0800 Subject: [PATCH] background - metamask controller - fix 'this' ref --- app/scripts/metamask-controller.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 67c35dd67..315b9832c 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -239,13 +239,14 @@ module.exports = class MetamaskController extends EventEmitter { } newUnapprovedTransaction (txParams, cb) { - this.txManager.addUnapprovedTransaction(txParams, (err, txMeta) => { + const self = this + self.txManager.addUnapprovedTransaction(txParams, (err, txMeta) => { if (err) return cb(err) - this.sendUpdate() - this.opts.showUnapprovedTx(txMeta) + self.sendUpdate() + self.opts.showUnapprovedTx(txMeta) // listen for tx completion (success, fail) - this.txManager.once(`${txMeta.id}:submitted`, successHandler) - this.txManager.once(`${txMeta.id}:rejected`, failHandler) + self.txManager.once(`${txMeta.id}:submitted`, successHandler) + self.txManager.once(`${txMeta.id}:rejected`, failHandler) function successHandler(rawTx) { removeHandlers() cb(null, rawTx) @@ -255,8 +256,8 @@ module.exports = class MetamaskController extends EventEmitter { cb(new Error('User denied message signature.')) } function removeHandlers() { - this.txManager.removeListener(`${txMeta.id}:submitted`, successHandler) - this.txManager.removeListener(`${txMeta.id}:rejected`, failHandler) + self.txManager.removeListener(`${txMeta.id}:submitted`, successHandler) + self.txManager.removeListener(`${txMeta.id}:rejected`, failHandler) } }) }