aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2017-01-15 12:51:29 +0800
committerkumavis <aaron@kumavis.me>2017-01-15 12:51:29 +0800
commitc3d491a37cb4d704e405b1e19560c14dd2c401ae (patch)
treed4c7828f54441f07fdf2aa2a7ee18a2cf2454713
parentfdcf03f57d0516731799266c8279c0caa5ffcbed (diff)
downloadtangerine-wallet-browser-c3d491a37cb4d704e405b1e19560c14dd2c401ae.tar
tangerine-wallet-browser-c3d491a37cb4d704e405b1e19560c14dd2c401ae.tar.gz
tangerine-wallet-browser-c3d491a37cb4d704e405b1e19560c14dd2c401ae.tar.bz2
tangerine-wallet-browser-c3d491a37cb4d704e405b1e19560c14dd2c401ae.tar.lz
tangerine-wallet-browser-c3d491a37cb4d704e405b1e19560c14dd2c401ae.tar.xz
tangerine-wallet-browser-c3d491a37cb4d704e405b1e19560c14dd2c401ae.tar.zst
tangerine-wallet-browser-c3d491a37cb4d704e405b1e19560c14dd2c401ae.zip
background - return txHash to provider-engine on done
-rw-r--r--app/scripts/metamask-controller.js24
-rw-r--r--app/scripts/transaction-manager.js3
2 files changed, 13 insertions, 14 deletions
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index 13008893b..b94b98eac 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -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)}`))
+ }
+ })
})
}
diff --git a/app/scripts/transaction-manager.js b/app/scripts/transaction-manager.js
index 7dbfc0dbc..5a44705b7 100644
--- a/app/scripts/transaction-manager.js
+++ b/app/scripts/transaction-manager.js
@@ -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)
}