From 407cba880a7d1707633823a9d28e6d3c9c7fcab1 Mon Sep 17 00:00:00 2001 From: Hamid Roohi Date: Mon, 12 Aug 2024 03:07:18 +0330 Subject: [PATCH] fix(wallet connect): fix wallet connect UI --- src/components/walletButton.tsx | 20 +++++- src/components/walletSelectionModal.tsx | 85 ++++++++++++++++++++++++- 2 files changed, 100 insertions(+), 5 deletions(-) diff --git a/src/components/walletButton.tsx b/src/components/walletButton.tsx index abdd142..f39523e 100644 --- a/src/components/walletButton.tsx +++ b/src/components/walletButton.tsx @@ -1,11 +1,27 @@ +import { useCallback, useState } from "react"; +import WalletSelectionModal from "./walletSelectionModal"; + export default function WalletButton() { + const [visible, setVisible] = useState(false); + + const handleClose = useCallback(() => { + setVisible(false); + }, []); + + console.log(visible); + return ( <> -
+
{ + setVisible(true); + }} + className="flex h-[36px] w-fit cursor-pointer items-center justify-center gap-[5px] rounded-[10px] bg-white px-[10px] hover:shadow-lg" + >

Connect Wallet

- {/* */} + ); } diff --git a/src/components/walletSelectionModal.tsx b/src/components/walletSelectionModal.tsx index ab33ea7..6d8b146 100644 --- a/src/components/walletSelectionModal.tsx +++ b/src/components/walletSelectionModal.tsx @@ -1,10 +1,89 @@ +import { useTalisman, useTransfer } from "@/hooks"; +import { WalletID } from "@/types"; +import { useConnectModal } from "@rainbow-me/rainbowkit"; +import Image from "next/image"; +import { useMemo } from "react"; + export default function WalletSelectionModal({ visible, onClose }: { visible: boolean; onClose: () => void }) { + const { talismanAccounts, connectTalisman } = useTalisman(); + const { openConnectModal } = useConnectModal(); + + const { + sender, + sourceChain, + targetChain, + activeSenderWallet, + activeRecipientWallet, + setSender, + setActiveSenderAccount, + setActiveRecipientAccount, + setActiveSenderWallet, + setActiveRecipientWallet, + } = useTransfer(); + const [supported, activeWallet, clearValue, setActiveAccount, setActiveWallet] = [ + sourceChain.wallets, + activeSenderWallet, + setSender, + setActiveSenderAccount, + setActiveSenderWallet, + ]; + + const [supportedWalletEvm, supportedWalletTalisman] = useMemo(() => { + return [supported.some((id) => id === WalletID.EVM), supported.some((id) => id === WalletID.TALISMAN)]; + }, [supported]); return ( <> {visible && ( -
-
-
+
+
+
+

Select a wallet Type

+
+ + +
+ + +
)}