aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorKevin Serrano <kevin.serrano@consensys.net>2017-03-23 23:28:06 +0800
committerKevin Serrano <kevin.serrano@consensys.net>2017-03-23 23:28:06 +0800
commitfa0bbd66b6896188c5a47ed6978fc992068ae22c (patch)
tree79cdb5ebf5a960150e0652b5d37693adb1e9262c /app
parentb9714b881a862302baa0c21d8b8c5360c0e9f85d (diff)
downloadtangerine-wallet-browser-fa0bbd66b6896188c5a47ed6978fc992068ae22c.tar
tangerine-wallet-browser-fa0bbd66b6896188c5a47ed6978fc992068ae22c.tar.gz
tangerine-wallet-browser-fa0bbd66b6896188c5a47ed6978fc992068ae22c.tar.bz2
tangerine-wallet-browser-fa0bbd66b6896188c5a47ed6978fc992068ae22c.tar.lz
tangerine-wallet-browser-fa0bbd66b6896188c5a47ed6978fc992068ae22c.tar.xz
tangerine-wallet-browser-fa0bbd66b6896188c5a47ed6978fc992068ae22c.tar.zst
tangerine-wallet-browser-fa0bbd66b6896188c5a47ed6978fc992068ae22c.zip
Fix persistence of transactions between networks.
Diffstat (limited to 'app')
-rw-r--r--app/scripts/transaction-manager.js32
1 files changed, 22 insertions, 10 deletions
diff --git a/app/scripts/transaction-manager.js b/app/scripts/transaction-manager.js
index 31c1c8431..7227bdc87 100644
--- a/app/scripts/transaction-manager.js
+++ b/app/scripts/transaction-manager.js
@@ -47,27 +47,39 @@ module.exports = class TransactionManager extends EventEmitter {
// Returns the tx list
getTxList () {
let network = this.getNetwork()
- let fullTxList = this.store.getState().transactions
+ let fullTxList = this.getFullTxList()
return fullTxList.filter(txMeta => txMeta.metamaskNetworkId === network)
}
+ // Returns the number of txs for the current network.
+ getTxCount () {
+ return this.getTxList().length
+ }
+
+ // Returns the full tx list across all networks
+ getFullTxList () {
+ return this.store.getState().transactions
+ }
+
// Adds a tx to the txlist
addTx (txMeta) {
- var txList = this.getTxList()
- var txHistoryLimit = this.txHistoryLimit
+ let txCount = this.getTxCount()
+ let network = this.getNetwork()
+ let fullTxList = this.getFullTxList()
+ let txHistoryLimit = this.txHistoryLimit
- // checks if the length of th tx history is
+ // checks if the length of the tx history is
// longer then desired persistence limit
// and then if it is removes only confirmed
// or rejected tx's.
// not tx's that are pending or unapproved
- if (txList.length > txHistoryLimit - 1) {
- var index = txList.findIndex((metaTx) => metaTx.status === 'confirmed' || metaTx.status === 'rejected')
- txList.splice(index, 1)
+ if (txCount > txHistoryLimit - 1) {
+ var index = fullTxList.findIndex((metaTx) => ((metaTx.status === 'confirmed' || metaTx.status === 'rejected') && network === txMeta.metamaskNetworkId))
+ fullTxList.splice(index, 1)
}
- txList.push(txMeta)
+ fullTxList.push(txMeta)
- this._saveTxList(txList)
+ this._saveTxList(fullTxList)
this.once(`${txMeta.id}:signed`, function (txId) {
this.removeAllListeners(`${txMeta.id}:rejected`)
})
@@ -89,7 +101,7 @@ module.exports = class TransactionManager extends EventEmitter {
//
updateTx (txMeta) {
var txId = txMeta.id
- var txList = this.getTxList()
+ var txList = this.getFullTxList()
var index = txList.findIndex(txData => txData.id === txId)
txList[index] = txMeta
this._saveTxList(txList)