-
Notifications
You must be signed in to change notification settings - Fork 29
Multichain Indexer Template (Template 1/6) #822
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
WalkthroughAdds 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
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)
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this 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
.gitignorehas 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
📒 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.jsoncodegenerator/cli/src/template_dirs.rscodegenerator/cli/templates/static/multichain_indexer_template/shared/schema.graphqlcodegenerator/cli/templates/static/multichain_indexer_template/typescript/src/EventHandlers.tscodegenerator/cli/templates/static/multichain_indexer_template/shared/README.mdcodegenerator/cli/templates/static/multichain_indexer_template/typescript/config.yamlcodegenerator/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.rscodegenerator/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
MultichainIndexervariant uses "Feature: Multichain Indexer" as its display name, which differs from the simpler naming ofGreeterandErc20. 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
MultichainIndexeris 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
FeeAmountEnabledhandler correctly maps event parameters to the entity and uses a composite ID that ensures uniqueness across chains.
22-31: LGTM!The
OwnerChangedhandler follows the same correct pattern, mapping event parameters appropriately.
33-45: LGTM!The
PoolCreatedhandler 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_FeeAmountEnabledtype is well-defined with appropriate field types and helpful documentation. The@indexdirective onchainIdis good for query performance.
12-21: LGTM!The
UniswapV3Factory_OwnerChangedtype correctly models the ownership change event with appropriate field types.
23-38: LGTM!The
UniswapV3Factory_PoolCreatedtype 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. Thestart_block: 0pattern 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.
There was a problem hiding this 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.examplefiles 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
.envconventions, that's also acceptable.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 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
Summary by CodeRabbit
New Features
Documentation