feat(subgraph): introduce mustache templates#96
Open
silent-cipher wants to merge 2 commits intomainfrom
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Introduces a Mustache-template-based build pipeline for the subgraph so that network-specific configuration (mainnet vs calibration) is centralized in subgraph/config/network.json, and network-targeted builds can generate the correct subgraph.yaml and constants automatically.
Changes:
- Added Mustache templates + generation scripts to produce
subgraph.yamlandsrc/generated/constants.tsfromconfig/network.json. - Updated subgraph mappings to consume generated constants (
ContractConstants) instead of hardcoded per-network values. - Removed legacy per-network subgraph YAML files and updated build scripts/docs to use
npm run build:<network>.
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| subgraph/utils/index.ts | Re-exports generated ContractConstants and removes hardcoded proving-period constants. |
| subgraph/src/pdp-verifier.ts | Switches proving-period config to generated ContractConstants. |
| subgraph/templates/subgraph.template.yaml | Parameterizes network, address, and start block via Mustache. |
| subgraph/templates/constants.template.ts | New Mustache template for generated contract constants. |
| subgraph/config/network.json | New centralized per-network configuration source. |
| subgraph/scripts/utils/config-loader.js | New helper to load/validate selected network config. |
| subgraph/scripts/generate-constants.js | New generator for src/generated/constants.ts. |
| subgraph/scripts/generate-config.js | New generator for subgraph.yaml. |
| subgraph/package.json | Adds generation + network build scripts and mustache dependency. |
| subgraph/package-lock.json | Updates lockfile for new deps and Graph tooling versions. |
| subgraph/.gitignore | Ignores generated subgraph.yaml. |
| subgraph/subgraph_mainnet.yaml | Removed legacy mainnet manifest file. |
| subgraph/subgraph_testnet.yaml | Removed legacy testnet manifest file. |
| README.md | Documents the new configuration and build flow. |
Files not reviewed (1)
- subgraph/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
|
@FilOzone/storswift : can you please review? @juliangruber : it may be good to look at this since I assume we'll want to do something similar with the filecoin-pay subgraph. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces a template-based build system using Mustache templates to streamline subgraph deployment across different networks (
mainnetandcalibration). The new system centralizes network configuration in a single JSON file and automatically generates network-specific constants and YAML files.Migration Guide
Before
cp subgraph_mainnet.yaml subgraph.yaml # Edit utils/index.ts to set constants graph codegen graph buildAfter
# Single command npm run build:mainnetBreaking Changes
None - this is an internal build system change that doesn't affect the deployed subgraph functionality.
Related to #89