aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/helpers/transactions.util.js
diff options
context:
space:
mode:
authorAlexander Tseung <alextsg@gmail.com>2018-08-12 12:12:30 +0800
committerAlexander Tseung <alextsg@gmail.com>2018-08-24 07:45:27 +0800
commitb48a293af059d2ad23fea0af601740888acd3f8b (patch)
treefd72fb11cb22667b4c0fb1f66eb8f7e059234307 /ui/app/helpers/transactions.util.js
parent5dcd8ceb7bbaef33fef5588feceac17577679e74 (diff)
downloadtangerine-wallet-browser-b48a293af059d2ad23fea0af601740888acd3f8b.tar.gz
tangerine-wallet-browser-b48a293af059d2ad23fea0af601740888acd3f8b.tar.zst
tangerine-wallet-browser-b48a293af059d2ad23fea0af601740888acd3f8b.zip
Update retry transaction logic to use network nonce
Diffstat (limited to 'ui/app/helpers/transactions.util.js')
-rw-r--r--ui/app/helpers/transactions.util.js16
1 files changed, 7 insertions, 9 deletions
diff --git a/ui/app/helpers/transactions.util.js b/ui/app/helpers/transactions.util.js
index e890a0852..e92a22e16 100644
--- a/ui/app/helpers/transactions.util.js
+++ b/ui/app/helpers/transactions.util.js
@@ -2,7 +2,6 @@ import ethUtil from 'ethereumjs-util'
import MethodRegistry from 'eth-method-registry'
import abi from 'human-standard-token-abi'
import abiDecoder from 'abi-decoder'
-import { hexToDecimal } from './conversions.util'
import {
TOKEN_METHOD_TRANSFER,
@@ -76,21 +75,20 @@ export function getTransactionActionKey (transaction, methodData) {
}
}
-export function getLatestSubmittedTxWithEarliestNonce (transactions = []) {
+export function getLatestSubmittedTxWithNonce (transactions = [], nonce = '0x0') {
if (!transactions.length) {
return {}
}
return transactions.reduce((acc, current) => {
- const accNonce = hexToDecimal(acc.nonce)
- const currentNonce = hexToDecimal(current.nonce)
+ const { submittedTime, txParams: { nonce: currentNonce } = {} } = current
- if (currentNonce < accNonce) {
- return current
- } else if (currentNonce === accNonce) {
- return current.submittedTime > acc.submittedTime ? current : acc
+ if (currentNonce === nonce) {
+ return acc.submittedTime
+ ? submittedTime > acc.submittedTime ? current : acc
+ : current
} else {
return acc
}
- })
+ }, {})
}