bigblocks
Version:
Complete Bitcoin UI component library - authentication, social, wallet, market, inscriptions, and blockchain interactions for React
18 lines • 2.99 kB
JSON
{
"name": "providers-bitcoinqueryprovider",
"type": "registry:component",
"dependencies": [
"@tanstack/react-query",
"bigblocks"
],
"devDependencies": [],
"registryDependencies": [],
"files": [
{
"path": "components/providers/BitcoinQueryProvider.tsx",
"type": "registry:component",
"content": "// BigBlocksQueryProvider - Simple QueryClient wrapper for bigblocks components\n\"use client\";\n\nimport { QueryClient, QueryClientProvider } from \"@tanstack/react-query\";\nimport type React from \"react\";\n\nexport interface BigBlocksQueryProviderProps {\n\tchildren: React.ReactNode;\n\tqueryClient?: QueryClient;\n}\n\n// Default QueryClient optimized for blockchain operations\nconst createDefaultQueryClient = () =>\n\tnew QueryClient({\n\t\tdefaultOptions: {\n\t\t\tqueries: {\n\t\t\t\tstaleTime: 30 * 1000, // 30 seconds\n\t\t\t\tgcTime: 5 * 60 * 1000, // 5 minutes\n\t\t\t\tretry: (failureCount, error) => {\n\t\t\t\t\t// Don't retry on blockchain-specific errors\n\t\t\t\t\tif (error && typeof error === \"object\" && \"message\" in error) {\n\t\t\t\t\t\tconst message = error.message as string;\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tmessage.includes(\"insufficient funds\") ||\n\t\t\t\t\t\t\tmessage.includes(\"invalid\")\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn failureCount < 2;\n\t\t\t\t},\n\t\t\t\tretryDelay: (attemptIndex) => Math.min(1000 * 2 ** attemptIndex, 10000),\n\t\t\t},\n\t\t\tmutations: {\n\t\t\t\tretry: false,\n\t\t\t},\n\t\t},\n\t});\n\nlet defaultQueryClient: QueryClient | null = null;\n\n/**\n * BigBlocksQueryProvider - Provides React Query context for bigblocks components\n *\n * Simple wrapper that provides QueryClient for market, wallet, and social components.\n * Works around bun's nested resolution limitations.\n *\n * Usage:\n * ```tsx\n * import { BigBlocksQueryProvider } from 'bigblocks';\n *\n * function App() {\n * return (\n * <BigBlocksQueryProvider>\n * <BigBlocksThemeProvider>\n * <BigBlocksAuthProvider>\n * <MarketTable listings={...} />\n * <PostButton onSuccess={...} />\n * </BigBlocksAuthProvider>\n * </BigBlocksThemeProvider>\n * </BigBlocksQueryProvider>\n * );\n * }\n * ```\n */\nexport function BigBlocksQueryProvider({\n\tchildren,\n\tqueryClient,\n}: BigBlocksQueryProviderProps) {\n\t// Use provided client or create/reuse default\n\tlet client = queryClient;\n\tif (!client) {\n\t\tif (!defaultQueryClient) {\n\t\t\tdefaultQueryClient = createDefaultQueryClient();\n\t\t}\n\t\tclient = defaultQueryClient;\n\t}\n\n\treturn <QueryClientProvider client={client}>{children}</QueryClientProvider>;\n}\n\n// Legacy export for backward compatibility\nexport const BitcoinQueryProvider = BigBlocksQueryProvider;\nexport type { BigBlocksQueryProviderProps as BitcoinQueryProviderProps };\n",
"target": "<%- config.aliases.components %>/bitcoinqueryprovider.tsx"
}
]
}