import React, { useState, useEffect } from 'react'; import { useToast } from '../components/ui/index'; export default function SecurityPage() { const [s, setS] = useState({}); const [wl, setWl] = useState([]); const [anomalies, setAnomalies] = useState([]); const [addr, setAddr] = useState(''); const [label, setLabel] = useState(''); const [err, setErr] = useState(''); const { addToast } = useToast(); useEffect(() => { load(); }, []); const load = async () => { if (!window.solvox) return; try { const [a, b, c] = await Promise.all([window.solvox.security.getSettings(), window.solvox.security.getWhitelist(), window.solvox.security.getAnomalies()]); setS(a); setWl(b); setAnomalies(c); } catch {} }; const upd = async (k: string, v: any) => { const n = { ...s, [k]: v }; setS(n); if (window.solvox) { await window.solvox.security.updateSettings(n); addToast({ type: 'success', title: 'Saved' }); } }; const addWl = async () => { if (!addr.trim() || !label.trim()) return setErr('Both required'); if (window.solvox) { const r = await window.solvox.security.addWhitelist(addr.trim(), label.trim()); if (r.success) { setAddr(''); setLabel(''); setErr(''); load(); } else setErr(r.error || 'Failed'); } }; const rmWl = async (a: string) => { if (window.solvox) { await window.solvox.security.removeWhitelist(a); load(); } }; const Toggle = ({ k, label, desc }: { k: string; label: string; desc: string }) => (
{label}
{desc}
); return (

Security

{/* Limits */}
Transaction limits
{[ { k: 'maxSingleTx', l: 'Max per transaction', u: 'tokens', v: s.maxSingleTx || 1000 }, { k: 'maxDailyVolume', l: 'Daily limit', u: '/day', v: s.maxDailyVolume || 5000 }, { k: 'velocityLimit', l: 'Max TX/hour', u: '', v: s.velocityLimit || 10 }, { k: 'cooldownMinutes', l: 'Cooldown', u: 'min', v: s.cooldownMinutes || 1 }, ].map(f => (
upd(f.k, Number(e.target.value))} className="input-field text-body-sm" /> {f.u && {f.u}}
))}
{/* Toggles */}
Features
{/* Whitelist */}
Address whitelist
setLabel(e.target.value)} placeholder="Label" className="input-field text-body-sm w-28" /> setAddr(e.target.value)} placeholder="Solana address" className="input-field text-body-sm flex-1 font-mono" />
{err &&
{err}
} {wl.length === 0 ?
No addresses whitelisted
: (
{wl.map((e, i) => (
{e.label}
{e.address.slice(0, 10)}…{e.address.slice(-6)}
))}
)}
{/* Anomalies */}
Anomaly log
AI-POWERED
{anomalies.length === 0 ? (
All clear — no anomalies detected ✓
Analyzed by @qvac/llm-llamacpp + @qvac/embed-llamacpp
) : (
{anomalies.map((a, i) => (
{a.severity.toUpperCase()} {a.type}
{a.description}
{new Date(a.timestamp).toLocaleString()}
))}
)}
); }