aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrankie <frankie.diamond@gmail.com>2018-05-22 07:00:44 +0800
committerAlexander Tseung <alextsg@users.noreply.github.com>2018-05-22 07:00:44 +0800
commite8b2e11c5624d80f535c1344d9c9be48627b1319 (patch)
tree8d66e7892bc242b978590b80ea7f9bcde0d5f0a3
parent45ad37162287a1db30caa8eeea89442d303ea883 (diff)
downloadtangerine-wallet-browser-e8b2e11c5624d80f535c1344d9c9be48627b1319.tar.gz
tangerine-wallet-browser-e8b2e11c5624d80f535c1344d9c9be48627b1319.tar.zst
tangerine-wallet-browser-e8b2e11c5624d80f535c1344d9c9be48627b1319.zip
Reveal get filtered tx list (#4332)
* add getFilteredTxList from txController to getApi * transactions - remove dead code (isNonceTaken)
-rw-r--r--app/scripts/controllers/transactions/index.js15
-rw-r--r--app/scripts/metamask-controller.js2
-rw-r--r--test/unit/tx-controller-test.js30
3 files changed, 1 insertions, 46 deletions
diff --git a/app/scripts/controllers/transactions/index.js b/app/scripts/controllers/transactions/index.js
index 3886db104..541f1db73 100644
--- a/app/scripts/controllers/transactions/index.js
+++ b/app/scripts/controllers/transactions/index.js
@@ -112,21 +112,6 @@ class TransactionController extends EventEmitter {
}
/**
- Check if a txMeta in the list with the same nonce has been confirmed in a block
- if the txParams dont have a nonce will return false
- @returns {boolean} whether the nonce has been used in a transaction confirmed in a block
- @param {object} txMeta - the txMeta object
- */
- async isNonceTaken (txMeta) {
- const { from, nonce } = txMeta.txParams
- if ('nonce' in txMeta.txParams) {
- const sameNonceTxList = this.txStateManager.getFilteredTxList({from, nonce, status: 'confirmed'})
- return (sameNonceTxList.length >= 1)
- }
- return false
- }
-
- /**
add a new unapproved transaction to the pipeline
@returns {Promise<string>} the hash of the transaction after being submitted to the network
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index 807c9a0b9..1b1d26886 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -382,7 +382,7 @@ module.exports = class MetamaskController extends EventEmitter {
updateTransaction: nodeify(txController.updateTransaction, txController),
updateAndApproveTransaction: nodeify(txController.updateAndApproveTransaction, txController),
retryTransaction: nodeify(this.retryTransaction, this),
- isNonceTaken: nodeify(txController.isNonceTaken, txController),
+ getFilteredTxList: nodeify(txController.getFilteredTxList, txController),
// messageManager
signMessage: nodeify(this.signMessage, this),
diff --git a/test/unit/tx-controller-test.js b/test/unit/tx-controller-test.js
index ddd921652..0b5c7226a 100644
--- a/test/unit/tx-controller-test.js
+++ b/test/unit/tx-controller-test.js
@@ -40,36 +40,6 @@ describe('Transaction Controller', function () {
txController.nonceTracker.getNonceLock = () => Promise.resolve({ nextNonce: 0, releaseLock: noop })
})
- describe('#isNonceTaken', function () {
- it('should return true', function (done) {
- txController.txStateManager._saveTxList([
- { id: 1, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: {nonce: 0, from: '0x8ACCE2391C0d510a6C5E5D8f819A678F79B7E675'} },
- { id: 2, status: 'confirmed', metamaskNetworkId: currentNetworkId, txParams: {nonce: 0, from: '0x8ACCE2391C0d510a6C5E5D8f819A678F79B7E675'} },
- { id: 3, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: {nonce: 0, from: '0x8ACCE2391C0d510a6C5E5D8f819A678F79B7E675'} },
- ])
- txController.isNonceTaken({txParams: {nonce:0, from:'0x8ACCE2391C0d510a6C5E5D8f819A678F79B7E675'}})
- .then((isNonceTaken) => {
- assert(isNonceTaken)
- done()
- }).catch(done)
-
- })
- it('should return false', function (done) {
- txController.txStateManager._saveTxList([
- { id: 1, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: {nonce: 0, from: '0x8ACCE2391C0d510a6C5E5D8f819A678F79B7E675'} },
- { id: 2, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: {nonce: 0, from: '0x8ACCE2391C0d510a6C5E5D8f819A678F79B7E675'} },
- { id: 3, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: {nonce: 0, from: '0x8ACCE2391C0d510a6C5E5D8f819A678F79B7E675'} },
- ])
-
- txController.isNonceTaken({txParams: {nonce:0, from:'0x8ACCE2391C0d510a6C5E5D8f819A678F79B7E675'}})
- .then((isNonceTaken) => {
- assert(!isNonceTaken)
- done()
- }).catch(done)
-
- })
- })
-
describe('#getState', function () {
it('should return a state object with the right keys and datat types', function () {
const exposedState = txController.getState()