{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "bigblocks-provider",
  "title": "BigBlocks Provider",
  "author": "Satchmo <https://bigblocks.dev>",
  "description": "Context provider that configures how all BigBlocks hooks fetch data. Web mode fetches from 1sat-stack API; custom mode lets you supply your own fetchers for desktop RPC, testing, or SSR.",
  "files": [
    {
      "path": "registry/new-york/blocks/bigblocks-provider/index.tsx",
      "content": "\"use client\"\n\nimport { useMemo } from \"react\"\nimport {\n  BigBlocksContext,\n  DEFAULT_API_URL,\n  DEFAULT_ORDFS_URL,\n  type BigBlocksContextValue,\n  type GetBalanceFn,\n  type GetOrdinalsFn,\n  type GetTokenBalancesFn,\n  type GetHistoryFn,\n  type OnExternalLinkFn,\n} from \"./bigblocks-context\"\n\n// ---------------------------------------------------------------------------\n// Re-exports\n// ---------------------------------------------------------------------------\n\nexport {\n  useBigBlocks,\n  BigBlocksContext,\n  DEFAULT_API_URL,\n  DEFAULT_ORDFS_URL,\n} from \"./bigblocks-context\"\n\nexport type {\n  BigBlocksContextValue,\n  BigBlocksBalance,\n  BigBlocksOrdinal,\n  BigBlocksTokenBalance,\n  BigBlocksHistoryEntry,\n  GetBalanceFn,\n  GetOrdinalsFn,\n  GetTokenBalancesFn,\n  GetHistoryFn,\n  OnExternalLinkFn,\n} from \"./bigblocks-context\"\n\n// ---------------------------------------------------------------------------\n// Props\n// ---------------------------------------------------------------------------\n\n/** Props for the BigBlocksProvider component */\nexport interface BigBlocksProviderProps {\n  /** 1sat-stack API base URL for web mode (default: \"https://api.1sat.app/1sat\") */\n  apiUrl?: string\n  /** ORDFS base URL for on-chain image resolution (default: \"https://ordfs.network\") */\n  ordfsUrl?: string\n  /**\n   * Custom balance fetcher. When provided, hooks call this function\n   * instead of the 1sat-stack API. Useful for desktop RPC, testing, or SSR.\n   */\n  getBalance?: GetBalanceFn\n  /**\n   * Custom ordinals fetcher. When provided, hooks call this function\n   * instead of the 1sat-stack API.\n   */\n  getOrdinals?: GetOrdinalsFn\n  /**\n   * Custom token balance fetcher. When provided, hooks call this function\n   * instead of the 1sat-stack API.\n   */\n  getTokenBalances?: GetTokenBalancesFn\n  /**\n   * Custom transaction history fetcher. When provided, hooks call this\n   * function instead of the 1sat-stack API.\n   */\n  getHistory?: GetHistoryFn\n  /**\n   * External link handler for desktop apps. When provided, components use\n   * this instead of `window.open` for outbound links.\n   */\n  onExternalLink?: OnExternalLinkFn\n  /** Child components that can access the BigBlocks context */\n  children: React.ReactNode\n}\n\n// ---------------------------------------------------------------------------\n// Provider\n// ---------------------------------------------------------------------------\n\n/**\n * Configures how all BigBlocks hooks fetch data.\n *\n * **Web mode** (default): hooks fetch from the 1sat-stack API at the\n * configured `apiUrl`.\n *\n * **Custom mode**: pass one or more custom fetcher functions (`getBalance`,\n * `getOrdinals`, `getTokenBalances`, `getHistory`) and hooks will call those\n * instead of the API. This enables desktop RPC backends, testing stubs, and\n * server-side rendering.\n *\n * @example\n * ```tsx\n * // Web mode — hooks fetch from the 1sat-stack API\n * <BigBlocksProvider>\n *   <App />\n * </BigBlocksProvider>\n *\n * // Custom mode — hooks call your functions instead\n * <BigBlocksProvider\n *   getBalance={myRpcBalance}\n *   getOrdinals={myRpcOrdinals}\n *   onExternalLink={(url) => shell.openExternal(url)}\n * >\n *   <App />\n * </BigBlocksProvider>\n * ```\n */\nexport function BigBlocksProvider({\n  apiUrl = DEFAULT_API_URL,\n  ordfsUrl = DEFAULT_ORDFS_URL,\n  getBalance,\n  getOrdinals,\n  getTokenBalances,\n  getHistory,\n  onExternalLink,\n  children,\n}: BigBlocksProviderProps) {\n  const value = useMemo<BigBlocksContextValue>(\n    () => ({\n      apiUrl,\n      ordfsUrl,\n      getBalance,\n      getOrdinals,\n      getTokenBalances,\n      getHistory,\n      onExternalLink,\n    }),\n    [apiUrl, ordfsUrl, getBalance, getOrdinals, getTokenBalances, getHistory, onExternalLink]\n  )\n\n  return (\n    <BigBlocksContext.Provider value={value}>\n      {children}\n    </BigBlocksContext.Provider>\n  )\n}\n",
      "type": "registry:lib",
      "target": "~/components/blocks/bigblocks-provider/index.tsx"
    },
    {
      "path": "registry/new-york/blocks/bigblocks-provider/bigblocks-context.ts",
      "content": "\"use client\"\n\nimport { createContext, useContext } from \"react\"\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/** Balance breakdown for a Bitcoin address */\nexport interface BigBlocksBalance {\n  /** Confirmed satoshis */\n  confirmed: number\n  /** Unconfirmed satoshis */\n  unconfirmed: number\n  /** Total satoshis (confirmed + unconfirmed) */\n  total: number\n}\n\n/** An ordinal output owned by an address */\nexport interface BigBlocksOrdinal {\n  /** Transaction outpoint (txid_vout) */\n  outpoint: string\n  /** MIME content type of the inscription */\n  contentType?: string\n  /** Human-readable name or label */\n  name?: string\n  /** Origin outpoint of the inscription */\n  origin?: string\n}\n\n/** A fungible token balance for an address */\nexport interface BigBlocksTokenBalance {\n  /** Token identifier (deploy txid) */\n  tokenId: string\n  /** Token ticker symbol */\n  symbol: string\n  /** Token protocol type (e.g. \"bsv21\") */\n  type: string\n  /** Token balance as a decimal string */\n  balance: string\n  /** Number of decimal places */\n  decimals: number\n}\n\n/** A transaction history entry */\nexport interface BigBlocksHistoryEntry {\n  /** Transaction ID */\n  txid: string\n  /** Human-readable description */\n  description: string\n  /** Amount in satoshis (positive = incoming, negative = outgoing) */\n  satoshis: number\n  /** Transaction status (e.g. \"confirmed\", \"pending\") */\n  status: string\n  /** ISO 8601 date string */\n  dateCreated: string\n}\n\n/** Custom data fetcher for balance queries */\nexport type GetBalanceFn = (\n  address: string\n) => Promise<BigBlocksBalance>\n\n/** Custom data fetcher for ordinal queries */\nexport type GetOrdinalsFn = (\n  address: string,\n  limit?: number\n) => Promise<BigBlocksOrdinal[]>\n\n/** Custom data fetcher for token balance queries */\nexport type GetTokenBalancesFn = (\n  address: string\n) => Promise<BigBlocksTokenBalance[]>\n\n/** Custom data fetcher for transaction history queries */\nexport type GetHistoryFn = (\n  address: string,\n  limit?: number\n) => Promise<BigBlocksHistoryEntry[]>\n\n/** Handler for opening external links (useful in desktop apps) */\nexport type OnExternalLinkFn = (url: string) => void\n\n/** Context value provided by BigBlocksProvider */\nexport interface BigBlocksContextValue {\n  /** 1sat-stack API base URL */\n  apiUrl: string\n  /** ORDFS base URL for resolving on-chain images */\n  ordfsUrl: string\n  /** Custom balance fetcher — when set, hooks use this instead of the API */\n  getBalance?: GetBalanceFn\n  /** Custom ordinals fetcher — when set, hooks use this instead of the API */\n  getOrdinals?: GetOrdinalsFn\n  /** Custom token balance fetcher — when set, hooks use this instead of the API */\n  getTokenBalances?: GetTokenBalancesFn\n  /** Custom history fetcher — when set, hooks use this instead of the API */\n  getHistory?: GetHistoryFn\n  /** External link handler for desktop apps or custom navigation */\n  onExternalLink?: OnExternalLinkFn\n}\n\n// ---------------------------------------------------------------------------\n// Defaults\n// ---------------------------------------------------------------------------\n\n/** Default 1sat-stack API base URL */\nexport const DEFAULT_API_URL = \"https://api.1sat.app/1sat\"\n\n/** Default ORDFS base URL for on-chain image resolution */\nexport const DEFAULT_ORDFS_URL = \"https://ordfs.network\"\n\n// ---------------------------------------------------------------------------\n// Context\n// ---------------------------------------------------------------------------\n\nexport const BigBlocksContext = createContext<BigBlocksContextValue | null>(null)\n\n// ---------------------------------------------------------------------------\n// Hook\n// ---------------------------------------------------------------------------\n\n/**\n * Access the BigBlocks configuration context.\n *\n * Must be called inside a `<BigBlocksProvider>`. Returns the context value\n * containing API URLs and optional custom data fetchers.\n *\n * @example\n * ```ts\n * const { apiUrl, ordfsUrl, getBalance } = useBigBlocks()\n *\n * // Fetch balance using custom fetcher or fall back to API\n * if (getBalance) {\n *   const balance = await getBalance(address)\n * } else {\n *   const res = await fetch(`${apiUrl}/owner/${address}/balance`)\n * }\n * ```\n *\n * @throws {Error} When called outside of BigBlocksProvider\n */\nexport function useBigBlocks(): BigBlocksContextValue {\n  const ctx = useContext(BigBlocksContext)\n  if (!ctx) {\n    throw new Error(\n      \"useBigBlocks must be used within a <BigBlocksProvider>. \" +\n        \"Wrap your component tree with <BigBlocksProvider> to provide configuration context.\"\n    )\n  }\n  return ctx\n}\n",
      "type": "registry:lib",
      "target": "~/components/blocks/bigblocks-provider/bigblocks-context.ts"
    }
  ],
  "type": "registry:lib"
}