- Updates how the transactions are ordered, now orders by nonce and then by date (#640)

This commit is contained in:
Agustin Pane 2020-03-09 09:15:04 -03:00 committed by GitHub
parent aaa480c2a5
commit 558b9f69f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 4 deletions

View File

@ -74,13 +74,31 @@ const TxsTable = ({
const columns = generateColumns()
const autoColumns = columns.filter(c => !c.custom)
const filteredData = getTxTableData(transactions, cancellationTransactions)
.sort(({ dateOrder: a }, { dateOrder: b }) => {
if (!a || !b) {
.sort((tx1, tx2) => {
// First order by nonce
const aNonce = tx1.tx.nonce
const bNonce = tx1.tx.nonce
if (aNonce && bNonce) {
const difference = aNonce - bNonce
if (difference !== 0) {
return difference
}
}
// If can't be ordered by nonce, order by date
const aDateOrder = tx1.dateOrder
const bDateOrder = tx2.dateOrder
// Second by date
if (!aDateOrder || !bDateOrder) {
return 0
}
return a - b
return aDateOrder - bDateOrder
})
.map((tx, id) => {
return {
...tx,
id,
}
})
.map((tx, id) => ({ ...tx, id }))
return (
<Block className={classes.container}>