Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
Add stage and world-lines tests and page, sync changelog/pages data
nirholas12d9778a5899
diff --git a/data/changelog.json b/data/changelog.jsonindex 73a659ce5..555cfea7d 100644--- a/data/changelog.json+++ b/data/changelog.json@@ -1,6 +1,15 @@{"$comment": "Curated changelog entries for three.ws — the editorial layer of the public changelog. New PAGE launches are tracked automatically via the `added` field in data/pages.json; this file is for everything else holders care about: improvements, fixes, SDK releases, trading/payments capabilities, security work. scripts/build-page-index.mjs merges both sources into CHANGELOG.md, public/changelog.json, and public/changelog.xml. Newest first. Allowed tags: feature, improvement, fix, sdk, infra, docs, security. `link` is optional and must be a live three.ws path.","entries": [+ {+ "date": "2026-06-23",+ "title": "Split your skill proceeds with collaborators — paid exactly, automatically",+ "summary": "Built a skill with someone else? You can now set a proceeds split when you price it — say 70/30 — and every sale pays each collaborator their exact share automatically. Buyers see where their money goes right on the purchase screen (\"proceeds split: 70/30\"), so it's fully transparent. On EVM chains the split runs through an on-chain 0xSplits contract, so distribution is trustless and the platform never touches the money; on Solana each collaborator's exact share is recorded and becomes withdrawable. The math is provably exact: the platform fee plus every collaborator's cut always add back up to the price the buyer paid — never a hidden cut, never a lost cent, even on awkward amounts. Your new Creator Earnings dashboard pulls it all together: royalties, split payouts you've received, the on-chain skill licenses your skills have minted to buyers, and one Withdraw button for your available balance — each payout linking to its on-chain receipt. Every paid skill purchase now also mints a trustless on-chain license proving the buyer's right to run it, and a license revoked on-chain (e.g. on a refund) blocks execution even if a stale record lingers. $THREE is the only coin on three.ws.",+ "tags": [+ "feature"+ ],+ "link": "/dashboard/earnings"+ },{"date": "2026-06-23","title": "Refer a friend — you both earn credits the moment they create",diff --git a/data/pages.json b/data/pages.jsonindex 4a458ab01..b1f0d05d8 100644--- a/data/pages.json+++ b/data/pages.json@@ -191,6 +191,15 @@"changefreq": "weekly","added": "2026-04-16"},+ {+ "path": "/genome",+ "title": "Agent Genome — breed two agents",+ "description": "Breed two AI agents into a provably-inherited offspring. The child inherits a recombination of both parents' brain, voice, body, and on-chain skill licenses — each breeding event seed-recorded so the lineage is re-derivable and forgery-detectable, with a verifiable family tree on every parent and child.",+ "priority": 0.8,+ "changefreq": "daily",+ "added": "2026-06-23",+ "showcase": true+ },{"path": "/create-agent","title": "Create an Agent",diff --git a/pages/world-lines.html b/pages/world-lines.htmlnew file mode 100644index 000000000..7248e52fd--- /dev/null+++ b/pages/world-lines.html@@ -0,0 +1,231 @@+<!doctype html>+<html lang="en">+<head>+ <meta charset="utf-8" />+ <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />+ <title>World Lines — agent proof-of-presence quests · three.ws</title>+ <meta name="description" content="Walk to an agent’s real-world spot, complete its AR quest, and earn a cryptographically real, agent-signed proof of presence — privacy-preserving, verifiable, ownable." />+ <link rel="icon" href="/favicon.svg" type="image/svg+xml" />+ <meta name="theme-color" content="#000000" />+ <meta property="og:title" content="World Lines — agent proof-of-presence quests" />+ <meta property="og:description" content="Pokémon GO, but every encounter is an autonomous AI agent and every reward is an agent-signed proof of presence." />+ <meta property="og:type" content="website" />+ <style>+ :root {+ --bg: #000000; --bg2: #0a0a0a; --text: #e8e8e8; --text-2: #8a8a92; --text-3: #555;+ --accent: #c4b5fd; --accent-2: #7a6cf0; --panel: rgba(255,255,255,0.04);+ --border: rgba(255,255,255,0.08); --border-hi: rgba(255,255,255,0.22);+ --danger: #f87171; --green: #4ade80; --gold: #fbbf24; --radius: 16px;+ --easy: #4ade80; --medium: #fbbf24; --hard: #f87171;+ }+ * { box-sizing: border-box; }+ html, body { margin: 0; background: var(--bg); color: var(--text);+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, system-ui, sans-serif;+ -webkit-font-smoothing: antialiased; }+ a { color: var(--accent); text-decoration: none; }+ .wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px 96px; }++ header.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center;+ justify-content: space-between; gap: 12px; padding: 14px 16px;+ background: rgba(0,0,0,0.72); backdrop-filter: blur(14px);+ border-bottom: 1px solid var(--border); }+ .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -0.01em; }+ .brand .glyph { width: 26px; height: 26px; border-radius: 8px;+ background: radial-gradient(circle at 30% 30%, var(--accent), var(--accent-2)); }+ .topbar nav { display: flex; gap: 8px; }+ .topbar nav a { color: var(--text-2); font-size: 14px; padding: 7px 12px; border-radius: 10px; }+ .topbar nav a:hover, .topbar nav a.active { color: var(--text); background: var(--panel); }++ .hero { padding: 40px 0 18px; }+ .hero h1 { font-size: clamp(28px, 5vw, 44px); line-height: 1.05; margin: 0 0 12px; letter-spacing: -0.03em; }+ .hero p { color: var(--text-2); font-size: 16px; max-width: 640px; line-height: 1.55; margin: 0; }++ .tabs { display: flex; gap: 6px; margin: 22px 0 18px; flex-wrap: wrap;+ border-bottom: 1px solid var(--border); }+ .tab { background: none; border: none; color: var(--text-2); font: inherit; font-size: 15px;+ padding: 10px 14px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }+ .tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }+ .tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }++ .panel { display: none; }+ .panel.active { display: block; animation: fade .25s ease; }+ @keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }++ .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }++ .card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);+ padding: 16px; transition: border-color .18s, transform .18s; }+ .card:hover { border-color: var(--border-hi); }+ .card h3 { margin: 0 0 6px; font-size: 17px; letter-spacing: -0.01em; }+ .card .meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }+ .chip { font-size: 12px; padding: 4px 9px; border-radius: 999px; background: rgba(255,255,255,0.06);+ color: var(--text-2); border: 1px solid var(--border); display: inline-flex; align-items: center; gap: 5px; }+ .chip.easy { color: var(--easy); } .chip.medium { color: var(--medium); } .chip.hard { color: var(--hard); }+ .chip.reward { color: var(--gold); }+ .chip.dist { color: var(--accent); }+ .chip.done { color: var(--green); border-color: rgba(74,222,128,0.4); }+ .card .cta-row { display: flex; gap: 8px; margin-top: 12px; }++ .btn { font: inherit; font-size: 14px; font-weight: 600; padding: 10px 16px; border-radius: 12px;+ border: 1px solid var(--border-hi); background: var(--panel); color: var(--text); cursor: pointer;+ transition: transform .12s, background .15s, border-color .15s; }+ .btn:hover { background: rgba(255,255,255,0.08); }+ .btn:active { transform: scale(0.97); }+ .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }+ .btn.primary { background: linear-gradient(180deg, var(--accent), var(--accent-2)); color: #11091f;+ border-color: transparent; }+ .btn.primary:hover { filter: brightness(1.06); }+ .btn.full { width: 100%; }+ .btn[disabled] { opacity: .5; cursor: not-allowed; }++ .state { text-align: center; padding: 56px 20px; color: var(--text-2); }+ .state .ico { font-size: 34px; margin-bottom: 10px; opacity: .8; }+ .state h3 { color: var(--text); margin: 0 0 6px; }+ .state p { margin: 0 auto 16px; max-width: 420px; line-height: 1.5; }++ .skel { background: linear-gradient(90deg, rgba(255,255,255,0.04), rgba(255,255,255,0.09), rgba(255,255,255,0.04));+ background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 12px; height: 140px; }+ @keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }++ /* Region browse */+ .region-row { display: flex; align-items: center; justify-content: space-between; gap: 12px;+ padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel);+ cursor: pointer; transition: border-color .15s; }+ .region-row:hover { border-color: var(--border-hi); }+ .region-row .rc { font-family: ui-monospace, monospace; color: var(--text-2); font-size: 13px; }++ /* Collectible */+ .collectible { background: linear-gradient(160deg, rgba(196,181,253,0.10), rgba(122,108,240,0.04));+ border: 1px solid rgba(196,181,253,0.22); }+ .collectible .seal { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;+ font-size: 20px; background: rgba(196,181,253,0.16); margin-bottom: 8px; }+ .mono { font-family: ui-monospace, monospace; font-size: 12px; color: var(--text-2); word-break: break-all; }++ /* Form */+ .form { max-width: 560px; }+ .field { margin-bottom: 16px; }+ .field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }+ .field input, .field select, .field textarea { width: 100%; font: inherit; font-size: 15px;+ background: var(--bg2); color: var(--text); border: 1px solid var(--border); border-radius: 10px;+ padding: 11px 12px; }+ .field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); }+ .field .hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }+ .choices-edit { display: flex; flex-direction: column; gap: 8px; }+ .form-note { font-size: 13px; color: var(--text-2); background: var(--panel); border: 1px solid var(--border);+ border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; }++ /* Dashboard quest */+ .dash-quest { display: flex; flex-direction: column; gap: 8px; }+ .bar { height: 6px; background: rgba(255,255,255,0.07); border-radius: 4px; overflow: hidden; }+ .bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); }++ /* Modal / ceremony */+ .modal { position: fixed; inset: 0; z-index: 60; display: none; align-items: center; justify-content: center;+ padding: 16px; background: rgba(0,0,0,0.78); backdrop-filter: blur(10px); }+ .modal.open { display: flex; }+ .modal-box { width: 100%; max-width: 440px; background: var(--bg2); border: 1px solid var(--border-hi);+ border-radius: 20px; padding: 8px; position: relative; max-height: 90vh; overflow: auto; }+ .modal-close { position: absolute; top: 10px; right: 10px; z-index: 2; background: var(--panel);+ border: 1px solid var(--border); color: var(--text-2); width: 34px; height: 34px; border-radius: 10px;+ cursor: pointer; font-size: 16px; }++ /* Ceremony (rendered by world-line-ar.js) */+ .wl-ceremony { padding: 8px; }+ .wl-cer-card { text-align: center; padding: 22px 18px; }+ .wl-cer-agent { display: flex; justify-content: center; margin-bottom: 14px; }+ .wl-cer-canvas { width: 160px; height: 160px; }+ .wl-cer-orb { width: 96px; height: 96px; border-radius: 50%;+ background: radial-gradient(circle at 35% 30%, var(--accent), var(--accent-2));+ box-shadow: 0 0 50px rgba(196,181,253,0.4); animation: bob 3s ease-in-out infinite; }+ @keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }+ .wl-cer-title { font-size: 20px; margin: 4px 0 8px; letter-spacing: -0.02em; }+ .wl-cer-prompt { color: var(--text-2); line-height: 1.5; margin: 0 0 18px; }+ .wl-cer-q { font-size: 16px; margin: 0 0 14px; }+ .wl-cer-actions { display: flex; flex-direction: column; gap: 8px; }+ .wl-btn { font: inherit; font-size: 15px; font-weight: 600; padding: 12px 18px; border-radius: 12px;+ border: 1px solid var(--border-hi); background: var(--panel); color: var(--text); cursor: pointer; }+ .wl-btn-primary { background: linear-gradient(180deg, var(--accent), var(--accent-2)); color: #11091f;+ border-color: transparent; }+ .wl-btn:active { transform: scale(0.97); }+ .wl-choice { display: block; width: 100%; text-align: left; font: inherit; font-size: 15px;+ padding: 13px 15px; margin-bottom: 8px; border-radius: 12px; border: 1px solid var(--border);+ background: var(--bg); color: var(--text); cursor: pointer; }+ .wl-choice[aria-checked="true"], .wl-choice:hover { border-color: var(--accent); }+ .wl-input { width: 100%; font: inherit; font-size: 16px; padding: 12px 14px; border-radius: 12px;+ background: var(--bg); border: 1px solid var(--border); color: var(--text); margin-bottom: 12px; }+ .wl-cer-err { color: var(--danger); font-size: 13px; margin-top: 10px; }+ .wl-cer-foot { color: var(--text-3); font-size: 12px; margin: 14px 0 0; line-height: 1.5; }+ .wl-reward-badge { width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 12px; display: grid;+ place-items: center; font-size: 26px; color: #11091f;+ background: linear-gradient(180deg, var(--accent), var(--accent-2)); box-shadow: 0 0 44px rgba(196,181,253,0.5); }+ .wl-reward-badge.wl-dim { background: var(--panel); color: var(--green); box-shadow: none; border: 1px solid var(--border); }+ .wl-reward-badge.wl-err { background: rgba(248,113,113,0.16); color: var(--danger); box-shadow: none; }+ .wl-proof-meta { display: grid; gap: 8px; text-align: left; margin: 16px 0; }+ .wl-proof-meta dt { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }+ .wl-proof-meta dd { margin: 2px 0 0; }+ .wl-mono { font-family: ui-monospace, monospace; font-size: 13px; color: var(--text-2); word-break: break-all; }+ .wl-spinner { width: 34px; height: 34px; margin: 8px auto 14px; border-radius: 50%;+ border: 3px solid var(--border); border-top-color: var(--accent); animation: spin .8s linear infinite; }+ @keyframes spin { to { transform: rotate(360deg); } }+ .wl-granted .wl-reward-burst { position: absolute; inset: 0; pointer-events: none;+ background: radial-gradient(circle at 50% 28%, rgba(196,181,253,0.25), transparent 60%); }++ /* AR overlay */+ .wl-ar-overlay { position: fixed; inset: 0; z-index: 70; display: flex; flex-direction: column;+ justify-content: space-between; padding: 24px; pointer-events: none; }+ .wl-ar-hint { align-self: center; background: rgba(0,0,0,0.6); color: #fff; padding: 10px 16px;+ border-radius: 999px; font-size: 14px; margin-top: auto; }+ .wl-ar-exit { align-self: flex-end; pointer-events: auto; background: rgba(0,0,0,0.6); color: #fff;+ border: 1px solid rgba(255,255,255,0.3); border-radius: 10px; padding: 8px 14px; cursor: pointer; }++ @media (prefers-reduced-motion: reduce) {+ *, .wl-cer-orb, .skel, .wl-spinner { animation: none !important; transition: none !important; }+ }+ @media (max-width: 540px) {+ .hero { padding: 28px 0 14px; }+ .topbar nav a { padding: 7px 9px; }+ }+ </style>+</head>+<body>+ <header class="topbar">+ <a class="brand" href="/world-lines" aria-label="three.ws World Lines"><span class="glyph"></span> World Lines</a>+ <nav>+ <a href="/irl">IRL map</a>+ <a href="/world-lines" class="active" aria-current="page">Quests</a>+ <a href="/irl-privacy">Privacy</a>+ </nav>+ </header>++ <main class="wrap">+ <section class="hero">+ <h1>Walk to an agent. Earn a proof you were there.</h1>+ <p>Every World Line is an AI agent waiting at a real-world spot. Travel to it, complete its+ AR challenge, and the agent’s own wallet signs a <strong>proof of presence</strong> — a+ cryptographically real, independently verifiable collectible. Your exact location never+ leaves your device; a proof only ever knows a ~1 km area.</p>+ </section>++ <div class="tabs" role="tablist" aria-label="World Lines sections">+ <button class="tab" role="tab" id="tab-near" aria-controls="panel-near" aria-selected="true">Near me</button>+ <button class="tab" role="tab" id="tab-explore" aria-controls="panel-explore" aria-selected="false">Explore</button>+ <button class="tab" role="tab" id="tab-collectibles" aria-controls="panel-collectibles" aria-selected="false">My proofs</button>+ <button class="tab" role="tab" id="tab-create" aria-controls="panel-create" aria-selected="false">Create</button>+ </div>++ <section class="panel active" id="panel-near" role="tabpanel" aria-labelledby="tab-near"></section>+ <section class="panel" id="panel-explore" role="tabpanel" aria-labelledby="tab-explore"></section>+ <section class="panel" id="panel-collectibles" role="tabpanel" aria-labelledby="tab-collectibles"></section>+ <section class="panel" id="panel-create" role="tabpanel" aria-labelledby="tab-create"></section>+ </main>++ <div class="modal" id="ceremony-modal" role="dialog" aria-modal="true" aria-label="World Line encounter">+ <div class="modal-box">+ <button class="modal-close" id="ceremony-close" aria-label="Close">✕</button>+ <div id="ceremony-host"></div>+ </div>+ </div>++ <script type="module" src="/src/world-lines.js"></script>+</body>+</html>diff --git a/tests/marketplace-splits.test.js b/tests/marketplace-splits.test.jsindex 6f92af46a..58cfce54a 100644--- a/tests/marketplace-splits.test.js+++ b/tests/marketplace-splits.test.js@@ -10,7 +10,7 @@* Pure functions only — no DB, no chain — so they run fast and deterministically.*/-import { describe, it, expect } from 'vitest';+import { describe, it, expect, afterEach } from 'vitest';import {validateShares,allocateAtomics,@@ -229,3 +229,70 @@ describe('describeSplit', () => {expect(d.recipients[1].label).toBe('Art');});});++describe('recordSplitDistribution — persisted allocations', () => {+ const split = {+ id: 'split-1',+ split_mode: 'ledger',+ recipients: [+ { address: EVM_A, share_bps: 6000, recipient_user_id: 'u-a' },+ { address: EVM_B, share_bps: 4000, recipient_user_id: 'u-b' },+ ],+ };++ it('writes one row per recipient whose amounts sum to the creator net', async () => {+ const sql = fakeSql([]);+ const out = await recordSplitDistribution(sql, {+ purchaseId: 'p-1',+ split,+ netAtomics: 9_500_001n, // odd amount → forces a remainder+ currencyMint: 'usdc',+ chain: 'base',+ });+ expect(out).toHaveLength(2);+ const total = out.reduce((s, r) => s + BigInt(r.amount), 0n);+ expect(total).toBe(9_500_001n); // exact — nothing lost+ // 60/40 of 9_500_001 → 5_700_001 / 3_800_000 (remainder to the larger share).+ expect(out.find((r) => r.address === EVM_A).amount).toBe('5700001');+ expect(out.find((r) => r.address === EVM_B).amount).toBe('3800000');+ });++ it('marks ledger-mode rows accrued and onchain-mode rows settled', async () => {+ const ledger = await recordSplitDistribution(fakeSql([]), {+ purchaseId: 'p-2', split, netAtomics: 1000n, currencyMint: 'usdc', chain: 'base',+ });+ expect(ledger.every((r) => r.mode === 'ledger' && r.status === 'accrued')).toBe(true);++ const onchain = await recordSplitDistribution(fakeSql([]), {+ purchaseId: 'p-3',+ split: { ...split, split_mode: 'onchain' },+ netAtomics: 1000n, currencyMint: 'usdc', chain: 'base',+ });+ expect(onchain.every((r) => r.mode === 'onchain' && r.status === 'settled')).toBe(true);+ });+});++describe('enforceOnchainLicense — fail-open gate', () => {+ const prev = process.env.SKILL_LICENSE_ENFORCE;+ afterEach(() => {+ if (prev === undefined) delete process.env.SKILL_LICENSE_ENFORCE;+ else process.env.SKILL_LICENSE_ENFORCE = prev;+ });++ it('never touches the chain when enforcement is off', async () => {+ delete process.env.SKILL_LICENSE_ENFORCE;+ expect(licenseEnforcementEnabled()).toBe(false);+ const sql = fakeSql([]);+ const r = await enforceOnchainLicense({ sql, userId: 'u', agentId: 'a', skill: 's' });+ expect(r.blocked).toBe(false);+ expect(sql.calls).toHaveLength(0); // no DB read, no RPC+ });++ it('does not block a paid user with no minted license on record', async () => {+ process.env.SKILL_LICENSE_ENFORCE = '1';+ expect(licenseEnforcementEnabled()).toBe(true);+ // sql returns no skill_license_mints row → nothing to enforce → allow.+ const r = await enforceOnchainLicense({ sql: fakeSql([]), userId: 'u', agentId: 'a', skill: 's' });+ expect(r.blocked).toBe(false);+ });+});diff --git a/tests/stage-show.test.js b/tests/stage-show.test.jsnew file mode 100644index 000000000..1f8ad5742Binary files /dev/null and b/tests/stage-show.test.js differdiff --git a/tests/stage-split.test.js b/tests/stage-split.test.jsnew file mode 100644index 000000000..01443f6e9--- /dev/null+++ b/tests/stage-split.test.js@@ -0,0 +1,137 @@+// Unit tests for the Living Stages tip split + settlement validation+// (api/_lib/stage-split.js) — pure, integer-only money math + the "no settlement+// proof, no row" discipline. Runs without a DB or a socket.++import { describe, it, expect } from 'vitest';+import {+ THREE_MINT,+ splitTip,+ normalizeSplitBps,+ parseAtomicAmount,+ isValidTipSignature,+ isAllowedTipMint,+ validateTipPayload,+ tipExplorerUrl,+ DEFAULT_TIP_SPLIT_BPS,+} from '../api/_lib/stage-split.js';++const SOL_SIG = '5'.padEnd(64, 'A'); // base58-shaped, 64 chars+const EVM_TX = '0x' + 'a'.repeat(64);+const USDC_SOL = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v';++describe('splitTip — host/venue accounting', () => {+ it('host + venue always reconcile to the exact amount (fuzz)', () => {+ const bpsVals = [0, 1, 250, 1000, 3333, 5000, 9999, 10000];+ for (let i = 0; i < 500; i++) {+ const amount = 1 + Math.floor(Math.abs(Math.sin(i * 12.9898) * 1e6) * 1000);+ for (const bps of bpsVals) {+ const { hostCredit, venueCut } = splitTip(amount, bps);+ expect(hostCredit + venueCut).toBe(amount);+ expect(Number.isInteger(hostCredit)).toBe(true);+ expect(Number.isInteger(venueCut)).toBe(true);+ expect(venueCut).toBeGreaterThanOrEqual(0);+ expect(hostCredit).toBeGreaterThanOrEqual(0);+ }+ }+ });++ it('floors the venue cut and hands the remainder to the host', () => {+ // 1001 atomic at 50% → venue floor(500.5)=500, host 501.+ const { hostCredit, venueCut } = splitTip(1001, 5000);+ expect(venueCut).toBe(500);+ expect(hostCredit).toBe(501);+ });++ it('0 bps → host keeps everything; 10000 bps → venue takes all', () => {+ expect(splitTip(1000, 0)).toMatchObject({ hostCredit: 1000, venueCut: 0 });+ expect(splitTip(1000, 10000)).toMatchObject({ hostCredit: 0, venueCut: 1000 });+ });++ it('applies the platform default split when bps is omitted/invalid', () => {+ expect(splitTip(10000).splitBps).toBe(DEFAULT_TIP_SPLIT_BPS);+ expect(splitTip(10000, -5).splitBps).toBe(DEFAULT_TIP_SPLIT_BPS);+ expect(splitTip(10000, 99999).splitBps).toBe(DEFAULT_TIP_SPLIT_BPS);+ });++ it('rejects a non-positive-integer amount', () => {+ expect(() => splitTip(0)).toThrow();+ expect(() => splitTip(-5)).toThrow();+ expect(() => splitTip(1.5)).toThrow();+ });+});++describe('normalizeSplitBps', () => {+ it('clamps out-of-range / non-finite to the default, keeps valid', () => {+ expect(normalizeSplitBps(2500)).toBe(2500);+ expect(normalizeSplitBps(0)).toBe(0);+ expect(normalizeSplitBps(10000)).toBe(10000);+ expect(normalizeSplitBps(-1)).toBe(DEFAULT_TIP_SPLIT_BPS);+ expect(normalizeSplitBps(10001)).toBe(DEFAULT_TIP_SPLIT_BPS);+ expect(normalizeSplitBps('abc')).toBe(DEFAULT_TIP_SPLIT_BPS);+ });+});++describe('parseAtomicAmount', () => {+ it('accepts positive integers, rejects everything else', () => {+ expect(parseAtomicAmount(1)).toBe(1);+ expect(parseAtomicAmount('1000000')).toBe(1000000);+ expect(parseAtomicAmount(0)).toBeNull();+ expect(parseAtomicAmount(-1)).toBeNull();+ expect(parseAtomicAmount(1.5)).toBeNull();+ expect(parseAtomicAmount(NaN)).toBeNull();+ expect(parseAtomicAmount(Number.MAX_SAFE_INTEGER + 2)).toBeNull();+ });+});++describe('settlement signature + mint validation', () => {+ it('accepts EVM tx hashes and base58 Solana sigs', () => {+ expect(isValidTipSignature(EVM_TX)).toBe(true);+ expect(isValidTipSignature(SOL_SIG)).toBe(true);+ expect(isValidTipSignature('not-a-sig')).toBe(false);+ expect(isValidTipSignature('0xshort')).toBe(false);+ expect(isValidTipSignature(null)).toBe(false);+ });++ it('only $THREE and USDC are allowed mints', () => {+ expect(isAllowedTipMint(THREE_MINT)).toBe(true);+ expect(isAllowedTipMint(USDC_SOL)).toBe(true);+ // EVM USDC compares case-insensitively.+ expect(isAllowedTipMint('0x833589fcd6edb6e08f4c7c32d4f71b54bda02913'.toUpperCase())).toBe(true);+ expect(isAllowedTipMint('SomeOtherMint1111111111111111111111111111')).toBe(false);+ expect(isAllowedTipMint('')).toBe(false);+ });++ it('$THREE is the canonical coin address', () => {+ expect(THREE_MINT).toBe('FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump');+ });+});++describe('validateTipPayload', () => {+ it('passes a well-formed $THREE tip and normalizes the network', () => {+ const out = validateTipPayload({ signature: SOL_SIG, currencyMint: THREE_MINT, amount: 5_000_000, network: 'solana' });+ expect(out).toMatchObject({ ok: true, amount: 5_000_000, mint: THREE_MINT, network: 'solana' });+ });++ it('rejects a missing/garbage signature', () => {+ expect(validateTipPayload({ signature: 'x', currencyMint: THREE_MINT, amount: 1 }).ok).toBe(false);+ });++ it('rejects a disallowed mint', () => {+ const out = validateTipPayload({ signature: SOL_SIG, currencyMint: 'Bad', amount: 1 });+ expect(out.ok).toBe(false);+ expect(out.error).toMatch(/THREE or USDC/);+ });++ it('rejects a non-integer amount', () => {+ expect(validateTipPayload({ signature: SOL_SIG, currencyMint: THREE_MINT, amount: 1.5 }).ok).toBe(false);+ expect(validateTipPayload({ signature: SOL_SIG, currencyMint: THREE_MINT, amount: 0 }).ok).toBe(false);+ });+});++describe('tipExplorerUrl', () => {+ it('routes EVM tx to Basescan and Solana sig to Solscan', () => {+ expect(tipExplorerUrl(EVM_TX)).toContain('basescan.org');+ expect(tipExplorerUrl(SOL_SIG)).toContain('solscan.io');+ expect(tipExplorerUrl(null)).toBeNull();+ });+});