import React, { useEffect, useState } from "react"; import { Popover } from "@headlessui/react"; import { toast } from "react-toastify"; import Image from "next/image"; import { formatWalletAddress } from "utils/formatters"; import ConnectModal from "./ConnectModal"; import useWalletStore from "stores/useWalletStore"; import useInjectiveBalance from "hooks/useInjectiveBalance"; const WalletPopover = ({ children }: { children: React.ReactNode }) => { const address = useWalletStore((state) => state.address); const actions = useWalletStore((state) => state.actions); const { data } = useInjectiveBalance(); return ( {children}
token

INJ{" "} {data?.toFixed(2)}

{address}

); }; const Wallet = () => { const [showConnectModal, setShowConnectModal] = useState(false); const [hasHydrated, setHasHydrated] = useState(false); const address = useWalletStore((state) => state.address); // avoid server-client hydration mismatch useEffect(() => { setHasHydrated(true); }, []); return ( <> {hasHydrated && address ? ( {formatWalletAddress(address)} ) : ( )} setShowConnectModal(false)} /> ); }; export default Wallet;