Skip to content

CommonJs -> ESM#837

Merged
DZakh merged 14 commits into
mainfrom
dz/esm
Dec 2, 2025
Merged

CommonJs -> ESM#837
DZakh merged 14 commits into
mainfrom
dz/esm

Conversation

@DZakh

@DZakh DZakh commented Nov 27, 2025

Copy link
Copy Markdown
Member
  • Migrate from CommonJs only to ESM only
  • Stricter tsconfig
  • tsc on every command
  • Remove max Node.js limit

Summary by CodeRabbit

  • Refactor

    • Project-wide migration to ES modules and ESM-compatible build/runtime behavior.
  • Dependencies

    • Updated TypeScript and several libraries; added modern tooling (tsx) and removed legacy ts-node/ts-mocha.
  • New Features

    • Async handler loading, dynamic JSON imports, improved event-registration checks, ESM runtime shims, and clearer package metadata/engine hints.
  • Removed

    • Legacy example contracts, artifacts, deploy/test scripts, and related helper tasks and configs.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Nov 27, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Convert many packages and templates from CommonJS to ES modules, update ReScript/TypeScript build/import paths for ESM, add async/dynamic handler import and registration hooks (EventRegister.isPendingRegistration + async register flows), add temporary TS .d.mts shims, and remove Hardhat contracts/artifacts and related scripts.

Changes

Cohort / File(s) Summary
Envio runtime & packaging
codegenerator/cli/npm/envio/bin.js, codegenerator/cli/npm/envio/index.js, codegenerator/cli/npm/envio/package.json, codegenerator/cli/npm/envio/package.json.tmpl
Add "type":"module", migrate CommonJS -> ESM (import/export, createRequire where needed), adjust exports/re-exports, and bump rescript-schema.
Rescript project specs & gen outputs
codegenerator/cli/npm/envio/rescript.json, codegenerator/cli/templates/.../rescript.json, scenarios/**/rescript.json, **/*.gen.ts, codegenerator/cli/npm/envio/src/bindings/*.gen.ts
Switch package-specs.module to esmodule, change suffix .res.js.res.mjs, add gentypeconfig.moduleResolution node16, and update generated import paths to .js/.mjs.
TypeScript configs & templates
multiple **/tsconfig.json, codegenerator/cli/templates/*, codegenerator/cli/templates/dynamic/codegen/package.json.hbs
Modernize TS configs (ES2022/ESNext, module→Node16/ESNext, moduleResolution bundler/node16, noEmit, stricter flags), update package.json templates to "type":"module", switch scripts to TSX/dynamic imports.
Handler registration & dynamic imports
codegenerator/cli/npm/envio/src/EventRegister.res, codegenerator/cli/npm/envio/src/EventRegister.resi, codegenerator/cli/npm/envio/src/Utils.res, codegenerator/cli/src/hbs_templating/codegen_templates.rs, codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs, codegenerator/cli/templates/dynamic/codegen/src/TestHelpers_MockDb.res.hbs
Export isPendingRegistration, add importPath/importPathWithJson externals, switch generated registration to async dynamic imports (await importPath/importPathWithJson), consume JSON .default, and adapt mock DB registration logic to conditional/async flows.
ReScript externals & ESM interop
codegenerator/cli/npm/envio/src/bindings/NodeJs.res, Pino.res, Postgres.res, BigDecimal.res, BigInt.res, Ink.res, Yargs.res
Make @module annotations explicit, add ImportMeta/Url and computed __dirname for ESM, adjust binding return/default mappings and module spec strings for ESM interop.
Vendored JS → ESM & API changes
codegenerator/cli/npm/envio/src/bindings/vendored-lodash-fns.js, codegenerator/cli/npm/envio/src/sources/vendored-fuel-abi-coder.js
Convert vendored code to ESM exports; fuel-abi-coder adds AbiCoder.getLogDecoder, changes EnumCoder/BigNumberCoder decode shapes, and exposes transpileAbi.
Generated TS declaration shims
codegenerator/cli/npm/envio/src/bindings/BigDecimal.res.d.mts, codegenerator/cli/npm/envio/src/bindings/BigInt.res.d.mts, codegenerator/cli/npm/envio/src/bindings/Ethers.res.d.mts
Add temporary .d.mts placeholder exports (lax any) to avoid tsc --noEmit failures when importing from .res.mjs.
Templates & generated code updates
codegenerator/cli/templates/*, codegenerator/cli/templates/static/codegen/index.js, .../Generated.res.hbs
Update templates to .mjs paths, change require-based scripts to dynamic import/tsx, convert register functions to async and await imports, and adjust start/test scripts.
Scenarios & test manifests
scenarios/**/package.json, scenarios/**/tsconfig.json, scenarios/**/rescript.json, scenarios/**/config.yaml, .mocharc.json, codegenerator/integration_tests/**/package.json
Add "type":"module", update test/start scripts to use tsx or envio start, bump TypeScript/tooling, update handler paths from .res.js.res.mjs, and remove some Mocha configs.
Hardhat / contracts removal (test_codegen)
scenarios/test_codegen/contracts/**, scenarios/test_codegen/hardhat.config.ts, related tasks/helpers/artifacts
Remove Hardhat contracts, artifacts, deploy scripts, tasks, helper scripts, and contracts package manifest.
Minor type-only imports & docs
multiple *.ts, *.res, README.md
Convert many value imports to type-only imports, update README examples to .mjs, and small formatting/import refinements.
Event register helper usage adjustments
EventRegister.res, EventRegister.resi, Generated.res.hbs, TestHelpers_MockDb.res.hbs
Add isPendingRegistration and switch generated registration to check pending state, await or finish registrations, and register handlers concurrently via Promise.all.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant User
    participant Envio as Envio CLI
    participant Generated as Generated Module
    participant Utils as Utils.importPathWithJson
    participant EventReg as EventRegister

    User->>Envio: start indexer
    Envio->>Generated: registerAllHandlers()
    Generated->>EventReg: isPendingRegistration()
    alt pending
        EventReg-->>Generated: true
        Generated->>EventReg: finishRegistration()
    else not pending
        EventReg-->>Generated: false
        Generated->>EventReg: startRegistration()
        loop handler files (async)
            Generated->>Utils: importPath(handlerFile)
            Utils-->>Generated: handlerModule
            Generated->>EventReg: registerHandler(handlerModule)
        end
        Generated->>EventReg: finishRegistration()
    end
    EventReg-->>Envio: handlers registered
    Envio-->>User: indexer ready
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

  • Areas needing extra attention:
    • async handler registration, concurrency, and error handling (Generated.res.hbs, TestHelpers_MockDb, EventRegister)
    • dynamic Fuel ABI JSON import and default selection (codegen_templates.rs, vendored fuel-abi-coder)
    • ReScript externals for ESM interop and computed __dirname (NodeJs.res, Pino.res, Postgres.res)
    • Vendored fuel-abi-coder API shape changes (EnumCoder.decode, BigNumberCoder.decode, new getLogDecoder)
    • Generated TS import path updates and .d.mts shims for BigInt/BigDecimal/Ethers

Possibly related PRs

Suggested labels

codex

Poem

🐰 I nudged CommonJS away,
hopped into the ESM day.
Handlers load with async grace,
.mjs footprints leave a trace,
carrots for each passing test. 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% 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 title 'CommonJs -> ESM' accurately captures the main migration objective of this large pull request, summarizing the primary change from the developer's perspective.
✨ 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 dz/esm

📜 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 627b0d1 and 841ecd0.

⛔ Files ignored due to path filters (1)
  • scenarios/test_codegen/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (4)
  • codegenerator/cli/npm/envio/src/Envio.gen.ts (1 hunks)
  • codegenerator/cli/npm/envio/src/Internal.gen.ts (1 hunks)
  • codegenerator/cli/templates/dynamic/codegen/src/TestHelpers_MockDb.res.hbs (2 hunks)
  • scenarios/test_codegen/src/handlers/EventHandlers.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • scenarios/test_codegen/src/handlers/EventHandlers.ts
🧰 Additional context used
📓 Path-based instructions (1)
codegenerator/cli/templates/dynamic/**/*.hbs

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

Handlebars templates must be placed in codegenerator/cli/templates/dynamic/

Files:

  • codegenerator/cli/templates/dynamic/codegen/src/TestHelpers_MockDb.res.hbs
🧠 Learnings (18)
📓 Common learnings
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Move entity creation from EventHandlers.ts to contract-specific handler files matching original subgraph organization
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/utils/**/*.ts : Implement helper functions with no entity/handler dependencies immediately during migration phase 5a
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Register dynamic contracts created by factory events using contractRegister above the 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-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/config.yaml : Update config.yaml to point handler field to contract-specific files instead of single EventHandlers.ts file
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Create handler skeleton files with exact filenames matching the original subgraph structure during file refactoring
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Implement complex handlers one at a time and run quality checks after each handler completion before proceeding to next
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Systematically review each handler logic against original subgraph multiple times until logic is completely correct
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/EventHandlers.ts : Clear all boilerplate logic from EventHandlers.ts and replace with empty handlers containing TODO comments
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Move entity creation from EventHandlers.ts to contract-specific handler files matching original subgraph organization

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/TestHelpers_MockDb.res.hbs
  • codegenerator/cli/npm/envio/src/Envio.gen.ts
  • codegenerator/cli/npm/envio/src/Internal.gen.ts
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/config.yaml : Update config.yaml to point handler field to contract-specific files instead of single EventHandlers.ts file

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/TestHelpers_MockDb.res.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/EventHandlers.ts : Clear all boilerplate logic from EventHandlers.ts and replace with empty handlers containing TODO comments

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/TestHelpers_MockDb.res.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Register dynamic contracts created by factory events using contractRegister above the handler (e.g., context.addPair(event.params.pair))

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/TestHelpers_MockDb.res.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Systematically review each handler logic against original subgraph multiple times until logic is completely correct

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/TestHelpers_MockDb.res.hbs
  • codegenerator/cli/npm/envio/src/Internal.gen.ts
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/utils/**/*.ts : Implement helper functions with no entity/handler dependencies immediately during migration phase 5a

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/TestHelpers_MockDb.res.hbs
  • codegenerator/cli/npm/envio/src/Internal.gen.ts
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Import entity types from 'generated/src/db/Entities.gen' not 'generated' for type definitions

Applied to files:

  • codegenerator/cli/npm/envio/src/Envio.gen.ts
  • codegenerator/cli/npm/envio/src/Internal.gen.ts
📚 Learning: 2025-11-25T12:40:49.622Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/**/*.ts : In Envio, use `entity_id` fields (e.g., `token_id: string`) instead of direct object references for entity relationships

Applied to files:

  • codegenerator/cli/npm/envio/src/Envio.gen.ts
  • codegenerator/cli/npm/envio/src/Internal.gen.ts
📚 Learning: 2025-11-25T12:40:49.622Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/**/*.ts : Define Effect schemas using the `S` module from 'envio' with required properties: name, input schema, output schema, rateLimit, and cache

Applied to files:

  • codegenerator/cli/npm/envio/src/Envio.gen.ts
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/effects/**/*.ts : Create Effect API functions in src/effects/ folder with proper schema definition using createEffect from 'envio'

Applied to files:

  • codegenerator/cli/npm/envio/src/Envio.gen.ts
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Use entity field names with _id suffix for entity relationships (e.g., token0_id, token1_id) matching generated schema

Applied to files:

  • codegenerator/cli/npm/envio/src/Envio.gen.ts
  • codegenerator/cli/npm/envio/src/Internal.gen.ts
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Ensure entity type annotations use the _t suffix (e.g., Pair_t, Token_t) when defining entity objects

Applied to files:

  • codegenerator/cli/npm/envio/src/Envio.gen.ts
  • codegenerator/cli/npm/envio/src/Internal.gen.ts
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Reference original subgraph logic files in TODO comments when creating skeleton handlers (e.g., 'Reference: original-subgraph/src/mappings/contract.ts')

Applied to files:

  • codegenerator/cli/npm/envio/src/Envio.gen.ts
  • codegenerator/cli/npm/envio/src/Internal.gen.ts
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Create handler skeleton files with exact filenames matching the original subgraph structure during file refactoring

Applied to files:

  • codegenerator/cli/npm/envio/src/Envio.gen.ts
  • codegenerator/cli/npm/envio/src/Internal.gen.ts
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/schema.graphql : Migrate schema by converting entity(immutable: true) decorators to plain entities and Bytes! to String!, removing immutable declarations

Applied to files:

  • codegenerator/cli/npm/envio/src/Envio.gen.ts
📚 Learning: 2025-11-25T12:40:49.622Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/EventHandlers.ts : Always cast timestamps to BigInt (e.g., `BigInt(event.block.timestamp)`) instead of using raw timestamps

Applied to files:

  • codegenerator/cli/npm/envio/src/Envio.gen.ts
  • codegenerator/cli/npm/envio/src/Internal.gen.ts
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Use async/await for all context.Entity.get() and context.effect() calls; context.Entity.set() does not need await

Applied to files:

  • codegenerator/cli/npm/envio/src/Internal.gen.ts
⏰ 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 (5)
codegenerator/cli/npm/envio/src/Envio.gen.ts (1)

12-12: Correct for ESM migration.

The .js extension is required for ESM compatibility. The import path rescript-schema/RescriptSchema.gen.js is consistent across all generated TypeScript files in the codebase (Envio.gen.ts, BigInt.gen.ts, BigDecimal.gen.ts) and aligns with rescript-schema 9.3.4.

codegenerator/cli/npm/envio/src/Internal.gen.ts (1)

10-10: ESM import specifier with .js extension looks correct here

Using import type { t as Address_t } from './Address.gen.js'; is consistent with Node ESM requirements (explicit .js extension) and with typical TS ESM setups where the type-only import is erased at runtime but still resolved against the .ts source. This update also addresses the earlier concern that the previous specifier “looked wrong.”

codegenerator/cli/templates/dynamic/codegen/src/TestHelpers_MockDb.res.hbs (3)

338-344: LGTM!

The explicit type annotation Internal.eventConfig improves type safety and aligns with the stricter typing goals of this PR.


345-349: LGTM!

Good defensive guard that catches misconfigured events early with a clear, actionable error message referencing the specific event.


321-325: No changes needed - this code is correct as written.

The conditional properly handles two scenarios: when a registration is already pending (call the synchronous finishRegistration()) versus when registration needs to be performed (call and await the async registerAllHandlers()). Both branches return the same type and are used appropriately. The finishRegistration() function is synchronous and does not require await.


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.

@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: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
codegenerator/cli/npm/envio/index.js (1)

13-42: S export properly migrated to ESM, but index.d.ts has a mismatch: unknown property declared but not exported.

The ESM syntax conversion is correct and imports are clean (lines 5-7, 19, 37). However, index.d.ts line 161 declares export const unknown: typeof Sury.unknown; which is not present in the index.js S object. This violates the "should match" requirement stated in both files' comments. Either add unknown to the S export in index.js line 41, or remove it from index.d.ts line 161 to maintain alignment.

♻️ Duplicate comments (1)
codegenerator/cli/npm/envio/package.json.tmpl (1)

4-4: Generated CLI packages become ESM‑only as well – align with support expectations

Adding "type": "module" here means all generated envio CLI packages will be pure ES modules; that’s fine if you’re officially dropping CommonJS support, but if not, you may want a dual‑mode setup similar to the main package note.

🧹 Nitpick comments (2)
codegenerator/cli/npm/envio/src/Utils.res (1)

3-4: Dynamic import via @val is risky under ESM; prefer a wrapper

@val external importPath ... = "import" assumes import can be treated as a normal value. In ESM, import is special syntax, and if the compiler emits something like a binding to import, the generated .mjs may not even parse.

A safer pattern is to wrap import() in a tiny %raw function:

-@val external importPath: string => promise<unknown> = "import"
+let importPath: string => promise<unknown> =
+  %raw(`(path) => import(path)`)

Please also run pnpm rescript to inspect the generated .mjs and pnpm mocha to catch any runtime issues once the compiler output looks OK, based on learnings.

scenarios/test_codegen/test/topic-hashing-test.ts (1)

1-5: Updated .mjs imports match ReScript ESM output

Pointing to Types.res.mjs and Rpc.res.mjs is in line with the new .res.mjs suffix and ESM build. As you further standardize on Node16/ESM in this scenario, consider eventually replacing const hre = require("hardhat"); with an ESM import to avoid CJS/ESM mixing in the same file.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f75b8f3 and 556b8dc.

⛔ Files ignored due to path filters (1)
  • scenarios/test_codegen/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (58)
  • codegenerator/cli/npm/envio/bin.js (2 hunks)
  • codegenerator/cli/npm/envio/index.js (2 hunks)
  • codegenerator/cli/npm/envio/package.json (1 hunks)
  • codegenerator/cli/npm/envio/package.json.tmpl (1 hunks)
  • codegenerator/cli/npm/envio/rescript.json (1 hunks)
  • codegenerator/cli/npm/envio/src/Envio.gen.ts (1 hunks)
  • codegenerator/cli/npm/envio/src/Internal.gen.ts (1 hunks)
  • codegenerator/cli/npm/envio/src/Utils.res (1 hunks)
  • codegenerator/cli/npm/envio/src/bindings/BigDecimal.gen.ts (1 hunks)
  • codegenerator/cli/npm/envio/src/bindings/BigDecimal.res (1 hunks)
  • codegenerator/cli/npm/envio/src/bindings/BigInt.gen.ts (1 hunks)
  • codegenerator/cli/npm/envio/src/bindings/Ethers.gen.ts (1 hunks)
  • codegenerator/cli/npm/envio/src/bindings/NodeJs.res (1 hunks)
  • codegenerator/cli/npm/envio/src/bindings/Pino.res (3 hunks)
  • codegenerator/cli/npm/envio/src/bindings/Postgres.res (1 hunks)
  • codegenerator/cli/npm/envio/src/bindings/vendored-lodash-fns.js (2 hunks)
  • codegenerator/cli/npm/envio/src/db/InternalTable.gen.ts (1 hunks)
  • codegenerator/cli/npm/envio/src/sources/HyperSyncClient.gen.ts (1 hunks)
  • codegenerator/cli/npm/envio/src/sources/vendored-fuel-abi-coder.js (3 hunks)
  • codegenerator/cli/src/cli_args/init_config.rs (2 hunks)
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs (1 hunks)
  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs (4 hunks)
  • codegenerator/cli/templates/static/blank_template/rescript/rescript.json (1 hunks)
  • codegenerator/cli/templates/static/blank_template/typescript/tsconfig.json (1 hunks)
  • codegenerator/cli/templates/static/codegen/index.js (1 hunks)
  • codegenerator/cli/templates/static/codegen/rescript.json (1 hunks)
  • codegenerator/cli/templates/static/codegen/src/Index.bs.js (1 hunks)
  • codegenerator/cli/templates/static/codegen/src/Index.res (1 hunks)
  • codegenerator/cli/templates/static/codegen/src/bindings/Yargs.res (1 hunks)
  • codegenerator/cli/templates/static/erc20_template/typescript/tsconfig.json (1 hunks)
  • codegenerator/cli/templates/static/factory_template/typescript/tsconfig.json (1 hunks)
  • codegenerator/cli/templates/static/greeter_template/typescript/tsconfig.json (1 hunks)
  • codegenerator/cli/templates/static/greeteronfuel_template/typescript/tsconfig.json (1 hunks)
  • codegenerator/integration_tests/tests/test_indexers/dynamic_contracts/package.json (1 hunks)
  • codegenerator/integration_tests/tests/test_indexers/dynamic_contracts/tsconfig.json (1 hunks)
  • codegenerator/integration_tests/tests/test_indexers/test_exits/package.json (1 hunks)
  • codegenerator/integration_tests/tests/test_indexers/test_exits/tsconfig.json (1 hunks)
  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/package.json (2 hunks)
  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/tsconfig.json (1 hunks)
  • scenarios/erc20_multichain_factory/config.yaml (1 hunks)
  • scenarios/erc20_multichain_factory/package.json (1 hunks)
  • scenarios/erc20_multichain_factory/rescript.json (1 hunks)
  • scenarios/fuel_test/contracts/ts-interaction-tools/tsconfig.json (1 hunks)
  • scenarios/fuel_test/package.json (2 hunks)
  • scenarios/fuel_test/rescript.json (1 hunks)
  • scenarios/fuel_test/tsconfig.json (1 hunks)
  • scenarios/helpers/README.md (1 hunks)
  • scenarios/helpers/package.json (1 hunks)
  • scenarios/helpers/rescript.json (1 hunks)
  • scenarios/test_codegen/.mocharc.json (1 hunks)
  • scenarios/test_codegen/config.yaml (2 hunks)
  • scenarios/test_codegen/package.json (3 hunks)
  • scenarios/test_codegen/rescript.json (1 hunks)
  • scenarios/test_codegen/test/Integration_ts_helpers.gen.ts (1 hunks)
  • scenarios/test_codegen/test/helpers/utils.ts (1 hunks)
  • scenarios/test_codegen/test/manual/README.md (1 hunks)
  • scenarios/test_codegen/test/topic-hashing-test.ts (1 hunks)
  • scenarios/test_codegen/tsconfig.json (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{res,resi}

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

**/*.{res,resi}: Always use ReScript 11 documentation
Never suggest ReasonML syntax
Never use [| item |] to create an array. Use [ item ] instead
Must always use = for setting value to a field. Use := only for ref values created using ref function
Use records when working with structured data, and objects to conveniently pass payload data between functions
Never use %raw to access object fields if you know the type

Files:

  • codegenerator/cli/npm/envio/src/bindings/Postgres.res
  • codegenerator/cli/npm/envio/src/bindings/NodeJs.res
  • codegenerator/cli/npm/envio/src/bindings/BigDecimal.res
  • codegenerator/cli/templates/static/codegen/src/bindings/Yargs.res
  • codegenerator/cli/templates/static/codegen/src/Index.res
  • codegenerator/cli/npm/envio/src/bindings/Pino.res
  • codegenerator/cli/npm/envio/src/Utils.res
codegenerator/cli/templates/dynamic/**/*.hbs

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

Handlebars templates must be placed in codegenerator/cli/templates/dynamic/

Files:

  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
codegenerator/cli/templates/static/**/*.res

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

Static ReScript files must be placed in codegenerator/cli/templates/static/

Files:

  • codegenerator/cli/templates/static/codegen/src/bindings/Yargs.res
  • codegenerator/cli/templates/static/codegen/src/Index.res
🧠 Learnings (52)
📓 Common learnings
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Applies to **/*.{test.res,spec.res} : Prefer public module APIs for testing in ReScript
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/rescript.mdc:0-0
Timestamp: 2025-11-25T12:40:26.435Z
Learning: Applies to **/*.{res,resi} : Always use ReScript 11 documentation
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Verify tests pass by running `pnpm rescript` compiler and `pnpm mocha` test runner
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/utils/**/*.ts : Implement helper functions with no entity/handler dependencies immediately during migration phase 5a

Applied to files:

  • codegenerator/cli/templates/static/codegen/src/Index.bs.js
  • scenarios/test_codegen/test/Integration_ts_helpers.gen.ts
  • scenarios/test_codegen/test/helpers/utils.ts
  • codegenerator/cli/npm/envio/src/db/InternalTable.gen.ts
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • codegenerator/cli/npm/envio/bin.js
  • scenarios/test_codegen/config.yaml
  • codegenerator/cli/npm/envio/src/bindings/Ethers.gen.ts
  • codegenerator/cli/npm/envio/src/Internal.gen.ts
  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
  • scenarios/test_codegen/test/topic-hashing-test.ts
  • codegenerator/cli/npm/envio/src/sources/vendored-fuel-abi-coder.js
  • codegenerator/cli/npm/envio/src/sources/HyperSyncClient.gen.ts
  • codegenerator/cli/templates/static/codegen/src/Index.res
  • codegenerator/cli/templates/static/codegen/index.js
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Use async/await for all context.Entity.get() and context.effect() calls; context.Entity.set() does not need await

Applied to files:

  • codegenerator/cli/templates/static/codegen/src/Index.bs.js
  • codegenerator/cli/templates/static/greeter_template/typescript/tsconfig.json
  • scenarios/test_codegen/test/Integration_ts_helpers.gen.ts
  • scenarios/test_codegen/test/helpers/utils.ts
  • codegenerator/cli/npm/envio/src/bindings/Ethers.gen.ts
  • scenarios/test_codegen/tsconfig.json
  • codegenerator/cli/npm/envio/src/Internal.gen.ts
  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
  • scenarios/test_codegen/test/topic-hashing-test.ts
  • codegenerator/cli/npm/envio/src/sources/HyperSyncClient.gen.ts
  • codegenerator/cli/templates/static/codegen/src/Index.res
  • codegenerator/cli/templates/static/greeteronfuel_template/typescript/tsconfig.json
  • codegenerator/cli/templates/static/factory_template/typescript/tsconfig.json
  • codegenerator/cli/templates/static/blank_template/typescript/tsconfig.json
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Create handler skeleton files with exact filenames matching the original subgraph structure during file refactoring

Applied to files:

  • codegenerator/cli/templates/static/codegen/src/Index.bs.js
  • scenarios/fuel_test/contracts/ts-interaction-tools/tsconfig.json
  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/tsconfig.json
  • codegenerator/cli/templates/static/greeter_template/typescript/tsconfig.json
  • codegenerator/integration_tests/tests/test_indexers/dynamic_contracts/tsconfig.json
  • scenarios/test_codegen/test/Integration_ts_helpers.gen.ts
  • codegenerator/cli/templates/static/blank_template/rescript/rescript.json
  • scenarios/test_codegen/test/helpers/utils.ts
  • codegenerator/cli/npm/envio/src/db/InternalTable.gen.ts
  • codegenerator/cli/templates/static/erc20_template/typescript/tsconfig.json
  • scenarios/test_codegen/config.yaml
  • codegenerator/cli/npm/envio/rescript.json
  • codegenerator/cli/npm/envio/src/bindings/Ethers.gen.ts
  • scenarios/test_codegen/tsconfig.json
  • codegenerator/cli/npm/envio/src/Internal.gen.ts
  • codegenerator/cli/npm/envio/src/Envio.gen.ts
  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
  • codegenerator/integration_tests/tests/test_indexers/test_exits/tsconfig.json
  • scenarios/test_codegen/test/topic-hashing-test.ts
  • codegenerator/cli/templates/static/codegen/rescript.json
  • codegenerator/cli/npm/envio/src/sources/HyperSyncClient.gen.ts
  • codegenerator/cli/templates/static/codegen/src/Index.res
  • codegenerator/cli/templates/static/greeteronfuel_template/typescript/tsconfig.json
  • codegenerator/cli/templates/static/factory_template/typescript/tsconfig.json
  • codegenerator/cli/templates/static/blank_template/typescript/tsconfig.json
  • codegenerator/cli/templates/static/codegen/index.js
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Import entity types from 'generated/src/db/Entities.gen' not 'generated' for type definitions

Applied to files:

  • codegenerator/cli/templates/static/codegen/src/Index.bs.js
  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/tsconfig.json
  • codegenerator/cli/templates/static/greeter_template/typescript/tsconfig.json
  • codegenerator/cli/npm/envio/package.json.tmpl
  • codegenerator/integration_tests/tests/test_indexers/dynamic_contracts/tsconfig.json
  • scenarios/test_codegen/test/Integration_ts_helpers.gen.ts
  • scenarios/test_codegen/test/helpers/utils.ts
  • codegenerator/cli/npm/envio/src/db/InternalTable.gen.ts
  • codegenerator/cli/templates/static/erc20_template/typescript/tsconfig.json
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • codegenerator/cli/npm/envio/rescript.json
  • codegenerator/cli/npm/envio/src/bindings/Ethers.gen.ts
  • codegenerator/integration_tests/tests/test_indexers/test_exits/package.json
  • codegenerator/cli/npm/envio/src/bindings/BigInt.gen.ts
  • codegenerator/cli/npm/envio/src/Internal.gen.ts
  • codegenerator/cli/npm/envio/src/Envio.gen.ts
  • codegenerator/cli/npm/envio/index.js
  • codegenerator/integration_tests/tests/test_indexers/test_exits/tsconfig.json
  • scenarios/test_codegen/test/topic-hashing-test.ts
  • codegenerator/cli/npm/envio/src/bindings/BigDecimal.gen.ts
  • codegenerator/cli/templates/static/codegen/rescript.json
  • codegenerator/cli/npm/envio/src/sources/HyperSyncClient.gen.ts
  • codegenerator/cli/templates/static/codegen/src/Index.res
  • codegenerator/cli/templates/static/greeteronfuel_template/typescript/tsconfig.json
  • codegenerator/cli/templates/static/factory_template/typescript/tsconfig.json
  • codegenerator/cli/templates/static/blank_template/typescript/tsconfig.json
  • codegenerator/cli/templates/static/codegen/index.js
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Move entity creation from EventHandlers.ts to contract-specific handler files matching original subgraph organization

Applied to files:

  • codegenerator/cli/templates/static/codegen/src/Index.bs.js
  • scenarios/fuel_test/contracts/ts-interaction-tools/tsconfig.json
  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/tsconfig.json
  • codegenerator/integration_tests/tests/test_indexers/dynamic_contracts/tsconfig.json
  • scenarios/test_codegen/test/Integration_ts_helpers.gen.ts
  • scenarios/test_codegen/test/helpers/utils.ts
  • codegenerator/cli/npm/envio/src/db/InternalTable.gen.ts
  • codegenerator/cli/templates/static/erc20_template/typescript/tsconfig.json
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • scenarios/test_codegen/config.yaml
  • codegenerator/cli/npm/envio/src/bindings/Ethers.gen.ts
  • scenarios/test_codegen/tsconfig.json
  • codegenerator/cli/npm/envio/src/Internal.gen.ts
  • codegenerator/cli/npm/envio/src/Envio.gen.ts
  • scenarios/erc20_multichain_factory/config.yaml
  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
  • codegenerator/cli/npm/envio/index.js
  • scenarios/test_codegen/test/topic-hashing-test.ts
  • codegenerator/cli/templates/static/codegen/rescript.json
  • codegenerator/cli/npm/envio/src/sources/HyperSyncClient.gen.ts
  • codegenerator/cli/templates/static/codegen/src/Index.res
  • codegenerator/integration_tests/tests/test_indexers/dynamic_contracts/package.json
  • codegenerator/cli/src/cli_args/init_config.rs
  • scenarios/erc20_multichain_factory/rescript.json
  • codegenerator/cli/templates/static/codegen/index.js
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Run pnpm codegen, pnpm tsc --noEmit, and TUI_OFF=true pnpm dev after every code change to catch runtime errors

Applied to files:

  • codegenerator/cli/templates/static/codegen/src/Index.bs.js
  • scenarios/fuel_test/contracts/ts-interaction-tools/tsconfig.json
  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/tsconfig.json
  • codegenerator/cli/templates/static/greeter_template/typescript/tsconfig.json
  • scenarios/fuel_test/package.json
  • scenarios/test_codegen/test/helpers/utils.ts
  • codegenerator/cli/templates/static/erc20_template/typescript/tsconfig.json
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • scenarios/test_codegen/package.json
  • scenarios/fuel_test/tsconfig.json
  • scenarios/test_codegen/tsconfig.json
  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/package.json
  • codegenerator/integration_tests/tests/test_indexers/test_exits/tsconfig.json
  • codegenerator/cli/templates/static/greeteronfuel_template/typescript/tsconfig.json
  • codegenerator/cli/templates/static/blank_template/typescript/tsconfig.json
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Systematically review each handler logic against original subgraph multiple times until logic is completely correct

Applied to files:

  • codegenerator/cli/templates/static/codegen/src/Index.bs.js
  • scenarios/test_codegen/test/helpers/utils.ts
  • scenarios/test_codegen/config.yaml
  • scenarios/test_codegen/tsconfig.json
  • scenarios/erc20_multichain_factory/config.yaml
  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
  • codegenerator/integration_tests/tests/test_indexers/test_exits/tsconfig.json
  • scenarios/test_codegen/test/topic-hashing-test.ts
  • codegenerator/cli/templates/static/codegen/index.js
📚 Learning: 2025-11-25T12:40:49.622Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
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/codegen/src/Index.bs.js
  • scenarios/fuel_test/contracts/ts-interaction-tools/tsconfig.json
  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/tsconfig.json
  • codegenerator/cli/templates/static/greeter_template/typescript/tsconfig.json
  • scenarios/fuel_test/package.json
  • codegenerator/cli/npm/envio/package.json.tmpl
  • codegenerator/integration_tests/tests/test_indexers/dynamic_contracts/tsconfig.json
  • scenarios/test_codegen/.mocharc.json
  • scenarios/test_codegen/test/helpers/utils.ts
  • codegenerator/cli/templates/static/erc20_template/typescript/tsconfig.json
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • scenarios/test_codegen/package.json
  • scenarios/fuel_test/tsconfig.json
  • codegenerator/cli/npm/envio/rescript.json
  • codegenerator/integration_tests/tests/test_indexers/test_exits/package.json
  • scenarios/test_codegen/tsconfig.json
  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/package.json
  • codegenerator/cli/npm/envio/src/Internal.gen.ts
  • codegenerator/cli/npm/envio/src/Envio.gen.ts
  • codegenerator/integration_tests/tests/test_indexers/test_exits/tsconfig.json
  • codegenerator/cli/templates/static/codegen/rescript.json
  • codegenerator/cli/npm/envio/src/sources/HyperSyncClient.gen.ts
  • codegenerator/cli/templates/static/greeteronfuel_template/typescript/tsconfig.json
  • codegenerator/cli/templates/static/factory_template/typescript/tsconfig.json
  • codegenerator/cli/templates/static/blank_template/typescript/tsconfig.json
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Reference original subgraph logic files in TODO comments when creating skeleton handlers (e.g., 'Reference: original-subgraph/src/mappings/contract.ts')

Applied to files:

  • codegenerator/cli/templates/static/codegen/src/Index.bs.js
  • scenarios/fuel_test/contracts/ts-interaction-tools/tsconfig.json
  • codegenerator/integration_tests/tests/test_indexers/dynamic_contracts/tsconfig.json
  • scenarios/test_codegen/test/Integration_ts_helpers.gen.ts
  • scenarios/test_codegen/test/helpers/utils.ts
  • codegenerator/cli/npm/envio/src/db/InternalTable.gen.ts
  • scenarios/test_codegen/config.yaml
  • codegenerator/cli/npm/envio/src/bindings/Ethers.gen.ts
  • scenarios/test_codegen/tsconfig.json
  • codegenerator/cli/npm/envio/src/Internal.gen.ts
  • codegenerator/cli/npm/envio/src/Envio.gen.ts
  • scenarios/erc20_multichain_factory/config.yaml
  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
  • codegenerator/integration_tests/tests/test_indexers/test_exits/tsconfig.json
  • scenarios/test_codegen/test/topic-hashing-test.ts
  • codegenerator/cli/npm/envio/src/sources/HyperSyncClient.gen.ts
  • codegenerator/cli/templates/static/codegen/index.js
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Prefix all entity IDs with chainId in multichain indexing: ${event.chainId}-${originalId}

Applied to files:

  • codegenerator/cli/templates/static/codegen/src/Index.bs.js
  • scenarios/erc20_multichain_factory/config.yaml
  • scenarios/test_codegen/test/topic-hashing-test.ts
  • scenarios/erc20_multichain_factory/rescript.json
📚 Learning: 2025-11-25T12:40:49.622Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/**/*.ts : Use `string | undefined` for optional string fields in TypeScript types, not `string | null`, as generated types are strict about null vs undefined

Applied to files:

  • scenarios/fuel_test/contracts/ts-interaction-tools/tsconfig.json
  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/tsconfig.json
  • codegenerator/cli/templates/static/greeter_template/typescript/tsconfig.json
  • codegenerator/integration_tests/tests/test_indexers/dynamic_contracts/tsconfig.json
  • codegenerator/cli/templates/static/erc20_template/typescript/tsconfig.json
  • codegenerator/integration_tests/tests/test_indexers/test_exits/tsconfig.json
  • codegenerator/cli/templates/static/greeteronfuel_template/typescript/tsconfig.json
  • codegenerator/cli/templates/static/factory_template/typescript/tsconfig.json
  • codegenerator/cli/templates/static/blank_template/typescript/tsconfig.json
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Ensure entity type annotations use the _t suffix (e.g., Pair_t, Token_t) when defining entity objects

Applied to files:

  • scenarios/fuel_test/contracts/ts-interaction-tools/tsconfig.json
  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/tsconfig.json
  • codegenerator/cli/templates/static/greeter_template/typescript/tsconfig.json
  • codegenerator/cli/npm/envio/package.json.tmpl
  • codegenerator/integration_tests/tests/test_indexers/dynamic_contracts/tsconfig.json
  • scenarios/test_codegen/test/Integration_ts_helpers.gen.ts
  • codegenerator/cli/npm/envio/src/db/InternalTable.gen.ts
  • codegenerator/cli/templates/static/erc20_template/typescript/tsconfig.json
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • codegenerator/cli/npm/envio/rescript.json
  • scenarios/test_codegen/rescript.json
  • codegenerator/cli/npm/envio/src/bindings/Ethers.gen.ts
  • scenarios/test_codegen/tsconfig.json
  • codegenerator/cli/npm/envio/src/Internal.gen.ts
  • codegenerator/cli/npm/envio/src/Envio.gen.ts
  • codegenerator/integration_tests/tests/test_indexers/test_exits/tsconfig.json
  • scenarios/test_codegen/test/topic-hashing-test.ts
  • codegenerator/cli/templates/static/codegen/rescript.json
  • codegenerator/cli/npm/envio/src/sources/HyperSyncClient.gen.ts
  • codegenerator/cli/templates/static/greeteronfuel_template/typescript/tsconfig.json
  • codegenerator/cli/templates/static/factory_template/typescript/tsconfig.json
  • codegenerator/cli/templates/static/blank_template/typescript/tsconfig.json
📚 Learning: 2025-11-25T12:40:19.463Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Verify tests pass by running `pnpm rescript` compiler and `pnpm mocha` test runner

Applied to files:

  • scenarios/helpers/README.md
  • scenarios/helpers/rescript.json
  • scenarios/fuel_test/package.json
  • scenarios/test_codegen/test/manual/README.md
  • scenarios/test_codegen/.mocharc.json
  • scenarios/fuel_test/rescript.json
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • scenarios/erc20_multichain_factory/package.json
  • scenarios/test_codegen/package.json
  • codegenerator/cli/npm/envio/rescript.json
  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/package.json
📚 Learning: 2025-11-25T12:40:19.463Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Applies to **/*.{test.res,spec.res} : Use `_only` to specify which tests to run in ReScript Mocha tests

Applied to files:

  • scenarios/helpers/README.md
  • scenarios/helpers/rescript.json
  • scenarios/test_codegen/test/manual/README.md
  • scenarios/test_codegen/.mocharc.json
  • codegenerator/cli/templates/static/blank_template/rescript/rescript.json
  • scenarios/fuel_test/rescript.json
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • scenarios/test_codegen/package.json
  • codegenerator/cli/npm/envio/rescript.json
  • scenarios/test_codegen/rescript.json
  • codegenerator/cli/templates/static/codegen/rescript.json
  • scenarios/erc20_multichain_factory/rescript.json
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Use entity field names with _id suffix for entity relationships (e.g., token0_id, token1_id) matching generated schema

Applied to files:

  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/tsconfig.json
  • codegenerator/cli/templates/static/greeter_template/typescript/tsconfig.json
  • codegenerator/integration_tests/tests/test_indexers/dynamic_contracts/tsconfig.json
  • scenarios/test_codegen/test/Integration_ts_helpers.gen.ts
  • scenarios/test_codegen/test/helpers/utils.ts
  • codegenerator/cli/npm/envio/src/db/InternalTable.gen.ts
  • codegenerator/cli/templates/static/erc20_template/typescript/tsconfig.json
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • codegenerator/cli/npm/envio/rescript.json
  • codegenerator/cli/npm/envio/src/bindings/Ethers.gen.ts
  • scenarios/test_codegen/tsconfig.json
  • codegenerator/cli/npm/envio/src/Internal.gen.ts
  • codegenerator/cli/npm/envio/src/Envio.gen.ts
  • codegenerator/cli/templates/static/codegen/rescript.json
  • codegenerator/cli/npm/envio/src/sources/HyperSyncClient.gen.ts
  • codegenerator/cli/templates/static/greeteronfuel_template/typescript/tsconfig.json
  • codegenerator/cli/templates/static/factory_template/typescript/tsconfig.json
  • codegenerator/cli/templates/static/blank_template/typescript/tsconfig.json
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Verify that entity field types in code match exactly with GraphQL schema property types (Int!, BigInt!, BigDecimal!, String!, Bytes!, Boolean!)

Applied to files:

  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/tsconfig.json
  • codegenerator/cli/templates/static/greeter_template/typescript/tsconfig.json
  • scenarios/test_codegen/test/Integration_ts_helpers.gen.ts
  • codegenerator/cli/npm/envio/src/db/InternalTable.gen.ts
  • codegenerator/cli/templates/static/erc20_template/typescript/tsconfig.json
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • scenarios/test_codegen/tsconfig.json
  • codegenerator/cli/npm/envio/src/bindings/BigInt.gen.ts
  • codegenerator/integration_tests/tests/test_indexers/test_exits/tsconfig.json
  • codegenerator/cli/npm/envio/src/bindings/BigDecimal.gen.ts
  • codegenerator/cli/templates/static/greeteronfuel_template/typescript/tsconfig.json
  • codegenerator/cli/templates/static/factory_template/typescript/tsconfig.json
  • codegenerator/cli/templates/static/blank_template/typescript/tsconfig.json
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Use ZERO_BD and ZERO_BI constants for entity field initialization instead of hardcoded 0 values

Applied to files:

  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/tsconfig.json
  • codegenerator/cli/templates/static/greeter_template/typescript/tsconfig.json
  • codegenerator/integration_tests/tests/test_indexers/dynamic_contracts/tsconfig.json
  • codegenerator/cli/npm/envio/src/db/InternalTable.gen.ts
  • codegenerator/cli/templates/static/erc20_template/typescript/tsconfig.json
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • codegenerator/cli/npm/envio/src/bindings/BigInt.gen.ts
  • codegenerator/cli/npm/envio/src/bindings/BigDecimal.gen.ts
  • codegenerator/cli/templates/static/factory_template/typescript/tsconfig.json
  • codegenerator/cli/templates/static/blank_template/typescript/tsconfig.json
  • codegenerator/cli/templates/static/codegen/index.js
📚 Learning: 2025-11-25T12:40:26.435Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/rescript.mdc:0-0
Timestamp: 2025-11-25T12:40:26.435Z
Learning: Applies to **/*.{res,resi} : Always use ReScript 11 documentation

Applied to files:

  • scenarios/helpers/rescript.json
  • codegenerator/cli/templates/static/blank_template/rescript/rescript.json
  • scenarios/fuel_test/rescript.json
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • scenarios/test_codegen/package.json
  • codegenerator/cli/npm/envio/rescript.json
  • scenarios/test_codegen/rescript.json
  • codegenerator/cli/npm/envio/index.js
  • codegenerator/cli/templates/static/codegen/rescript.json
  • scenarios/erc20_multichain_factory/rescript.json
📚 Learning: 2025-11-25T12:40:19.463Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Applies to **/*.{test.res,spec.res} : Prefer public module APIs for testing in ReScript

Applied to files:

  • scenarios/helpers/rescript.json
  • scenarios/test_codegen/.mocharc.json
  • codegenerator/cli/templates/static/blank_template/rescript/rescript.json
  • scenarios/fuel_test/rescript.json
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • scenarios/test_codegen/package.json
  • codegenerator/cli/npm/envio/rescript.json
  • scenarios/test_codegen/rescript.json
  • scenarios/test_codegen/test/topic-hashing-test.ts
  • codegenerator/cli/templates/static/codegen/rescript.json
  • scenarios/erc20_multichain_factory/rescript.json
📚 Learning: 2025-11-25T12:40:19.463Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Applies to codegenerator/cli/templates/static/**/*.res : Static ReScript files must be placed in `codegenerator/cli/templates/static/`

Applied to files:

  • scenarios/helpers/rescript.json
  • scenarios/fuel_test/package.json
  • codegenerator/cli/templates/static/blank_template/rescript/rescript.json
  • scenarios/fuel_test/rescript.json
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • scenarios/test_codegen/package.json
  • codegenerator/cli/npm/envio/rescript.json
  • scenarios/test_codegen/rescript.json
  • codegenerator/cli/templates/static/codegen/rescript.json
  • scenarios/erc20_multichain_factory/rescript.json
📚 Learning: 2025-11-25T12:40:26.435Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/rescript.mdc:0-0
Timestamp: 2025-11-25T12:40:26.435Z
Learning: Applies to **/*.{res,resi} : Never suggest ReasonML syntax

Applied to files:

  • scenarios/helpers/rescript.json
  • codegenerator/cli/templates/static/blank_template/rescript/rescript.json
  • scenarios/fuel_test/rescript.json
  • codegenerator/cli/npm/envio/rescript.json
  • scenarios/test_codegen/rescript.json
  • codegenerator/cli/templates/static/codegen/rescript.json
📚 Learning: 2025-11-25T12:40:19.463Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Applies to **/generated/src/Config.res : Generated config module must be named `Config.res` and convert environment variables to typed config, setting up persistence

Applied to files:

  • scenarios/helpers/rescript.json
  • codegenerator/cli/templates/static/blank_template/rescript/rescript.json
  • scenarios/fuel_test/rescript.json
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • codegenerator/cli/npm/envio/rescript.json
  • scenarios/test_codegen/rescript.json
  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
  • codegenerator/cli/templates/static/codegen/rescript.json
  • scenarios/erc20_multichain_factory/rescript.json
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Whitelist and use the commands: pnpm codegen, pnpm tsc --noEmit, TUI_OFF=true pnpm dev during development

Applied to files:

  • scenarios/fuel_test/package.json
  • scenarios/test_codegen/package.json
  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/package.json
📚 Learning: 2025-11-25T12:40:19.463Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Applies to **/generated/src/Index.res : Generated runtime entry module must be named `Index.res` and must start HTTP server, load `Config.res`, call `RegisterHandlers.res`, and spin up `GlobalStateManager.res`

Applied to files:

  • scenarios/fuel_test/package.json
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • scenarios/test_codegen/package.json
  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
  • codegenerator/cli/templates/static/codegen/src/Index.res
  • codegenerator/cli/templates/static/codegen/index.js
📚 Learning: 2025-11-25T12:40:49.622Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
Learning: Whitelist the following commands for execution: `pnpm codegen` and `pnpm tsc --noEmit`

Applied to files:

  • scenarios/fuel_test/package.json
  • scenarios/test_codegen/package.json
  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/package.json
📚 Learning: 2025-11-25T12:40:19.463Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Rust CLI entry point is at `codegenerator/cli/src/lib.rs`

Applied to files:

  • scenarios/fuel_test/package.json
  • scenarios/test_codegen/package.json
📚 Learning: 2025-11-25T12:40:49.622Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/**/*.ts : In Envio, use `entity_id` fields (e.g., `token_id: string`) instead of direct object references for entity relationships

Applied to files:

  • codegenerator/cli/npm/envio/package.json.tmpl
  • scenarios/test_codegen/test/Integration_ts_helpers.gen.ts
  • codegenerator/cli/npm/envio/src/db/InternalTable.gen.ts
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • codegenerator/cli/npm/envio/rescript.json
  • codegenerator/cli/npm/envio/src/bindings/Ethers.gen.ts
  • codegenerator/cli/npm/envio/src/Internal.gen.ts
  • codegenerator/cli/npm/envio/src/Envio.gen.ts
  • codegenerator/cli/npm/envio/index.js
  • codegenerator/cli/npm/envio/src/sources/HyperSyncClient.gen.ts
  • codegenerator/cli/templates/static/greeteronfuel_template/typescript/tsconfig.json
  • codegenerator/cli/templates/static/factory_template/typescript/tsconfig.json
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Register dynamic contracts created by factory events using contractRegister above the handler (e.g., context.addPair(event.params.pair))

Applied to files:

  • codegenerator/integration_tests/tests/test_indexers/dynamic_contracts/tsconfig.json
  • codegenerator/cli/npm/envio/src/db/InternalTable.gen.ts
  • scenarios/test_codegen/config.yaml
  • scenarios/erc20_multichain_factory/config.yaml
  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
  • scenarios/test_codegen/test/topic-hashing-test.ts
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Never hardcode chainId = 1; always use event.chainId for chain-specific operations

Applied to files:

  • scenarios/test_codegen/test/Integration_ts_helpers.gen.ts
  • codegenerator/cli/npm/envio/src/Envio.gen.ts
  • scenarios/test_codegen/test/topic-hashing-test.ts
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Use chain-specific Bundle IDs in format ${chainId}-1 for accurate pricing per network

Applied to files:

  • scenarios/test_codegen/test/Integration_ts_helpers.gen.ts
📚 Learning: 2025-11-25T12:40:26.435Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/rescript.mdc:0-0
Timestamp: 2025-11-25T12:40:26.435Z
Learning: Applies to **/*.test.{res,resi} : Never use `Js.Console.log` in test files. Use `Assert` module for all verifications

Applied to files:

  • scenarios/test_codegen/test/manual/README.md
  • scenarios/test_codegen/.mocharc.json
  • scenarios/test_codegen/test/topic-hashing-test.ts
📚 Learning: 2025-11-25T12:40:26.435Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/rescript.mdc:0-0
Timestamp: 2025-11-25T12:40:26.435Z
Learning: Applies to **/*.test.{res,resi} : Tests should be silent unless they fail - rely on assertions rather than logging

Applied to files:

  • scenarios/test_codegen/test/manual/README.md
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/effects/**/*.ts : Create Effect API functions in src/effects/ folder with proper schema definition using createEffect from 'envio'

Applied to files:

  • codegenerator/cli/npm/envio/bin.js
  • codegenerator/cli/npm/envio/src/Envio.gen.ts
  • codegenerator/cli/npm/envio/index.js
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/config.yaml : Update config.yaml to point handler field to contract-specific files instead of single EventHandlers.ts file

Applied to files:

  • scenarios/test_codegen/config.yaml
  • scenarios/erc20_multichain_factory/config.yaml
  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
  • codegenerator/cli/src/cli_args/init_config.rs
  • codegenerator/cli/templates/static/codegen/index.js
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/EventHandlers.ts : Clear all boilerplate logic from EventHandlers.ts and replace with empty handlers containing TODO comments

Applied to files:

  • scenarios/test_codegen/config.yaml
  • scenarios/erc20_multichain_factory/config.yaml
  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/config.yaml : Check that global contract definitions in config.yaml do not repeat handler, events, or configuration in network-specific sections

Applied to files:

  • scenarios/test_codegen/config.yaml
  • scenarios/erc20_multichain_factory/config.yaml
📚 Learning: 2025-11-25T12:40:49.622Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/EventHandlers.ts : When updating existing entities in TypeScript handlers, always use the spread operator since returned objects are read-only and immutable

Applied to files:

  • scenarios/test_codegen/config.yaml
  • scenarios/erc20_multichain_factory/config.yaml
📚 Learning: 2025-11-25T12:40:49.622Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/**/*.ts : Define Effect schemas using the `S` module from 'envio' with required properties: name, input schema, output schema, rateLimit, and cache

Applied to files:

  • codegenerator/cli/npm/envio/rescript.json
  • codegenerator/cli/npm/envio/src/Envio.gen.ts
  • codegenerator/cli/npm/envio/index.js
  • codegenerator/cli/npm/envio/src/sources/vendored-fuel-abi-coder.js
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Never use .bind() pattern for contract state access; use Effect API with viem transport for RPC calls instead

Applied to files:

  • codegenerator/cli/npm/envio/src/bindings/Ethers.gen.ts
  • scenarios/erc20_multichain_factory/config.yaml
📚 Learning: 2025-11-25T12:40:49.622Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
Learning: Use Node.js v20 only (no higher or lower versions)

Applied to files:

  • scenarios/test_codegen/tsconfig.json
  • codegenerator/integration_tests/tests/test_indexers/test_exits/tsconfig.json
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Maintain BigDecimal precision for financial calculations; never simplify to JavaScript number types

Applied to files:

  • codegenerator/cli/npm/envio/src/bindings/BigInt.gen.ts
  • codegenerator/cli/npm/envio/src/sources/vendored-fuel-abi-coder.js
  • codegenerator/cli/npm/envio/src/bindings/BigDecimal.res
  • codegenerator/cli/npm/envio/src/bindings/BigDecimal.gen.ts
  • codegenerator/cli/templates/static/codegen/index.js
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/utils/**/*.ts : Return BigDecimal from helper functions for financial calculations instead of number type

Applied to files:

  • codegenerator/cli/npm/envio/src/bindings/BigInt.gen.ts
  • codegenerator/cli/npm/envio/src/sources/vendored-fuel-abi-coder.js
  • codegenerator/cli/npm/envio/src/bindings/BigDecimal.res
  • codegenerator/cli/npm/envio/src/bindings/BigDecimal.gen.ts
  • codegenerator/cli/templates/static/codegen/index.js
📚 Learning: 2025-11-25T12:40:49.622Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/EventHandlers.ts : Always cast timestamps to BigInt (e.g., `BigInt(event.block.timestamp)`) instead of using raw timestamps

Applied to files:

  • codegenerator/cli/npm/envio/src/bindings/BigInt.gen.ts
  • codegenerator/cli/npm/envio/src/Internal.gen.ts
  • codegenerator/cli/npm/envio/src/Envio.gen.ts
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/config.yaml : Remove address field from config.yaml for dynamically created contracts; only include addresses for factory contracts

Applied to files:

  • scenarios/erc20_multichain_factory/config.yaml
📚 Learning: 2025-11-25T12:40:49.622Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/EventHandlers.ts : When making external calls in handlers with preload optimisations enabled, MUST use the Effect API from 'envio' instead of direct fetch/external calls

Applied to files:

  • scenarios/erc20_multichain_factory/config.yaml
  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
  • scenarios/test_codegen/test/topic-hashing-test.ts
📚 Learning: 2025-11-25T12:40:49.622Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/EventHandlers.ts : ALWAYS normalize amounts when adding tokens with different decimal places; create helper functions to convert all amounts to a standard decimal (e.g., 18 decimals)

Applied to files:

  • scenarios/erc20_multichain_factory/config.yaml
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Implement complex handlers one at a time and run quality checks after each handler completion before proceeding to next

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Use Effect API for all external calls (RPC calls, API calls) via context.effect() with preload_handlers: true enabled

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Do not use !context.isPreload check logic during the main implementation phase; use it only after all handlers are complete

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-11-25T12:40:49.622Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/EventHandlers.ts : Use `!context.isPreload` checks in handlers to prevent logic from running during preload when using preload optimisations

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/schema.graphql : Migrate schema by converting entity(immutable: true) decorators to plain entities and Bytes! to String!, removing immutable declarations

Applied to files:

  • codegenerator/cli/npm/envio/index.js
🧬 Code graph analysis (1)
codegenerator/cli/src/cli_args/init_config.rs (1)
codegenerator/cli/src/utils/unique_hashmap.rs (1)
  • try_insert (4-17)
⏰ 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

Comment on lines +5 to +7
import * as Sury from "rescript-schema";
import { schema as bigintSchema } from "./src/bindings/BigInt.res.mjs";
import { schema as bigDecimalSchema } from "./src/bindings/BigDecimal.res.mjs";

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.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify ReScript config and imported .mjs files

echo "=== Looking for ReScript configuration files ==="
fd -e json "bsconfig|rescript" --maxdepth 3 | head -20

echo -e "\n=== Checking codegenerator/cli/npm/envio directory structure ==="
find codegenerator/cli/npm/envio -type f -name "*.json" | head -10

echo -e "\n=== Verifying imported .mjs files exist ==="
test -f "codegenerator/cli/npm/envio/src/bindings/BigInt.res.mjs" && echo "✓ BigInt.res.mjs exists" || echo "✗ BigInt.res.mjs NOT found"
test -f "codegenerator/cli/npm/envio/src/bindings/BigDecimal.res.mjs" && echo "✓ BigDecimal.res.mjs exists" || echo "✗ BigDecimal.res.mjs NOT found"

echo -e "\n=== Checking for source .res files ==="
fd "^(BigInt|BigDecimal)\.res$" codegenerator/cli/npm/envio/

echo -e "\n=== ReScript config in root or codegenerator ==="
cat bsconfig.json 2>/dev/null || echo "No bsconfig.json in root"
echo "---"
find codegenerator -name "bsconfig.json" -o -name "rescript.json" 2>/dev/null

Repository: enviodev/hyperindex

Length of output: 2276


🏁 Script executed:

#!/bin/bash
# Check ReScript configuration and actual imports

echo "=== ReScript configuration ==="
cat codegenerator/cli/npm/envio/rescript.json

echo -e "\n=== Actual imports in index.js ==="
head -20 codegenerator/cli/npm/envio/index.js

echo -e "\n=== Package.json build scripts ==="
grep -A 10 '"scripts"' codegenerator/cli/npm/envio/package.json

echo -e "\n=== Check compiled output directory ==="
find codegenerator/cli/npm/envio/src/bindings -type f | head -20

Repository: enviodev/hyperindex

Length of output: 2676


🏁 Script executed:

#!/bin/bash
# Check if .res.mjs files are in .gitignore

echo "=== Checking .gitignore for .res.mjs exclusion ==="
grep -r "\.mjs\|\.res\.mjs" .gitignore 2>/dev/null || echo "No .mjs patterns found in .gitignore"

echo -e "\n=== Looking for any .gitignore in codegenerator or envio directories ==="
find codegenerator/cli/npm/envio -name ".gitignore" -exec cat {} \;

echo -e "\n=== Check if .res.mjs files are in git ==="
git ls-files codegenerator/cli/npm/envio/src/bindings/*.res.mjs 2>/dev/null | wc -l

echo -e "\n=== Verify Envio.res.mjs (also imported) ==="
test -f "codegenerator/cli/npm/envio/src/Envio.res.mjs" && echo "✓ Envio.res.mjs exists" || echo "✗ Envio.res.mjs NOT found"
git ls-files "codegenerator/cli/npm/envio/src/Envio.res.mjs" 2>/dev/null && echo "  - In git" || echo "  - Not in git"

Repository: enviodev/hyperindex

Length of output: 2444


🏁 Script executed:

#!/bin/bash
# Verify package entry points and build workflow

echo "=== Package.json main and exports ==="
cat codegenerator/cli/npm/envio/package.json | grep -A 20 '"main"\|"exports"' | head -30

echo -e "\n=== Check if there's a prepare or prebuild script ==="
cat codegenerator/cli/npm/envio/package.json | grep -A 5 '"scripts"'

echo -e "\n=== Look for build output configuration ==="
ls -la codegenerator/cli/npm/envio/ | grep -E "dist|build|lib"

Repository: enviodev/hyperindex

Length of output: 875


The imports reference non-existent compiled files that are excluded from the repository.

The .res.mjs files are deliberately excluded from git (via .gitignore), but index.js (the package entry point per package.json main field) imports from them directly. Without these compiled artifacts, the imports will fail at runtime:

  • Line 6: import { schema as bigintSchema } from "./src/bindings/BigInt.res.mjs" → file missing
  • Line 7: import { schema as bigDecimalSchema } from "./src/bindings/BigDecimal.res.mjs" → file missing
  • Line 11: export * from "./src/Envio.res.mjs" → file missing

The ReScript configuration is correct (specifies ESM output with in-source compilation), but the compiled output isn't present in the repository. The package requires a build step (pnpm rescript per learnings) to be run before index.js is functional. This should either be:

  1. Enforced via a prepare script in package.json, or
  2. Documented as a required pre-import build step
🤖 Prompt for AI Agents
In codegenerator/cli/npm/envio/index.js around lines 5 to 7, the file imports
compiled ReScript artifacts (.res.mjs) that are intentionally excluded from the
repo so runtime imports will fail; add a prepare script to package.json that
runs the ReScript build (e.g., "prepare": "pnpm rescript build" or the project’s
existing build command) so the compiled .res.mjs outputs are produced prior to
publishing/installation, and/or update README to document that consumers must
run the ReScript build (or run the package’s prepare script) before importing
this module; ensure package.json main field remains correct and that CI/publish
steps run the build to include artifacts where necessary.

"print-benchmark-summary": "node -e 'import(\"./src/Benchmark.res.mjs\").then(m => m.Summary.printSummary())'",
{{!-- We need this to always have cwd at the root of the project --}}
"start": "cd {{relative_path_to_root_from_generated}} && ts-node {{relative_path_to_generated_from_root}}/src/Index.res.js"
"start": "cd {{relative_path_to_root_from_generated}} && node --loader {{relative_path_to_generated_from_root}}/node_modules/ts-node/esm.mjs --experimental-specifier-resolution=node {{relative_path_to_generated_from_root}}/src/Index.res.mjs"

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.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if the template file exists and read its contents
if [ -f "codegenerator/cli/templates/dynamic/codegen/package.json.hbs" ]; then
  echo "=== File found, reading contents ==="
  cat -n "codegenerator/cli/templates/dynamic/codegen/package.json.hbs" | head -30
else
  echo "File not found at specified path"
  fd "package.json.hbs" codegenerator/
fi

Repository: enviodev/hyperindex

Length of output: 1545


🏁 Script executed:

#!/bin/bash
# Check for ts-node in dependencies
echo "=== Searching for ts-node in package.json files ==="
rg -A 5 -B 5 '"ts-node"' --type json codegenerator/cli/templates/

echo ""
echo "=== Looking for dependencies section in the template ==="
sed -n '28,80p' codegenerator/cli/templates/dynamic/codegen/package.json.hbs

Repository: enviodev/hyperindex

Length of output: 989


🏁 Script executed:

#!/bin/bash
# Search for Index.res or Index files in the codebase
echo "=== Looking for Index.res or Index files ==="
fd "Index\.(res|ts|mjs)" codegenerator/

echo ""
echo "=== Looking for any comments about ts-node or ESM loader ==="
rg -C 3 "ts-node|esm\.mjs" codegenerator/ --type hbs

echo ""
echo "=== Checking if there are any TypeScript files in src/ ==="
fd "\.(ts|tsx)$" codegenerator/cli/templates/dynamic/codegen/src/ 2>/dev/null | head -20

Repository: enviodev/hyperindex

Length of output: 1916


🏁 Script executed:

#!/bin/bash
# Check if Index.res has any special characteristics
echo "=== Reading Index.res from static template ==="
cat -n codegenerator/cli/templates/static/codegen/src/Index.res | head -30

echo ""
echo "=== Search for git history or comments about Index.res ==="
git log --oneline -n 20 -- codegenerator/cli/templates/dynamic/codegen/package.json.hbs 2>/dev/null | head -10

echo ""
echo "=== Check for any index-related configuration or special handling ==="
rg -i "index\.res" codegenerator/ -A 2 -B 2 --type hbs --type res | head -40

Repository: enviodev/hyperindex

Length of output: 1299


🏁 Script executed:

#!/bin/bash
# Search for TODOs or comments about start script
echo "=== Search for TODOs or FIXME related to start script ==="
rg "TODO|FIXME" codegenerator/cli/templates/dynamic/codegen/ -A 2 -B 2

echo ""
echo "=== Search for documentation about running the start script ==="
fd "README|DOCS|docs" codegenerator/cli/templates/dynamic/codegen/

echo ""
echo "=== Look for any ESM or ts-node related documentation ==="
rg -i "esm|commonjs" codegenerator/cli/templates/dynamic/ --type hbs --type json -l

echo ""
echo "=== Check the recent commit that mentions ESM migration ==="
git show 556b8dcc --stat 2>/dev/null | head -30

Repository: enviodev/hyperindex

Length of output: 3574


🌐 Web query:

ts-node ESM loader support for .mjs files Node.js compatibility

💡 Result:

Short answer

  • ts-node supports running TypeScript as native ESM via its loader/CLI (ts-node --esm / ts-node-esm / node --loader ts-node/esm), but that support depends on Node’s experimental loader hooks and has known compatibility and stability issues across Node releases. [1][2][3]

Key points (what you need to know)

  • Node treats .mjs as ESM; any loader used must implement Node’s ESM loader hooks. ts-node exposes an ESM loader (ts-node/esm) to do this. Use the ts-node CLI flag --esm or node --loader ts-node/esm. [1][3]
  • The Node ESM loader API has changed and some flags (e.g. --loader behavior and related warnings) are experimental/deprecated in recent Node versions (Node 20+), so ts-node’s loader can break between Node releases and is not recommended for production. Expect to need Node-specific workarounds (NODE_OPTIONS or spawn-child behavior) and to upgrade/adjust when Node changes its loader hooks. [2][3][9]
  • .mjs files are handled as ESM by Node; if you want to author TypeScript and run it as .mjs, prefer using .mts (TS ESM extension) or set "type":"module" and keep .ts/.mts—ts-node’s ESM path is intended for .ts/.mts ESM workflows rather than forcing .mjs. If you have pre-built .mjs JS files, they run normally under Node; ts-node’s loader is for on-the-fly TypeScript → ESM handling. [2][3][8]

Practical options/recommendations

  1. For development (fast, flexible): use ts-node’s ESM support but pin Node version and test when upgrading Node. Run via:
    • npx ts-node-esm ./src/main.ts
    • or node --loader ts-node/esm ./src/main.ts
      (set "type":"module" and "module":"ESNext" in package.json/tsconfig as documented). [1][3]
  2. If you need more stable cross-Node support: use a modern loader based on esbuild (esbuild-kit/esm-loader) or use tsx which implements robust ESM+TS loading and is less tied to Node loader instability. These handle .mjs/.mts and Node resolution quirks more resiliently. [0][1]
  3. For production or to avoid loader breakage: compile with tsc (emit .mjs/.js as needed) and run plain node. [2]

Sources

  • ts-node (TypeStrong) README & ESM notes. [1]
  • Node.js ECMAScript modules docs / loader behavior. [2]
  • esbuild-kit esm-loader (alternative loader that supports .mjs/.mts). [0]
  • Practical notes / troubleshooting about ts-node --esm and Node loader warnings. [9]

If you want, tell me: (a) your Node version and (b) whether you want on-the-fly execution (dev) or production builds — I’ll give exact commands/config for your case.


🏁 Script executed:

#!/bin/bash
# Check for any test files or test documentation about the start script
echo "=== Search for test files mentioning start script or Index ==="
fd "test|spec" codegenerator/cli/templates/dynamic/codegen/ -type f 2>/dev/null | head -10

echo ""
echo "=== Look for any .mjs or .cjs references in recent commits ==="
git log --oneline --all -- "*.mjs" "*.cjs" 2>/dev/null | head -20

echo ""
echo "=== Check if there's a way to run the start script without ts-node ==="
rg "Index\.res\.mjs|start.*script" codegenerator/ -B 3 -A 3 --type hbs

Repository: enviodev/hyperindex

Length of output: 2408


Based on my verification, I've identified a significant issue with the start script configuration:

Remove ts-node/esm.mjs loader; use direct node import like other scripts in the file.

The start script unnecessarily uses the ts-node ESM loader on a pre-built .mjs file (compiled ReScript). This is problematic because:

  1. ts-node is for TypeScript, not pre-compiled JavaScript. Index.res.mjs is pure compiled ReScript → JavaScript, not TypeScript source.

  2. Inconsistent with other scripts: Lines 13-16 successfully use plain node with import() for other .res.mjs files (Migrations, Benchmark) without ts-node.

  3. Adds experimental/unstable hooks: The --loader ts-node/esm.mjs uses Node's experimental ESM loader hooks, which have known stability issues across Node versions (especially Node 20+). The project targets Node 22.x which has documented loader instability.

  4. Git history shows instability: Commits like "Downgrade ink and convert geneated back to cjs" and this recent "CommonJs -> ESM WIP" indicate ongoing ESM migration issues.

Suggested fix: Use the same pattern as other scripts:

"start": "cd {{relative_path_to_root_from_generated}} && node -e 'import(\"{{relative_path_to_generated_from_root}}/src/Index.res.mjs\").then(m => m.main())'"

Or if Index.res.mjs is an executable entry point, simply:

"start": "cd {{relative_path_to_root_from_generated}} && node {{relative_path_to_generated_from_root}}/src/Index.res.mjs"

Comment thread codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs Outdated
Comment thread scenarios/test_codegen/test/manual/README.md
@DZakh DZakh linked an issue Nov 28, 2025 that may be closed by this pull request

@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: 1

♻️ Duplicate comments (2)
codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs (1)

27-27: Fix typo in comment.

"Relatvie" should be "Relative".

-  // Relatvie to cwd (project root)
+  // Relative to cwd (project root)
codegenerator/cli/templates/dynamic/codegen/package.json.hbs (1)

18-18: Avoid ts-node ESM loader for compiled Index.res.mjs (agree with prior review)

I agree with the earlier review: using --loader ts-node/esm.mjs and --experimental-specifier-resolution=node to run a compiled Index.res.mjs is unnecessary and brittle, especially on Node 22.x, and inconsistent with the other scripts that just use node + ESM imports.

Since Index.res.mjs is already JS, you can drop the ts-node loader and let Node run the file directly:

-    "start": "cd {{relative_path_to_root_from_generated}} &&  node --no-warnings --loader {{relative_path_to_generated_from_root}}/node_modules/ts-node/esm.mjs --experimental-specifier-resolution=node {{relative_path_to_generated_from_root}}/src/Index.res.mjs"
+    "start": "cd {{relative_path_to_root_from_generated}} && node --no-warnings {{relative_path_to_generated_from_root}}/src/Index.res.mjs"

This removes experimental loader hooks and avoids coupling the generated runtime to ts-node’s ESM implementation while keeping the same entrypoint.

Does ts-node 10.9.1 officially support Node 22.x ESM loader usage (via `--loader ts-node/esm.mjs`) for production, or is it recommended to run already-compiled `.mjs` files with plain `node` instead?
🧹 Nitpick comments (1)
codegenerator/cli/templates/dynamic/codegen/package.json.hbs (1)

13-16: Dynamic ESM imports for migrations/benchmark are correctly structured; Windows portability is a valid concern

The runUpMigrations, runDownMigrations, and Summary.printSummary functions are properly exported from their respective ReScript source files and will be available in the compiled .mjs outputs.

However, the node -e 'import("...").then(...)' pattern does have a portability limitation: cmd.exe on Windows does not interpret single-quoted strings the same way as POSIX shells, which will break npm run db-up/db-down/db-setup/print-benchmark-summary on Windows. If cross-platform npm script support is a priority, consider extracting this code into a small .mjs CLI file committed to the template and updating the scripts to invoke it directly (e.g., node ./scripts/db.mjs up), which preserves ESM semantics while avoiding shell-quoting issues.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 894faae and 53f7e04.

⛔ Files ignored due to path filters (1)
  • scenarios/test_codegen/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (8)
  • codegenerator/cli/npm/envio/src/bindings/BigDecimal.res.d.mts (1 hunks)
  • codegenerator/cli/npm/envio/src/bindings/BigInt.res.d.mts (1 hunks)
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs (2 hunks)
  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs (4 hunks)
  • codegenerator/cli/templates/static/codegen/src/ink/bindings/Ink.res (2 hunks)
  • codegenerator/integration_tests/tests/test_indexers/test_exits/package.json (1 hunks)
  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/package.json (2 hunks)
  • scenarios/fuel_test/package.json (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • scenarios/fuel_test/package.json
  • codegenerator/integration_tests/tests/test_indexers/test_exits/package.json
  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/package.json
🧰 Additional context used
📓 Path-based instructions (3)
codegenerator/cli/templates/static/**/*.res

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

Static ReScript files must be placed in codegenerator/cli/templates/static/

Files:

  • codegenerator/cli/templates/static/codegen/src/ink/bindings/Ink.res
**/*.{res,resi}

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

**/*.{res,resi}: Always use ReScript 11 documentation
Never suggest ReasonML syntax
Never use [| item |] to create an array. Use [ item ] instead
Must always use = for setting value to a field. Use := only for ref values created using ref function
Use records when working with structured data, and objects to conveniently pass payload data between functions
Never use %raw to access object fields if you know the type

Files:

  • codegenerator/cli/templates/static/codegen/src/ink/bindings/Ink.res
codegenerator/cli/templates/dynamic/**/*.hbs

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

Handlebars templates must be placed in codegenerator/cli/templates/dynamic/

Files:

  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
🧠 Learnings (35)
📓 Common learnings
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/utils/**/*.ts : Implement helper functions with no entity/handler dependencies immediately during migration phase 5a
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Use async/await for all context.Entity.get() and context.effect() calls; context.Entity.set() does not need await
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Move entity creation from EventHandlers.ts to contract-specific handler files matching original subgraph organization
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Maintain BigDecimal precision for financial calculations; never simplify to JavaScript number types

Applied to files:

  • codegenerator/cli/npm/envio/src/bindings/BigDecimal.res.d.mts
  • codegenerator/cli/npm/envio/src/bindings/BigInt.res.d.mts
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/utils/**/*.ts : Return BigDecimal from helper functions for financial calculations instead of number type

Applied to files:

  • codegenerator/cli/npm/envio/src/bindings/BigDecimal.res.d.mts
  • codegenerator/cli/npm/envio/src/bindings/BigInt.res.d.mts
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Verify that entity field types in code match exactly with GraphQL schema property types (Int!, BigInt!, BigDecimal!, String!, Bytes!, Boolean!)

Applied to files:

  • codegenerator/cli/npm/envio/src/bindings/BigDecimal.res.d.mts
  • codegenerator/cli/npm/envio/src/bindings/BigInt.res.d.mts
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Use ZERO_BD and ZERO_BI constants for entity field initialization instead of hardcoded 0 values

Applied to files:

  • codegenerator/cli/npm/envio/src/bindings/BigDecimal.res.d.mts
  • codegenerator/cli/npm/envio/src/bindings/BigInt.res.d.mts
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Ensure entity type annotations use the _t suffix (e.g., Pair_t, Token_t) when defining entity objects

Applied to files:

  • codegenerator/cli/npm/envio/src/bindings/BigDecimal.res.d.mts
  • codegenerator/cli/npm/envio/src/bindings/BigInt.res.d.mts
📚 Learning: 2025-11-25T12:40:49.622Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/**/*.ts : Define Effect schemas using the `S` module from 'envio' with required properties: name, input schema, output schema, rateLimit, and cache

Applied to files:

  • codegenerator/cli/npm/envio/src/bindings/BigDecimal.res.d.mts
  • codegenerator/cli/npm/envio/src/bindings/BigInt.res.d.mts
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Import entity types from 'generated/src/db/Entities.gen' not 'generated' for type definitions

Applied to files:

  • codegenerator/cli/npm/envio/src/bindings/BigDecimal.res.d.mts
  • codegenerator/cli/npm/envio/src/bindings/BigInt.res.d.mts
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
📚 Learning: 2025-11-25T12:40:49.622Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
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/npm/envio/src/bindings/BigDecimal.res.d.mts
  • codegenerator/cli/npm/envio/src/bindings/BigInt.res.d.mts
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
📚 Learning: 2025-11-25T12:40:49.622Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/**/*.ts : Use `string | undefined` for optional string fields in TypeScript types, not `string | null`, as generated types are strict about null vs undefined

Applied to files:

  • codegenerator/cli/npm/envio/src/bindings/BigDecimal.res.d.mts
  • codegenerator/cli/npm/envio/src/bindings/BigInt.res.d.mts
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Create handler skeleton files with exact filenames matching the original subgraph structure during file refactoring

Applied to files:

  • codegenerator/cli/npm/envio/src/bindings/BigDecimal.res.d.mts
  • codegenerator/cli/npm/envio/src/bindings/BigInt.res.d.mts
  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Run pnpm codegen, pnpm tsc --noEmit, and TUI_OFF=true pnpm dev after every code change to catch runtime errors

Applied to files:

  • codegenerator/cli/npm/envio/src/bindings/BigDecimal.res.d.mts
  • codegenerator/cli/npm/envio/src/bindings/BigInt.res.d.mts
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
📚 Learning: 2025-11-25T12:40:49.622Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/EventHandlers.ts : Always cast timestamps to BigInt (e.g., `BigInt(event.block.timestamp)`) instead of using raw timestamps

Applied to files:

  • codegenerator/cli/npm/envio/src/bindings/BigInt.res.d.mts
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Move entity creation from EventHandlers.ts to contract-specific handler files matching original subgraph organization

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-11-25T12:40:19.463Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Applies to **/generated/src/Index.res : Generated runtime entry module must be named `Index.res` and must start HTTP server, load `Config.res`, call `RegisterHandlers.res`, and spin up `GlobalStateManager.res`

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-11-25T12:40:19.463Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Applies to codegenerator/cli/templates/static/**/*.res : Static ReScript files must be placed in `codegenerator/cli/templates/static/`

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Systematically review each handler logic against original subgraph multiple times until logic is completely correct

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Reference original subgraph logic files in TODO comments when creating skeleton handlers (e.g., 'Reference: original-subgraph/src/mappings/contract.ts')

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Do not use !context.isPreload check logic during the main implementation phase; use it only after all handlers are complete

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-11-25T12:40:19.463Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Applies to **/*.{test.res,spec.res} : Prefer public module APIs for testing in ReScript

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
📚 Learning: 2025-11-25T12:40:26.435Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/rescript.mdc:0-0
Timestamp: 2025-11-25T12:40:26.435Z
Learning: Applies to **/*.{res,resi} : Always use ReScript 11 documentation

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
📚 Learning: 2025-11-25T12:40:19.463Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Verify tests pass by running `pnpm rescript` compiler and `pnpm mocha` test runner

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
📚 Learning: 2025-11-25T12:40:19.463Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Applies to **/generated/src/Config.res : Generated config module must be named `Config.res` and convert environment variables to typed config, setting up persistence

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-11-25T12:40:19.463Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Applies to **/*.{test.res,spec.res} : Use `_only` to specify which tests to run in ReScript Mocha tests

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Use async/await for all context.Entity.get() and context.effect() calls; context.Entity.set() does not need await

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Register dynamic contracts created by factory events using contractRegister above the handler (e.g., context.addPair(event.params.pair))

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Include proper error handling for Effect API calls with try/catch and fallback values

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/utils/**/*.ts : Implement helper functions with no entity/handler dependencies immediately during migration phase 5a

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Use Effect API for all external calls (RPC calls, API calls) via context.effect() with preload_handlers: true enabled

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/config.yaml : Update config.yaml to point handler field to contract-specific files instead of single EventHandlers.ts file

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Use context.log.error() for error logging in handlers and effects instead of console.log()

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Implement complex handlers one at a time and run quality checks after each handler completion before proceeding to next

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-11-25T12:40:49.622Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/EventHandlers.ts : Use `!context.isPreload` checks in handlers to prevent logic from running during preload when using preload optimisations

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-11-25T12:40:49.622Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/EventHandlers.ts : When making external calls in handlers with preload optimisations enabled, MUST use the Effect API from 'envio' instead of direct fetch/external calls

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/EventHandlers.ts : Clear all boilerplate logic from EventHandlers.ts and replace with empty handlers containing TODO comments

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
🧬 Code graph analysis (2)
codegenerator/cli/npm/envio/src/bindings/BigDecimal.res.d.mts (1)
codegenerator/cli/npm/envio/src/bindings/BigInt.res.d.mts (1)
  • schema (5-5)
codegenerator/cli/npm/envio/src/bindings/BigInt.res.d.mts (1)
codegenerator/cli/npm/envio/src/bindings/BigDecimal.res.d.mts (1)
  • schema (5-5)
⏰ 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 (9)
codegenerator/cli/npm/envio/src/bindings/BigInt.res.d.mts (1)

1-5: ESM stub and tsc workaround comment look good

The explanatory comment clearly documents why this stub exists and when it can be removed, and keeping export const schema: any; as a permissive placeholder is appropriate for a GenType-generated binding shim in this migration.

codegenerator/cli/npm/envio/src/bindings/BigDecimal.res.d.mts (1)

1-5: Consistent BigDecimal binding stub with BigInt

This mirrors the BigInt stub pattern and documents the tsc --noEmit workaround clearly; using export const schema: any; as a temporary ambient placeholder is reasonable for the ES module migration.

codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs (5)

1-7: LGTM!

The displayImportError helper provides a good approach for formatting import exceptions, especially handling ts-node errors that can't automatically convert to strings. Using inspect with depth: 5 is appropriate for nested error objects.


9-22: LGTM!

The async migration for registerContractHandlers is well-structured with proper error handling that includes contract name and handler path context.


24-54: LGTM on ESM auto-loading implementation.

Good improvements for ESM migration:

  • globIterator binding to node:fs/promises glob (Node.js 22+)
  • Pattern extended to include .mjs files for ESM support
  • Parallel loading via Promise.all with per-file error handling

130-151: LGTM on parallel handler registration.

Using Promise.all for contract handler registration improves loading performance compared to sequential loading. The flow correctly awaits all handlers before calling finishRegistration().


141-148: The code at line 145 is correct as written. Path.relativePathToRootFromGenerated is a valid ReScript value generated by the Path.res.hbs template that produces a module with this constant. The pattern of using ReScript string interpolation ${Path.relativePathToRootFromGenerated} in backtick strings is intentional and allows runtime reference to a compile-time-generated constant.

Likely an incorrect or invalid review comment.

codegenerator/cli/templates/static/codegen/src/ink/bindings/Ink.res (1)

221-263: BigText binding is correctly implemented and consistent with Spinner

The binding uses @module("ink-big-text") @react.component external make ... = "default", which is the correct pattern for binding CommonJS packages in this ESM-configured project (see rescript.json: "module": "esmodule", "moduleResolution": "node16"). Both ink-big-text and ink-spinner are CommonJS packages; using = "default" enables proper CommonJS-to-ESM interop. The binding is consistent with the existing Spinner module and follows standard ReScript practice. No changes needed.

codegenerator/cli/templates/dynamic/codegen/package.json.hbs (1)

7-7: ESM flag on generated package looks consistent with .mjs usage

Adding "type": "module" here is aligned with the move to .res.mjs entrypoints and keeps the generated package clearly ESM; no issues from the template side. As per coding guidelines, this Handlebars template is also correctly placed under codegenerator/cli/templates/dynamic/.

Comment thread codegenerator/cli/templates/dynamic/codegen/package.json.hbs
Comment thread codegenerator/cli/npm/envio/src/Internal.gen.ts

@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: 4

♻️ Duplicate comments (2)
codegenerator/cli/templates/dynamic/codegen/package.json.hbs (2)

18-18: Remove ts-node/esm.mjs loader; use direct node import like other scripts in the file.

This issue was already flagged in previous review comments. The start script unnecessarily uses the ts-node ESM loader on a pre-built .mjs file, which is problematic because:

  1. ts-node is for TypeScript, not pre-compiled JavaScript (Index.res.mjs is compiled ReScript)
  2. Inconsistent with lines 13-16 which successfully use plain node with import() for other .res.mjs files
  3. Adds experimental/unstable Node loader hooks

Use the same pattern as the other scripts in this file, or if Index.res.mjs is an executable entry point, use plain node.


38-53: Major dependency version bumps need explicit compatibility verification.

This issue was already flagged in previous review comments. Multiple major version bumps are introduced:

  • react19.2.0: Major version with breaking changes
  • @rescript/react0.14.0: Requires React 19, removes legacy JSX v3, mandates ReScript 11.0+
  • ink6.5.1: Major version bump
  • ink-big-text2.0.0: Major version
  • ink-spinner5.0.0: Major version

The template requires confirming the generated code still compiles and runs with these versions, particularly the ReScript/React integration (JSX v4 migration, uncurried bindings) and Ink-based TUI components.

🧹 Nitpick comments (2)
scenarios/test_codegen/test/CustomSelection_test.ts (1)

77-77: Remove debug console.log statement.

This debug output should be removed before merging.

Apply this diff:

-  console.log(updatedMockDb.entities.CustomSelectionTestPass.get(hash));
-
   assert.notEqual(
codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs (1)

1-7: Consider making displayImportError private if not used elsewhere.

The function is currently exported as a public top-level binding but appears to only be used internally within this generated file. If it's not intended to be part of the public API, consider making it private using %%private().

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 10e7684 and b8cfcd2.

⛔ Files ignored due to path filters (1)
  • scenarios/test_codegen/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (40)
  • codegenerator/cli/npm/envio/package.json (2 hunks)
  • codegenerator/cli/npm/envio/package.json.tmpl (2 hunks)
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs (2 hunks)
  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs (4 hunks)
  • codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs (2 hunks)
  • codegenerator/integration_tests/tests/test_indexers/dynamic_contracts/package.json (2 hunks)
  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/package.json (1 hunks)
  • scenarios/erc20_multichain_factory/.mocharc.json (1 hunks)
  • scenarios/erc20_multichain_factory/package.json (1 hunks)
  • scenarios/fuel_test/package.json (2 hunks)
  • scenarios/helpers/package.json (2 hunks)
  • scenarios/test_codegen/.mocharc.json (0 hunks)
  • scenarios/test_codegen/contracts/.gitignore (0 hunks)
  • scenarios/test_codegen/contracts/README.md (0 hunks)
  • scenarios/test_codegen/contracts/artifacts/contracts/GravatarRegistry.sol/GravatarRegistry.json (0 hunks)
  • scenarios/test_codegen/contracts/artifacts/contracts/NftFactory.sol/NftFactory.json (0 hunks)
  • scenarios/test_codegen/contracts/artifacts/contracts/SimpleNft.sol/SimpleNft.json (0 hunks)
  • scenarios/test_codegen/contracts/contracts/GravatarRegistry.sol (0 hunks)
  • scenarios/test_codegen/contracts/contracts/NftFactory.sol (0 hunks)
  • scenarios/test_codegen/contracts/contracts/SimpleNft.sol (0 hunks)
  • scenarios/test_codegen/contracts/deploy/deploy.js (0 hunks)
  • scenarios/test_codegen/contracts/package.json (0 hunks)
  • scenarios/test_codegen/contracts/secretsManager.example.ts (0 hunks)
  • scenarios/test_codegen/contracts/tasks/index.js (0 hunks)
  • scenarios/test_codegen/contracts/tasks/newGravatarTask.js (0 hunks)
  • scenarios/test_codegen/contracts/tasks/updateGravatarImageTask.js (0 hunks)
  • scenarios/test_codegen/contracts/tasks/updateGravatarNameTask.js (0 hunks)
  • scenarios/test_codegen/hardhat.config.ts (0 hunks)
  • scenarios/test_codegen/package.json (3 hunks)
  • scenarios/test_codegen/src/EventHandlers.ts (3 hunks)
  • scenarios/test_codegen/test/CustomSelection_test.ts (2 hunks)
  • scenarios/test_codegen/test/E2EEthNode_test.res (0 hunks)
  • scenarios/test_codegen/test/EventHandler_test.ts (1 hunks)
  • scenarios/test_codegen/test/helpers/LiveGravatarTask.res (0 hunks)
  • scenarios/test_codegen/test/helpers/SetupRpcNode.res (0 hunks)
  • scenarios/test_codegen/test/helpers/contracts/GravatarRegistry.sol (0 hunks)
  • scenarios/test_codegen/test/helpers/node-and-contracts.ts (0 hunks)
  • scenarios/test_codegen/test/helpers/setupNodeAndContracts.js (0 hunks)
  • scenarios/test_codegen/test/helpers/taskLiveGravatarTxs.js (0 hunks)
  • scenarios/test_codegen/test/topic-hashing-test.ts (1 hunks)
💤 Files with no reviewable changes (24)
  • scenarios/test_codegen/.mocharc.json
  • scenarios/test_codegen/test/helpers/LiveGravatarTask.res
  • scenarios/test_codegen/contracts/tasks/newGravatarTask.js
  • scenarios/test_codegen/contracts/tasks/updateGravatarImageTask.js
  • scenarios/test_codegen/contracts/deploy/deploy.js
  • scenarios/test_codegen/contracts/tasks/updateGravatarNameTask.js
  • scenarios/test_codegen/test/helpers/contracts/GravatarRegistry.sol
  • scenarios/test_codegen/contracts/artifacts/contracts/NftFactory.sol/NftFactory.json
  • scenarios/test_codegen/test/helpers/taskLiveGravatarTxs.js
  • scenarios/test_codegen/contracts/artifacts/contracts/SimpleNft.sol/SimpleNft.json
  • scenarios/test_codegen/test/helpers/node-and-contracts.ts
  • scenarios/test_codegen/test/helpers/setupNodeAndContracts.js
  • scenarios/test_codegen/contracts/README.md
  • scenarios/test_codegen/contracts/artifacts/contracts/GravatarRegistry.sol/GravatarRegistry.json
  • scenarios/test_codegen/test/E2EEthNode_test.res
  • scenarios/test_codegen/test/helpers/SetupRpcNode.res
  • scenarios/test_codegen/contracts/secretsManager.example.ts
  • scenarios/test_codegen/contracts/.gitignore
  • scenarios/test_codegen/contracts/contracts/GravatarRegistry.sol
  • scenarios/test_codegen/contracts/contracts/SimpleNft.sol
  • scenarios/test_codegen/contracts/tasks/index.js
  • scenarios/test_codegen/contracts/contracts/NftFactory.sol
  • scenarios/test_codegen/contracts/package.json
  • scenarios/test_codegen/hardhat.config.ts
✅ Files skipped from review due to trivial changes (1)
  • scenarios/test_codegen/test/EventHandler_test.ts
🚧 Files skipped from review as they are similar to previous changes (6)
  • codegenerator/cli/npm/envio/package.json
  • codegenerator/integration_tests/tests/test_indexers/dynamic_contracts/package.json
  • scenarios/fuel_test/package.json
  • scenarios/erc20_multichain_factory/package.json
  • scenarios/test_codegen/test/topic-hashing-test.ts
  • scenarios/helpers/package.json
🧰 Additional context used
📓 Path-based instructions (1)
codegenerator/cli/templates/dynamic/**/*.hbs

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

Handlebars templates must be placed in codegenerator/cli/templates/dynamic/

Files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
  • codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
🧠 Learnings (40)
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Register dynamic contracts created by factory events using contractRegister above the handler (e.g., context.addPair(event.params.pair))

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Include proper error handling for Effect API calls with try/catch and fallback values

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
  • scenarios/test_codegen/src/EventHandlers.ts
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/config.yaml : Update config.yaml to point handler field to contract-specific files instead of single EventHandlers.ts file

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Move entity creation from EventHandlers.ts to contract-specific handler files matching original subgraph organization

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
  • scenarios/test_codegen/src/EventHandlers.ts
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Reference original subgraph logic files in TODO comments when creating skeleton handlers (e.g., 'Reference: original-subgraph/src/mappings/contract.ts')

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/package.json
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/utils/**/*.ts : Implement helper functions with no entity/handler dependencies immediately during migration phase 5a

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
  • scenarios/test_codegen/src/EventHandlers.ts
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Use context.log.error() for error logging in handlers and effects instead of console.log()

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
  • scenarios/test_codegen/src/EventHandlers.ts
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Use async/await for all context.Entity.get() and context.effect() calls; context.Entity.set() does not need await

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
  • scenarios/test_codegen/src/EventHandlers.ts
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Use Effect API for all external calls (RPC calls, API calls) via context.effect() with preload_handlers: true enabled

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
  • scenarios/test_codegen/src/EventHandlers.ts
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Implement complex handlers one at a time and run quality checks after each handler completion before proceeding to next

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Create handler skeleton files with exact filenames matching the original subgraph structure during file refactoring

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Do not use !context.isPreload check logic during the main implementation phase; use it only after all handlers are complete

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
📚 Learning: 2025-11-25T12:40:19.463Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Applies to **/generated/src/Config.res : Generated config module must be named `Config.res` and convert environment variables to typed config, setting up persistence

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
📚 Learning: 2025-11-25T12:40:19.463Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Applies to **/generated/src/Index.res : Generated runtime entry module must be named `Index.res` and must start HTTP server, load `Config.res`, call `RegisterHandlers.res`, and spin up `GlobalStateManager.res`

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Systematically review each handler logic against original subgraph multiple times until logic is completely correct

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/package.json
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/EventHandlers.ts : Clear all boilerplate logic from EventHandlers.ts and replace with empty handlers containing TODO comments

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
  • scenarios/test_codegen/src/EventHandlers.ts
📚 Learning: 2025-11-25T12:40:49.622Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/EventHandlers.ts : When making external calls in handlers with preload optimisations enabled, MUST use the Effect API from 'envio' instead of direct fetch/external calls

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
  • scenarios/test_codegen/src/EventHandlers.ts
📚 Learning: 2025-11-25T12:40:49.622Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/EventHandlers.ts : Use `!context.isPreload` checks in handlers to prevent logic from running during preload when using preload optimisations

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-11-25T12:40:19.463Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Applies to **/*.{test.res,spec.res} : Use `_only` to specify which tests to run in ReScript Mocha tests

Applied to files:

  • scenarios/test_codegen/test/CustomSelection_test.ts
  • codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs
  • scenarios/erc20_multichain_factory/.mocharc.json
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • scenarios/test_codegen/package.json
📚 Learning: 2025-05-27T17:07:12.878Z
Learnt from: JonoPrest
Repo: enviodev/hyperindex PR: 555
File: scenarios/test_codegen/test/lib_tests/EntityHistory_test.res:631-659
Timestamp: 2025-05-27T17:07:12.878Z
Learning: In isolated tests for EntityHistory rollbacks with controlled mock data setup, the ordering of getRollbackDiff results is deterministic and doesn't require sorting before comparison with deepStrictEqual.

Applied to files:

  • scenarios/test_codegen/test/CustomSelection_test.ts
📚 Learning: 2025-11-25T12:40:49.622Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
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/dynamic/init_templates/shared/package.json.hbs
  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/package.json
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • codegenerator/cli/npm/envio/package.json.tmpl
📚 Learning: 2025-11-25T12:40:49.622Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/**/*.ts : Use `string | undefined` for optional string fields in TypeScript types, not `string | null`, as generated types are strict about null vs undefined

Applied to files:

  • codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Run pnpm codegen, pnpm tsc --noEmit, and TUI_OFF=true pnpm dev after every code change to catch runtime errors

Applied to files:

  • codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs
  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/package.json
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • codegenerator/cli/npm/envio/package.json.tmpl
  • scenarios/test_codegen/package.json
📚 Learning: 2025-11-25T12:40:19.463Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Verify tests pass by running `pnpm rescript` compiler and `pnpm mocha` test runner

Applied to files:

  • codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs
  • scenarios/erc20_multichain_factory/.mocharc.json
  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/package.json
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • codegenerator/cli/npm/envio/package.json.tmpl
  • scenarios/test_codegen/package.json
📚 Learning: 2025-11-25T12:40:19.463Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Applies to **/*.{test.res,spec.res} : Prefer public module APIs for testing in ReScript

Applied to files:

  • codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs
  • scenarios/erc20_multichain_factory/.mocharc.json
  • scenarios/test_codegen/src/EventHandlers.ts
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • scenarios/test_codegen/package.json
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Prefix all entity IDs with chainId in multichain indexing: ${event.chainId}-${originalId}

Applied to files:

  • scenarios/erc20_multichain_factory/.mocharc.json
📚 Learning: 2025-11-25T12:40:26.435Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/rescript.mdc:0-0
Timestamp: 2025-11-25T12:40:26.435Z
Learning: Applies to **/*.test.{res,resi} : Use try/catch as expressions instead of refs for tracking success/failure in tests

Applied to files:

  • scenarios/erc20_multichain_factory/.mocharc.json
📚 Learning: 2025-11-25T12:40:26.435Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/rescript.mdc:0-0
Timestamp: 2025-11-25T12:40:26.435Z
Learning: Applies to **/*.test.{res,resi} : Never use `Js.Console.log` in test files. Use `Assert` module for all verifications

Applied to files:

  • scenarios/erc20_multichain_factory/.mocharc.json
  • scenarios/test_codegen/src/EventHandlers.ts
📚 Learning: 2025-11-25T12:40:26.435Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/rescript.mdc:0-0
Timestamp: 2025-11-25T12:40:26.435Z
Learning: Applies to **/*.test.{res,resi} : When testing with multiple iterations, collect results in data structures and assert on them

Applied to files:

  • scenarios/erc20_multichain_factory/.mocharc.json
📚 Learning: 2025-11-25T12:40:26.435Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/rescript.mdc:0-0
Timestamp: 2025-11-25T12:40:26.435Z
Learning: Applies to **/*.test.{res,resi} : Tests should be silent unless they fail - rely on assertions rather than logging

Applied to files:

  • scenarios/erc20_multichain_factory/.mocharc.json
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Test the indexer with TUI_OFF=true pnpm dev for ~30 seconds after every code change to catch runtime errors

Applied to files:

  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/package.json
📚 Learning: 2025-11-25T12:40:49.622Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/EventHandlers.ts : When updating existing entities in TypeScript handlers, always use the spread operator since returned objects are read-only and immutable

Applied to files:

  • scenarios/test_codegen/src/EventHandlers.ts
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/effects/**/*.ts : Create Effect API functions in src/effects/ folder with proper schema definition using createEffect from 'envio'

Applied to files:

  • scenarios/test_codegen/src/EventHandlers.ts
📚 Learning: 2025-11-25T12:40:49.622Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/**/*.ts : Define Effect schemas using the `S` module from 'envio' with required properties: name, input schema, output schema, rateLimit, and cache

Applied to files:

  • scenarios/test_codegen/src/EventHandlers.ts
  • codegenerator/cli/npm/envio/package.json.tmpl
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Use batch Promise.all() for multiple Effect API calls to improve performance

Applied to files:

  • scenarios/test_codegen/src/EventHandlers.ts
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Verify that entity field types in code match exactly with GraphQL schema property types (Int!, BigInt!, BigDecimal!, String!, Bytes!, Boolean!)

Applied to files:

  • scenarios/test_codegen/src/EventHandlers.ts
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • codegenerator/cli/npm/envio/package.json.tmpl
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Import entity types from 'generated/src/db/Entities.gen' not 'generated' for type definitions

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • codegenerator/cli/npm/envio/package.json.tmpl
📚 Learning: 2025-11-25T12:40:19.463Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Applies to codegenerator/cli/templates/static/**/*.res : Static ReScript files must be placed in `codegenerator/cli/templates/static/`

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • codegenerator/cli/npm/envio/package.json.tmpl
  • scenarios/test_codegen/package.json
📚 Learning: 2025-11-25T12:40:26.435Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/rescript.mdc:0-0
Timestamp: 2025-11-25T12:40:26.435Z
Learning: Applies to **/*.{res,resi} : Always use ReScript 11 documentation

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • scenarios/test_codegen/package.json
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Ensure entity type annotations use the _t suffix (e.g., Pair_t, Token_t) when defining entity objects

Applied to files:

  • codegenerator/cli/npm/envio/package.json.tmpl
🔇 Additional comments (20)
scenarios/erc20_multichain_factory/.mocharc.json (1)

2-2: Configuration correctly aligns with ESM migration.

The glob pattern update from test/**/*.res.js to test/**/*.{ts,res.mjs} is correct and properly configured. ReScript's build configuration (rescript.json) outputs .res.mjs files, no stale .res.js files remain, and the pattern accommodates both compiled ReScript tests and TypeScript tests.

Verify the migration is complete by running pnpm rescript && pnpm mocha to ensure all tests compile and execute properly.

codegenerator/cli/templates/dynamic/codegen/package.json.hbs (2)

7-7: LGTM! Correct ESM package type declaration.

The addition of "type": "module" correctly enables ESM mode for the generated package, which is essential for the CommonJS → ESM migration.


13-16: LGTM! Proper ESM dynamic import pattern for database and benchmark scripts.

The migration to node -e 'import(...).then(m => m.function())' is the correct approach for invoking functions from ESM modules. The pattern is consistent across all four scripts.

codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/package.json (1)

4-4: ESM configuration is properly set up, but the mocha test script references non-existent test files.

The tsconfig.json is correctly configured with "module": "Node16" and "moduleResolution": "Node16" to align with "type": "module" in package.json. However, the mocha script in package.json runs test/**/*.{ts} but there are no test files or test directory in this package—only src/, config files, and schema definitions. Either remove the mocha script if this package doesn't require tests, or add actual test files if tests are intended.

⛔ Skipped due to learnings
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Verify tests pass by running `pnpm rescript` compiler and `pnpm mocha` test runner
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Applies to **/*.{test.res,spec.res} : Use `_only` to specify which tests to run in ReScript Mocha tests
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Systematically review each handler logic against original subgraph multiple times until logic is completely correct
scenarios/test_codegen/package.json (5)

4-4: ESM module type correctly declared.

The addition of "type": "module" aligns with the PR's CommonJS→ESM migration objective.


40-40: Dependency updates align with ESM migration.

The additions of ts-node@10.9.2 and sinon@^15.0.4, plus the patch bump of rescript-schema to 9.3.4, all appear compatible with the ESM migration and modern testing practices.

Also applies to: 44-44, 45-45


52-52: TypeScript version pinning to 5.9.3 is consistent across the entire repository and represents the intended dependency strategy—not an anomaly specific to this file. No action needed.


16-16: ReScript test files will not be discovered by mocha — pattern mismatch requires file renaming.

The mocha script searches for test/**/*.{ts,res.mjs}, but all 41 ReScript test files in the directory have the .res extension, not .res.mjs. The mocha command will only discover TypeScript tests (.ts files) and will silently skip all ReScript tests, resulting in incomplete test coverage. Rename all .res test files to .res.mjs to match the expected pattern.

⛔ Skipped due to learnings
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Applies to **/*.{test.res,spec.res} : Use `_only` to specify which tests to run in ReScript Mocha tests
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Applies to **/*.{test.res,spec.res} : Prefer public module APIs for testing in ReScript
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Verify tests pass by running `pnpm rescript` compiler and `pnpm mocha` test runner
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Applies to codegenerator/cli/templates/static/**/*.res : Static ReScript files must be placed in `codegenerator/cli/templates/static/`
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/rescript.mdc:0-0
Timestamp: 2025-11-25T12:40:26.435Z
Learning: Applies to **/*.{res,resi} : Always use ReScript 11 documentation
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/rescript.mdc:0-0
Timestamp: 2025-11-25T12:40:26.435Z
Learning: Applies to **/*.test.{res,resi} : Use try/catch as expressions instead of refs for tracking success/failure in tests
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/rescript.mdc:0-0
Timestamp: 2025-11-25T12:40:26.435Z
Learning: Applies to **/*.test.{res,resi} : Never use `Js.Console.log` in test files. Use `Assert` module for all verifications
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/rescript.mdc:0-0
Timestamp: 2025-11-25T12:40:26.435Z
Learning: Applies to **/*.{res,resi} : Never suggest ReasonML syntax
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Run pnpm codegen, pnpm tsc --noEmit, and TUI_OFF=true pnpm dev after every code change to catch runtime errors

24-24: envio start is the appropriate command for this test scenario.

The change from ts-node ./generated/src/Index.res.js to envio start correctly uses the envio CLI to start the indexer. The config.yaml is properly configured for envio, and this pattern is consistently applied across other test scenarios in the codebase.

scenarios/test_codegen/src/EventHandlers.ts (2)

2-8: LGTM! Type-only imports correctly applied.

The migration to type-only imports for Effect, Logger, EffectCaller, NftCollection, User, eventLog, NftFactory_SimpleNftCreated_eventArgs, NftFactory_SimpleNftCreated_event, and TypeEqual is correct. These identifiers are only used in type positions throughout the file, which makes this change appropriate for the ESM migration.

Also applies to: 17-21, 24-24


310-310: Non-null assertion is justified here.

TestHelpers.Addresses.mockAddresses is a statically initialized array with 20 hardcoded addresses defined in codegenerator/cli/npm/envio/src/bindings/Ethers.res. Array access to [0] is guaranteed to succeed at runtime, making the non-null assertion safe and appropriate.

codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs (5)

9-22: LGTM! Async conversion for ESM imports is correct.

The function has been properly converted to async to support dynamic ESM imports via Utils.importPath. The error handling is appropriate and provides clear context including contract name and handler path.


27-27: Typo fixed as requested.

The comment now correctly reads "Relative to cwd (project root)" - the previous typo has been addressed.


41-53: LGTM! Async auto-loading with proper error handling.

The conversion to asynchronous imports is well-implemented:

  • Each handler file is imported in parallel using Promise.all
  • Per-file error handling provides clear context about which file failed to load
  • Fail-fast behavior ensures that if any handler fails to load, the entire operation fails
  • Comments clearly explain the relative path logic

28-28: .mjs inclusion in handler glob pattern is necessary for ESM support.

ReScript is configured to output ESM modules with .res.mjs suffix (see rescript.json configurations throughout the templates and scenarios). The generated .mjs files are actively imported in package.json scripts and referenced in configuration files. Adding .mjs to the glob pattern ensures the handler auto-loader can discover both .js and .mjs files, which is essential for the ESM-based handler loading mechanism.


141-148: Good change to parallel handler registration.

Using Promise.all ensures all contract handlers are fully registered before proceeding to EventRegister.finishRegistration(). This improves performance through parallel loading, which is safe since each contract handler registration is independent—each registerContractHandlers call only imports a single handler file with no cross-contract dependencies or side effects.

codegenerator/cli/npm/envio/package.json.tmpl (1)

4-4: Good addition of ESM package type.

The addition of "type": "module" correctly marks this package as ESM, aligning with the PR's CommonJS to ESM migration. Both entry point files (bin.js and index.js) are using ESM syntax (import/export statements), and all src files are in ESM format (.mjs). The rescript-schema dependency version 9.3.4 exists and is available.

codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs (3)

4-4: LGTM! ESM enablement is correct.

Adding "type": "module" is the standard approach to enable ESM for this package.


20-20: LGTM! Test script structure is correct.

The conditional build step for ReScript projects followed by mocha execution is consistent with the dev and start scripts.


31-31: Correct TypeScript version to 5.9.2.

TypeScript version 5.9.3 does not exist; the latest stable release is v5.9.2 (July 31, 2025). Update line 31 to "typescript": "5.9.2".

While the upgrade from 5.2.2 includes breaking changes across lib.d.ts updates, type checking strictness, and module resolution, these are typical for such a version jump and should be manageable for generated templates. However, the immediate issue is the non-existent version reference.

⛔ Skipped due to learnings
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.ts : After any change to TypeScript files, run `pnpm tsc --noEmit` to ensure successful compilation
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Systematically review each handler logic against original subgraph multiple times until logic is completely correct
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/**/*.ts : Use `string | undefined` for optional string fields in TypeScript types, not `string | null`, as generated types are strict about null vs undefined
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Verify that entity field types in code match exactly with GraphQL schema property types (Int!, BigInt!, BigDecimal!, String!, Bytes!, Boolean!)
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Reference original subgraph logic files in TODO comments when creating skeleton handlers (e.g., 'Reference: original-subgraph/src/mappings/contract.ts')

Comment thread codegenerator/cli/npm/envio/package.json.tmpl
Comment thread codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs Outdated
Comment thread codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs Outdated
Comment thread scenarios/test_codegen/test/CustomSelection_test.ts Outdated

@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)
scenarios/test_codegen/src/handlers/EventHandlers.ts (1)

137-137: Consider using context.log for consistent observability.

While these debug logs work, using context.log.info() or context.log.debug() would provide better observability and align with the framework's logging patterns.

Apply this diff:

-  console.log("AAAA", event.transaction.hash);
+  context.log.info("AAAA", event.transaction.hash);
-  console.log("event.transaction.hash", event.transaction.hash);
+  context.log.info("event.transaction.hash", event.transaction.hash);

Based on learnings, handlers should use the context logger for all logging to maintain consistent observability patterns.

Also applies to: 196-196

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b8cfcd2 and b740b9d.

📒 Files selected for processing (5)
  • codegenerator/cli/npm/envio/src/EventRegister.res (1 hunks)
  • codegenerator/cli/npm/envio/src/EventRegister.resi (1 hunks)
  • codegenerator/cli/templates/dynamic/codegen/src/TestHelpers_MockDb.res.hbs (2 hunks)
  • scenarios/test_codegen/config.yaml (0 hunks)
  • scenarios/test_codegen/src/handlers/EventHandlers.ts (5 hunks)
💤 Files with no reviewable changes (1)
  • scenarios/test_codegen/config.yaml
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{res,resi}

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

**/*.{res,resi}: Always use ReScript 11 documentation
Never suggest ReasonML syntax
Never use [| item |] to create an array. Use [ item ] instead
Must always use = for setting value to a field. Use := only for ref values created using ref function
Use records when working with structured data, and objects to conveniently pass payload data between functions
Never use %raw to access object fields if you know the type

Files:

  • codegenerator/cli/npm/envio/src/EventRegister.res
  • codegenerator/cli/npm/envio/src/EventRegister.resi
codegenerator/cli/templates/dynamic/**/*.hbs

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

Handlebars templates must be placed in codegenerator/cli/templates/dynamic/

Files:

  • codegenerator/cli/templates/dynamic/codegen/src/TestHelpers_MockDb.res.hbs
🧠 Learnings (20)
📓 Common learnings
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Applies to **/*.{test.res,spec.res} : Prefer public module APIs for testing in ReScript
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Verify tests pass by running `pnpm rescript` compiler and `pnpm mocha` test runner
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/utils/**/*.ts : Implement helper functions with no entity/handler dependencies immediately during migration phase 5a
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Move entity creation from EventHandlers.ts to contract-specific handler files matching original subgraph organization
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Move entity creation from EventHandlers.ts to contract-specific handler files matching original subgraph organization

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/TestHelpers_MockDb.res.hbs
  • scenarios/test_codegen/src/handlers/EventHandlers.ts
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/EventHandlers.ts : Clear all boilerplate logic from EventHandlers.ts and replace with empty handlers containing TODO comments

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/TestHelpers_MockDb.res.hbs
  • scenarios/test_codegen/src/handlers/EventHandlers.ts
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Register dynamic contracts created by factory events using contractRegister above the handler (e.g., context.addPair(event.params.pair))

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/TestHelpers_MockDb.res.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/config.yaml : Update config.yaml to point handler field to contract-specific files instead of single EventHandlers.ts file

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/TestHelpers_MockDb.res.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/utils/**/*.ts : Implement helper functions with no entity/handler dependencies immediately during migration phase 5a

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/TestHelpers_MockDb.res.hbs
📚 Learning: 2025-11-25T12:40:49.622Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/EventHandlers.ts : When updating existing entities in TypeScript handlers, always use the spread operator since returned objects are read-only and immutable

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/TestHelpers_MockDb.res.hbs
  • scenarios/test_codegen/src/handlers/EventHandlers.ts
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Systematically review each handler logic against original subgraph multiple times until logic is completely correct

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/TestHelpers_MockDb.res.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Reference original subgraph logic files in TODO comments when creating skeleton handlers (e.g., 'Reference: original-subgraph/src/mappings/contract.ts')

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/TestHelpers_MockDb.res.hbs
📚 Learning: 2025-11-25T12:40:49.622Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/EventHandlers.ts : When making external calls in handlers with preload optimisations enabled, MUST use the Effect API from 'envio' instead of direct fetch/external calls

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/TestHelpers_MockDb.res.hbs
  • scenarios/test_codegen/src/handlers/EventHandlers.ts
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/effects/**/*.ts : Create Effect API functions in src/effects/ folder with proper schema definition using createEffect from 'envio'

Applied to files:

  • scenarios/test_codegen/src/handlers/EventHandlers.ts
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Include proper error handling for Effect API calls with try/catch and fallback values

Applied to files:

  • scenarios/test_codegen/src/handlers/EventHandlers.ts
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Use Effect API for all external calls (RPC calls, API calls) via context.effect() with preload_handlers: true enabled

Applied to files:

  • scenarios/test_codegen/src/handlers/EventHandlers.ts
📚 Learning: 2025-11-25T12:40:49.622Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/**/*.ts : Define Effect schemas using the `S` module from 'envio' with required properties: name, input schema, output schema, rateLimit, and cache

Applied to files:

  • scenarios/test_codegen/src/handlers/EventHandlers.ts
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Use batch Promise.all() for multiple Effect API calls to improve performance

Applied to files:

  • scenarios/test_codegen/src/handlers/EventHandlers.ts
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Use async/await for all context.Entity.get() and context.effect() calls; context.Entity.set() does not need await

Applied to files:

  • scenarios/test_codegen/src/handlers/EventHandlers.ts
📚 Learning: 2025-11-25T12:40:26.435Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/rescript.mdc:0-0
Timestamp: 2025-11-25T12:40:26.435Z
Learning: Applies to **/*.test.{res,resi} : Never use `Js.Console.log` in test files. Use `Assert` module for all verifications

Applied to files:

  • scenarios/test_codegen/src/handlers/EventHandlers.ts
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Use context.log.error() for error logging in handlers and effects instead of console.log()

Applied to files:

  • scenarios/test_codegen/src/handlers/EventHandlers.ts
📚 Learning: 2025-11-25T12:40:19.463Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Applies to **/*.{test.res,spec.res} : Prefer public module APIs for testing in ReScript

Applied to files:

  • scenarios/test_codegen/src/handlers/EventHandlers.ts
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Verify that entity field types in code match exactly with GraphQL schema property types (Int!, BigInt!, BigDecimal!, String!, Bytes!, Boolean!)

Applied to files:

  • scenarios/test_codegen/src/handlers/EventHandlers.ts
🔇 Additional comments (8)
scenarios/test_codegen/src/handlers/EventHandlers.ts (3)

2-8: LGTM! Type-only imports correctly applied for ESM migration.

The conversion of Effect, Logger, and EffectCaller to type-only imports is correct. These types are used exclusively in type annotations throughout the file and will be properly erased at runtime in ESM.


17-21: LGTM! Entity and event types correctly converted to type-only imports.

The distinction between type-only imports (NftCollection, User, eventLog, event types) and value imports (BigDecimal, onBlock) is correctly applied. All type-only imports are used exclusively in type annotations.


24-24: LGTM! TypeEqual correctly imported as type-only.

Proper separation between the type (TypeEqual) and the runtime function (expectType).

codegenerator/cli/npm/envio/src/EventRegister.resi (1)

11-11: LGTM: Clean API extension.

The new isPendingRegistration signature is well-placed and provides a useful query method for checking registration state.

codegenerator/cli/npm/envio/src/EventRegister.res (1)

71-76: LGTM: Correct implementation.

The function properly checks the activeRegistration ref and returns whether there's an unfinished registration in progress. The logic handles both Some and None cases correctly.

codegenerator/cli/templates/dynamic/codegen/src/TestHelpers_MockDb.res.hbs (3)

321-325: LGTM: Flexible registration flow for test scenarios.

The conditional logic appropriately handles cases where handlers may have already started registration (via preRegistered array) versus cases where registration hasn't begun. The mixed sync/async branches should compile correctly in ReScript's async context.


338-338: LGTM: Improved clarity.

Explicit type annotation makes the code more readable and provides better IDE support.


346-349: LGTM: Good defensive check.

The runtime validation ensures that events have either a handler or contract register before processing, preventing silent failures. The error message clearly identifies the problematic event configuration.

@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: 2

♻️ Duplicate comments (2)
codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs (1)

20-22: Typo fix confirmed.

The spelling correction from "Relatvie" to "Relative" has been addressed.

codegenerator/cli/templates/dynamic/codegen/package.json.hbs (1)

38-50: Major dependency version bumps require coordinated verification.

This has been flagged in a previous review. The React 19, @rescript/react 0.14.0, and ink 6.x upgrades are interdependent and require:

  1. JSX v4 migration for ReScript
  2. Uncurried bindings
  3. Updated Ink component APIs

Ensure the generated code and TUI components are tested with these versions.

🧹 Nitpick comments (3)
codegenerator/cli/npm/envio/src/bindings/Ethers.res.d.mts (1)

1-5: Shim looks fine; consider making the cleanup more trackable

The minimal Addresses: any shim is a reasonable way to unblock tsc --noEmit with ESM/genType in the interim, and the ESM-style export is correct for a .d.mts file.

You might make the future removal easier to track by turning the comment into an explicit TODO (e.g., // TODO: remove after GenType includes @ts-ignore for this import) or referencing an issue. Optionally, once the underlying ReScript/JS shape is stable, tightening the type away from any would restore type-safety for consumers.

codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs (1)

27-35: Consider moving tsx into the TypeScript conditional block.

tsx is placed unconditionally (line 34), but it's primarily needed for TypeScript test file execution. For pure ReScript projects that only have .res.mjs test files, tsx may be unnecessary overhead.

However, if the design intent is that all projects may have TypeScript test files regardless of the main language choice, this placement is acceptable.

codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/package.json (1)

9-9: Minor: Simplify redundant glob pattern brace expansion.

The glob pattern test/**/*.{ts} uses brace expansion {ts} which expands to just .ts—equivalent to test/**/*.ts. While functionally correct, simplifying to test/**/*.ts improves clarity.

-    "mocha": "tsc --noEmit && NODE_OPTIONS='--no-warnings --import tsx' mocha test/**/*.{ts}",
+    "mocha": "tsc --noEmit && NODE_OPTIONS='--no-warnings --import tsx' mocha test/**/*.ts",
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b740b9d and 367dc5b.

⛔ Files ignored due to path filters (3)
  • scenarios/erc20_multichain_factory/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • scenarios/fuel_test/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • scenarios/test_codegen/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (15)
  • codegenerator/cli/npm/envio/src/bindings/Ethers.res.d.mts (1 hunks)
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs (2 hunks)
  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs (3 hunks)
  • codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs (2 hunks)
  • codegenerator/integration_tests/tests/test_indexers/dynamic_contracts/package.json (2 hunks)
  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/package.json (1 hunks)
  • scenarios/erc20_multichain_factory/package.json (1 hunks)
  • scenarios/fuel_test/contracts/ts-interaction-tools/package.json (1 hunks)
  • scenarios/fuel_test/package.json (2 hunks)
  • scenarios/fuel_test/src/AllEventsHandlers.ts (1 hunks)
  • scenarios/fuel_test/src/GreeterHandlers.ts (1 hunks)
  • scenarios/fuel_test/test/test.ts (1 hunks)
  • scenarios/fuel_test/tsconfig.json (1 hunks)
  • scenarios/test_codegen/package.json (3 hunks)
  • scenarios/test_codegen/test/Utils_test.res (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • scenarios/fuel_test/contracts/ts-interaction-tools/package.json
  • scenarios/fuel_test/tsconfig.json
  • scenarios/erc20_multichain_factory/package.json
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{res,resi}

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

**/*.{res,resi}: Always use ReScript 11 documentation
Never suggest ReasonML syntax
Never use [| item |] to create an array. Use [ item ] instead
Must always use = for setting value to a field. Use := only for ref values created using ref function
Use records when working with structured data, and objects to conveniently pass payload data between functions
Never use %raw to access object fields if you know the type

Files:

  • scenarios/test_codegen/test/Utils_test.res
codegenerator/cli/templates/dynamic/**/*.hbs

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

Handlebars templates must be placed in codegenerator/cli/templates/dynamic/

Files:

  • codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs
  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
🧠 Learnings (36)
📓 Common learnings
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/utils/**/*.ts : Implement helper functions with no entity/handler dependencies immediately during migration phase 5a
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Move entity creation from EventHandlers.ts to contract-specific handler files matching original subgraph organization
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Create handler skeleton files with exact filenames matching the original subgraph structure during file refactoring
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Applies to **/*.{test.res,spec.res} : Prefer public module APIs for testing in ReScript
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Ensure entity type annotations use the _t suffix (e.g., Pair_t, Token_t) when defining entity objects

Applied to files:

  • codegenerator/cli/npm/envio/src/bindings/Ethers.res.d.mts
  • scenarios/fuel_test/src/AllEventsHandlers.ts
  • codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs
  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/package.json
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Reference original subgraph logic files in TODO comments when creating skeleton handlers (e.g., 'Reference: original-subgraph/src/mappings/contract.ts')

Applied to files:

  • codegenerator/cli/npm/envio/src/bindings/Ethers.res.d.mts
  • codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs
  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/package.json
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Import entity types from 'generated/src/db/Entities.gen' not 'generated' for type definitions

Applied to files:

  • codegenerator/cli/npm/envio/src/bindings/Ethers.res.d.mts
  • scenarios/fuel_test/src/AllEventsHandlers.ts
  • codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs
  • scenarios/fuel_test/test/test.ts
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
📚 Learning: 2025-11-25T12:40:49.622Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/EventHandlers.ts : When updating existing entities in TypeScript handlers, always use the spread operator since returned objects are read-only and immutable

Applied to files:

  • scenarios/fuel_test/src/AllEventsHandlers.ts
  • scenarios/fuel_test/src/GreeterHandlers.ts
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Move entity creation from EventHandlers.ts to contract-specific handler files matching original subgraph organization

Applied to files:

  • scenarios/fuel_test/src/AllEventsHandlers.ts
  • scenarios/fuel_test/src/GreeterHandlers.ts
  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/EventHandlers.ts : Clear all boilerplate logic from EventHandlers.ts and replace with empty handlers containing TODO comments

Applied to files:

  • scenarios/fuel_test/src/AllEventsHandlers.ts
  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/utils/**/*.ts : Implement helper functions with no entity/handler dependencies immediately during migration phase 5a

Applied to files:

  • scenarios/fuel_test/src/AllEventsHandlers.ts
  • scenarios/fuel_test/src/GreeterHandlers.ts
  • scenarios/fuel_test/test/test.ts
  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-11-25T12:40:49.622Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/**/*.ts : Define Effect schemas using the `S` module from 'envio' with required properties: name, input schema, output schema, rateLimit, and cache

Applied to files:

  • scenarios/fuel_test/src/AllEventsHandlers.ts
  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/package.json
📚 Learning: 2025-11-25T12:40:49.622Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
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/dynamic/init_templates/shared/package.json.hbs
  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/package.json
  • codegenerator/integration_tests/tests/test_indexers/dynamic_contracts/package.json
  • scenarios/fuel_test/package.json
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
📚 Learning: 2025-11-25T12:40:49.622Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/**/*.ts : Use `string | undefined` for optional string fields in TypeScript types, not `string | null`, as generated types are strict about null vs undefined

Applied to files:

  • codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Run pnpm codegen, pnpm tsc --noEmit, and TUI_OFF=true pnpm dev after every code change to catch runtime errors

Applied to files:

  • codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs
  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/package.json
  • codegenerator/integration_tests/tests/test_indexers/dynamic_contracts/package.json
  • scenarios/fuel_test/package.json
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • scenarios/test_codegen/package.json
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Create handler skeleton files with exact filenames matching the original subgraph structure during file refactoring

Applied to files:

  • codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs
  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Verify that entity field types in code match exactly with GraphQL schema property types (Int!, BigInt!, BigDecimal!, String!, Bytes!, Boolean!)

Applied to files:

  • codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs
  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/package.json
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
📚 Learning: 2025-11-25T12:40:49.622Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
Learning: Use Node.js v20 only (no higher or lower versions)

Applied to files:

  • codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Use Node.js v20 only; do not use higher or lower versions for development environment

Applied to files:

  • codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs
📚 Learning: 2025-11-25T12:40:19.463Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Applies to **/*.{test.res,spec.res} : Use `_only` to specify which tests to run in ReScript Mocha tests

Applied to files:

  • codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs
  • scenarios/fuel_test/package.json
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • scenarios/test_codegen/package.json
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Systematically review each handler logic against original subgraph multiple times until logic is completely correct

Applied to files:

  • codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs
  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/package.json
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
📚 Learning: 2025-11-25T12:40:19.463Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Applies to codegenerator/cli/templates/static/**/*.res : Static ReScript files must be placed in `codegenerator/cli/templates/static/`

Applied to files:

  • codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs
  • scenarios/fuel_test/package.json
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • scenarios/test_codegen/package.json
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Implement complex handlers one at a time and run quality checks after each handler completion before proceeding to next

Applied to files:

  • codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs
  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Do not use !context.isPreload check logic during the main implementation phase; use it only after all handlers are complete

Applied to files:

  • codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs
  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
📚 Learning: 2025-11-25T12:40:19.463Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Verify tests pass by running `pnpm rescript` compiler and `pnpm mocha` test runner

Applied to files:

  • codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs
  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/package.json
  • scenarios/fuel_test/package.json
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • scenarios/test_codegen/package.json
📚 Learning: 2025-11-25T12:40:19.463Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Applies to **/*.{test.res,spec.res} : Prefer public module APIs for testing in ReScript

Applied to files:

  • codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs
  • scenarios/fuel_test/package.json
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • scenarios/test_codegen/package.json
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Register dynamic contracts created by factory events using contractRegister above the handler (e.g., context.addPair(event.params.pair))

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Use async/await for all context.Entity.get() and context.effect() calls; context.Entity.set() does not need await

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/config.yaml : Update config.yaml to point handler field to contract-specific files instead of single EventHandlers.ts file

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Use Effect API for all external calls (RPC calls, API calls) via context.effect() with preload_handlers: true enabled

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Use context.log.error() for error logging in handlers and effects instead of console.log()

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-11-25T12:40:19.463Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Applies to **/generated/src/Index.res : Generated runtime entry module must be named `Index.res` and must start HTTP server, load `Config.res`, call `RegisterHandlers.res`, and spin up `GlobalStateManager.res`

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
📚 Learning: 2025-11-25T12:40:19.463Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Applies to **/generated/src/Config.res : Generated config module must be named `Config.res` and convert environment variables to typed config, setting up persistence

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
📚 Learning: 2025-11-25T12:40:49.622Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/EventHandlers.ts : When making external calls in handlers with preload optimisations enabled, MUST use the Effect API from 'envio' instead of direct fetch/external calls

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-11-25T12:40:49.622Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/EventHandlers.ts : Use `!context.isPreload` checks in handlers to prevent logic from running during preload when using preload optimisations

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Test the indexer with TUI_OFF=true pnpm dev for ~30 seconds after every code change to catch runtime errors

Applied to files:

  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/package.json
📚 Learning: 2025-11-25T12:40:26.435Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/rescript.mdc:0-0
Timestamp: 2025-11-25T12:40:26.435Z
Learning: Applies to **/*.{res,resi} : Always use ReScript 11 documentation

Applied to files:

  • scenarios/fuel_test/package.json
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • scenarios/test_codegen/package.json
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Whitelist and use the commands: pnpm codegen, pnpm tsc --noEmit, TUI_OFF=true pnpm dev during development

Applied to files:

  • scenarios/fuel_test/package.json
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Use entity field names with _id suffix for entity relationships (e.g., token0_id, token1_id) matching generated schema

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
🔇 Additional comments (16)
scenarios/test_codegen/test/Utils_test.res (1)

133-135: Function hash expectation string looks correct

The updated expectation from a function () {}‑style representation to function() {} matches the new literal used in %raw and keeps the test aligned with the current Utils.Hash.makeOrThrow behavior while still going through the public Utils.Hash API in tests, which is consistent with prior learnings.

scenarios/fuel_test/src/AllEventsHandlers.ts (1)

6-6: LGTM! Correct type-only import.

The TypeEqual import is correctly marked as type-only since it's exclusively used in type positions (the AssertSchemaType type alias and expectType calls). This optimization is consistent with ESM migration best practices and helps with tree-shaking.

scenarios/fuel_test/test/test.ts (1)

2-2: LGTM! Correct type-only import.

The User import is correctly marked as type-only since it's only used as a type annotation at line 27. This aligns with the ESM migration and follows TypeScript best practices.

scenarios/fuel_test/src/GreeterHandlers.ts (1)

1-1: LGTM! Correct type-only import.

The User import is correctly marked as type-only since it's exclusively used as a type annotation at line 20. This change properly supports the ESM migration while maintaining type safety.

codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs (3)

2-16: LGTM!

The async handler registration pattern is well-structured. The error handling correctly logs the exception with context before re-throwing, which aids debugging.


38-48: Async loading pattern looks correct.

The Promise.all with per-file error handling provides good error context while maintaining fail-fast behavior. When any handler fails to load, the entire operation will fail with a descriptive error message.


136-143: Good use of parallel handler registration.

Collecting all handler registrations and awaiting them with Promise.all is more efficient than sequential registration. The handlers are independent, making parallel execution safe.

codegenerator/integration_tests/tests/test_indexers/dynamic_contracts/package.json (2)

4-13: ESM migration changes look good.

The addition of "type": "module", tsx-based test execution with --import tsx, and the new start script align well with the broader CommonJS-to-ESM migration. The approach of using tsc --noEmit before mocha ensures type-checking without emitting files.


19-20: > Likely an incorrect or invalid review comment.

scenarios/fuel_test/package.json (1)

4-17: ESM migration changes are consistent.

The updates to "type": "module", the mocha script using tsx, and the simplified "start": "envio start" align with the broader migration pattern. The mocha script correctly includes both .ts and .res.mjs test file patterns for this ReScript-enabled scenario.

codegenerator/cli/templates/dynamic/codegen/package.json.hbs (1)

13-16: Dynamic import scripts are well-structured.

The ESM dynamic import pattern import("./path.res.mjs").then(m => m.fn()) is the correct approach for invoking compiled ReScript modules in an ESM context without needing additional loaders.

scenarios/test_codegen/package.json (4)

4-4: ESM migration marker added correctly.

The "type": "module" declaration correctly marks the package as ESM-first, enabling all .js and .ts files to be treated as ES modules by default.


16-16: mocha script updated for ESM TypeScript support.

The mocha invocation now uses NODE_OPTIONS='--no-warnings --import tsx' to load tsx as an ESM loader, which transpiles TypeScript on-the-fly. The test file pattern includes .res.mjs, indicating ReScript compilation targets ESM. This setup is appropriate for the migration.


24-24: Verify the "start" script change.

The start script has been updated to "envio start". Confirm this command:

  • Correctly replaces the previous hardhat-based test setup (Hardhat packages removed per PR summary).
  • Works as expected in the test scenario context.
  • envio at line 55 is available and configured properly.

40-40: All dependency versions are valid and compatible—no action required.

The packages verified successfully. TypeScript 5.9.3 is a patch release (not a major jump) specifically designed to address ESM/interop compatibility. tsx 4.21.0 works with Mocha + ESM via import loader setup (documented approach). sinon 15.0.4 has no ESM-related breaking changes. rescript-schema 9.3.4 appears to be a patch update with no identified breaking changes.

codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/package.json (1)

4-4: The mocha script glob pattern test/**/*.{ts} will match zero test files in this template.

This is a template indexer directory with no test/ folder. The mocha script should either be removed if this indexer template doesn't require tests, or test files should be added to a test/ directory. As currently configured, pnpm test will execute mocha with no test files to run.

⛔ Skipped due to learnings
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.ts : After any change to TypeScript files, run `pnpm tsc --noEmit` to ensure successful compilation
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Verify tests pass by running `pnpm rescript` compiler and `pnpm mocha` test runner
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Run pnpm codegen, pnpm tsc --noEmit, and TUI_OFF=true pnpm dev after every code change to catch runtime errors
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Test the indexer with TUI_OFF=true pnpm dev for ~30 seconds after every code change to catch runtime errors
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Systematically review each handler logic against original subgraph multiple times until logic is completely correct
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Verify that entity field types in code match exactly with GraphQL schema property types (Int!, BigInt!, BigDecimal!, String!, Bytes!, Boolean!)
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Applies to **/*.{test.res,spec.res} : Use `_only` to specify which tests to run in ReScript Mocha tests

Comment thread codegenerator/cli/templates/dynamic/codegen/package.json.hbs Outdated
Comment thread codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs Outdated
@DZakh DZakh changed the title CommonJs -> ESM WIP CommonJs -> ESM Dec 2, 2025
@DZakh DZakh requested a review from JonoPrest December 2, 2025 10:00

@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: 2

♻️ Duplicate comments (1)
codegenerator/cli/templates/dynamic/codegen/package.json.hbs (1)

37-53: Major dependency version bumps noted—prior review concerns still apply.

A previous review comment thoroughly documented the breaking changes in these major version bumps (React 19.2.0, @rescript/react 0.14.0, Ink 6.5.1, etc.) and requested compatibility verification. Those concerns remain valid for this WIP PR. Ensure:

  • ReScript 11 + JSX v4 + uncurried bindings are tested
  • React 19 breaking changes (JSX transform, ReactDOM APIs) are verified
  • Ink TUI components work with the new versions

Based on learnings, run pnpm rescript and pnpm mocha to verify tests pass after these updates.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a539d6e and 8b91ce6.

⛔ Files ignored due to path filters (3)
  • scenarios/erc20_multichain_factory/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • scenarios/fuel_test/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • scenarios/test_codegen/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (12)
  • codegenerator/cli/npm/envio/package.json (2 hunks)
  • codegenerator/cli/npm/envio/package.json.tmpl (3 hunks)
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs (2 hunks)
  • codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs (3 hunks)
  • codegenerator/cli/templates/static/erc20_template/typescript/test/test.ts (2 hunks)
  • codegenerator/integration_tests/tests/test_indexers/dynamic_contracts/package.json (2 hunks)
  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/package.json (1 hunks)
  • scenarios/erc20_multichain_factory/.mocharc.json (0 hunks)
  • scenarios/erc20_multichain_factory/package.json (1 hunks)
  • scenarios/fuel_test/package.json (2 hunks)
  • scenarios/helpers/package.json (2 hunks)
  • scenarios/test_codegen/package.json (4 hunks)
💤 Files with no reviewable changes (1)
  • scenarios/erc20_multichain_factory/.mocharc.json
🚧 Files skipped from review as they are similar to previous changes (6)
  • scenarios/helpers/package.json
  • scenarios/fuel_test/package.json
  • codegenerator/integration_tests/tests/test_indexers/dynamic_contracts/package.json
  • codegenerator/cli/npm/envio/package.json
  • codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs
  • codegenerator/cli/npm/envio/package.json.tmpl
🧰 Additional context used
📓 Path-based instructions (1)
codegenerator/cli/templates/dynamic/**/*.hbs

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

Handlebars templates must be placed in codegenerator/cli/templates/dynamic/

Files:

  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
🧠 Learnings (26)
📓 Common learnings
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Move entity creation from EventHandlers.ts to contract-specific handler files matching original subgraph organization
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/utils/**/*.ts : Implement helper functions with no entity/handler dependencies immediately during migration phase 5a
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/config.yaml : Update config.yaml to point handler field to contract-specific files instead of single EventHandlers.ts file
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Import entity types from 'generated/src/db/Entities.gen' not 'generated' for type definitions

Applied to files:

  • codegenerator/cli/templates/static/erc20_template/typescript/test/test.ts
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Move entity creation from EventHandlers.ts to contract-specific handler files matching original subgraph organization

Applied to files:

  • codegenerator/cli/templates/static/erc20_template/typescript/test/test.ts
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/utils/**/*.ts : Implement helper functions with no entity/handler dependencies immediately during migration phase 5a

Applied to files:

  • codegenerator/cli/templates/static/erc20_template/typescript/test/test.ts
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Ensure entity type annotations use the _t suffix (e.g., Pair_t, Token_t) when defining entity objects

Applied to files:

  • codegenerator/cli/templates/static/erc20_template/typescript/test/test.ts
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Reference original subgraph logic files in TODO comments when creating skeleton handlers (e.g., 'Reference: original-subgraph/src/mappings/contract.ts')

Applied to files:

  • codegenerator/cli/templates/static/erc20_template/typescript/test/test.ts
  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/package.json
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Systematically review each handler logic against original subgraph multiple times until logic is completely correct

Applied to files:

  • codegenerator/cli/templates/static/erc20_template/typescript/test/test.ts
  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/package.json
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Verify that entity field types in code match exactly with GraphQL schema property types (Int!, BigInt!, BigDecimal!, String!, Bytes!, Boolean!)

Applied to files:

  • codegenerator/cli/templates/static/erc20_template/typescript/test/test.ts
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Create handler skeleton files with exact filenames matching the original subgraph structure during file refactoring

Applied to files:

  • codegenerator/cli/templates/static/erc20_template/typescript/test/test.ts
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
📚 Learning: 2025-11-25T12:40:49.622Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/**/*.ts : Use `string | undefined` for optional string fields in TypeScript types, not `string | null`, as generated types are strict about null vs undefined

Applied to files:

  • codegenerator/cli/templates/static/erc20_template/typescript/test/test.ts
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Use entity field names with _id suffix for entity relationships (e.g., token0_id, token1_id) matching generated schema

Applied to files:

  • codegenerator/cli/templates/static/erc20_template/typescript/test/test.ts
📚 Learning: 2025-11-25T12:40:26.435Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/rescript.mdc:0-0
Timestamp: 2025-11-25T12:40:26.435Z
Learning: Applies to **/*.test.{res,resi} : Never use `Js.Console.log` in test files. Use `Assert` module for all verifications

Applied to files:

  • codegenerator/cli/templates/static/erc20_template/typescript/test/test.ts
📚 Learning: 2025-11-25T12:40:19.463Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Verify tests pass by running `pnpm rescript` compiler and `pnpm mocha` test runner

Applied to files:

  • scenarios/erc20_multichain_factory/package.json
  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/package.json
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • scenarios/test_codegen/package.json
📚 Learning: 2025-11-25T12:40:19.463Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Applies to **/*.{test.res,spec.res} : Prefer public module APIs for testing in ReScript

Applied to files:

  • scenarios/erc20_multichain_factory/package.json
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • scenarios/test_codegen/package.json
📚 Learning: 2025-11-25T12:40:49.622Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
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/integration_tests/tests/test_indexers/wildcard-uni-factory/package.json
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Run pnpm codegen, pnpm tsc --noEmit, and TUI_OFF=true pnpm dev after every code change to catch runtime errors

Applied to files:

  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/package.json
  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • scenarios/test_codegen/package.json
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Test the indexer with TUI_OFF=true pnpm dev for ~30 seconds after every code change to catch runtime errors

Applied to files:

  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/package.json
📚 Learning: 2025-11-25T12:40:49.622Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/**/*.ts : Define Effect schemas using the `S` module from 'envio' with required properties: name, input schema, output schema, rateLimit, and cache

Applied to files:

  • codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/package.json
📚 Learning: 2025-11-25T12:40:19.463Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Applies to **/generated/src/Index.res : Generated runtime entry module must be named `Index.res` and must start HTTP server, load `Config.res`, call `RegisterHandlers.res`, and spin up `GlobalStateManager.res`

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
📚 Learning: 2025-11-25T12:40:19.463Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Applies to codegenerator/cli/templates/static/**/*.res : Static ReScript files must be placed in `codegenerator/cli/templates/static/`

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • scenarios/test_codegen/package.json
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Applies to codegenerator/cli/templates/static/shared/src/**/*.ts : Do not use !context.isPreload check logic during the main implementation phase; use it only after all handlers are complete

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
📚 Learning: 2025-11-25T12:40:26.435Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/rescript.mdc:0-0
Timestamp: 2025-11-25T12:40:26.435Z
Learning: Applies to **/*.{res,resi} : Always use ReScript 11 documentation

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • scenarios/test_codegen/package.json
📚 Learning: 2025-11-25T12:40:19.463Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Applies to **/generated/src/Config.res : Generated config module must be named `Config.res` and convert environment variables to typed config, setting up persistence

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
📚 Learning: 2025-11-25T12:40:19.463Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Applies to **/*.{test.res,spec.res} : Use `_only` to specify which tests to run in ReScript Mocha tests

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/package.json.hbs
  • scenarios/test_codegen/package.json
📚 Learning: 2025-11-25T12:40:49.622Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-11-25T12:40:49.622Z
Learning: Use Node.js v20 only (no higher or lower versions)

Applied to files:

  • scenarios/test_codegen/package.json
📚 Learning: 2025-11-25T12:41:23.343Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-11-25T12:41:23.343Z
Learning: Use Node.js v20 only; do not use higher or lower versions for development environment

Applied to files:

  • scenarios/test_codegen/package.json
⏰ 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 (17)
scenarios/test_codegen/package.json (6)

4-4: ESM enablement is correct.

Adding "type": "module" aligns the package with the CommonJS-to-ESM migration objective.


61-61: Verify Node version constraint against learnings.

The engines field specifies "node": ">=22.0.0" (unbounded upper), but the retrieved learnings state "Use Node.js v20 only." This appears to be a deliberate change from the previous constraint ">=22.0.0 <=22.10.0", but please confirm this aligns with the project's intended runtime environment and CI/CD constraints.


16-16: Mocha script with tsx import is the correct ESM pattern.

The NODE_OPTIONS='--import tsx' approach correctly enables TypeScript support in ESM context for Mocha test execution.


24-24: Verify "start" script delegation.

The "start" script now delegates to an external envio start CLI rather than executing a local entry point. Confirm that this external CLI is available in the runtime environment and correctly replaces the previous ts-node ./generated/src/Index.res.js behavior.


40-40: Verify dependency versions for ESM compatibility.

Dependencies tsx (4.21.0) and typescript (5.9.3) are pinned to exact versions (no caret). Confirm:

  • tsx@4.21.0 is compatible with Node 22 and the mocha test suite.
  • typescript@5.9.3 does not introduce breaking changes for the project's codebase.
  • Consider whether exact pinning is necessary or if a bounded caret (^5.9.3, ^4.21.0) would be more maintainable.

Also applies to: 52-52


44-44: Verify updated and added devDependencies.

  • rescript-schema updated to 9.3.4 — confirm compatibility with the ReScript build pipeline.
  • sinon added as ^15.0.4 — confirm compatibility with mocha and existing test suite.

Also applies to: 45-45

codegenerator/cli/templates/static/erc20_template/typescript/test/test.ts (2)

2-2: LGTM! Clean ESM import consolidation.

The consolidated import with the type keyword for Account follows TypeScript best practices and aligns with the ESM migration objectives.


12-13: Verify that mock addresses are guaranteed to be populated.

The non-null assertions assume that Addresses.mockAddresses contains at least two elements. While this is likely safe for controlled test fixtures, consider adding a brief comment or defensive check to make the assumption explicit for template users.

Optional: Add a comment for clarity:

 //Get mock addresses from helpers
+// Test helpers guarantee at least 2 mock addresses are available
 const userAddress1 = Addresses.mockAddresses[0]!;
 const userAddress2 = Addresses.mockAddresses[1]!;
codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/package.json (4)

4-4: LGTM! ESM migration correctly configured.

The "type": "module" field enables ES module semantics for this package, consistent with the broader PR's CommonJS-to-ESM migration.


9-9: Good practice: Type-check before running tests.

The mocha script now runs tsc --noEmit before executing tests, catching type errors early. The use of tsx with NODE_OPTIONS correctly handles ES module TypeScript execution.


13-13: LGTM! Start script correctly delegates to envio CLI.

The change from ts-node generated/src/Index.res.js to envio start addresses the previous review concern about ESM loader support and properly delegates execution to the envio CLI.


19-21: Dependency updates align with ESM migration.

The updates are consistent with the migration:

  • TypeScript 5.9.3 has better ES module support
  • tsx replaces ts-node/ts-mocha for ESM-native TypeScript execution
codegenerator/cli/templates/dynamic/codegen/package.json.hbs (3)

7-7: LGTM! ES module type declaration.

The "type": "module" field correctly configures the generated package for ES module semantics, consistent with the PR's migration goals.


13-16: LGTM! Database scripts use correct ESM dynamic import pattern.

The migration scripts correctly use node -e 'import(...).then(...)' to dynamically load ES modules. The pattern is clean and appropriate for running compiled ReScript (.res.mjs) files.


24-24: Node engine constraint loosened—verify compatibility.

The upper bound has been removed (previously <=22.10.0), now allowing any Node.js 22.x version. Ensure this aligns with the compatibility matrix for the updated dependencies (React 19, ReScript 11.1.3, etc.).

scenarios/erc20_multichain_factory/package.json (2)

9-9: The mocha pattern is correct; clarify the relationship between envio dev and envio start commands.

The mocha pattern correctly references .mjs files (line 9), which ReScript outputs per rescript.json configuration. However, envio start is not a replacement for envio dev—they are complementary commands with different purposes: envio dev includes automatic codegen for changed files, while envio start starts the indexer without automatic codegen. Both scripts should coexist (line 12-13), so no CI/CD updates are required for existing envio dev workflows.

Likely an incorrect or invalid review comment.


21-21: Verify rescript-schema 9.3.4 includes ESM/CJS interoperability fixes.

The patch bump from 9.3.0 to 9.3.4 addresses ESM-forward packaging issues in the 9.3.0 release, which caused runtime and module resolution problems when mixing "type":"module" with ReScript outputs. Confirm that 9.3.4 resolves the specific entrypoint and module format issues relevant to your build setup.

Comment thread codegenerator/cli/templates/dynamic/codegen/package.json.hbs
Comment thread scenarios/erc20_multichain_factory/package.json

@JonoPrest JonoPrest left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🚀

@DZakh DZakh enabled auto-merge (squash) December 2, 2025 14:04
@DZakh DZakh merged commit 10625ae into main Dec 2, 2025
2 checks passed
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.

Tests in scenarios/test_codegen fail on node v24

2 participants