diff options
author | Dan Finlay <dan@danfinlay.com> | 2016-04-20 08:32:09 +0800 |
---|---|---|
committer | Dan Finlay <dan@danfinlay.com> | 2016-04-20 08:32:09 +0800 |
commit | 901d23a02904a859901ca4f0bf5a6e42684567ec (patch) | |
tree | 5a84e24e460f1a50140f891809e49c3d95f9c5ce /app | |
parent | 0a0a631af29eb1547f18f2f8072670db0e415372 (diff) | |
download | tangerine-wallet-browser-901d23a02904a859901ca4f0bf5a6e42684567ec.tar tangerine-wallet-browser-901d23a02904a859901ca4f0bf5a6e42684567ec.tar.gz tangerine-wallet-browser-901d23a02904a859901ca4f0bf5a6e42684567ec.tar.bz2 tangerine-wallet-browser-901d23a02904a859901ca4f0bf5a6e42684567ec.tar.lz tangerine-wallet-browser-901d23a02904a859901ca4f0bf5a6e42684567ec.tar.xz tangerine-wallet-browser-901d23a02904a859901ca4f0bf5a6e42684567ec.tar.zst tangerine-wallet-browser-901d23a02904a859901ca4f0bf5a6e42684567ec.zip |
Add extra tx methods to configManager
Diffstat (limited to 'app')
-rw-r--r-- | app/scripts/lib/config-manager.js | 28 |
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') |