Skip to content

feat(subgraph): introduce mustache templates#96

Merged
kaola526 merged 3 commits into
mainfrom
feat/subgraph/mustache-template
May 13, 2026
Merged

feat(subgraph): introduce mustache templates#96
kaola526 merged 3 commits into
mainfrom
feat/subgraph/mustache-template

Conversation

@silent-cipher
Copy link
Copy Markdown
Collaborator

Summary

This PR introduces a template-based build system using Mustache templates to streamline subgraph deployment across different networks (mainnet and calibration). 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 build

After

# Single command
npm run build:mainnet

Breaking Changes

None - this is an internal build system change that doesn't affect the deployed subgraph functionality.

Related to #89

Copilot AI review requested due to automatic review settings April 2, 2026 06:30
@FilOzzy FilOzzy added this to FOC Apr 2, 2026
@github-project-automation github-project-automation Bot moved this to 📌 Triage in FOC Apr 2, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.yaml and src/generated/constants.ts from config/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.

Comment thread subgraph/utils/index.ts Outdated
Comment thread subgraph/package.json Outdated
Comment thread subgraph/.gitignore Outdated
@silent-cipher silent-cipher self-assigned this Apr 2, 2026
@silent-cipher silent-cipher requested a review from kaola526 April 2, 2026 08:15
@rjan90 rjan90 moved this from 📌 Triage to 🔎 Awaiting review in FOC Apr 2, 2026
@rjan90 rjan90 added this to the M4.2: mainnet GA milestone Apr 2, 2026
@BigLep BigLep requested review from a team and juliangruber April 2, 2026 17:13
@BigLep
Copy link
Copy Markdown
Contributor

BigLep commented Apr 8, 2026

@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.

Comment thread subgraph/.gitignore
Comment thread subgraph/config/network.json Outdated
@BigLep BigLep moved this from 🔎 Awaiting review to ⌨️ In Progress in FOC Apr 23, 2026
@BigLep BigLep moved this from ⌨️ In Progress to 🔎 Awaiting review in FOC May 1, 2026
@BigLep BigLep moved this from 🔎 Awaiting review to ⌨️ In Progress in FOC May 1, 2026
@BigLep BigLep moved this from ⌨️ In Progress to 🔎 Awaiting review in FOC May 4, 2026
@BigLep BigLep mentioned this pull request May 8, 2026
@BigLep
Copy link
Copy Markdown
Contributor

BigLep commented May 12, 2026

@FilOzone/storswift : any concerns with merging this? This has been open for over a month now...

@github-project-automation github-project-automation Bot moved this from 🔎 Awaiting review to ✔️ Approved by reviewer in FOC May 13, 2026
@kaola526 kaola526 merged commit 1b7c78b into main May 13, 2026
3 checks passed
@github-project-automation github-project-automation Bot moved this from ✔️ Approved by reviewer to 🎉 Done in FOC May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🎉 Done

Development

Successfully merging this pull request may close these issues.

7 participants