aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts
diff options
context:
space:
mode:
authorfrankiebee <frankie.diamond@gmail.com>2018-05-02 04:57:43 +0800
committerfrankiebee <frankie.diamond@gmail.com>2018-05-02 04:57:43 +0800
commita45cb754358ff798dce25fa0b44d6b182abc7692 (patch)
tree968d6f937dbfa36706c32a872f8bcb6c3215f30a /app/scripts
parent62bf76db53cf0702739d2735edfe8ffcb142b7c2 (diff)
downloadtangerine-wallet-browser-a45cb754358ff798dce25fa0b44d6b182abc7692.tar
tangerine-wallet-browser-a45cb754358ff798dce25fa0b44d6b182abc7692.tar.gz
tangerine-wallet-browser-a45cb754358ff798dce25fa0b44d6b182abc7692.tar.bz2
tangerine-wallet-browser-a45cb754358ff798dce25fa0b44d6b182abc7692.tar.lz
tangerine-wallet-browser-a45cb754358ff798dce25fa0b44d6b182abc7692.tar.xz
tangerine-wallet-browser-a45cb754358ff798dce25fa0b44d6b182abc7692.tar.zst
tangerine-wallet-browser-a45cb754358ff798dce25fa0b44d6b182abc7692.zip
transactions - add a nonce check utility for ui use
Diffstat (limited to 'app/scripts')
-rw-r--r--app/scripts/controllers/transactions/index.js15
-rw-r--r--app/scripts/metamask-controller.js1
2 files changed, 16 insertions, 0 deletions
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
@@ -112,6 +112,21 @@ 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} 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
@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 c4a73d8ea..a90acb4d5 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -382,6 +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),
// messageManager
signMessage: nodeify(this.signMessage, this),