Use Vitest as a suggested test framework#884
Conversation
📝 WalkthroughWalkthroughUpdates to code generation templates, test tooling, and examples: TypeScript and ReScript test templates migrate to Vitest, ReScript handler/entity-id generation adjusted, ERC‑20 template config extended, generated code filters out test files, and docs add a testrust instruction. Changes
Sequence Diagram(s)(Skipped — changes are template/tooling and do not introduce a new multi-component runtime control flow requiring a sequence diagram.) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI Agents
In @codegenerator/cli/templates/static/erc20_template/typescript/config.yaml:
- Line 14: The config sets address_format: lowercase but individual contract
entries (the address field like 0x32353A6C91143bfd6C7d363B546e62a9A2489A20) are
in checksum/mixed-case; convert those address values to all-lowercase so they
match address.toLowerCase() lookups and the address_format setting, and apply
the same fix to the other affected entries (the similar address fields called
out for lines 19 and 22).
🧹 Nitpick comments (1)
.cursor/commands/testrust.md (1)
1-1: Clear instruction, but consider adding brief context.The instruction is actionable and correctly placed in the Cursor commands directory. To improve developer experience, consider adding a brief explanation of what these commands do:
Run `cargo test` and `cargo clippy` at `codegenerator/cli` - `cargo test`: Runs the Rust test suite - `cargo clippy`: Performs linting and suggestions for code improvementsThis is optional but would help developers understand the purpose of each command without needing to look up Cargo documentation.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (10)
.cursor/commands/testrust.mdcodegenerator/cli/src/hbs_templating/contract_import_templates.rscodegenerator/cli/templates/dynamic/contract_import_templates/typescript/src/indexer.test.ts.hbscodegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbscodegenerator/cli/templates/static/erc20_template/typescript/config.yamlcodegenerator/cli/templates/static/erc20_template/typescript/src/indexer.test.tscodegenerator/cli/templates/static/factory_template/typescript/src/indexer.test.tscodegenerator/cli/templates/static/greeter_template/typescript/src/indexer.test.tscodegenerator/cli/templates/static/greeteronfuel_template/typescript/src/indexer.test.tscodegenerator/cli/templates/static/svmblock_template/typescript/src/indexer.test.ts
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{test,spec}.{ts,tsx,js,jsx,res}
📄 CodeRabbit inference engine (.cursor/rules/navigation.mdc)
**/*.{test,spec}.{ts,tsx,js,jsx,res}: Always use single assert to check the whole value instead of multiple asserts for every field
Prefer Public module API for testing
Use_onlyto specify which tests to run during test development
Files:
codegenerator/cli/templates/static/erc20_template/typescript/src/indexer.test.tscodegenerator/cli/templates/static/greeter_template/typescript/src/indexer.test.tscodegenerator/cli/templates/static/greeteronfuel_template/typescript/src/indexer.test.ts
codegenerator/cli/templates/dynamic/**/*.hbs
📄 CodeRabbit inference engine (.cursor/rules/navigation.mdc)
Templates in Handlebars format (.hbs) live under
codegenerator/cli/templates/dynamic/
Files:
codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbscodegenerator/cli/templates/dynamic/contract_import_templates/typescript/src/indexer.test.ts.hbs
🧠 Learnings (31)
📓 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-12-04T12:13:23.246Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.ts : For Step 6 - Final Migration Verification: Go through each handler and helper function systematically, comparing the logic line-by-line to the original subgraph implementation. Iterate multiple times until logic is completely correct, as first pass often misses subtle differences
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2026-01-05T11:20:07.222Z
Learning: Applies to codegenerator/cli/templates/static/**/*.res : Static ReScript template files live under `codegenerator/cli/templates/static/` and are copied verbatim
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-12-04T12:12:49.547Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.{ts,js} : In Envio HyperIndex, use `entity_id` fields (e.g., `token_id: string`) instead of direct object references for entity relationships
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.246Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/**/*.ts : For Step 3 - Refactor file structure to mirror the original subgraph EXACTLY using the same filenames, create separate handler files by contract (e.g., contract1.ts, contract2.ts) instead of a single EventHandlers.ts file, and move handlers from EventHandlers.ts to contract-specific files
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2026-01-05T11:20:07.222Z
Learning: Verify tests pass by running compiler `pnpm rescript` and tests `pnpm mocha`
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-12-04T12:12:49.547Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.{ts,js} : When updating existing entities in HyperIndex handlers, always use the spread operator for immutability since returned objects are read-only
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-12-04T12:12:49.547Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.{ts,js} : ALWAYS normalize amounts when adding tokens with different decimal places in HyperIndex handlers, creating helper functions to convert to standard decimals (e.g., 18 decimals)
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.246Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/effects/**/*.ts : When making external RPC calls, use viem with createPublicClient and batching for efficiency. Define Effect functions with proper schemas using the S module from 'envio': S.object(), S.string, S.number, etc.
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.246Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.ts : Always verify entity type field names match exactly with the generated entity types. For example, use `token0_id` not `token0`, and `transaction_id` not `transaction`. Run `pnpm tsc --noEmit` to catch type mismatches
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.246Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.ts : Import entity types from `generated/src/db/Entities.gen` for type annotations (e.g., `Pair_t`, `Token_t`), NOT from `generated` which exports contract handlers. Use the correct entity type imports to prevent TypeScript errors like 'refers to a value, but is being used as a type'
📚 Learning: 2025-12-04T12:13:23.246Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.246Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.ts : For Step 6 - Final Migration Verification: Go through each handler and helper function systematically, comparing the logic line-by-line to the original subgraph implementation. Iterate multiple times until logic is completely correct, as first pass often misses subtle differences
Applied to files:
codegenerator/cli/templates/static/erc20_template/typescript/src/indexer.test.tscodegenerator/cli/templates/static/greeter_template/typescript/src/indexer.test.tscodegenerator/cli/templates/static/greeteronfuel_template/typescript/src/indexer.test.tscodegenerator/cli/src/hbs_templating/contract_import_templates.rscodegenerator/cli/templates/dynamic/contract_import_templates/typescript/src/indexer.test.ts.hbs
📚 Learning: 2025-12-04T12:13:23.246Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.246Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.ts : Always verify entity type field names match exactly with the generated entity types. For example, use `token0_id` not `token0`, and `transaction_id` not `transaction`. Run `pnpm tsc --noEmit` to catch type mismatches
Applied to files:
codegenerator/cli/templates/static/erc20_template/typescript/src/indexer.test.tscodegenerator/cli/templates/static/erc20_template/typescript/config.yamlcodegenerator/cli/templates/static/greeter_template/typescript/src/indexer.test.tscodegenerator/cli/templates/static/greeteronfuel_template/typescript/src/indexer.test.tscodegenerator/cli/src/hbs_templating/contract_import_templates.rscodegenerator/cli/templates/dynamic/contract_import_templates/typescript/src/indexer.test.ts.hbs
📚 Learning: 2026-01-05T11:20:07.222Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2026-01-05T11:20:07.222Z
Learning: Applies to **/*.{test,spec}.{ts,tsx,js,jsx,res} : Always use single assert to check the whole value instead of multiple asserts for every field
Applied to files:
codegenerator/cli/templates/static/erc20_template/typescript/src/indexer.test.tscodegenerator/cli/templates/static/greeter_template/typescript/src/indexer.test.tscodegenerator/cli/templates/static/greeteronfuel_template/typescript/src/indexer.test.tscodegenerator/cli/templates/dynamic/contract_import_templates/typescript/src/indexer.test.ts.hbs
📚 Learning: 2025-12-04T12:13:23.246Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.246Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.ts : Import entity types from `generated/src/db/Entities.gen` for type annotations (e.g., `Pair_t`, `Token_t`), NOT from `generated` which exports contract handlers. Use the correct entity type imports to prevent TypeScript errors like 'refers to a value, but is being used as a type'
Applied to files:
codegenerator/cli/templates/static/erc20_template/typescript/src/indexer.test.tscodegenerator/cli/templates/static/greeter_template/typescript/src/indexer.test.tscodegenerator/cli/templates/static/greeteronfuel_template/typescript/src/indexer.test.tscodegenerator/cli/src/hbs_templating/contract_import_templates.rscodegenerator/cli/templates/dynamic/contract_import_templates/typescript/src/indexer.test.ts.hbs
📚 Learning: 2025-12-04T12:12:49.547Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-12-04T12:12:49.547Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.{ts,js} : When updating existing entities in HyperIndex handlers, always use the spread operator for immutability since returned objects are read-only
Applied to files:
codegenerator/cli/templates/static/erc20_template/typescript/src/indexer.test.tscodegenerator/cli/templates/static/greeter_template/typescript/src/indexer.test.tscodegenerator/cli/templates/static/greeteronfuel_template/typescript/src/indexer.test.tscodegenerator/cli/src/hbs_templating/contract_import_templates.rscodegenerator/cli/templates/dynamic/contract_import_templates/typescript/src/indexer.test.ts.hbs
📚 Learning: 2025-12-04T12:12:49.547Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-12-04T12:12:49.547Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.{ts,js} : In Envio HyperIndex, use `entity_id` fields (e.g., `token_id: string`) instead of direct object references for entity relationships
Applied to files:
codegenerator/cli/templates/static/erc20_template/typescript/src/indexer.test.tscodegenerator/cli/templates/static/erc20_template/typescript/config.yamlcodegenerator/cli/templates/static/greeter_template/typescript/src/indexer.test.tscodegenerator/cli/templates/static/greeteronfuel_template/typescript/src/indexer.test.tscodegenerator/cli/src/hbs_templating/contract_import_templates.rscodegenerator/cli/templates/dynamic/contract_import_templates/typescript/src/indexer.test.ts.hbs
📚 Learning: 2026-01-05T11:20:07.222Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2026-01-05T11:20:07.222Z
Learning: Applies to **/*.{test,spec}.{ts,tsx,js,jsx,res} : Prefer Public module API for testing
Applied to files:
codegenerator/cli/templates/static/erc20_template/typescript/src/indexer.test.tscodegenerator/cli/templates/static/greeter_template/typescript/src/indexer.test.tscodegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbscodegenerator/cli/templates/static/greeteronfuel_template/typescript/src/indexer.test.tscodegenerator/cli/templates/dynamic/contract_import_templates/typescript/src/indexer.test.ts.hbs
📚 Learning: 2025-12-04T12:13:23.245Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.245Z
Learning: AFTER EVERY SINGLE CODE CHANGE, you MUST test the indexer with `TUI_OFF=true pnpm dev` to catch runtime errors early, as TypeScript compilation only catches syntax and type errors while runtime errors (database issues, missing entities, logic errors) only appear when running the indexer
Applied to files:
codegenerator/cli/templates/static/erc20_template/typescript/src/indexer.test.tscodegenerator/cli/templates/static/greeteronfuel_template/typescript/src/indexer.test.ts
📚 Learning: 2025-12-04T12:12:49.547Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-12-04T12:12:49.547Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.{ts,js} : Import and use the Effect API (`S`, `createEffect`) from 'envio' package for external calls in HyperIndex handlers
Applied to files:
codegenerator/cli/templates/static/erc20_template/typescript/src/indexer.test.tscodegenerator/cli/templates/static/greeter_template/typescript/src/indexer.test.tscodegenerator/cli/templates/static/greeteronfuel_template/typescript/src/indexer.test.tscodegenerator/cli/templates/dynamic/contract_import_templates/typescript/src/indexer.test.ts.hbs
📚 Learning: 2025-12-04T12:12:49.547Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-12-04T12:12:49.547Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.{ts,js} : ALWAYS normalize amounts when adding tokens with different decimal places in HyperIndex handlers, creating helper functions to convert to standard decimals (e.g., 18 decimals)
Applied to files:
codegenerator/cli/templates/static/erc20_template/typescript/src/indexer.test.tscodegenerator/cli/templates/static/erc20_template/typescript/config.yaml
📚 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/src/indexer.test.tscodegenerator/cli/templates/static/greeter_template/typescript/src/indexer.test.tscodegenerator/cli/templates/static/greeteronfuel_template/typescript/src/indexer.test.tscodegenerator/cli/templates/dynamic/contract_import_templates/typescript/src/indexer.test.ts.hbs
📚 Learning: 2025-11-19T05:36:33.975Z
Learnt from: nikbhintade
Repo: enviodev/hyperindex PR: 822
File: codegenerator/cli/templates/static/multichain_indexer_template/typescript/src/EventHandlers.ts:10-18
Timestamp: 2025-11-19T05:36:33.975Z
Learning: The multichain_indexer_template in codegenerator/cli/templates/static/ is designed to demonstrate multichain indexing features. It intentionally uses minimal event parameters (e.g., only capturing the `pool` address from Uniswap V3 PoolCreated events) to keep the focus on multichain functionality rather than comprehensive event indexing.
Applied to files:
codegenerator/cli/templates/static/erc20_template/typescript/config.yamlcodegenerator/cli/src/hbs_templating/contract_import_templates.rs
📚 Learning: 2025-12-04T12:13:23.246Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.246Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/config.yaml : When using multichain indexing, ensure contract names in config.yaml are unique across all networks, place contract definitions in the global contracts section (not in network sections), and only define addresses for those contracts in network sections
Applied to files:
codegenerator/cli/templates/static/erc20_template/typescript/config.yaml
📚 Learning: 2025-12-04T12:13:23.246Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.246Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.ts : Never hardcode contract addresses or configuration values - always use constants defined in the original subgraph or utility files. Reference original subgraph patterns for constants like FACTORY_ADDRESS, ADDRESS_ZERO, etc.
Applied to files:
codegenerator/cli/templates/static/erc20_template/typescript/config.yaml
📚 Learning: 2025-12-04T12:13:23.246Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.246Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/config.yaml : For dynamic contracts created by factories, remove the `address` field from contract definitions in config.yaml since they don't have a fixed address
Applied to files:
codegenerator/cli/templates/static/erc20_template/typescript/config.yaml
📚 Learning: 2025-12-04T12:13:23.246Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.246Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/**/*.ts : For Step 3 - Refactor file structure to mirror the original subgraph EXACTLY using the same filenames, create separate handler files by contract (e.g., contract1.ts, contract2.ts) instead of a single EventHandlers.ts file, and move handlers from EventHandlers.ts to contract-specific files
Applied to files:
codegenerator/cli/templates/static/erc20_template/typescript/config.yamlcodegenerator/cli/src/hbs_templating/contract_import_templates.rscodegenerator/cli/templates/dynamic/contract_import_templates/typescript/src/indexer.test.ts.hbs
📚 Learning: 2025-12-04T12:12:49.547Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-12-04T12:12:49.547Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.{ts,js,yaml,yml} : Ensure case consistency when matching addresses in configuration objects, using lowercase keys to match `address.toLowerCase()` lookups
Applied to files:
codegenerator/cli/templates/static/erc20_template/typescript/config.yaml
📚 Learning: 2025-12-04T12:13:23.246Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.246Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/**/*.ts : For Step 4 - Implement contract registration for factory events using `contractRegister` above the handler to track dynamically created contracts: `Factory.EventName.contractRegister(({ event, context }) => { context.addContractName(event.params.contractAddress); });`
Applied to files:
codegenerator/cli/templates/static/erc20_template/typescript/config.yamlcodegenerator/cli/src/hbs_templating/contract_import_templates.rscodegenerator/cli/templates/dynamic/contract_import_templates/typescript/src/indexer.test.ts.hbs
📚 Learning: 2025-12-04T12:12:49.547Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-12-04T12:12:49.547Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.{yaml,yml} : Use the Envio EVM schema file for YAML validation in config.yaml: `yaml-language-server: $schema=./node_modules/envio/evm.schema.json`
Applied to files:
codegenerator/cli/templates/static/erc20_template/typescript/config.yaml
📚 Learning: 2025-12-04T12:13:23.246Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.246Z
Learning: Applies to codegenerator/cli/templates/static/shared/{**/*.ts,**/schema.graphql} : Ensure database schema compatibility: verify that the types you're setting in code match the schema entity property types exactly. Compare with schema.graphql - for example, `Int!` in schema requires `number` in code, `BigInt!` requires `BigInt`, `BigDecimal!` requires `BigDecimal`
Applied to files:
codegenerator/cli/templates/static/greeter_template/typescript/src/indexer.test.tscodegenerator/cli/templates/dynamic/contract_import_templates/typescript/src/indexer.test.ts.hbs
📚 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:
codegenerator/cli/templates/static/greeter_template/typescript/src/indexer.test.tscodegenerator/cli/templates/static/greeteronfuel_template/typescript/src/indexer.test.tscodegenerator/cli/templates/dynamic/contract_import_templates/typescript/src/indexer.test.ts.hbs
📚 Learning: 2026-01-05T11:20:07.222Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2026-01-05T11:20:07.222Z
Learning: Entry point for the Rust CLI is `codegenerator/cli/src/lib.rs`
Applied to files:
.cursor/commands/testrust.md
📚 Learning: 2026-01-05T11:20:07.222Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2026-01-05T11:20:07.222Z
Learning: Command dispatcher for Rust CLI is `codegenerator/cli/src/commands.rs`
Applied to files:
.cursor/commands/testrust.md
📚 Learning: 2026-01-05T11:20:07.222Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2026-01-05T11:20:07.222Z
Learning: Applies to codegenerator/cli/templates/static/**/*.res : Static ReScript template files live under `codegenerator/cli/templates/static/` and are copied verbatim
Applied to files:
codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbscodegenerator/cli/src/hbs_templating/contract_import_templates.rs
📚 Learning: 2026-01-05T11:20:07.222Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2026-01-05T11:20:07.222Z
Learning: Verify tests pass by running compiler `pnpm rescript` and tests `pnpm mocha`
Applied to files:
codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs
📚 Learning: 2025-12-04T12:12:49.547Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-12-04T12:12:49.547Z
Learning: 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
📚 Learning: 2026-01-05T11:20:07.222Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2026-01-05T11:20:07.222Z
Learning: Applies to **/*.{test,spec}.{ts,tsx,js,jsx,res} : Use `_only` to specify which tests to run during test development
Applied to files:
codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs
📚 Learning: 2025-12-04T12:13:23.246Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.246Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/EventHandlers.ts : For Step 1 - Clear all boilerplate code from EventHandlers.ts and replace with empty handlers containing TODO comments referencing the original subgraph implementation
Applied to files:
codegenerator/cli/src/hbs_templating/contract_import_templates.rs
📚 Learning: 2025-12-04T12:13:23.245Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.245Z
Learning: For multichain indexing, prefix all entity IDs with `event.chainId`: `${event.chainId}-${originalId}`, never hardcode `chainId = 1`, always use `event.chainId`, and use chain-specific Bundle IDs like `${chainId}-1` for accurate pricing per network
Applied to files:
codegenerator/cli/src/hbs_templating/contract_import_templates.rs
📚 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:
codegenerator/cli/templates/dynamic/contract_import_templates/typescript/src/indexer.test.ts.hbs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build_and_test
🔇 Additional comments (11)
codegenerator/cli/templates/static/greeteronfuel_template/typescript/src/indexer.test.ts (1)
1-1: LGTM! Clean migration to Vitest.The test framework migration from Node's assert to Vitest is correctly implemented:
- Import statements updated to use Vitest's
describe,it, andexpect- Assertion API correctly changed:
deepEqual→toEqualfor object comparison,equal→toBefor primitive comparisons- Test logic and structure remain unchanged
- Trailing newline added for consistent formatting
Also applies to: 39-39, 77-77, 118-118, 121-121
codegenerator/cli/templates/static/greeter_template/typescript/src/indexer.test.ts (1)
1-1: LGTM! Clean migration to Vitest.The test framework migration from Node's assert to Vitest is correctly implemented with the same clean pattern as the other template files:
- Import statements updated to use Vitest's
describe,it, andexpect- Assertion API correctly changed:
deepEqual→toEqualfor object comparison,equal→toBefor primitive comparisons- Test logic and structure remain unchanged
Also applies to: 39-39, 78-78, 119-119, 122-122
codegenerator/cli/templates/static/erc20_template/typescript/src/indexer.test.ts (1)
1-1: LGTM! Clean migration to Vitest with custom error messages.The test framework migration from Node's assert to Vitest is correctly implemented:
- Import statements updated to use Vitest's
describe,it, andexpect- Assertion API correctly changed from
assert.equal(actual, expected, message)toexpect(actual, message).toBe(expected)- Custom error messages are properly retained using Vitest's optional message parameter
- Test logic and structure remain unchanged
Also applies to: 46-49, 56-59
codegenerator/cli/templates/static/erc20_template/typescript/config.yaml (1)
2-3: LGTM! Multichain configuration follows best practices.The configuration updates are well-structured:
- Name and description updated for consistency
- Top-level contracts block correctly defines the ERC20 contract with its events
- Multichain setup properly separates contract definitions (global) from addresses (per-network)
- Start blocks updated to more recent blocks for faster initial sync
- Gnosis Mainnet support added alongside Ethereum Mainnet
Also applies to: 4-8, 11-11, 15-19
codegenerator/cli/templates/dynamic/contract_import_templates/typescript/src/indexer.test.ts.hbs (2)
3-3: LGTM: Vitest imports are correct.The migration from Node's assert module to Vitest's test helpers is properly implemented.
41-41: No action required — the custom message syntax is fully supported in Vitest 4.0.16.Vitest's expect() API explicitly supports passing a custom error message as the second parameter. The syntax
expect(actual, message).toEqual(expected)is the standard, documented way to add custom assertions and is fully compatible with Vitest 4.0.16.Likely an incorrect or invalid review comment.
codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs (2)
14-14: LGTM: Test command properly configured.The conditional ReScript build before running Vitest ensures generated code is available for testing.
24-24: No action needed. Vitest 4.0.16 is a focused bug-fix release (December 16, 2025) that stabilizes Browser Mode and fixes several issues related to imports, console handling, and coverage. As a patch release, it does not introduce breaking changes.codegenerator/cli/src/hbs_templating/contract_import_templates.rs (3)
315-322: LGTM: ReScript namespace cleanup is well-implemented.The addition of
open Indexerdirective eliminates the need for theIndexer.prefix in handler calls, making the generated code cleaner while maintaining correctness.
738-739: LGTM: Test expectations updated correctly.The test assertion properly reflects the new chainId format with the upcast operator.
385-388: The ReScript chainId upcast pattern is valid and already proven in production code.The upcast operator
(event.chainId :> int)is already used throughout the codebase in identical contexts. The test helpers inscenarios/test_codegen/test/helpers/Mock.resuse the exact same pattern:ChainMap.Chain.makeUnsafe(~chainId=(chainConfig.chain :> int)), which is part of the working test suite. The type coercion is correct and the generated ReScript code follows established patterns that successfully compile and run.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs (1)
27-31: LGTM! Test file filtering correctly implemented.The filtering logic properly excludes standard test files (
.test.and.spec.) from handler auto-loading, directly addressing the PR objective to prevent test files from being registered as handlers when using Vitest.The implementation correctly:
- Collects all files matching the glob pattern first
- Filters out files containing
.test.or.spec.in their path- Uses appropriate substring matching for the common naming conventions
Optional refinement: If you want to handle edge cases like plural forms (
.tests.,.specs.) or case variations (.TEST.,.SPEC.), you could use a case-insensitive approach:🔎 Optional: more comprehensive pattern matching
- files->Js.Array2.filter(file => { - !(file->Js.String2.includes(".test.") || file->Js.String2.includes(".spec.")) - }) + files->Js.Array2.filter(file => { + let lowerFile = file->Js.String2.toLowerCase + !(lowerFile->Js.String2.includes(".test.") || + lowerFile->Js.String2.includes(".spec.") || + lowerFile->Js.String2.includes(".tests.") || + lowerFile->Js.String2.includes(".specs.")) + })However, this is likely unnecessary since standard conventions use lowercase singular forms (
.test.and.spec.).
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
🧰 Additional context used
📓 Path-based instructions (1)
codegenerator/cli/templates/dynamic/**/*.hbs
📄 CodeRabbit inference engine (.cursor/rules/navigation.mdc)
Templates in Handlebars format (.hbs) live under
codegenerator/cli/templates/dynamic/
Files:
codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
🧠 Learnings (12)
📓 Common learnings
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-12-04T12:12:49.547Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.{ts,js} : In Envio HyperIndex, use `entity_id` fields (e.g., `token_id: string`) instead of direct object references for entity relationships
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.246Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.ts : Always verify entity type field names match exactly with the generated entity types. For example, use `token0_id` not `token0`, and `transaction_id` not `transaction`. Run `pnpm tsc --noEmit` to catch type mismatches
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.246Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.ts : For Step 6 - Final Migration Verification: Go through each handler and helper function systematically, comparing the logic line-by-line to the original subgraph implementation. Iterate multiple times until logic is completely correct, as first pass often misses subtle differences
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.246Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.ts : Import entity types from `generated/src/db/Entities.gen` for type annotations (e.g., `Pair_t`, `Token_t`), NOT from `generated` which exports contract handlers. Use the correct entity type imports to prevent TypeScript errors like 'refers to a value, but is being used as a type'
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-12-04T12:12:49.547Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.{ts,js} : When updating existing entities in HyperIndex handlers, always use the spread operator for immutability since returned objects are read-only
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.246Z
Learning: Applies to codegenerator/cli/templates/static/shared/{**/*.ts,**/schema.graphql} : Ensure database schema compatibility: verify that the types you're setting in code match the schema entity property types exactly. Compare with schema.graphql - for example, `Int!` in schema requires `number` in code, `BigInt!` requires `BigInt`, `BigDecimal!` requires `BigDecimal`
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.246Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/**/*.ts : For Step 3 - Refactor file structure to mirror the original subgraph EXACTLY using the same filenames, create separate handler files by contract (e.g., contract1.ts, contract2.ts) instead of a single EventHandlers.ts file, and move handlers from EventHandlers.ts to contract-specific files
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.246Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.ts : For entity creation patterns, always include all required fields in a single object literal and use `context.Entity.set(entity)` (without await). Update patterns should spread existing entity data and update only changed fields: `const updated = { ...existing, field: newValue }; context.Entity.set(updated);`
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2026-01-05T11:20:07.222Z
Learning: Applies to codegenerator/cli/templates/static/**/*.res : Static ReScript template files live under `codegenerator/cli/templates/static/` and are copied verbatim
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-12-04T12:12:49.547Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.{ts,js} : ALWAYS normalize amounts when adding tokens with different decimal places in HyperIndex handlers, creating helper functions to convert to standard decimals (e.g., 18 decimals)
📚 Learning: 2026-01-05T11:20:07.222Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2026-01-05T11:20:07.222Z
Learning: Applies to codegenerator/cli/templates/dynamic/**/*.hbs : Templates in Handlebars format (.hbs) live under `codegenerator/cli/templates/dynamic/`
Applied to files:
codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-12-04T12:13:23.246Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.246Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/**/*.ts : For Step 3 - Refactor file structure to mirror the original subgraph EXACTLY using the same filenames, create separate handler files by contract (e.g., contract1.ts, contract2.ts) instead of a single EventHandlers.ts file, and move handlers from EventHandlers.ts to contract-specific files
Applied to files:
codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-12-04T12:13:23.246Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.246Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/utils/**/*.ts : When implementing Step 5a (Helper Functions), examine ALL function calls within helper functions and recursively implement any dependencies that have NO entity/handler dependencies
Applied to files:
codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-12-04T12:13:23.246Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.246Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.ts : For Step 6 - Final Migration Verification: Go through each handler and helper function systematically, comparing the logic line-by-line to the original subgraph implementation. Iterate multiple times until logic is completely correct, as first pass often misses subtle differences
Applied to files:
codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-12-04T12:12:49.547Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-12-04T12:12:49.547Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.{ts,js} : When updating existing entities in HyperIndex handlers, always use the spread operator for immutability since returned objects are read-only
Applied to files:
codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-12-04T12:12:49.547Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-12-04T12:12:49.547Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.{ts,js} : Use `!context.isPreload` check to prevent logic from running during preload in HyperIndex handlers
Applied to files:
codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-12-04T12:12:49.547Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-12-04T12:12:49.547Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.{ts,js} : In Envio HyperIndex, use `entity_id` fields (e.g., `token_id: string`) instead of direct object references for entity relationships
Applied to files:
codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2026-01-05T11:20:07.222Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2026-01-05T11:20:07.222Z
Learning: Applies to codegenerator/cli/templates/static/**/*.res : Static ReScript template files live under `codegenerator/cli/templates/static/` and are copied verbatim
Applied to files:
codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-12-04T12:13:23.246Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.246Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.ts : Import entity types from `generated/src/db/Entities.gen` for type annotations (e.g., `Pair_t`, `Token_t`), NOT from `generated` which exports contract handlers. Use the correct entity type imports to prevent TypeScript errors like 'refers to a value, but is being used as a type'
Applied to files:
codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-12-04T12:13:23.246Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.246Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/EventHandlers.ts : For Step 1 - Clear all boilerplate code from EventHandlers.ts and replace with empty handlers containing TODO comments referencing the original subgraph implementation
Applied to files:
codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-12-04T12:12:49.547Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-12-04T12:12:49.547Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.{ts,js} : Import and use the Effect API (`S`, `createEffect`) from 'envio' package for external calls in HyperIndex handlers
Applied to files:
codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
⏰ 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
|
Merged as part of #889 |
Also:
Summary by CodeRabbit
New Features
Chores
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.