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.

2.5 KB
Raw Blame
#!/usr/bin/env node
// Refresh the vendored Pump program IDLs under contracts/idl/pump/ and the
// reference mirror under docs/pumpfun-program/idl/.
//
// Source of truth: pump-fun/pump-public-docs (mirrored via nirholas/pumpkit).
// Run after Pump publishes a new IDL version, then commit the diff.
//
//   node scripts/refresh-pump-idls.mjs
//
// Exits non-zero if any download fails so it's safe to wire into CI.

import { writeFileSync, mkdirSync } from 'node:fs';
import { resolve, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';

const HERE = dirname(fileURLToPath(import.meta.url));
const OUT_DIRS = [
	resolve(HERE, '..', 'contracts', 'idl', 'pump'),
	resolve(HERE, '..', 'docs', 'pumpfun-program', 'idl'),
];

// Upstream doc strings use em and en dashes, which this repo bans in
// committed text. Rewrite them to a plain hyphen so a refresh lands clean.
function scrubDashes(text) {
	return text.replace(/ ?[\u2014\u2013] ?/g, ' - ');
}

const SOURCES = [
	{
		name: 'pump',
		urls: [
			'https://raw.githubusercontent.com/pump-fun/pump-public-docs/main/idl/pump.json',
			'https://raw.githubusercontent.com/nirholas/pumpkit/main/docs/protocol/pump-official/idl/pump.json',
		],
	},
	{
		name: 'pump_amm',
		urls: [
			'https://raw.githubusercontent.com/pump-fun/pump-public-docs/main/idl/pump_amm.json',
			'https://raw.githubusercontent.com/nirholas/pumpkit/main/docs/protocol/pump-official/idl/pump_amm.json',
		],
	},
	{
		name: 'pump_fees',
		urls: [
			'https://raw.githubusercontent.com/pump-fun/pump-public-docs/main/idl/pump_fees.json',
			'https://raw.githubusercontent.com/nirholas/pumpkit/main/docs/protocol/pump-official/idl/pump_fees.json',
		],
	},
];

for (const dir of OUT_DIRS) mkdirSync(dir, { recursive: true });

let failures = 0;
for (const { name, urls } of SOURCES) {
	let body = null;
	let usedUrl = null;
	for (const url of urls) {
		try {
			const resp = await fetch(url);
			if (!resp.ok) continue;
			const text = await resp.text();
			JSON.parse(text); // validate structure before writing
			body = scrubDashes(text);
			usedUrl = url;
			break;
		} catch {
			// try next mirror
		}
	}
	if (!body) {
		console.error(`✗ ${name}: all sources failed`);
		failures++;
		continue;
	}
	for (const dir of OUT_DIRS) writeFileSync(resolve(dir, `${name}.json`), body);
	console.log(`✓ ${name} ← ${usedUrl}`);
}

if (failures > 0) {
	console.error(`\nRefresh failed for ${failures} IDL(s).`);
	process.exit(1);
}
console.log('\nAll Pump IDLs refreshed.');