mirror of
https://github.com/Such-Software/smirk-website.git
synced 2026-12-01 12:14:12 +01:00
feat(website): add compact navigation and educational swap demos
This commit is contained in:
@@ -11,7 +11,7 @@ This website serves as a hub for Smirk wallet users to:
|
||||
- **Manage social tips** - view sent/received, clawback unclaimed
|
||||
- **Public stats** - platform growth metrics at /stats
|
||||
|
||||
**Important**: This site is ONLY accessible to users with the Smirk extension installed. Authentication happens via cryptographic signatures from the user's wallet keys.
|
||||
Public landing, download, demo, and Premium information pages need no extension. Account features require the Smirk extension and authenticate with wallet signatures.
|
||||
|
||||
## Architecture
|
||||
|
||||
@@ -127,3 +127,18 @@ src/
|
||||
|
||||
- [smirk-extension](../smirk-extension) - Browser extension (injects `window.smirk`)
|
||||
- [smirk-backend](../smirk-backend) - Rust backend API
|
||||
|
||||
## Public navigation and demos
|
||||
|
||||
The landing page keeps its existing composition. Compact navigation links to `/downloads`, `/demos`, the Smirk Wallet forum category, and `/premium`. The existing official desktop release parser remains the source of download metadata; development versions are not announced as shipped.
|
||||
|
||||
`/demos/basicswap` explains the LTC/WOW protocol-8 target. `/demos/eigenswap` is an unreleased v0.3.3 compatibility preview for the BTC-paying, XMR-receiving taker. Both are browser-local educational simulations with distinct recovery and unknown states. They make no wallet, quote, signing, or payment requests. `/premium` explains the current in-wallet Feed purchase path; it does not implement checkout or grant forum membership.
|
||||
|
||||
Run focused source checks with Node 24 or newer:
|
||||
|
||||
```sh
|
||||
node --test src/lib/swap-demos.test.ts src/lib/public-tip.test.ts src/lib/username.test.ts tests/desktop-downloads.test.mjs
|
||||
node node_modules/typescript/bin/tsc --noEmit --incremental false
|
||||
```
|
||||
|
||||
Production remains the existing reviewed Fleet website artifact and check/diff procedure. A local preview or source merge is not deployment.
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
import Link from 'next/link';
|
||||
import SwapWalkthrough from '@/components/SwapWalkthrough';
|
||||
import { SWAP_DEMOS } from '@/lib/swap-demos';
|
||||
export const metadata = { title: "BasicSwap-compatible swaps" };
|
||||
export default function Demo() {
|
||||
const demo = SWAP_DEMOS.find(value => value.slug === "basicswap")!;
|
||||
return <div className="demo-page"><Link href="/demos" className="text-sm text-zinc-400 hover:text-[#fbeb0a]">← All demos</Link>
|
||||
<p className="mt-8 text-xs text-[#fbeb0a]">{demo.badge} · Interactive simulation</p><h1 className="mt-4 text-3xl font-bold sm:text-4xl">{demo.title}</h1>
|
||||
<p className="mt-5 leading-relaxed text-zinc-300">{demo.intro}</p><p className="mt-4 border-l-2 border-zinc-700 pl-4 text-xs leading-relaxed text-zinc-400">{demo.support} No wallet connection or real funds.</p><SwapWalkthrough demo={demo} />
|
||||
</div>;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import Link from 'next/link';
|
||||
import SwapWalkthrough from '@/components/SwapWalkthrough';
|
||||
import { SWAP_DEMOS } from '@/lib/swap-demos';
|
||||
export const metadata = { title: "EigenSwap" };
|
||||
export default function Demo() {
|
||||
const demo = SWAP_DEMOS.find(value => value.slug === "eigenswap")!;
|
||||
return <div className="demo-page"><Link href="/demos" className="text-sm text-zinc-400 hover:text-[#fbeb0a]">← All demos</Link>
|
||||
<p className="mt-8 text-xs text-[#fbeb0a]">{demo.badge} · Interactive simulation</p><h1 className="mt-4 text-3xl font-bold sm:text-4xl">{demo.title}</h1>
|
||||
<p className="mt-5 leading-relaxed text-zinc-300">{demo.intro}</p><p className="mt-4 border-l-2 border-zinc-700 pl-4 text-xs leading-relaxed text-zinc-400">{demo.support} No wallet connection or real funds.</p><SwapWalkthrough demo={demo} />
|
||||
</div>;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import Link from 'next/link';
|
||||
import { SWAP_DEMOS } from '@/lib/swap-demos';
|
||||
export const metadata = { title: 'Swap demos', description: 'Interactive explanations of BasicSwap-compatible and EigenSwap protocols. Simulations only, with no wallet connection or real funds.' };
|
||||
export default function Demos() {
|
||||
return <div className="demo-page"><p className="text-sm text-[#fbeb0a]">Learn by stepping through</p><h1 className="mt-4 text-3xl font-bold sm:text-4xl">Swap demos</h1>
|
||||
<p className="mt-5 max-w-2xl leading-relaxed text-zinc-400">See how two peers exchange assets, and what recovery means when a swap stops. These interactive simulations never connect to a wallet or move funds.</p>
|
||||
<div className="mt-10 grid gap-5 md:grid-cols-2">{SWAP_DEMOS.map(demo => <Link key={demo.slug} href={`/demos/${demo.slug}`} className="rounded-xl border border-zinc-800 p-6 transition-colors hover:border-[#fbeb0a]">
|
||||
<p className="text-xs text-[#fbeb0a]">{demo.badge}</p><h2 className="mt-4 text-xl font-semibold">{demo.title}</h2><p className="mt-3 text-sm leading-relaxed text-zinc-400">{demo.intro}</p><p className="mt-6 text-sm">Explore the walkthrough →</p>
|
||||
</Link>)}</div><p className="mt-8 text-xs text-zinc-400">Educational previews, not a live swap interface or an announcement of a new wallet release.</p>
|
||||
</div>;
|
||||
}
|
||||
@@ -105,3 +105,9 @@ body {
|
||||
background: transparent;
|
||||
}
|
||||
}
|
||||
|
||||
/* Dedicated educational pages preserve the landing page composition. */
|
||||
.demo-page { width: 100%; max-width: 56rem; margin: 0 auto; padding: 3rem 1.5rem 5rem; }
|
||||
.demo-assets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
|
||||
a:focus-visible, button:focus-visible, summary:focus-visible, input:focus-visible { outline: 2px solid var(--smirk-yellow); outline-offset: 4px; }
|
||||
@media (max-width: 380px) { .demo-page { padding-left: 1rem; padding-right: 1rem; } .demo-assets { gap: .5rem; } }
|
||||
|
||||
+6
-1
@@ -1,6 +1,7 @@
|
||||
import type { Metadata } from "next";
|
||||
import { Geist_Mono } from "next/font/google";
|
||||
import "./globals.css";
|
||||
import SiteLinks from "@/components/SiteLinks";
|
||||
import { SmirkBridgeBootstrap } from "./SmirkBridgeBootstrap";
|
||||
|
||||
const geistMono = Geist_Mono({
|
||||
@@ -48,8 +49,11 @@ export default function RootLayout({
|
||||
<html lang="en">
|
||||
<body className={`${geistMono.variable} font-mono antialiased min-h-screen flex flex-col`}>
|
||||
<SmirkBridgeBootstrap />
|
||||
<header className="px-4 py-5 text-zinc-400"><SiteLinks label="Site navigation" /></header>
|
||||
<main className="flex-1 flex flex-col">{children}</main>
|
||||
<footer className="py-4 text-center text-xs text-zinc-500 flex items-center justify-center gap-3 flex-wrap">
|
||||
<footer className="px-4 py-5 text-center text-xs text-zinc-400">
|
||||
<div className="mb-4"><SiteLinks label="Explore Smirk" /></div>
|
||||
<div className="flex items-center justify-center gap-3 flex-wrap">
|
||||
<a href="/stats" className="hover:text-[#fbeb0a] transition-colors">
|
||||
Stats
|
||||
</a>
|
||||
@@ -73,6 +77,7 @@ export default function RootLayout({
|
||||
such.software
|
||||
</a>
|
||||
</span>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import Link from 'next/link';
|
||||
export const metadata = { title: 'Premium relay posting' };
|
||||
export default function Premium() {
|
||||
return <div className="demo-page max-w-2xl"><p className="text-sm text-[#fbeb0a]">For the Smirk feed</p><h1 className="mt-4 text-3xl font-bold">Premium relay posting</h1>
|
||||
<p className="mt-6 leading-relaxed text-zinc-300">Open Smirk and visit Feed to see current plans and pay. Your selected backend shows the available plans and creates an invoice for your account.</p>
|
||||
<p className="mt-5 leading-relaxed text-zinc-400">Follow the payment options shown with your invoice. Posting access activates after the backend verifies settlement; creating an invoice alone does not activate it.</p>
|
||||
<p className="mt-5 text-sm leading-relaxed text-zinc-400">Smirk relay premium and forum premium are separate. This page does not create an invoice or take a payment.</p>
|
||||
<Link href="/downloads" className="mt-8 inline-block rounded-lg border border-zinc-700 px-5 py-3 text-sm hover:border-[#fbeb0a]">Get Smirk Wallet →</Link>
|
||||
</div>;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import Link from 'next/link';
|
||||
export default function SiteLinks({ label }: { label: string }) {
|
||||
return <nav aria-label={label} className="flex flex-wrap items-center justify-center gap-x-6 gap-y-2 text-xs sm:text-sm">
|
||||
<Link href="/downloads" className="hover:text-[#fbeb0a]">Downloads</Link>
|
||||
<Link href="/demos" className="hover:text-[#fbeb0a]">Demos</Link>
|
||||
<a href="https://forum.such.software/category/13/smirk-wallet" className="hover:text-[#fbeb0a]">Forum</a>
|
||||
<Link href="/premium" className="hover:text-[#fbeb0a]">Premium</Link>
|
||||
</nav>;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
"use client";
|
||||
import { useState } from 'react';
|
||||
import { advanceDemo, INITIAL_DEMO_STATE, setDemoEvidence, simulatedAssetState, type SwapDemo } from '@/lib/swap-demos';
|
||||
export default function SwapWalkthrough({ demo }: { demo: SwapDemo }) {
|
||||
const [state, setState] = useState(INITIAL_DEMO_STATE);
|
||||
const current = demo.steps[state.step];
|
||||
return <div className="mt-10">
|
||||
<div className="demo-assets">{demo.assets.map((asset, side) => <div key={asset} className="rounded-xl border border-zinc-800 p-5">
|
||||
<p className="text-xs text-zinc-400">{demo.people[side]}</p><p className="mt-2 text-2xl font-bold">{asset}</p>
|
||||
<p className="mt-2 text-sm text-[#fbeb0a]">{simulatedAssetState(state.step, side)}</p>
|
||||
</div>)}</div>
|
||||
<ol aria-label="Swap steps" className="my-8 grid gap-2 sm:grid-cols-2">{demo.steps.map((step, index) => <li key={step.label} aria-current={index === state.step ? 'step' : undefined}
|
||||
className={`rounded-lg border px-4 py-3 text-sm ${index === state.step ? 'border-[#fbeb0a] text-[#fbeb0a]' : 'border-zinc-800 text-zinc-400'}`}>
|
||||
<span className="mr-3 tabular-nums">{index + 1}.</span>{step.label}
|
||||
</li>)}</ol>
|
||||
<section aria-live="polite" aria-atomic="true" className="min-h-36">
|
||||
<p className="text-xs text-zinc-400">Simulated step {state.step + 1} of {demo.steps.length}</p>
|
||||
<h2 className="mt-3 text-xl font-semibold">{current.label}</h2><p className="mt-3 leading-relaxed text-zinc-300">{current.detail}</p>
|
||||
{state.evidenceUnknown && <p role="status" className="mt-4 rounded-lg border border-amber-700 p-4 text-sm text-amber-200">Evidence unavailable. The last known stage and locked funds stay unchanged. Recheck before continuing.</p>}
|
||||
</section>
|
||||
<div className="my-6 flex flex-wrap gap-3">
|
||||
<button type="button" disabled={state.evidenceUnknown || state.step === demo.steps.length - 1} onClick={() => setState(value => advanceDemo(value, demo.steps.length))}
|
||||
className="rounded-lg bg-[#fbeb0a] px-5 py-3 text-sm font-semibold text-black disabled:cursor-not-allowed disabled:opacity-40">{state.step === demo.steps.length - 1 ? 'Walkthrough complete' : 'Next step'}</button>
|
||||
<button type="button" onClick={() => setState(INITIAL_DEMO_STATE)} className="rounded-lg border border-zinc-700 px-5 py-3 text-sm">Start over</button>
|
||||
</div>
|
||||
<label className="inline-flex cursor-pointer items-center gap-3 text-sm text-zinc-400">
|
||||
<input type="checkbox" checked={state.evidenceUnknown} onChange={event => setState(value => setDemoEvidence(value, event.target.checked))} className="h-4 w-4 accent-[#fbeb0a]" />Simulate unavailable evidence
|
||||
</label>
|
||||
<section className="mt-12 border-t border-zinc-800 pt-8" aria-labelledby="recovery-heading">
|
||||
<h2 id="recovery-heading" className="text-xl font-semibold">If the swap does not finish</h2><p className="mb-5 mt-3 text-sm text-zinc-400">Different states have different recovery paths. Expand one to explore it.</p>
|
||||
{demo.recovery.map(branch => <details key={branch.label} className="border-b border-zinc-800 py-4"><summary className="cursor-pointer text-sm text-zinc-200">{branch.label}</summary><p className="mt-3 text-sm leading-relaxed text-zinc-400">{branch.detail}</p></details>)}
|
||||
</section>
|
||||
<p className="mt-8 text-xs leading-relaxed text-zinc-400">Steps and confirmations are simulated. Real swaps require network fees, chain confirmations, saved recovery data and timely monitoring.</p>
|
||||
</div>;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { advanceDemo, INITIAL_DEMO_STATE, setDemoEvidence, simulatedAssetState, SWAP_DEMOS } from './swap-demos.ts';
|
||||
test('unknown evidence preserves the last known stage and locked assets', () => {
|
||||
for (const step of [2, 3, 4]) {
|
||||
const state = setDemoEvidence({ step, evidenceUnknown: false }, true);
|
||||
const before = [0, 1].map(side => simulatedAssetState(state.step, side));
|
||||
assert.equal(advanceDemo(state, 6), state);
|
||||
assert.deepEqual([0, 1].map(side => simulatedAssetState(state.step, side)), before);
|
||||
assert.equal(advanceDemo(setDemoEvidence(state, false), 6).step, step + 1);
|
||||
}
|
||||
});
|
||||
test('complete walkthroughs stop at the final stage', () => {
|
||||
for (const demo of SWAP_DEMOS) {
|
||||
let state = INITIAL_DEMO_STATE;
|
||||
for (const _ of demo.steps) state = advanceDemo(state, demo.steps.length);
|
||||
assert.equal(state.step, demo.steps.length - 1);
|
||||
assert.equal(advanceDemo(state, demo.steps.length).step, state.step);
|
||||
assert.equal(simulatedAssetState(state.step, 1), 'Received');
|
||||
}
|
||||
});
|
||||
test('designs retain distinct compensation and cooperation-required branches', () => {
|
||||
const basic = SWAP_DEMOS.find(demo => demo.slug === 'basicswap')!;
|
||||
const eigen = SWAP_DEMOS.find(demo => demo.slug === 'eigenswap')!;
|
||||
assert.ok(basic.recovery.some(branch => /compensation/i.test(branch.detail)));
|
||||
assert.ok(eigen.recovery.some(branch => /maker cooperation/i.test(branch.detail)));
|
||||
assert.ok(eigen.badge.includes('preview'));
|
||||
});
|
||||
@@ -0,0 +1,143 @@
|
||||
export interface DemoStep { readonly label: string; readonly detail: string }
|
||||
export interface SwapDemo {
|
||||
readonly slug: string; readonly title: string; readonly badge: string; readonly intro: string;
|
||||
readonly assets: readonly string[]; readonly people: readonly string[];
|
||||
readonly steps: readonly DemoStep[]; readonly recovery: readonly DemoStep[]; readonly support: string;
|
||||
}
|
||||
export const SWAP_DEMOS: readonly SwapDemo[] = [
|
||||
{
|
||||
"slug": "basicswap",
|
||||
"title": "BasicSwap-compatible swaps",
|
||||
"badge": "Protocol 8",
|
||||
"intro": "Follow an illustrative Litecoin and Wownero exchange, including what happens when the success path stops.",
|
||||
"assets": [
|
||||
"LTC",
|
||||
"WOW"
|
||||
],
|
||||
"people": [
|
||||
"LTC-side leader",
|
||||
"WOW-side follower"
|
||||
],
|
||||
"steps": [
|
||||
{
|
||||
"label": "Agree on terms",
|
||||
"detail": "Two peers agree on amounts, destinations, fees and recovery conditions. A relayed offer or connected peer does not mean funds are locked."
|
||||
},
|
||||
{
|
||||
"label": "Prepare recovery",
|
||||
"detail": "Validate the transaction graph and key proofs, preserve the swap state, and save and verify recovery data before authorizing funding."
|
||||
},
|
||||
{
|
||||
"label": "Lock Litecoin",
|
||||
"detail": "The LTC-side leader funds the agreed Litecoin contract. Wait for the required chain evidence and recovery checks."
|
||||
},
|
||||
{
|
||||
"label": "Lock Wownero",
|
||||
"detail": "The WOW-side follower funds the shared Wownero address after the Litecoin checks pass. Verify its amount and confirmations."
|
||||
},
|
||||
{
|
||||
"label": "Claim Litecoin",
|
||||
"detail": "The follower uses the authorized signature path to claim LTC. The resulting valid signature lets the leader recover the missing Wownero key share."
|
||||
},
|
||||
{
|
||||
"label": "Receive Wownero",
|
||||
"detail": "The leader sweeps the shared WOW output to its wallet. Completion requires the appropriate evidence; a broadcast alone is not settlement."
|
||||
}
|
||||
],
|
||||
"recovery": [
|
||||
{
|
||||
"label": "Before funding: stop",
|
||||
"detail": "You can cancel the local request before funds are committed. Messages already relayed to another peer may remain."
|
||||
},
|
||||
{
|
||||
"label": "Submission uncertain",
|
||||
"detail": "Keep the signed transaction and reserved inputs. Check its exact status before retrying; do not create a new payment."
|
||||
},
|
||||
{
|
||||
"label": "Wait for recovery",
|
||||
"detail": "Eligibility follows the agreed chain timelocks and validated unspent state, not a browser countdown."
|
||||
},
|
||||
{
|
||||
"label": "Refund or compensation",
|
||||
"detail": "The LTC refund path can return LTC to the leader and reveal the share needed for the follower to recover WOW. If the leader does not complete the refund-spend path, a later follower swipe can yield LTC compensation. Compensation is not a WOW refund and is not guaranteed equal market value."
|
||||
},
|
||||
{
|
||||
"label": "Restore and recheck",
|
||||
"detail": "Load retained recovery data and revalidate current chain state. Missing evidence or a reorganization means status needs checking, not automatic success."
|
||||
}
|
||||
],
|
||||
"support": "This compatibility work is under development. The walkthrough is not a live trading interface and cannot start a swap."
|
||||
},
|
||||
{
|
||||
"slug": "eigenswap",
|
||||
"title": "EigenSwap",
|
||||
"badge": "v0.3.3 preview",
|
||||
"intro": "Explore a Bitcoin-paying, Monero-receiving taker flow. This is an unreleased compatibility preview, not an integrated wallet feature.",
|
||||
"assets": [
|
||||
"BTC",
|
||||
"XMR"
|
||||
],
|
||||
"people": [
|
||||
"BTC-paying taker",
|
||||
"XMR-paying maker"
|
||||
],
|
||||
"steps": [
|
||||
{
|
||||
"label": "Review a maker quote",
|
||||
"detail": "Choose BTC amount and review XMR amount, fees, any anti-spam deposit and recovery deadlines."
|
||||
},
|
||||
{
|
||||
"label": "Prepare the swap",
|
||||
"detail": "Exchange and validate key proofs and signed recovery transactions. Persist per-swap state before publishing the Bitcoin lock."
|
||||
},
|
||||
{
|
||||
"label": "Lock Bitcoin",
|
||||
"detail": "The taker funds the agreed two-key Bitcoin output first."
|
||||
},
|
||||
{
|
||||
"label": "Verify Monero",
|
||||
"detail": "The maker locks XMR to a shared address. The taker checks address, amount and required confirmations before releasing the encrypted signature."
|
||||
},
|
||||
{
|
||||
"label": "Maker claims Bitcoin",
|
||||
"detail": "The maker completes the adaptor signature and redeems BTC. The published signature lets the taker recover the maker’s Monero key share."
|
||||
},
|
||||
{
|
||||
"label": "Sweep Monero",
|
||||
"detail": "The taker signs and publishes the XMR sweep, retains recovery material, and waits for the configured confirmation policy."
|
||||
}
|
||||
],
|
||||
"recovery": [
|
||||
{
|
||||
"label": "Cancel and refund",
|
||||
"detail": "If the success path stalls, the taker waits for the Bitcoin cancel condition and completes the applicable refund path, paying network fees."
|
||||
},
|
||||
{
|
||||
"label": "Deposit withheld",
|
||||
"detail": "A maker may require an anti-spam deposit up to 20%. Reclaim, withhold and mercy are distinct branches: your refund may be partial, and network fees still apply."
|
||||
},
|
||||
{
|
||||
"label": "Missed deadline",
|
||||
"detail": "After the punish condition, the maker can take the BTC. XMR recovery then depends on maker cooperation; no guaranteed automatic refund."
|
||||
},
|
||||
{
|
||||
"label": "Source unavailable",
|
||||
"detail": "Status stays unknown while the source is unavailable. Keep your saved swap state and follow the Bitcoin recovery deadlines; unavailable Monero evidence does not confirm a payment."
|
||||
},
|
||||
{
|
||||
"label": "Resume from saved swap data",
|
||||
"detail": "Your wallet seed alone is not enough to restore this swap. Per-swap records are also needed. Wallet integration and background monitoring are still under development."
|
||||
}
|
||||
],
|
||||
"support": "A local test-network implementation exists. Wallet integration and mainnet use are not available in this preview."
|
||||
}
|
||||
];
|
||||
export interface DemoState { readonly step: number; readonly evidenceUnknown: boolean }
|
||||
export const INITIAL_DEMO_STATE: DemoState = Object.freeze({ step: 0, evidenceUnknown: false });
|
||||
export function advanceDemo(state: DemoState, count: number): DemoState {
|
||||
return state.evidenceUnknown ? state : { ...state, step: Math.min(state.step + 1, count - 1) };
|
||||
}
|
||||
export function setDemoEvidence(state: DemoState, evidenceUnknown: boolean): DemoState { return { ...state, evidenceUnknown }; }
|
||||
export function simulatedAssetState(step: number, side: number): string {
|
||||
return side === 0 ? (step < 2 ? 'Not locked' : step < 4 ? 'Locked' : 'Claimed') : (step < 3 ? 'Not locked' : step < 5 ? 'Locked' : 'Received');
|
||||
}
|
||||
Reference in New Issue
Block a user