Conversation
WalkthroughAdded a new "Effects API" template variant: new Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Event as UniswapV3Factory.PoolCreated
participant Handler as EventHandler
participant Effect as fetchTokenDetails
participant RPC as Ethereum RPC
participant Store as Indexer Context
Event->>Handler: Invoke with token0, token1, fee, tickSpacing
par Concurrent decimals fetch
Handler->>Effect: fetch token0 decimals
Handler->>Effect: fetch token1 decimals
end
Effect->>RPC: call ERC20.decimals
RPC-->>Effect: decimals | error
Note right of Effect: on error -> return fallback 18
Effect-->>Handler: decimals result
Handler->>Handler: compose UniswapV3Factory_PoolCreated entity
Handler->>Store: set UniswapV3Factory_PoolCreated(entity)
Store-->>Handler: ack
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
⏰ 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)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (4)
codegenerator/cli/templates/static/effects_api_template/shared/.env.example (1)
1-3: Tidy up .env example to satisfy dotenv-linter (optional).dotenv-linter warnings are only about style (quoted values and missing trailing newline). If you care about keeping it clean, you can drop the quotes and add a final newline:
-ENVIO_API_TOKEN="<YOUR-API-TOKEN>" -ETHEREUM_MAINNET_RPC="<YOUR-ETHEREUM-MAINNET-RPC-URL>" +ENVIO_API_TOKEN=<YOUR-API-TOKEN> +ETHEREUM_MAINNET_RPC=<YOUR-ETHEREUM-MAINNET-RPC-URL> +codegenerator/cli/templates/static/effects_api_template/shared/.gitignore (1)
1-35: Remove duplicate patterns in .gitignore (nit).
*.obj(Line 16) and*.annot(Line 18) are already listed earlier (Lines 2 and 8). Not a functional issue, but you can drop the duplicates to keep this list a bit cleaner.-*.obj -*~ -*.annot +*~codegenerator/cli/templates/static/effects_api_template/typescript/src/EventHandlers.ts (1)
1-71: Normalize viemdecimalstype to matchS.number& ensure viem dependency is wired.Two things to double‑check here:
- Effect output vs. viem return type
Depending on your viem version & config,
client.readContractfordecimals()may return abigint(even foruint8), while the effect schema declares:output: { decimal: S.number, }To avoid any schema/runtime mismatch, it’s safer to coerce explicitly:
- const decimals = await client.readContract({ + const decimals = await client.readContract({ address: input.token as `0x${string}`, abi: ERC20_ABI, functionName: "decimals", }); - - return { decimal: decimals }; + return { decimal: Number(decimals) };
- Template dependency on
viemThis template imports
viemandviem/chains, but generator wiring forpackage.jsonisn’t visible here (and per PR description is still in question). Please ensure that:
- The scaffolded project’s
package.jsonincludesviemas a dependency, or- The shared README for this template clearly tells users to
npm install viem/pnpm add viemafter generation.codegenerator/cli/templates/static/effects_api_template/shared/README.md (1)
1-99: Tweak link text to be more descriptive (markdownlint MD059)The README is clear, but markdownlint flags bare-URL link text. Consider making the link text descriptive for better accessibility and lint compliance:
-You can learn more about the Effects API in the documentation: [https://docs.envio.dev/docs/HyperIndex/effect-api](https://docs.envio.dev/docs/HyperIndex/effect-api) +You can learn more about the Effects API in the [Effects API documentation](https://docs.envio.dev/docs/HyperIndex/effect-api). -While indexer is running, visit the Envio Console([https://envio.dev/console](https://envio.dev/console)) to open the GraphQL Playground and query your indexed data. +While the indexer is running, visit the [Envio Console](https://envio.dev/console) to open the GraphQL Playground and query your indexed data.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (9)
codegenerator/cli/src/cli_args/init_config.rs(1 hunks)codegenerator/cli/src/template_dirs.rs(1 hunks)codegenerator/cli/templates/static/effects_api_template/shared/.env.example(1 hunks)codegenerator/cli/templates/static/effects_api_template/shared/.gitignore(1 hunks)codegenerator/cli/templates/static/effects_api_template/shared/README.md(1 hunks)codegenerator/cli/templates/static/effects_api_template/shared/schema.graphql(1 hunks)codegenerator/cli/templates/static/effects_api_template/typescript/config.yaml(1 hunks)codegenerator/cli/templates/static/effects_api_template/typescript/src/EventHandlers.ts(1 hunks)codegenerator/cli/templates/static/effects_api_template/typescript/tsconfig.json(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
codegenerator/cli/**
📄 CodeRabbit inference engine (.cursor/rules/navigation.mdc)
The Rust CLI lives in codegenerator/cli
Files:
codegenerator/cli/templates/static/effects_api_template/shared/schema.graphqlcodegenerator/cli/src/cli_args/init_config.rscodegenerator/cli/templates/static/effects_api_template/typescript/config.yamlcodegenerator/cli/templates/static/effects_api_template/typescript/tsconfig.jsoncodegenerator/cli/templates/static/effects_api_template/typescript/src/EventHandlers.tscodegenerator/cli/src/template_dirs.rscodegenerator/cli/templates/static/effects_api_template/shared/README.md
🧠 Learnings (5)
📚 Learning: 2025-11-19T05:36:33.940Z
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.940Z
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/effects_api_template/shared/schema.graphqlcodegenerator/cli/templates/static/effects_api_template/typescript/config.yamlcodegenerator/cli/templates/static/effects_api_template/typescript/src/EventHandlers.ts
📚 Learning: 2025-10-21T16:31:22.127Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-10-21T16:31:22.127Z
Learning: Applies to codegenerator/cli/src/hbs_templating/codegen_templates.rs : hbs_templating/codegen_templates.rs feeds templates
Applied to files:
codegenerator/cli/src/cli_args/init_config.rscodegenerator/cli/src/template_dirs.rs
📚 Learning: 2025-10-21T16:31:22.127Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-10-21T16:31:22.127Z
Learning: Applies to codegenerator/cli/templates/static/**/*.res : Static templates are raw ReScript files copied verbatim under codegenerator/cli/templates/static
Applied to files:
codegenerator/cli/templates/static/effects_api_template/typescript/tsconfig.jsoncodegenerator/cli/templates/static/effects_api_template/shared/.gitignore
📚 Learning: 2025-10-21T16:31:22.127Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-10-21T16:31:22.127Z
Learning: Compiled .js artifacts can be ignored
Applied to files:
codegenerator/cli/templates/static/effects_api_template/shared/.gitignore
📚 Learning: 2025-10-21T16:31:22.127Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-10-21T16:31:22.127Z
Learning: Applies to **/*.res : Prefer reading ReScript .res modules directly
Applied to files:
codegenerator/cli/templates/static/effects_api_template/shared/.gitignore
🧬 Code graph analysis (1)
codegenerator/cli/src/cli_args/init_config.rs (2)
codegenerator/cli/src/config_parsing/entity_parsing.rs (2)
serialize(1184-1189)serialize(1335-1340)codegenerator/cli/src/rescript_types.rs (1)
serialize(703-709)
🪛 dotenv-linter (4.0.0)
codegenerator/cli/templates/static/effects_api_template/shared/.env.example
[warning] 2-2: [QuoteCharacter] The value has quote characters (', ")
(QuoteCharacter)
[warning] 3-3: [EndingBlankLine] No blank line at the end of the file
(EndingBlankLine)
[warning] 3-3: [QuoteCharacter] The value has quote characters (', ")
(QuoteCharacter)
🪛 markdownlint-cli2 (0.18.1)
codegenerator/cli/templates/static/effects_api_template/shared/README.md
23-23: Link text should be descriptive
(MD059, descriptive-link-text)
⏰ 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/src/cli_args/init_config.rs (1)
29-35: EffectsApi template variant wiring looks correct.Adding
EffectsApiwith astrum(serialize = "Feature: Effects API")label fits the existing enum pattern and will integrate cleanly with InitFlow and iteration/Display usage.codegenerator/cli/templates/static/effects_api_template/typescript/config.yaml (1)
1-19: Config wiring for the Effects API template looks consistent.Contract name, handler path, PoolCreated signature, mainnet factory address, and flags (
unordered_multichain_mode,preload_handlers) all line up with the new TS handler and Uniswap V3 factory ABI.If you haven’t already, verify this
config.yamlagainstevm.schema.jsonviaenvio’s own validation to catch any schema drift.codegenerator/cli/src/template_dirs.rs (1)
15-23: EffectsApi →effects_apimapping looks correctThe new
evm::Template::EffectsApi => "effects_api"arm is consistent with existing mappings and aligns with theeffects_api_templatedirectory naming used by the static templates.codegenerator/cli/templates/static/effects_api_template/typescript/tsconfig.json (1)
1-21: TypeScript compiler options are sensible for this templateThe
tsconfig.jsonsettings (ES2020 target/lib, strict mode, CommonJS, JSON module support) are coherent with a Node 18+ / BigInt / viem-based Effects API template.codegenerator/cli/templates/static/effects_api_template/shared/schema.graphql (1)
1-10: PoolCreated GraphQL type is well-structuredThe
UniswapV3Factory_PoolCreatedtype cleanly captures the expected event fields (ids, token addresses/decimals, fee, tick spacing, pool) and fits typical indexing patterns; nothing problematic stands out.
| #[strum(serialize = "Feature: External Calls")] | ||
| EffectsApi |
There was a problem hiding this comment.
A suggestion for consistency:
| #[strum(serialize = "Feature: External Calls")] | |
| EffectsApi | |
| #[strum(serialize = "Feature: External Calls")] | |
| ExternalCalls |
| @@ -0,0 +1,3 @@ | |||
| # To create or update a token visit https://envio.dev/app/api-tokens | |||
| ENVIO_API_TOKEN="<YOUR-API-TOKEN>" | |||
| ETHEREUM_MAINNET_RPC="<YOUR-ETHEREUM-MAINNET-RPC-URL>" No newline at end of file | |||
There was a problem hiding this comment.
Currently it's required on hosted service to have env vars prefixed with ENVIO_ to set them via UI, so let's also do this in the template.
| @@ -0,0 +1,99 @@ | |||
| # Effects API | |||
|
|
||
| _Please refer to the [documentation website](https://docs.envio.dev) for a thorough guide on all [Envio](https://envio.dev) indexer features_ | ||
|
|
||
| With HyperIndex, the Effects API allows you to perform external calls from your handlers. |
There was a problem hiding this comment.
This is Effect API, not Effects API
| _Please refer to the [documentation website](https://docs.envio.dev) for a thorough guide on all [Envio](https://envio.dev) indexer features_ | ||
|
|
||
| With HyperIndex, the Effects API allows you to perform external calls from your handlers. | ||
| These calls run in parallel with your handler logic, so they don’t block execution. |
| Add your Envio API key to the .env file, then start the indexer: | ||
|
|
||
| ```bash | ||
| pnpm install viem # install viem to interact with RPC |
There was a problem hiding this comment.
This should be a part of the template, so we shouldn't require more than pnpm i for the user
There was a problem hiding this comment.
How can I do that? I am not sure about it.
There was a problem hiding this comment.
We usually include it into a package json, which should become a part of the template.
| // Create a Viem client for mainnet RPC reads | ||
| const client = createPublicClient({ | ||
| chain: mainnet, | ||
| transport: http(process.env.ETHEREUM_MAINNET_RPC!, { batch: true }), | ||
| }); |
There was a problem hiding this comment.
Let's make it multichain as I suggested in the previous PR
| name: effects-api | ||
| description: Example indexer showing how to use HyperIndex’s Effects API. |
There was a problem hiding this comment.
Let's also add feature or example to the name
Template for showing Effects API usage
Current issue:
package.jsonas this template usesviem, right I have added that step in the README fileSummary by CodeRabbit
New Features
Documentation