Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move providers out of App directory #1370

Merged
merged 1 commit into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 3 additions & 44 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,13 @@
'use client';

import { ApolloProvider } from '@apollo/client';
import { ChakraProvider } from '@chakra-ui/react';
import { theme } from '@decent-org/fractal-ui';
import '@fontsource/ibm-plex-mono';
import '@fontsource/ibm-plex-sans';
import { midnightTheme, RainbowKitProvider } from '@rainbow-me/rainbowkit';
import 'i18next';
import { ReactNode, useEffect } from 'react';
import { ToastContainer } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.min.css';
import { WagmiConfig } from 'wagmi';
import { ModalProvider } from '../src/components/ui/modals/ModalProvider';
import Layout from '../src/components/ui/page/Layout';
import { ErrorFallback } from '../src/components/ui/utils/ErrorFallback';
import { APP_NAME } from '../src/constants/common';
import graphQLClient from '../src/graphql';
import { FractalErrorBoundary, initErrorLogging } from '../src/helpers/errorLogging';
import { AppProvider } from '../src/providers/App/AppProvider';
import { NetworkConfigProvider } from '../src/providers/NetworkConfig/NetworkConfigProvider';
import { chains, wagmiConfig } from '../src/providers/NetworkConfig/rainbow-kit.config';
import { initErrorLogging } from '../src/helpers/errorLogging';
import Providers from '../src/providers/Providers';

export default function RootLayout({ children }: { children: ReactNode }) {
useEffect(() => {
Expand Down Expand Up @@ -90,36 +78,7 @@ export default function RootLayout({ children }: { children: ReactNode }) {
<title>{APP_NAME}</title>
</head>
<body>
<ChakraProvider
theme={theme}
resetCSS
>
<FractalErrorBoundary fallback={<ErrorFallback />}>
<WagmiConfig config={wagmiConfig}>
<RainbowKitProvider
chains={chains}
modalSize="compact"
theme={midnightTheme()}
>
<NetworkConfigProvider>
<AppProvider>
<ToastContainer
position="bottom-center"
closeButton={false}
newestOnTop={false}
pauseOnFocusLoss={false}
/>
<ApolloProvider client={graphQLClient}>
<ModalProvider>
<Layout>{children}</Layout>
</ModalProvider>
</ApolloProvider>
</AppProvider>
</NetworkConfigProvider>
</RainbowKitProvider>
</WagmiConfig>
</FractalErrorBoundary>
</ChakraProvider>
<Providers>{children}</Providers>
</body>
</html>
);
Expand Down
54 changes: 54 additions & 0 deletions src/providers/Providers.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
'use client';
import { ApolloProvider } from '@apollo/client';
import { ChakraProvider } from '@chakra-ui/react';
import { theme } from '@decent-org/fractal-ui';
import { RainbowKitProvider, midnightTheme } from '@rainbow-me/rainbowkit';
import { ReactNode, useEffect } from 'react';
import { ToastContainer } from 'react-toastify';
import { WagmiConfig } from 'wagmi';
import { ModalProvider } from '../components/ui/modals/ModalProvider';
import Layout from '../components/ui/page/Layout';
import { ErrorFallback } from '../components/ui/utils/ErrorFallback';
import graphQLClient from '../graphql';
import { FractalErrorBoundary, initErrorLogging } from '../helpers/errorLogging';
import { AppProvider } from './App/AppProvider';
import { NetworkConfigProvider } from './NetworkConfig/NetworkConfigProvider';
import { wagmiConfig, chains } from './NetworkConfig/rainbow-kit.config';

export default function Providers({ children }: { children: ReactNode }) {
useEffect(() => {
initErrorLogging();
}, []);
return (
<ChakraProvider
theme={theme}
resetCSS
>
<FractalErrorBoundary fallback={<ErrorFallback />}>
<ApolloProvider client={graphQLClient}>
<WagmiConfig config={wagmiConfig}>
<RainbowKitProvider
chains={chains}
modalSize="compact"
theme={midnightTheme()}
>
<NetworkConfigProvider>
<AppProvider>
<ToastContainer
position="bottom-center"
closeButton={false}
newestOnTop={false}
pauseOnFocusLoss={false}
/>
<ModalProvider>
<Layout>{children}</Layout>
</ModalProvider>
</AppProvider>
</NetworkConfigProvider>
</RainbowKitProvider>
</WagmiConfig>
</ApolloProvider>
</FractalErrorBoundary>
</ChakraProvider>
);
}
Loading