2025-10-23 12:16:25 +05:30
|
|
|
import React from "react";
|
|
|
|
|
import { OpChanClient, type OpChanClientConfig } from "@opchan/core";
|
|
|
|
|
import { ClientProvider } from "../context/ClientContext";
|
|
|
|
|
import { StoreWiring } from "./StoreWiring";
|
|
|
|
|
import { WagmiProvider } from "wagmi";
|
2025-10-28 12:45:05 +05:30
|
|
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
|
|
|
import { wagmiConfig } from "@opchan/core";
|
2025-10-23 12:16:25 +05:30
|
|
|
|
|
|
|
|
export interface OpChanProviderProps {
|
2025-09-25 21:52:40 +05:30
|
|
|
config: OpChanClientConfig;
|
|
|
|
|
children: React.ReactNode;
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-28 12:45:05 +05:30
|
|
|
// Create a default QueryClient instance
|
|
|
|
|
const defaultQueryClient = new QueryClient({
|
|
|
|
|
defaultOptions: {
|
|
|
|
|
queries: {
|
|
|
|
|
refetchOnWindowFocus: false,
|
|
|
|
|
retry: 1,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
2025-09-25 21:52:40 +05:30
|
|
|
/**
|
2025-10-23 12:16:25 +05:30
|
|
|
* OpChan provider that constructs the OpChanClient and provides wallet context.
|
2025-10-28 12:45:05 +05:30
|
|
|
* Simplified to use WagmiProvider + QueryClient only (no AppKit).
|
2025-09-25 21:52:40 +05:30
|
|
|
*/
|
2025-10-23 12:16:25 +05:30
|
|
|
export const OpChanProvider: React.FC<OpChanProviderProps> = ({
|
|
|
|
|
config,
|
|
|
|
|
children,
|
|
|
|
|
}) => {
|
2025-09-25 21:52:40 +05:30
|
|
|
const [client] = React.useState(() => new OpChanClient(config));
|
|
|
|
|
|
|
|
|
|
return (
|
2025-10-23 12:16:25 +05:30
|
|
|
<WagmiProvider config={wagmiConfig}>
|
2025-10-28 12:45:05 +05:30
|
|
|
<QueryClientProvider client={defaultQueryClient}>
|
|
|
|
|
<ClientProvider client={client}>
|
|
|
|
|
<StoreWiring />
|
|
|
|
|
{children}
|
|
|
|
|
</ClientProvider>
|
|
|
|
|
</QueryClientProvider>
|
2025-10-23 12:16:25 +05:30
|
|
|
</WagmiProvider>
|
2025-09-25 21:52:40 +05:30
|
|
|
);
|
|
|
|
|
};
|