import { useWallet } from '@tronweb3/tronwallet-adapter-react-hooks'; import type { FC, MouseEvent } from 'react'; import React, { useCallback, useMemo } from 'react'; import type { ButtonProps } from './Button.js'; import { Button } from './Button.js'; export const WalletConnectButton: FC = ({ children, disabled, onClick, ...props }) => { const { wallet, connect, connecting, connected } = useWallet(); const handleClick = useCallback( async (event: MouseEvent) => { if (onClick) onClick(event); if (!event.defaultPrevented) { await connect(); } }, [onClick, connect] ); const content = useMemo(() => { if (children) return children; if (connecting) return 'Connecting ...'; if (connected) return 'Connected'; if (wallet) return 'Connect'; return 'Connect Wallet'; }, [children, connecting, connected, wallet]); return ( ); };