How graphprotocol/contracts works
Main Components
• Smart Contracts: This includes the primary “contracts” package. It features numerous subdirectories (like “arbitrum”, “staking”, “governance”, “l2”, etc.) which represent different aspects of the protocol operations on-chain. Also include “token-distribution” since it manages token locks and distributions.
• Data Edge: Represented by the “data-edge” package, this component appears to handle event processing, custom tasks (like bridging events and working with calldata), and may be responsible for interfacing between on-chain events and off-chain indexing or analytics.
• SDK: The “sdk” package is the TypeScript-based interface used to interact with the protocol’s contracts. It covers deployments, network interactions, wrappers around the contracts, and helper utilities.
• Developer Tooling and Configurations: Include “eslint-graph-config” and “solhint-graph-config” as shared linting/formatting utilities to enforce consistent code style in TypeScript and Solidity, respectively.
• CI/CD Infrastructure: Although not part of the “runtime” system, the GitHub workflows in “.github” (build, tests, publish, deployment verification) are essential to the overall system. They ensure continuous integration, testing (via Mocha, Hardhat, etc.), deployment, and versioning (using Changesets).
• That the contracts (on-chain components) are deployed to different networks (Ethereum, Arbitrum, etc.) and are used by both the SDK and Token Distribution modules.
• That the Data Edge package listens to blockchain events (emitted by the contracts) and may interact with other off-chain services to provide indexing.
• Demonstrate that the SDK is a middleware layer that eases contract interaction and deployment (using scripts, tasks, and network deployment ‘actions’ included in the repository).
Architectural Patterns
• Monorepo Structure: Emphasize that all packages share dependencies and versioning via Yarn workspaces.
• Modularization: The separation into discrete packages (contracts, sdk, token-distribution, etc.) allows clear boundaries between on-chain logic, off-chain services, and developer tools.
• CI/CD and Versioning: The use of Changesets for version management and GitHub workflows for automated testing, building, and deployment.
• Blockchain Interaction: A clear delineation of how smart contracts (with audits and tests in their subdirectories) interact with deployment scripts, SDK interfaces, and proxy/upgrades support.