aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/helpers
diff options
context:
space:
mode:
authorAlexander Tseung <alextsg@gmail.com>2018-08-03 11:20:15 +0800
committerAlexander Tseung <alextsg@gmail.com>2018-08-24 07:44:44 +0800
commit5ddd9b55be0d8bd778822b4b401cbd22a7b57c54 (patch)
tree607cb4747aba68d7f6127e5f1bfb6d732f735acf /ui/app/helpers
parentfa8313f9036882e1a558d871f4e520da71ffaa03 (diff)
downloadtangerine-wallet-browser-5ddd9b55be0d8bd778822b4b401cbd22a7b57c54.tar.gz
tangerine-wallet-browser-5ddd9b55be0d8bd778822b4b401cbd22a7b57c54.tar.zst
tangerine-wallet-browser-5ddd9b55be0d8bd778822b4b401cbd22a7b57c54.zip
Add retry button to TransactionListItem
Diffstat (limited to 'ui/app/helpers')
-rw-r--r--ui/app/helpers/transactions.util.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/ui/app/helpers/transactions.util.js b/ui/app/helpers/transactions.util.js
index 04cef150f..68e935702 100644
--- a/ui/app/helpers/transactions.util.js
+++ b/ui/app/helpers/transactions.util.js
@@ -2,6 +2,8 @@ import ethUtil from 'ethereumjs-util'
import MethodRegistry from 'eth-method-registry'
const registry = new MethodRegistry({ provider: global.ethereumProvider })
+import { hexToDecimal } from './conversions.util'
+
import {
TOKEN_METHOD_TRANSFER,
TOKEN_METHOD_APPROVE,
@@ -55,3 +57,22 @@ export async function getMethodData (data = {}) {
params: parsedResult.args,
}
}
+
+export function getLatestSubmittedTxWithEarliestNonce (transactions = []) {
+ if (!transactions.length) {
+ return {}
+ }
+
+ return transactions.reduce((acc, current) => {
+ const accNonce = hexToDecimal(acc.nonce)
+ const currentNonce = hexToDecimal(current.nonce)
+
+ if (currentNonce < accNonce) {
+ return current
+ } else if (currentNonce === accNonce) {
+ return current.submittedTime > acc.submittedTime ? current : acc
+ } else {
+ return acc
+ }
+ })
+}