From a45cb754358ff798dce25fa0b44d6b182abc7692 Mon Sep 17 00:00:00 2001 From: frankiebee Date: Tue, 1 May 2018 13:57:43 -0700 Subject: transactions - add a nonce check utility for ui use --- app/scripts/controllers/transactions/index.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'app/scripts/controllers/transactions/index.js') diff --git a/app/scripts/controllers/transactions/index.js b/app/scripts/controllers/transactions/index.js index 541f1db73..a1588cfef 100644 --- a/app/scripts/controllers/transactions/index.js +++ b/app/scripts/controllers/transactions/index.js @@ -111,6 +111,21 @@ class TransactionController extends EventEmitter { this.txStateManager.wipeTransactions(address) } + /** + 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} weather 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 -- cgit