diff --git a/explorer/src/components/SearchBar.tsx b/explorer/src/components/SearchBar.tsx index 9e1bca15a9..0dedc91cf3 100644 --- a/explorer/src/components/SearchBar.tsx +++ b/explorer/src/components/SearchBar.tsx @@ -60,7 +60,7 @@ const SEARCHABLE_PROGRAMS: ProgramName[] = [ "Stake Program", "System Program", "Vote Program", - "SPL Token", + "SPL Token Program", ]; function buildProgramOptions(search: string) { diff --git a/explorer/src/components/account/TokenAccountSection.tsx b/explorer/src/components/account/TokenAccountSection.tsx index 4b1917f0f8..21a3c63d5b 100644 --- a/explorer/src/components/account/TokenAccountSection.tsx +++ b/explorer/src/components/account/TokenAccountSection.tsx @@ -89,7 +89,7 @@ function MintAccountCard({ )} - {tokenInfo && ( + {tokenInfo?.website && ( Website diff --git a/explorer/src/components/account/UnknownAccountCard.tsx b/explorer/src/components/account/UnknownAccountCard.tsx index 115f3cd143..17a9a45721 100644 --- a/explorer/src/components/account/UnknownAccountCard.tsx +++ b/explorer/src/components/account/UnknownAccountCard.tsx @@ -3,11 +3,15 @@ import { Account } from "providers/accounts"; import { lamportsToSolString } from "utils"; import { TableCardBody } from "components/common/TableCardBody"; import { Address } from "components/common/Address"; +import { addressLabel } from "utils/tx"; +import { useCluster } from "providers/cluster"; export function UnknownAccountCard({ account }: { account: Account }) { const { details, lamports } = account; + const { cluster } = useCluster(); if (lamports === undefined) return null; + const label = addressLabel(account.pubkey.toBase58(), cluster); return (
@@ -21,6 +25,12 @@ export function UnknownAccountCard({ account }: { account: Account }) {
+ {label && ( + + Address Label + {label} + + )} Balance (SOL) diff --git a/explorer/src/pages/AccountDetailsPage.tsx b/explorer/src/pages/AccountDetailsPage.tsx index ff9810f9a7..2d54fb26c5 100644 --- a/explorer/src/pages/AccountDetailsPage.tsx +++ b/explorer/src/pages/AccountDetailsPage.tsx @@ -50,15 +50,17 @@ export function AccountHeader({ address }: { address: string }) { if (tokenDetails) { return (
-
-
- token logo + {tokenDetails.logo && ( +
+
+ token logo +
-
+ )}
Token
diff --git a/explorer/src/tokenRegistry.ts b/explorer/src/tokenRegistry.ts index ee289d50a2..98a630d145 100644 --- a/explorer/src/tokenRegistry.ts +++ b/explorer/src/tokenRegistry.ts @@ -3,22 +3,17 @@ import { Cluster } from "providers/cluster"; export type TokenDetails = { name: string; symbol: string; - logo: string; - icon: string; - website: string; + logo?: string; + icon?: string; + website?: string; }; -const ENABLE_DETAILS = !!new URLSearchParams(window.location.search).get( - "test" -); - function get(address: string, cluster: Cluster): TokenDetails | undefined { - if (ENABLE_DETAILS && cluster === Cluster.MainnetBeta) - return MAINNET_TOKENS[address]; + if (cluster === Cluster.MainnetBeta) return MAINNET_TOKENS[address]; } function all(cluster: Cluster) { - if (ENABLE_DETAILS && cluster === Cluster.MainnetBeta) return MAINNET_TOKENS; + if (cluster === Cluster.MainnetBeta) return MAINNET_TOKENS; return {}; } @@ -28,11 +23,44 @@ export const TokenRegistry = { }; const MAINNET_TOKENS: { [key: string]: TokenDetails } = { - MSRMmR98uWsTBgusjwyNkE8nDtV79sJznTedhJLzS4B: { + SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt: { + name: "Serum", + symbol: "SRM", + }, + MSRMcoVyrFxnSgo5uXwone5SKcGhT1KEJMFEkMEWf9L: { name: "MegaSerum", symbol: "MSRM", - logo: "/tokens/serum-64.png", - icon: "/tokens/serum-32.png", - website: "https://projectserum.com", + }, + "9n4nbM75f5Ui33ZbPYXn59EwSgE8CGsHtAeTH5YFeJ9E": { + symbol: "BTC", + name: "Wrapped Bitcoin", + }, + "2FPyTwcZLUg1MDrwsyoP4D6s1tM7hAkHYRjkNb5w6Pxk": { + symbol: "ETH", + name: "Wrapped Ethereum", + }, + AGFEad2et2ZJif9jaGpdMixQqvW5i81aBdvKe7PHNfz3: { + symbol: "FTT", + name: "Wrapped FTT", + }, + "3JSf5tPeuscJGtaCp5giEiDhv51gQ4v3zWg8DGgyLfAB": { + symbol: "YFI", + name: "Wrapped YFI", + }, + CWE8jPTUYhdCTZYWPTe1o5DFqfdjzWKc9WKz6rSjQUdG: { + symbol: "LINK", + name: "Wrapped Chainlink", + }, + Ga2AXHpfAF6mv2ekZwcsJFqu7wB4NV331qNH7fW9Nst8: { + symbol: "XRP", + name: "Wrapped XRP", + }, + BQcdHdAQW1hczDbBi9hiegXAR7A98Q9jx3X3iBBBDiq4: { + symbol: "USDT", + name: "Wrapped USDT", + }, + BXXkv6z8ykpG1yuvUDPgh732wzVHB69RnB9YgSYh3itW: { + symbol: "USDC", + name: "Wrapped USDC", }, }; diff --git a/explorer/src/utils/tx.ts b/explorer/src/utils/tx.ts index d975f0ac41..835c7ea938 100644 --- a/explorer/src/utils/tx.ts +++ b/explorer/src/utils/tx.ts @@ -24,7 +24,7 @@ export type ProgramName = | "System Program" | "Vest Program" | "Vote Program" - | "SPL Token"; + | "SPL Token Program"; export const PROGRAM_IDS: { [key: string]: ProgramName } = { Budget1111111111111111111111111111111111111: "Budget Program", @@ -35,13 +35,13 @@ export const PROGRAM_IDS: { [key: string]: ProgramName } = { [SystemProgram.programId.toBase58()]: "System Program", Vest111111111111111111111111111111111111111: "Vest Program", [VOTE_PROGRAM_ID.toBase58()]: "Vote Program", - TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA: "SPL Token", + TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA: "SPL Token Program", }; const LOADER_IDS = { MoveLdr111111111111111111111111111111111111: "Move Loader", NativeLoader1111111111111111111111111111111: "Native Loader", - [BpfLoader.programId().toBase58()]: "BPF Loader", + [BpfLoader.programId(1).toBase58()]: "BPF Loader", [BpfLoader.programId(2).toBase58()]: "BPF Loader 2", }; @@ -65,18 +65,24 @@ export const SYSVAR_IDS = { [SYSVAR_STAKE_HISTORY_PUBKEY.toBase58()]: "SYSVAR_STAKE_HISTORY", }; -export function displayAddress(address: string, cluster: Cluster): string { +export function addressLabel( + address: string, + cluster: Cluster +): string | undefined { return ( PROGRAM_IDS[address] || LOADER_IDS[address] || SYSVAR_IDS[address] || SYSVAR_ID[address] || WRAPPED_SOL[address] || - TokenRegistry.get(address, cluster)?.name || - address + TokenRegistry.get(address, cluster)?.name ); } +export function displayAddress(address: string, cluster: Cluster): string { + return addressLabel(address, cluster) || address; +} + export function intoTransactionInstruction( tx: ParsedTransaction, index: number