x402-smartperps / tree / tools/gen-examples.mjs ยท raw (this view has old GitHub links rewritten for the mirror; raw is byte-exact)
// Record example outputs for the Bazaar discovery declaration, OpenAPI and landing page from a real engine run.
//   node tools/gen-examples.mjs   (writes src/examples.js; lists trimmed so every 402 header stays well under 8 KB)
import { writeFileSync } from 'node:fs';
import { buildSnapshot, coinLite, coinFull, scan, walletProfile, DISCLAIMER } from '../src/engine.js';
const { snapshot, cohortRecord } = await buildSnapshot({});
const now = Date.now();
const strip = ({ reliable, ...r }) => r;
const shortQ = (r) => ({ ...r, cohort: { ...r.cohort, rules: undefined } });
const lite = { ...shortQ(strip(coinLite('BTC', snapshot, [], now))), tier: 'lite', disclaimer: DISCLAIMER };
const coin0 = strip(coinFull('ETH', snapshot, [], cohortRecord.cohort, now));
const coin = { ...shortQ(coin0), top_positions: coin0.top_positions.slice(0, 2), liquidation_clusters: { longs: coin0.liquidation_clusters.longs.slice(0, 3), shorts: coin0.liquidation_clusters.shorts.slice(0, 3), no_liquidation_price_usd: coin0.liquidation_clusters.no_liquidation_price_usd }, tier: 'coin', disclaimer: DISCLAIMER };
const s0 = strip(scan(snapshot, [], { limit: 2 }, now));
const sc = { ...shortQ(s0), tier: 'scan', disclaimer: DISCLAIMER };
const w0 = await walletProfile(cohortRecord.cohort[0].a, { cohort: cohortRecord.cohort, now });
const wallet = { ...w0, address: '0x0000000000000000000000000000000000000001', positions: w0.positions.slice(0, 2), tier: 'wallet', disclaimer: DISCLAIMER }; // placeholder address: docs never name a real account
if (wallet.last_30d) wallet.last_30d.most_traded = wallet.last_30d.most_traded.slice(0, 2);
const J = (o) => JSON.stringify(o);
writeFileSync(new URL('../src/examples.js', import.meta.url), `// Example outputs for the Bazaar discovery declaration, OpenAPI and landing page (recorded ${new Date(now).toISOString()}; trimmed lists).\nexport const LITE_EXAMPLE = ${J(lite)};\nexport const COIN_EXAMPLE = ${J(coin)};\nexport const SCAN_EXAMPLE = ${J(sc)};\nexport const WALLET_EXAMPLE = ${J(wallet)};\n`);
console.log(snapshot.failed, [lite, coin, sc, wallet].map((x) => J(x).length));

agentgate-source: code mirror on Cloudflare Pages. All repos