from __future__ import annotations from dataclasses import dataclass, field from typing import Dict, List, Optional @dataclass class GraphOfContracts: """A simple in-memory registry for contract adapters and versions.""" contracts: Dict[str, Dict[str, str]] = field(default_factory=dict) def register(self, contract_id: str, adapter_version: str, schema_hash: str = "") -> Dict[str, str]: record = {"adapter_version": adapter_version, "schema_hash": schema_hash} self.contracts[contract_id] = record return record def get_version(self, contract_id: str) -> Optional[str]: return self.contracts.get(contract_id, {}).get("adapter_version") def get_record(self, contract_id: str) -> Dict[str, str]: return dict(self.contracts.get(contract_id, {}))