From 344c19dbe308637df6b7895eb5312569204a1db8 Mon Sep 17 00:00:00 2001 From: Justin Starry Date: Thu, 26 May 2022 10:54:25 +0800 Subject: [PATCH] explorer: Add fee column to block history card (#25573) --- .../src/components/block/BlockHistoryCard.tsx | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/explorer/src/components/block/BlockHistoryCard.tsx b/explorer/src/components/block/BlockHistoryCard.tsx index ff47db8fc..04bd56f2c 100644 --- a/explorer/src/components/block/BlockHistoryCard.tsx +++ b/explorer/src/components/block/BlockHistoryCard.tsx @@ -15,6 +15,7 @@ import { pickClusterParams, useQuery } from "utils/url"; import { useCluster } from "providers/cluster"; import { displayAddress } from "utils/tx"; import { parseProgramLogs } from "utils/program-logs"; +import { SolBalance } from "utils"; const PAGE_SIZE = 25; @@ -33,10 +34,11 @@ const useQueryAccountFilter = (query: URLSearchParams): PublicKey | null => { return null; }; -type SortMode = "index" | "compute"; +type SortMode = "index" | "compute" | "fee"; const useQuerySort = (query: URLSearchParams): SortMode => { const sort = query.get("sort"); if (sort === "compute") return "compute"; + if (sort === "fee") return "fee"; return "index"; }; @@ -151,6 +153,8 @@ export function BlockHistoryCard({ block }: { block: BlockResponse }) { if (sortMode === "compute" && showComputeUnits) { filteredTxs.sort((a, b) => b.computeUnits! - a.computeUnits!); + } else if (sortMode === "fee") { + filteredTxs.sort((a, b) => (b.meta?.fee || 0) - (a.meta?.fee || 0)); } return [filteredTxs, showComputeUnits]; @@ -217,9 +221,18 @@ export function BlockHistoryCard({ block }: { block: BlockResponse }) { Result Transaction Signature + { + query.set("sort", "fee"); + history.push(pickClusterParams(location, query)); + }} + > + Fee + {showComputeUnits && ( { query.set("sort", "compute"); history.push(pickClusterParams(location, query)); @@ -267,6 +280,15 @@ export function BlockHistoryCard({ block }: { block: BlockResponse }) { {signature} + + + {tx.meta !== null ? ( + + ) : ( + "Unknown" + )} + + {showComputeUnits && ( {tx.logTruncated && ">"}