diff options
author | frankiebee <frankie.diamond@gmail.com> | 2017-08-19 03:23:35 +0800 |
---|---|---|
committer | frankiebee <frankie.diamond@gmail.com> | 2017-08-22 01:29:10 +0800 |
commit | 7ea83b6bae34dcf652d85474fe1d82893d592d55 (patch) | |
tree | f788533b11bc669cf443d430f874c4ec76c8acf6 /app/scripts/lib | |
parent | e9712a13ecd96db0bcc9d22998fc4df2ecdeeebc (diff) | |
download | tangerine-wallet-browser-7ea83b6bae34dcf652d85474fe1d82893d592d55.tar tangerine-wallet-browser-7ea83b6bae34dcf652d85474fe1d82893d592d55.tar.gz tangerine-wallet-browser-7ea83b6bae34dcf652d85474fe1d82893d592d55.tar.bz2 tangerine-wallet-browser-7ea83b6bae34dcf652d85474fe1d82893d592d55.tar.lz tangerine-wallet-browser-7ea83b6bae34dcf652d85474fe1d82893d592d55.tar.xz tangerine-wallet-browser-7ea83b6bae34dcf652d85474fe1d82893d592d55.tar.zst tangerine-wallet-browser-7ea83b6bae34dcf652d85474fe1d82893d592d55.zip |
Create TxStateManager
Diffstat (limited to 'app/scripts/lib')
-rw-r--r-- | app/scripts/lib/tx-state-manager.js | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/app/scripts/lib/tx-state-manager.js b/app/scripts/lib/tx-state-manager.js index 91271cc4a..378ea38ab 100644 --- a/app/scripts/lib/tx-state-manager.js +++ b/app/scripts/lib/tx-state-manager.js @@ -23,7 +23,25 @@ module.exports = class TransactionStateManger extends ObservableStore { return this.getState().transactions } + // Returns the tx list + + getUnapprovedTxList () { + const txList = this.getTxsByMetaData('status', 'unapproved') + return txList.reduce((result, tx) => { + result[tx.id] = tx + return result + }, {}) + } + + addTx (txMeta) { + this.once(`${txMeta.id}:signed`, function (txId) { + this.removeAllListeners(`${txMeta.id}:rejected`) + }) + this.once(`${txMeta.id}:rejected`, function (txId) { + this.removeAllListeners(`${txMeta.id}:signed`) + }) + const transactions = this.getFullTxList() const txCount = this.getTxCount() const txHistoryLimit = this.txHistoryLimit @@ -38,7 +56,6 @@ module.exports = class TransactionStateManger extends ObservableStore { transactions.splice(index, 1) } transactions.push(txMeta) - transactions.push(txMeta) this._saveTxList(transactions) } // gets tx by Id and returns it |