Skip to content

Conversation

@nikbhintade
Copy link
Member

@nikbhintade nikbhintade commented Oct 22, 2025

Added 6 new templates that users can now select directly from the CLI. Currently, all of these templates are available only in TypeScript.

CLI Updates:

  • Fixed an issue where the CLI listed templates for all languages, even when only TypeScript versions existed.
  • Updated logic to show templates only if that language is supported for them.
  • Updated failing tests to reflect the new language-based template filtering.

Summary by CodeRabbit

  • New Features

    • Added multiple new init templates (topic-filtering, wildcard-indexing, on-block-handler, effects-api, factory-indexer, multichain-indexer) with sample configs, handlers, and GraphQL types.
  • Documentation

    • Added README guides, example .env files, and .gitignore entries for each new template.
  • Chores

    • CLI interactive init and help now assume TypeScript only; JavaScript/ReScript init options and legacy template artifacts removed.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 22, 2025

Walkthrough

Adds multiple new TypeScript indexer templates and static assets; extends CLI Template enum with new variants; restricts interactive init and template scaffolding to TypeScript; removes JavaScript/ReScript branches, many legacy JS/Rescript templates, and related tests and build steps.

Changes

Cohort / File(s) Change Summary
CLI help & args
codegenerator/cli/CommandLineHelp.md, codegenerator/cli/src/cli_args/init_config.rs
Narrowed CLI language choices to TypeScript; added new evm::Template variants (Greeter, Erc20, TopicFiltering, WildcardIndexing, OnBlockHandler, EffectsAPI, FactoryIndexer, MultichainIndexer) with strum serializations.
Interactive init
codegenerator/cli/src/cli_args/interactive_init/mod.rs
Removed interactive language selection; hard-coded Language::TypeScript in prompt_missing_init_args; removed FromStr import.
Template registry & tests
codegenerator/cli/src/template_dirs.rs
Added mappings for new templates to directory names; updated tests to assume TypeScript only and added assertions for static/shared and dynamic shared init templates.
Init executor & templating
codegenerator/cli/src/executor/init.rs, codegenerator/cli/src/hbs_templating/*.rs, codegenerator/cli/src/hbs_templating/init_templates.rs
Removed JS/ReScript codegen/build branches and related flags (is_rescript/is_javascript); simplified templating to TypeScript-only paths; updated tests.
Graph migration mapping
codegenerator/cli/src/config_parsing/graph_migration/mod.rs
Removed JS/ReScript handler-directory cases; tests now assert TypeScript handler path only.
New static templates — Effects API
codegenerator/cli/templates/static/effects_api_template/shared/*, .../typescript/*
Added README, schema.graphql (UniswapV3 types), .env.example, .gitignore, TypeScript config.yaml, EventHandlers.ts (effects for token decimals), and tsconfig.json.
New static templates — Factory indexer
codegenerator/cli/templates/static/factory_indexer_template/shared/*, .../typescript/*
Added README, schema.graphql (PoolCreated, Swap), .env.example, .gitignore, TypeScript config.yaml, EventHandlers.ts (pool registration & swaps), and tsconfig.json.
New static templates — Multichain indexer
codegenerator/cli/templates/static/multichain_indexer_template/shared/*, .../typescript/*
Added README, schema.graphql (FeeAmountEnabled, OwnerChanged, PoolCreated), .gitignore, multi-network config.yaml, EventHandlers.ts, and tsconfig.json.
New static templates — On-block handler
codegenerator/cli/templates/static/onblock_handler_template/shared/*, .../typescript/*
Added README, schema.graphql (TotalSupply, TotalSupplySnapshot), .env.example, .gitignore, TypeScript config.yaml, EventHandlers.ts (onBlock snapshots, mint/burn logic), and tsconfig.json.
New static templates — Topic filtering
codegenerator/cli/templates/static/topic_filtering_template/shared/*, .../typescript/*
Added README, schema.graphql (Transfer), .env.example, .gitignore, TypeScript config.yaml (topic-based eventFilters), EventHandlers.ts (topic-filtered handlers), and tsconfig.json.
New static templates — Wildcard indexing
codegenerator/cli/templates/static/wildcard_indexing_template/shared/*, .../typescript/*
Added README, schema.graphql (Transfer), .env.example, .gitignore, TypeScript config.yaml (wildcard: true), EventHandlers.ts (wildcard handler), and tsconfig.json.
Removed legacy templates & tests
codegenerator/cli/templates/static/erc20_template/*, .../greeter*, .../greeteronfuel*, .../blank_template/rescript/*
Deleted many JavaScript/ReScript template files (configs, handlers, tests, rescript.json) and supporting artifacts; removed JS/Rescript build/test artifacts and associated tests.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant Interactive as prompt_ecosystem
    participant Registry as TemplateRegistry
    participant Scaffolder as InitScaffolder

    User->>CLI: run `envio init`
    CLI->>Interactive: prompt_missing_init_args()
    Note right of Interactive #EDF7EA: language set to TypeScript (hard-coded)
    Interactive->>Registry: request available templates for TypeScript
    Registry-->>Interactive: list(TypeScript-supported templates)
    Interactive-->>User: display templates
    User->>CLI: select template
    CLI->>Scaffolder: scaffold(template, Language::TypeScript)
    Scaffolder-->>CLI: write files (config, schema, handlers, README, tsconfig)
Loading
sequenceDiagram
    participant Chain as EventSource
    participant Handler as GeneratedHandler (TypeScript)
    participant Context as PersistenceContext

    Chain->>Handler: emits event
    Handler->>Handler: parse & transform event -> entity
    Handler->>Context: context.Entity.set(entity)
    Context-->>Handler: ack
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Areas to focus during review:

  • init_config.rs enum additions and strum(serialize = "...") strings for correctness.
  • template_dirs.rs directory mappings and updated tests asserting static/shared template presence.
  • Interactive init signature change and hard-coded TypeScript selection in interactive_init/mod.rs.
  • TypeScript EventHandlers for Effects API and onBlock templates (async effects, external RPC usage, persistence).
  • Confirm deletions of legacy JS/Rescript templates do not break external consumers.

Possibly related PRs

Suggested labels

codex

Suggested reviewers

  • JonoPrest
  • DZakh

Poem

🐰 I hopped through templates fresh and bright,
TypeScript only — moonlit night,
Effects fetch decimals, factories spring,
Snapshots, filters, wildcards sing,
Scaffolds laid out — a joyful bite.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 53.33% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "New Templates & Changes in CLI" directly captures the primary objective of the changeset. The PR's main purpose is to add six new templates (TopicFiltering, WildcardIndexing, OnBlockHandler, EffectsAPI, FactoryIndexer, and MultichainIndexer) that users can select from the CLI, with supporting changes to the CLI initialization logic to filter templates by language support. The title accurately references both the new templates (the primary change) and the CLI modifications (supporting infrastructure), making it clearly related to the actual changes made. While "Changes in CLI" could theoretically be more specific, the combination with "New Templates" provides sufficient clarity about the main modification.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/new-templates

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 629695a and eb8eb09.

📒 Files selected for processing (3)
  • codegenerator/cli/src/cli_args/interactive_init/mod.rs (2 hunks)
  • codegenerator/cli/src/template_dirs.rs (2 hunks)
  • codegenerator/cli/templates/static/greeteronfuel_template/typescript/config.yaml (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
codegenerator/cli/**

📄 CodeRabbit inference engine (.cursor/rules/navigation.mdc)

The Rust CLI lives in codegenerator/cli

Files:

  • codegenerator/cli/src/cli_args/interactive_init/mod.rs
  • codegenerator/cli/templates/static/greeteronfuel_template/typescript/config.yaml
  • codegenerator/cli/src/template_dirs.rs
🧠 Learnings (9)
📓 Common learnings
Learnt from: CR
PR: enviodev/hyperindex#0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-08-11T08:42:57.311Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.ts : After any change to TypeScript files, run `pnpm tsc --noEmit` to ensure successful compilation
📚 Learning: 2025-08-11T08:42:57.311Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-08-11T08:42:57.311Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.ts : Ensure address matching uses consistent casing: use lowercase keys in config objects and compare against `address.toLowerCase()`

Applied to files:

  • codegenerator/cli/templates/static/greeteronfuel_template/typescript/config.yaml
📚 Learning: 2025-10-13T12:27:30.803Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-10-13T12:27:30.803Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/config.yaml : Refactor to contract-specific handler files in config.yaml and remove the single EventHandlers.ts reference

Applied to files:

  • codegenerator/cli/templates/static/greeteronfuel_template/typescript/config.yaml
📚 Learning: 2025-10-13T12:26:45.351Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: .cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-10-13T12:26:45.351Z
Learning: Applies to config.yaml : Set `preload_handlers: true` when using the Effect API for external calls

Applied to files:

  • codegenerator/cli/templates/static/greeteronfuel_template/typescript/config.yaml
📚 Learning: 2025-08-11T08:49:57.399Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: scenarios/test_codegen/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-08-11T08:49:57.399Z
Learning: Applies to scenarios/test_codegen/**/config.yaml : Enable preload optimizations by adding preload_handlers: true in config.yaml

Applied to files:

  • codegenerator/cli/templates/static/greeteronfuel_template/typescript/config.yaml
📚 Learning: 2025-08-11T08:47:04.346Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: scenarios/fuel_test/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-08-11T08:47:04.346Z
Learning: Applies to scenarios/fuel_test/**/config.yaml : Enable preload optimizations by adding `preload_handlers: true` in config.yaml

Applied to files:

  • codegenerator/cli/templates/static/greeteronfuel_template/typescript/config.yaml
📚 Learning: 2025-08-11T08:42:57.311Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-08-11T08:42:57.311Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/config.yaml : Add `preload_handlers: true` to config.yaml to enable preload optimisations

Applied to files:

  • codegenerator/cli/templates/static/greeteronfuel_template/typescript/config.yaml
📚 Learning: 2025-10-13T12:27:30.803Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-10-13T12:27:30.803Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/config.yaml : Set preload_handlers: true when using Effect API-based external calls and ensure necessary transaction field selections are configured

Applied to files:

  • codegenerator/cli/templates/static/greeteronfuel_template/typescript/config.yaml
📚 Learning: 2025-10-21T16:31:22.127Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-10-21T16:31:22.127Z
Learning: Applies to codegenerator/cli/src/hbs_templating/codegen_templates.rs : hbs_templating/codegen_templates.rs feeds templates

Applied to files:

  • codegenerator/cli/src/template_dirs.rs
🔇 Additional comments (5)
codegenerator/cli/templates/static/greeteronfuel_template/typescript/config.yaml (1)

15-18: ✓ Preload optimization correctly enabled for template.

The addition of preload_handlers: true aligns with best practices and the contextual comments clearly explain the implications (handlers run twice, use Effect API for external calls). This follows the documented learning for enabling preload optimizations in Fuel indexer templates.

codegenerator/cli/src/template_dirs.rs (3)

21-26: LGTM! Clean addition of new template mappings.

The six new template variant mappings follow the established pattern and naming conventions. The snake_case directory names are consistent with existing templates.


441-482: Good update to reflect TypeScript-only template availability.

The test now correctly validates only TypeScript templates, matching the PR's stated scope. The enhanced error messages with template and language details will improve debugging when directory structures are incorrect. The addition of the dynamic shared init template check (lines 478-481) is a good catch for completeness.


485-524: LGTM! Test extraction correctly scoped to TypeScript.

The test appropriately restricts EVM and FUEL template extraction to TypeScript (matching template availability), while preserving blank template extraction for all languages. The improved error messages and clear temp directory naming enhance test maintainability.

codegenerator/cli/src/cli_args/interactive_init/mod.rs (1)

142-142: No issues found—downstream compatibility verified.

The Language enum now contains only the TypeScript variant, and all match statements are exhaustive. No remaining references to JavaScript or ReScript exist in the codebase. The hardcoding of Language::TypeScript at line 142 aligns correctly with the enum definition and template handling logic.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 16

♻️ Duplicate comments (5)
codegenerator/cli/templates/static/multichain_indexer_template/shared/.env.example (1)

2-2: Remove quotes around the placeholder value.

Same issue as in codegenerator/cli/templates/static/effects_api_template/shared/.env.example.

- ENVIO_API_TOKEN="<YOUR-API-TOKEN>"
+ ENVIO_API_TOKEN=<YOUR-API-TOKEN>
codegenerator/cli/templates/static/factory_indexer_template/shared/.env.example (1)

2-2: Remove quotes around the placeholder value.

Same issue as in codegenerator/cli/templates/static/effects_api_template/shared/.env.example.

- ENVIO_API_TOKEN="<YOUR-API-TOKEN>"
+ ENVIO_API_TOKEN=<YOUR-API-TOKEN>
codegenerator/cli/templates/static/wildcard_indexing_template/shared/.env.example (1)

2-2: Remove quotes around the placeholder value.

Same issue as in codegenerator/cli/templates/static/effects_api_template/shared/.env.example.

- ENVIO_API_TOKEN="<YOUR-API-TOKEN>"
+ ENVIO_API_TOKEN=<YOUR-API-TOKEN>
codegenerator/cli/templates/static/onblock_handler_template/shared/.env.example (1)

2-2: Remove quotes around the placeholder value.

Same issue as in codegenerator/cli/templates/static/effects_api_template/shared/.env.example.

- ENVIO_API_TOKEN="<YOUR-API-TOKEN>"
+ ENVIO_API_TOKEN=<YOUR-API-TOKEN>
codegenerator/cli/templates/static/topic_filtering_template/shared/.env.example (1)

2-2: Remove quotes around the placeholder value.

Same issue as in codegenerator/cli/templates/static/effects_api_template/shared/.env.example.

- ENVIO_API_TOKEN="<YOUR-API-TOKEN>"
+ ENVIO_API_TOKEN=<YOUR-API-TOKEN>
🧹 Nitpick comments (22)
codegenerator/cli/templates/static/onblock_handler_template/shared/.gitignore (1)

1-35: Remove duplicated ignore patterns.

The .gitignore file contains unnecessary duplicate entries that can be consolidated:

  • Line 2 and 16 both specify *.obj
  • Line 8 and 18 both specify *.annot

While duplicates don't affect functionality, removing them improves clarity and maintainability.

Apply this diff to deduplicate the patterns:

 *.exe
 *.obj
 *.out
 *.compile
 *.native
 *.byte
 *.cmo
 *.annot
 *.cmi
 *.cmx
 *.cmt
 *.cmti
 *.cma
 *.a
 *.cmxa
-*.obj
 *~
-*.annot
 *.cmj
 *.bak
codegenerator/cli/templates/static/factory_indexer_template/shared/.gitignore (1)

1-35: Remove duplicated ignore patterns.

Like the onblock_handler_template .gitignore, this file contains unnecessary duplicate entries (*.obj on lines 2 and 16; *.annot on lines 8 and 18). Consolidate to improve maintainability.

Apply this diff to deduplicate the patterns:

 *.exe
 *.obj
 *.out
 *.compile
 *.native
 *.byte
 *.cmo
 *.annot
 *.cmi
 *.cmx
 *.cmt
 *.cmti
 *.cma
 *.a
 *.cmxa
-*.obj
 *~
-*.annot
 *.cmj
 *.bak
codegenerator/cli/templates/static/wildcard_indexing_template/shared/.gitignore (1)

1-35: Remove duplicated ignore patterns (consistent issue across templates).

This .gitignore file shares the same duplication issue as the other templates' .gitignore files in this PR (*.obj appears at lines 2 and 16; *.annot appears at lines 8 and 18). Consolidating these across all template .gitignore files will improve consistency and maintainability.

Apply this diff to deduplicate:

 *.exe
 *.obj
 *.out
 *.compile
 *.native
 *.byte
 *.cmo
 *.annot
 *.cmi
 *.cmx
 *.cmt
 *.cmti
 *.cma
 *.a
 *.cmxa
-*.obj
 *~
-*.annot
 *.cmj
 *.bak
codegenerator/cli/src/cli_args/interactive_init/mod.rs (1)

79-84: Consider a more professional comment style.

The emoji-prefixed comment is informal for production code.

-                    // ✅ Filter templates based on selected language
+                    // Filter templates based on selected language
                     let options: Vec<_> = evm::Template::iter()
                         .filter(|t| t.supported_languages().contains(&selected_language))
                         .collect();
codegenerator/cli/templates/static/effects_api_template/typescript/tsconfig.json (1)

21-21: Add newline at end of file.

The file is missing a trailing newline, which is a POSIX standard and expected by most editors and linters.

codegenerator/cli/templates/static/multichain_indexer_template/shared/README.md (1)

44-44: Minor grammar improvement.

Consider changing "While indexer is running" to "While the indexer is running" for better readability.

codegenerator/cli/templates/static/topic_filtering_template/typescript/src/EventHandler.ts (1)

23-23: Add newline at end of file.

The file is missing a trailing newline, which is a POSIX standard and expected by most editors and linters.

codegenerator/cli/templates/static/multichain_indexer_template/shared/.gitignore (2)

1-35: Remove duplicate patterns.

The .gitignore contains duplicate entries:

  • *.obj appears on both lines 2 and 16
  • *.annot appears on both lines 8 and 18

Apply this diff to remove duplicates:

 *.exe
 *.obj
 *.out
 *.compile
 *.native
 *.byte
 *.cmo
 *.annot
 *.cmi
 *.cmx
 *.cmt
 *.cmti
 *.cma
 *.a
 *.cmxa
-*.obj
 *~
-*.annot
 *.cmj
 *.bak
 lib/*
 *.mlast
 *.mliast
 .vscode
 .merlin
 .bsb.lock
 node_modules/
 build/
 benchmarks/
 artifacts
 cache
 *.res.js
 *.res.mjs
 generated
 .env

35-35: Add newline at end of file.

The file is missing a trailing newline, which is a POSIX standard and expected by most editors and linters.

codegenerator/cli/templates/static/multichain_indexer_template/typescript/config.yaml (2)

12-12: Consider using realistic start_block values.

Setting start_block: 0 will index from the genesis block, which can be extremely slow and resource-intensive for mainnet chains. For a template, consider using more recent block numbers or documenting that users should update these values.


30-30: Add newline at end of file.

The file is missing a trailing newline, which is a POSIX standard and expected by most editors and linters.

codegenerator/cli/templates/static/topic_filtering_template/shared/README.md (2)

7-7: Consider simplifying the phrase.

As flagged by static analysis, "add an additional feature" is somewhat redundant. Consider simplifying to "add a feature" or "we add filtering" for clearer prose.


50-50: Minor grammar improvement.

Consider changing "While indexer is running" to "While the indexer is running" for better readability.

codegenerator/cli/templates/static/topic_filtering_template/shared/.gitignore (2)

1-35: Remove duplicate patterns.

The .gitignore contains duplicate entries:

  • *.obj appears on both lines 2 and 16
  • *.annot appears on both lines 8 and 18

Apply this diff to remove duplicates:

 *.exe
 *.obj
 *.out
 *.compile
 *.native
 *.byte
 *.cmo
 *.annot
 *.cmi
 *.cmx
 *.cmt
 *.cmti
 *.cma
 *.a
 *.cmxa
-*.obj
 *~
-*.annot
 *.cmj
 *.bak
 lib/*
 *.mlast
 *.mliast
 .vscode
 .merlin
 .bsb.lock
 node_modules/
 build/
 benchmarks/
 artifacts
 cache
 *.res.js
 *.res.mjs
 generated
 .env

35-35: Add newline at end of file.

The file is missing a trailing newline, which is a POSIX standard and expected by most editors and linters.

codegenerator/cli/templates/static/onblock_handler_template/typescript/config.yaml (2)

10-10: Consider using realistic start_block value.

Setting start_block: 0 will index from the genesis block, which can be extremely slow and resource-intensive for mainnet. For a template, consider using a more recent block number or documenting that users should update this value.


16-16: Add newline at end of file.

The file is missing a trailing newline, which is a POSIX standard and expected by most editors and linters.

codegenerator/cli/templates/static/multichain_indexer_template/typescript/src/EventHandlers.ts (1)

11-19: LGTM; multichain-safe IDs are correct. Minor nits.

Good use of ${event.chainId}_... in entity IDs. Optionally, consider:

  • Using ${event.chainId}_${event.transaction.hash}_${event.logIndex} for stronger uniqueness across reorgs.
  • Normalizing addresses (e.g., toLowerCase) for consistent querying.

Also applies to: 21-29, 31-42

codegenerator/cli/templates/static/onblock_handler_template/typescript/src/EventHandlers.ts (1)

13-18: Avoid hardcoding chain: 1 for onBlock.

Parameterize or derive from config so the template works on non-mainnet networks and testnets. Example: pass chain(s) via config.yaml or expose a CHAIN_ID env. Based on learnings.

codegenerator/cli/templates/static/effects_api_template/typescript/src/EventHandlers.ts (1)

35-43: Parallelize token metadata lookups for performance.

Fetch token0/token1 decimals concurrently.

-UniswapV3Factory.PoolCreated.handler(async ({ event, context }) => {
-  const token0Details = await context.effect(fetchTokenDetails, {
-    token: event.params.token0,
-  });
-
-  const token1Details = await context.effect(fetchTokenDetails, {
-    token: event.params.token1,
-  });
+UniswapV3Factory.PoolCreated.handler(async ({ event, context }) => {
+  const [token0Details, token1Details] = await Promise.all([
+    context.effect(fetchTokenDetails, { token: event.params.token0 }),
+    context.effect(fetchTokenDetails, { token: event.params.token1 }),
+  ]);

Also consider removing console.log or switching to a template-friendly logger.

codegenerator/cli/templates/static/factory_indexer_template/typescript/src/EventHandlers.ts (2)

19-21: Register dynamic contracts before handling the creating event.

Place contractRegister above the PoolCreated handler to ensure deterministic registration. Based on learnings.

+UniswapV3Factory.PoolCreated.contractRegister(({ event, context }) => {
+    context.addUniswapV3Pool(event.params.pool);
+});
+
 UniswapV3Factory.PoolCreated.handler(async ({ event, context }) => {
@@
     context.UniswapV3Factory_PoolCreated.set(entity);
 });
-
-UniswapV3Factory.PoolCreated.contractRegister(({ event, context }) => {
-    context.addUniswapV3Pool(event.params.pool);
-});

Also applies to: 6-17


23-36: LGTM; event-to-entity mapping looks correct.

IDs include chainId, and Swap fields align with typical Uniswap v3 event params.

Normalize sender/recipient to lowercase for consistent querying.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 130db80 and 6efc6c9.

📒 Files selected for processing (46)
  • codegenerator/cli/CommandLineHelp.md (1 hunks)
  • codegenerator/cli/src/cli_args/init_config.rs (1 hunks)
  • codegenerator/cli/src/cli_args/interactive_init/mod.rs (4 hunks)
  • codegenerator/cli/src/template_dirs.rs (3 hunks)
  • codegenerator/cli/templates/static/effects_api_template/shared/.env.example (1 hunks)
  • codegenerator/cli/templates/static/effects_api_template/shared/.gitignore (1 hunks)
  • codegenerator/cli/templates/static/effects_api_template/shared/README.md (1 hunks)
  • codegenerator/cli/templates/static/effects_api_template/shared/schema.graphql (1 hunks)
  • codegenerator/cli/templates/static/effects_api_template/typescript/config.yaml (1 hunks)
  • codegenerator/cli/templates/static/effects_api_template/typescript/src/EventHandlers.ts (1 hunks)
  • codegenerator/cli/templates/static/effects_api_template/typescript/tsconfig.json (1 hunks)
  • codegenerator/cli/templates/static/factory_indexer_template/shared/.env.example (1 hunks)
  • codegenerator/cli/templates/static/factory_indexer_template/shared/.gitignore (1 hunks)
  • codegenerator/cli/templates/static/factory_indexer_template/shared/README.md (1 hunks)
  • codegenerator/cli/templates/static/factory_indexer_template/shared/schema.graphql (1 hunks)
  • codegenerator/cli/templates/static/factory_indexer_template/typescript/config.yaml (1 hunks)
  • codegenerator/cli/templates/static/factory_indexer_template/typescript/src/EventHandlers.ts (1 hunks)
  • codegenerator/cli/templates/static/factory_indexer_template/typescript/tsconfig.json (1 hunks)
  • codegenerator/cli/templates/static/multichain_indexer_template/shared/.env.example (1 hunks)
  • codegenerator/cli/templates/static/multichain_indexer_template/shared/.gitignore (1 hunks)
  • codegenerator/cli/templates/static/multichain_indexer_template/shared/README.md (1 hunks)
  • codegenerator/cli/templates/static/multichain_indexer_template/shared/schema.graphql (1 hunks)
  • codegenerator/cli/templates/static/multichain_indexer_template/typescript/config.yaml (1 hunks)
  • codegenerator/cli/templates/static/multichain_indexer_template/typescript/src/EventHandlers.ts (1 hunks)
  • codegenerator/cli/templates/static/multichain_indexer_template/typescript/tsconfig.json (1 hunks)
  • codegenerator/cli/templates/static/onblock_handler_template/shared/.env.example (1 hunks)
  • codegenerator/cli/templates/static/onblock_handler_template/shared/.gitignore (1 hunks)
  • codegenerator/cli/templates/static/onblock_handler_template/shared/README.md (1 hunks)
  • codegenerator/cli/templates/static/onblock_handler_template/shared/schema.graphql (1 hunks)
  • codegenerator/cli/templates/static/onblock_handler_template/typescript/config.yaml (1 hunks)
  • codegenerator/cli/templates/static/onblock_handler_template/typescript/src/EventHandlers.ts (1 hunks)
  • codegenerator/cli/templates/static/onblock_handler_template/typescript/tsconfig.json (1 hunks)
  • codegenerator/cli/templates/static/topic_filtering_template/shared/.env.example (1 hunks)
  • codegenerator/cli/templates/static/topic_filtering_template/shared/.gitignore (1 hunks)
  • codegenerator/cli/templates/static/topic_filtering_template/shared/README.md (1 hunks)
  • codegenerator/cli/templates/static/topic_filtering_template/shared/schema.graphql (1 hunks)
  • codegenerator/cli/templates/static/topic_filtering_template/typescript/config.yaml (1 hunks)
  • codegenerator/cli/templates/static/topic_filtering_template/typescript/src/EventHandler.ts (1 hunks)
  • codegenerator/cli/templates/static/topic_filtering_template/typescript/tsconfig.json (1 hunks)
  • codegenerator/cli/templates/static/wildcard_indexing_template/shared/.env.example (1 hunks)
  • codegenerator/cli/templates/static/wildcard_indexing_template/shared/.gitignore (1 hunks)
  • codegenerator/cli/templates/static/wildcard_indexing_template/shared/README.md (1 hunks)
  • codegenerator/cli/templates/static/wildcard_indexing_template/shared/schema.graphql (1 hunks)
  • codegenerator/cli/templates/static/wildcard_indexing_template/typescript/config.yaml (1 hunks)
  • codegenerator/cli/templates/static/wildcard_indexing_template/typescript/src/EventHandler.ts (1 hunks)
  • codegenerator/cli/templates/static/wildcard_indexing_template/typescript/tsconfig.json (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
codegenerator/cli/**

📄 CodeRabbit inference engine (.cursor/rules/navigation.mdc)

The Rust CLI lives in codegenerator/cli

Files:

  • codegenerator/cli/templates/static/factory_indexer_template/shared/schema.graphql
  • codegenerator/cli/templates/static/onblock_handler_template/shared/README.md
  • codegenerator/cli/src/cli_args/interactive_init/mod.rs
  • codegenerator/cli/templates/static/onblock_handler_template/shared/schema.graphql
  • codegenerator/cli/templates/static/factory_indexer_template/shared/README.md
  • codegenerator/cli/templates/static/topic_filtering_template/typescript/config.yaml
  • codegenerator/cli/templates/static/multichain_indexer_template/typescript/config.yaml
  • codegenerator/cli/templates/static/multichain_indexer_template/typescript/tsconfig.json
  • codegenerator/cli/templates/static/effects_api_template/typescript/config.yaml
  • codegenerator/cli/src/template_dirs.rs
  • codegenerator/cli/templates/static/effects_api_template/shared/schema.graphql
  • codegenerator/cli/templates/static/wildcard_indexing_template/shared/schema.graphql
  • codegenerator/cli/templates/static/effects_api_template/shared/README.md
  • codegenerator/cli/templates/static/effects_api_template/typescript/tsconfig.json
  • codegenerator/cli/CommandLineHelp.md
  • codegenerator/cli/templates/static/effects_api_template/typescript/src/EventHandlers.ts
  • codegenerator/cli/templates/static/wildcard_indexing_template/shared/README.md
  • codegenerator/cli/templates/static/topic_filtering_template/shared/README.md
  • codegenerator/cli/templates/static/onblock_handler_template/typescript/config.yaml
  • codegenerator/cli/templates/static/wildcard_indexing_template/typescript/src/EventHandler.ts
  • codegenerator/cli/templates/static/topic_filtering_template/typescript/tsconfig.json
  • codegenerator/cli/templates/static/topic_filtering_template/typescript/src/EventHandler.ts
  • codegenerator/cli/templates/static/wildcard_indexing_template/typescript/tsconfig.json
  • codegenerator/cli/templates/static/onblock_handler_template/typescript/tsconfig.json
  • codegenerator/cli/templates/static/factory_indexer_template/typescript/src/EventHandlers.ts
  • codegenerator/cli/templates/static/multichain_indexer_template/typescript/src/EventHandlers.ts
  • codegenerator/cli/templates/static/factory_indexer_template/typescript/config.yaml
  • codegenerator/cli/templates/static/multichain_indexer_template/shared/schema.graphql
  • codegenerator/cli/templates/static/topic_filtering_template/shared/schema.graphql
  • codegenerator/cli/templates/static/wildcard_indexing_template/typescript/config.yaml
  • codegenerator/cli/templates/static/multichain_indexer_template/shared/README.md
  • codegenerator/cli/templates/static/factory_indexer_template/typescript/tsconfig.json
  • codegenerator/cli/src/cli_args/init_config.rs
  • codegenerator/cli/templates/static/onblock_handler_template/typescript/src/EventHandlers.ts
🧠 Learnings (19)
📚 Learning: 2025-08-11T08:47:04.346Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: scenarios/fuel_test/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-08-11T08:47:04.346Z
Learning: Always load and reference HyperIndex docs and example indexers during development (docs.envio.dev HyperIndex, Uniswap v4 indexer, Safe indexer)

Applied to files:

  • codegenerator/cli/templates/static/factory_indexer_template/shared/README.md
  • codegenerator/cli/templates/static/wildcard_indexing_template/shared/README.md
  • codegenerator/cli/templates/static/multichain_indexer_template/shared/README.md
📚 Learning: 2025-08-11T08:49:57.399Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: scenarios/test_codegen/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-08-11T08:49:57.399Z
Learning: Include HyperIndex documentation and example indexers (Uniswap v4 and Safe) in the context during development

Applied to files:

  • codegenerator/cli/templates/static/factory_indexer_template/shared/README.md
  • codegenerator/cli/templates/static/multichain_indexer_template/shared/README.md
📚 Learning: 2025-10-21T16:31:22.099Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-10-21T16:31:22.099Z
Learning: Compiled .js artifacts can be ignored

Applied to files:

  • codegenerator/cli/templates/static/topic_filtering_template/shared/.gitignore
  • codegenerator/cli/templates/static/factory_indexer_template/shared/.gitignore
  • codegenerator/cli/templates/static/onblock_handler_template/shared/.gitignore
  • codegenerator/cli/templates/static/wildcard_indexing_template/shared/.gitignore
  • codegenerator/cli/templates/static/multichain_indexer_template/shared/.gitignore
  • codegenerator/cli/templates/static/effects_api_template/shared/.gitignore
📚 Learning: 2025-10-13T12:27:30.803Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-10-13T12:27:30.803Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/config.yaml : Refactor to contract-specific handler files in config.yaml and remove the single EventHandlers.ts reference

Applied to files:

  • codegenerator/cli/templates/static/topic_filtering_template/typescript/config.yaml
  • codegenerator/cli/templates/static/multichain_indexer_template/typescript/config.yaml
  • codegenerator/cli/templates/static/effects_api_template/typescript/config.yaml
  • codegenerator/cli/templates/static/effects_api_template/typescript/src/EventHandlers.ts
  • codegenerator/cli/templates/static/onblock_handler_template/typescript/config.yaml
  • codegenerator/cli/templates/static/wildcard_indexing_template/typescript/src/EventHandler.ts
  • codegenerator/cli/templates/static/topic_filtering_template/typescript/src/EventHandler.ts
  • codegenerator/cli/templates/static/factory_indexer_template/typescript/src/EventHandlers.ts
  • codegenerator/cli/templates/static/multichain_indexer_template/typescript/src/EventHandlers.ts
  • codegenerator/cli/templates/static/factory_indexer_template/typescript/config.yaml
  • codegenerator/cli/templates/static/wildcard_indexing_template/typescript/config.yaml
📚 Learning: 2025-10-13T12:27:30.803Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-10-13T12:27:30.803Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/config.yaml : Avoid duplicate contract definitions in network sections; define handlers/events globally and only provide addresses per network; enable unordered_multichain_mode: true

Applied to files:

  • codegenerator/cli/templates/static/multichain_indexer_template/typescript/config.yaml
  • codegenerator/cli/templates/static/effects_api_template/typescript/config.yaml
  • codegenerator/cli/templates/static/onblock_handler_template/typescript/config.yaml
  • codegenerator/cli/templates/static/wildcard_indexing_template/typescript/config.yaml
📚 Learning: 2025-10-13T12:27:30.803Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-10-13T12:27:30.803Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/config.yaml : For multichain deployments, keep handlers and events defined in the global contracts section and only list addresses under networks per chain

Applied to files:

  • codegenerator/cli/templates/static/multichain_indexer_template/typescript/config.yaml
  • codegenerator/cli/templates/static/onblock_handler_template/typescript/config.yaml
📚 Learning: 2025-08-11T08:42:57.311Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-08-11T08:42:57.311Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.ts : After any change to TypeScript files, run `pnpm tsc --noEmit` to ensure successful compilation

Applied to files:

  • codegenerator/cli/templates/static/multichain_indexer_template/typescript/tsconfig.json
  • codegenerator/cli/templates/static/effects_api_template/typescript/tsconfig.json
  • codegenerator/cli/templates/static/topic_filtering_template/typescript/tsconfig.json
  • codegenerator/cli/templates/static/wildcard_indexing_template/typescript/tsconfig.json
  • codegenerator/cli/templates/static/onblock_handler_template/typescript/tsconfig.json
  • codegenerator/cli/templates/static/factory_indexer_template/typescript/tsconfig.json
📚 Learning: 2025-10-13T12:27:30.803Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-10-13T12:27:30.803Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/.env.example : Document all environment variables used in code by listing them in .env.example with descriptions and example values

Applied to files:

  • codegenerator/cli/templates/static/multichain_indexer_template/shared/.env.example
  • codegenerator/cli/templates/static/factory_indexer_template/shared/.env.example
  • codegenerator/cli/templates/static/wildcard_indexing_template/shared/.env.example
  • codegenerator/cli/templates/static/effects_api_template/shared/.env.example
  • codegenerator/cli/templates/static/onblock_handler_template/shared/.env.example
  • codegenerator/cli/templates/static/topic_filtering_template/shared/.env.example
📚 Learning: 2025-10-13T12:27:30.803Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-10-13T12:27:30.803Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.{ts,js} : Search for all usages of process.env.* to ensure they are documented and handled; update .env.example accordingly

Applied to files:

  • codegenerator/cli/templates/static/wildcard_indexing_template/shared/.env.example
  • codegenerator/cli/templates/static/onblock_handler_template/shared/.env.example
📚 Learning: 2025-10-13T12:26:45.351Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: .cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-10-13T12:26:45.351Z
Learning: Applies to .env.example : Document all environment variables discovered in code under .env.example with sample values and comments

Applied to files:

  • codegenerator/cli/templates/static/wildcard_indexing_template/shared/.env.example
  • codegenerator/cli/templates/static/topic_filtering_template/shared/.env.example
📚 Learning: 2025-10-13T12:27:30.803Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-10-13T12:27:30.803Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/effects/**/*.ts : External calls (RPC/API) must be implemented via the Effect API in src/effects/ using experimental_createEffect with proper input/output schemas and error handling

Applied to files:

  • codegenerator/cli/templates/static/effects_api_template/shared/README.md
📚 Learning: 2025-10-13T12:26:45.351Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: .cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-10-13T12:26:45.351Z
Learning: Applies to src/effects/**/*.ts : Create external calls (RPC/API) as Effect API functions under src/effects and define schemas via `experimental_createEffect`

Applied to files:

  • codegenerator/cli/templates/static/effects_api_template/shared/README.md
📚 Learning: 2025-10-13T12:26:45.351Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: .cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-10-13T12:26:45.351Z
Learning: Applies to src/EventHandlers.ts : Remove the monolithic EventHandlers.ts file after moving handlers to contract-specific files

Applied to files:

  • codegenerator/cli/templates/static/effects_api_template/typescript/src/EventHandlers.ts
  • codegenerator/cli/templates/static/wildcard_indexing_template/typescript/src/EventHandler.ts
  • codegenerator/cli/templates/static/topic_filtering_template/typescript/src/EventHandler.ts
  • codegenerator/cli/templates/static/factory_indexer_template/typescript/src/EventHandlers.ts
  • codegenerator/cli/templates/static/multichain_indexer_template/typescript/src/EventHandlers.ts
  • codegenerator/cli/templates/static/onblock_handler_template/typescript/src/EventHandlers.ts
📚 Learning: 2025-10-13T12:27:30.803Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-10-13T12:27:30.803Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/EventHandlers.ts : Remove the original src/EventHandlers.ts after moving handlers into contract-specific files

Applied to files:

  • codegenerator/cli/templates/static/effects_api_template/typescript/src/EventHandlers.ts
  • codegenerator/cli/templates/static/wildcard_indexing_template/typescript/src/EventHandler.ts
  • codegenerator/cli/templates/static/topic_filtering_template/typescript/src/EventHandler.ts
  • codegenerator/cli/templates/static/factory_indexer_template/typescript/src/EventHandlers.ts
  • codegenerator/cli/templates/static/multichain_indexer_template/typescript/src/EventHandlers.ts
  • codegenerator/cli/templates/static/onblock_handler_template/typescript/src/EventHandlers.ts
📚 Learning: 2025-10-13T12:27:30.803Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-10-13T12:27:30.803Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/EventHandlers.ts : Clear all boilerplate logic from src/EventHandlers.ts and replace handlers with empty skeletons before implementing business logic

Applied to files:

  • codegenerator/cli/templates/static/effects_api_template/typescript/src/EventHandlers.ts
  • codegenerator/cli/templates/static/wildcard_indexing_template/typescript/src/EventHandler.ts
  • codegenerator/cli/templates/static/topic_filtering_template/typescript/src/EventHandler.ts
  • codegenerator/cli/templates/static/factory_indexer_template/typescript/src/EventHandlers.ts
  • codegenerator/cli/templates/static/multichain_indexer_template/typescript/src/EventHandlers.ts
  • codegenerator/cli/templates/static/onblock_handler_template/typescript/src/EventHandlers.ts
📚 Learning: 2025-10-13T12:27:30.803Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-10-13T12:27:30.803Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Register dynamic contracts using contractRegister above the creating event’s handler (e.g., context.addPair(event.params.pair))

Applied to files:

  • codegenerator/cli/templates/static/wildcard_indexing_template/typescript/src/EventHandler.ts
  • codegenerator/cli/templates/static/topic_filtering_template/typescript/src/EventHandler.ts
  • codegenerator/cli/templates/static/factory_indexer_template/typescript/src/EventHandlers.ts
📚 Learning: 2025-10-13T12:27:30.803Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-10-13T12:27:30.803Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Prefix all entity IDs with event.chainId and never hardcode chainId=1; accept chainId in helper functions; use chain-specific Bundle IDs like `${chainId}-1`

Applied to files:

  • codegenerator/cli/templates/static/topic_filtering_template/typescript/src/EventHandler.ts
  • codegenerator/cli/templates/static/multichain_indexer_template/typescript/src/EventHandlers.ts
📚 Learning: 2025-10-13T12:26:45.351Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: .cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-10-13T12:26:45.351Z
Learning: Applies to src/**/*.ts : For multichain support, prefix all entity IDs with `${event.chainId}-...` and never hardcode `chainId = 1`

Applied to files:

  • codegenerator/cli/templates/static/multichain_indexer_template/typescript/src/EventHandlers.ts
📚 Learning: 2025-10-13T12:26:45.351Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: .cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-10-13T12:26:45.351Z
Learning: Applies to src/EventHandlers.ts : Clear boilerplate logic in EventHandlers.ts and replace with empty handlers before implementing business logic

Applied to files:

  • codegenerator/cli/templates/static/onblock_handler_template/typescript/src/EventHandlers.ts
🧬 Code graph analysis (3)
codegenerator/cli/src/template_dirs.rs (3)
codegenerator/cli/src/cli_args/interactive_init/mod.rs (1)
  • Language (152-154)
codegenerator/integration_tests/src/main.rs (1)
  • new (43-55)
codegenerator/cli/src/hbs_templating/init_templates.rs (1)
  • new (23-58)
codegenerator/cli/src/cli_args/init_config.rs (2)
codegenerator/cli/src/config_parsing/entity_parsing.rs (2)
  • serialize (1177-1182)
  • serialize (1328-1333)
codegenerator/cli/src/rescript_types.rs (1)
  • serialize (703-709)
codegenerator/cli/templates/static/onblock_handler_template/typescript/src/EventHandlers.ts (1)
codegenerator/cli/npm/envio/index.d.ts (1)
  • bigint (109-109)
🪛 dotenv-linter (4.0.0)
codegenerator/cli/templates/static/multichain_indexer_template/shared/.env.example

[warning] 2-2: [QuoteCharacter] The value has quote characters (', ")

(QuoteCharacter)

codegenerator/cli/templates/static/factory_indexer_template/shared/.env.example

[warning] 2-2: [QuoteCharacter] The value has quote characters (', ")

(QuoteCharacter)

codegenerator/cli/templates/static/wildcard_indexing_template/shared/.env.example

[warning] 2-2: [QuoteCharacter] The value has quote characters (', ")

(QuoteCharacter)

codegenerator/cli/templates/static/effects_api_template/shared/.env.example

[warning] 2-2: [QuoteCharacter] The value has quote characters (', ")

(QuoteCharacter)

codegenerator/cli/templates/static/onblock_handler_template/shared/.env.example

[warning] 2-2: [QuoteCharacter] The value has quote characters (', ")

(QuoteCharacter)

codegenerator/cli/templates/static/topic_filtering_template/shared/.env.example

[warning] 2-2: [QuoteCharacter] The value has quote characters (', ")

(QuoteCharacter)

🪛 LanguageTool
codegenerator/cli/templates/static/topic_filtering_template/shared/README.md

[style] ~7-~7: This phrase might be redundant. Consider either removing or replacing the adjective ‘additional’.
Context: ...n event signature. In this version, we add an additional feature that filters those events further based...

(ADD_AN_ADDITIONAL)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build_and_test
🔇 Additional comments (26)
codegenerator/cli/templates/static/topic_filtering_template/typescript/tsconfig.json (1)

1-21: TypeScript configuration structure is sound.

The tsconfig.json follows best practices with es2020 target (supporting BigInt), strict mode enabled, and proper CommonJS module setup. This aligns with the standard template configuration pattern across other templates in the PR.

Per the learning guidelines, ensure TypeScript compilation verification is completed: after any changes to TypeScript files, run pnpm tsc --noEmit to validate the configuration. Given the PR mentions path issues during CLI testing, confirm this template's generated files reference correct module paths.

codegenerator/cli/templates/static/wildcard_indexing_template/shared/README.md (1)

1-45: Documentation is clear and well-structured.

The README provides excellent guidance on wildcard indexing with proper code examples, prerequisites, and running instructions. References to official documentation are included, and the example correctly demonstrates the wildcard: true configuration.

Verify that hyperlinks on lines 8 and 45 are active and point to correct endpoints:

  • Line 8: https://docs.envio.dev/docs/HyperIndex/wildcard-indexing
  • Line 45: https://envio.dev/console
codegenerator/cli/templates/static/factory_indexer_template/typescript/tsconfig.json (1)

1-21: TypeScript configuration is consistent with template standards.

The tsconfig.json follows the same valid pattern used across other templates in this PR, ensuring consistent build configuration across the template suite.

codegenerator/cli/templates/static/multichain_indexer_template/typescript/tsconfig.json (1)

1-21: LGTM.

Consistent with other template TypeScript configurations in the PR.

codegenerator/cli/templates/static/onblock_handler_template/shared/schema.graphql (1)

1-13: LGTM!

The GraphQL schema is well-defined with clear field naming and appropriate types. The distinction between currentSupply (TotalSupply) and supply (TotalSupplySnapshot) appropriately differentiates the current state from historical snapshots.

codegenerator/cli/src/cli_args/interactive_init/mod.rs (3)

11-11: LGTM!

The import of Template from crate::template_dirs is appropriate for enabling language-aware template filtering.


34-37: LGTM!

Adding the selected_language parameter enables language-specific template filtering as intended by this PR.


166-166: LGTM!

Passing language.clone() to prompt_ecosystem correctly provides the language context needed for template filtering.

codegenerator/cli/templates/static/topic_filtering_template/shared/schema.graphql (1)

1-12: LGTM!

The GraphQL schema is well-defined with clear, helpful comments explaining each field. The field types are appropriate for representing transfer events.

codegenerator/cli/templates/static/wildcard_indexing_template/typescript/config.yaml (1)

1-15: LGTM!

The configuration is appropriate for wildcard indexing. The contract is defined without a specific address (line 8), which is correct for wildcard matching. The recent start_block (23480542) helps keep template data minimal for demonstration purposes.

codegenerator/cli/templates/static/wildcard_indexing_template/typescript/src/EventHandler.ts (1)

1-14: LGTM!

The event handler is well-structured and correctly implements wildcard Transfer event indexing. The ID construction (line 6) follows best practices by combining chainId, block.number, and logIndex to ensure uniqueness across chains and transactions.

codegenerator/cli/templates/static/effects_api_template/typescript/config.yaml (1)

21-21: No changes required—UniswapV3Pool configuration is correct.

The verification confirms this is the proper factory pattern implementation. Both the effects_api_template and factory_indexer_template use the identical pattern: UniswapV3Factory has a hardcoded address (the factory contract), while UniswapV3Pool lacks an address because pool instances are dynamically registered via the PoolCreated event. This is the correct design for factory-deployed contracts.

codegenerator/cli/templates/static/multichain_indexer_template/typescript/config.yaml (1)

17-22: The address is correct — no changes needed.

The UniswapV3Factory on Unichain Mainnet (chain ID 130) is deployed at 0x1f98400000000000000000000000000000000003. The address beginning 0x1F98431c... is UniswapV3Factory on Ethereum mainnet and Unichain Sepolia. Uniswap V3 deployments use different contract addresses across different networks; the address in the template is the legitimate mainnet deployment, not a placeholder.

Likely an incorrect or invalid review comment.

codegenerator/cli/templates/static/effects_api_template/shared/README.md (1)

1-93: Documentation is clear and comprehensive.

The README provides excellent guidance on the Effects API template with concrete examples, prerequisites, and running instructions. The code samples are accurate and demonstrate the pattern well.

codegenerator/cli/templates/static/topic_filtering_template/typescript/config.yaml (1)

1-15: Configuration is well-structured and complete.

The template config properly defines the topic filtering indexer with complete contract specification and appropriate network configuration. The ERC20 Transfer event setup is correct.

codegenerator/cli/templates/static/factory_indexer_template/shared/schema.graphql (1)

1-20: GraphQL schema is well-structured.

The factory indexer schema properly models the Uniswap V3 relationship between pool creation and swaps. The @derivedFrom relationship is correctly established on the pool reference field.

codegenerator/cli/templates/static/factory_indexer_template/shared/README.md (1)

1-55: Documentation clearly explains the factory pattern.

The README provides a clear explanation of dynamic contract registration with proper examples and running instructions. The Uniswap V3 concrete example effectively demonstrates the contractRegister pattern.

codegenerator/cli/templates/static/wildcard_indexing_template/shared/schema.graphql (1)

1-12: Schema is well-documented and properly structured.

The Transfer type is clearly defined with helpful inline comments explaining each field's purpose. The field types are appropriate for the wildcard indexing pattern.

codegenerator/cli/templates/static/multichain_indexer_template/shared/schema.graphql (1)

1-20: Schema types are well-defined.

All three GraphQL types are properly structured with appropriate field types for capturing Uniswap V3 Factory events across multiple chains.

codegenerator/cli/src/cli_args/init_config.rs (2)

72-84: Sanity check: handler path is plumbed from Language into HumanConfig as-is.

Given the unified path above, this flow looks correct. Please re-run a local init (TS and JS/ReScript) to confirm configs reference the right EventHandlers file relative to the project root.

Also applies to: 147-156, 167-184


356-361: TypeScript path should include "./", not remove it from others.

The actual template config.yaml files consistently use ./src/EventHandlers.* across all languages. The Rust code should mirror this by adding ./ to TypeScript, not removing it from ReScript and JavaScript as suggested.

-            Language::ReScript => "./src/EventHandlers.res.js".to_string(),
+            Language::ReScript => "./src/EventHandlers.res.js".to_string(),
             Language::TypeScript => "./src/EventHandlers.ts".to_string(),
-            Language::JavaScript => "./src/EventHandlers.js".to_string(),
+            Language::JavaScript => "./src/EventHandlers.js".to_string(),

Likely an incorrect or invalid review comment.

codegenerator/cli/src/template_dirs.rs (5)

13-14: LGTM! Clean trait extension.

The new supported_languages() method provides a clear API for querying language support per template, enabling dynamic filtering in the CLI.


57-65: LGTM!

The Fuel template language support is properly implemented and consistent with the EVM Greeter template.


469-508: LGTM! Well-improved test coverage.

The test updates properly validate that each template has directories for only its supported languages, and the error messages are now more specific and helpful. The addition of the dynamic shared init template check is also good.


514-552: LGTM! Tests properly validate template extraction.

The extraction tests now correctly iterate over only the supported languages for each template. The use of separate TempDirs for template types improves test isolation.


22-24: Based on the script output you provided, I can now verify the situation:

Key Finding: All 6 new template directories exist and are properly configured:

  • ✅ effects_api_template
  • ✅ factory_indexer_template
  • ✅ multichain_indexer_template
  • ✅ onblock_handler_template
  • ✅ topic_filtering_template
  • ✅ wildcard_indexing_template

The code snippet shown only displays lines 22-24 with 3 enum variants, but this is just a partial view. The 3 visible variants (TopicFiltering, WildcardIndexing, OnBlockHandler) match 3 of the 6 template directories. Since all 6 directories exist on disk with proper TypeScript subdirectories, the template directory structure is complete and correct.

The original review comment was based on incomplete information—the code snippet doesn't show the full enum, so it appeared that only 3 templates were added when in fact all 6 are present. The discrepancy mentioned in the PR description and code is resolved by the fact that all template directories are present on the filesystem.


No issues found - template directories verified as complete.

Comment on lines 31 to 40
#[strum(serialize = "Greeter")]
Greeter,
#[strum(serialize = "ERC20")]
Erc20,
#[strum(serialize = "Feature: Topic Filtering")]
TopicFiltering,
#[strum(serialize = "Feature: Wildcard Indexing")]
WildcardIndexing,
#[strum(serialize = "Feature: On-Block Handler")]
OnBlockHandler,
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Template naming/serialization may drift across clap/strum/serde. Verify UX strings and parsing.

  • strum(serialize = "...") sets Display/EnumString, but clap::ValueEnum uses its own naming rules unless given explicit clap attributes; serde derives won’t use strum Display either.
  • Result: interactive/help text and config (de)serialization may show different strings than the ones you intend (“Feature: ...”).

Please confirm:

  • CLI shows the intended labels for these variants.
  • Non-interactive flags parse both human labels and machine labels as expected.
  • The new templates (effects-api, factory-indexer, multichain-indexer) are exposed to users (either here or via template_dirs). If they’re intentionally not in this enum, ensure template_dirs.rs maps them correctly.

You can run:


🏁 Script executed:

#!/bin/bash
# Inspect enum variants and any template mappings
rg -nP 'enum\s+Template\b' -C2 codegenerator/cli
rg -nP 'supported_languages\s*\(' codegenerator/cli
rg -nP '(effects_api_template|factory_indexer_template|multichain_indexer_template)' -n codegenerator/cli

Length of output: 1647


I need to gather more information about the Template enums and how they're used.<!-- [scratchpad_update]
[observations_additional]

  • Web search confirms: clap::ValueEnum has its own naming logic separate from strum serialize
  • clap uses kebab-case by default; can be overridden with #[clap(rename_all = "...")] attribute
  • strum(serialize = "...") controls Display/EnumString/serde serialization, NOT clap's ValueEnum parsing
  • When clap::ValueEnum and strum both present, clap won't automatically respect strum(serialize) unless #[clap(...)] attributes are explicitly added
  • This is exactly what the review comment warns about
  • ValueEnum.to_possible_value() is the method that controls CLI value parsing

[pending_critical]

  • Need to inspect the actual Template enum definition to see if clap attributes are present
  • Need to find where the new templates are defined/used
  • Need to check template_dirs.rs for template registration
    [scratchpad_end] -->

Need to inspect the actual Template enum and template registration in more detail.


🏁 Script executed:

#!/bin/bash
# Get full context of the Template enum at line 30
sed -n '28,80p' codegenerator/cli/src/cli_args/init_config.rs

Length of output: 2220


🏁 Script executed:

#!/bin/bash
# Get full context of the second Template enum at line 231
sed -n '229,240p' codegenerator/cli/src/cli_args/init_config.rs

Length of output: 285


🏁 Script executed:

#!/bin/bash
# Look for clap attributes on Template enum
rg -nP '#\[clap' codegenerator/cli/src/cli_args/init_config.rs -A2 -B2

Length of output: 243


🏁 Script executed:

#!/bin/bash
# Search for new template names in template_dirs.rs
rg -nP '(effects|factory|multichain)' codegenerator/cli/src/template_dirs.rs -i -C2

Length of output: 0


🏁 Script executed:

#!/bin/bash
# Check if there's a match on Template enum and ValueEnum derive to understand how it's used
ast-grep --pattern $'#[derive($$$ValueEnum$$$)]
pub enum Template {
  $$$
}'

Length of output: 0


🏁 Script executed:

#!/bin/bash
# Look for clap rename_all on the enum itself
rg -nP 'enum Template' codegenerator/cli -B5 | head -40

Length of output: 1303


🏁 Script executed:

#!/bin/bash
# Search in template_dirs for TemplateProvider or template registration logic
rg -nP 'fn.*template' codegenerator/cli/src/template_dirs.rs -i -n

Length of output: 1251


🏁 Script executed:

#!/bin/bash
# Look for where Template enum variants are used in value parsing
rg -nP 'to_possible_value|value_variants|Template::' codegenerator/cli/src/cli_args/init_config.rs -n

Length of output: 0


🏁 Script executed:

#!/bin/bash
# Check if there's any test or mock for template selection
fd -e rs codegenerator/cli -path '*/test*' -o -name '*test*' | xargs rg -l Template 2>/dev/null | head -5

Length of output: 360


🏁 Script executed:

#!/bin/bash
# Look for explicit use of strum in imports or dependencies
rg -n '^use.*strum' codegenerator/cli/src/

Length of output: 991


🏁 Script executed:

#!/bin/bash
# Look for where Template is actually parsed/matched in the interactive flow
rg -nP 'Template::|template.*select|select.*template' codegenerator/cli/src/cli_args/interactive_init/ -i

Length of output: 932


🏁 Script executed:

#!/bin/bash
# Check Cargo.toml for versions of clap, strum, serde
rg -n '(clap|strum|serde)' codegenerator/cli/Cargo.toml -A1

Length of output: 379


🏁 Script executed:

#!/bin/bash
# Look at the full enum definition including derive macros
sed -n '25,100p' codegenerator/cli/src/cli_args/init_config.rs

Length of output: 3034


I need to verify a few more critical details about how Template enum is used in argument parsing and whether clap attributes exist at the module level.


🏁 Script executed:

#!/bin/bash
# Check if Template is used in clap argument definitions
rg -nP 'template|Template' codegenerator/cli/src/cli_args/clap_definitions.rs -i -C3

Length of output: 1763


🏁 Script executed:

#!/bin/bash
# Look at the evm module declaration to see if there are clap attributes
sed -n '1,50p' codegenerator/cli/src/cli_args/init_config.rs

Length of output: 1537


🏁 Script executed:

#!/bin/bash
# Check how the Template is rendered in the interactive prompt (Display impl check)
rg -nP 'shared_prompts|SelectItem' codegenerator/cli/src/cli_args/interactive_init/shared_prompts.rs -C5

Length of output: 887


🏁 Script executed:

#!/bin/bash
# Look for where template names are actually output to user (help text, prompts)
rg -nP 'which.*template|select.*template' codegenerator/cli/src/cli_args/interactive_init/ -i -C3

Length of output: 1539


🏁 Script executed:

#!/bin/bash
# Check TemplateType enum to understand template registration
sed -n '179,220p' codegenerator/cli/src/template_dirs.rs

Length of output: 1422


🏁 Script executed:

#!/bin/bash
# Look for any rename_all or clap rename directives on evm module
grep -n 'mod evm' codegenerator/cli/src/cli_args/init_config.rs -B5 -A10

Length of output: 411


🏁 Script executed:

#!/bin/bash
# Search for ValueEnum implementation to see if to_possible_value is customized
rg -nP 'impl.*ValueEnum|to_possible_value' codegenerator/cli/src/cli_args/init_config.rs -n

Length of output: 0


🏁 Script executed:

#!/bin/bash
# Check template_dirs.rs TemplateType for variant names
sed -n '179,200p' codegenerator/cli/src/template_dirs.rs

Length of output: 679


Add #[clap(...)] attributes to Template enum variants to align clap parsing with strum Display strings.

The review concern is valid. Template enum (line 29-40) derives ValueEnum without explicit clap attributes, causing a mismatch:

  • Interactive UI displays strum serialized strings: "ERC20", "Feature: Topic Filtering"
  • clap parses using variant names as kebab-case: "erc-20", "topic-filtering"

This breaks non-interactive flag parsing (e.g., --template erc-20 would fail).

Fix: Add #[clap(name = "...")] attributes on each Template variant, mirroring the strum serialized values. Reference: Language enum (lines 346-352) demonstrates the correct pattern with explicit clap name attributes.

Regarding new templates: effects_api_template, factory_indexer_template, multichain_indexer_template are not found in the Template enum or template_dirs.rs. Verify whether these should be added to the enum or are intentionally excluded.

🤖 Prompt for AI Agents
In codegenerator/cli/src/cli_args/init_config.rs around lines 31 to 40, the
Template enum variants derive ValueEnum but lack clap name attributes so clap
parsing uses kebab-case variant names (e.g., "erc-20") while the interactive UI
uses strum serialized strings (e.g., "ERC20"); add #[clap(name = "...")] to each
variant with the exact string used in #[strum(serialize = "...")] (e.g.,
#[clap(name = "ERC20")]) so non-interactive flags parse the same values, and
also verify whether effects_api_template, factory_indexer_template, and
multichain_indexer_template should be added to this enum or intentionally
omitted and update template_dirs.rs accordingly.

@@ -0,0 +1,2 @@
# To create or update a token visit https://envio.dev/app/api-tokens
ENVIO_API_TOKEN="<YOUR-API-TOKEN>"
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove quotes around the placeholder value in .env.example.

The double-quoted placeholder value violates dotenv conventions. If users copy this line without modification, the token value will include the literal quotes, causing authentication failures. Placeholder values in .env.example should be unquoted.

- ENVIO_API_TOKEN="<YOUR-API-TOKEN>"
+ ENVIO_API_TOKEN=<YOUR-API-TOKEN>
🧰 Tools
🪛 dotenv-linter (4.0.0)

[warning] 2-2: [QuoteCharacter] The value has quote characters (', ")

(QuoteCharacter)

🤖 Prompt for AI Agents
In codegenerator/cli/templates/static/effects_api_template/shared/.env.example
around line 2, the placeholder ENVIO_API_TOKEN is wrapped in double quotes which
can cause users to copy the quotes into their actual .env and break
authentication; remove the surrounding quotes so the placeholder is unquoted
(ENVIO_API_TOKEN=<YOUR-API-TOKEN>) and ensure any accompanying documentation
notes the token should be pasted without quotes.

Comment on lines +1 to +35
*.exe
*.obj
*.out
*.compile
*.native
*.byte
*.cmo
*.annot
*.cmi
*.cmx
*.cmt
*.cmti
*.cma
*.a
*.cmxa
*.obj
*~
*.annot
*.cmj
*.bak
lib/*
*.mlast
*.mliast
.vscode
.merlin
.bsb.lock
node_modules/
build/
benchmarks/
artifacts
cache
*.res.js
*.res.mjs
generated
.env
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove duplicate ignore patterns.

The file contains duplicate patterns that should be consolidated:

  • *.obj appears on lines 2 and 16
  • *.annot appears on lines 8 and 18

Apply this diff to remove duplicates:

 *.exe
 *.obj
 *.out
 *.compile
 *.native
 *.byte
 *.cmo
 *.annot
 *.cmi
 *.cmx
 *.cmt
 *.cmti
 *.cma
 *.a
 *.cmxa
-*.obj
 *~
-*.annot
 *.cmj
 *.bak
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
*.exe
*.obj
*.out
*.compile
*.native
*.byte
*.cmo
*.annot
*.cmi
*.cmx
*.cmt
*.cmti
*.cma
*.a
*.cmxa
*.obj
*~
*.annot
*.cmj
*.bak
lib/*
*.mlast
*.mliast
.vscode
.merlin
.bsb.lock
node_modules/
build/
benchmarks/
artifacts
cache
*.res.js
*.res.mjs
generated
.env
*.exe
*.obj
*.out
*.compile
*.native
*.byte
*.cmo
*.annot
*.cmi
*.cmx
*.cmt
*.cmti
*.cma
*.a
*.cmxa
*~
*.cmj
*.bak
lib/*
*.mlast
*.mliast
.vscode
.merlin
.bsb.lock
node_modules/
build/
benchmarks/
artifacts
cache
*.res.js
*.res.mjs
generated
.env
🤖 Prompt for AI Agents
In codegenerator/cli/templates/static/effects_api_template/shared/.gitignore
around lines 1 to 35, there are duplicate ignore patterns (*.obj on lines 2 and
16, and *.annot on lines 8 and 18); remove the duplicated entries so each
pattern appears only once (keep a single instance of *.obj and a single instance
of *.annot), preserving the rest of the ordering and content.

}
,
async ({ block, context }) => {
const latestSupply = await context.TotalSupply.get("latest");
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Chain-scope the “latest” entity ID to prevent collisions across networks.

If run against multiple chains now or later, "latest" will collide. Include chainId in the key.

-        const latestSupply = await context.TotalSupply.get("latest");
+        const latestSupply = await context.TotalSupply.get(`${block.chainId}-latest`);
@@
-    const latestSupply = await context.TotalSupply.getOrCreate({
-        id: "latest",
+    const latestSupply = await context.TotalSupply.getOrCreate({
+        id: `${event.chainId}-latest`,
@@
-    const latestEntity: TotalSupply = {
-        id: "latest",
+    const latestEntity: TotalSupply = {
+        id: `${event.chainId}-latest`,

Additionally, consider guarding burns so supply doesn’t go negative on malformed events.

Also applies to: 48-53, 67-72

🤖 Prompt for AI Agents
In
codegenerator/cli/templates/static/onblock_handler_template/typescript/src/EventHandlers.ts
around line 21 (and also update the similar occurrences at lines 48-53 and
67-72), the entity key "latest" must be chain-scoped to avoid cross-chain
collisions and burns must be guarded so supply cannot go negative; change all
uses of the "latest" key to include the chain identifier from the handler
context (e.g., prepend or append context.chainId/context.network.chainId to the
key) and update any get/set calls accordingly, and when applying burn/transfer
decrements clamp the resulting supply at zero (or skip the decrement if it would
go negative) so malformed events cannot produce a negative totalSupply.

Comment on lines +26 to +35
const supply = latestSupply.currentSupply;
const blockNumber = latestSupply.blockNumber;
const timestamp = latestSupply.timestamp;

const totalSupplySnapshot: TotalSupplySnapshot = {
id: `${block.chainId}_${block.number}`,
supply: supply,
blockNumber: blockNumber,
timestamp: timestamp,
};
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Bug: snapshot stores stale blockNumber/timestamp from latestSupply.

Use the current block’s values, not the last mint/burn’s. Fix below.

-        const supply = latestSupply.currentSupply;
-        const blockNumber = latestSupply.blockNumber;
-        const timestamp = latestSupply.timestamp;
+        const supply = latestSupply.currentSupply;
+        const blockNumber = BigInt(block.number);
+        const timestamp = BigInt(block.timestamp);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const supply = latestSupply.currentSupply;
const blockNumber = latestSupply.blockNumber;
const timestamp = latestSupply.timestamp;
const totalSupplySnapshot: TotalSupplySnapshot = {
id: `${block.chainId}_${block.number}`,
supply: supply,
blockNumber: blockNumber,
timestamp: timestamp,
};
const supply = latestSupply.currentSupply;
const blockNumber = BigInt(block.number);
const timestamp = BigInt(block.timestamp);
const totalSupplySnapshot: TotalSupplySnapshot = {
id: `${block.chainId}_${block.number}`,
supply: supply,
blockNumber: blockNumber,
timestamp: timestamp,
};
🤖 Prompt for AI Agents
In
codegenerator/cli/templates/static/onblock_handler_template/typescript/src/EventHandlers.ts
around lines 26 to 35, the TotalSupplySnapshot is being populated with
blockNumber and timestamp from latestSupply (stale values); change those
assignments to use the current block's values (block.number and block.timestamp)
so the snapshot reflects the current block, and update the id if it relies on
those fields to use the current block values as well.

Comment on lines +1 to +21
{
"compilerOptions": {
"target": "es2020", //required for use with BigInt types
"lib": [
"es2020"
],
"allowJs": true,
"checkJs": false,
"outDir": "build",
"strict": true,
"noImplicitAny": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"module": "CommonJS"
},
"include": [
"src",
"test"
]
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

TypeScript configuration looks correct.

The configuration appropriately targets es2020 for BigInt support with strict type checking enabled. Ensure that TypeScript compilation succeeds with this configuration before merging.


🏁 Script executed:

#!/bin/bash
# Description: Verify TypeScript compilation for onblock_handler_template

cd codegenerator/cli/templates/static/onblock_handler_template/typescript
pnpm tsc --noEmit

Length of output: 195


🏁 Script executed:

#!/bin/bash
# Check what files exist in the onblock_handler_template directory
fd . codegenerator/cli/templates/static/onblock_handler_template/typescript/ -type f

Length of output: 170


🏁 Script executed:

#!/bin/bash
# Check the parent directory structure to understand template organization
ls -la codegenerator/cli/templates/static/onblock_handler_template/

Length of output: 226


🏁 Script executed:

#!/bin/bash
# Search for references to onblock_handler_template in the codebase
rg -n "onblock_handler_template" codegenerator/cli/ --type rust --type ts --type toml

Length of output: 0


🏁 Script executed:

#!/bin/bash
# Check if there's a package.json at a higher level (workspace root)
fd package.json codegenerator/cli/templates/ -type f

Length of output: 170


🏁 Script executed:

#!/bin/bash
# Look for TypeScript files in the template structure
fd '\.ts$' codegenerator/cli/templates/static/onblock_handler_template/ -type f

Length of output: 170


🏁 Script executed:

#!/bin/bash
# Check if there's a root package.json we can use for type checking
fd package.json codegenerator/cli/ -type f | head -5

Length of output: 170


🏁 Script executed:

#!/bin/bash
# Check the README or documentation about these templates
fd README codegenerator/cli/templates/ -type f

Length of output: 170


🏁 Script executed:

#!/bin/bash
# Look at the structure of the templates directory
ls -la codegenerator/cli/templates/static/

Length of output: 934


🏁 Script executed:

#!/bin/bash
# Check if tsconfig.json is referenced in any Rust source code (generator code)
rg -n "tsconfig" codegenerator/cli/ --type rust -A2 -B2

Length of output: 0


🏁 Script executed:

#!/bin/bash
# Search for any test or validation of these templates
fd "template" codegenerator/cli/src/ --type f -name "*.rs" | head -10

Length of output: 230


🏁 Script executed:

#!/bin/bash
# Look at the actual Rust code that generates or manages these templates
ls -la codegenerator/cli/src/

Length of output: 1176


🏁 Script executed:

#!/bin/bash
# Check the structure more broadly
find codegenerator/cli/templates -type d | head -20

Length of output: 1265


🏁 Script executed:

#!/bin/bash
# Look for configuration or references to how templates are validated
rg -n "onblock" codegenerator/cli/src/ --type rust -C2 | head -30

Length of output: 436


🏁 Script executed:

#!/bin/bash
# Check if there's a build.rs or similar that processes templates
fd "build.rs\|lib.rs\|main.rs" codegenerator/cli/src/ --type f

Length of output: 0


🏁 Script executed:

#!/bin/bash
# Examine the content structure of the template directory
find codegenerator/cli/templates/static/onblock_handler_template -type f -exec file {} \;

Length of output: 319


🏁 Script executed:

#!/bin/bash
# Check if there's documentation about template usage
rg -n "template" codegenerator/cli/README.md --type markdown -C3 2>/dev/null || echo "No README found"

Length of output: 15


🏁 Script executed:

#!/bin/bash
# Look for CargoToml or similar configuration that might reference these templates
cat codegenerator/cli/Cargo.toml | grep -A10 -B10 "onblock\|template" || echo "No matches in Cargo.toml"

Length of output: 24


🏁 Script executed:

#!/bin/bash
# Check what Rust modules exist in the CLI
ls -la codegenerator/cli/src/*.rs

Length of output: 596


🏁 Script executed:

#!/bin/bash
# List all files recursively in the onblock_handler_template directory
find codegenerator/cli/templates/static/onblock_handler_template -type f

Length of output: 660


🏁 Script executed:

#!/bin/bash
# Compare with another template to understand the pattern
find codegenerator/cli/templates/static/greeter_template -type f | head -20

Length of output: 1366


🏁 Script executed:

#!/bin/bash
# Check if there's any TypeScript validation in the build process
cat codegenerator/cli/Cargo.toml

Length of output: 1879


🏁 Script executed:

#!/bin/bash
# Validate tsconfig.json syntax using a simple JSON validator
python3 << 'EOF'
import json
try:
    with open('codegenerator/cli/templates/static/onblock_handler_template/typescript/tsconfig.json', 'r') as f:
        data = json.load(f)
    print("✓ tsconfig.json is valid JSON")
    print("✓ Compiler options found:", len(data.get('compilerOptions', {})))
    print("✓ Include paths:", data.get('include', []))
except json.JSONDecodeError as e:
    print("✗ JSON syntax error:", str(e))
except Exception as e:
    print("✗ Error:", str(e))
EOF

Length of output: 98


🏁 Script executed:

#!/bin/bash
# Check the template_dirs.rs to understand how templates are used
cat codegenerator/cli/src/template_dirs.rs | head -100

Length of output: 3160


🏁 Script executed:

#!/bin/bash
# Look for any documentation about these templates
find codegenerator/cli/templates -name "*.md" -o -name "README*" 2>/dev/null

Length of output: 1102


🏁 Script executed:

#!/bin/bash
# Check if there are similar onblock or handler templates elsewhere
find codegenerator/cli/templates -type d -name "*onblock*" -o -type d -name "*handler*"

Length of output: 59


🏁 Script executed:

#!/bin/bash
# List files in related templates' typescript directories
ls -la codegenerator/cli/templates/static/greeter_template/typescript/

Length of output: 401


🏁 Script executed:

#!/bin/bash
# Check if there's any validation or testing of template files
rg -n "tsconfig\|typescript" codegenerator/cli/src/commands.rs -C2

Length of output: 0


🏁 Script executed:

#!/bin/bash
# Compare tsconfig.json between templates
cat codegenerator/cli/templates/static/greeter_template/typescript/tsconfig.json

Length of output: 392


🏁 Script executed:

#!/bin/bash
# Check another template's tsconfig.json 
cat codegenerator/cli/templates/static/wildcard_indexing_template/typescript/tsconfig.json

Length of output: 392


🏁 Script executed:

#!/bin/bash
# Verify the exact content of the file under review
cat codegenerator/cli/templates/static/onblock_handler_template/typescript/tsconfig.json

Length of output: 392


🏁 Script executed:

#!/bin/bash
# Check if topic_filtering also has tsconfig
cat codegenerator/cli/templates/static/topic_filtering_template/typescript/tsconfig.json

Length of output: 392


Remove JSON comment from tsconfig.json — the file contains invalid JSON syntax.

Line 3 has //required for use with BigInt types which violates the JSON specification. JSON does not support // comments. This will cause TypeScript compilation to fail when users initialize projects from this template.

Remove the comment entirely or move the explanation to documentation.

{
  "compilerOptions": {
    "target": "es2020",
    "lib": [
      "es2020"
    ],

Note: This issue exists identically in other TypeScript templates (greeter_template, wildcard_indexing_template, topic_filtering_template).

🤖 Prompt for AI Agents
In
codegenerator/cli/templates/static/onblock_handler_template/typescript/tsconfig.json
lines 1-21, remove the inline comment on line 3 ("//required for use with BigInt
types") because tsconfig.json must be valid JSON; delete the comment or move the
note to accompanying docs/README and ensure the file only contains valid JSON
(no // or /* */ comments) so TypeScript compilation from the template won't
fail.

Comment on lines +16 to +22
{
wildcard: true,
eventFilters: {
from: ZERO_ADDRESS,
to: ZERO_ADDRESS,
}
},
Copy link
Contributor

@coderabbitai coderabbitai bot Oct 22, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify eventFilters logic - may not match any transfers.

The current configuration filters for transfers where BOTH from AND to are ZERO_ADDRESS, which is impossible for standard ERC20 transfers. Typically, you'd want to match:

  • Mints: from = ZERO_ADDRESS (any to)
  • Burns: to = ZERO_ADDRESS (any from)

If this is an example template, consider documenting the expected behavior or adjusting to demonstrate a realistic use case.

Run the following script to check if there are other topic filtering examples or documentation that clarify the intended behavior:


🏁 Script executed:

#!/bin/bash
# Search for topic filtering examples and documentation
rg -n -C3 "eventFilters" --type=ts --type=md --type=yaml

Length of output: 12852


🏁 Script executed:

#!/bin/bash
# Get the full context of the EventHandler.ts template file
cat codegenerator/cli/templates/static/topic_filtering_template/typescript/src/EventHandler.ts

Length of output: 506


🏁 Script executed:

#!/bin/bash
# Check for README or documentation in the template directory
find codegenerator/cli/templates/static/topic_filtering_template -type f \( -name "*.md" -o -name "*.txt" -o -name "README*" \) -exec cat {} +

Length of output: 1654


Fix template to demonstrate realistic topic filtering patterns.

The template's eventFilters configuration requires both from and to to equal ZERO_ADDRESS simultaneously, which is impossible for valid ERC20 transfers and demonstrates ineffective filtering. The README provides no explanation for this configuration.

Based on test examples in the codebase, realistic Transfer filtering shows:

  • Mints: from: ZERO_ADDRESS (any to)
  • Burns: to: ZERO_ADDRESS (any from)

Update the template to demonstrate one of these realistic patterns or show both mints and burns using separate filter objects in an array (for OR logic), matching patterns used in scenarios/test_codegen/src/EventHandlers.ts.

🤖 Prompt for AI Agents
In
codegenerator/cli/templates/static/topic_filtering_template/typescript/src/EventHandler.ts
around lines 16 to 22, the eventFilters currently require both from and to to
equal ZERO_ADDRESS which can never match real ERC20 Transfer events; replace
that single impossible filter with realistic pattern(s) — either a single filter
for mints (from: ZERO_ADDRESS, no to constraint) or burns (to: ZERO_ADDRESS, no
from constraint), or preferably an array of two filter objects (one for mints
and one for burns) to implement OR logic as used in
scenarios/test_codegen/src/EventHandlers.ts so the template demonstrates real
Transfer filtering.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

🧩 Analysis chain

🌐 Web query:

envio hyperindex wildcard indexing multiple filters

💡 Result:

Yes — HyperIndex supports wildcard indexing with multiple topic/event filters. Key points:

  • Use the eventFilters option with wildcard: true. eventFilters can be:
    • An array of filter objects (multiple filters).
    • Each indexed param can be an array of allowed values.
    • A function that returns filters per chainId for multichain indexers. [1][2][3]

Example (JS):
const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
const WHITELISTED = [
"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
"0x70997970C51812dc3A010C7d01b50e0d17dc79C8",
];
ERC20.Transfer.handler(
async ({ event, context }) => { /* ... */ },
{
wildcard: true,
eventFilters: [
{ from: ZERO_ADDRESS, to: WHITELISTED },
{ from: WHITELISTED, to: ZERO_ADDRESS },
],
}
);

Notes / limitations:

  • For a given network only one event signature may be indexed as wildcard (i.e., one wildcard event per signature per network).
  • RPC data source supports topic filtering only when applied to a single wildcard event. [1][2]

Sources: Envio HyperIndex docs and release notes. [1][2][3]


@DZakh Thank you for confirming! You're absolutely right—the current template demonstrates an impossible filter condition.

The issue is that the template uses a single filter object (AND logic), when it should use an array of filter objects (OR logic) to match realistic transfer patterns.

Current (broken) code:

eventFilters: {
  from: ZERO_ADDRESS,
  to: ZERO_ADDRESS,  // Both conditions must be true = impossible!
}

Corrected code for mints OR burns:

eventFilters: [
  { from: ZERO_ADDRESS },  // Mints: from zero address (any recipient)
  { to: ZERO_ADDRESS },    // Burns: to zero address (any sender)
]

Advanced example (from the documentation you linked):

const WHITELISTED = [
  "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
  "0x70997970C51812dc3A010C7d01b50e0d17dc79C8",
];

ERC20.Transfer.handler(
  async ({ event, context }) => {
    context.Transfer.set({
      id: `${event.chainId}_${event.block.number}_${event.logIndex}`,
      amount: event.params.value,
      from: event.params.from,
      to: event.params.to,
      contract: event.srcAddress,
    });
  },
  {
    wildcard: true,
    eventFilters: [
      { from: ZERO_ADDRESS, to: WHITELISTED },  // Mints to whitelisted addresses
      { from: WHITELISTED, to: ZERO_ADDRESS },  // Burns from whitelisted addresses
    ],
  }
);

The key difference is using an array [{...}, {...}] for OR logic vs. a single object {...} for AND logic.


🧠 Learnings used
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-10-13T12:27:30.803Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/EventHandlers.ts : Remove the original src/EventHandlers.ts after moving handlers into contract-specific files

Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-10-13T12:27:30.803Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/EventHandlers.ts : Clear all boilerplate logic from src/EventHandlers.ts and replace handlers with empty skeletons before implementing business logic

Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-10-13T12:26:45.351Z
Learning: Applies to src/EventHandlers.ts : Remove the monolithic EventHandlers.ts file after moving handlers to contract-specific files

Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-10-13T12:27:30.803Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/config.yaml : Refactor to contract-specific handler files in config.yaml and remove the single EventHandlers.ts reference

Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-10-13T12:26:45.351Z
Learning: Applies to src/EventHandlers.ts : Clear boilerplate logic in EventHandlers.ts and replace with empty handlers before implementing business logic

Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-10-13T12:27:30.803Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Register dynamic contracts using contractRegister above the creating event’s handler (e.g., context.addPair(event.params.pair))

Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-10-13T12:27:30.803Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Prefix all entity IDs with event.chainId and never hardcode chainId=1; accept chainId in helper functions; use chain-specific Bundle IDs like `${chainId}-1`

Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-10-13T12:26:45.351Z
Learning: Applies to src/**/*.ts : For multichain support, prefix all entity IDs with `${event.chainId}-...` and never hardcode `chainId = 1`

Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-10-13T12:27:30.803Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Do not access derivedFrom arrays in handlers; they are virtual. Use indexed queries (e.g., context.Entity.getWhere.<field>.eq(value)) instead

Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-10-13T12:27:30.803Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Consume external calls via context.effect within handlers; optionally guard with !context.isPreload when needed

Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-10-13T12:27:30.803Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/config.yaml : For events that create Transaction-linked entities (Transfer, Mint, Burn, Swap, etc.), ensure transaction hash is selected via field_selection

Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-10-13T12:27:30.803Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Avoid hardcoded values like addresses; use constants aligned with the original subgraph (e.g., FACTORY_ADDRESS, ADDRESS_ZERO)

Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-10-13T12:27:30.803Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Import entity types from generated/src/db/Entities.gen (e.g., Pair_t, Token_t) rather than from generated contract handlers

Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-10-13T12:26:45.351Z
Learning: Applies to src/**/*.ts : Register dynamically created contracts using `contractRegister` above the corresponding factory event handler

Comment on lines +1 to +21
{
"compilerOptions": {
"target": "es2020", //required for use with BigInt types
"lib": [
"es2020"
],
"allowJs": true,
"checkJs": false,
"outDir": "build",
"strict": true,
"noImplicitAny": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"module": "CommonJS"
},
"include": [
"src",
"test"
]
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

TypeScript configuration looks correct.

The configuration appropriately targets es2020 for BigInt support with strict type checking enabled. Ensure that TypeScript compilation succeeds with this configuration before merging.


🏁 Script executed:

#!/bin/bash
# Description: Verify TypeScript compilation for wildcard_indexing_template

cd codegenerator/cli/templates/static/wildcard_indexing_template/typescript
pnpm tsc --noEmit

Length of output: 197



🏁 Script executed:

#!/bin/bash
# Find package.json files in the codegenerator/cli/templates directory hierarchy
echo "=== Searching for package.json in templates directory ==="
find codegenerator/cli/templates -name "package.json" -type f | head -20

echo -e "\n=== Checking root package.json in codegenerator/cli ==="
if [ -f "codegenerator/cli/package.json" ]; then
  echo "Found: codegenerator/cli/package.json"
else
  echo "Not found at codegenerator/cli/package.json"
fi

echo -e "\n=== Checking if tsconfig.json is valid JSON ==="
cat codegenerator/cli/templates/static/wildcard_indexing_template/typescript/tsconfig.json | python3 -m json.tool > /dev/null && echo "Valid JSON" || echo "Invalid JSON"

echo -e "\n=== List contents of template directory ==="
ls -la codegenerator/cli/templates/static/wildcard_indexing_template/typescript/

Length of output: 679


🏁 Script executed:

#!/bin/bash
# Explore repository structure to understand how templates are used

echo "=== Searching for package.json in templates hierarchy ==="
find codegenerator/cli/templates -name "package.json" -type f 2>/dev/null

echo -e "\n=== Checking codegenerator/cli directory ==="
ls -la codegenerator/cli/ | grep -E "package|tsconfig"

echo -e "\n=== Validating tsconfig.json is valid JSON ==="
if python3 -m json.tool codegenerator/cli/templates/static/wildcard_indexing_template/typescript/tsconfig.json > /dev/null 2>&1; then
  echo "✓ tsconfig.json is valid JSON"
else
  echo "✗ tsconfig.json is invalid JSON"
fi

echo -e "\n=== Contents of wildcard_indexing_template directory ==="
find codegenerator/cli/templates/static/wildcard_indexing_template -type f

echo -e "\n=== Check if there's a root package.json ==="
[ -f "package.json" ] && echo "Found package.json at repository root" || echo "No package.json at root"

Length of output: 987



🏁 Script executed:

#!/bin/bash
# Check other template tsconfig.json files for the same issue

echo "=== Checking all tsconfig.json files in templates ==="
find codegenerator/cli/templates -name "tsconfig.json" -type f -print0 | xargs -0 -I {} sh -c 'echo "File: {}"; python3 -m json.tool "{}" > /dev/null 2>&1 && echo "  ✓ Valid JSON" || echo "  ✗ Invalid JSON"'

echo -e "\n=== Display onblock_handler_template tsconfig.json for comparison ==="
cat codegenerator/cli/templates/static/onblock_handler_template/typescript/tsconfig.json

Length of output: 1568


🏁 Script executed:

#!/bin/bash
# Check all tsconfig.json files in templates for validity

echo "=== Checking all tsconfig.json files in templates ==="
find codegenerator/cli/templates -name "tsconfig.json" -type f | while read file; do
  echo "File: $file"
  if python3 -m json.tool "$file" > /dev/null 2>&1; then
    echo "  ✓ Valid JSON"
  else
    echo "  ✗ Invalid JSON - Error details:"
    python3 -m json.tool "$file" 2>&1 | head -5
  fi
done

echo -e "\n=== Compare with onblock_handler_template tsconfig.json ==="
if [ -f "codegenerator/cli/templates/static/onblock_handler_template/typescript/tsconfig.json" ]; then
  echo "Content:"
  cat codegenerator/cli/templates/static/onblock_handler_template/typescript/tsconfig.json
fi

Length of output: 2517


Remove inline comments from tsconfig.json—they are invalid JSON syntax.

All template tsconfig.json files contain inline comments (e.g., //required for use with BigInt types) which violate JSON specification. While TypeScript can parse JSONC, the generated files will fail validation and cause issues with standard JSON tools. Move the comment to a line above the property or remove it entirely:

{
  "compilerOptions": {
    // Required for use with BigInt types
    "target": "es2020",
    ...
  }
}

This affects all 10 templates: blank_template, erc20_template, greeter_template, greeteronfuel_template, effects_api_template, factory_indexer_template, multichain_indexer_template, onblock_handler_template, topic_filtering_template, and wildcard_indexing_template.

🤖 Prompt for AI Agents
In
codegenerator/cli/templates/static/wildcard_indexing_template/typescript/tsconfig.json
lines 1-21, the file contains inline C++/JS-style comments (e.g., "//required
for use with BigInt types") which makes it invalid JSON; remove those inline
comments or relocate them to their own lines as JSON comments are not allowed in
standard JSON, so update the file to eliminate any // comments inside the JSON
object (and apply the same change across the other nine templates:
blank_template, erc20_template, greeter_template, greeteronfuel_template,
effects_api_template, factory_indexer_template, multichain_indexer_template,
onblock_handler_template, and topic_filtering_template) ensuring each
tsconfig.json is pure valid JSON with any explanatory notes moved outside the
JSON or into build docs.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (3)
codegenerator/cli/templates/static/topic_filtering_template/typescript/src/EventHandlers.ts (1)

16-22: Critical issue with eventFilters already flagged in previous review.

The configuration requiring both from and to to equal ZERO_ADDRESS simultaneously cannot match any valid ERC20 Transfer events. This issue has already been comprehensively documented in the previous review comment, which provides detailed explanations and suggests realistic filtering patterns (mints or burns).

codegenerator/cli/src/template_dirs.rs (1)

34-34: Remove the placeholder comment.

The comment suggests this is example code needing adjustment. Please remove it as the mappings appear to be the actual implementation.

-            // Example mappings — adjust based on what your actual templates support
codegenerator/cli/src/cli_args/init_config.rs (1)

29-47: Add #[clap(name = "...")] attributes to align CLI parsing with display strings.

The Template enum derives ValueEnum but lacks explicit #[clap(name = "...")] attributes, causing a critical mismatch:

  • Interactive UI (using Display via strum): Shows "ERC20", "Feature: Topic Filtering", etc.
  • CLI parsing (using ValueEnum): Accepts kebab-case variant names like "erc20", "topic-filtering", etc.

This breaks non-interactive usage where users see one set of strings but must type different ones.

Fix: Add #[clap(name = "...")] to each variant, mirroring the strum serialization. Reference the Language enum (lines 352-357) which demonstrates the correct pattern:

 #[derive(Clone, Debug, ValueEnum, Serialize, Deserialize, EnumIter, EnumString, Display)]
 pub enum Template {
+    #[clap(name = "Greeter")]
     #[strum(serialize = "Greeter")]
     Greeter,
+    #[clap(name = "ERC20")]
     #[strum(serialize = "ERC20")]
     Erc20,
+    #[clap(name = "Feature: Topic Filtering")]
     #[strum(serialize = "Feature: Topic Filtering")]
     TopicFiltering,
+    #[clap(name = "Feature: Wildcard Indexing")]
     #[strum(serialize = "Feature: Wildcard Indexing")]
     WildcardIndexing,
+    #[clap(name = "Feature: onBlock Handler")]
     #[strum(serialize = "Feature: onBlock Handler")]
     OnBlockHandler,
+    #[clap(name = "Feature: Effects API")]
     #[strum(serialize = "Feature: Effects API")]
     EffectsAPI,
+    #[clap(name = "Feature: Factory Indexer")]
     #[strum(serialize = "Feature: Factory Indexer")]
     FactoryIndexer,
+    #[clap(name = "Feature: Multichain Indexer")]
     #[strum(serialize = "Feature: Multichain Indexer")]
     MultichainIndexer,
 }
🧹 Nitpick comments (1)
codegenerator/cli/templates/static/wildcard_indexing_template/typescript/src/EventHandlers.ts (1)

3-14: LGTM! Wildcard handler implementation is correct.

The handler correctly implements wildcard ERC20 Transfer indexing. The ID composition (chainId_blockNumber_logIndex) ensures uniqueness across chains and within blocks, and all required fields are properly mapped from the event parameters.

Consider adding a timestamp field to improve queryability:

 ERC20.Transfer.handler(
   async ({ event, context }) => {
     context.Transfer.set({
       id: `${event.chainId}_${event.block.number}_${event.logIndex}`,
       amount: event.params.value,
       from: event.params.from,
       to: event.params.to,
       contract: event.srcAddress,
+      timestamp: event.block.timestamp,
     });
   },
   { wildcard: true },
 );

Note: This would also require updating the schema to include the timestamp field.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6efc6c9 and a03fee0.

📒 Files selected for processing (4)
  • codegenerator/cli/src/cli_args/init_config.rs (1 hunks)
  • codegenerator/cli/src/template_dirs.rs (3 hunks)
  • codegenerator/cli/templates/static/topic_filtering_template/typescript/src/EventHandlers.ts (1 hunks)
  • codegenerator/cli/templates/static/wildcard_indexing_template/typescript/src/EventHandlers.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
codegenerator/cli/**

📄 CodeRabbit inference engine (.cursor/rules/navigation.mdc)

The Rust CLI lives in codegenerator/cli

Files:

  • codegenerator/cli/src/template_dirs.rs
  • codegenerator/cli/templates/static/wildcard_indexing_template/typescript/src/EventHandlers.ts
  • codegenerator/cli/src/cli_args/init_config.rs
  • codegenerator/cli/templates/static/topic_filtering_template/typescript/src/EventHandlers.ts
🧠 Learnings (7)
📚 Learning: 2025-10-21T16:31:22.099Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-10-21T16:31:22.099Z
Learning: Applies to codegenerator/cli/src/hbs_templating/codegen_templates.rs : hbs_templating/codegen_templates.rs feeds templates

Applied to files:

  • codegenerator/cli/src/template_dirs.rs
📚 Learning: 2025-10-13T12:27:30.803Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-10-13T12:27:30.803Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/EventHandlers.ts : Remove the original src/EventHandlers.ts after moving handlers into contract-specific files

Applied to files:

  • codegenerator/cli/templates/static/wildcard_indexing_template/typescript/src/EventHandlers.ts
  • codegenerator/cli/templates/static/topic_filtering_template/typescript/src/EventHandlers.ts
📚 Learning: 2025-10-13T12:26:45.351Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: .cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-10-13T12:26:45.351Z
Learning: Applies to src/EventHandlers.ts : Remove the monolithic EventHandlers.ts file after moving handlers to contract-specific files

Applied to files:

  • codegenerator/cli/templates/static/wildcard_indexing_template/typescript/src/EventHandlers.ts
  • codegenerator/cli/templates/static/topic_filtering_template/typescript/src/EventHandlers.ts
📚 Learning: 2025-10-13T12:27:30.803Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-10-13T12:27:30.803Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/EventHandlers.ts : Clear all boilerplate logic from src/EventHandlers.ts and replace handlers with empty skeletons before implementing business logic

Applied to files:

  • codegenerator/cli/templates/static/wildcard_indexing_template/typescript/src/EventHandlers.ts
  • codegenerator/cli/templates/static/topic_filtering_template/typescript/src/EventHandlers.ts
📚 Learning: 2025-10-13T12:27:30.803Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-10-13T12:27:30.803Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/config.yaml : Refactor to contract-specific handler files in config.yaml and remove the single EventHandlers.ts reference

Applied to files:

  • codegenerator/cli/templates/static/wildcard_indexing_template/typescript/src/EventHandlers.ts
  • codegenerator/cli/templates/static/topic_filtering_template/typescript/src/EventHandlers.ts
📚 Learning: 2025-10-13T12:27:30.803Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-10-13T12:27:30.803Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Register dynamic contracts using contractRegister above the creating event’s handler (e.g., context.addPair(event.params.pair))

Applied to files:

  • codegenerator/cli/templates/static/wildcard_indexing_template/typescript/src/EventHandlers.ts
📚 Learning: 2025-10-13T12:26:45.351Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: .cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-10-13T12:26:45.351Z
Learning: Applies to src/EventHandlers.ts : Clear boilerplate logic in EventHandlers.ts and replace with empty handlers before implementing business logic

Applied to files:

  • codegenerator/cli/templates/static/topic_filtering_template/typescript/src/EventHandlers.ts
🧬 Code graph analysis (2)
codegenerator/cli/src/template_dirs.rs (2)
codegenerator/cli/src/cli_args/interactive_init/mod.rs (1)
  • Language (152-154)
codegenerator/cli/src/hbs_templating/init_templates.rs (1)
  • new (23-58)
codegenerator/cli/src/cli_args/init_config.rs (2)
codegenerator/cli/src/config_parsing/entity_parsing.rs (2)
  • serialize (1177-1182)
  • serialize (1328-1333)
codegenerator/cli/src/rescript_types.rs (1)
  • serialize (703-709)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build_and_test
🔇 Additional comments (7)
codegenerator/cli/templates/static/wildcard_indexing_template/typescript/src/EventHandlers.ts (1)

1-1: LGTM!

The import statement correctly references the generated ERC20 contract bindings.

codegenerator/cli/templates/static/topic_filtering_template/typescript/src/EventHandlers.ts (2)

1-3: LGTM!

Import and constant definitions are correct. The ZERO_ADDRESS constant is properly formatted for Ethereum addresses.


6-15: LGTM!

The handler implementation is correct. The composite ID format ensures uniqueness across chains and blocks, and the field mappings properly extract Transfer event data into the entity.

codegenerator/cli/src/template_dirs.rs (4)

13-14: LGTM! Clean trait extension for language-aware filtering.

The new supported_languages() method enables the language-based template filtering described in the PR objectives.


63-71: LGTM! Fuel template language support correctly configured.

The implementation correctly specifies that the Greeter template supports all three languages, consistent with the EVM Greeter template.


475-559: LGTM! Tests correctly updated to use language-aware filtering.

The tests now properly iterate only over each template's supported languages rather than all languages globally. This prevents false failures when templates don't support all languages and aligns with the language-based template filtering introduced in this PR.


22-28: All new template directories exist and are correctly mapped.

Verification confirms that all six template directories are present in the filesystem and correctly referenced by the code mappings in to_dir_name(). The code changes are sound.

@DZakh DZakh mentioned this pull request Oct 23, 2025
4 tasks
Comment on lines +35 to +46
#[strum(serialize = "Feature: Topic Filtering")]
TopicFiltering,
#[strum(serialize = "Feature: Wildcard Indexing")]
WildcardIndexing,
#[strum(serialize = "Feature: onBlock Handler")]
OnBlockHandler,
#[strum(serialize = "Feature: Effects API")]
EffectsAPI,
#[strum(serialize = "Feature: Factory Indexer")]
FactoryIndexer,
#[strum(serialize = "Feature: Multichain Indexer")]
MultichainIndexer,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#[strum(serialize = "Feature: Topic Filtering")]
TopicFiltering,
#[strum(serialize = "Feature: Wildcard Indexing")]
WildcardIndexing,
#[strum(serialize = "Feature: onBlock Handler")]
OnBlockHandler,
#[strum(serialize = "Feature: Effects API")]
EffectsAPI,
#[strum(serialize = "Feature: Factory Indexer")]
FactoryIndexer,
#[strum(serialize = "Feature: Multichain Indexer")]
MultichainIndexer,
#[strum(serialize = "Feature: Topic Filtering")]
TopicFiltering,
#[strum(serialize = "Feature: Wildcard Indexing")]
WildcardIndexing,
#[strum(serialize = "Feature: Block Handler")]
OnBlockHandler,
#[strum(serialize = "Feature: External Calls")]
EffectsAPI,
#[strum(serialize = "Feature: Factory Contract")]
FactoryIndexer,
#[strum(serialize = "Feature: Multichain Indexer")]
MultichainIndexer,

Copy link
Member

@DZakh DZakh left a comment

Choose a reason for hiding this comment

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

Nice work 👍 If you don't mind, I'll continue reviewing after we get rid of Js and ReScript templates 🙏

@nikbhintade
Copy link
Member Author

@DZakh I have removed the JS & ReScript templates. I didn’t change the current structure for selecting templates, which is from the language subdirectory of the template. I did start with it, but it kept getting harder, so I kept it as it was.

The step of language selection is removed from the CLI; instead, TypeScript is hardcoded, so the rest of the code will remain the same.

After removing the JS & ReScript template, I have fixed all the tests that were using ReScript or JS.

Please let me know if any other changes are needed.

Copy link
Member

@DZakh DZakh left a comment

Choose a reason for hiding this comment

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

Hi, @nikbhintade nice job 👍 I left some comments. If it's getting difficult to change all at once, you can split this into multiple PRs:

  • Remove js, rescript templates
  • Remove language selection from init
  • Add a new template per PR

Also, it'd be nice to init HyperIndex with git configured. And ideally move the templates to a separate repo, but it can be scoped out.

* `-l`, `--language <LANGUAGE>` — The language used to write handlers

Possible values: `javascript`, `typescript`, `rescript`
Possible values: `typescript`
Copy link
Member

Choose a reason for hiding this comment

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

It would be nice to keep ReScript option for contract import. No need to have a promt for it, only as a cli.

.context("parsing user input for language selection")?
}
};
let language = Language::TypeScript;
Copy link
Member

Choose a reason for hiding this comment

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

I'd do it this way. Also need to perform this check only for contract import flow. Since templates are TS only.

Suggested change
let language = Language::TypeScript;
let language = match init_args.language {
Some(args_language) => args_language,
None => Language::TypeScript
};

Comment on lines 255 to +256
let int_as_string = |int_var_name| match language {
Language::ReScript => format!("{int_var_name}->Belt.Int.toString"),
Language::TypeScript | Language::JavaScript => int_var_name,
Language::TypeScript => int_var_name,
Copy link
Member

Choose a reason for hiding this comment

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

Let's keep ReScript here

build/
benchmarks/
artifacts
cache
Copy link
Member

Choose a reason for hiding this comment

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

Let's remove it from here

functionName: "decimals",
});

console.log(`Token decimals: ${decimals}`);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
console.log(`Token decimals: ${decimals}`);

Comment on lines +6 to +17
UniswapV3Factory.PoolCreated.handler(async ({ event, context }) => {
const entity = {
id: `${event.chainId}_${event.params.pool}`,
token0: event.params.token0,
token1: event.params.token1,
fee: event.params.fee,
tickSpacing: event.params.tickSpacing,
pool: event.params.pool,
};

context.UniswapV3Factory_PoolCreated.set(entity);
});
Copy link
Member

Choose a reason for hiding this comment

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

Let's remove the handler and UniswapV3Factory_PoolCreated since it's not relevant for the template.

Comment on lines +1 to +20
type UniswapV3Factory_FeeAmountEnabled {
id: ID!
fee: BigInt!
tickSpacing: BigInt!
}

type UniswapV3Factory_OwnerChanged {
id: ID!
oldOwner: String!
newOwner: String!
}

type UniswapV3Factory_PoolCreated {
id: ID!
token0: String!
token1: String!
fee: BigInt!
tickSpacing: BigInt!
pool: String!
}
Copy link
Member

Choose a reason for hiding this comment

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

Let's also store chainId here, since it's a common pattern for multichain indexers. You can event add @index for it.

Comment on lines +67 to +74
const latestEntity: TotalSupply = {
id: "latest",
currentSupply: newSupply,
blockNumber: BigInt(event.block.number),
timestamp: BigInt(event.block.timestamp),
};

context.TotalSupply.set(latestEntity);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const latestEntity: TotalSupply = {
id: "latest",
currentSupply: newSupply,
blockNumber: BigInt(event.block.number),
timestamp: BigInt(event.block.timestamp),
};
context.TotalSupply.set(latestEntity);
const latestEntity: TotalSupply = {
id: "latest",
currentSupply: newSupply,
blockNumber: BigInt(event.block.number),
timestamp: BigInt(event.block.timestamp),
};
context.TotalSupply.set({
...latestSupply,
currentSupply: newSupply
});

Comment on lines +18 to +19
}
,
Copy link
Member

Choose a reason for hiding this comment

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

Formatting

Comment on lines +16 to +22
{
wildcard: true,
eventFilters: {
from: ZERO_ADDRESS,
to: ZERO_ADDRESS,
}
},
Copy link
Member

Choose a reason for hiding this comment

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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants