import React, { useState, useEffect } from 'react'; import { Hammer, Sparkles, ShieldCheck, Terminal, Wallet, Key, Loader2, Eye, Image as ImageIcon, Zap, Globe, Share2, ExternalLink, Info, AlertCircle, // Added missing X icon import X } from 'lucide-react'; import { nftService, GeneratedNFT } from '../services/nftService.ts'; declare global { interface Window { ethereum?: any; } } const CryptView: React.FC = () => { const [prompt, setPrompt] = useState(''); const [isSynthesizing, setIsSynthesizing] = useState(false); const [isMinting, setIsMinting] = useState(false); const [nft, setNft] = useState(null); const [openSeaKey, setOpenSeaKey] = useState(''); const [walletAddress, setWalletAddress] = useState(''); const [mintLogs, setMintLogs] = useState([]); const [walletConnected, setWalletConnected] = useState(false); const [isConnecting, setIsConnecting] = useState(false); const [error, setError] = useState(null); const connectWallet = async () => { if (typeof window.ethereum === 'undefined') { setError("MetaMask not detected. Please install the browser extension to interact with the foundry."); return; } setIsConnecting(true); setError(null); try { const accounts = await window.ethereum.request({ method: 'eth_requestAccounts' }); if (accounts.length > 0) { setWalletAddress(accounts[0]); setWalletConnected(true); } } catch (err: any) { console.error("Wallet Connection Failed:", err); setError(err.message || "Failed to establish neural handshake with wallet."); } finally { setIsConnecting(false); } }; useEffect(() => { const checkConnection = async () => { if (window.ethereum) { const accounts = await window.ethereum.request({ method: 'eth_accounts' }); if (accounts.length > 0) { setWalletAddress(accounts[0]); setWalletConnected(true); } } }; checkConnection(); if (window.ethereum) { window.ethereum.on('accountsChanged', (accounts: string[]) => { if (accounts.length > 0) { setWalletAddress(accounts[0]); setWalletConnected(true); } else { setWalletAddress(''); setWalletConnected(false); } }); } }, []); const handleSynthesize = async () => { if (!prompt.trim()) return; setIsSynthesizing(true); setNft(null); setMintLogs([]); setError(null); const [imageUrl, metadata] = await Promise.all([ nftService.generateImage(prompt), nftService.generateMetadata(prompt) ]); if (imageUrl) { setNft({ name: metadata.name || "Neural Artifact", description: metadata.description || "Synthesized by Lumina Oracle", imageUrl, traits: metadata.traits || [] }); } else { setError("Asset synthesis failed. Please adjust your prompt parameters."); } setIsSynthesizing(false); }; const handleMint = async () => { if (!nft || !openSeaKey || !walletConnected) return; setIsMinting(true); setMintLogs(["Starting deployment sequence..."]); const steps = await nftService.mintToOpenSea(nft, openSeaKey, walletAddress); for (const step of steps) { await new Promise(r => setTimeout(r, 800)); setMintLogs(prev => [...prev, step]); } setIsMinting(false); }; const shortenAddress = (addr: string) => `${addr.substring(0, 6)}...${addr.substring(addr.length - 4)}`; return (
{/* Header */}

Quantum Crypt

Neural Asset Synthesis & Blockchain Deployment

Wallet: {walletConnected ? shortenAddress(walletAddress) : 'Disconnected'}
{!walletConnected && ( )}
{error && (

{error}

)}
{/* Left: Configuration & Foundry */}

Integration Layer

setOpenSeaKey(e.target.value)} placeholder="X-API-KEY-..." className="w-full bg-black border border-zinc-800 focus:border-blue-500/50 rounded-xl py-3 px-4 text-white text-xs outline-none transition-all placeholder:text-zinc-800 font-mono" />