Skip to content

Add block handler support for fuel - #820

Merged
DZakh merged 7 commits into
mainfrom
feat-fuel-block-handler-BHcot
Nov 12, 2025
Merged

Add block handler support for fuel#820
DZakh merged 7 commits into
mainfrom
feat-fuel-block-handler-BHcot

Conversation

@DZakh

@DZakh DZakh commented Nov 10, 2025

Copy link
Copy Markdown
Member

Nobody asked, but still 🫡

(only because Solana and block.events feature)

Summary by CodeRabbit

Release Notes

  • New Features

    • Added support for Fuel blockchain block events, enabling event handling on Fuel chains
    • Implemented ecosystem-aware block handler parameters that adapt to EVM and Fuel blockchains
  • Bug Fixes

    • Removed platform-specific validation restrictions that prevented non-EVM blockchain support in block handlers

@coderabbitai

coderabbitai Bot commented Nov 10, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This 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

Cohort / File(s) Summary
Type exports and re-exports
codegenerator/cli/npm/envio/index.d.ts
Exports new fuelBlockEvent type alias from generated source
Core type definitions
codegenerator/cli/npm/envio/src/Envio.gen.ts, codegenerator/cli/npm/envio/src/Envio.res
Adds blockEvent (EVM) and fuelBlockEvent (Fuel) types; transforms onBlockArgs from single-generic onBlockArgs<context> to two-generic onBlockArgs<block, context> for ecosystem flexibility
Internal type abstractions
codegenerator/cli/npm/envio/src/Internal.gen.ts, codegenerator/cli/npm/envio/src/Internal.res
Removes public blockEvent export from Internal.gen.ts; replaces concrete blockEvent with opaque type in Internal.res; removes context field from onBlockArgs
Platform abstraction
codegenerator/cli/npm/envio/src/Platform.res
Adds makeBlockEvent function to construct platform-specific block events dynamically using platform configuration
Handler registration
codegenerator/cli/npm/envio/src/EventRegister.res
Removes platform guard check, allowing non-EVM platforms to proceed through block event registration
Event processing logic
codegenerator/cli/templates/static/codegen/src/EventProcessing.res
Adds ~platform parameter to preloadBatchOrThrow; threads platform through call sites; replaces literal block object creation with Platform.makeBlockEvent invocations
Handler templates
codegenerator/cli/templates/dynamic/codegen/src/Handlers.res.hbs
Adds conditional block type to onBlock signature: Envio.blockEvent for EVM, Envio.fuelBlockEvent for Fuel
Test helper templates
codegenerator/cli/templates/dynamic/codegen/src/TestHelpers_MockDb.res.hbs
Passes ~platform=indexer.config.platform to preloadBatchOrThrow call

Sequence Diagram

sequenceDiagram
    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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Areas requiring attention:
    • Generic parameter addition to onBlockArgs and its cascading effects across type definitions and handler templates
    • Platform abstraction threading through EventProcessing and call sites to ensure consistent platform configuration passing
    • Internal vs. public type boundary: opaque Internal.blockEvent vs. concrete Envio.blockEvent and Envio.fuelBlockEvent
    • Conditional template logic in Handlers.res.hbs for EVM vs. Fuel ecosystem routing

Possibly related PRs

Suggested reviewers

  • JonoPrest
  • JasoonS

Poem

🐰 A rabbit hops 'cross chains so bright,
EVM blocks by day, Fuel blocks by night,
Platform-aware, the events now dance,
Generic types grant ecosystems a chance!
From Solidity to Sway, all blocks align,
Multi-chain magic—a developer's design!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add block handler support for fuel' directly and accurately summarizes the main objective of the PR, which introduces block handler support for the Fuel blockchain platform.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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-fuel-block-handler-BHcot

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.

@DZakh
DZakh requested a review from JonoPrest November 10, 2025 16:03
Base automatically changed from dz/platform-abstraction to main November 12, 2025 10:19

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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/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.blockNumberName is clever and the implementation is straightforward, the three uses of Utils.magic for type coercion (lines 138-140) could be fragile if types change. Consider whether @obj or 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

📥 Commits

Reviewing files that changed from the base of the PR and between 4f34a2b and 6fd5c18.

⛔ Files ignored due to path filters (1)
  • scenarios/test_codegen/pnpm-lock.yaml is 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.hbs
  • codegenerator/cli/npm/envio/src/Envio.res
  • codegenerator/cli/templates/dynamic/codegen/src/Handlers.res.hbs
  • codegenerator/cli/npm/envio/src/Platform.res
  • codegenerator/cli/npm/envio/index.d.ts
  • codegenerator/cli/templates/static/codegen/src/EventProcessing.res
  • codegenerator/cli/npm/envio/src/Internal.res
  • codegenerator/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.hbs
  • codegenerator/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.hbs
  • codegenerator/cli/templates/dynamic/codegen/src/Handlers.res.hbs
  • codegenerator/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.res
  • codegenerator/cli/npm/envio/src/Platform.res
  • codegenerator/cli/templates/static/codegen/src/EventProcessing.res
  • codegenerator/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.res
  • codegenerator/cli/npm/envio/src/Platform.res
  • codegenerator/cli/npm/envio/index.d.ts
  • codegenerator/cli/npm/envio/src/Internal.res
  • codegenerator/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 fuelBlockEvent export 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 blockEvent opaque is an excellent design choice that enforces platform-specific construction through Platform.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.platform and passed to preloadBatchOrThrow, 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 blockEvent and fuelBlockEvent types with platform-specific field names (number for EVM, height for Fuel) combined with the generic onBlockArgs<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_ecosystem properly instantiates onBlockArgs with the appropriate block event type (blockEvent for EVM, fuelBlockEvent for Fuel), maintaining type safety across ecosystems.

codegenerator/cli/npm/envio/src/Envio.res (2)

5-17: Excellent type design with clear documentation.

The separate blockEvent and fuelBlockEvent types with helpful comments explaining the EVM vs Fuel field naming differences (number vs height) 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 onBlockArgs generic over both 'block and 'context is 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.makeBlockEvent with the platform from indexer.config, ensuring the correct field names (number for EVM, height for Fuel) are used dynamically.


241-241: Necessary parameter addition for platform abstraction.

Adding the ~platform: Platform.t parameter to preloadBatchOrThrow enables 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.makeBlockEvent with 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.platform and passed to preloadBatchOrThrow, completing the consistent threading of platform information through the entire event processing pipeline.

@DZakh
DZakh merged commit fd3d6a0 into main Nov 12, 2025
2 checks passed
@DZakh
DZakh deleted the feat-fuel-block-handler-BHcot branch November 12, 2025 10:40
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