- tradefinance: LoC, bill of exchange, factoring, PO financing, dynamic discounting, securitization + tranche tokens, credit lines, guarantees - compliance: sanctions/AML, certificate of origin, phytosanitary, halal, recalls, export licenses, duty/tariff, customs declaration - dpp: EU Digital Product Passport (ERC721) + lifecycle/materials/repairability/recycling - logistics: freight, cold-chain, bonded warehouse, fleet, containers, proof-of-delivery - commodities: tokens, harvest/grading registries, storage receipts, price oracle, vault - energy: renewable energy certs (ERC1155), emissions trading, water/biodiversity, green bonds - workforce: soulbound worker credentials, safety training, milestone payroll, skills - data: IoT sensors, quality inspection, lab tests, oracle aggregator, data marketplace - 1468 forge tests green; 117 ABIs exported; DeployPlatform extended Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
94 lines
4.4 KiB
JavaScript
94 lines
4.4 KiB
JavaScript
#!/usr/bin/env node
|
|
// Copies compiled ABI arrays from Foundry `out/` into the shared package's abis dir.
|
|
// Fails fast (non-zero exit) if any expected artifact is missing.
|
|
import { readFileSync, writeFileSync, mkdirSync, existsSync } from "node:fs";
|
|
import { dirname, join } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
const pkgRoot = join(__dirname, "..");
|
|
const outDir = join(pkgRoot, "out");
|
|
const sharedAbisDir = join(pkgRoot, "..", "shared", "src", "abis");
|
|
|
|
const CONTRACTS = [
|
|
// root
|
|
"ProvenanceRegistry", "AttestationRegistry", "SettlementEscrow", "MockUSDC",
|
|
// M0 core
|
|
"AddressBook", "Pauser",
|
|
// M1 provenance
|
|
"CheckpointOracle", "ProvenanceFactory", "BatchMetadataStore",
|
|
// M2 payments / settlement
|
|
"StablecoinRegistry", "FeeManager", "Treasury", "PaymentRouter", "EscrowFactory", "SettlementRouter",
|
|
// M3 identity
|
|
"OrganizationRegistry", "SupplierRegistry", "BuyerRegistry", "CarrierRegistry", "KYCRegistry", "IdentityResolver",
|
|
// M4 reputation & bonds
|
|
"ReputationEngine", "SupplierBond", "StakeManager", "SlashingController", "ScoreOracle",
|
|
// M5 invoice financing / RWA
|
|
"InvoiceNFT", "ReceivableRegistry", "InvoiceFinancing", "FinancingPool", "LenderVault",
|
|
"DiscountCalculator", "YieldDistributor", "RepaymentController",
|
|
// M6 insurance
|
|
"InsurancePool", "PolicyManager", "ClaimsProcessor", "PremiumCalculator", "RiskPool",
|
|
// M7 disputes & governance
|
|
"DisputeArbitration", "ArbiterStaking", "GovernanceToken", "ProofChainGovernor", "ProofChainTimelock", "ProposalRegistry",
|
|
// M8 tokenization & ESG
|
|
"BatchNFT", "WarehouseReceipt", "CarbonCreditToken", "ESGRegistry", "SustainabilityOracle", "OffsetMarketplace",
|
|
// M9 marketplace
|
|
"ListingRegistry", "FinancingMarketplace", "AuctionHouse", "OrderBook", "BidManager",
|
|
// M10 rewards & loyalty
|
|
"LoyaltyPoints", "RewardsDistributor", "StakingRewards", "ReferralProgram", "EmissionsController",
|
|
// Wave A: tradefinance
|
|
"LetterOfCredit", "BillOfExchange", "FactoringAgreement", "PurchaseOrderFinancing", "DynamicDiscounting",
|
|
"SupplyChainFinance", "ReceivableSecuritization", "TrancheToken", "CreditLineManager", "GuaranteeRegistry",
|
|
// Wave A: compliance
|
|
"SanctionsScreening", "AMLRegistry", "TradeComplianceEngine", "CertificateOfOrigin", "PhytosanitaryCertificate",
|
|
"HalalCertification", "ProductRecallRegistry", "ExportLicenseRegistry", "DutyAndTariffCalculator", "CustomsDeclaration",
|
|
// Wave A: dpp
|
|
"DigitalProductPassport", "DPPLifecycleRegistry", "MaterialComposition", "RepairabilityIndex", "RecyclingRegistry",
|
|
"DPPDataCarrier", "DPPComplianceOracle",
|
|
// Wave A: logistics
|
|
"FreightBooking", "ColdChainMonitor", "BondedWarehouse", "FleetRegistry", "RouteAttestation",
|
|
"CustomsBonded", "ContainerRegistry", "LastMileProofOfDelivery",
|
|
// Wave A: commodities
|
|
"CommodityToken", "CommodityVault", "HarvestRegistry", "GradingRegistry", "StorageReceipt", "PriceOracle",
|
|
// Wave A: energy
|
|
"RenewableEnergyCertificate", "EmissionsTrading", "WaterCredit", "BiodiversityCredit", "GreenBondIssuer",
|
|
// Wave A: workforce
|
|
"WorkerCredential", "SafetyTrainingRegistry", "MilestonePayroll", "SkillAttestation", "LaborComplianceRegistry",
|
|
// Wave A: data
|
|
"IoTSensorRegistry", "QualityInspection", "LabTestAttestation", "OracleAggregator", "DataMarketplace",
|
|
];
|
|
|
|
function loadAbi(name) {
|
|
const artifactPath = join(outDir, `${name}.sol`, `${name}.json`);
|
|
if (!existsSync(artifactPath)) {
|
|
throw new Error(`Missing artifact ${artifactPath}. Run \`forge build\` first.`);
|
|
}
|
|
const artifact = JSON.parse(readFileSync(artifactPath, "utf8"));
|
|
if (!Array.isArray(artifact.abi)) {
|
|
throw new Error(`Artifact ${artifactPath} has no abi array.`);
|
|
}
|
|
return artifact.abi;
|
|
}
|
|
|
|
function main() {
|
|
mkdirSync(sharedAbisDir, { recursive: true });
|
|
const failures = [];
|
|
for (const name of CONTRACTS) {
|
|
try {
|
|
const abi = loadAbi(name);
|
|
const dest = join(sharedAbisDir, `${name}.json`);
|
|
writeFileSync(dest, `${JSON.stringify(abi, null, 2)}\n`);
|
|
console.log(`exported ${name} -> ${dest} (${abi.length} entries)`);
|
|
} catch (err) {
|
|
failures.push(`${name}: ${err.message}`);
|
|
}
|
|
}
|
|
if (failures.length > 0) {
|
|
console.error("ABI export failed:\n" + failures.map((f) => ` - ${f}`).join("\n"));
|
|
process.exit(1);
|
|
}
|
|
console.log(`Exported ${CONTRACTS.length} ABIs to ${sharedAbisDir}`);
|
|
}
|
|
|
|
main();
|