{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"asset-row","type":"registry:ui","title":"Asset Row","description":"Displays a practical portfolio or watchlist row from token identity, network, amount, value, and change.","docs":"```tsx\nimport { AssetRow } from \"@/components/ui/asset-row\"\n\n<AssetRow symbol=\"ETH\" name=\"Ethereum\" amount={1.2845} value={4163.91} change={2.41} chainId={1} />\n```","dependencies":["lucide-react","viem@2.55.19"],"devDependencies":[],"registryDependencies":["tooltip"],"cssVars":{"theme":{"color-positive":"var(--positive, var(--onchain-positive))","color-negative":"var(--negative, var(--onchain-negative))"},"light":{"onchain-positive":"oklch(0.596 0.145 163.225)","onchain-negative":"oklch(0.577 0.245 27.325)"},"dark":{"onchain-positive":"oklch(0.765 0.177 163.223)","onchain-negative":"oklch(0.704 0.191 22.216)"}},"files":[{"path":"registry/onchain-ui/asset-row.tsx","type":"registry:ui","target":"components/ui/asset-row.tsx","content":"import { cn } from \"@/lib/utils\";\nimport {\n  parseNumericValue,\n  type NumericValue,\n} from \"@/lib/onchain/format\";\nimport { NetworkLogo, type NetworkLogoProps } from \"./network-logo\";\nimport { TokenLogo, type TokenLogoProps } from \"./token-logo\";\nimport { TokenPrice, type TokenPriceProps } from \"./token-price\";\nimport type { ReactNode } from \"react\";\n\ntype AmountValue = NumericValue;\n\nexport interface AssetRowProps {\n  /** Token symbol */\n  symbol: string;\n  /** Token name */\n  name?: string | null | undefined;\n  /** Token image URL */\n  src?: string | null | undefined;\n  /** Token contract address */\n  address?: string | null | undefined;\n  /** Whether the asset is the chain's native currency */\n  isNative?: boolean | undefined;\n  /** Token amount held by the user */\n  amount?: AmountValue | undefined;\n  /** Fiat value for the position */\n  value?: TokenPriceProps[\"value\"] | undefined;\n  /** Price or position change percentage */\n  change?: TokenPriceProps[\"change\"] | undefined;\n  /** Optional network chain id for the logo badge */\n  chainId?: number | null | undefined;\n  /** Optional network name for the logo badge */\n  networkName?: string | null | undefined;\n  /** Optional network image URL for the logo badge */\n  networkSrc?: string | null | undefined;\n  /** Secondary metadata shown beside the token name */\n  subtitle?: ReactNode | undefined;\n  /** A second line under the name, e.g. the symbol and contract address */\n  description?: ReactNode | undefined;\n  /**\n   * Replaces the token logo and network badge, e.g. with a TokenStack for a\n   * basket or LP position\n   */\n  logo?: ReactNode | undefined;\n  /**\n   * Formats the right-side amount instead of \"1,234.5678 SYMBOL\", for apps\n   * with a house number style\n   */\n  formatAmount?: ((amount: number) => ReactNode) | undefined;\n  /** Row density. `sm` suits pickers and dense lists. Default: default */\n  size?: \"default\" | \"sm\" | undefined;\n  /** Hide the right-side amount. Default: false */\n  hideAmount?: boolean | undefined;\n  /** Locale passed to Intl.NumberFormat */\n  locale?: string | undefined;\n  /** Maximum fraction digits for the token amount. Default: 4 */\n  maximumFractionDigits?: number | undefined;\n  /** Props passed to TokenLogo */\n  logoProps?: Partial<TokenLogoProps> | undefined;\n  /** Props passed to NetworkLogo */\n  networkLogoProps?: Partial<NetworkLogoProps> | undefined;\n  /** Props passed to TokenPrice, e.g. `format` and `formatChange` */\n  priceProps?: Partial<TokenPriceProps> | undefined;\n  /** Applied to the root wrapper */\n  className?: string | undefined;\n  /** Applied to the token identity block */\n  identityClassName?: string | undefined;\n  /** Applied to the right-side value block */\n  valueClassName?: string | undefined;\n}\n\nfunction formatAmount({\n  locale,\n  maximumFractionDigits,\n  value,\n}: {\n  locale?: string | undefined;\n  maximumFractionDigits: number;\n  value: number;\n}) {\n  return new Intl.NumberFormat(locale, {\n    maximumFractionDigits,\n  }).format(value);\n}\n\n// Spacing and type per size. `default` is the portfolio-card row; `sm` is a\n// dense list row, e.g. a token picker inside a menu or dialog.\nconst sizeClasses = {\n  default: {\n    root: \"gap-4 px-1 py-3\",\n    identity: \"gap-3\",\n    name: \"text-base font-medium leading-tight\",\n    secondary: \"text-sm\",\n    value: \"text-base\",\n    valueWeight: \"font-semibold\",\n    valueGap: \"gap-1\",\n    logo: \"xl\",\n    network: \"xs\",\n  },\n  sm: {\n    root: \"gap-3 px-3 py-2.5\",\n    identity: \"gap-3\",\n    name: \"text-sm font-medium\",\n    secondary: \"text-xs\",\n    value: \"text-sm\",\n    valueWeight: \"font-medium\",\n    valueGap: \"gap-0\",\n    logo: \"md\",\n    network: \"xs\",\n  },\n} as const;\n\nexport function AssetRow({\n  symbol,\n  name,\n  src,\n  address,\n  isNative = false,\n  amount,\n  value,\n  change,\n  chainId,\n  networkName,\n  networkSrc,\n  subtitle,\n  description,\n  logo,\n  hideAmount = false,\n  locale,\n  maximumFractionDigits = 4,\n  formatAmount: formatAmountProp,\n  size = \"default\",\n  logoProps,\n  networkLogoProps,\n  priceProps,\n  className,\n  identityClassName,\n  valueClassName,\n}: AssetRowProps) {\n  const parsedAmount = parseNumericValue(amount);\n  const hasNetwork = Boolean(chainId || networkName || networkSrc);\n  const hasValue = value !== null && value !== undefined && value !== \"\";\n  const hasChange = typeof change === \"number\" && Number.isFinite(change);\n  const hasDescription = description != null && description !== false;\n  const showAmount = !hideAmount && parsedAmount !== null;\n  const s = sizeClasses[size];\n\n  // Spans throughout, so the row can sit inside a <button> or <a> (a picker\n  // row is usually one); div and p are not valid there.\n  return (\n    <span\n      data-slot=\"asset-row\"\n      className={cn(\n        \"flex w-full min-w-0 items-center justify-between rounded-lg\",\n        s.root,\n        className\n      )}\n    >\n      <span\n        className={cn(\n          \"flex min-w-0 flex-1 items-center\",\n          s.identity,\n          identityClassName\n        )}\n      >\n        <span className=\"relative shrink-0\">\n          {logo ?? (\n            <>\n              <TokenLogo\n                address={address}\n                chainId={chainId}\n                isNative={isNative}\n                name={name}\n                size={s.logo}\n                src={src}\n                symbol={symbol}\n                {...logoProps}\n              />\n              {hasNetwork && (\n                <NetworkLogo\n                  chainId={chainId}\n                  className=\"absolute -bottom-1 -right-1 ring-2 ring-background\"\n                  name={networkName}\n                  size={s.network}\n                  src={networkSrc}\n                  {...networkLogoProps}\n                />\n              )}\n            </>\n          )}\n        </span>\n\n        <span className=\"block min-w-0 flex-1\">\n          <span className=\"flex min-w-0 items-baseline gap-2\">\n            <span className={cn(\"block truncate\", s.name)}>\n              {name ?? symbol}\n            </span>\n            {subtitle && (\n              <span className={cn(\"truncate text-muted-foreground\", s.secondary)}>\n                {subtitle}\n              </span>\n            )}\n          </span>\n          {hasDescription && (\n            <span\n              className={cn(\n                \"flex min-w-0 items-center gap-1.5 text-muted-foreground\",\n                s.secondary\n              )}\n            >\n              {description}\n            </span>\n          )}\n          {hasChange && (\n            <TokenPrice\n              {...priceProps}\n              value={null}\n              fallback={null}\n              change={change}\n              className=\"mt-1 gap-0\"\n              priceClassName=\"hidden\"\n              changeClassName={cn(s.secondary, priceProps?.changeClassName)}\n            />\n          )}\n        </span>\n      </span>\n\n      {/* Omitted when empty: an empty block still takes the row's gap, which\n          truncated the name early on rows with nothing held. */}\n      {(hasValue || showAmount) && (\n        <span className={cn(\"grid shrink-0 text-right\", s.valueGap, valueClassName)}>\n          {hasValue && (\n            <TokenPrice\n              {...priceProps}\n              value={value}\n              change={null}\n              className={cn(\"justify-end\", s.value, priceProps?.className)}\n              priceClassName={cn(s.valueWeight, priceProps?.priceClassName)}\n            />\n          )}\n          {showAmount && (\n            <span\n              className={cn(\n                \"block font-mono text-muted-foreground tabular-nums\",\n                s.secondary\n              )}\n            >\n              {formatAmountProp\n                ? formatAmountProp(parsedAmount)\n                : `${formatAmount({ locale, maximumFractionDigits, value: parsedAmount })} ${symbol}`}\n            </span>\n          )}\n        </span>\n      )}\n    </span>\n  );\n}\n"},{"path":"registry/onchain-ui/token-logo.tsx","type":"registry:ui","target":"components/ui/token-logo.tsx","content":"\"use client\";\n\nimport { useMemo, useState, type ReactNode } from \"react\";\nimport { cn } from \"@/lib/utils\";\nimport { getTokenIcon } from \"@/lib/onchain/crypto-icons\";\nimport {\n  Tooltip,\n  TooltipContent,\n  TooltipTrigger,\n} from \"@/components/ui/tooltip\";\n\nconst sizeClasses = {\n  xs: \"size-5 text-[9px]\",\n  sm: \"size-6 text-[10px]\",\n  md: \"size-8 text-xs\",\n  lg: \"size-10 text-sm\",\n  xl: \"size-12 text-base\",\n} as const;\n\n// Pixel sizes for layouts that size marks in px rather than steps. The font\n// tracks the named sizes (~3/8 of the diameter) with a floor for legibility.\n// Kept as numbers for a literal style object: shadcn/lint's no-inline-styles\n// cannot check a computed one.\nfunction getPixelFontSize(size: number) {\n  return Math.max(8, Math.round(size * 0.375));\n}\n\nexport interface TokenLogoProps {\n  /** Token image URL. Always wins over inferred icons */\n  src?: string | null | undefined;\n  /** Token symbol, used for alt text and fallback initials */\n  symbol?: string | null | undefined;\n  /** Token name, used for alt text */\n  name?: string | null | undefined;\n  /** Token contract address, used for icon inference and as a fallback label */\n  address?: string | null | undefined;\n  /** EVM chain id, used with address to infer an icon via the crypto-icons adapter */\n  chainId?: number | null | undefined;\n  /** Use the native-currency icon rather than the wrapped token at `address` */\n  isNative?: boolean | undefined;\n  /** Named size, or a diameter in pixels such as 28. Default: md */\n  size?: keyof typeof sizeClasses | number | undefined;\n  /** Custom fallback content when the image is missing or fails */\n  fallback?: ReactNode | undefined;\n  /** Show an animated tooltip. Default: false */\n  showTooltip?: boolean | undefined;\n  /** Tooltip content. Defaults to name, symbol, then address. */\n  tooltipContent?: ReactNode | undefined;\n  /**\n   * `tile` draws the image on a bordered muted circle. `bare` draws it on\n   * nothing, for logos that bring their own padding on a transparent canvas,\n   * where a tile reads as a ring around every mark. Default: tile\n   */\n  variant?: \"tile\" | \"bare\" | undefined;\n  /** Load the image eagerly at high priority, for logos above the fold */\n  priority?: boolean | undefined;\n  /** Applied to the root wrapper */\n  className?: string | undefined;\n  /** Applied to the image */\n  imageClassName?: string | undefined;\n  /** Applied to the fallback */\n  fallbackClassName?: string | undefined;\n}\n\nfunction getFallbackText({\n  address,\n  name,\n  symbol,\n}: Pick<TokenLogoProps, \"address\" | \"name\" | \"symbol\">) {\n  if (symbol) return symbol.slice(0, 4).toUpperCase();\n  if (name) return name.slice(0, 2).toUpperCase();\n  if (address) return address.slice(2, 4).toUpperCase();\n  return \"?\";\n}\n\nexport function TokenLogo({\n  src,\n  symbol,\n  name,\n  address,\n  chainId,\n  isNative = false,\n  size = \"md\",\n  fallback,\n  showTooltip = false,\n  tooltipContent,\n  variant = \"tile\",\n  priority = false,\n  className,\n  imageClassName,\n  fallbackClassName,\n}: TokenLogoProps) {\n  const [failedSrc, setFailedSrc] = useState<string | null>(null);\n\n  // Explicit src wins; otherwise ask the crypto-icons adapter.\n  const inferredIcon = useMemo(\n    () =>\n      src ? null : getTokenIcon({ chainId, address, isNative, symbol }),\n    [address, chainId, isNative, src, symbol]\n  );\n  const resolvedSrc =\n    src ?? (typeof inferredIcon === \"string\" ? inferredIcon : null);\n  const inferredNode =\n    inferredIcon != null && typeof inferredIcon !== \"string\"\n      ? inferredIcon\n      : null;\n  const shouldShowImage = Boolean(resolvedSrc) && failedSrc !== resolvedSrc;\n\n  const alt = useMemo(() => {\n    if (name && symbol) return `${name} (${symbol})`;\n    return name ?? symbol ?? address ?? \"Token\";\n  }, [address, name, symbol]);\n\n  const tooltip = tooltipContent ?? name ?? symbol ?? address;\n\n  // The fallback keeps its tile in every variant, so a missing logo is still\n  // a visible shape.\n  const bare = variant === \"bare\" && (shouldShowImage || inferredNode != null);\n  const px = typeof size === \"number\" ? size : undefined;\n\n  const logo = (\n    <span\n      className={cn(\n        \"relative inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full font-medium text-muted-foreground\",\n        bare ? null : \"border bg-muted\",\n        px === undefined ? sizeClasses[size as keyof typeof sizeClasses] : null,\n        className\n      )}\n      style={{\n        width: px,\n        height: px,\n        fontSize: px === undefined ? undefined : getPixelFontSize(px),\n      }}\n    >\n      {shouldShowImage ? (\n        <img\n          src={resolvedSrc ?? undefined}\n          alt={alt}\n          className={cn(\n            \"size-full\",\n            variant === \"bare\" ? \"object-contain\" : \"object-cover\",\n            imageClassName\n          )}\n          loading={priority ? \"eager\" : \"lazy\"}\n          fetchPriority={priority ? \"high\" : undefined}\n          decoding=\"async\"\n          referrerPolicy=\"no-referrer\"\n          onError={() => setFailedSrc(resolvedSrc)}\n        />\n      ) : inferredNode ? (\n        inferredNode\n      ) : (\n        <span className={cn(\"select-none\", fallbackClassName)}>\n          {fallback ?? getFallbackText({ address, name, symbol })}\n        </span>\n      )}\n    </span>\n  );\n\n  if (!showTooltip || tooltip == null) return logo;\n\n  return (\n    <Tooltip>\n      <TooltipTrigger render={logo} />\n      <TooltipContent>{tooltip}</TooltipContent>\n    </Tooltip>\n  );\n}\n"},{"path":"registry/onchain-ui/network-logo.tsx","type":"registry:ui","target":"components/ui/network-logo.tsx","content":"\"use client\";\n\nimport { useMemo, useState, type ReactNode } from \"react\";\nimport { cn } from \"@/lib/utils\";\nimport { getNetworkIcon } from \"@/lib/onchain/crypto-icons\";\nimport { getNetworkMeta } from \"@/lib/onchain/config\";\nimport {\n  Tooltip,\n  TooltipContent,\n  TooltipTrigger,\n} from \"@/components/ui/tooltip\";\n\nconst sizeClasses = {\n  xs: \"size-5 text-[8px]\",\n  sm: \"size-6 text-[9px]\",\n  md: \"size-8 text-[10px]\",\n  lg: \"size-10 text-xs\",\n  xl: \"size-12 text-sm\",\n} as const;\n\nexport interface NetworkLogoProps {\n  /** EVM chain id */\n  chainId?: number | null | undefined;\n  /** Network image URL override */\n  src?: string | null | undefined;\n  /** Network name, used for alt text and fallback */\n  name?: string | null | undefined;\n  /** Short network symbol, used for fallback */\n  symbol?: string | null | undefined;\n  /** Named size, or a diameter in pixels such as 16. Default: md */\n  size?: keyof typeof sizeClasses | number | undefined;\n  /**\n   * `tile` draws the mark on a bordered muted circle. `bare` draws it on\n   * nothing, for full-bleed brand art that should not sit in a ring. Default: tile\n   */\n  variant?: \"tile\" | \"bare\" | undefined;\n  /** Custom fallback content for unsupported chains */\n  fallback?: ReactNode | undefined;\n  /** Show an animated tooltip. Default: false */\n  showTooltip?: boolean | undefined;\n  /** Tooltip content. Defaults to network name, symbol, then chain id */\n  tooltipContent?: ReactNode | undefined;\n  /** Applied to the root wrapper */\n  className?: string | undefined;\n  /** Applied to the image */\n  imageClassName?: string | undefined;\n  /** Applied to the fallback */\n  fallbackClassName?: string | undefined;\n}\n\n// How many characters fit inside the circle at each size, measured rather than\n// derived: the font and the circle do not grow in step, so the limit is not a\n// constant ratio. Values leave ~20% slack so glyphs never touch the border.\nconst fallbackMaxChars = {\n  xs: 3,\n  sm: 3,\n  md: 4,\n  lg: 4,\n  xl: 4,\n} as const;\n\n// Pixel sizes follow the named steps: up to xs/sm (24px) fits three\n// characters, larger fits four. The font tracks ~1/3 of the diameter.\nfunction getMaxChars(size: keyof typeof sizeClasses | number) {\n  if (typeof size !== \"number\") return fallbackMaxChars[size];\n  return size <= 24 ? 3 : 4;\n}\n\nfunction getPixelFontSize(size: number) {\n  return Math.max(7, Math.round(size * 0.33));\n}\n\nfunction getFallbackText({\n  chainId,\n  name,\n  symbol,\n  maxChars,\n}: Pick<NetworkLogoProps, \"chainId\" | \"name\" | \"symbol\"> & {\n  maxChars: number;\n}) {\n  if (symbol) return symbol.slice(0, Math.min(4, maxChars)).toUpperCase();\n  if (name) return name.slice(0, 2).toUpperCase();\n  // A chain id is only shown when it fits whole. Truncating one produces a\n  // different, real-looking chain id, which is worse than admitting we do not\n  // recognise the network — the full id stays in `alt` and the tooltip.\n  if (chainId != null) {\n    const id = String(chainId);\n    if (id.length <= maxChars) return id;\n  }\n  return \"?\";\n}\n\nexport function NetworkLogo({\n  chainId,\n  src,\n  name,\n  symbol,\n  size = \"md\",\n  variant = \"tile\",\n  fallback,\n  showTooltip = false,\n  tooltipContent,\n  className,\n  imageClassName,\n  fallbackClassName,\n}: NetworkLogoProps) {\n  const [failedSrc, setFailedSrc] = useState<string | null>(null);\n  const knownNetwork = getNetworkMeta(chainId);\n\n  // Explicit src wins; otherwise ask the crypto-icons adapter.\n  const adapterIcon = src ? null : getNetworkIcon(chainId);\n  const resolvedSrc =\n    src ?? (typeof adapterIcon === \"string\" ? adapterIcon : null);\n  const knownIcon =\n    adapterIcon != null && typeof adapterIcon !== \"string\"\n      ? adapterIcon\n      : null;\n  const displayName = name ?? knownNetwork.name;\n  const displaySymbol = symbol ?? knownNetwork.symbol;\n  const shouldShowImage = Boolean(resolvedSrc) && failedSrc !== resolvedSrc;\n\n  const alt = useMemo(() => {\n    if (displayName && displaySymbol) return `${displayName} (${displaySymbol})`;\n    return displayName ?? displaySymbol ?? String(chainId ?? \"Network\");\n  }, [chainId, displayName, displaySymbol]);\n\n  const tooltip = tooltipContent ?? displayName ?? displaySymbol ?? chainId;\n\n  const px = typeof size === \"number\" ? size : undefined;\n  // The fallback keeps its tile in every variant, so an unknown network is\n  // still a visible shape.\n  const bare = variant === \"bare\" && (shouldShowImage || (knownIcon != null && !fallback));\n\n  const logo = (\n    <span\n      className={cn(\n        \"relative inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full font-semibold text-muted-foreground\",\n        bare ? null : \"border bg-muted\",\n        px === undefined ? sizeClasses[size as keyof typeof sizeClasses] : null,\n        className\n      )}\n      style={{\n        width: px,\n        height: px,\n        fontSize: px === undefined ? undefined : getPixelFontSize(px),\n      }}\n    >\n      {shouldShowImage ? (\n        <img\n          src={resolvedSrc ?? undefined}\n          alt={alt}\n          className={cn(\"size-full object-cover\", imageClassName)}\n          loading=\"lazy\"\n          decoding=\"async\"\n          referrerPolicy=\"no-referrer\"\n          onError={() => setFailedSrc(resolvedSrc)}\n        />\n      ) : knownIcon && !fallback ? (\n        knownIcon\n      ) : (\n        <span className={cn(\"select-none\", fallbackClassName)}>\n          {fallback ??\n            getFallbackText({\n              chainId,\n              name: displayName,\n              symbol: displaySymbol,\n              maxChars: getMaxChars(size),\n            })}\n        </span>\n      )}\n    </span>\n  );\n\n  if (!showTooltip || tooltip == null) return logo;\n\n  return (\n    <Tooltip>\n      <TooltipTrigger render={logo} />\n      <TooltipContent>{tooltip}</TooltipContent>\n    </Tooltip>\n  );\n}\n"},{"path":"registry/onchain-ui/token-price.tsx","type":"registry:ui","target":"components/ui/token-price.tsx","content":"import { ArrowDownIcon, ArrowUpIcon, MinusIcon } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\nimport {\n  parseNumericValue,\n  type NumericValue,\n} from \"@/lib/onchain/format\";\nimport type { ReactNode } from \"react\";\n\ntype PriceValue = NumericValue;\ntype Trend = \"down\" | \"neutral\" | \"up\";\n\n// `positive` and `negative` are theme tokens, like `destructive`. Define\n// `--positive` and `--negative` in your CSS to retheme gains and losses; until\n// you do, the registry's light and dark defaults (`--onchain-positive`,\n// `--onchain-negative`) apply. The defaults use their own names so installing\n// never overrides tokens you already have, in any mode.\nconst trendClasses = {\n  down: \"text-negative\",\n  neutral: \"text-muted-foreground\",\n  up: \"text-positive\",\n} as const;\n\nexport interface TokenPriceProps {\n  /** Token price value */\n  value: PriceValue;\n  /** ISO 4217 currency code. Default: USD */\n  currency?: string | undefined;\n  /** Locale passed to Intl.NumberFormat */\n  locale?: string | undefined;\n  /** Use compact notation, e.g. $3.2K */\n  compact?: boolean | undefined;\n  /** Value shown when price is null, undefined, empty, or invalid. Default: -- */\n  fallback?: ReactNode | undefined;\n  /** Minimum fraction digits for the price */\n  minimumFractionDigits?: number | undefined;\n  /** Maximum fraction digits for the price */\n  maximumFractionDigits?: number | undefined;\n  /** 24h-style percentage change, e.g. -2.34 means -2.34% */\n  change?: number | null | undefined;\n  /** Override the derived change direction */\n  trend?: Trend | undefined;\n  /** Show trend icon before the change. Default: true */\n  showChangeIcon?: boolean | undefined;\n  /** Fraction digits for the change value. Default: 2 */\n  changeFractionDigits?: number | undefined;\n  /** Hide the plus sign for positive changes. Default: false */\n  hidePositiveSign?: boolean | undefined;\n  /**\n   * Formats the price instead of Intl.NumberFormat, for apps with a house\n   * number style. Receives the parsed number; currency, locale, compact and\n   * the fraction digit props are then unused.\n   */\n  format?: ((value: number) => ReactNode) | undefined;\n  /**\n   * Formats the change instead of the default \"+2.34%\". Receives `change` as\n   * passed, so an app that stores fractions (0.0234) can format them itself.\n   */\n  formatChange?: ((change: number) => ReactNode) | undefined;\n  /** Applied to the root wrapper */\n  className?: string | undefined;\n  /** Applied to the formatted price */\n  priceClassName?: string | undefined;\n  /** Applied to the change badge */\n  changeClassName?: string | undefined;\n}\n\nfunction getMaximumFractionDigits(value: number) {\n  const abs = Math.abs(value);\n  if (abs >= 1) return 2;\n  if (abs >= 0.01) return 4;\n  return 6;\n}\n\nfunction formatPrice({\n  compact,\n  currency,\n  locale,\n  maximumFractionDigits,\n  minimumFractionDigits,\n  value,\n}: {\n  compact: boolean;\n  currency: string;\n  locale?: string | undefined;\n  maximumFractionDigits?: number | undefined;\n  minimumFractionDigits?: number | undefined;\n  value: number;\n}) {\n  const abs = Math.abs(value);\n  const hasExplicitDigits =\n    maximumFractionDigits !== undefined || minimumFractionDigits !== undefined;\n\n  // Sub-cent prices round to $0.00 with fraction digits; keep the leading\n  // significant figures instead, e.g. $0.00000041.\n  if (!hasExplicitDigits && abs > 0 && abs < 0.01) {\n    return new Intl.NumberFormat(locale, {\n      style: \"currency\",\n      currency,\n      currencyDisplay: \"narrowSymbol\",\n      notation: compact ? \"compact\" : \"standard\",\n      maximumSignificantDigits: 2,\n    }).format(value);\n  }\n\n  const resolvedMaximumFractionDigits =\n    maximumFractionDigits ?? getMaximumFractionDigits(value);\n\n  return new Intl.NumberFormat(locale, {\n    style: \"currency\",\n    currency,\n    currencyDisplay: \"narrowSymbol\",\n    notation: compact ? \"compact\" : \"standard\",\n    minimumFractionDigits,\n    // Intl.NumberFormat throws a RangeError when min > max\n    maximumFractionDigits: Math.max(\n      resolvedMaximumFractionDigits,\n      minimumFractionDigits ?? 0\n    ),\n  }).format(value);\n}\n\nfunction getTrend(change?: number | null): Trend {\n  if (!change) return \"neutral\";\n  return change > 0 ? \"up\" : \"down\";\n}\n\nfunction formatPercent(\n  change: number,\n  fractionDigits: number,\n  hidePositiveSign: boolean\n) {\n  const sign = change > 0 && !hidePositiveSign ? \"+\" : \"\";\n  return `${sign}${change.toFixed(fractionDigits)}%`;\n}\n\nfunction TrendIcon({ trend }: { trend: Trend }) {\n  if (trend === \"up\") return <ArrowUpIcon className=\"size-3\" />;\n  if (trend === \"down\") return <ArrowDownIcon className=\"size-3\" />;\n  return <MinusIcon className=\"size-3\" />;\n}\n\nexport function TokenPrice({\n  value,\n  currency = \"USD\",\n  locale,\n  compact = false,\n  fallback = \"--\",\n  minimumFractionDigits,\n  maximumFractionDigits,\n  change,\n  trend,\n  showChangeIcon = true,\n  changeFractionDigits = 2,\n  hidePositiveSign = false,\n  format,\n  formatChange,\n  className,\n  priceClassName,\n  changeClassName,\n}: TokenPriceProps) {\n  const parsedValue = parseNumericValue(value);\n  const shouldShowChange = typeof change === \"number\" && Number.isFinite(change);\n  const derivedTrend = trend ?? getTrend(change);\n\n  return (\n    <span className={cn(\"inline-flex items-center gap-2\", className)}>\n      <span className={cn(\"font-mono tabular-nums\", priceClassName)}>\n        {parsedValue === null\n          ? fallback\n          : format\n            ? format(parsedValue)\n            : formatPrice({\n              compact,\n              currency,\n              locale,\n              maximumFractionDigits,\n              minimumFractionDigits,\n              value: parsedValue,\n            })}\n      </span>\n\n      {shouldShowChange && (\n        <span\n          className={cn(\n            \"inline-flex items-center gap-0.5 font-mono text-xs tabular-nums\",\n            trendClasses[derivedTrend],\n            changeClassName\n          )}\n        >\n          {showChangeIcon && <TrendIcon trend={derivedTrend} />}\n          {formatChange\n            ? formatChange(change)\n            : formatPercent(change, changeFractionDigits, hidePositiveSign)}\n        </span>\n      )}\n    </span>\n  );\n}\n"},{"path":"lib/onchain/format.ts","type":"registry:lib","target":"lib/onchain/format.ts","content":"export function truncateAddress(address: string, chars = 4): string {\n  if (!address) return \"\";\n\n  return `${address.slice(0, chars + 2)}…${address.slice(-chars)}`;\n}\n\nexport type NumericValue = number | string | null | undefined;\n\n/** Parses numbers and numeric strings; anything else becomes null. */\nexport function parseNumericValue(value: NumericValue): number | null {\n  if (typeof value === \"number\") return Number.isFinite(value) ? value : null;\n  if (typeof value === \"string\" && value.trim() !== \"\") {\n    const parsed = Number(value);\n    return Number.isFinite(parsed) ? parsed : null;\n  }\n  return null;\n}\n\n"},{"path":"lib/onchain/crypto-icons.tsx","type":"registry:lib","target":"lib/onchain/crypto-icons.tsx","content":"import { getAddress } from \"viem\";\nimport type { ReactNode } from \"react\";\n\n/**\n * Crypto icon adapter.\n *\n * This file is the single seam onchain-ui components use to resolve token and\n * network icons — the crypto equivalent of shadcn's icon library setting.\n * Swap the implementations to point at your icon package, token list, CDN, or\n * indexer; the component contract stays the same.\n *\n * Both functions may return:\n * - a string, treated as an image URL\n * - a ReactNode, rendered directly in place of the image\n * - null, meaning \"unknown\" — components fall back to readable initials\n *\n * Explicit props (`src`, `fallback`) always win over this adapter.\n */\n\nexport type CryptoIcon = string | ReactNode | null;\n\nexport interface TokenIconQuery {\n  /** EVM chain id the token lives on */\n  chainId?: number | null | undefined;\n  /** Token contract address */\n  address?: string | null | undefined;\n  /** Token symbol. Unused by the default adapter: symbols are not canonical */\n  symbol?: string | null | undefined;\n  /** Whether this is the chain's native currency rather than an ERC-20 */\n  isNative?: boolean | undefined;\n}\n\n// Chain folder names in the Trust Wallet assets repo.\nconst trustWalletChainFolders: Record<number, string> = {\n  1: \"ethereum\",\n  10: \"optimism\",\n  137: \"polygon\",\n  8453: \"base\",\n  42161: \"arbitrum\",\n};\n\n/**\n * Resolves a token icon from the community-maintained Trust Wallet assets\n * repo by chain id and contract address. Coverage is good for established\n * tokens; misses degrade to the component's initials fallback.\n *\n * This default is fine for demos and prototypes. In production, prefer your\n * own token metadata (`src`) or point this function at your token list or\n * CDN.\n */\nexport function getTokenIcon(query: TokenIconQuery): CryptoIcon {\n  const { chainId, address, isNative, symbol } = query;\n  if (isNative && symbol?.toUpperCase() === \"ETH\") {\n    return <EthereumMark className=\"size-full\" />;\n  }\n  if (chainId == null || !address) return null;\n\n  const chainFolder = trustWalletChainFolders[chainId];\n  if (!chainFolder) return null;\n\n  try {\n    // The repo stores assets under EIP-55 checksummed addresses.\n    const checksummed = getAddress(address);\n    return `https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/${chainFolder}/assets/${checksummed}/logo.png`;\n  } catch {\n    return null;\n  }\n}\n\nfunction EthereumMark({ className }: { className?: string }) {\n  return (\n    <svg viewBox=\"0 0 32 32\" aria-hidden=\"true\" className={className}>\n      <circle cx=\"16\" cy=\"16\" r=\"16\" fill=\"#627EEA\" />\n      <g fill=\"#FFF\">\n        <path fillOpacity=\".602\" d=\"M16.498 4v8.87l7.497 3.35z\" />\n        <path d=\"M16.498 4L9 16.22l7.498-3.35z\" />\n        <path fillOpacity=\".602\" d=\"M16.498 21.968v6.027L24 17.616z\" />\n        <path d=\"M16.498 27.995v-6.028L9 17.616z\" />\n        <path fillOpacity=\".2\" d=\"M16.498 20.573l7.497-4.353-7.497-3.348z\" />\n        <path fillOpacity=\".602\" d=\"M9 16.22l7.498 4.353v-7.701z\" />\n      </g>\n    </svg>\n  );\n}\n\nfunction BaseMark({ className }: { className?: string }) {\n  return (\n    <svg viewBox=\"0 0 146 146\" aria-hidden=\"true\" className={className}>\n      <circle cx=\"73\" cy=\"73\" r=\"73\" fill=\"#0052FF\" />\n      <path\n        d=\"M73.323 123.729C101.617 123.729 124.553 100.832 124.553 72.5875C124.553 44.343 101.617 21.4463 73.323 21.4463C46.4795 21.4463 24.4581 42.0558 22.271 68.2887H89.9859V76.8864H22.271C24.4581 103.119 46.4795 123.729 73.323 123.729Z\"\n        fill=\"white\"\n      />\n    </svg>\n  );\n}\n\nfunction OptimismMark({ className }: { className?: string }) {\n  return (\n    <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" className={className}>\n      <circle cx=\"12\" cy=\"12\" r=\"12\" fill=\"#FF0420\" />\n      <path\n        fillRule=\"evenodd\"\n        clipRule=\"evenodd\"\n        d=\"M4.85865 15.3781C5.43829 15.7927 6.18265 16 7.09173 16C8.19009 16 9.06774 15.7517 9.72466 15.2553C10.3809 14.7516 10.8427 13.9926 11.1099 12.978C11.2703 12.3558 11.4079 11.7149 11.5226 11.0554C11.5598 10.8196 11.5788 10.6231 11.5795 10.4659C11.5795 9.94787 11.4459 9.50377 11.1786 9.13373C10.9039 8.74954 10.5214 8.4555 10.0793 8.28884C9.61364 8.09628 9.08706 8 8.49956 8C6.34017 8 5.00078 9.01845 4.48139 11.0554C4.29802 11.804 4.15686 12.4448 4.05796 12.978C4.02335 13.176 4.00397 13.3764 4 13.5773C4 14.3554 4.28622 14.9557 4.85865 15.3781ZM8.99176 12.9112C8.77268 13.762 8.16848 14.3161 7.25186 14.3161C6.34508 14.3161 6.03561 13.703 6.19869 12.9112C6.33623 12.1927 6.47377 11.5852 6.61132 11.0888C6.8471 10.1702 7.40316 9.68389 8.35023 9.68389C9.25407 9.68389 9.5488 10.2891 9.3926 11.0888C9.3009 11.6075 9.16729 12.215 8.99176 12.9112ZM12.4608 15.9204C12.5059 15.9728 12.5691 15.999 12.6504 15.999H14.1653C14.2427 15.9981 14.3174 15.9703 14.3765 15.9204C14.4423 15.8699 14.4862 15.796 14.4993 15.7141L14.9778 13.4742H16.5182C17.4909 13.4742 18.2513 13.0026 18.8083 12.583C19.3729 12.1638 19.7477 11.5162 19.9332 10.6398C19.9784 10.4342 20.0006 10.236 20 10.0454C20 9.38327 19.7477 8.87666 19.2435 8.5256C18.7457 8.1752 18.0849 8 17.2609 8H14.2989C14.2209 8.00126 14.1458 8.02976 14.0867 8.08056C14.0222 8.13166 13.9788 8.20477 13.9649 8.28589L12.4274 15.7141C12.411 15.7846 12.423 15.8587 12.4608 15.9204ZM17.874 10.6172C17.7345 11.2293 17.201 11.7893 16.5742 11.7893H15.2941L15.7352 9.68389H17.0713C17.5262 9.68389 17.9064 9.77428 17.9064 10.2743C17.9064 10.3726 17.8963 10.4868 17.874 10.6172Z\"\n        fill=\"white\"\n      />\n    </svg>\n  );\n}\n\nfunction ArbitrumMark({ className }: { className?: string }) {\n  return (\n    <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" className={className}>\n      <circle cx=\"12\" cy=\"12\" r=\"12\" fill=\"#213147\" />\n      <path\n        d=\"M13.203 13.2158L12.4164 15.3402C12.3951 15.3993 12.3951 15.4636 12.4164 15.5227L13.7695 19.178L15.3346 18.2879L13.4562 13.2158C13.4136 13.099 13.2456 13.099 13.203 13.2158Z\"\n        fill=\"white\"\n      />\n      <path\n        d=\"M14.78 9.64306C14.7373 9.52621 14.5693 9.52621 14.5267 9.64306L13.7402 11.7674C13.7188 11.8265 13.7188 11.8909 13.7402 11.9499L15.9571 17.9345L17.5221 17.0443L14.78 9.64306Z\"\n        fill=\"white\"\n      />\n      <path\n        d=\"M11.9985 4.9913C12.0371 4.9913 12.0758 5.0018 12.1104 5.02019L18.0787 8.41424C18.148 8.45363 18.1907 8.52716 18.1907 8.60462V15.3914C18.1907 15.4702 18.148 15.5424 18.0787 15.5818L12.1104 18.9759C12.0772 18.9955 12.0371 19.0047 11.9985 19.0047C11.9598 19.0047 11.9211 18.9943 11.8865 18.9759L5.91826 15.5844C5.84894 15.545 5.80628 15.4715 5.80628 15.3941V8.60593C5.80628 8.52716 5.84894 8.45494 5.91826 8.41555L11.8865 5.0215C11.9211 5.0018 11.9598 4.9913 11.9985 4.9913ZM11.9985 4C11.7865 4 11.5732 4.05383 11.3826 4.16281L5.41568 7.55555C5.03442 7.77219 4.7998 8.17265 4.7998 8.60593V15.3927C4.7998 15.826 5.03442 16.2265 5.41568 16.4431L11.3839 19.8371C11.5745 19.9448 11.7865 20 11.9998 20C12.2118 20 12.425 19.9462 12.6157 19.8371L18.5839 16.4431C18.9652 16.2265 19.1998 15.826 19.1998 15.3927V8.60593C19.1998 8.17265 18.9652 7.77219 18.5839 7.55555L12.6143 4.16281C12.4237 4.05383 12.2104 4 11.9985 4Z\"\n        fill=\"white\"\n      />\n      <path d=\"M8.05225 17.9426L8.60149 16.4615L9.70662 17.3662L8.67348 18.2958L8.05225 17.9426Z\" fill=\"white\" />\n      <path\n        d=\"M11.4965 8.12012H9.98351C9.87019 8.12012 9.76888 8.1897 9.73022 8.29474L6.48682 17.0523L8.05186 17.9425L11.6232 8.29868C11.6565 8.21203 11.5912 8.12012 11.4965 8.12012Z\"\n        fill=\"white\"\n      />\n      <path\n        d=\"M14.144 8.12012H12.6309C12.5176 8.12012 12.4163 8.1897 12.3776 8.29474L8.67432 18.2944L10.2393 19.1846L14.2706 8.29868C14.3026 8.21203 14.2373 8.12012 14.144 8.12012Z\"\n        fill=\"white\"\n      />\n    </svg>\n  );\n}\n\nfunction PolygonMark({ className }: { className?: string }) {\n  return (\n    <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" className={className}>\n      <defs>\n        <linearGradient\n          id=\"onchain-ui-polygon-bg\"\n          x1=\"3.948\"\n          y1=\"16.617\"\n          x2=\"19.217\"\n          y2=\"7.645\"\n          gradientUnits=\"userSpaceOnUse\"\n        >\n          <stop stopColor=\"#A726C1\" />\n          <stop offset=\"0.88\" stopColor=\"#803BDF\" />\n          <stop offset=\"1\" stopColor=\"#7B3FE4\" />\n        </linearGradient>\n      </defs>\n      <circle cx=\"12\" cy=\"12\" r=\"12\" fill=\"url(#onchain-ui-polygon-bg)\" />\n      <path\n        d=\"M15.8794 14.8595L19.6745 12.6947C19.8757 12.5797 20 12.3664 20 12.1375V7.80782C20 7.57894 19.8757 7.36569 19.6745 7.25069L15.8794 5.08583C15.6782 4.97083 15.4284 4.97195 15.2284 5.08583L11.4332 7.25069C11.232 7.36569 11.1077 7.57894 11.1077 7.80782V15.545L8.44614 17.0623L5.78456 15.545V12.5093L8.44614 10.992L10.2013 11.9935V9.95705L8.77163 9.1409C8.67331 9.08508 8.56029 9.05493 8.44614 9.05493C8.33199 9.05493 8.21897 9.08508 8.12065 9.1409L4.32549 11.3058C4.12432 11.4208 4 11.634 4 11.8629V16.1926C4 16.4215 4.12432 16.6347 4.32549 16.7497L8.12065 18.9146C8.32182 19.0285 8.57046 19.0285 8.77163 18.9146L12.5668 16.7497C12.768 16.6347 12.8923 16.4215 12.8923 16.1926V8.45538L12.9397 8.42859L15.5527 6.93808L18.2143 8.45538V11.4911L15.5527 13.0084L13.7998 12.0092V14.0456L15.2272 14.8595C15.4284 14.9734 15.6782 14.9734 15.8782 14.8595H15.8794Z\"\n        fill=\"white\"\n      />\n    </svg>\n  );\n}\n\n/**\n * Resolves a network icon by chain id. The default adapter ships crisp inline\n * marks for common chains so `<NetworkLogo chainId={8453} />` works offline\n * with zero configuration.\n */\nexport function getNetworkIcon(chainId?: number | null): CryptoIcon {\n  if (chainId === 1) return <EthereumMark className=\"size-full\" />;\n  if (chainId === 10) return <OptimismMark className=\"size-full\" />;\n  if (chainId === 137) return <PolygonMark className=\"size-full\" />;\n  if (chainId === 8453) return <BaseMark className=\"size-full\" />;\n  if (chainId === 42161) return <ArbitrumMark className=\"size-full\" />;\n  return null;\n}\n"},{"path":"lib/onchain/config.ts","type":"registry:lib","target":"lib/onchain/config.ts","content":"import {\n  arbitrum,\n  base,\n  mainnet,\n  optimism,\n  polygon,\n  robinhood,\n} from \"viem/chains\";\nimport type { AssetGatewayUrls, Chain, PublicClient } from \"viem\";\n\n/** The small client surface identity resolution actually consumes. */\nexport type OnchainReadClient = Pick<\n  PublicClient,\n  \"getEnsAddress\" | \"getEnsAvatar\" | \"getEnsName\" | \"readContract\"\n>;\n\n/**\n * The single place onchain-ui components look for app-wide settings.\n *\n * This file is yours: edit it once and every component follows. There is no\n * provider and no context — components import these functions directly, so\n * they work the same in a server component, a test, or a non-React consumer.\n *\n * Per-instance overrides always win. `<NetworkLogo name=\"…\" />` and\n * `<AddressDisplay explorerUrl=\"…\" />` beat anything configured here.\n */\n\nexport interface OnchainUIConfig {\n  /**\n   * Chains your app supports. Supplies block explorer URLs and display names\n   * for networks that have no built-in entry below.\n   *\n   * Using wagmi? Point this at the config you already wrote:\n   *\n   * ```ts\n   * import { wagmiConfig } from \"@/lib/onchain/wagmi\";\n   * chains: wagmiConfig.chains,\n   * ```\n   */\n  chains: readonly Chain[];\n\n  /**\n   * Returns a viem client for reads that are not tied to a rendered component\n   * — currently ENS and Basename resolution. Leave undefined to use the public\n   * endpoints below.\n   *\n   * Using wagmi? Share its transports instead of configuring RPC twice:\n   *\n   * ```ts\n   * import { getPublicClient } from \"@wagmi/core\";\n   * import { wagmiConfig } from \"@/lib/onchain/wagmi\";\n   * getClient: (chainId) => getPublicClient(wagmiConfig, { chainId }),\n   * ```\n   */\n  getClient?: (chainId: number) => OnchainReadClient | undefined;\n\n  /**\n   * Public gateways used to turn IPFS and Arweave avatar records into URLs.\n   * Replace these with your own gateway in production when reliability or\n   * rate limits matter.\n   */\n  avatarGatewayUrls?: AssetGatewayUrls | undefined;\n\n  /**\n   * The chain an address is assumed to live on when a component is given no\n   * chain id. Default: 1 (Ethereum). An app on one L2 sets its own, or every\n   * explorer link points at the wrong chain.\n   */\n  defaultChainId?: number | undefined;\n}\n\nexport const onchainConfig: OnchainUIConfig = {\n  chains: [mainnet, base, arbitrum, optimism, polygon, robinhood],\n  avatarGatewayUrls: {\n    ipfs: \"https://gateway.pinata.cloud\",\n    arweave: \"https://arweave.net\",\n  },\n};\n\n/**\n * Curated network names and symbols.\n *\n * These are deliberately not derived from the viem chain: `chain.name` gives\n * \"OP Mainnet\" where a badge wants \"Optimism\", and `nativeCurrency.symbol`\n * gives \"ETH\" for Base, Optimism, and Arbitrum alike, which is useless as a\n * network mark. Chains absent here fall back to the configured chain's name.\n */\nconst knownNetworks: Partial<\n  Record<number, { name: string; symbol: string }>\n> = {\n  1: { name: \"Ethereum\", symbol: \"ETH\" },\n  10: { name: \"Optimism\", symbol: \"OP\" },\n  137: { name: \"Polygon\", symbol: \"POL\" },\n  4663: { name: \"Robinhood Chain\", symbol: \"RH\" },\n  8453: { name: \"Base\", symbol: \"BASE\" },\n  42161: { name: \"Arbitrum\", symbol: \"ARB\" },\n};\n\nfunction findChain(chainId?: number | null) {\n  if (chainId == null) return null;\n  return onchainConfig.chains.find((chain) => chain.id === chainId) ?? null;\n}\n\nexport interface NetworkMeta {\n  name: string | null;\n  symbol: string | null;\n}\n\n/** Display name and symbol for a chain, or nulls when it is unrecognised. */\nexport function getNetworkMeta(chainId?: number | null): NetworkMeta {\n  if (chainId == null) return { name: null, symbol: null };\n\n  const known = knownNetworks[chainId];\n  if (known) return known;\n\n  return { name: findChain(chainId)?.name ?? null, symbol: null };\n}\n\n/**\n * Block explorer base URL for a chain, or null when we have none.\n *\n * Derived from the configured chains rather than a second hardcoded map —\n * viem's chain objects already carry `blockExplorers`. Null is a real answer:\n * an address on an unrecognised chain does not exist in mainnet's address\n * space, so callers render no link rather than a misleading one.\n */\nexport function getExplorerUrl(chainId?: number | null): string | null {\n  const chain = findChain(chainId);\n  return chain?.blockExplorers?.default.url ?? null;\n}\n\n/** The chain to assume when a component is given none. */\nexport function getDefaultChainId(): number {\n  return onchainConfig.defaultChainId ?? 1;\n}\n\n/** A read client for `chainId`, if the app configured one. */\nexport function getConfiguredClient(\n  chainId: number\n): OnchainReadClient | undefined {\n  return onchainConfig.getClient?.(chainId);\n}\n\n/** App-wide gateways for ENS and Basename avatar assets, if configured. */\nexport function getConfiguredAvatarGatewayUrls(): AssetGatewayUrls | undefined {\n  return onchainConfig.avatarGatewayUrls;\n}\n"}]}