1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-26 12:29:06 +01:00

background - metamask controller - fix 'this' ref

This commit is contained in:
kumavis 2017-01-13 15:51:08 -08:00
parent 29e83d71a8
commit d755b66e20

View File

@ -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)
}
})
}