Skip to content

Commit

Permalink
fix: wallet connect issues + sepolia | mobile view alert
Browse files Browse the repository at this point in the history
  • Loading branch information
0xtiti committed Mar 20, 2024
1 parent 97036e6 commit 1862fff
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 42 deletions.
1 change: 1 addition & 0 deletions src/components/Theme/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './rainbowTheme';
export * from './theme';
export * from './muiThemeConfig';
4 changes: 3 additions & 1 deletion src/pages/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ const ResponsiveDisclaimer = styled('div')(() => {
textAlign: 'start',
fontSize: '1.6rem',
padding: '1rem 0.8rem 1rem',

'@media (max-width: 600px)': {
display: 'block',
},
p: {
padding: '1rem 0',
margin: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/providers/ThemeProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createContext, useEffect, useMemo, useState } from 'react';

import { ThemeProvider as MuiThemeProvider } from '@mui/material/styles';
import { getMuiThemeConfig } from '~/components/Theme/muiThemeConfig';
import { getMuiThemeConfig } from '~/components';

import { Theme, ThemeName } from '~/types';
import { THEME_KEY, getTheme } from '~/utils';
Expand Down
48 changes: 9 additions & 39 deletions src/providers/Web3ModalProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,50 +1,20 @@
import '@rainbow-me/rainbowkit/styles.css';

import React from 'react';
'use client';
import type { ReactNode } from 'react';

import { RainbowKitProvider, connectorsForWallets, darkTheme } from '@rainbow-me/rainbowkit';
import '@rainbow-me/rainbowkit/styles.css';
import { RainbowKitProvider, darkTheme } from '@rainbow-me/rainbowkit';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { rainbowWallet, walletConnectWallet, injectedWallet } from '@rainbow-me/rainbowkit/wallets';
import { WagmiProvider, http, createConfig } from 'wagmi';
import { localhost } from 'wagmi/chains';
import { WagmiProvider } from 'wagmi';

import { getConfig } from '../config';
import { config } from '../utils';

const { PROJECT_ID } = getConfig();

const getWallets = () => {
if (PROJECT_ID) {
return [injectedWallet, rainbowWallet, walletConnectWallet];
} else {
return [injectedWallet];
}
type Props = {
children: ReactNode;
};

const connectors = connectorsForWallets(
[
{
groupName: 'Recommended',
wallets: getWallets(),
},
],
{
appName: 'Web3 React boilerplate',
projectId: PROJECT_ID,
},
);

const config = createConfig({
chains: [localhost],
transports: {
[localhost.id]: http(),
},
batch: { multicall: true },
connectors,
});

const queryClient = new QueryClient();

export function Web3ModalProvider({ children }: { children: React.ReactElement }) {
export function Web3ModalProvider({ children }: Props) {
return (
<WagmiProvider config={config}>
<QueryClientProvider client={queryClient}>
Expand Down
9 changes: 8 additions & 1 deletion src/providers/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
'use client';
import type { ReactNode } from 'react';

import { StateProvider } from './StateProvider';
import { ThemeProvider } from './ThemeProvider';
import { Web3ModalProvider } from './Web3ModalProvider';

export const Providers = ({ children }: { children: React.ReactElement }) => {
type Props = {
children: ReactNode;
};

export const Providers = ({ children }: Props) => {
return (
<ThemeProvider>
<StateProvider>
Expand Down
43 changes: 43 additions & 0 deletions src/utils/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { createConfig, http, cookieStorage, createStorage } from 'wagmi';
import { localhost, sepolia } from 'wagmi/chains';
import { rainbowWallet, walletConnectWallet, injectedWallet } from '@rainbow-me/rainbowkit/wallets';
import { connectorsForWallets } from '@rainbow-me/rainbowkit';

import { getConfig } from '../config';

const { PROJECT_ID } = getConfig();

const getWallets = () => {
if (PROJECT_ID) {
return [injectedWallet, rainbowWallet, walletConnectWallet];
} else {
return [injectedWallet];
}
};

const connectors = connectorsForWallets(
[
{
groupName: 'Recommended',
wallets: getWallets(),
},
],
{
appName: 'Web3 React boilerplate',
projectId: PROJECT_ID,
},
);

export const config = createConfig({
chains: [localhost, sepolia],
ssr: true,
storage: createStorage({
storage: cookieStorage,
}),
transports: {
[localhost.id]: http(),
[sepolia.id]: http(),
},
batch: { multicall: true },
connectors,
});
1 change: 1 addition & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './getTheme';
export * from './Variables';
export * from './config';

0 comments on commit 1862fff

Please sign in to comment.