Skip to content

Commit f86bd21

Browse files
Merge branch 'feat/add-sub-hooks' of github.com:Web3Auth/web3auth-web into feat/add-sub-hooks
2 parents 5d003e2 + a6ba012 commit f86bd21

File tree

3 files changed

+3
-337
lines changed

3 files changed

+3
-337
lines changed

demo/wagmi-react-app/src/chainconfig.ts

Lines changed: 0 additions & 327 deletions
This file was deleted.

demo/wagmi-react-app/src/index.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,21 @@
11
import "./index.css";
22

33
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
4-
import { CHAIN_NAMESPACES, CustomChainConfig } from "@web3auth/modal";
54
import { type Web3AuthContextConfig, Web3AuthProvider } from "@web3auth/modal/react";
65
import { WagmiProvider } from "@web3auth/modal/react/wagmi";
76
import { StrictMode } from "react";
87
import { createRoot } from "react-dom/client";
9-
import { mainnet, sepolia } from "wagmi/chains";
108

119
import App from "./App";
12-
import { getChainConfig } from "./chainconfig";
1310

1411
const queryClient = new QueryClient();
1512
const clientId = "BKZDJP0ouZP0PtfQYssMiezINbUwnIthw6ClTtTICvh0MCRgAxi5GJbHKH9cjM6xyWxe73c6c94ASCTxbGNLUt8";
16-
const mainnetChainConfig = getChainConfig(CHAIN_NAMESPACES.EIP155, mainnet.id, clientId) as CustomChainConfig;
17-
const sepoliaChainConfig = getChainConfig(CHAIN_NAMESPACES.EIP155, sepolia.id, clientId) as CustomChainConfig;
1813

1914
const web3authConfig: Web3AuthContextConfig = {
2015
web3AuthOptions: {
2116
enableLogging: true,
2217
web3AuthNetwork: "sapphire_devnet",
2318
clientId: clientId,
24-
chains: [mainnetChainConfig, sepoliaChainConfig],
25-
defaultChainId: sepoliaChainConfig.chainId,
2619
authBuildEnv: "testing",
2720
},
2821
};

packages/modal/src/react/wagmi/provider.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ function Web3AuthWagmiProvider({ children }: PropsWithChildren) {
117117

118118
export function WagmiProvider({ children, ...props }: PropsWithChildren<WagmiProviderProps>) {
119119
const { config } = props;
120-
const { web3Auth } = useWeb3Auth();
120+
const { web3Auth, isInitialized } = useWeb3Auth();
121121

122122
const finalConfig = useMemo(() => {
123123
const finalConfig: CreateConfigParameters = {
@@ -131,7 +131,7 @@ export function WagmiProvider({ children, ...props }: PropsWithChildren<WagmiPro
131131
};
132132

133133
const wagmiChains: Chain[] = [];
134-
if (web3Auth?.coreOptions?.chains) {
134+
if (isInitialized && web3Auth?.coreOptions?.chains) {
135135
const defaultChainId = web3Auth.currentChain?.chainId;
136136
const chains = web3Auth.coreOptions.chains;
137137
chains.forEach((chain) => {
@@ -172,7 +172,7 @@ export function WagmiProvider({ children, ...props }: PropsWithChildren<WagmiPro
172172

173173
if (!finalConfig.chains) return;
174174
return createWagmiConfig(finalConfig);
175-
}, [config, web3Auth]);
175+
}, [config, web3Auth, isInitialized]);
176176

177177
// WagmiProviderBase requires a config to initialize
178178
// If no config is provided, it will throw an error.

0 commit comments

Comments
 (0)