@@ -6,17 +6,17 @@ import {
66 useEnableMFA ,
77 useIdentityToken ,
88 useManageMFA ,
9- useSwitchChain ,
109 useWalletConnectScanner ,
1110 useWalletUI ,
1211 useWeb3Auth ,
1312 useWeb3AuthUser ,
13+ useSwitchChain as useWeb3AuthSwitchChain ,
1414} from " @web3auth/modal/vue" ;
1515import { type CustomChainConfig , type NFTCheckoutPluginType } from " @web3auth/no-modal" ;
1616import { useI18n } from " petite-vue-i18n" ;
1717
1818import { useSignAndSendTransaction , useSignMessage as useSolanaSignMessage , useSignTransaction , useSolanaWallet } from " @web3auth/modal/vue/solana" ;
19- import { useAccount , useBalance , useChainId , useSignMessage , useSignTypedData } from " @wagmi/vue" ;
19+ import { useAccount , useBalance , useChainId , useSignMessage , useSignTypedData , useSwitchChain as useWagmiSwitchChain } from " @wagmi/vue" ;
2020
2121import { LAMPORTS_PER_SOL , PublicKey , SystemProgram , Transaction } from " @solana/web3.js" ;
2222import { ProviderConfig } from " @toruslabs/base-controllers" ;
@@ -42,15 +42,16 @@ const { isConnected, provider, web3Auth, isMFAEnabled } = useWeb3Auth();
4242const { userInfo, loading : userInfoLoading } = useWeb3AuthUser ();
4343const { enableMFA } = useEnableMFA ();
4444const { manageMFA } = useManageMFA ();
45- const { switchChain } = useSwitchChain ();
45+ const { switchChainAsync } = useWagmiSwitchChain ();
46+ const { switchChain } = useWeb3AuthSwitchChain ();
4647const { showWalletUI, loading : showWalletUILoading } = useWalletUI ();
4748const { showWalletConnectScanner, loading : showWalletConnectScannerLoading } = useWalletConnectScanner ();
4849const { showCheckout, loading : showCheckoutLoading } = useCheckout ();
4950const { authenticateUser, loading : authenticateUserLoading } = useIdentityToken ();
5051const { status, address } = useAccount ();
5152const { signTypedDataAsync } = useSignTypedData ();
5253const { signMessageAsync } = useSignMessage ();
53- const chainId = useChainId ();
54+ const wagmiChainId = useChainId ();
5455const balance = useBalance ({
5556 address: address ,
5657});
@@ -188,7 +189,7 @@ const onGetPrivateKey = async () => {
188189};
189190
190191const getConnectedChainId = async () => {
191- printToConsole (" chainId" , chainId .value );
192+ printToConsole (" chainId" , wagmiChainId .value );
192193};
193194
194195const onGetBalance = async () => {
@@ -323,8 +324,8 @@ const onSwitchChain = async () => {
323324 const currentNamespace = currentChainNamespace .value ;
324325 const newChain = props .chains .find ((x ) => x .chainNamespace === currentNamespace && x .chainId !== chainId );
325326 if (! newChain ) throw new Error (` Please configure at least 2 chains for ${currentNamespace } in the config ` );
326- await switchChain ({ chainId: newChain .chainId });
327- printToConsole (" switchedChain" , { chainId: newChain . chainId });
327+ const data = await switchChainAsync ({ chainId: Number ( newChain .chainId ) });
328+ printToConsole (" switchedChain" , { chainId: data . id });
328329 } catch (error ) {
329330 printToConsole (" switchedChain error" , error );
330331 }
0 commit comments