From 9f19fea8e08415c670ce3df5d7e363baac366d2c Mon Sep 17 00:00:00 2001 From: frankiebee Date: Wed, 17 Jan 2018 15:42:01 -0800 Subject: [PATCH 1/2] transactions - wrap addTxDefaults in a try catch and re try addTxDefaults on boot if they did not complete --- app/scripts/controllers/transactions.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/app/scripts/controllers/transactions.js b/app/scripts/controllers/transactions.js index bb9253175..4c9a4cd80 100644 --- a/app/scripts/controllers/transactions.js +++ b/app/scripts/controllers/transactions.js @@ -43,6 +43,18 @@ module.exports = class TransactionController extends EventEmitter { txHistoryLimit: opts.txHistoryLimit, getNetwork: this.getNetwork.bind(this), }) + + this.txStateManager.getFilteredTxList({ + status: 'unapproved', + loadingDefaults: true, + }).forEach((tx) => { + this.addTxDefaults(tx) + .then((txMeta) => { + txMeta.loadingDefaults = false + this.txStateManager.updateTx(txMeta, 'transactions: gas estimation for tx on boot') + }) + }) + this.store = this.txStateManager.store this.txStateManager.on('tx:status-update', this.emit.bind(this, 'tx:status-update')) this.nonceTracker = new NonceTracker({ @@ -171,11 +183,17 @@ module.exports = class TransactionController extends EventEmitter { this.addTx(txMeta) this.emit('newUnapprovedTx', txMeta) // add default tx params - await this.addTxDefaults(txMeta) - + try { + await this.addTxDefaults(txMeta) + } catch (error) { + console.log(error) + this.txStateManager.setTxStatusFailed(txMeta.id, error) + throw error + } txMeta.loadingDefaults = false // save txMeta this.txStateManager.updateTx(txMeta) + return txMeta } From be8d9244326443fb7f54df271d4e2a2abda90f6f Mon Sep 17 00:00:00 2001 From: frankiebee Date: Wed, 17 Jan 2018 15:48:37 -0800 Subject: [PATCH 2/2] transactions - fail txs on boot who fail addTxDefaults --- app/scripts/controllers/transactions.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/scripts/controllers/transactions.js b/app/scripts/controllers/transactions.js index 4c9a4cd80..73aadb292 100644 --- a/app/scripts/controllers/transactions.js +++ b/app/scripts/controllers/transactions.js @@ -52,6 +52,8 @@ module.exports = class TransactionController extends EventEmitter { .then((txMeta) => { txMeta.loadingDefaults = false this.txStateManager.updateTx(txMeta, 'transactions: gas estimation for tx on boot') + }).catch((error) => { + this.txStateManager.setTxStatusFailed(tx.id, error) }) })