open-energymesh-offline-fir.../graph_of_contracts_registry.js

20 lines
507 B
JavaScript

// Lightweight Graph-of-Contracts registry: versioned contracts and schemas
class GraphOfContractsRegistry {
constructor() {
this.contracts = {}; // key: `${name}@${version}` -> schema
}
registerContract(name, version, schema) {
if (!name || !version) return;
const key = `${name}@${version}`;
this.contracts[key] = schema;
}
getContract(name, version) {
const key = `${name}@${version}`;
return this.contracts[key];
}
}
module.exports = { GraphOfContractsRegistry };