From 04daa1a7ac08006a1935b4b9966315fb4f82c4f9 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Tue, 13 Nov 2018 16:35:48 -0800 Subject: [PATCH] Resubmit approved transactions on new block May fix #4343 and related issues, where an error could leave transactions stranded in the approved state. --- CHANGELOG.md | 2 ++ app/scripts/controllers/transactions/index.js | 6 +++++- .../controllers/transactions/tx-state-manager.js | 11 +++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 85ac342dcf10..2c284c4ce665 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Current Develop Branch +- Resubmit approved transactions on new block, to fix bug where an error can stick transactions in this state. + ## 5.0.2 Friday November 9 2018 - Fixed bug that caused accounts to update slowly to sites. #5717 diff --git a/app/scripts/controllers/transactions/index.js b/app/scripts/controllers/transactions/index.js index 9f2290924781..0975e6b7cc55 100644 --- a/app/scripts/controllers/transactions/index.js +++ b/app/scripts/controllers/transactions/index.js @@ -82,7 +82,11 @@ class TransactionController extends EventEmitter { provider: this.provider, nonceTracker: this.nonceTracker, publishTransaction: (rawTx) => this.query.sendRawTransaction(rawTx), - getPendingTransactions: this.txStateManager.getPendingTransactions.bind(this.txStateManager), + getPendingTransactions: () => { + const pending = this.txStateManager.getPendingTransactions.bind(this.txStateManager) + const approved = this.txStateManager.getApprovedTransactions.bind(this.txStateManager) + return [...pending, ...approved] + } getCompletedTransactions: this.txStateManager.getConfirmedTransactions.bind(this.txStateManager), }) diff --git a/app/scripts/controllers/transactions/tx-state-manager.js b/app/scripts/controllers/transactions/tx-state-manager.js index 58c48e34e27d..e455cc237695 100644 --- a/app/scripts/controllers/transactions/tx-state-manager.js +++ b/app/scripts/controllers/transactions/tx-state-manager.js @@ -81,6 +81,17 @@ class TransactionStateManager extends EventEmitter { }, {}) } + /** + @param [address] {string} - hex prefixed address to sort the txMetas for [optional] + @returns {array} the tx list whos status is approved if no address is provide + returns all txMetas who's status is approved for the current network + */ + getApprovedTransactions(address) { + const opts = { status: 'submitted' } + if (address) opts.from = address + return this.getFilteredTxList(opts) + } + /** @param [address] {string} - hex prefixed address to sort the txMetas for [optional] @returns {array} the tx list whos status is submitted if no address is provide