diff --git a/explorer/src/components/SearchBar.tsx b/explorer/src/components/SearchBar.tsx index be18957d8..88cc2b80e 100644 --- a/explorer/src/components/SearchBar.tsx +++ b/explorer/src/components/SearchBar.tsx @@ -6,6 +6,7 @@ import StateManager from "react-select"; import { LOADER_IDS, PROGRAM_NAME_BY_ID, + SPECIAL_IDS, SYSVAR_IDS, LoaderName, programLabel, @@ -141,6 +142,28 @@ function buildSysvarOptions(search: string) { } } +function buildSpecialOptions(search: string) { + const matchedSpecialIds = Object.entries(SPECIAL_IDS).filter( + ([address, name]) => { + return ( + name.toLowerCase().includes(search.toLowerCase()) || + address.includes(search) + ); + } + ); + + if (matchedSpecialIds.length > 0) { + return { + label: "Accounts", + options: matchedSpecialIds.map(([id, name]) => ({ + label: name, + value: [name, id], + pathname: "/address/" + id, + })), + }; + } +} + function buildTokenOptions( search: string, cluster: Cluster, @@ -194,6 +217,11 @@ function buildOptions( options.push(sysvarOptions); } + const specialOptions = buildSpecialOptions(search); + if (specialOptions) { + options.push(specialOptions); + } + const tokenOptions = buildTokenOptions(search, cluster, tokenRegistry); if (tokenOptions) { options.push(tokenOptions); diff --git a/explorer/src/utils/tx.ts b/explorer/src/utils/tx.ts index ae14d0f2b..a5177287f 100644 --- a/explorer/src/utils/tx.ts +++ b/explorer/src/utils/tx.ts @@ -132,7 +132,8 @@ export const LOADER_IDS = { BPFLoaderUpgradeab1e11111111111111111111111: "BPF Upgradeable Loader", } as const; -const SYSVAR_ID: { [key: string]: string } = { +export const SPECIAL_IDS: { [key: string]: string } = { + "1nc1nerator11111111111111111111111111111111": "Incinerator", Sysvar1111111111111111111111111111111111111: "SYSVAR", }; @@ -182,7 +183,7 @@ export function addressLabel( return ( programLabel(address, cluster) || SYSVAR_IDS[address] || - SYSVAR_ID[address] || + SPECIAL_IDS[address] || tokenLabel(address, tokenRegistry) || SerumMarketRegistry.get(address, cluster) );