mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
77 lines
1.8 KiB
TypeScript
77 lines
1.8 KiB
TypeScript
import { ChakraProvider } from '@chakra-ui/react';
|
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
import { createWeb3Modal, defaultWagmiConfig } from '@web3modal/wagmi/react';
|
|
import React from 'react';
|
|
import { WagmiConfig } from 'wagmi';
|
|
import { mainnet } from 'wagmi/chains';
|
|
|
|
import type { Props as PageProps } from 'nextjs/getServerSideProps';
|
|
|
|
import { AppContextProvider } from 'lib/contexts/app';
|
|
import { SocketProvider } from 'lib/socket/context';
|
|
import * as app from 'playwright/utils/app';
|
|
import theme from 'theme';
|
|
|
|
type Props = {
|
|
children: React.ReactNode;
|
|
withSocket?: boolean;
|
|
appContext?: {
|
|
pageProps: PageProps;
|
|
};
|
|
}
|
|
|
|
const defaultAppContext = {
|
|
pageProps: {
|
|
cookies: '',
|
|
referrer: '',
|
|
id: '',
|
|
height_or_hash: '',
|
|
hash: '',
|
|
number: '',
|
|
q: '',
|
|
},
|
|
};
|
|
|
|
// >>> Web3 stuff
|
|
const chains = [ mainnet ];
|
|
const WALLET_CONNECT_PROJECT_ID = 'PROJECT_ID';
|
|
|
|
const wagmiConfig = defaultWagmiConfig({
|
|
chains,
|
|
projectId: WALLET_CONNECT_PROJECT_ID,
|
|
});
|
|
|
|
createWeb3Modal({
|
|
wagmiConfig,
|
|
projectId: WALLET_CONNECT_PROJECT_ID,
|
|
chains,
|
|
});
|
|
// <<<<
|
|
|
|
const TestApp = ({ children, withSocket, appContext = defaultAppContext }: Props) => {
|
|
const [ queryClient ] = React.useState(() => new QueryClient({
|
|
defaultOptions: {
|
|
queries: {
|
|
refetchOnWindowFocus: false,
|
|
retry: 0,
|
|
},
|
|
},
|
|
}));
|
|
|
|
return (
|
|
<ChakraProvider theme={ theme }>
|
|
<QueryClientProvider client={ queryClient }>
|
|
<SocketProvider url={ withSocket ? `ws://${ app.domain }:${ app.socketPort }` : undefined }>
|
|
<AppContextProvider { ...appContext }>
|
|
<WagmiConfig config={ wagmiConfig }>
|
|
{ children }
|
|
</WagmiConfig>
|
|
</AppContextProvider>
|
|
</SocketProvider>
|
|
</QueryClientProvider>
|
|
</ChakraProvider>
|
|
);
|
|
};
|
|
|
|
export default TestApp;
|