mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
background - return txHash to provider-engine on done
This commit is contained in:
parent
fdcf03f57d
commit
c3d491a37c
@ -246,20 +246,16 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||
self.sendUpdate()
|
||||
self.opts.showUnapprovedTx(txMeta)
|
||||
// listen for tx completion (success, fail)
|
||||
self.txManager.once(`${txMeta.id}:submitted`, successHandler)
|
||||
self.txManager.once(`${txMeta.id}:rejected`, failHandler)
|
||||
function successHandler(rawTx) {
|
||||
removeHandlers()
|
||||
cb(null, rawTx)
|
||||
}
|
||||
function failHandler() {
|
||||
removeHandlers()
|
||||
cb(new Error('User denied message signature.'))
|
||||
}
|
||||
function removeHandlers() {
|
||||
self.txManager.removeListener(`${txMeta.id}:submitted`, successHandler)
|
||||
self.txManager.removeListener(`${txMeta.id}:rejected`, failHandler)
|
||||
}
|
||||
self.txManager.once(`${txMeta.id}:finished`, (status) => {
|
||||
switch (status) {
|
||||
case 'submitted':
|
||||
return cb(null, txMeta.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(txMeta.txParams)}`))
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -342,6 +342,9 @@ module.exports = class TransactionManager extends EventEmitter {
|
||||
var txMeta = this.getTx(txId)
|
||||
txMeta.status = status
|
||||
this.emit(`${txMeta.id}:${status}`, txId)
|
||||
if (status === 'submitted' || status === 'rejected') {
|
||||
this.emit(`${txMeta.id}:finished`, status)
|
||||
}
|
||||
this.emit('updateBadge')
|
||||
this.updateTx(txMeta)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user