feat: automate type generation with append-only version log#207
Open
sameh-farouk wants to merge 2 commits intomasterfrom
Open
feat: automate type generation with append-only version log#207sameh-farouk wants to merge 2 commits intomasterfrom
sameh-farouk wants to merge 2 commits intomasterfrom
Conversation
Replace hand-maintained src/types/ with auto-generated types from Subsquid typegen, seeded from all TFChain networks (devnet, qanet, testnet, mainnet). JSONL sorted by specVersion so typegen assigns the lowest version label for each unique event hash. Infrastructure: - Add scripts/merge-versions.js: append-only JSONL merger, sorted output - Add scripts/seed-versions.sh: multi-network metadata discovery (order: devnet -> qanet -> testnet -> mainnet) - Seed typegen/tfchainVersions.jsonl with 93 specVersions from all networks - Update typegen/typegen.json: output directly to src/types/, add 3 events to config that were used by processor but missing from typegen config (FarmCertificationSet, NodeCertificationSet, FarmingPolicyUpdated) - Add Makefile targets: typegen, typegen-seed, typegen-add - Rewrite docs/typeChanges.md with automated workflow, deployment order, resync guidance, and notes on typesBundle.json being frozen Type generation: - Regenerate src/types/ from chain metadata (correct hashes) - Remove src/typesDevelopment/ (no longer needed) - Remove src/types/context.ts (unused) Mapping renames (all verified: identical hashes and type structures): - V49 -> V9: FarmDeleted, FarmPayoutV2, NodeDeleted, NodeUptimeReported, TwinDeleted, TwinStored, TwinUpdated, PricingPolicyStored - V49 -> V19: NodeContractCanceled, NameContractCanceled, PriceStored - V49 -> V12: NodePublicConfigStored - V101 -> V63: FarmStored, FarmUpdated, NodeStored, NodeUpdated - V122 -> V123: All ServiceContract events - V124 -> V125: TwinStored, TwinUpdated - V134 -> V140: NodeExtraFeeSet - Removed dead branches with phantom hashes from wrong field ordering (FarmStored/Updated V63, NodeStored/Updated V63, TwinStored/Updated V49) - Removed unused v63 import from farms.ts
This was referenced Apr 1, 2026
Closed
sameh-farouk
added a commit
that referenced
this pull request
Apr 3, 2026
Existing indexer snapshots on all networks were built with an old typesBundle that had a typo: "dedicatedFarm:" (trailing colon) in the Farm struct. The stored JSON has "dedicatedFarm:" as the key, but the processor expects "dedicatedFarm" (no colon) after the typesBundle was corrected. This causes an assertion failure when decoding pre-V14 FarmStored/FarmUpdated events (specs 63-70). Production 2.12.3 had this workaround in the isV101 branch, which was removed by the typegen automation (PR #207) when relabeling the hash as isV63. The patch sets dedicatedFarm = false on the raw args before decoding. This is safe because farmStored hardcodes dedicatedFarm = false anyway. Remove this workaround after all indexers are resynced with the corrected typesBundle. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
a4fb1b7 to
f97b850
Compare
Existing indexer snapshots on all networks were built with an old typesBundle that had a typo: "dedicatedFarm:" (trailing colon) in the Farm struct. The stored JSON has "dedicatedFarm:" as the key, but the processor expects "dedicatedFarm" (no colon) after the typesBundle was corrected. This causes an assertion failure when decoding pre-V14 FarmStored/FarmUpdated events (specs 63-70). Patch the raw event args by reading the actual value from the colon key (falling back to the normal key for corrected indexers, then false for versions that lack the field entirely), instead of hardcoding false which discarded the real on-chain value. Also read dedicatedFarm from the parsed event in farmStored instead of hardcoding false, so farms created as dedicated are recorded correctly. Production 2.12.3 had the workaround in the isV101 branch, which was removed by the typegen automation when relabeling the hash as isV63. Remove this workaround after all indexers are resynced with the corrected typesBundle. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
f97b850 to
94fdaf4
Compare
Member
Author
|
Tetsed on test vm
|
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
src/types/generation viamake typegenusing Subsquid typegen toolingtypegen/tfchainVersions.jsonl) tracking all processed spec versionsscripts/seed-versions.shto bootstrap the version log from chain metadatascripts/merge-versions.jsto merge new versions into the existing logv122→v123,v124→v127)docs/typeChanges.mdwith complete version change documentationRelated Issues
Test plan
npx tsc --noEmitpasses — no type errorsmake typegenproduces identical output on re-run (deterministic)