Skip to content

Conversation

@nikbhintade
Copy link
Member

@nikbhintade nikbhintade commented Nov 11, 2025

Summary by CodeRabbit

  • New Features

    • Added a Multichain Indexer template for indexing across multiple blockchains, plus a new CLI template option.
    • Added event handlers and GraphQL types to capture Uniswap V3 factory events.
    • Included TypeScript build config, example env entries, and repository ignore patterns for the template.
  • Documentation

    • Added a comprehensive README with usage, configuration examples, and run/codegen instructions.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 11, 2025

Walkthrough

Adds a new "Multichain Indexer" template: a Template enum variant with Strum serialization, mapping to a new directory name, and static TypeScript template files (schema, config, event handlers, docs, and supporting files) for indexing Uniswap V3 across multiple chains.

Changes

Cohort / File(s) Summary
CLI enum & mapping
codegenerator/cli/src/cli_args/init_config.rs, codegenerator/cli/src/template_dirs.rs
Added MultichainIndexer variant to public Template enum with #[strum(serialize = "Feature: Multichain Indexer")]; annotated Greeter and Erc20 with explicit #[strum(serialize = "...")]. Added mapping to "multichain_indexer" in template_dirs.rs.
Template static shared files
codegenerator/cli/templates/static/multichain_indexer_template/shared/*
Added .gitignore, README.md (usage, config examples, run/codegen steps), .env.example (ENVIO_API_TOKEN placeholder), and schema.graphql defining three entity types: UniswapV3Factory_FeeAmountEnabled, UniswapV3Factory_OwnerChanged, UniswapV3Factory_PoolCreated (each with chainId indexed).
TypeScript template & build config
codegenerator/cli/templates/static/multichain_indexer_template/typescript/...
Added config.yaml (UniswapV3Factory contract + event signatures, networks for chain IDs 1, 130, 42161, unordered_multichain_mode, preload handlers), src/EventHandlers.ts (three async handlers creating/persisting entities), and tsconfig.json (strict TS settings).
Docs / CLI help
codegenerator/cli/CommandLineHelp.md
Added multichain-indexer as a new possible value for the template option in CLI help.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant CLI as dev CLI
  participant Init as init_config
  participant FS as template files
  note over CLI,Init: User selects "multichain-indexer"
  CLI->>Init: parse option -> Template::MultichainIndexer
  Init->>FS: resolve "multichain_indexer" dir -> copy template files
  note over FS: files created (schema, config.yaml, src/EventHandlers.ts, README)
Loading
sequenceDiagram
  autonumber
  participant Chain as Blockchain (any network)
  participant Env as Envio runtime
  participant Handler as EventHandlers.ts
  participant Store as Indexer context (context.set)
  note over Chain,Handler: UniswapV3Factory events emitted
  Chain->>Env: log/event
  Env->>Handler: invoke handler with event + context
  Handler->>Store: build entity (id from chainId:block:logIndex) -> context.set(entity)
  alt success
    Store-->>Handler: ack
  else error
    Store-->>Handler: error
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Review focuses: new public enum variant serialization, template directory mapping, GraphQL schema consistency, event handler field mappings and ID construction, and config.yaml network/addresses.
  • Files requiring extra attention:
    • codegenerator/cli/src/cli_args/init_config.rs — ensure Strum annotations match CLI help strings.
    • codegenerator/cli/src/template_dirs.rs — mapping correctness.
    • .../shared/schema.graphql and .../typescript/src/EventHandlers.ts — alignment between schema, generated types, and handler persistence.
    • .../typescript/config.yaml — network chain IDs and addresses.

Suggested reviewers

  • JonoPrest
  • DZakh

Poem

🐰 I hopped through code and built a bridge of light,
Multichain whispers turned to indexed sight.
Events arrive, I stitch them tight—
Chains converge, entities alight.
Hop on, the index hums tonight! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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 PR title 'Multichain Indexer Template (Template 1/6)' accurately describes the main change: adding a new multichain indexer template to the codebase.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch nb/multichain-template

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: 0

🧹 Nitpick comments (1)
codegenerator/cli/templates/static/multichain_indexer_template/shared/.gitignore (1)

1-35: Remove duplicate entries.

The .gitignore has duplicate patterns: *.obj (lines 2 and 16) and *.annot (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
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1fc77a8 and 71bc5b7.

📒 Files selected for processing (8)
  • codegenerator/cli/src/cli_args/init_config.rs (1 hunks)
  • codegenerator/cli/src/template_dirs.rs (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)
🧰 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/multichain_indexer_template/typescript/tsconfig.json
  • codegenerator/cli/src/template_dirs.rs
  • codegenerator/cli/templates/static/multichain_indexer_template/shared/schema.graphql
  • codegenerator/cli/templates/static/multichain_indexer_template/typescript/src/EventHandlers.ts
  • codegenerator/cli/templates/static/multichain_indexer_template/shared/README.md
  • codegenerator/cli/templates/static/multichain_indexer_template/typescript/config.yaml
  • codegenerator/cli/src/cli_args/init_config.rs
🧠 Learnings (6)
📓 Common learnings
Learnt from: CR
Repo: enviodev/hyperindex PR: 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
📚 Learning: 2025-10-21T16:31:22.127Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-10-21T16:31:22.127Z
Learning: Compiled .js artifacts can be ignored

Applied to files:

  • codegenerator/cli/templates/static/multichain_indexer_template/shared/.gitignore
📚 Learning: 2025-10-21T16:31:22.127Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-10-21T16:31:22.127Z
Learning: Applies to codegenerator/cli/templates/static/**/*.res : Static templates are raw ReScript files copied verbatim under codegenerator/cli/templates/static

Applied to files:

  • codegenerator/cli/templates/static/multichain_indexer_template/shared/.gitignore
📚 Learning: 2025-10-21T16:31:22.127Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-10-21T16:31:22.127Z
Learning: Applies to **/*.res : Prefer reading ReScript .res modules directly

Applied to files:

  • codegenerator/cli/templates/static/multichain_indexer_template/shared/.gitignore
📚 Learning: 2025-10-21T16:31:22.127Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 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
  • codegenerator/cli/src/cli_args/init_config.rs
📚 Learning: 2025-10-21T16:31:22.127Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-10-21T16:31:22.127Z
Learning: Applies to codegenerator/cli/src/system_config.rs : system_config.rs converts to internal structs

Applied to files:

  • codegenerator/cli/src/cli_args/init_config.rs
🧬 Code graph analysis (1)
codegenerator/cli/src/cli_args/init_config.rs (2)
codegenerator/cli/src/config_parsing/entity_parsing.rs (2)
  • serialize (1184-1189)
  • serialize (1335-1340)
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 (11)
codegenerator/cli/templates/static/multichain_indexer_template/shared/README.md (1)

1-44: LGTM!

The documentation is clear, well-structured, and provides helpful guidance for users getting started with the multichain indexer template.

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

29-37: LGTM! Verify the "Feature:" prefix is intentional.

The strum serialization attributes are correctly added. The new MultichainIndexer variant uses "Feature: Multichain Indexer" as its display name, which differs from the simpler naming of Greeter and Erc20. Ensure this prefix is intentional and consistent with your template categorization scheme.

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

15-24: LGTM!

The directory mapping for MultichainIndexer is correctly implemented and follows the established pattern for template directory names.

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

1-21: LGTM!

The TypeScript configuration is well-suited for blockchain indexing with appropriate strict type checking, ES2020 target for BigInt support, and standard compilation settings.

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

11-20: LGTM!

The FeeAmountEnabled handler correctly maps event parameters to the entity and uses a composite ID that ensures uniqueness across chains.


22-31: LGTM!

The OwnerChanged handler follows the same correct pattern, mapping event parameters appropriately.


33-45: LGTM!

The PoolCreated handler is correctly implemented with all required fields (token0, token1, fee, tickSpacing, pool) properly mapped from the event parameters.

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

1-10: LGTM!

The UniswapV3Factory_FeeAmountEnabled type is well-defined with appropriate field types and helpful documentation. The @index directive on chainId is good for query performance.


12-21: LGTM!

The UniswapV3Factory_OwnerChanged type correctly models the ownership change event with appropriate field types.


23-38: LGTM!

The UniswapV3Factory_PoolCreated type comprehensively captures all pool creation parameters with clear documentation for each field.

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

11-28: Let me search for the actual Uniswap V3 Factory deployment block information:

Based on my verification findings:

Partially validate the concern about contract addresses, but with template context.

Network ID 130 correctly represents Unichain Mainnet, as verified. However, regarding contract addresses:

  • The canonical Uniswap V3 Factory address 0x1F98431c8aD98523631AE4a59f267346ea31F984 is used across Mainnet, Polygon, Optimism, and Arbitrum
  • The address for chain 130 (0x1F98400000000000000000000000000000000003) appears to be a placeholder rather than the actual canonical factory address
  • The addresses for chains 1 and 42161 are correct

Since this file resides in codegenerator/cli/templates/static/multichain_indexer_template/, it is a template/example configuration. Template files typically use placeholder values for demonstration. If this template is intended for real usage, the chain 130 address should be verified and corrected. The start_block: 0 pattern is acceptable for a template but would need proper deployment block values for production use.

Consider clarifying in the template whether the addresses are actual deployments or placeholders, particularly for chain 130.

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

🧹 Nitpick comments (1)
codegenerator/cli/templates/static/multichain_indexer_template/shared/.env.example (1)

1-2: Minor: Consider removing quotes from placeholder value.

The dotenv-linter flags the QuoteCharacter issue on line 2. While this doesn't cause functional problems, conventional .env.example files typically omit quotes around simple placeholder values like <YOUR-API-TOKEN> since they lack spaces or shell-special characters. This also makes it clearer to users that this is a placeholder requiring replacement.

Optional refinement:

-ENVIO_API_TOKEN="<YOUR-API-TOKEN>"
+ENVIO_API_TOKEN=<YOUR-API-TOKEN>

The guidance comment on line 1 is clear and helpful. If you'd like to keep the quotes for consistency with your project's .env conventions, that's also acceptable.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 71bc5b7 and 7763509.

📒 Files selected for processing (2)
  • codegenerator/cli/CommandLineHelp.md (1 hunks)
  • codegenerator/cli/templates/static/multichain_indexer_template/shared/.env.example (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • codegenerator/cli/CommandLineHelp.md
🧰 Additional context used
🪛 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)

⏰ 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

@nikbhintade nikbhintade requested a review from DZakh November 11, 2025 12:02
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.

2 participants