Add block handler support for fuel - #820
Conversation
WalkthroughThis pull request introduces multi-ecosystem block event support by making block event types generic and platform-specific. It replaces fixed block event definitions with parameterized types (blockEvent for EVM, fuelBlockEvent for Fuel), adds a Platform abstraction for dynamic block event construction, and threads platform configuration through event processing layers. The platform guard preventing non-EVM platforms is also removed. Changes
Sequence DiagramsequenceDiagram
participant EventProcessing
participant Platform
participant Handlers
Note over EventProcessing,Handlers: Old Flow (Fixed Block Type)
EventProcessing->>Handlers: onBlockArgs<blockEvent, context>
Note over EventProcessing,Handlers: New Flow (Platform-Specific Block Type)
EventProcessing->>Platform: makeBlockEvent(blockNumber, chainId, platform)
Platform-->>EventProcessing: blockEvent or fuelBlockEvent
EventProcessing->>Handlers: onBlockArgs<BlockType, context>
Note right of Handlers: BlockType resolved from platform
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
codegenerator/cli/npm/envio/src/Platform.res (1)
135-141: Consider safer alternatives to Utils.magic for type coercion.While the dynamic field naming based on
platform.blockNumberNameis clever and the implementation is straightforward, the three uses ofUtils.magicfor type coercion (lines 138-140) could be fragile if types change. Consider whether@objor external functions could provide safer type coercion, though dynamic field naming may make this challenging.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
scenarios/test_codegen/pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (10)
codegenerator/cli/npm/envio/index.d.ts(1 hunks)codegenerator/cli/npm/envio/src/Envio.gen.ts(1 hunks)codegenerator/cli/npm/envio/src/Envio.res(1 hunks)codegenerator/cli/npm/envio/src/EventRegister.res(0 hunks)codegenerator/cli/npm/envio/src/Internal.gen.ts(0 hunks)codegenerator/cli/npm/envio/src/Internal.res(1 hunks)codegenerator/cli/npm/envio/src/Platform.res(1 hunks)codegenerator/cli/templates/dynamic/codegen/src/Handlers.res.hbs(1 hunks)codegenerator/cli/templates/dynamic/codegen/src/TestHelpers_MockDb.res.hbs(1 hunks)codegenerator/cli/templates/static/codegen/src/EventProcessing.res(4 hunks)
💤 Files with no reviewable changes (2)
- codegenerator/cli/npm/envio/src/EventRegister.res
- codegenerator/cli/npm/envio/src/Internal.gen.ts
🧰 Additional context used
📓 Path-based instructions (6)
codegenerator/cli/**
📄 CodeRabbit inference engine (.cursor/rules/navigation.mdc)
The Rust CLI lives in codegenerator/cli
Files:
codegenerator/cli/templates/dynamic/codegen/src/TestHelpers_MockDb.res.hbscodegenerator/cli/npm/envio/src/Envio.rescodegenerator/cli/templates/dynamic/codegen/src/Handlers.res.hbscodegenerator/cli/npm/envio/src/Platform.rescodegenerator/cli/npm/envio/index.d.tscodegenerator/cli/templates/static/codegen/src/EventProcessing.rescodegenerator/cli/npm/envio/src/Internal.rescodegenerator/cli/npm/envio/src/Envio.gen.ts
codegenerator/cli/templates/dynamic/**/*.hbs
📄 CodeRabbit inference engine (.cursor/rules/navigation.mdc)
Dynamic templates are Handlebars files under codegenerator/cli/templates/dynamic
Files:
codegenerator/cli/templates/dynamic/codegen/src/TestHelpers_MockDb.res.hbscodegenerator/cli/templates/dynamic/codegen/src/Handlers.res.hbs
{codegenerator/cli/templates/static/codegen/src/**,codegenerator/cli/templates/dynamic/codegen/src/**}
📄 CodeRabbit inference engine (.cursor/rules/navigation.mdc)
Template versions of runtime live under templates/{static,dynamic}/codegen/src and are the recommended editing targets
Files:
codegenerator/cli/templates/dynamic/codegen/src/TestHelpers_MockDb.res.hbscodegenerator/cli/templates/dynamic/codegen/src/Handlers.res.hbscodegenerator/cli/templates/static/codegen/src/EventProcessing.res
**/*.res
📄 CodeRabbit inference engine (.cursor/rules/navigation.mdc)
Prefer reading ReScript .res modules directly
Files:
codegenerator/cli/npm/envio/src/Envio.rescodegenerator/cli/npm/envio/src/Platform.rescodegenerator/cli/templates/static/codegen/src/EventProcessing.rescodegenerator/cli/npm/envio/src/Internal.res
codegenerator/cli/npm/envio/**
📄 CodeRabbit inference engine (.cursor/rules/navigation.mdc)
Shared library-fied runtime lives in codegenerator/cli/npm/envio
Files:
codegenerator/cli/npm/envio/src/Envio.rescodegenerator/cli/npm/envio/src/Platform.rescodegenerator/cli/npm/envio/index.d.tscodegenerator/cli/npm/envio/src/Internal.rescodegenerator/cli/npm/envio/src/Envio.gen.ts
codegenerator/cli/templates/static/**/*.res
📄 CodeRabbit inference engine (.cursor/rules/navigation.mdc)
Static templates are raw ReScript files copied verbatim under codegenerator/cli/templates/static
Files:
codegenerator/cli/templates/static/codegen/src/EventProcessing.res
🧠 Learnings (2)
📚 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/dynamic/**/*.hbs : Dynamic templates are Handlebars files under codegenerator/cli/templates/dynamic
Applied to files:
codegenerator/cli/templates/dynamic/codegen/src/Handlers.res.hbs
📚 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 generated/src/EventProcessing.res : In generated runtime, EventProcessing.res handles processing
Applied to files:
codegenerator/cli/templates/static/codegen/src/EventProcessing.res
🧬 Code graph analysis (1)
codegenerator/cli/npm/envio/src/Envio.gen.ts (1)
codegenerator/cli/npm/envio/index.d.ts (3)
blockEvent(9-9)fuelBlockEvent(10-10)onBlockArgs(11-11)
⏰ 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/npm/envio/index.d.ts (1)
10-10: LGTM! New Fuel block event type export.The new
fuelBlockEventexport follows the existing pattern and correctly extends the public API to support Fuel ecosystem block handlers.codegenerator/cli/npm/envio/src/Internal.res (1)
172-173: Well-designed abstraction using opaque type.Making
blockEventopaque is an excellent design choice that enforces platform-specific construction throughPlatform.makeBlockEvent, preventing direct manipulation and ensuring consistency across EVM and Fuel ecosystems.codegenerator/cli/templates/dynamic/codegen/src/TestHelpers_MockDb.res.hbs (1)
517-517: Correct parameter threading for platform abstraction.The platform parameter is properly sourced from
indexer.config.platformand passed topreloadBatchOrThrow, maintaining consistency with the production code changes in EventProcessing.res.codegenerator/cli/npm/envio/src/Envio.gen.ts (1)
14-18: Well-structured multi-ecosystem type definitions.The distinct
blockEventandfuelBlockEventtypes with platform-specific field names (numberfor EVM,heightfor Fuel) combined with the genericonBlockArgs<block,context>provide excellent type safety and clear separation of concerns for multi-ecosystem support.codegenerator/cli/templates/dynamic/codegen/src/Handlers.res.hbs (1)
13-17: Clean ecosystem-specific type selection in template.The conditional type selection based on
is_evm_ecosystemproperly instantiatesonBlockArgswith the appropriate block event type (blockEventfor EVM,fuelBlockEventfor Fuel), maintaining type safety across ecosystems.codegenerator/cli/npm/envio/src/Envio.res (2)
5-17: Excellent type design with clear documentation.The separate
blockEventandfuelBlockEventtypes with helpful comments explaining the EVM vs Fuel field naming differences (numbervsheight) make the multi-ecosystem support clear and maintainable. The backward compatibility note for EVM is particularly valuable.
20-23: Well-designed generic type for multi-ecosystem support.Making
onBlockArgsgeneric over both'blockand'contextis a clean design that enables type-safe usage with both EVM and Fuel block event types while maintaining flexibility.codegenerator/cli/templates/static/codegen/src/EventProcessing.res (4)
191-194: Correct platform-aware block event construction.The block event construction now properly uses
Platform.makeBlockEventwith the platform fromindexer.config, ensuring the correct field names (numberfor EVM,heightfor Fuel) are used dynamically.
241-241: Necessary parameter addition for platform abstraction.Adding the
~platform: Platform.tparameter topreloadBatchOrThrowenables platform-aware block event construction during the preload phase, completing the platform abstraction threading through the processing pipeline.
291-294: Consistent block event construction in preload path.The block event construction in the preload phase correctly uses
Platform.makeBlockEventwith the same pattern as the handler path, ensuring consistency between preload and execution phases.
412-412: Complete parameter threading for platform abstraction.The platform parameter is correctly sourced from
indexer.config.platformand passed topreloadBatchOrThrow, completing the consistent threading of platform information through the entire event processing pipeline.
Nobody asked, but still 🫡
(only because Solana and block.events feature)
Summary by CodeRabbit
Release Notes
New Features
Bug Fixes