From f1a5ac792c2d6999dc4726bcc3d07651b2a0bd12 Mon Sep 17 00:00:00 2001 From: rajgoesout Date: Tue, 25 Nov 2025 07:06:54 +0530 Subject: [PATCH] Make tx cost consistent across block page and transaction signature page Show `Not Supported Slot` instead of showing 0 value or making the component disappear. Fixes https://github.com/solana-foundation/explorer/issues/662 --- app/components/block/BlockHistoryCard.tsx | 6 +++--- app/tx/[signature]/page-client.tsx | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/components/block/BlockHistoryCard.tsx b/app/components/block/BlockHistoryCard.tsx index 366936b74..04e2d0564 100755 --- a/app/components/block/BlockHistoryCard.tsx +++ b/app/components/block/BlockHistoryCard.tsx @@ -118,7 +118,7 @@ export function BlockHistoryCard({ block, epoch }: { block: VersionedBlockRespon let costUnits: number | undefined = undefined; try { - costUnits = tx.meta?.costUnits ?? 0; + costUnits = tx.meta?.costUnits; } catch (err) { // ignore parsing errors because some old logs aren't parsable } @@ -172,7 +172,7 @@ export function BlockHistoryCard({ block, epoch }: { block: VersionedBlockRespon if (sortMode === 'compute' && showComputeUnits) { filteredTxs.sort((a, b) => b.computeUnits! - a.computeUnits!); } else if (sortMode === 'txnCost') { - filteredTxs.sort((a, b) => b.costUnits! - a.costUnits!); + filteredTxs.sort((a, b) => (b.costUnits ?? 0) - (a.costUnits ?? 0)); } else if (sortMode === 'fee') { filteredTxs.sort((a, b) => (b.meta?.fee || 0) - (a.meta?.fee || 0)); } else if (sortMode === 'reservedCUs') { @@ -345,7 +345,7 @@ export function BlockHistoryCard({ block, epoch }: { block: VersionedBlockRespon {tx.costUnits !== undefined ? new Intl.NumberFormat('en-US').format(tx.costUnits) - : 'Unknown'} + : 'Not Supported Slot'} {tx.invocations.size === 0 diff --git a/app/tx/[signature]/page-client.tsx b/app/tx/[signature]/page-client.tsx index c33f3d151..553ba27fd 100644 --- a/app/tx/[signature]/page-client.tsx +++ b/app/tx/[signature]/page-client.tsx @@ -346,12 +346,12 @@ function StatusCard({ signature, autoRefresh }: SignatureProps & AutoRefreshProp )} - {costUnits !== undefined && ( - - Transaction cost - {costUnits.toLocaleString('en-US')} - - )} + + Transaction cost + + {costUnits !== undefined ? costUnits.toLocaleString('en-US') : 'Not Supported Slot'} + + {reservedCUs !== undefined && (