diff options
author | brunobar79 <brunobar79@gmail.com> | 2018-11-15 13:29:06 +0800 |
---|---|---|
committer | brunobar79 <brunobar79@gmail.com> | 2018-11-15 13:29:06 +0800 |
commit | e44b750f0f0bba3ec2b12c4f99343c62d28cd017 (patch) | |
tree | b1d18271b90d1b728e178d4039de97ac220f0512 /app | |
parent | 18f39ef69e117a3560456a30f0e8506ed7b0e044 (diff) | |
parent | d684bb4c17fb23deeb1ed037fe83923173795e97 (diff) | |
download | tangerine-wallet-browser-e44b750f0f0bba3ec2b12c4f99343c62d28cd017.tar tangerine-wallet-browser-e44b750f0f0bba3ec2b12c4f99343c62d28cd017.tar.gz tangerine-wallet-browser-e44b750f0f0bba3ec2b12c4f99343c62d28cd017.tar.bz2 tangerine-wallet-browser-e44b750f0f0bba3ec2b12c4f99343c62d28cd017.tar.lz tangerine-wallet-browser-e44b750f0f0bba3ec2b12c4f99343c62d28cd017.tar.xz tangerine-wallet-browser-e44b750f0f0bba3ec2b12c4f99343c62d28cd017.tar.zst tangerine-wallet-browser-e44b750f0f0bba3ec2b12c4f99343c62d28cd017.zip |
Merge branch 'develop' of github.com:MetaMask/metamask-extension into trezor-v5
Diffstat (limited to 'app')
-rw-r--r-- | app/scripts/controllers/transactions/index.js | 7 | ||||
-rw-r--r-- | app/scripts/controllers/transactions/pending-tx-tracker.js | 6 | ||||
-rw-r--r-- | app/scripts/controllers/transactions/tx-state-manager.js | 11 |
3 files changed, 22 insertions, 2 deletions
diff --git a/app/scripts/controllers/transactions/index.js b/app/scripts/controllers/transactions/index.js index 9f2290924..9cf822d34 100644 --- a/app/scripts/controllers/transactions/index.js +++ b/app/scripts/controllers/transactions/index.js @@ -82,7 +82,12 @@ class TransactionController extends EventEmitter { provider: this.provider, nonceTracker: this.nonceTracker, publishTransaction: (rawTx) => this.query.sendRawTransaction(rawTx), - getPendingTransactions: this.txStateManager.getPendingTransactions.bind(this.txStateManager), + getPendingTransactions: () => { + const pending = this.txStateManager.getPendingTransactions() + const approved = this.txStateManager.getApprovedTransactions() + return [...pending, ...approved] + }, + approveTransaction: this.approveTransaction.bind(this), getCompletedTransactions: this.txStateManager.getConfirmedTransactions.bind(this.txStateManager), }) diff --git a/app/scripts/controllers/transactions/pending-tx-tracker.js b/app/scripts/controllers/transactions/pending-tx-tracker.js index 70cac096b..44a50a589 100644 --- a/app/scripts/controllers/transactions/pending-tx-tracker.js +++ b/app/scripts/controllers/transactions/pending-tx-tracker.js @@ -27,6 +27,7 @@ class PendingTransactionTracker extends EventEmitter { this.getPendingTransactions = config.getPendingTransactions this.getCompletedTransactions = config.getCompletedTransactions this.publishTransaction = config.publishTransaction + this.approveTransaction = config.approveTransaction this.confirmTransaction = config.confirmTransaction } @@ -108,7 +109,7 @@ class PendingTransactionTracker extends EventEmitter { if (txBlockDistance <= Math.pow(2, retryCount) - 1) return // Only auto-submit already-signed txs: - if (!('rawTx' in txMeta)) return + if (!('rawTx' in txMeta)) return this.approveTransaction(txMeta.id) const rawTx = txMeta.rawTx const txHash = await this.publishTransaction(rawTx) @@ -129,6 +130,9 @@ class PendingTransactionTracker extends EventEmitter { const txHash = txMeta.hash const txId = txMeta.id + // Only check submitted txs + if (txMeta.status !== 'submitted') return + // extra check in case there was an uncaught error during the // signature and submission process if (!txHash) { diff --git a/app/scripts/controllers/transactions/tx-state-manager.js b/app/scripts/controllers/transactions/tx-state-manager.js index 58c48e34e..62319507d 100644 --- a/app/scripts/controllers/transactions/tx-state-manager.js +++ b/app/scripts/controllers/transactions/tx-state-manager.js @@ -83,6 +83,17 @@ class TransactionStateManager extends EventEmitter { /** @param [address] {string} - hex prefixed address to sort the txMetas for [optional] + @returns {array} the tx list whos status is approved if no address is provide + returns all txMetas who's status is approved for the current network + */ + getApprovedTransactions(address) { + const opts = { status: 'approved' } + if (address) opts.from = address + return this.getFilteredTxList(opts) + } + + /** + @param [address] {string} - hex prefixed address to sort the txMetas for [optional] @returns {array} the tx list whos status is submitted if no address is provide returns all txMetas who's status is submitted for the current network */ |