diff options
author | Alexander Tseung <alextsg@gmail.com> | 2018-08-03 11:20:15 +0800 |
---|---|---|
committer | Alexander Tseung <alextsg@gmail.com> | 2018-08-24 07:44:44 +0800 |
commit | 5ddd9b55be0d8bd778822b4b401cbd22a7b57c54 (patch) | |
tree | 607cb4747aba68d7f6127e5f1bfb6d732f735acf /ui/app/helpers | |
parent | fa8313f9036882e1a558d871f4e520da71ffaa03 (diff) | |
download | tangerine-wallet-browser-5ddd9b55be0d8bd778822b4b401cbd22a7b57c54.tar tangerine-wallet-browser-5ddd9b55be0d8bd778822b4b401cbd22a7b57c54.tar.gz tangerine-wallet-browser-5ddd9b55be0d8bd778822b4b401cbd22a7b57c54.tar.bz2 tangerine-wallet-browser-5ddd9b55be0d8bd778822b4b401cbd22a7b57c54.tar.lz tangerine-wallet-browser-5ddd9b55be0d8bd778822b4b401cbd22a7b57c54.tar.xz 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.js | 21 |
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 + } + }) +} |