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.

marketplace: payment modal polish, time-pass + asset flow chrome, create-review route

nirholasa2a584150439
diff --git a/pages/marketplace.html b/pages/marketplace.html
index a8b709240..68bbb718f 100644
--- a/pages/marketplace.html
+++ b/pages/marketplace.html
@@ -14,9 +14,7 @@
<link rel="stylesheet" href="/style.css" />
<link rel="stylesheet" href="/footer.css" />
<link rel="stylesheet" href="/marketplace.css" />
- <link rel="stylesheet" href="/marketplace-skills.css" />
<link rel="stylesheet" href="/marketplace-v2.css" />
- <link rel="stylesheet" href="/marketplace-improvements.css" />
<link rel="stylesheet" href="/fonts/fonts.css" />
<style>
/* Author display rules on modal overlays override the UA stylesheet's
@@ -1476,6 +1474,161 @@
border-color: #6366f1;
color: #fff;
}
+
+ /* Sub-title badge under the modal heading. Used by the time-pass flow
+ to make the temporary-access nature of the purchase impossible to
+ miss, and by the asset flow to distinguish "Buy Avatar" vs the
+ permanent "Unlock skill" copy. Hidden by default; opened flows
+ populate it via setPaymentBadge(). */
+ .payment-modal-badge {
+ margin: -6px 0 14px;
+ padding: 8px 12px;
+ background: rgba(99, 102, 241, 0.10);
+ border: 1px solid rgba(99, 102, 241, 0.32);
+ border-radius: 8px;
+ font-size: 12px;
+ color: #c7d2fe;
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ }
+ .payment-modal-badge .payment-modal-badge-icon {
+ width: 16px;
+ height: 16px;
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ flex: 0 0 auto;
+ }
+ .payment-modal-badge.warn {
+ background: rgba(253, 224, 71, 0.08);
+ border-color: rgba(253, 224, 71, 0.30);
+ color: #fde68a;
+ }
+
+ /* Persistent post-purchase success card. Replaces the modal body so
+ the user sees what they bought + a one-click path to use it,
+ instead of a 1.5s status flash before the modal closes. */
+ .payment-modal-success {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ text-align: center;
+ padding: 8px 8px 4px;
+ gap: 12px;
+ }
+ .payment-modal-success .ps-check {
+ width: 56px;
+ height: 56px;
+ border-radius: 50%;
+ background: rgba(134, 239, 172, 0.16);
+ border: 1px solid rgba(134, 239, 172, 0.40);
+ color: #86efac;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ font-size: 28px;
+ font-weight: 700;
+ line-height: 1;
+ }
+ .payment-modal-success .ps-title {
+ font-size: 18px;
+ font-weight: 700;
+ color: #fff;
+ margin: 0;
+ }
+ .payment-modal-success .ps-sub {
+ font-size: 13px;
+ color: rgba(255, 255, 255, 0.62);
+ margin: 0;
+ line-height: 1.4;
+ }
+ .payment-modal-success .ps-actions {
+ display: flex;
+ gap: 10px;
+ width: 100%;
+ margin-top: 6px;
+ }
+ .payment-modal-success .ps-actions .btn-primary,
+ .payment-modal-success .ps-actions .btn-secondary {
+ flex: 1;
+ padding: 11px 14px;
+ font-size: 14px;
+ font-weight: 600;
+ border-radius: 8px;
+ text-align: center;
+ text-decoration: none;
+ border: 1px solid transparent;
+ cursor: pointer;
+ }
+ .payment-modal-success .ps-actions .btn-primary {
+ background: #6366f1;
+ color: #fff;
+ }
+ .payment-modal-success .ps-actions .btn-primary:hover { background: #4f46e5; }
+ .payment-modal-success .ps-actions .btn-secondary {
+ background: transparent;
+ color: rgba(255, 255, 255, 0.78);
+ border-color: rgba(255, 255, 255, 0.18);
+ }
+ .payment-modal-success .ps-actions .btn-secondary:hover {
+ background: rgba(255, 255, 255, 0.06);
+ color: #fff;
+ }
+
+ /* Verify-again retry card: lets the user re-poll without re-paying
+ when the server can't confirm the on-chain transfer in the initial
+ 60s window. Signature already on chain — only the server lookup
+ needs to retry. */
+ .payment-modal-retry {
+ display: flex;
+ flex-direction: column;
+ gap: 10px;
+ padding: 14px;
+ background: rgba(253, 224, 71, 0.06);
+ border: 1px solid rgba(253, 224, 71, 0.22);
+ border-radius: 10px;
+ margin-top: 10px;
+ }
+ .payment-modal-retry p {
+ margin: 0;
+ font-size: 13px;
+ color: #fde68a;
+ line-height: 1.45;
+ }
+ .payment-modal-retry .retry-tx {
+ font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
+ font-size: 11px;
+ color: rgba(255, 255, 255, 0.55);
+ word-break: break-all;
+ }
+ .payment-modal-retry .retry-tx a { color: #93c5fd; }
+ .payment-modal-retry .retry-actions {
+ display: flex;
+ gap: 8px;
+ }
+ .payment-modal-retry .retry-actions button {
+ flex: 1;
+ padding: 9px 12px;
+ font-size: 13px;
+ font-weight: 600;
+ border-radius: 7px;
+ cursor: pointer;
+ border: 1px solid transparent;
+ }
+ .payment-modal-retry .retry-primary {
+ background: #fde047;
+ color: #1f1500;
+ }
+ .payment-modal-retry .retry-primary:disabled {
+ opacity: 0.6;
+ cursor: not-allowed;
+ }
+ .payment-modal-retry .retry-secondary {
+ background: transparent;
+ color: rgba(255, 255, 255, 0.7);
+ border-color: rgba(255, 255, 255, 0.18);
+ }
</style>
<meta property="og:type" content="website" />
<meta property="og:title" content="Agent Marketplace · three.ws" />
@@ -2199,11 +2352,13 @@
<h2 id="payment-modal-title">Unlock Skill</h2>
<button class="market-modal-close" id="payment-modal-close" aria-label="Close">×</button>
</div>
- <div class="payment-modal-body">
- <p>You are purchasing access to the following skill:</p>
+ <div class="payment-modal-body" id="payment-modal-body">
+ <div class="payment-modal-badge" id="payment-modal-badge" hidden></div>
+
+ <p id="payment-modal-lede">You are purchasing access to the following skill:</p>
<div class="payment-item">
<strong id="payment-skill-name"></strong>
- <span>from agent</span>
+ <span id="payment-item-from">from agent</span>
<em id="payment-agent-name"></em>
</div>
@@ -2216,13 +2371,14 @@
<!-- Wallet connection status and button will be rendered here by JS -->
<button class="btn-primary" id="payment-connect-wallet-btn">Connect Wallet</button>
</div>
-
+
<button class="btn-primary payment-confirm-btn" id="payment-confirm-btn" disabled>Confirm Purchase</button>
<div class="payment-qr" id="payment-qr" aria-live="polite"></div>
<div class="payment-status" id="payment-status" role="status" aria-live="polite"></div>
</div>
+ <div class="payment-modal-success" id="payment-modal-success" hidden role="status" aria-live="polite"></div>
</div>
</div>
diff --git a/public/marketplace-skills.css b/public/marketplace-skills.css
deleted file mode 100644
index 85a215055..000000000
--- a/public/marketplace-skills.css
+++ /dev/null
@@ -1,43 +0,0 @@
-.skill-row {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 8px 0;
- border-bottom: 1px solid rgba(255, 255, 255, 0.05);
-}
-
-.skill-row:last-child {
- border-bottom: none;
-}
-
-.skill-name {
- font-size: 14px;
- color: rgba(255, 255, 255, 0.9);
-}
-
-.skill-btn {
- background-color: #374151;
- color: #d1d5db;
- border: none;
- border-radius: 6px;
- padding: 4px 12px;
- font-size: 12px;
- font-weight: 500;
- cursor: pointer;
- transition: background-color 0.2s;
-}
-
-.skill-btn:disabled {
- background-color: #1f2937;
- color: #6b7280;
- cursor: not-allowed;
-}
-
-.skill-btn.purchase {
- background-color: #3b82f6;
- color: white;
-}
-
-.skill-btn.purchase:hover {
- background-color: #2563eb;
-}
diff --git a/public/marketplace.css b/public/marketplace.css
index 1380dff14..0fe297033 100644
--- a/public/marketplace.css
+++ b/public/marketplace.css
@@ -891,6 +891,15 @@ body.market-page {
cursor: not-allowed;
}
+.skill-btn.purchase {
+ background-color: #3b82f6;
+ color: white;
+}
+
+.skill-btn.purchase:hover {
+ background-color: #2563eb;
+}
+
/* ── Skills / Library panels ─────────────────────────────────────────── */
.market-skills,
diff --git a/scripts/snap-marketplace.mjs b/scripts/snap-marketplace.mjs
new file mode 100644
index 000000000..f49d3a7c8
--- /dev/null
+++ b/scripts/snap-marketplace.mjs
@@ -0,0 +1,83 @@
+import puppeteer from 'puppeteer';
+const browser = await puppeteer.launch({
+ headless: 'new',
+ executablePath: '/home/codespace/.cache/puppeteer/chrome/linux-148.0.7778.97/chrome-linux64/chrome',
+ args: ['--no-sandbox', '--disable-setuid-sandbox'],
+});
+const page = await browser.newPage();
+await page.setViewport({ width: 1280, height: 800 });
+const errors = [];
+const consoleMsgs = [];
+page.on('console', (m) => consoleMsgs.push(`[${m.type()}] ${m.text()}`));
+page.on('pageerror', (e) => errors.push(`pageerror: ${e.message}`));
+page.on('requestfailed', (r) => errors.push(`reqfailed: ${r.url()} - ${r.failure()?.errorText}`));
+
+await page.goto('http://localhost:3001/marketplace', { waitUntil: 'networkidle2', timeout: 30000 });
+await new Promise((r) => setTimeout(r, 600));
+
+await page.screenshot({ path: '/tmp/snap-marketplace-grid.png', fullPage: false });
+
+// Simulate opening a time-pass purchase by directly invoking helpers from window scope.
+// Helpers aren't exported, so we exercise via DOM only: open the payment modal manually
+// to confirm the new chrome renders.
+await page.evaluate(() => {
+ document.getElementById('payment-modal-title').textContent = 'Get 2h access';
+ const lede = document.getElementById('payment-modal-lede'); if (lede) lede.textContent = 'You are renting temporary access to this skill:';
+ const fromLbl = document.getElementById('payment-item-from'); if (fromLbl) fromLbl.textContent = 'on agent';
+ const badge = document.getElementById('payment-modal-badge');
+ badge.hidden = false;
+ badge.className = 'payment-modal-badge warn';
+ badge.innerHTML = '<span class="payment-modal-badge-icon" aria-hidden="true">⏱</span><span>Access expires 2 hours after purchase. Not a permanent unlock.</span>';
+ document.getElementById('payment-skill-name').textContent = 'web-search';
+ document.getElementById('payment-agent-name').textContent = 'MyResearchAgent';
+ document.getElementById('payment-price-display').textContent = '0.50 USDC';
+ document.getElementById('payment-confirm-btn').textContent = 'Pay & unlock 2h access';
+ document.getElementById('payment-modal-overlay').hidden = false;
+});
+await new Promise((r) => setTimeout(r, 400));
+await page.screenshot({ path: '/tmp/snap-marketplace-timepass-modal.png', fullPage: false });
+
+// Now show success card
+await page.evaluate(() => {
+ const body = document.getElementById('payment-modal-body');
+ const success = document.getElementById('payment-modal-success');
+ body.hidden = true;
+ success.hidden = false;
+ success.innerHTML = `
+ <div class="ps-check" aria-hidden="true">✓</div>
+ <h3 class="ps-title">2h access unlocked</h3>
+ <p class="ps-sub">web-search is now usable. Access ends 2 hours from now.</p>
+ <div class="ps-actions">
+ <button type="button" class="btn-secondary" data-success-close>Done</button>
+ </div>`;
+});
+await new Promise((r) => setTimeout(r, 300));
+await page.screenshot({ path: '/tmp/snap-marketplace-success.png', fullPage: false });
+
+// Now show verify-again
+await page.evaluate(() => {
+ const body = document.getElementById('payment-modal-body');
+ const success = document.getElementById('payment-modal-success');
+ body.hidden = false;
+ success.hidden = true;
+ document.getElementById('payment-confirm-btn').hidden = true;
+ const status = document.getElementById('payment-status');
+ status.className = 'payment-status';
+ status.innerHTML = `
+ <div class="payment-modal-retry">
+ <p>Payment is on-chain but the server hasn't seen it yet. Re-verify below.</p>
+ <div class="retry-tx">Tx: <a href="https://solscan.io/tx/abcdef" target="_blank" rel="noopener">abcdef012345…</a></div>
+ <div class="retry-actions">
+ <button type="button" class="retry-primary" data-retry-verify>Verify again</button>
+ <button type="button" class="retry-secondary" data-retry-close>Close</button>
+ </div>
+ </div>`;
+});
+await new Promise((r) => setTimeout(r, 300));
+await page.screenshot({ path: '/tmp/snap-marketplace-retry.png', fullPage: false });
+
+console.log('--- console msgs ---');
+for (const m of consoleMsgs.slice(-20)) console.log(m);
+console.log('--- errors ---');
+for (const e of errors) console.log(e);
+await browser.close();
diff --git a/src/marketplace.js b/src/marketplace.js
index 1b0521d30..1037cb0f0 100644
--- a/src/marketplace.js
+++ b/src/marketplace.js
@@ -3824,6 +3824,100 @@ function setStatus(text, kind) {
el.className = 'payment-status' + (kind ? ' ' + kind : '');
}
+// ── Payment modal chrome helpers ──────────────────────────────────────────
+//
+// The same modal is reused by skill / time-pass / asset flows. These helpers
+// keep title + sub-badge + success card in sync so each flow reads naturally
+// to the user (e.g. "Get 2h access" with an expiry badge, not "Unlock Skill"
+// with no hint that the access is temporary).
+
+function setPaymentTitle(text) {
+ const el = $('payment-modal-title');
+ if (el) el.textContent = text;
+}
+
+function setPaymentLede(text) {
+ const el = $('payment-modal-lede');
+ if (el) el.textContent = text;
+}
+
+function setPaymentFromLabel(text) {
+ const el = $('payment-item-from');
+ if (el) el.textContent = text;
+}
+
+function setPaymentBadge(html, kind) {
+ const el = $('payment-modal-badge');
+ if (!el) return;
+ if (!html) {
+ el.hidden = true;
+ el.innerHTML = '';
+ el.className = 'payment-modal-badge';
+ return;
+ }
+ el.hidden = false;
+ el.className = 'payment-modal-badge' + (kind ? ' ' + kind : '');
+ el.innerHTML = html;
+}
+
+// Swap the modal into "success" mode: persistent confirmation card with a
+// one-click path to use what was just bought. No auto-close — the user
+// decides when to dismiss, and we surface a clear next step (View / Done).
+function renderPaymentSuccess({ title, message, primaryHref, primaryLabel, secondaryLabel = 'Done' }) {
+ const body = $('payment-modal-body');
+ const success = $('payment-modal-success');
+ if (!body || !success) return;
+ body.hidden = true;
+ const primary = primaryHref
+ ? `<a class="btn-primary" href="${escapeHtml(primaryHref)}" data-success-primary>${escapeHtml(primaryLabel || 'View')}</a>`
+ : '';
+ success.innerHTML = `
+ <div class="ps-check" aria-hidden="true">✓</div>
+ <h3 class="ps-title">${escapeHtml(title)}</h3>
+ ${message ? `<p class="ps-sub">${escapeHtml(message)}</p>` : ''}
+ <div class="ps-actions">
+ ${primary}
+ <button type="button" class="btn-secondary" data-success-close>${escapeHtml(secondaryLabel)}</button>
+ </div>`;
+ success.hidden = false;
+ success.querySelector('[data-success-close]')?.addEventListener('click', closePaymentModal);
+}
+
+// Swap the body's status row into a "verify again" card when server-side
+// confirmation times out. The on-chain transfer already landed — only the
+// indexer/poll didn't catch it in 60s. Users must NOT re-pay; they need a
+// way to re-poll. Surface the txid so they can also check Solscan directly.
+function renderPaymentVerifyAgain({ txid, message, retryFn }) {
+ const status = $('payment-status');
+ const confirmBtn = $('payment-confirm-btn');
+ if (confirmBtn) confirmBtn.hidden = true;
+ if (!status) return;
+ const explorer = txid ? `https://solscan.io/tx/${encodeURIComponent(txid)}` : '';
+ status.className = 'payment-status';
+ status.innerHTML = `
+ <div class="payment-modal-retry">
+ <p>${escapeHtml(message || "We couldn't confirm with the server in time. Your payment is safe — re-verify below.")}</p>
+ ${explorer ? `<div class="retry-tx">Tx: <a href="${escapeHtml(explorer)}" target="_blank" rel="noopener">${escapeHtml(txid.slice(0, 12))}…</a></div>` : ''}
+ <div class="retry-actions">
+ <button type="button" class="retry-primary" data-retry-verify>Verify again</button>
+ <button type="button" class="retry-secondary" data-retry-close>Close</button>
+ </div>
+ </div>`;
+ const retryBtn = status.querySelector('[data-retry-verify]');
+ retryBtn?.addEventListener('click', async () => {
+ retryBtn.disabled = true;
+ retryBtn.textContent = 'Verifying…';
+ try {
+ await retryFn();
+ } catch (err) {
+ retryBtn.disabled = false;
+ retryBtn.textContent = 'Verify again';
+ setStatus(err.message || 'Verification failed', 'err');
+ }
+ });
+ status.querySelector('[data-retry-close]')?.addEventListener('click', closePaymentModal);
+}
+
function closePaymentModal() {
$('payment-modal-overlay').hidden = true;
const qr = $('payment-qr'); if (qr) qr.innerHTML = '';
@@ -3831,7 +3925,17 @@ function closePaymentModal() {
if (confirmBtn) {
delete confirmBtn.dataset.durationHours;
delete confirmBtn.dataset.mode;
+ confirmBtn.hidden = false;
+ confirmBtn.disabled = true;
}
+ // Reset success/body visibility so the next open() shows the form, not
+ // the last purchase's confirmation card.
+ const body = $('payment-modal-body');
+ const success = $('payment-modal-success');
+ if (body) body.hidden = false;
+ if (success) { success.hidden = true; success.innerHTML = ''; }
+ setPaymentBadge('');
+ setStatus('');
pendingAssetPurchase = null;
}
@@ -3858,19 +3962,25 @@ async function openTimePassFlow(agentId, skill, durationHours, btn) {
// Open the normal purchase modal but with duration set, so the purchase
// will create a time-pass row. We pass duration_hours in the body.
+ setPaymentTitle(`Get ${durationHours}h access`);
+ setPaymentLede('You are renting temporary access to this skill:');
+ setPaymentFromLabel('on agent');
+ setPaymentBadge(`<span class="payment-modal-badge-icon" aria-hidden="true">⏱</span><span>Access expires ${durationHours} hour${durationHours === 1 ? '' : 's'} after purchase. Not a permanent unlock.</span>`, 'warn');
$('payment-skill-name').textContent = skill;
$('payment-agent-name').textContent = detailState.agent.name;
const tpAmount = price.time_pass_amount || price.amount;
const decimals = Number(price.mint_decimals ?? 6);
const human = (Number(tpAmount) / Math.pow(10, decimals)).toFixed(decimals === 6 ? 2 : 4);
- $('payment-price-display').textContent = `${human} ${shortMintLabel(price.currency_mint)} · ${durationHours}h access`;
+ $('payment-price-display').textContent = `${human} ${shortMintLabel(price.currency_mint)}`;
const qr = $('payment-qr'); if (qr) qr.innerHTML = '';
setStatus('');
$('payment-modal-overlay').hidden = false;
updateWalletUI();
// Store duration in a data attribute so handlePurchase can pick it up.
- $('payment-confirm-btn').dataset.durationHours = String(durationHours);
+ const confirmBtn = $('payment-confirm-btn');
+ confirmBtn.dataset.durationHours = String(durationHours);
+ confirmBtn.textContent = `Pay & unlock ${durationHours}h access`;
if (btn) {
btn.disabled = false;
@@ -3923,9 +4033,15 @@ async function openPurchaseFlow(agentId, skill) {
const decimals = Number(price.mint_decimals ?? 6);
const human = (Number(price.amount) / Math.pow(10, decimals)).toFixed(decimals === 6 ? 2 : 4);
+ setPaymentTitle('Unlock skill');
+ setPaymentLede('You are purchasing permanent access to this skill:');
+ setPaymentFromLabel('on agent');
+ setPaymentBadge('');
$('payment-skill-name').textContent = skill;
$('payment-agent-name').textContent = detailState.agent.name;
$('payment-price-display').textContent = `${human} ${shortMintLabel(price.currency_mint)}`;
+ const confirmBtn = $('payment-confirm-btn');
+ if (confirmBtn) confirmBtn.textContent = 'Confirm Purchase';
const qr = $('payment-qr'); if (qr) qr.innerHTML = '';
setStatus('');
$('payment-modal-overlay').hidden = false;
@@ -3984,10 +4100,20 @@ function openAssetPurchaseFlow(asset) {
pendingAssetPurchase = asset;
confirmBtn.dataset.mode = 'asset';
confirmBtn.disabled = false;
+ confirmBtn.hidden = false;
delete confirmBtn.dataset.durationHours;
+ const typeLabel = asset.item_type ? asset.item_type.charAt(0).toUpperCase() + asset.item_type.slice(1) : 'Asset';
+ setPaymentTitle(`Buy ${typeLabel}`);
+ setPaymentLede(`You are buying this ${asset.item_type || 'asset'}:`);
+ setPaymentFromLabel(typeLabel);
+ setPaymentBadge('');
+ confirmBtn.textContent = `Confirm purchase`;
+
skillName.textContent = asset.label || 'Asset';
- if (agentName) agentName.textContent = asset.item_type.charAt(0).toUpperCase() + asset.item_type.slice(1);
+ // For assets the secondary line is just the type ("Avatar"), so suppress
+ // the agent-name slot — there is no agent to attribute the purchase to.
+ if (agentName) agentName.textContent = '';
const decimals = Number(asset.price?.mint_decimals ?? 6);
const human = (Number(asset.price?.amount || 0) / Math.pow(10, decimals)).toFixed(decimals === 6 ? 2 : 4);
@@ -4019,6 +4145,17 @@ async function pollAssetConfirm(reference, windowMs = 60_000) {
return false;
}
+// Where to point the post-purchase "View" CTA for each asset type. Owned
+// assets land in the user's dashboard, so the user can use them immediately
+// without going back through the marketplace.
+function assetViewTarget(asset) {
+ const type = asset?.item_type;
+ if (type === 'avatar') return { href: '/dashboard/avatars', label: 'View avatar' };
+ if (type === 'agent') return { href: '/dashboard/agents', label: 'View agent' };
+ if (type === 'plugin') return { href: '/dashboard', label: 'View plugin' };
+ return { href: '/dashboard', label: 'View in dashboard' };
+}
+
async function handleAssetPurchase() {
const confirmBtn = $('payment-confirm-btn');
const asset = pendingAssetPurchase;
@@ -4032,8 +4169,13 @@ async function handleAssetPurchase() {
try {
purchase = await createPendingAssetPurchase(asset.item_type, asset.item_id);
if (purchase.already_owned) {
- setStatus('Already purchased.', 'ok');
- setTimeout(closePaymentModal, 1200);
+ const target = assetViewTarget(asset);
+ renderPaymentSuccess({
+ title: 'Already owned',
+ message: `You already purchased ${asset.label}.`,
+ primaryHref: target.href,
+ primaryLabel: target.label,
+ });
return;
}
} catch (e) {
@@ -4042,6 +4184,7 @@ async function handleAssetPurchase() {
return;
}
+ let txid;
try {
setStatus('Building transfer…');
const tx = await buildSplTransferWithReference({
@@ -4053,7 +4196,6 @@ async function handleAssetPurchase() {
});
setStatus('Approve in wallet…');
- let txid;
if (typeof connectedWallet.provider.signAndSendTransaction === 'function') {
const result = await connectedWallet.provider.signAndSendTransaction(tx);
txid = result?.signature ?? result;
@@ -4066,12 +4208,55 @@ async function handleAssetPurchase() {
setStatus('Verifying with server…');
const ok = await pollAssetConfirm(purchase.reference, 60_000);
- if (!ok) throw new Error('Server could not verify the transaction within 60 seconds.');
+ if (!ok) {
+ renderPaymentVerifyAgain({
+ txid,
+ message: "We couldn't verify the transfer with the server in 60s. The on-chain transaction is safe — re-verify below.",
+ retryFn: async () => {
+ const ok2 = await pollAssetConfirm(purchase.reference, 60_000);
+ if (!ok2) throw new Error('Still not confirmed — wait a few seconds and try again.');
+ const target = assetViewTarget(asset);
+ renderPaymentSuccess({
+ title: `${asset.label} purchased`,
+ message: `${asset.item_type === 'avatar' ? 'Your new avatar' : 'Your purchase'} is in your dashboard.`,
+ primaryHref: target.href,
+ primaryLabel: target.label,
+ });
+ },
+ });
+ return;
+ }
- setStatus(`✓ ${asset.label} purchased.`, 'ok');
- setTimeout(closePaymentModal, 1500);
+ const target = assetViewTarget(asset);
+ renderPaymentSuccess({
+ title: `${asset.label} purchased`,
+ message: `${asset.item_type === 'avatar' ? 'Your new avatar' : asset.item_type === 'agent' ? 'Your new agent' : 'Your purchase'} is in your dashboard.`,
+ primaryHref: target.href,
+ primaryLabel: target.label,
+ });
} catch (e) {
console.error('[marketplace] asset purchase failed', e);
+ // Differentiate "tx already sent, server lookup failing" from
+ // "tx never built". If we have a txid, the user already paid and
+ // must NOT be told to retry — surface the verify-again card.
+ if (txid) {
+ renderPaymentVerifyAgain({
+ txid,
+ message: e.message || 'Payment sent but verification failed — re-verify below.',
+ retryFn: async () => {
+ const ok2 = await pollAssetConfirm(purchase.reference, 60_000);
+ if (!ok2) throw new Error('Still not confirmed — wait a few seconds and try again.');
+ const target = assetViewTarget(asset);
+ renderPaymentSuccess({
+ title: `${asset.label} purchased`,
+ message: `${asset.item_type === 'avatar' ? 'Your new avatar' : 'Your purchase'} is in your dashboard.`,
+ primaryHref: target.href,
+ primaryLabel: target.label,
+ });
+ },
+ });
+ return;
+ }
setStatus(e.message || 'Purchase failed', 'err');
confirmBtn.disabled = false;
}
@@ -4095,14 +4280,31 @@ async function handlePurchase() {
const skill = $('payment-skill-name').textContent;
const durationHours = confirmBtn.dataset.durationHours ? Number(confirmBtn.dataset.durationHours) : null;
+ const onUnlocked = async () => {
+ await fetchUserPurchases();
+ loadDetail(agentId);
+ renderPaymentSuccess({
+ title: durationHours ? `${durationHours}h access unlocked` : 'Skill unlocked',
+ message: durationHours
+ ? `${skill} is now usable. Access ends ${durationHours} hour${durationHours === 1 ? '' : 's'} from now.`
+ : `${skill} is now part of your library on ${detailState.agent.name}.`,
+ primaryHref: null,
+ secondaryLabel: 'Done',
+ });
+ };
+
let purchase;
try {
purchase = await createPendingPurchase(agentId, skill, durationHours);
if (purchase.already_owned) {
- setStatus('Already purchased. Refreshing…', 'ok');
await fetchUserPurchases();
loadDetail(agentId);
- setTimeout(closePaymentModal, 1200);
+ renderPaymentSuccess({
+ title: 'Already unlocked',
+ message: `You already have access to ${skill}.`,
+ primaryHref: null,
+ secondaryLabel: 'Continue',
+ });
return;
}
} catch (e) {
@@ -4111,6 +4313,7 @@ async function handlePurchase() {
return;
}
+ let txid;
try {
setStatus('Building transfer…');
const tx = await buildSplTransferWithReference({
@@ -4122,7 +4325,6 @@ async function handlePurchase() {
});
setStatus('Approve in wallet…');
- let txid;
if (typeof connectedWallet.provider.signAndSendTransaction === 'function') {
const result = await connectedWallet.provider.signAndSendTransaction(tx);
txid = result?.signature ?? result;
@@ -4135,14 +4337,34 @@ async function handlePurchase() {
setStatus('Verifying with server…');
const ok = await pollConfirm(purchase.reference, 60_000);
- if (!ok) throw new Error('Server could not verify the transaction within 60 seconds.');
+ if (!ok) {
+ renderPaymentVerifyAgain({
+ txid,
+ message: "Payment is on-chain but the server hasn't seen it yet. Re-verify below.",
+ retryFn: async () => {
+ const ok2 = await pollConfirm(purchase.reference, 60_000);
+ if (!ok2) throw new Error('Still not confirmed — wait a few seconds and try again.');
+ await onUnlocked();
+ },
+ });
+ return;
+ }
- setStatus('✓ Skill unlocked.', 'ok');
- await fetchUserPurchases();
- loadDetail(agentId);
- setTimeout(closePaymentModal, 1500);
+ await onUnlocked();
} catch (e) {
console.error('[marketplace] purchase failed', e);
+ if (txid) {
+ renderPaymentVerifyAgain({
+ txid,
+ message: e.message || 'Payment sent but verification failed — re-verify below.',
+ retryFn: async () => {
+ const ok2 = await pollConfirm(purchase.reference, 60_000);
+ if (!ok2) throw new Error('Still not confirmed — wait a few seconds and try again.');
+ await onUnlocked();
+ },
+ });
+ return;
+ }
setStatus(e.message || 'Purchase failed', 'err');
confirmBtn.disabled = false;
}
@@ -4159,10 +4381,14 @@ async function startQrPurchase() {
try {
purchase = await createPendingPurchase(agentId, skill);
if (purchase.already_owned) {
- setStatus('Already purchased.', 'ok');
await fetchUserPurchases();
loadDetail(agentId);
- setTimeout(closePaymentModal, 1200);
+ renderPaymentSuccess({
+ title: 'Already unlocked',
+ message: `You already have access to ${skill}.`,
+ primaryHref: null,
+ secondaryLabel: 'Continue',
+ });
return;
}
} catch (e) { setStatus(e.message, 'err'); return; }
@@ -4187,12 +4413,33 @@ async function startQrPurchase() {
setStatus('Waiting for payment on your phone…');
const ok = await pollConfirm(purchase.reference, 300_000);
if (ok) {
- setStatus('✓ Skill unlocked.', 'ok');
await fetchUserPurchases();
loadDetail(agentId);
- setTimeout(closePaymentModal, 1500);
+ renderPaymentSuccess({
+ title: 'Skill unlocked',
+ message: `${skill} is now part of your library on ${detailState.agent.name}.`,
+ primaryHref: null,
+ secondaryLabel: 'Done',
+ });
} else {
- setStatus('No confirmation in 5 minutes; pending purchase will expire automatically.', 'err');
+ // On QR flow we have no txid (buyer paid from their phone — txid is
+ // known to the server only). Offer a verify-again that re-polls.
+ renderPaymentVerifyAgain({
+ txid: null,
+ message: "No confirmation in 5 minutes. If you paid, re-verify below; otherwise the pending purchase will expire automatically.",
+ retryFn: async () => {
+ const ok2 = await pollConfirm(purchase.reference, 60_000);
+ if (!ok2) throw new Error('Still no confirmation — give it another minute.');
+ await fetchUserPurchases();
+ loadDetail(agentId);
+ renderPaymentSuccess({
+ title: 'Skill unlocked',
+ message: `${skill} is now part of your library on ${detailState.agent.name}.`,
+ primaryHref: null,
+ secondaryLabel: 'Done',
+ });
+ },
+ });
}
}
diff --git a/vercel.json b/vercel.json
index fd138c411..73a765a8c 100644
--- a/vercel.json
+++ b/vercel.json
@@ -1618,6 +1618,14 @@
"src": "/create/selfie/",
"dest": "/create-selfie.html"
},
+ {
+ "src": "/create-review",
+ "dest": "/create-review.html"
+ },
+ {
+ "src": "/create-review/",
+ "dest": "/create-review.html"
+ },
{
"src": "/create",
"dest": "/create.html"
diff --git a/vite.config.js b/vite.config.js
index 1caa48872..7598c2a93 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -129,6 +129,7 @@ const appConfig = {
launchpad: resolve(__dirname, 'pages/launchpad.html'),
create: resolve(__dirname, 'pages/create.html'),
'create-selfie': resolve(__dirname, 'pages/create-selfie.html'),
+ 'create-review': resolve(__dirname, 'pages/create-review.html'),
'agent-home': resolve(__dirname, 'pages/agent-home.html'),
marketplace: resolve(__dirname, 'pages/marketplace.html'),
'agent-edit': resolve(__dirname, 'pages/agent-edit.html'),
@@ -234,6 +235,8 @@ const appConfig = {
'/create': resolve(root, 'pages/create.html'),
'/create/selfie': resolve(root, 'pages/create-selfie.html'),
'/create/selfie/': resolve(root, 'pages/create-selfie.html'),
+ '/create-review': resolve(root, 'pages/create-review.html'),
+ '/create-review/': resolve(root, 'pages/create-review.html'),
'/dashboard': resolve(root, 'public/dashboard/index.html'),
'/studio': resolve(root, 'public/studio/index.html'),
'/studio/': resolve(root, 'public/studio/index.html'),