import coinbase from "@/assets/coinbase.svg"; import { IconWallet } from "@/assets/icons"; import metamask from "@/assets/metamask.svg"; import moonLogoLight from "@/assets/moon-logo-light.png"; import rabby from "@/assets/rabby.png"; import trustwallet from "@/assets/trustwallet.png"; import walletconnect from "@/assets/walletconnect.svg"; import { useConnectToMoon } from "@/hooks"; import { useMemo } from "react"; import { useAccount, useConnect, useSignMessage } from "wagmi"; export const useWalletConnectors = () => { const { connectors, connect } = useConnect(); const { address } = useAccount(); const { signMessageAsync } = useSignMessage(); const walletAddress = address ? address : ""; const { connectToMoonSiwe } = useConnectToMoon({ address: walletAddress, signMessageAsync, }); const walletIcons: any = useMemo( () => ({ MetaMask: , "Coinbase Wallet": , "Rabby Wallet": , Safe: , Moon: , WalletConnect: , "Browser Wallet": , }), [], ); const handleConnect = async (connector: any) => { connect({ connector }); connectToMoonSiwe(); }; //remove duplicate connectors const uniqueConnectors = connectors.filter( (v: any, i: any, a: any) => a.findIndex((t: any) => t.name === v.name) === i, ); return useMemo( () => uniqueConnectors.map((connector: any) => ({ type: "connector", color: "blue-600", hoverColor: "blue-700", text: connector.name, icon: walletIcons[connector.name], component: (
), })), [connect, connectors, walletIcons], ); };