Skip to content

feat(subgraph): introduce mustache templates#96

Open
silent-cipher wants to merge 2 commits intomainfrom
feat/subgraph/mustache-template
Open

feat(subgraph): introduce mustache templates#96
silent-cipher wants to merge 2 commits intomainfrom
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
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🔎 Awaiting review

Development

Successfully merging this pull request may close these issues.

5 participants