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.

feat(receipts): add an Outbound tab for what your agents spent elsewhere

nirholas9e1ff2270cb9
diff --git a/pages/receipts.html b/pages/receipts.html
index 9284be191..19f150488 100644
--- a/pages/receipts.html
+++ b/pages/receipts.html
@@ -97,6 +97,19 @@
</p>
</section>
+ <!-- tab bar: what three.ws billed you vs what your agents spent elsewhere -->
+ <div class="rc-tabs" role="tablist" aria-label="Receipt direction">
+ <button type="button" class="rc-tab" id="rc-tab-inbound" role="tab" aria-selected="true" aria-controls="rc-panel-inbound">
+ <span data-i18n="receipts.tab_inbound">Inbound</span>
+ <span class="rc-tab-sub" data-i18n="receipts.tab_inbound_sub">What three.ws billed you</span>
+ </button>
+ <button type="button" class="rc-tab" id="rc-tab-outbound" role="tab" aria-selected="false" aria-controls="rc-panel-outbound">
+ <span data-i18n="receipts.tab_outbound">Outbound</span>
+ <span class="rc-tab-sub" data-i18n="receipts.tab_outbound_sub">What your agents spent elsewhere</span>
+ </button>
+ </div>
+
+ <div id="rc-panel-inbound" role="tabpanel" aria-labelledby="rc-tab-inbound">
<!-- signed-out state -->
<section class="rc-signin" id="rc-signin" aria-label="Connect a wallet">
<h2 data-i18n="receipts.signin_h">Prove your wallet, get your receipts</h2>
@@ -225,11 +238,116 @@
<a href="/docs/api-reference">API reference</a>.
</p>
</section>
+ </div>
+
+ <div id="rc-panel-outbound" role="tabpanel" aria-labelledby="rc-tab-outbound" hidden>
+ <!-- signed-out state: account session, not a wallet signature -->
+ <section class="rc-signin" id="ob-signin" aria-label="Sign in to view outbound spend">
+ <h2 data-i18n="receipts.ob_signin_h">Sign in to see what your agents spent</h2>
+ <p class="rc-signin-copy" data-i18n="receipts.ob_signin_copy">
+ Outbound receipts are account-scoped: they show what your Agent Payment
+ Sessions spent at other, external x402 merchants. Sign in to view them.
+ </p>
+ <div class="rc-connect-row">
+ <a href="/login?r=/receipts" class="rc-btn rc-btn-primary" id="ob-signin-link" style="text-decoration:none">
+ <span class="rc-btn-label" data-i18n="receipts.ob_signin_btn">Sign in →</span>
+ </a>
+ </div>
+ <p class="rc-signin-note" data-i18n-html="receipts.ob_signin_note">
+ Never run a Payment Session yet? Fund one from
+ <a href="/payments">the Payment Sessions dashboard</a> and hand its token
+ to an agent, or read the
+ <a href="/docs/tutorials/agent-spending-envelope">spending envelope guide</a>.
+ </p>
+ </section>
+
+ <!-- signed-in vault -->
+ <section id="ob-vault" aria-label="What your agents spent elsewhere" hidden>
+ <div class="rc-vault-head">
+ <span class="rc-wallet" id="ob-vault-label" data-i18n="receipts.ob_vault_label">Outbound spend, across every Payment Session</span>
+ <span class="rc-vault-tools">
+ <select class="rc-tool" id="ob-filter-network" title="Filter by network" data-i18n-attr="title:receipts.ob_filter_network_title">
+ <option value="" data-i18n="receipts.ob_filter_all">All networks</option>
+ <option value="solana">Solana</option>
+ <option value="base">Base</option>
+ </select>
+ <button type="button" class="rc-tool" id="ob-refresh" title="Re-fetch outbound receipts" data-i18n="receipts.refresh_btn" data-i18n-attr="title:receipts.refresh_title">
+ Refresh
+ </button>
+ <button type="button" class="rc-tool" id="ob-export" title="Export the visible outbound receipts as CSV" data-i18n="receipts.export_btn" data-i18n-attr="title:receipts.export_title">
+ Export CSV
+ </button>
+ </span>
+ </div>
+
+ <div class="rc-kpis" aria-label="Summary">
+ <div class="rc-kpi rc-kpi-hero">
+ <span class="rc-kpi-label" data-i18n="receipts.ob_kpi_spend">Total spend</span>
+ <span class="rc-kpi-val" id="ob-k-spend">·</span>
+ <span class="rc-kpi-sub" data-i18n="receipts.ob_kpi_spend_note">as reported by settlement</span>
+ </div>
+ <div class="rc-kpi">
+ <span class="rc-kpi-label" data-i18n="receipts.ob_kpi_payments">Payments</span>
+ <span class="rc-kpi-val" id="ob-k-total">·</span>
+ </div>
+ <div class="rc-kpi">
+ <span class="rc-kpi-label" data-i18n="receipts.ob_kpi_verified">Verified on-chain</span>
+ <span class="rc-kpi-val" id="ob-k-verified">·</span>
+ </div>
+ <div class="rc-kpi">
+ <span class="rc-kpi-label" data-i18n="receipts.ob_kpi_merchants">Merchants</span>
+ <span class="rc-kpi-val" id="ob-k-merchants">·</span>
+ </div>
+ </div>
+
+ <div class="rc-search-wrap">
+ <label class="rc-search-label" for="ob-search" data-i18n="receipts.ob_search_label">Filter loaded receipts</label>
+ <input
+ type="search"
+ class="rc-search"
+ id="ob-search"
+ placeholder="Filter by merchant host or tx hash"
+ data-i18n-attr="placeholder:receipts.ob_search_placeholder"
+ />
+ </div>
+
+ <div class="rc-list" id="ob-list" aria-live="polite"></div>
+
+ <div class="rc-more-wrap" id="ob-more-wrap" hidden>
+ <p class="rc-shown" id="ob-shown"></p>
+ <button type="button" class="rc-btn rc-btn-secondary rc-more" id="ob-more">
+ <span class="rc-btn-label" data-i18n="receipts.ob_load_more">Load more</span>
+ </button>
+ </div>
+
+ <div class="rc-empty" id="ob-empty" hidden>
+ <h3 id="ob-empty-title"></h3>
+ <p id="ob-empty-body"></p>
+ </div>
+
+ <div class="rc-load-error" id="ob-load-error" role="alert" hidden>
+ <h3 data-i18n="receipts.load_error_h">Could not load your outbound receipts</h3>
+ <p id="ob-load-error-msg"></p>
+ <button type="button" class="rc-tool" id="ob-retry" data-i18n="receipts.retry_btn">Retry</button>
+ </div>
+
+ <p class="rc-fineprint rc-hint" data-i18n-html="receipts.ob_fineprint">
+ <kbd>e</kbd> export CSV. "Verified on-chain" reads the settlement
+ transaction's own token-balance change on Solana, independent of
+ whatever the merchant's response claimed; resolved once per payment
+ and cached. Base-network payments show the reported figures only.
+ The API behind this tab is
+ <code>GET /api/x402/outbound-receipts</code>, documented in the
+ <a href="/docs/api-reference">API reference</a>.
+ </p>
+ </section>
+ </div>
</main>
<div class="rc-toast" id="rc-toast" role="status" aria-live="polite" hidden></div>
<script type="module" src="/src/receipts.js"></script>
+ <script type="module" src="/src/receipts-outbound.js"></script>
<script src="/brand.js" defer></script>
<div id="footer-container"></div>
<script src="/footer.js"></script>
diff --git a/src/receipts-lib.js b/src/receipts-lib.js
index a5bd2a589..a93cbc648 100644
--- a/src/receipts-lib.js
+++ b/src/receipts-lib.js
@@ -270,7 +270,7 @@ export function formatSpendEntries(spend, unpriced = 0) {
};
}
-function csvCell(value) {
+export function csvCell(value) {
const s = value == null ? '' : String(value);
return /[",\n\r]/.test(s) ? `"${s.replace(/"/g, '""')}"` : s;
}
@@ -306,6 +306,72 @@ export function receiptsToCsv(rows) {
return [header, ...lines].join('\n');
}
+// Mints the Outbound tab can name without a lookup, mirroring
+// api/_lib/x402/solana-settlement.js's KNOWN_MINT_SYMBOLS. A resolved
+// settlement in any other mint still renders (amount + short mint address),
+// just without a ticker.
+const SOLANA_USDC_MINT = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v';
+const THREE_MINT = 'FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump';
+const OUTBOUND_MINT_SYMBOLS = { [SOLANA_USDC_MINT]: 'USDC', [THREE_MINT]: 'THREE' };
+
+/** @param {string|null|undefined} mint */
+export function outboundMintSymbol(mint) {
+ return OUTBOUND_MINT_SYMBOLS[mint] || null;
+}
+
+/**
+ * Human amount for one outbound receipt: the chain-resolved settlement when
+ * one exists (ground truth), otherwise the amount the settlement response
+ * reported when the execution was recorded.
+ * @param {{ resolved?: { amountAtomics: string, decimals: number, mint: string }|null,
+ * reportedAmountUsd: number }} receipt
+ */
+export function formatOutboundAmount(receipt) {
+ if (receipt?.resolved) {
+ const amt = formatReceiptAmount(
+ receipt.resolved.amountAtomics,
+ receipt.resolved.decimals,
+ outboundMintSymbol(receipt.resolved.mint),
+ );
+ if (amt) return amt;
+ }
+ const value = Number(receipt?.reportedAmountUsd) || 0;
+ return { value, label: amountLabel(value, null), symbol: null, usd: true };
+}
+
+/**
+ * CSV export of the loaded outbound-receipt rows. Columns are documented in
+ * docs/x402-receipts.md alongside the inbound export.
+ * @param {Array<object>} rows
+ */
+export function outboundReceiptsToCsv(rows) {
+ const header =
+ 'id,created_at,network,endpoint_host,endpoint_url,reported_amount_usd,tx_hash,resolved_payer,resolved_payee,resolved_mint,resolved_amount_atomics,resolved_decimals,resolved_fee_lamports,resolved_slot,resolved_block_time,resolve_error';
+ const lines = (rows || []).map((r) =>
+ [
+ r.id,
+ r.createdAt,
+ r.network,
+ r.endpointHost,
+ r.endpointUrl,
+ r.reportedAmountUsd,
+ r.txHash,
+ r.resolved?.payer ?? '',
+ r.resolved?.payee ?? '',
+ r.resolved?.mint ?? '',
+ r.resolved?.amountAtomics ?? '',
+ r.resolved?.decimals ?? '',
+ r.resolved?.feeLamports ?? '',
+ r.resolved?.slot ?? '',
+ r.resolved?.blockTime ?? '',
+ r.resolveError ?? '',
+ ]
+ .map(csvCell)
+ .join(','),
+ );
+ return [header, ...lines].join('\n');
+}
+
/**
* Aggregate stats for the KPI strip.
* @param {Array<{resourceUrl: string, issuedAt: string, network: string}>} rows
diff --git a/src/receipts-outbound.js b/src/receipts-outbound.js
new file mode 100644
index 000000000..b22612af1
--- /dev/null
+++ b/src/receipts-outbound.js
@@ -0,0 +1,333 @@
+/**
+ * /receipts, Outbound tab: what the signed-in account's agents spent at OTHER,
+ * external x402 merchants while executing an Agent Payment Session, enriched
+ * with what the Solana chain itself says settled.
+ *
+ * Counterpart to receipts.js (the buyer side: what three.ws billed a wallet).
+ * This tab uses the account session cookie, not a wallet signature, since
+ * Payment Sessions are account-scoped. Also owns the tab bar that switches
+ * between the two panels.
+ */
+import { formatOutboundAmount, outboundReceiptsToCsv } from './receipts-lib.js';
+import { timeAgo } from './shared/pulse-format.js';
+
+const API_URL = '/api/x402/outbound-receipts';
+const FETCH_LIMIT = 50;
+
+const $ = (id) => document.getElementById(id);
+
+const state = {
+ signedIn: null, // null = unknown yet, true/false once checked
+ rows: [],
+ summary: null,
+ nextCursor: null,
+ network: '',
+ query: '',
+ loading: false,
+ loadingMore: false,
+};
+
+function esc(s) {
+ return String(s ?? '').replace(
+ /[&<>"']/g,
+ (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c],
+ );
+}
+
+function shortSig(s) {
+ if (!s || s.length <= 14) return s || '';
+ return `${s.slice(0, 6)}…${s.slice(-4)}`;
+}
+
+function solscanTxUrl(sig) {
+ return sig ? `https://solscan.io/tx/${sig}` : null;
+}
+
+async function api(path, opts = {}) {
+ const res = await fetch(path, {
+ credentials: 'include',
+ headers: { 'content-type': 'application/json', ...(opts.headers || {}) },
+ ...opts,
+ });
+ const d = await res.json().catch(() => ({}));
+ if (!res.ok) {
+ const code = d.code || d.error || null;
+ const message = d.error_description || d.message || `HTTP ${res.status}`;
+ throw Object.assign(new Error(message), { status: res.status, code });
+ }
+ return d;
+}
+
+// ── data ─────────────────────────────────────────────────────────────────────
+
+function buildQuery(cursor) {
+ const params = new URLSearchParams({ limit: String(FETCH_LIMIT) });
+ if (state.network) params.set('network', state.network);
+ if (cursor) params.set('cursor', cursor);
+ return params;
+}
+
+async function refresh() {
+ if (state.loading) return;
+ state.loading = true;
+ renderSkeleton();
+ try {
+ const body = await api(`${API_URL}?${buildQuery()}`);
+ state.signedIn = true;
+ state.rows = body.receipts || [];
+ state.summary = body.summary || null;
+ state.nextCursor = body.nextCursor || null;
+ showVault();
+ renderVault();
+ } catch (err) {
+ if (err.status === 401) {
+ state.signedIn = false;
+ showSignin();
+ } else {
+ showVault();
+ renderLoadError(err.message || 'Could not load your outbound receipts.');
+ }
+ } finally {
+ state.loading = false;
+ }
+}
+
+async function loadMore() {
+ if (!state.nextCursor || state.loading || state.loadingMore) return;
+ state.loadingMore = true;
+ setMoreBusy(true);
+ try {
+ const body = await api(`${API_URL}?${buildQuery(state.nextCursor)}`);
+ state.rows = state.rows.concat(body.receipts || []);
+ state.nextCursor = body.nextCursor || null;
+ renderVault();
+ } catch (err) {
+ showMoreError(err.message || 'Could not load more receipts.');
+ } finally {
+ state.loadingMore = false;
+ setMoreBusy(false);
+ }
+}
+
+// ── rendering ────────────────────────────────────────────────────────────────
+
+function showSignin() {
+ $('ob-signin').hidden = false;
+ $('ob-vault').hidden = true;
+}
+
+function showVault() {
+ $('ob-signin').hidden = true;
+ $('ob-vault').hidden = false;
+}
+
+function renderSkeleton() {
+ if ($('ob-vault').hidden) return;
+ $('ob-list').innerHTML = Array.from({ length: 3 })
+ .map(() => '<div class="rc-row rc-skeleton" aria-hidden="true"></div>')
+ .join('');
+ $('ob-empty').hidden = true;
+ $('ob-load-error').hidden = true;
+ $('ob-more-wrap').hidden = true;
+}
+
+function renderLoadError(message) {
+ $('ob-list').innerHTML = '';
+ $('ob-empty').hidden = true;
+ $('ob-more-wrap').hidden = true;
+ const el = $('ob-load-error');
+ el.hidden = false;
+ $('ob-load-error-msg').textContent = message;
+}
+
+function showMoreError(message) {
+ const el = $('ob-load-error');
+ el.hidden = false;
+ $('ob-load-error-msg').textContent = message;
+}
+
+function setMoreBusy(busy) {
+ const btn = $('ob-more');
+ btn.disabled = busy;
+ btn.querySelector('.rc-btn-label').textContent = busy ? 'Loading…' : 'Load more';
+}
+
+function filteredRows() {
+ const q = state.query.trim().toLowerCase();
+ if (!q) return state.rows;
+ return state.rows.filter(
+ (r) =>
+ String(r.endpointHost || '').toLowerCase().includes(q) ||
+ String(r.txHash || '').toLowerCase().includes(q),
+ );
+}
+
+function renderPager(shown) {
+ const wrap = $('ob-more-wrap');
+ if (!state.nextCursor) {
+ wrap.hidden = true;
+ return;
+ }
+ wrap.hidden = false;
+ $('ob-shown').textContent = `Showing the newest ${shown} outbound payment${shown === 1 ? '' : 's'}.`;
+}
+
+function statusBadge(r) {
+ if (r.resolved) return '<span class="rc-net" data-net="Solana" title="Verified against the settlement transaction itself">verified</span>';
+ if (r.resolveError) return '<span class="rc-net" title="The chain lookup for this signature failed permanently">unverified</span>';
+ if (r.resolvePending) return '<span class="rc-net" title="Chain verification is still resolving; refresh to check again">pending</span>';
+ return '';
+}
+
+function renderVault() {
+ $('ob-k-spend').textContent = state.summary ? `$${Number(state.summary.totalSpendUsd || 0).toFixed(2)}` : '·';
+ $('ob-k-total').textContent = state.summary ? String(state.summary.total) : '·';
+ $('ob-k-verified').textContent = state.summary ? String(state.summary.verified) : '·';
+ $('ob-k-merchants').textContent = state.summary ? String(state.summary.uniqueMerchants) : '·';
+ $('ob-load-error').hidden = true;
+
+ const rows = filteredRows();
+ const list = $('ob-list');
+
+ if (!state.rows.length) {
+ list.innerHTML = '';
+ $('ob-more-wrap').hidden = true;
+ $('ob-empty').hidden = false;
+ $('ob-empty-title').textContent = 'No outbound spend yet';
+ $('ob-empty-body').innerHTML =
+ 'Nothing here until an agent spends through an Agent Payment Session at another x402 merchant. ' +
+ 'Fund a session from the <a href="/payments">Payment Sessions dashboard</a> and hand its token to an ' +
+ 'agent, or read the <a href="/docs/tutorials/agent-spending-envelope">spending envelope guide</a>.';
+ return;
+ }
+ if (!rows.length) {
+ list.innerHTML = '';
+ $('ob-more-wrap').hidden = true;
+ $('ob-empty').hidden = false;
+ $('ob-empty-title').textContent = 'No outbound payments match your filter';
+ $('ob-empty-body').textContent = 'Try a different merchant host, network, or transaction hash.';
+ return;
+ }
+ $('ob-empty').hidden = true;
+ renderPager(state.rows.length);
+
+ list.innerHTML = rows
+ .map((r, i) => {
+ const url = r.network === 'solana' ? solscanTxUrl(r.txHash) : null;
+ const txCell = r.txHash
+ ? url
+ ? `<a class="rc-tx" href="${esc(url)}" target="_blank" rel="noopener noreferrer">${esc(shortSig(r.txHash))} ↗</a>`
+ : `<span class="rc-tx" title="${esc(r.txHash)}">${esc(shortSig(r.txHash))}</span>`
+ : '<span class="rc-tx rc-tx-none">no tx</span>';
+ const when = r.createdAt
+ ? `<time datetime="${esc(r.createdAt)}" title="${esc(new Date(r.createdAt).toLocaleString())}">${esc(timeAgo(r.createdAt))}</time>`
+ : '·';
+ const amount = formatOutboundAmount(r);
+ const netLabel = r.network === 'solana' ? 'Solana' : 'Base';
+ return `
+ <div class="rc-row" data-idx="${i}">
+ <div class="rc-row-main">
+ <span class="rc-resource" title="${esc(r.endpointUrl || r.endpointHost)}">${esc(r.endpointHost || r.endpointUrl)}</span>
+ <span class="rc-meta">
+ <span class="rc-amount" title="${esc(amount.label)}">${esc(amount.label)}</span>
+ <span class="rc-net" data-net="${esc(netLabel)}">${esc(netLabel)}</span>
+ ${statusBadge(r)}
+ ${when}
+ ${txCell}
+ </span>
+ </div>
+ </div>`;
+ })
+ .join('');
+}
+
+// ── CSV export ───────────────────────────────────────────────────────────────
+
+function downloadBlob(content, filename, type) {
+ const blob = new Blob([content], { type });
+ const url = URL.createObjectURL(blob);
+ const a = document.createElement('a');
+ a.href = url;
+ a.download = filename;
+ a.click();
+ URL.revokeObjectURL(url);
+}
+
+function exportCsv() {
+ if (!state.rows.length) {
+ toast('Nothing to export yet');
+ return;
+ }
+ downloadBlob(outboundReceiptsToCsv(filteredRows()), 'x402-outbound-receipts.csv', 'text/csv');
+ toast('CSV exported');
+}
+
+let toastTimer = null;
+function toast(message) {
+ const el = $('rc-toast');
+ if (!el) return;
+ el.textContent = message;
+ el.hidden = false;
+ el.classList.add('show');
+ clearTimeout(toastTimer);
+ toastTimer = setTimeout(() => {
+ el.classList.remove('show');
+ toastTimer = setTimeout(() => {
+ el.hidden = true;
+ }, 200);
+ }, 1800);
+}
+
+// ── tab bar ──────────────────────────────────────────────────────────────────
+
+function selectTab(which) {
+ const inboundTab = $('rc-tab-inbound');
+ const outboundTab = $('rc-tab-outbound');
+ const inboundPanel = $('rc-panel-inbound');
+ const outboundPanel = $('rc-panel-outbound');
+ const toOutbound = which === 'outbound';
+
+ inboundTab.setAttribute('aria-selected', String(!toOutbound));
+ outboundTab.setAttribute('aria-selected', String(toOutbound));
+ inboundPanel.hidden = toOutbound;
+ outboundPanel.hidden = !toOutbound;
+
+ if (toOutbound && state.signedIn === null) refresh();
+}
+
+function wireTabs() {
+ $('rc-tab-inbound').addEventListener('click', () => selectTab('inbound'));
+ $('rc-tab-outbound').addEventListener('click', () => selectTab('outbound'));
+}
+
+function wireVault() {
+ $('ob-refresh').addEventListener('click', refresh);
+ $('ob-retry').addEventListener('click', refresh);
+ $('ob-export').addEventListener('click', exportCsv);
+ $('ob-more').addEventListener('click', loadMore);
+ $('ob-search').addEventListener('input', (e) => {
+ state.query = e.target.value;
+ renderVault();
+ });
+ $('ob-filter-network').addEventListener('change', (e) => {
+ state.network = e.target.value;
+ refresh();
+ });
+
+ document.addEventListener('keydown', (e) => {
+ if (e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement) return;
+ if ($('rc-panel-outbound').hidden) return;
+ if (e.key === '/') {
+ e.preventDefault();
+ $('ob-search').focus();
+ }
+ if (e.key === 'e') exportCsv();
+ });
+}
+
+function boot() {
+ wireTabs();
+ wireVault();
+}
+
+boot();
diff --git a/src/receipts.css b/src/receipts.css
index d3d627b33..142afe01b 100644
--- a/src/receipts.css
+++ b/src/receipts.css
@@ -82,6 +82,55 @@
text-underline-offset: 2px;
}
+/* ── tab bar ──────────────────────────────────────────────────────────────── */
+.rc-tabs {
+ display: flex;
+ gap: 8px;
+ margin: 0 0 var(--space-lg, 24px);
+ border-bottom: 1px solid var(--line, rgba(255, 255, 255, 0.1));
+}
+.rc-tab {
+ appearance: none;
+ background: transparent;
+ border: none;
+ border-bottom: 2px solid transparent;
+ color: color-mix(in srgb, var(--ink, #d8d8d8) 60%, transparent);
+ cursor: pointer;
+ display: flex;
+ flex-direction: column;
+ align-items: flex-start;
+ gap: 0.2em;
+ font: inherit;
+ padding: 0.6em 0.2em 0.8em;
+ margin-bottom: -1px;
+ transition:
+ color var(--duration-fast) var(--ease-standard),
+ border-color var(--duration-fast) var(--ease-standard);
+}
+.rc-tab span:first-child {
+ font-size: 0.98rem;
+ font-weight: 650;
+}
+.rc-tab-sub {
+ font-size: 0.76rem;
+ font-weight: 400;
+ color: color-mix(in srgb, var(--ink, #d8d8d8) 50%, transparent);
+}
+.rc-tab:hover {
+ color: var(--ink, #fff);
+}
+.rc-tab:focus-visible {
+ outline: 2px solid var(--rc-accent);
+ outline-offset: 2px;
+}
+.rc-tab[aria-selected='true'] {
+ color: var(--ink, #fff);
+ border-bottom-color: var(--rc-accent);
+}
+.rc-tab[aria-selected='true'] .rc-tab-sub {
+ color: color-mix(in srgb, var(--ink, #d8d8d8) 70%, transparent);
+}
+
/* ── sign-in card ─────────────────────────────────────────────────────────── */
.rc-signin {
margin-top: var(--space-xl, 32px);
@@ -225,6 +274,10 @@
outline: 2px solid var(--rc-accent);
outline-offset: 2px;
}
+select.rc-tool {
+ appearance: none;
+ background-color: color-mix(in srgb, var(--panel, #131318) 88%, transparent);
+}
/* KPI strip */
.rc-kpis {
diff --git a/tests/receipts-lib.test.js b/tests/receipts-lib.test.js
index 6d7491c46..2a0367f65 100644
--- a/tests/receipts-lib.test.js
+++ b/tests/receipts-lib.test.js
@@ -15,6 +15,9 @@ import {
summarizeReceipts,
formatReceiptAmount,
totalSpend,
+ outboundMintSymbol,
+ formatOutboundAmount,
+ outboundReceiptsToCsv,
} from '../src/receipts-lib.js';
// The API supplies the scale (server-resolved from the same env config that
@@ -202,3 +205,63 @@ describe('summarizeReceipts', () => {
expect(s.firstAt).toBe(null);
});
});
+
+const USDC_MINT = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v';
+const THREE_MINT = 'FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump';
+const SYNTH_MINT = 'THREEsynthetic1111111111111111111111111111';
+
+describe('outboundMintSymbol', () => {
+ it('recognises USDC and $THREE, and nothing else', () => {
+ expect(outboundMintSymbol(USDC_MINT)).toBe('USDC');
+ expect(outboundMintSymbol(THREE_MINT)).toBe('THREE');
+ expect(outboundMintSymbol(SYNTH_MINT)).toBeNull();
+ });
+});
+
+describe('formatOutboundAmount', () => {
+ it('prefers the chain-resolved amount, under its real ticker', () => {
+ const amt = formatOutboundAmount({
+ reportedAmountUsd: 1,
+ resolved: { amountAtomics: '2000000000', decimals: 6, mint: THREE_MINT },
+ });
+ expect(amt.label).toBe('2,000.00 THREE');
+ expect(amt.usd).toBe(false);
+ });
+
+ it('falls back to the reported USD amount when nothing has resolved yet', () => {
+ const amt = formatOutboundAmount({ reportedAmountUsd: 4.5, resolved: null });
+ expect(amt.label).toBe('$4.50');
+ expect(amt.usd).toBe(true);
+ });
+});
+
+describe('outboundReceiptsToCsv', () => {
+ it('emits the resolved settlement columns when present', () => {
+ const csv = outboundReceiptsToCsv([
+ {
+ id: 'exec-1',
+ createdAt: '2026-10-15T00:00:00.000Z',
+ network: 'solana',
+ endpointHost: 'merchant.test',
+ endpointUrl: 'https://merchant.test/api/paid',
+ reportedAmountUsd: 1,
+ txHash: 'sig1',
+ resolved: { payer: 'PAYER', payee: 'PAYEE', mint: USDC_MINT, amountAtomics: '1000000', decimals: 6, feeLamports: 5000, slot: 1, blockTime: 2 },
+ resolveError: null,
+ },
+ ]);
+ const [header, row] = csv.split('\n');
+ expect(header).toBe(
+ 'id,created_at,network,endpoint_host,endpoint_url,reported_amount_usd,tx_hash,resolved_payer,resolved_payee,resolved_mint,resolved_amount_atomics,resolved_decimals,resolved_fee_lamports,resolved_slot,resolved_block_time,resolve_error',
+ );
+ expect(row).toContain('PAYER');
+ expect(row).toContain('PAYEE');
+ expect(row).toContain(USDC_MINT);
+ });
+
+ it('handles empty input', () => {
+ expect(outboundReceiptsToCsv([])).toBe(
+ 'id,created_at,network,endpoint_host,endpoint_url,reported_amount_usd,tx_hash,resolved_payer,resolved_payee,resolved_mint,resolved_amount_atomics,resolved_decimals,resolved_fee_lamports,resolved_slot,resolved_block_time,resolve_error',
+ );
+ });
+});