import React from 'react'; import { Link } from 'react-router-dom'; import { useAuth } from '@/contexts/AuthContext'; import { useForum } from '@/contexts/ForumContext'; import { Button } from '@/components/ui/button'; import { Badge } from '@/components/ui/badge'; import { ShieldCheck, LogOut, Terminal, Wifi, WifiOff, Eye, MessageSquare, RefreshCw, Key } from 'lucide-react'; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip'; const Header = () => { const { currentUser, isAuthenticated, verificationStatus, connectWallet, disconnectWallet, verifyOrdinal, delegateKey, isDelegationValid, delegationTimeRemaining } = useAuth(); const { isNetworkConnected, isRefreshing } = useForum(); const handleConnect = async () => { await connectWallet(); }; const handleDisconnect = () => { disconnectWallet(); }; const handleVerify = async () => { await verifyOrdinal(); }; const handleDelegateKey = async () => { await delegateKey(); }; // Format delegation time remaining for display const formatDelegationTime = () => { if (!isDelegationValid()) return null; const timeRemaining = delegationTimeRemaining(); const hours = Math.floor(timeRemaining / (1000 * 60 * 60)); const minutes = Math.floor((timeRemaining % (1000 * 60 * 60)) / (1000 * 60)); return `${hours}h ${minutes}m`; }; const renderDelegationButton = () => { // Only show delegation button for verified Ordinal owners if (verificationStatus !== 'verified-owner') return null; const hasValidDelegation = isDelegationValid(); const timeRemaining = formatDelegationTime(); return ( {hasValidDelegation ? (

You have a delegated browser key active for {timeRemaining}. You won't need to sign messages with your wallet for most actions.

) : (

Delegate a browser key to avoid signing every action with your wallet. Improves UX by reducing wallet popups for 24 hours.

)}
); }; const renderAccessBadge = () => { if (verificationStatus === 'unverified') { return ( ); } if (verificationStatus === 'verifying') { return ( Verifying... ); } if (verificationStatus === 'verified-none') { return (
Read-Only Access

Wallet Verified - No Ordinals Found

Your wallet has been verified but does not contain any Ordinal Operators.

You can browse content but cannot post, comment, or vote.

Verify again

); } if (verificationStatus === 'verified-owner') { return (
Full Access

Ordinal Operators Verified!

You have full forum access with permission to post, comment, and vote.

Verify again

); } return null; }; return (
OpChan PoC v0.1
{isNetworkConnected ? ( <> Connected ) : ( <> Offline )}

{isNetworkConnected ? "Connected to Waku network" : "Not connected to Waku network. Some features may be unavailable."}

{isRefreshing &&

Refreshing data...

}
{!currentUser ? ( ) : ( <> {renderAccessBadge()} {renderDelegationButton()} {currentUser.address.slice(0, 6)}...{currentUser.address.slice(-4)} )}
); }; export default Header;