From 901d23a02904a859901ca4f0bf5a6e42684567ec Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Tue, 19 Apr 2016 17:32:09 -0700 Subject: Add extra tx methods to configManager --- app/scripts/lib/config-manager.js | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'app/scripts/lib/config-manager.js') 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') -- cgit v1.2.3 From f72887a0a288c2e9a31adea34146ed6857bdb6ae Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Tue, 19 Apr 2016 17:33:37 -0700 Subject: Fix config manager method --- app/scripts/lib/config-manager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/scripts/lib/config-manager.js') diff --git a/app/scripts/lib/config-manager.js b/app/scripts/lib/config-manager.js index bcf251496..b0dcd4d3f 100644 --- a/app/scripts/lib/config-manager.js +++ b/app/scripts/lib/config-manager.js @@ -165,7 +165,7 @@ 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 + return ('params' in tx) ? tx.params[key] === params[key] && result : result }, true) }) return matching.length > 0 ? matching[0] : null -- cgit v1.2.3 From 532edf670e8c30db958765141974f3fb0f5ec44c Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Wed, 20 Apr 2016 09:29:37 -0700 Subject: Store metamaskId on metaTx instead of getTxWithParams method. --- app/scripts/lib/config-manager.js | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'app/scripts/lib/config-manager.js') diff --git a/app/scripts/lib/config-manager.js b/app/scripts/lib/config-manager.js index b0dcd4d3f..c79dc7a8f 100644 --- a/app/scripts/lib/config-manager.js +++ b/app/scripts/lib/config-manager.js @@ -161,16 +161,6 @@ 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 ('params' in tx) ? tx.params[key] === params[key] && result : result - }, true) - }) - return matching.length > 0 ? matching[0] : null -} - ConfigManager.prototype.confirmTx = function(txId) { this._setTxStatus(txId, 'confirmed') } -- cgit v1.2.3