Files
proxmox/scripts/verify/generate-crosschain-publication-packs.mjs
defiQUG dbd517b279 Sync workspace: config, docs, scripts, CI, operator rules, and submodule pointers.
- Update dbis_core, cross-chain-pmm-lps, explorer-monorepo, metamask-integration, pr-workspace/chains
- Omit embedded publish git dirs and empty placeholders from index

Made-with: Cursor
2026-04-12 06:12:20 -07:00

90 lines
2.8 KiB
JavaScript

#!/usr/bin/env node
import fs from 'fs';
import path from 'path';
const repoRoot = path.resolve(path.dirname(new URL(import.meta.url).pathname), '..', '..');
const matrixPath = path.join(repoRoot, 'reports', 'status', 'contract_verification_publish_matrix.json');
const outDir = path.join(repoRoot, 'reports', 'status', 'publication-packs');
const chainIds = ['1', '10', '56', '137', '8453'];
const chainNames = {
'1': 'ethereum-mainnet',
'10': 'optimism',
'56': 'bsc',
'137': 'polygon',
'8453': 'base',
};
function ensureDir(dir) {
fs.mkdirSync(dir, { recursive: true });
}
const matrix = JSON.parse(fs.readFileSync(matrixPath, 'utf8'));
for (const chainId of chainIds) {
const entries = matrix.entries.filter((entry) => entry.chainId === chainId);
if (!entries.length) continue;
const slug = chainNames[chainId] || `chain-${chainId}`;
const chainDir = path.join(outDir, slug);
ensureDir(chainDir);
const summary = {
chainId,
chainName: entries[0].chainName,
explorer: entries[0].explorer,
generatedAt: matrix.generatedAt,
total: entries.length,
counts: entries.reduce((acc, entry) => {
acc[entry.contractType] = (acc[entry.contractType] || 0) + 1;
return acc;
}, {}),
entries,
};
const grouped = entries.reduce((acc, entry) => {
(acc[entry.contractType] ||= []).push(entry);
return acc;
}, {});
const sections = Object.entries(grouped)
.sort(([a], [b]) => a.localeCompare(b))
.map(([type, items]) => {
const rows = items
.map((entry) => `| ${entry.label} | \`${entry.address}\` | ${entry.automation} | ${entry.publishNotes} |`)
.join('\n');
return `## ${type}\n\n| Label | Address | Automation | Notes |\n| --- | --- | --- | --- |\n${rows}`;
})
.join('\n\n');
const md = `# ${summary.chainName} Publication Pack
**Chain ID:** ${chainId}
**Explorer:** ${summary.explorer}
**Generated:** ${summary.generatedAt}
This pack groups the repo-known contracts and published deployment inventory for ${summary.chainName}. Use it when doing per-chain explorer verification and publication closure.
## Operator sequence
1. Verify repo-owned deployments on the chain explorer.
2. Confirm the address list still matches on-chain deployment reality.
3. Update repo-facing token lists, PMM inventories, and mapping docs if anything changed.
4. Regenerate:
- \`node scripts/verify/generate-contract-verification-publish-matrix.mjs\`
- \`node scripts/verify/generate-crosschain-publication-packs.mjs\`
## Counts
${Object.entries(summary.counts).map(([type, count]) => `- \`${type}\`: ${count}`).join('\n')}
${sections}
`;
fs.writeFileSync(path.join(chainDir, 'pack.json'), JSON.stringify(summary, null, 2) + '\n');
fs.writeFileSync(path.join(chainDir, 'README.md'), md + '\n');
}
console.log(`Wrote grouped publication packs under ${outDir}`);