Skip to content

Commit

Permalink
Update connect modal (#340)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucemans authored Dec 11, 2024
1 parent fdee6d3 commit 0c16014
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 16 deletions.
38 changes: 28 additions & 10 deletions app/app/theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { ThemeProvider } from 'next-themes';
import { useEffect } from 'react';
import { holesky, mainnet, sepolia } from 'viem/chains';
import { createConfig, http, WagmiProvider } from 'wagmi';
import {
createConfig,
http,
useAccount,
useConfig,
WagmiProvider,
} from 'wagmi';
import { injected, walletConnect } from 'wagmi/connectors';

const config = createConfig({
Expand All @@ -30,6 +36,8 @@ const config = createConfig({
});

declare module 'wagmi' {
// @ts-ignore
// eslint-disable-next-line unused-imports/no-unused-vars
interface Register {
config: typeof config;
}
Expand All @@ -38,19 +46,29 @@ declare module 'wagmi' {
const queryClient = new QueryClient();

export const Theme = ({ children }) => {
useEffect(() => {
(async () => {
const { setupConfig } = await import('@ens-tools/thorin-core');

setupConfig(() => config as any);
})();
}, []);

return (
<ThemeProvider attribute="class">
<QueryClientProvider client={queryClient}>
<WagmiProvider config={config}>{children}</WagmiProvider>
<WagmiProvider config={config}>
{children}
<WagmiChild />
</WagmiProvider>
</QueryClientProvider>
</ThemeProvider>
);
};

export const WagmiChild = () => {
const state = useConfig();
const { address, connector } = useAccount();

useEffect(() => {
(async () => {
const { setupConfig } = await import('@ens-tools/thorin-core');

setupConfig(() => state || config);
})();
}, [state, address, connector]);

return <></>;
};
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"browserslist": "defaults, not ie <= 11",
"dependencies": {
"@ens-tools/format": "^0.0.2",
"@ens-tools/thorin-core": "0.0.5",
"@ens-tools/thorin-core": "0.1.4-1",
"@ensdomains/thorin": "1.0.0-beta.9",
"@headlessui/react": "^1.7.18",
"@mdx-js/loader": "^3.0.0",
Expand Down
26 changes: 21 additions & 5 deletions app/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0c16014

Please sign in to comment.