Files
dark-lord/lib/exchangeState.ts
drjones e0a4a20862 Tor ops: launch UI, onion list/health scripts, systemd installer, README glow-up
- Replace fake-site footer with dark-web launch CTA; fix HubChatter inside AppProviders (client crash)
- Add /launch, DEPLOY.md, onions:list|status|health, list-onion-urls, install-systemd, onion-status
- start.sh CYBERLUX_PREPARE_ONLY; copy pass on satellite pages; Navbar launch link
- README: operator cheat sheet, phone Tor note, systemd via install-systemd.sh

Made-with: Cursor
2026-04-15 22:12:44 -07:00

79 lines
1.9 KiB
TypeScript

export type ExchangeListing = {
id: string;
kind: "wts" | "wtb";
title: string;
body: string;
price: string;
currency: "BTC" | "XMR" | "USD";
author: string;
ts: number;
};
const KEY = "cyberlux-exchange-v1";
function uid(): string {
if (typeof crypto !== "undefined" && "randomUUID" in crypto) return crypto.randomUUID();
return `e_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
}
const seed: ExchangeListing[] = [
{
id: "es-1",
kind: "wts",
title: "Hardware entropy module (listing)",
body: "Open-box. Local pickup on this onion only. Meet at public node.",
price: "0.015",
currency: "BTC",
author: "EntropyCorp",
ts: Date.now() - 3600000 * 20,
},
{
id: "es-2",
kind: "wtb",
title: "Looking for vintage cipher manuals (replica)",
body: "Budget flexible for the right scan quality.",
price: "120",
currency: "USD",
author: "Collector42",
ts: Date.now() - 3600000 * 8,
},
];
export function loadExchange(): ExchangeListing[] {
if (typeof window === "undefined") return seed;
try {
const raw = localStorage.getItem(KEY);
if (!raw) {
saveExchange(seed);
return seed;
}
const v = JSON.parse(raw) as ExchangeListing[];
return Array.isArray(v) && v.length ? v : seed;
} catch {
return seed;
}
}
export function saveExchange(list: ExchangeListing[]): void {
if (typeof window === "undefined") return;
localStorage.setItem(KEY, JSON.stringify(list));
}
export function addListing(
L: Omit<ExchangeListing, "id" | "ts">,
): ExchangeListing {
const row: ExchangeListing = {
id: uid(),
ts: Date.now(),
kind: L.kind,
title: L.title.trim(),
body: L.body.trim(),
price: L.price.trim(),
currency: L.currency,
author: L.author.trim() || "Anonymous",
};
const all = [row, ...loadExchange()];
saveExchange(all);
return row;
}