How metacontract/mc works
Project Type and Purpose
• This is an open-source, Foundry-based smart-contract framework (“Meta Contract”) that implements the UCS (ERC-7546) upgradeable-clone architecture.
• It provides two core libraries—devkit (for registry, system messaging, utilities, testing scaffolds) and std (standard functions, interfaces, storage)—plus a full documentation site and CI/CD pipelines.
Top-Level Architectural Components
A. Source Code
• src/devkit (core modules: registry, system, test stubs, types, utils)
• src/std (standard functions, internal/protected layers, interfaces, storage)
• lib (Git submodules: forge-std, ucs-contracts)
B. Build & Test
• Foundry (forge): compile, test, deploy
• deployments/*.json: output artifacts
• script/ (Solidity or JS scripts to drive tasks)
• test/ (unit & integration tests for devkit and std)
C. Documentation Site
• site/ (Docusaurus config, docs/ content, React pages, static assets)
• site/script/ (tools to generate and integrate Forge docs into site)
D. CI/CD & Release Automation
• .github/workflows (ci.yml, review_workflow.yml)
• GitHub issue & PR templates
• npm (package.json) and Foundry (foundry.toml, remappings.txt) for dependency and build management
Relationships and Data Flows
• Developer edits src/… → forge build → compiled JSON/artifacts → optionally deployed on-chain
• forge test runs tests in test/ using mock/dummy contexts from devkit
• site/script extracts on-chain API docs from compiled artifacts → merges into site/docs → npm run build → static site
• GitHub Actions triggers on push/PR → runs forge test, lints code, builds docs, publishes to GH Pages or package registry
Key Architectural Patterns & Principles
• Modularity: clear separation between devkit core logic and std library
• Upgradeable-clone (UCS) pattern: clone factories, proxy logic, registry management
• Layered design: internal vs protected vs public interfaces in std functions
• Documentation-as-code: automated generation & integration of API docs
• Continuous integration: automated testing, docs build, and release workflows
Essential Details to Capture
• Names of key modules (e.g., devkit.registry, std.functions.protected)
• Data/artifact formats (JSON ABI, bytecode, markdown docs)
• Flow of test mocks and dummy contexts from devkit into tests
• Integration points (site/script ↔ forge docs, CI/CD ↔ package publish)
• Upgradeable-clone factory interaction with registry and on-chain proxies