diff options
author | kumavis <kumavis@users.noreply.github.com> | 2017-01-03 03:30:00 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-03 03:30:00 +0800 |
commit | fc723e7f7c037dbeb9cf427c3bdcc9f39c26785c (patch) | |
tree | 9cb3b8fb5622aa23d4856e21405f8939505d3271 /app/scripts/lib/config-manager.js | |
parent | 2ab34760b0e2e006c0b87722e8397c642eb86981 (diff) | |
parent | fa3e708f34fce523601c39b3131bdbe858d2f85f (diff) | |
download | tangerine-wallet-browser-fc723e7f7c037dbeb9cf427c3bdcc9f39c26785c.tar tangerine-wallet-browser-fc723e7f7c037dbeb9cf427c3bdcc9f39c26785c.tar.gz tangerine-wallet-browser-fc723e7f7c037dbeb9cf427c3bdcc9f39c26785c.tar.bz2 tangerine-wallet-browser-fc723e7f7c037dbeb9cf427c3bdcc9f39c26785c.tar.lz tangerine-wallet-browser-fc723e7f7c037dbeb9cf427c3bdcc9f39c26785c.tar.xz tangerine-wallet-browser-fc723e7f7c037dbeb9cf427c3bdcc9f39c26785c.tar.zst tangerine-wallet-browser-fc723e7f7c037dbeb9cf427c3bdcc9f39c26785c.zip |
Merge pull request #921 from MetaMask/TxManager
Feature: TxManager handles transaction state tracking
Diffstat (limited to 'app/scripts/lib/config-manager.js')
-rw-r--r-- | app/scripts/lib/config-manager.js | 54 |
1 files changed, 1 insertions, 53 deletions
diff --git a/app/scripts/lib/config-manager.js b/app/scripts/lib/config-manager.js index ede877b76..93501c859 100644 --- a/app/scripts/lib/config-manager.js +++ b/app/scripts/lib/config-manager.js @@ -8,7 +8,6 @@ const normalize = require('./sig-util').normalize const TESTNET_RPC = MetamaskConfig.network.testnet const MAINNET_RPC = MetamaskConfig.network.mainnet const MORDEN_RPC = MetamaskConfig.network.morden -const txLimit = 40 /* The config-manager is a convenience object * wrapping a pojo-migrator. @@ -19,8 +18,6 @@ const txLimit = 40 */ module.exports = ConfigManager function ConfigManager (opts) { - this.txLimit = txLimit - // ConfigManager is observable and will emit updates this._subs = [] @@ -209,61 +206,12 @@ ConfigManager.prototype.getTxList = function () { } } -ConfigManager.prototype.unconfirmedTxs = function () { - var transactions = this.getTxList() - return transactions.filter(tx => tx.status === 'unconfirmed') - .reduce((result, tx) => { result[tx.id] = tx; return result }, {}) -} - -ConfigManager.prototype._saveTxList = function (txList) { +ConfigManager.prototype.setTxList = function (txList) { var data = this.migrator.getData() data.transactions = txList this.setData(data) } -ConfigManager.prototype.addTx = function (tx) { - var transactions = this.getTxList() - while (transactions.length > this.txLimit - 1) { - transactions.shift() - } - transactions.push(tx) - this._saveTxList(transactions) -} - -ConfigManager.prototype.getTx = function (txId) { - var transactions = this.getTxList() - var matching = transactions.filter(tx => tx.id === txId) - return matching.length > 0 ? matching[0] : null -} - -ConfigManager.prototype.confirmTx = function (txId) { - this._setTxStatus(txId, 'confirmed') -} - -ConfigManager.prototype.rejectTx = function (txId) { - this._setTxStatus(txId, 'rejected') -} - -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() - var found, index - transactions.forEach((otherTx, i) => { - if (otherTx.id === tx.id) { - found = true - index = i - } - }) - if (found) { - transactions[index] = tx - } - this._saveTxList(transactions) -} // wallet nickname methods |