diff --git a/examples/hello/frontend/package.json b/examples/hello/frontend/package.json index 670a41f3..5757f5c0 100644 --- a/examples/hello/frontend/package.json +++ b/examples/hello/frontend/package.json @@ -10,8 +10,8 @@ "preview": "vite preview" }, "dependencies": { - "@zetachain/toolkit": "16.1.3", - "@zetachain/wallet": "1.0.12", + "@zetachain/toolkit": "16.1.4", + "@zetachain/wallet": "1.0.13", "clsx": "^2.1.1", "ethers": "^6.13.2", "react": "^19.1.0", diff --git a/examples/hello/frontend/src/ConfirmedContent.tsx b/examples/hello/frontend/src/ConfirmedContent.tsx index 30f4e702..7d5122c2 100644 --- a/examples/hello/frontend/src/ConfirmedContent.tsx +++ b/examples/hello/frontend/src/ConfirmedContent.tsx @@ -79,7 +79,7 @@ export function ConfirmedContent({
{!connectedChainTxHash && } {!zetachainTxHash && } { const { switchChain } = useDynamicSwitchChainHook(); + const userWallets = useUserWallets(); + const switchWallet = useSwitchWallet(); + + const primaryWalletChain = primaryWallet?.chain; + const walletIds: Record = useMemo(() => { + const solanaWallet = userWallets.find( + (wallet) => wallet.chain === 'SOL' + )?.id; + const evmWallet = userWallets.find((wallet) => wallet.chain === 'EVM')?.id; + + return { + EVM: evmWallet || '', + SOL: solanaWallet || '', + }; + }, [userWallets]); const handleNetworkSelect = (chain: SupportedChain) => { + // We only switch wallet if the chain type is + // different from the primary wallet chain (i.e.: EVM -> SOL) + if (chain.chainType !== primaryWalletChain) { + switchWallet(walletIds[chain.chainType]); + } + switchChain(chain.chainId); }; @@ -60,7 +84,7 @@ const DynamicConnectedContent = ({ const Eip6963ConnectedContent = ({ selectedProvider, supportedChain, - primaryWallet, + account, }: ConnectedContentProps) => { const { switchChain } = useSwitchChain(); @@ -89,7 +113,7 @@ const Eip6963ConnectedContent = ({