aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2017-12-08 07:04:14 +0800
committerkumavis <aaron@kumavis.me>2017-12-08 07:04:14 +0800
commita91200fd08b429c81d4096de17cdd9066a632ade (patch)
treeec2fa57389fc99c8786b58ff5af7130d7ce85e8d /app/scripts
parentdc4e3ef24185f3f4dae1fedc5840e36b703617d2 (diff)
downloadtangerine-wallet-browser-a91200fd08b429c81d4096de17cdd9066a632ade.tar
tangerine-wallet-browser-a91200fd08b429c81d4096de17cdd9066a632ade.tar.gz
tangerine-wallet-browser-a91200fd08b429c81d4096de17cdd9066a632ade.tar.bz2
tangerine-wallet-browser-a91200fd08b429c81d4096de17cdd9066a632ade.tar.lz
tangerine-wallet-browser-a91200fd08b429c81d4096de17cdd9066a632ade.tar.xz
tangerine-wallet-browser-a91200fd08b429c81d4096de17cdd9066a632ade.tar.zst
tangerine-wallet-browser-a91200fd08b429c81d4096de17cdd9066a632ade.zip
tx-controller - failed state is a finished state
Diffstat (limited to 'app/scripts')
-rw-r--r--app/scripts/controllers/transactions.js14
-rw-r--r--app/scripts/lib/tx-state-manager.js2
2 files changed, 9 insertions, 7 deletions
diff --git a/app/scripts/controllers/transactions.js b/app/scripts/controllers/transactions.js
index 6110b9c75..f95b5e39a 100644
--- a/app/scripts/controllers/transactions.js
+++ b/app/scripts/controllers/transactions.js
@@ -138,18 +138,20 @@ module.exports = class TransactionController extends EventEmitter {
async newUnapprovedTransaction (txParams) {
log.debug(`MetaMaskController newUnapprovedTransaction ${JSON.stringify(txParams)}`)
- const txMeta = await this.addUnapprovedTransaction(txParams)
- this.emit('newUnapprovedTx', txMeta)
+ const initialTxMeta = await this.addUnapprovedTransaction(txParams)
+ this.emit('newUnapprovedTx', initialTxMeta)
// listen for tx completion (success, fail)
return new Promise((resolve, reject) => {
- this.txStateManager.once(`${txMeta.id}:finished`, (completedTx) => {
- switch (completedTx.status) {
+ this.txStateManager.once(`${initialTxMeta.id}:finished`, (finishedTxMeta) => {
+ switch (finishedTxMeta.status) {
case 'submitted':
- return resolve(completedTx.hash)
+ return resolve(finishedTxMeta.hash)
case 'rejected':
return reject(new Error('MetaMask Tx Signature: User denied transaction signature.'))
+ case 'failed':
+ return reject(new Error(finishedTxMeta.err.message))
default:
- return reject(new Error(`MetaMask Tx Signature: Unknown problem: ${JSON.stringify(completedTx.txParams)}`))
+ return reject(new Error(`MetaMask Tx Signature: Unknown problem: ${JSON.stringify(finishedTxMeta.txParams)}`))
}
})
})
diff --git a/app/scripts/lib/tx-state-manager.js b/app/scripts/lib/tx-state-manager.js
index cc441c584..a8ef39891 100644
--- a/app/scripts/lib/tx-state-manager.js
+++ b/app/scripts/lib/tx-state-manager.js
@@ -240,7 +240,7 @@ module.exports = class TransactionStateManger extends EventEmitter {
txMeta.status = status
this.emit(`${txMeta.id}:${status}`, txId)
this.emit(`tx:status-update`, txId, status)
- if (status === 'submitted' || status === 'rejected') {
+ if (['submitted', 'rejected', 'failed'].includes(status)) {
this.emit(`${txMeta.id}:finished`, txMeta)
}
this.updateTx(txMeta, `txStateManager: setting status to ${status}`)