aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/scripts/lib/config-manager.js28
1 files changed, 25 insertions, 3 deletions
diff --git a/app/scripts/lib/config-manager.js b/app/scripts/lib/config-manager.js
index 356d53c22..bcf251496 100644
--- a/app/scripts/lib/config-manager.js
+++ b/app/scripts/lib/config-manager.js
@@ -161,6 +161,16 @@ ConfigManager.prototype.getTx = function(txId) {
return matching.length > 0 ? matching[0] : null
}
+ConfigManager.prototype.getTxWithParams = function(params) {
+ var transactions = this.getTxList()
+ var matching = transactions.filter((tx) => {
+ return Object.keys(tx.txParams).reduce((result, key) => {
+ return tx.params[key] === params[key] && result
+ }, true)
+ })
+ return matching.length > 0 ? matching[0] : null
+}
+
ConfigManager.prototype.confirmTx = function(txId) {
this._setTxStatus(txId, 'confirmed')
}
@@ -170,14 +180,26 @@ ConfigManager.prototype.rejectTx = function(txId) {
}
ConfigManager.prototype._setTxStatus = function(txId, status) {
+ var tx = this.getTx(txId)
+ tx.status = status
+ this.updateTx(tx)
+}
+
+ConfigManager.prototype.updateTx = function(tx) {
var transactions = this.getTxList()
- transactions.forEach((tx) => {
- if (tx.id === txId) {
- tx.status = status
+ var found, index
+ transactions.forEach((otherTx, i) => {
+ if (otherTx.id === tx.id) {
+ found = true
+ index = i
}
})
+ if (found) {
+ transactions[index] = tx
+ }
this._saveTxList(transactions)
}
+
ConfigManager.prototype.unconfirmedTxs = function() {
var transactions = this.getTxList()
return transactions.filter(tx => tx.status === 'unconfirmed')