UNPKG

bigblocks

Version:

Complete Bitcoin UI component library - authentication, social, wallet, market, inscriptions, and blockchain interactions for React

67 lines (66 loc) 2.32 kB
// BigBlocksQueryProvider - Simple QueryClient wrapper for bigblocks components "use client"; import { jsx as _jsx } from "react/jsx-runtime"; import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; // Default QueryClient optimized for blockchain operations const createDefaultQueryClient = () => new QueryClient({ defaultOptions: { queries: { staleTime: 30 * 1000, // 30 seconds gcTime: 5 * 60 * 1000, // 5 minutes retry: (failureCount, error) => { // Don't retry on blockchain-specific errors if (error && typeof error === "object" && "message" in error) { const message = error.message; if (message.includes("insufficient funds") || message.includes("invalid")) { return false; } } return failureCount < 2; }, retryDelay: (attemptIndex) => Math.min(1000 * 2 ** attemptIndex, 10000), }, mutations: { retry: false, }, }, }); let defaultQueryClient = null; /** * BigBlocksQueryProvider - Provides React Query context for bigblocks components * * Simple wrapper that provides QueryClient for market, wallet, and social components. * Works around bun's nested resolution limitations. * * Usage: * ```tsx * import { BigBlocksQueryProvider } from 'bigblocks'; * * function App() { * return ( * <BigBlocksQueryProvider> * <BigBlocksThemeProvider> * <BigBlocksAuthProvider> * <MarketTable listings={...} /> * <PostButton onSuccess={...} /> * </BigBlocksAuthProvider> * </BigBlocksThemeProvider> * </BigBlocksQueryProvider> * ); * } * ``` */ export function BigBlocksQueryProvider({ children, queryClient, }) { // Use provided client or create/reuse default let client = queryClient; if (!client) { if (!defaultQueryClient) { defaultQueryClient = createDefaultQueryClient(); } client = defaultQueryClient; } return _jsx(QueryClientProvider, { client: client, children: children }); } // Legacy export for backward compatibility export const BitcoinQueryProvider = BigBlocksQueryProvider;