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
fix(oracle): serve coin art through the image proxy so a metadata URI stops rendering as a broken icon
nirholasa444f6727f75
diff --git a/api/oracle-share.js b/api/oracle-share.jsindex 645873731..4eafcac40 100644--- a/api/oracle-share.js+++ b/api/oracle-share.js@@ -172,6 +172,23 @@ function agoServer(ts) {return `${Math.floor(s / 86400)}d ago`;}+// Token art lives on public IPFS gateways, and roughly half of pump.fun art is+// stored as a metadata JSON document rather than an image, sharing one+// `image_uri` column with the real thing. Hot-linked, both fail in the browser:+// the gateway answers without CORS headers or with `application/json`, and+// Chrome blocks it (ERR_BLOCKED_BY_ORB), leaving a broken icon on the hero.+// /api/img is the platform's answer (SSRF-hardened fetch, multi-gateway retry,+// one-hop metadata resolution, on-brand placeholder on total failure) and is+// what src/oracle.js already renders through; the server-rendered header uses+// the same lane.+function proxiedImg(url, seed = '') {+ const raw = String(url || '').trim();+ if (!raw || !/^(https?|ipfs|ar):/i.test(raw)) return raw;+ const q = new URLSearchParams({ url: raw });+ if (seed) q.set('seed', seed);+ return `/api/img?${q.toString()}`;+}+function pillarBar(kind, label, val) {const v = val == null ? null : Math.max(0, Math.min(100, Number(val)));return `<div class="pil ${kind}"><div class="lab">${label}<b>${v == null ? '—' : Math.round(v)}</b></div>@@ -194,7 +211,7 @@ function heroHtml({ mint, row, pump, origin }) {const sw = Number(row?.smart_wallet_count || 0);const imgUri = row?.image_uri || pump?.image || '';const img = imgUri- ? `<img class="coin-icon" src="${esc(imgUri)}" alt="" width="64" height="64" loading="eager" data-no-dark-filter>`+ ? `<img class="coin-icon" src="${esc(proxiedImg(imgUri, mint))}" alt="" width="64" height="64" loading="eager" data-no-dark-filter>`: `<div class="coin-icon oc-icon-letter" aria-hidden="true">${esc(((symRaw || mint)[0] || '?').toUpperCase())}</div>`;// Dial: the score for scored coins; a "reading" state for fresh launches thatdiff --git a/public/oracle-coin.js b/public/oracle-coin.jsindex 714b7789b..bc27a3a98 100644--- a/public/oracle-coin.js+++ b/public/oracle-coin.js@@ -25,6 +25,21 @@const $ = (sel, root = document) => root.querySelector(sel);const esc = (s) => String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));+ // Token art lives on public IPFS gateways, and roughly half of pump.fun art is+ // a metadata JSON document sharing one `image_uri` column with the real image.+ // Hot-linked, both fail: the gateway answers without CORS headers or with+ // `application/json` and Chrome blocks it (ERR_BLOCKED_BY_ORB), leaving a+ // broken tile. /api/img resolves the metadata hop, retries across gateways and+ // always hands back a valid image. Buildless file, so this mirrors+ // proxiedImageURL() from src/ipfs.js rather than importing it.+ const imgProxy = (url, seed = '') => {+ const raw = String(url ?? '').trim();+ if (!raw || !/^(https?|ipfs|ar):/i.test(raw)) return raw;+ const q = new URLSearchParams({ url: raw });+ if (seed) q.set('seed', seed);+ return `/api/img?${q.toString()}`;+ };+// ── formatters (ported 1:1 from src/oracle.js) ─────────────────────────────const fmtSol = (n) => (n == null ? '—' : `${Number(n) < 0.01 && Number(n) > 0 ? Number(n).toFixed(4) : Number(n).toFixed(2)}◎`);function fmtUsd(n) {@@ -832,7 +847,7 @@<div style="display:flex;flex-direction:column;gap:6px">${related.map((r) => {const imgEl = r.image_uri- ? `<img src="${esc(r.image_uri)}" alt="" style="width:28px;height:28px;border-radius:7px;object-fit:cover;flex:none;border:1px solid var(--line)" loading="lazy">`+ ? `<img src="${esc(imgProxy(r.image_uri, r.mint))}" alt="" style="width:28px;height:28px;border-radius:7px;object-fit:cover;flex:none;border:1px solid var(--line)" loading="lazy">`: `<div style="width:28px;height:28px;border-radius:7px;background:var(--line);display:grid;place-items:center;font:700 11px/1 var(--mono);color:var(--faint);flex:none">${esc((r.symbol || '?')[0])}</div>`;return `<a class="dr-related" href="/oracle/coin/${encodeURIComponent(r.mint)}" data-related-mint="${esc(r.mint)}">${imgEl}diff --git a/tests/oracle/coin-page-images.test.js b/tests/oracle/coin-page-images.test.jsnew file mode 100644index 000000000..1cc04426a--- /dev/null+++ b/tests/oracle/coin-page-images.test.js@@ -0,0 +1,75 @@+// /oracle/coin/<mint> renders token art through the same-origin image proxy.+//+// Token art lives on public IPFS gateways, and roughly half of pump.fun art is+// a metadata JSON document sharing one `image_uri` column with the real image.+// Hot-linked, both fail in the browser: the gateway answers without CORS headers+// or with `application/json`, Chrome blocks it (ERR_BLOCKED_BY_ORB), and the+// coin page shows a broken hero icon plus one per related coin. /api/img exists+// to absorb exactly that (multi-gateway retry, one-hop metadata resolution,+// on-brand placeholder), so no image on this page may address a gateway+// directly. These pin the two render sites that regressed.++import { describe, it, expect } from 'vitest';+import { readFileSync } from 'node:fs';+import { resolve, dirname } from 'node:path';+import { fileURLToPath } from 'node:url';++const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '../..');+const read = (p) => readFileSync(resolve(ROOT, p), 'utf8');++const serverPage = read('api/oracle-share.js');+const clientPage = read('public/oracle-coin.js');++// Every <img src="${…}"> interpolation in a file, as its raw expression.+function imgSrcExpressions(source) {+ return [...source.matchAll(/<img[^>]*\ssrc="\$\{([^}]+)\}"/g)].map((m) => m[1]);+}++describe('server-rendered coin hero', () => {+ it('renders at least one image', () => {+ expect(imgSrcExpressions(serverPage).length).toBeGreaterThan(0);+ });++ it('routes every image through the proxy helper', () => {+ for (const expr of imgSrcExpressions(serverPage)) {+ expect(expr).toContain('proxiedImg(');+ }+ });++ it('builds proxy URLs against /api/img', () => {+ expect(serverPage).toContain('`/api/img?${q.toString()}`');+ });++ it('leaves a same-origin or relative source untouched', () => {+ // The helper only rewrites remote schemes; a local path must pass through+ // so an on-platform asset is never bounced through the proxy.+ expect(serverPage).toMatch(/if \(!raw \|\| !\/\^\(https\?\|ipfs\|ar\):\/i\.test\(raw\)\) return raw;/);+ });+});++describe('client-hydrated coin page', () => {+ it('renders at least one image', () => {+ expect(imgSrcExpressions(clientPage).length).toBeGreaterThan(0);+ });++ it('routes every image through the proxy helper', () => {+ for (const expr of imgSrcExpressions(clientPage)) {+ expect(expr).toContain('imgProxy(');+ }+ });++ it('builds proxy URLs against /api/img', () => {+ expect(clientPage).toContain('`/api/img?${q.toString()}`');+ });+});++describe('no gateway is addressed directly', () => {+ for (const [name, source] of [+ ['api/oracle-share.js', serverPage],+ ['public/oracle-coin.js', clientPage],+ ]) {+ it(`${name} never hard-codes a public IPFS gateway host`, () => {+ expect(source).not.toMatch(/https:\/\/(ipfs\.io|dweb\.link|gateway\.pinata\.cloud|w3s\.link)\//);+ });+ }+});