zeta-chain / universalkit

UniversalKit by ZetaChain provides a set of React components designed to make building universal applications easier.
https://www.zetachain.com/docs/developers/frontend/universalkit/
MIT License
3 stars 2 forks source link

Add ability to switch chains in the swap component #11

Open fadeev opened 1 month ago

fadeev commented 1 month ago

Right now when you select a token on a chain that is different from the one selected in MetaMask, the button is disabled.

Screenshot 2024-08-01 at 15 47 57

Make the button clickable, so that it opens MetaMask and prompts the user to switch the chain:

Screenshot 2024-08-01 at 15 49 23

Use wagmi:

import { useSwitchChain } from "wagmi";
const { switchChain } = useSwitchChain();

The bulk of the logic should be in the index.tsx of the swap component (and not in the template) to separate logic from presentation.

Make sure the button displays a spinner import { Loader2 } from "lucide-react" when changing the network.

fadeev commented 1 month ago

Assigned to @mikelord007

fadeev commented 1 month ago

@mikelord007 any updates on the issue?