/** * Trims the address to the first 5 and last 5 characters. * @param address The address to trim. * @returns The trimmed address. */ export function trimAddress(address: string): string { if (address.length < 11) return address const trimmedAddress = `${address.slice(0, 5)}...${address.slice(-5)}` return trimmedAddress } const MAINNET_EXPLORER_URLS: Record<"bitcoin" | "evm" | "mezo", string> = { bitcoin: "https://mempool.space", evm: "https://etherscan.io", mezo: "https://explorer.mezo.org", } const TESTNET_EXPLORER_URLS: Record<"bitcoin" | "evm" | "mezo", string> = { bitcoin: "https://mempool.space/testnet", evm: "https://sepolia.etherscan.io", mezo: "https://explorer.test.mezo.org", } /** * Get the URL of the block explorer page for an address. * @param address - The address to link to. * @param chainType - The chain type of the address. * @param isTestnet - Whether the address is on testnet. * @returns The URL of the block explorer page for the address. */ export function getAddressExplorerUrl( address: string, chainType: "bitcoin" | "evm" | "mezo", isTestnet: boolean, ) { const EXPLORER_URLS = isTestnet ? TESTNET_EXPLORER_URLS : MAINNET_EXPLORER_URLS const baseUrl = EXPLORER_URLS[chainType] const endpoint = `address/${address}` return `${baseUrl}/${endpoint}` }