diff options
author | frankiebee <frankie.diamond@gmail.com> | 2018-01-18 07:42:01 +0800 |
---|---|---|
committer | frankiebee <frankie.diamond@gmail.com> | 2018-01-18 07:42:01 +0800 |
commit | 9f19fea8e08415c670ce3df5d7e363baac366d2c (patch) | |
tree | af6e56a5b8f6f6278793a1399fa95980573f3859 /app | |
parent | 5e4dd7118f285005301743d1c6b2f08182188456 (diff) | |
download | tangerine-wallet-browser-9f19fea8e08415c670ce3df5d7e363baac366d2c.tar tangerine-wallet-browser-9f19fea8e08415c670ce3df5d7e363baac366d2c.tar.gz tangerine-wallet-browser-9f19fea8e08415c670ce3df5d7e363baac366d2c.tar.bz2 tangerine-wallet-browser-9f19fea8e08415c670ce3df5d7e363baac366d2c.tar.lz tangerine-wallet-browser-9f19fea8e08415c670ce3df5d7e363baac366d2c.tar.xz tangerine-wallet-browser-9f19fea8e08415c670ce3df5d7e363baac366d2c.tar.zst tangerine-wallet-browser-9f19fea8e08415c670ce3df5d7e363baac366d2c.zip |
transactions - wrap addTxDefaults in a try catch and re try addTxDefaults on boot if they did not complete
Diffstat (limited to 'app')
-rw-r--r-- | app/scripts/controllers/transactions.js | 22 |
1 files 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 } |