deviant/scripts/compile-contracts.mjs
Local Dev debd6a6fbb chore: sweep in-flight work across all domains
Snapshot commit rolling up ~255 files of coherent-but-multi-domain in-flight
work that had accumulated on this branch. Split by area:

Contracts + covenants
- New: AsmFxSwap, DeviantOpenMintNBA, DeviantTieredMintOracleFT,
  TermCouponVault, UniformReserve, UniformReserveAggregate.
- Verify-artifact refresh (src/verify/artifacts/*.json + canonical.ts).

Wallet + shell (shells/app + src/wallet)
- App.tsx, MainScreen, ArtemisionScreen, AssetDetail, AgoraScreen,
  SettingsScreen, Unlock, TokenImportModal, UniformFiat/DepositPanel,
  KatalogosPanel (renamed from PinaxPanel), shell.css.
- src/wallet: wallet.ts, runtime.ts, index.ts. Core registry/chipnetFile.
- Deleted stale hook: useAllDevBalances.ts.

Cross-chain + correspondent (services/correspondent + scripts)
- Correspondent server/bch/config updates for PYUSD Solana, EURC Sepolia,
  aggregate reserve flows.
- New scripts: PYUSD roundtrip, EURC onboarding, GMX game loop /
  genesis / mint sanity, tiered mint fee, aggregate reserve, product2
  shares dividends, product3 t-bond, uniform fiat cell tests.

Telegram order-book (P2PExchange bot)
- db.ts, index.ts, en/ru locales — updates upstream from the extracted
  standalone repo at D:/Dev/P2PExchange.

Docs — Parameters (specs), wiki, snapshots, design mockups
- Parameters: FIATm/MBA_Shares/Potidaea/Anthemus refinements +
  ASM_CrossChain/DebitCredit + UniformFiat + Anthemus DEX MVP prompt +
  Artemision + Athenae Politeia + Philosophy + SSHkeyServer runbook +
  new dApp/{Artemision,Katalogos,Pinax,Pari_escrow,SURFACES}.
- wiki: cross-chain, games-tote, glossary, governance/voting-systems,
  infra, wallet, wallet-ui-design, decisions (ADR log).
- snapshots: catch-up entries and INDEX regeneration.
- design: mockups refreshed (agora, asset-detail, assets-tab, potidaea)
  + Potidaea assets + tote deploy notes.

Housekeeping
- .gitignore: exclude the new root test/session state files
  (.sol-vault-keys.json, .football-tote-state.json,
  .tote-platform-state.json, .redeem-roundtrip-state.json,
  .eurc-onboard-state.json — some contain oracle privkeys / vault
  secretKeyBase58; NEVER commit) + the .usdm-historical-chart.html
  chart output + MS Office `~$*` lock files + scripts/bundle-surfaces
  `build/` output. Also add scripts/bundle-surfaces.mjs.
- CLAUDE.md, WALLET-COORDINATION.md, snapshots/INDEX.md, design/README.md
  refreshed.
- package.json / package-lock.json bumps.

Verified: sensitive files at repo root confirmed ignored (git check-ignore
each). No `.env`, no raw WIF/xprv/mnemonic/secretKey/oraclePriv strings in
the staged diff. MS Word autosave file (`Parameters/Philosophy/~$*.docx`)
excluded and gitignored.

The WizardConnect responder work landed separately in the previous commit
(6987591); this is everything else that had accumulated alongside it.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-07-29 01:14:33 +02:00

96 lines
3.4 KiB
JavaScript

#!/usr/bin/env node
/**
* compile-contracts.mjs — compiles CashScript sources to artifact JSON.
*
* Uses the cashscript SDK's compileFile. Output goes to contracts/dist/.
* Run after editing any contracts/*.cash source.
*/
import { readdirSync, readFileSync, writeFileSync, mkdirSync, existsSync } from 'node:fs';
import { join } from 'node:path';
const ROOT = join(import.meta.dirname, '..');
const SRC = join(ROOT, 'contracts');
const OUT = join(SRC, 'dist');
// The trust-critical D-3 module (src/verify/canonical.ts) imports the canonical
// templates as embedded JSON (so it runs in browsers/WebViews with no fs). Those
// embedded copies MUST NOT drift from the compiled source, so we mirror them here
// on every compile. Keep this list in lockstep with the imports in canonical.ts.
const EMBED = join(ROOT, 'src', 'verify', 'artifacts');
const EMBEDDED = new Set([
'DeviantOpenMintFT.json',
'DeviantOpenMintNBA.json',
'DeviantManagedMintFT.json',
'DeviantBondingCurveFT.json',
'DeviantEscFeeSupply.json',
'DeviantDescFeeSupply.json',
'OpenTote.json',
'ParimutuelToteOpen.json',
'ParimutuelToteOpenMBA.json',
// Phase G.1 — voting-system canonical templates (snapshot 0127+; §6.15 roadmap).
'CitizenToken.json',
'EndorsementCovenant.json',
'RegistryState.json',
'ApplicationCovenant.json',
'ApplicationCovenantB.json',
'ApplicationCovenantC.json',
'ApplicationCovenantD.json',
'ApplicationCovenantE.json',
'BallotCovenant.json',
'ElderFreezeAction.json',
'ComplaintCovenant.json',
]);
if (!existsSync(OUT)) mkdirSync(OUT, { recursive: true });
if (!existsSync(EMBED)) mkdirSync(EMBED, { recursive: true });
async function main() {
// CashScript 0.12 split the compiler into a separate `cashc` package.
// The SDK package (`cashscript`) is runtime-only and no longer exports
// compileFile.
let compileFile;
try {
({ compileFile } = await import('cashc'));
} catch {
console.error('cashc not installed. Run `npm install` first.');
process.exit(1);
}
const sources = readdirSync(SRC).filter((f) => f.endsWith('.cash'));
if (sources.length === 0) {
console.log('No .cash sources found in contracts/');
return;
}
for (const src of sources) {
const srcPath = join(SRC, src);
// Skip contracts marked SUPERSEDED or EXPECTED-COMPILE-FAIL in their header
// comments. Convention for files we keep on disk as reference (SUPERSEDED) or
// as deliberate negative artifacts that document a Script limitation
// (EXPECTED-COMPILE-FAIL) but should not break the build.
const header = readFileSync(srcPath, 'utf8').slice(0, 600);
const skipMatch = /SUPERSEDED|EXPECTED-COMPILE-FAIL/.exec(header);
if (skipMatch) {
console.log(`skipped ${src} (marked ${skipMatch[0]})`);
continue;
}
try {
const artifact = compileFile(srcPath);
const jsonName = src.replace(/\.cash$/, '.json');
const json = JSON.stringify(artifact, null, 2);
const outPath = join(OUT, jsonName);
writeFileSync(outPath, json);
console.log(`compiled ${src} -> ${outPath}`);
// Mirror canonical templates into the embedded D-3 copy (see EMBED above).
if (EMBEDDED.has(jsonName)) {
writeFileSync(join(EMBED, jsonName), json);
console.log(` embedded ${jsonName} -> ${join(EMBED, jsonName)}`);
}
} catch (err) {
console.error(`FAILED ${src}:`, err.message);
process.exitCode = 1;
}
}
}
main();