import { Loader2, Wallet, X } from 'lucide-react' import { useState } from 'react' import { connectWallet, disconnectWallet, getIdentityKey, getProvider, } from '../lib/wallet' import { Button } from './ui/button' interface Props { onConnected: () => void onDisconnected: () => void connected: boolean } export function ConnectWallet({ onConnected, onDisconnected, connected, }: Props) { const [connecting, setConnecting] = useState(false) const [error, setError] = useState(null) async function handleConnect() { setConnecting(true) setError(null) try { await connectWallet() onConnected() } catch (e) { setError(e instanceof Error ? e.message : 'Failed to connect wallet') } finally { setConnecting(false) } } function handleDisconnect() { disconnectWallet() onDisconnected() } if (connected) { return (
{getProvider() === 'brc100' ? 'BRC-100' : 'OneSat'} ยท{' '} {getIdentityKey()?.slice(0, 12)}...
) } return (
{error &&

{error}

}
) }