From 3722f4608975171f1f24ddb1cbe5b8873e8f52aa Mon Sep 17 00:00:00 2001 From: Justin Starry Date: Sun, 14 Mar 2021 10:16:32 +0800 Subject: [PATCH] explorer: Add token symbol to token label (#15841) --- explorer/src/utils/tx.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/explorer/src/utils/tx.ts b/explorer/src/utils/tx.ts index bafad06815..2a1c2125fc 100644 --- a/explorer/src/utils/tx.ts +++ b/explorer/src/utils/tx.ts @@ -148,6 +148,19 @@ export function programLabel( } } +export function tokenLabel( + address: string, + tokenRegistry?: TokenInfoMap +): string | undefined { + if (!tokenRegistry) return; + const tokenInfo = tokenRegistry.get(address); + if (!tokenInfo) return; + if (tokenInfo.name === tokenInfo.symbol) { + return tokenInfo.name; + } + return `${tokenInfo.name} (${tokenInfo.symbol})`; +} + export function addressLabel( address: string, cluster: Cluster, @@ -158,7 +171,7 @@ export function addressLabel( LOADER_IDS[address] || SYSVAR_IDS[address] || SYSVAR_ID[address] || - tokenRegistry?.get(address)?.name || + tokenLabel(address, tokenRegistry) || SerumMarketRegistry.get(address, cluster) ); }