"use client"; import { useState } from "react"; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from "@/components/ui/dialog"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; import { Plus, Search, Loader2 } from "lucide-react"; interface AddTokenModalProps { open: boolean; onOpenChange: (open: boolean) => void; onAddToken: (token: { symbol: string; name: string; chain: string; contractAddress?: string }) => void; } const SUPPORTED_CHAINS = [ { value: "solana", label: "Solana" }, { value: "ethereum", label: "Ethereum" }, { value: "base", label: "Base" }, { value: "arbitrum", label: "Arbitrum" }, { value: "polygon", label: "Polygon" }, ]; export function AddTokenModal({ open, onOpenChange, onAddToken }: AddTokenModalProps) { const [symbol, setSymbol] = useState(""); const [name, setName] = useState(""); const [chain, setChain] = useState("solana"); const [contractAddress, setContractAddress] = useState(""); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(""); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setError(""); if (!symbol.trim()) { setError("Token symbol is required"); return; } if (!chain) { setError("Please select a chain"); return; } setIsLoading(true); // Simulate API call delay await new Promise((resolve) => setTimeout(resolve, 500)); onAddToken({ symbol: symbol.toUpperCase().trim(), name: name.trim() || symbol.toUpperCase().trim(), chain, contractAddress: contractAddress.trim() || undefined, }); // Reset form setSymbol(""); setName(""); setChain("solana"); setContractAddress(""); setIsLoading(false); onOpenChange(false); }; return ( Add Token to Watchlist
setSymbol(e.target.value)} className="uppercase" />
setName(e.target.value)} />
setContractAddress(e.target.value)} />

Provide contract address for accurate token identification

{error &&

{error}

}
); }