Skip to content

Commit

Permalink
Resubmit approved transactions on new block
Browse files Browse the repository at this point in the history
May fix #4343 and related issues, where an error could leave
transactions stranded in the approved state.
  • Loading branch information
danfinlay committed Nov 14, 2018
1 parent f2514ad commit 04daa1a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion app/scripts/controllers/transactions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
})

Expand Down
11 changes: 11 additions & 0 deletions app/scripts/controllers/transactions/tx-state-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 04daa1a

Please sign in to comment.