From f4d0eadf9f956e8bee358fa6fd6f9752270c361c Mon Sep 17 00:00:00 2001 From: tom Date: Wed, 18 Dec 2024 08:44:45 +0100 Subject: [PATCH] fix sorting by block number on transactions page --- ui/txs/sortTxs.ts | 6 ++++++ ui/txs/useTxsSort.tsx | 1 + 2 files changed, 7 insertions(+) diff --git a/ui/txs/sortTxs.ts b/ui/txs/sortTxs.ts index 3993612e4c..a66afab633 100644 --- a/ui/txs/sortTxs.ts +++ b/ui/txs/sortTxs.ts @@ -13,6 +13,12 @@ export default function sortTxs(sorting: TransactionsSortingValue | undefined) { return compareBns(tx2.fee.value || 0, tx1.fee.value || 0); case 'fee-asc': return compareBns(tx1.fee.value || 0, tx2.fee.value || 0); + case 'block_number-asc': { + if (tx1.block_number && tx2.block_number) { + return tx1.block_number - tx2.block_number; + } + return 0; + } default: return 0; } diff --git a/ui/txs/useTxsSort.tsx b/ui/txs/useTxsSort.tsx index b3a77e5514..8999f3388c 100644 --- a/ui/txs/useTxsSort.tsx +++ b/ui/txs/useTxsSort.tsx @@ -15,6 +15,7 @@ export const SORT_OPTIONS: Array> = [ { label: 'Value descending', value: 'value-desc' }, { label: 'Fee ascending', value: 'fee-asc' }, { label: 'Fee descending', value: 'fee-desc' }, + { label: 'Block number ascending', value: 'block_number-asc' }, ]; type SortingValue = TransactionsSortingValue | undefined;