import * as React from "react"; import { Button } from "@/components/ui/button"; import { Badge } from "@/components/ui/badge"; import { Bitcoin, Coins, Shield, ShieldCheck, Loader2, AlertCircle } from "lucide-react"; import { useAuth } from "@/contexts/useAuth"; import { useAppKitAccount } from "@reown/appkit/react"; interface VerificationStepProps { onComplete: () => void; onBack: () => void; isLoading: boolean; setIsLoading: (loading: boolean) => void; } export function VerificationStep({ onComplete, onBack, isLoading, setIsLoading, }: VerificationStepProps) { const { currentUser, verificationStatus, verifyOwnership, isAuthenticating } = useAuth(); // Get account info to determine wallet type const bitcoinAccount = useAppKitAccount({ namespace: "bip122" }); const ethereumAccount = useAppKitAccount({ namespace: "eip155" }); const isBitcoinConnected = bitcoinAccount.isConnected; const isEthereumConnected = ethereumAccount.isConnected; const walletType = isBitcoinConnected ? 'bitcoin' : 'ethereum'; const [verificationResult, setVerificationResult] = React.useState<{ success: boolean; message: string; details?: any; } | null>(null); const handleVerify = async () => { if (!currentUser) return; setIsLoading(true); setVerificationResult(null); try { const success = await verifyOwnership(); if (success) { setVerificationResult({ success: true, message: walletType === 'bitcoin' ? "Ordinal ownership verified successfully!" : "ENS ownership verified successfully!", details: walletType === 'bitcoin' ? currentUser.ordinalOwnership : { ensName: currentUser.ensName, ensAvatar: currentUser.ensAvatar } }); } else { setVerificationResult({ success: false, message: walletType === 'bitcoin' ? "No Ordinal ownership found. You'll have read-only access." : "No ENS ownership found. You'll have read-only access." }); } } catch (error) { setVerificationResult({ success: false, message: "Verification failed. Please try again." }); } finally { setIsLoading(false); } }; const handleNext = () => { onComplete(); }; const getVerificationType = () => { return walletType === 'bitcoin' ? 'Bitcoin Ordinal' : 'ENS Domain'; }; const getVerificationIcon = () => { return walletType === 'bitcoin' ? Bitcoin : Coins; }; const getVerificationColor = () => { return walletType === 'bitcoin' ? 'text-orange-500' : 'text-blue-500'; }; const getVerificationDescription = () => { if (walletType === 'bitcoin') { return "Verify that you own Bitcoin Ordinals to get full posting and voting access."; } else { return "Verify that you own an ENS domain to get full posting and voting access."; } }; // Show verification result if (verificationResult) { return (
{verificationResult.success ? ( ) : ( )} {verificationResult.success ? 'Verification Complete' : 'Verification Result'}

{verificationResult.message}

{verificationResult.details && (
{walletType === 'bitcoin' ? (

Ordinal ID: {verificationResult.details.id}

) : (

ENS Name: {verificationResult.details.ensName}

)}
)}
); } // Show verification status if (verificationStatus === 'verified-owner') { return (
Already Verified

Your {getVerificationType()} ownership has been verified.

{currentUser && (
{walletType === 'bitcoin' && currentUser.ordinalOwnership && (

Ordinal ID: {typeof currentUser.ordinalOwnership === 'object' ? currentUser.ordinalOwnership.id : 'Verified'}

)} {walletType === 'ethereum' && currentUser.ensName && (

ENS Name: {currentUser.ensName}

)}
)}
); } // Show verification form return (
{React.createElement(getVerificationIcon(), { className: `h-8 w-8 ${getVerificationColor()}` })}

Verify {getVerificationType()} Ownership

{getVerificationDescription()}

What happens during verification?
Verification is required to access posting and voting features
); }