Skip to content

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.

Play onboard, THREE token page, holders dashboard, Jupiter swap, and changelog updates

nirholasf7aa852a3f5f
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d814f6a9e..6122c2a5b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,6 +16,8 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr
- **The 3D agent on the homepage moves again instead of standing frozen** — The live avatar in the homepage hero had stopped animating — it loaded but stood in a stiff arms-out pose, and the Wave, Dance, and Pray buttons did nothing. The viewer only renders frames while something is moving to save your battery, and a recent change meant that starting an animation no longer woke the renderer back up once it had gone idle, so the avatar was stuck on its first frame. The renderer is now nudged awake the instant any animation starts, so the homepage agent idles, walks, and responds to the move buttons as intended. `[fix]`
- **The animated 3D bot in the site footer renders again** — The little animated 3D robot that sits in the footer across the site — and on the sign-in page — had gone missing, leaving an empty space. The model files it loads are compressed, but the footer loader wasn't set up to unpack that format, so it failed before the bot could appear. The decoder is now wired in, so the bot loads and spins as intended everywhere the footer shows. `[fix]`
- **The disco dance floor in coin worlds works again** — Every coin world has a disco pad beside the totem that pulses to a shared beat and crossfades dancers in lockstep. A wiring gap meant the world tried to listen for a beat the connection didn't know about, which threw an error the moment you entered and left the pad dark. The beat is now delivered properly: step onto the pad, hit Dance, and you and everyone else standing on it move to the same animation on the same beat, with the floor and lights pulsing in time. (`/play`) `[fix]`
+- **The homepage avatar now prays, then walks** — Tap “🙏 Pray” on the homepage hero and the avatar finishes the prayer and rises straight into a walk — one smooth motion instead of snapping back to a standing idle at the end of the clip. After the walk plays out, the avatar eases back into its gentle idle-and-stroll rhythm. The other one-tap emotes (wave, dance, jump, and the rest) also return to that ambient motion now instead of freezing on their last frame. `[improvement]`
+- **Token swaps now confirm success or failure clearly** — When you buy $THREE (or swap any pair) from the swap window, it now tells you exactly how it went. After you approve in your wallet, a banner shows it submitting and confirming on-chain, then resolves to a clear result: a green “Swap confirmed” with the amount you received and a Solscan link, a red on-chain failure with the reason (and a hint to widen slippage when that's the cause), or a “still confirming” notice with a link if the network is slow. Previously a swap could land successfully but the window sat on “Confirming…” indefinitely with no confirmation — because it was waiting on a live socket the swap proxy doesn't carry. It now polls the chain directly and gives you a definite answer in seconds. (`/three-token`) `[fix]`
- **Your $THREE holder tier now shows across the site** — Holding $THREE is now visible everywhere you are. A holder chip in the top bar shows your live tier (◆ Bronze, Silver, Gold…) on every page and links to the full tier breakdown. On Forge, choosing the High quality tier now shows a clear, designed panel instead of a silent block: holders see an "Unlocked" badge and generate straight away, while everyone else gets a "Get $THREE" path, the exact reason (sign in, link a wallet, or hold more), and a one-tap switch back to free Draft or Standard — no dead ends and no raw errors. (`/forge`) `[feature, improvement]`
## 2026-06-17
diff --git a/data/changelog.json b/data/changelog.json
index 6a436c7b7..d16f0a97e 100644
--- a/data/changelog.json
+++ b/data/changelog.json
@@ -1,6 +1,23 @@
{
"$comment": "Curated changelog entries for three.ws \u2014 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-18",
+ "title": "Token swaps now confirm success or failure clearly",
+ "summary": "When you buy $THREE (or swap any pair) from the swap window, it now tells you exactly how it went. After you approve in your wallet, a banner shows it submitting and confirming on-chain, then resolves to a clear result: a green “Swap confirmed” with the amount you received and a Solscan link, a red on-chain failure with the reason (and a hint to widen slippage when that's the cause), or a “still confirming” notice with a link if the network is slow. Previously a swap could land successfully but the window sat on “Confirming…” indefinitely with no confirmation — because it was waiting on a live socket the swap proxy doesn't carry. It now polls the chain directly and gives you a definite answer in seconds.",
+ "tags": [
+ "fix"
+ ],
+ "link": "/three-token"
+ },
+ {
+ "date": "2026-06-18",
+ "title": "The homepage avatar now prays, then walks",
+ "summary": "Tap “🙏 Pray” on the homepage hero and the avatar finishes the prayer and rises straight into a walk — one smooth motion instead of snapping back to a standing idle at the end of the clip. After the walk plays out, the avatar eases back into its gentle idle-and-stroll rhythm. The other one-tap emotes (wave, dance, jump, and the rest) also return to that ambient motion now instead of freezing on their last frame.",
+ "tags": [
+ "improvement"
+ ]
+ },
{
"date": "2026-06-18",
"title": "Play is movable on phones again — and avatars load instead of a placeholder",
diff --git a/public/changelog.json b/public/changelog.json
index de9815d53..c3c137c0a 100644
--- a/public/changelog.json
+++ b/public/changelog.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-06-18T02:14:39.580Z",
+ "generated_at": "2026-06-18T02:23:59.485Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json",
"site": {
"name": "three.ws",
@@ -106,6 +106,26 @@
"fix"
]
},
+ {
+ "date": "2026-06-18",
+ "type": "update",
+ "title": "The homepage avatar now prays, then walks",
+ "summary": "Tap “🙏 Pray” on the homepage hero and the avatar finishes the prayer and rises straight into a walk — one smooth motion instead of snapping back to a standing idle at the end of the clip. After the walk plays out, the avatar eases back into its gentle idle-and-stroll rhythm. The other one-tap emotes (wave, dance, jump, and the rest) also return to that ambient motion now instead of freezing on their last frame.",
+ "link": null,
+ "tags": [
+ "improvement"
+ ]
+ },
+ {
+ "date": "2026-06-18",
+ "type": "update",
+ "title": "Token swaps now confirm success or failure clearly",
+ "summary": "When you buy $THREE (or swap any pair) from the swap window, it now tells you exactly how it went. After you approve in your wallet, a banner shows it submitting and confirming on-chain, then resolves to a clear result: a green “Swap confirmed” with the amount you received and a Solscan link, a red on-chain failure with the reason (and a hint to widen slippage when that's the cause), or a “still confirming” notice with a link if the network is slow. Previously a swap could land successfully but the window sat on “Confirming…” indefinitely with no confirmation — because it was waiting on a live socket the swap proxy doesn't carry. It now polls the chain directly and gives you a definite answer in seconds.",
+ "link": "/three-token",
+ "tags": [
+ "fix"
+ ]
+ },
{
"date": "2026-06-18",
"type": "update",
diff --git a/public/changelog.xml b/public/changelog.xml
index 20de5de91..75512840d 100644
--- a/public/changelog.xml
+++ b/public/changelog.xml
@@ -86,6 +86,22 @@
<category>fix</category>
<description>Every coin world has a disco pad beside the totem that pulses to a shared beat and crossfades dancers in lockstep. A wiring gap meant the world tried to listen for a beat the connection didn't know about, which threw an error the moment you entered and left the pad dark. The beat is now delivered properly: step onto the pad, hit Dance, and you and everyone else standing on it move to the same animation on the same beat, with the floor and lights pulsing in time.</description>
</item>
+ <item>
+ <title>The homepage avatar now prays, then walks</title>
+ <link>https://three.ws/changelog</link>
+ <guid isPermaLink="false">2026-06-18:The homepage avatar now prays, then walks</guid>
+ <pubDate>Thu, 18 Jun 2026 12:00:00 GMT</pubDate>
+ <category>improvement</category>
+ <description>Tap “🙏 Pray” on the homepage hero and the avatar finishes the prayer and rises straight into a walk — one smooth motion instead of snapping back to a standing idle at the end of the clip. After the walk plays out, the avatar eases back into its gentle idle-and-stroll rhythm. The other one-tap emotes (wave, dance, jump, and the rest) also return to that ambient motion now instead of freezing on their last frame.</description>
+ </item>
+ <item>
+ <title>Token swaps now confirm success or failure clearly</title>
+ <link>https://three.ws/three-token</link>
+ <guid isPermaLink="false">2026-06-18:Token swaps now confirm success or failure clearly</guid>
+ <pubDate>Thu, 18 Jun 2026 12:00:00 GMT</pubDate>
+ <category>fix</category>
+ <description>When you buy $THREE (or swap any pair) from the swap window, it now tells you exactly how it went. After you approve in your wallet, a banner shows it submitting and confirming on-chain, then resolves to a clear result: a green “Swap confirmed” with the amount you received and a Solscan link, a red on-chain failure with the reason (and a hint to widen slippage when that's the cause), or a “still confirming” notice with a link if the network is slow. Previously a swap could land successfully but the window sat on “Confirming…” indefinitely with no confirmation — because it was waiting on a live socket the swap proxy doesn't carry. It now polls the chain directly and gives you a definite answer in seconds.</description>
+ </item>
<item>
<title>Your $THREE holder tier now shows across the site</title>
<link>https://three.ws/forge</link>
diff --git a/public/features.json b/public/features.json
index ab889704d..b698294ca 100644
--- a/public/features.json
+++ b/public/features.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-06-18T02:14:39.567Z",
+ "generated_at": "2026-06-18T02:23:59.441Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json",
"site": {
"name": "three.ws",
diff --git a/scripts/play-onboard-block-probe.mjs b/scripts/play-onboard-block-probe.mjs
index 9d0216fb1..ce4b82c3c 100644
--- a/scripts/play-onboard-block-probe.mjs
+++ b/scripts/play-onboard-block-probe.mjs
@@ -2,40 +2,48 @@ import { chromium } from 'playwright';
const URL = process.env.PROBE_URL || 'http://localhost:3000/play';
const browser = await chromium.launch();
-// First-time touch user — fresh storage, so onboarding shows.
const ctx = await browser.newContext({ viewport: { width: 390, height: 780 }, hasTouch: true, isMobile: true });
const page = await ctx.newPage();
await page.goto(URL, { waitUntil: 'domcontentloaded' });
await page.waitForSelector('.cc-card', { timeout: 15000 });
await page.tap('.cc-card');
await page.waitForFunction(() => window.__CC__?.phase === 'world', { timeout: 20000 }).catch(() => {});
-await page.waitForTimeout(1300); // let onboarding (650ms delay) appear
+// Wait for the onboarding overlay to actually appear (650ms delay after build).
+const onboardUp = await page.waitForFunction(() => document.getElementById('po-overlay')?.classList.contains('po-show'), { timeout: 6000 }).then(() => true).catch(() => false);
const pre = await page.evaluate(() => {
const z = document.getElementById('cc-joystick');
const r = z.getBoundingClientRect();
const cx = r.left + r.width / 2, cy = r.top + r.height / 2;
const top = document.elementFromPoint(cx, cy);
- return {
- onboardingUp: !!document.getElementById('po-overlay'),
- topAtJoystick: top ? (top.id ? '#' + top.id : top.tagName + '.' + String(top.className).split(' ')[0]) : null,
- cx, cy,
- };
+ return { onboardUp: !!document.getElementById('po-overlay'), topAtJoystick: top ? (top.id ? '#' + top.id : top.tagName + '.' + String(top.className).split(' ')[0]) : null, cx, cy };
});
+// Drag the joystick up WHILE the onboarding card is still showing.
const before = await page.evaluate(() => ({ ...window.__CC__.localPos }));
await page.mouse.move(pre.cx, pre.cy);
await page.mouse.down();
-await page.mouse.move(pre.cx, pre.cy - 55, { steps: 5 });
-await page.waitForTimeout(450);
+await page.mouse.move(pre.cx, pre.cy - 55, { steps: 6 });
+await page.waitForTimeout(500);
const joyVec = await page.evaluate(() => window.__CC__._joy);
const during = await page.evaluate(() => ({ ...window.__CC__.localPos }));
await page.mouse.up();
+const movedDuringOnboarding = Math.abs(before.x - during.x) > 0.02 || Math.abs(before.z - during.z) > 0.02;
-const moved = Math.abs(before.x - during.x) > 0.02 || Math.abs(before.z - during.z) > 0.02;
-console.log('onboardingUp :', pre.onboardingUp);
-console.log('topAtJoystick :', pre.topAtJoystick);
-console.log('joyVec :', JSON.stringify(joyVec));
-console.log('MOVED (joystick) :', moved);
+// The card must still be interactive: tap "Enter the world"/close to dismiss.
+const cardWorks = await page.evaluate(() => {
+ const btn = document.querySelector('#po-overlay .po-close') || document.querySelector('#po-overlay .po-btn-primary');
+ if (!btn) return 'no-button';
+ btn.click();
+ return 'clicked';
+});
+await page.waitForTimeout(400);
+const dismissed = await page.evaluate(() => !document.getElementById('po-overlay'));
+
+console.log('onboarding shown :', onboardUp);
+console.log('topAtJoystick :', pre.topAtJoystick, '(want #cc-joystick — backdrop no longer eats input)');
+console.log('joyVec during onboard :', JSON.stringify(joyVec));
+console.log('MOVED during onboarding:', movedDuringOnboarding);
+console.log('card button :', cardWorks, '=> dismissed:', dismissed);
await browser.close();
diff --git a/src/dashboard-next/pages/holders.js b/src/dashboard-next/pages/holders.js
index d742f6664..c157fcda2 100644
--- a/src/dashboard-next/pages/holders.js
+++ b/src/dashboard-next/pages/holders.js
@@ -55,7 +55,7 @@ function tierFor(pctOfSupply) {
main.innerHTML = `
<div style="margin-bottom:6px">
<div style="display:flex;align-items:center;gap:12px;margin-bottom:4px">
- <div style="width:36px;height:36px;border-radius:10px;background:linear-gradient(135deg,#fff 0%,#888 100%);display:grid;place-items:center;font-weight:800;font-size:15px;color:#000;flex-shrink:0">$3</div>
+ <div style="width:36px;height:36px;border-radius:10px;background:#111116;border:1px solid #232329;display:grid;place-items:center;flex-shrink:0;overflow:hidden"><img src="/favicon.svg" alt="three.ws" width="26" height="26" style="display:block" /></div>
<div>
<h1 class="dn-h1" style="margin:0">$THREE Holders</h1>
<p class="dn-h1-sub" style="margin:0">The on-chain holder leaderboard for the protocol token</p>
@@ -239,7 +239,7 @@ function badgeSvg(pos, token) {
<text x="36" y="276" fill="#ffffff" font-size="14" opacity="0.55">${esc(wallet)}</text>
<text x="430" y="276" fill="#ffffff" font-size="14" opacity="0.55">three.ws/holders</text>
<circle cx="540" cy="64" r="26" fill="none" stroke="${tier.accent}" stroke-opacity="0.6"/>
- <text x="540" y="71" fill="#ffffff" font-size="22" font-weight="800" text-anchor="middle">$3</text>
+ <text x="540" y="71" fill="#ffffff" font-size="22" font-weight="800" text-anchor="middle">3</text>
</g>
</svg>`;
}
diff --git a/src/dashboard-next/pages/three-token.js b/src/dashboard-next/pages/three-token.js
index b6acb636a..3a665ed68 100644
--- a/src/dashboard-next/pages/three-token.js
+++ b/src/dashboard-next/pages/three-token.js
@@ -86,7 +86,7 @@ function toast(msg) {
main.innerHTML = `
<div style="margin-bottom:6px">
<div style="display:flex;align-items:center;gap:12px;margin-bottom:4px">
- <div style="width:36px;height:36px;border-radius:10px;background:linear-gradient(135deg,#fff 0%,#888 100%);display:grid;place-items:center;font-weight:800;font-size:15px;color:#000;flex-shrink:0">$3</div>
+ <div style="width:36px;height:36px;border-radius:10px;background:#111116;border:1px solid #232329;display:grid;place-items:center;flex-shrink:0;overflow:hidden"><img src="/favicon.svg" alt="three.ws" width="26" height="26" style="display:block" /></div>
<div>
<h1 class="dn-h1" style="margin:0">$THREE</h1>
<p class="dn-h1-sub" style="margin:0">The protocol token powering the three.ws agent economy</p>
diff --git a/src/game/play-onboard.js b/src/game/play-onboard.js
index a83261e7c..5a75ac608 100644
--- a/src/game/play-onboard.js
+++ b/src/game/play-onboard.js
@@ -138,13 +138,18 @@ export class PlayOnboard {
if (this._overlay) return;
this._step = 0;
+ // Non-modal coach card, not a blocking modal. The dimmed backdrop is purely
+ // visual (pointer-events:none in CSS) so the movement joystick and look-drag
+ // stay live behind it — a first-time touch player can start walking the
+ // instant the world loads instead of facing a dead joystick under the intro.
+ // `po-onboarding` on <body> lifts the joystick crisp above the backdrop.
const overlay = mk('div', {
id: 'po-overlay',
role: 'dialog',
- 'aria-modal': 'true',
'aria-label': 'Welcome to this world',
});
document.body.appendChild(overlay);
+ document.body.classList.add('po-onboarding');
this._overlay = overlay;
this._renderSlide();
@@ -241,6 +246,7 @@ export class PlayOnboard {
const overlay = this._overlay;
if (!overlay) return;
overlay.classList.remove('po-show');
+ document.body.classList.remove('po-onboarding');
setTimeout(() => overlay.remove(), 250);
this._overlay = null;
if (this._keyFn) { document.removeEventListener('keydown', this._keyFn); this._keyFn = null; }
@@ -339,17 +345,28 @@ export class PlayOnboard {
s.textContent = `
/* ── PlayOnboard ─────────────────────────────────────────────────────────── */
-/* First-join overlay */
+/* First-join overlay — a non-blocking coach card. The dimmed/blurred backdrop is
+ visual only: pointer-events:none lets the movement joystick, look-drag, and
+ world taps stay live behind it, so a first-time touch player can move the
+ moment the world loads instead of hitting a dead joystick under the intro.
+ Only the card itself (.po-card) re-enables pointer input. */
#po-overlay {
position: fixed; inset: 0; z-index: 45;
display: flex; align-items: center; justify-content: center; padding: 20px;
background: rgba(4,4,5,0.74); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
opacity: 0; transition: opacity 0.22s ease;
+ pointer-events: none;
}
#po-overlay.po-show { opacity: 1; }
+/* Keep the joystick above the backdrop while the intro is up so it reads crisp
+ (not blurred) and is obviously usable — it sits bottom-left, clear of the
+ centered card. Scoped to onboarding so default stacking is untouched. */
+body.po-onboarding #cc-joystick { z-index: 60; }
+
.po-card {
position: relative;
+ pointer-events: auto;
width: min(440px, calc(100vw - 32px));
background: var(--cc-panel-solid, #0c0c0e);
border: 1px solid var(--cc-edge, rgba(255,255,255,0.12));
@@ -537,6 +554,7 @@ export class PlayOnboard {
dispose() {
this._disposed = true;
clearTimeout(this._showTimer);
+ document.body.classList.remove('po-onboarding');
if (this._keyFn) { document.removeEventListener('keydown', this._keyFn); this._keyFn = null; }
if (this._overlay) { this._overlay.remove(); this._overlay = null; }
if (this._helpPanel) { this._helpPanel.remove(); this._helpPanel = null; }
diff --git a/src/swap-jupiter.js b/src/swap-jupiter.js
index 623bf6962..38a745f1f 100644
--- a/src/swap-jupiter.js
+++ b/src/swap-jupiter.js
@@ -52,6 +52,7 @@ let _styleInjected = false;
let _ctx = null; // Current open call's context: { wallet, getProvider, inputToken, outputToken, ... }
let _quoteSeq = 0;
let _quote = null; // Last successful quote response from Jupiter.
+let _phase = 'idle'; // 'idle' while quoting/swapping, 'done' once a swap has settled (button becomes Close).
const STYLE = `
.sj-overlay {
@@ -165,8 +166,26 @@ const STYLE = `
.sj-slippage { width: 90px; }
.sj-status { margin-top: 12px; font-size: 12px; min-height: 16px; }
-.sj-status.sj-err { color: #ef4444; }
-.sj-status.sj-ok { color: #10b981; }
+.sj-status.sj-ok,
+.sj-status.sj-err,
+.sj-status.sj-pending {
+ margin-top: 14px;
+ padding: 10px 12px;
+ border-radius: 8px;
+ line-height: 1.45;
+}
+.sj-status.sj-err { color: #ef4444; background: rgba(239,68,68,0.07); border: 1px solid rgba(239,68,68,0.22); }
+.sj-status.sj-ok { color: #10b981; background: rgba(16,185,129,0.08); border: 1px solid rgba(16,185,129,0.25); }
+.sj-status.sj-pending { color: #f59e0b; background: rgba(245,158,11,0.07); border: 1px solid rgba(245,158,11,0.22); }
+.sj-status strong { font-weight: 600; }
+.sj-status .sj-status-title { display: flex; align-items: center; gap: 6px; font-weight: 600; }
+.sj-status .sj-status-sub { display: block; margin-top: 4px; opacity: 0.92; }
+.sj-status .sj-spin {
+ display: inline-block; width: 11px; height: 11px;
+ border: 2px solid currentColor; border-right-color: transparent;
+ border-radius: 50%; animation: sj-spin 0.7s linear infinite;
+}
+@keyframes sj-spin { to { transform: rotate(360deg); } }
.sj-status a { color: inherit; text-decoration: underline; }
.sj-btn {
@@ -393,6 +412,7 @@ function debouncedQuote() {
}
function onAmountInput() {
+ _phase = 'idle'; // Editing the amount starts a new swap; drop any settled state.
const v = $('sj-from-amount').value;
if (!v || Number(v) <= 0) {
$('sj-to-amount').value = '';
@@ -406,6 +426,7 @@ function onAmountInput() {
async function fetchQuote() {
if (!_ctx) return;
+ _phase = 'idle'; // A new quote means a new swap; the button is no longer "Close".
const amountStr = $('sj-from-amount').value;
const baseUnits = toBaseUnits(amountStr, _ctx.inputToken.decimals);
if (!baseUnits || baseUnits === '0') return;
@@ -691,7 +712,69 @@ function findToken(mint) {
// ── Swap execution ─────────────────────────────────────────────────────────
+const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
+
+// Build a Solscan tx link node, reused across status states.
+function solscanLink(href) {
+ return el('a', { href, target: '_blank', rel: 'noopener', text: 'View on Solscan ↗' });
+}
+
+// Render a two-line status banner: a bold title (optionally with a leading
+// node like a checkmark or spinner) and a sub-line (e.g. the explorer link).
+function statusBanner(title, sub, lead) {
+ const titleRow = el('span', { class: 'sj-status-title' });
+ if (lead) titleRow.append(lead);
+ titleRow.append(typeof title === 'string' ? document.createTextNode(title) : title);
+ const node = el('span', {}, titleRow);
+ if (sub) node.append(el('span', { class: 'sj-status-sub' }, sub));
+ return node;
+}
+
+// Turn an on-chain error object into a human-readable line. Jupiter slippage
+// failures surface as a Custom instruction error; show the raw shape so the
+// user (and support) can see exactly what the chain rejected.
+function describeChainError(err) {
+ if (!err) return 'unknown error';
+ if (typeof err === 'string') return err;
+ if (err.InstructionError) {
+ const detail = err.InstructionError[1];
+ if (detail && typeof detail === 'object' && 'Custom' in detail) {
+ return `instruction error (custom code ${detail.Custom}) — often slippage; widen tolerance and retry`;
+ }
+ return `instruction error: ${JSON.stringify(detail)}`;
+ }
+ try { return JSON.stringify(err); } catch { return 'transaction error'; }
+}
+
+// Poll signature status over plain HTTP (getSignatureStatuses is allowlisted by
+// the /api/solana-rpc proxy). We deliberately do NOT use connection.confirm-
+// Transaction here: it relies on a WebSocket signatureSubscribe the proxy can't
+// serve, so it hangs until block height expires. Polling gives a definitive
+// confirmed / failed / timeout verdict in seconds.
+async function pollSwapConfirmation(connection, sig, { timeoutMs = 60_000, intervalMs = 1500 } = {}) {
+ const deadline = Date.now() + timeoutMs;
+ while (Date.now() < deadline) {
+ let value = null;
+ try {
+ const resp = await connection.getSignatureStatuses([sig], { searchTransactionHistory: false });
+ value = resp?.value?.[0] || null;
+ } catch (err) {
+ log.warn('[swap-jupiter] status poll error', err);
+ }
+ if (value) {
+ if (value.err) return { state: 'failed', err: value.err };
+ if (value.confirmationStatus === 'confirmed' || value.confirmationStatus === 'finalized') {
+ return { state: 'confirmed', confirmationStatus: value.confirmationStatus };
+ }
+ }
+ await sleep(intervalMs);
+ }
+ return { state: 'timeout' };
+}
+
async function executeSwap() {
+ // After a settled swap the primary button becomes a "Close" action.
+ if (_phase === 'done') { closeSwap(); return; }
if (!_ctx || !_quote) return;
const btn = $('sj-confirm');
btn.disabled = true;
@@ -739,6 +822,10 @@ async function executeSwap() {
btn.textContent = 'Submitting…';
setStatus('Submitting transaction…');
+ // Snapshot the expected output for the success line before any reset.
+ const outSym = _ctx.outputToken.symbol;
+ const outAmount = $('sj-to-amount').value;
+
const connection = new Connection(SWAP_RPC, 'confirmed');
const sig = await connection.sendRawTransaction(signed.serialize(), {
skipPreflight: false,
@@ -746,38 +833,49 @@ async function executeSwap() {
});
const explorerLink = `https://solscan.io/tx/${sig}`;
- setStatus(el('span', {},
- 'Submitted. ',
- el('a', { href: explorerLink, target: '_blank', rel: 'noopener', text: 'View on Solscan ↗' }),
- ), 'sj-ok');
- // Confirm (non-blocking for UX — show signature first).
+ // Show a live "confirming" banner with a spinner, then poll over HTTP for
+ // a definitive verdict (the proxy can't serve the WebSocket that
+ // confirmTransaction needs, so we never call it).
btn.textContent = 'Confirming…';
- try {
- const latest = await connection.getLatestBlockhash('confirmed');
- await connection.confirmTransaction(
- { signature: sig, blockhash: latest.blockhash, lastValidBlockHeight: latest.lastValidBlockHeight },
- 'confirmed',
- );
- setStatus(el('span', {},
- 'Swap confirmed. ',
- el('a', { href: explorerLink, target: '_blank', rel: 'noopener', text: 'View on Solscan ↗' }),
- ), 'sj-ok');
- btn.textContent = 'Done';
- } catch (confErr) {
- setStatus(el('span', {},
- 'Submitted, awaiting confirmation. ',
- el('a', { href: explorerLink, target: '_blank', rel: 'noopener', text: 'View on Solscan ↗' }),
- ), 'sj-ok');
- log.warn('[swap-jupiter] confirm failed', confErr);
- btn.textContent = 'Swap again';
+ setStatus(statusBanner('Submitted — confirming on-chain…', solscanLink(explorerLink),
+ el('span', { class: 'sj-spin', 'aria-hidden': 'true' })), 'sj-pending');
+
+ const result = await pollSwapConfirmation(connection, sig);
+
+ if (result.state === 'confirmed') {
+ const received = outAmount ? ` — received ~${outAmount} ${outSym}` : '';
+ setStatus(statusBanner(`Swap confirmed${received}`, solscanLink(explorerLink), '✓'), 'sj-ok');
+ btn.textContent = 'Close';
+ btn.disabled = false;
+ _phase = 'done';
+ refreshBalance();
+ } else if (result.state === 'failed') {
+ setStatus(statusBanner(
+ 'Swap failed on-chain',
+ el('span', {}, `${describeChainError(result.err)} · `, solscanLink(explorerLink)),
+ '✕',
+ ), 'sj-err');
btn.disabled = false;
+ btn.textContent = `Swap ${_ctx.inputToken.symbol} → ${_ctx.outputToken.symbol}`;
+ } else {
+ // Timed out waiting — the tx may still land. Point the user at Solscan
+ // for the final word rather than leaving them on a dead spinner.
+ setStatus(statusBanner(
+ 'Still confirming — taking longer than usual',
+ el('span', {}, 'Your swap was submitted. Check the final status: ', solscanLink(explorerLink)),
+ ), 'sj-pending');
+ btn.textContent = 'Close';
+ btn.disabled = false;
+ _phase = 'done';
+ refreshBalance();
}
-
- refreshBalance();
} catch (err) {
log.error('[swap-jupiter] swap failed', err);
- setStatus(`Swap failed: ${err.message}`, 'sj-err');
+ const friendly = /user rejected|rejected the request|declined/i.test(err.message || '')
+ ? 'You declined the transaction in your wallet.'
+ : err.message;
+ setStatus(statusBanner('Swap failed', friendly, '✕'), 'sj-err');
btn.disabled = false;
btn.textContent = `Swap ${_ctx.inputToken.symbol} → ${_ctx.outputToken.symbol}`;
}
@@ -807,6 +905,7 @@ export function openSwapModal({ wallet, getProvider, defaultInputMint, defaultOu
_ctx = { wallet, getProvider, inputToken, outputToken };
_quote = null;
+ _phase = 'idle';
setTokenUI('from', inputToken);
setTokenUI('to', outputToken);
diff --git a/src/three-token-page.js b/src/three-token-page.js
index 62b3a9a3c..c3e063a93 100644
--- a/src/three-token-page.js
+++ b/src/three-token-page.js
@@ -54,7 +54,8 @@ function injectStyles() {
a { color:inherit; }
.tk-wrap { max-width:1080px; margin:0 auto; padding:24px 18px 64px; }
.tk-head { display:flex; align-items:center; gap:14px; margin-bottom:4px; }
- .tk-logo { width:46px; height:46px; border-radius:12px; background:linear-gradient(135deg,#fff,#888); display:grid; place-items:center; font-weight:800; color:#000; font-size:18px; flex-shrink:0; }
+ .tk-logo { width:46px; height:46px; border-radius:12px; background:#111116; border:1px solid #232329; display:grid; place-items:center; flex-shrink:0; overflow:hidden; }
+ .tk-logo img { width:32px; height:32px; display:block; }
.tk-title { font-size:26px; font-weight:800; margin:0; letter-spacing:-0.02em; }
.tk-sub { margin:0; color:#9a9aa3; font-size:13px; }
.tk-ca { font-family:ui-monospace,Menlo,monospace; font-size:11.5px; color:#8a8a93; cursor:pointer; border:1px solid #232329; border-radius:8px; padding:3px 8px; background:none; }
@@ -196,7 +197,7 @@ function boot() {
wrap.className = 'tk-wrap';
wrap.innerHTML = `
<div class="tk-head">
- <div class="tk-logo">$3</div>
+ <div class="tk-logo"><img src="/favicon.svg" alt="three.ws" width="32" height="32" /></div>
<div style="flex:1;min-width:0">
<h1 class="tk-title">$THREE</h1>
<p class="tk-sub">The protocol token powering the three.ws agent economy</p>