Topic Filter Template#1078
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdds a new EVM template "Feature: Topic Filter", wires it into CLI/init (args and interactive), maps it to a template directory, supplies TypeScript template scaffolding (schema, config, handler, tests, docs, env/gitignore), and registers the template in e2e tests. (47 words) Changes
Sequence Diagram(s)sequenceDiagram
participant Dev as Dev (user)
participant CLI as CLI
participant Scaffold as Template Scaffold
participant Indexer as Indexer Runtime
participant Envio as Envio API/Store
Dev->>CLI: run `envio init -t feature-topic-filter -l typescript`
CLI->>Scaffold: create `feature_filter` files (config, handlers, schema, tests)
Dev->>CLI: run `pnpm codegen` / `pnpm dev` / tests
CLI->>Indexer: start indexer with template config (wildcard + eventFilters)
Indexer->>Envio: subscribe/process chain events using topic filters
Indexer->>Envio: write Transfer records to GraphQL store
Dev->>Envio: query results via GraphQL Playground
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
packages/cli/templates/static/feature_filter_template/shared/.gitignore (1)
1-36: Deduplicate repeated ignore patterns.
*.objand*.annotare listed twice; trimming duplicates keeps this file easier to maintain.Suggested cleanup
*.exe *.obj *.out *.compile *.native *.byte *.cmo *.annot *.cmi *.cmx *.cmt *.cmti *.cma *.a *.cmxa -*.obj *~ -*.annot *.cmj *.bak🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/cli/templates/static/feature_filter_template/shared/.gitignore` around lines 1 - 36, The .gitignore contains duplicate patterns; remove the repeated entries for "*.obj" and "*.annot" so each ignore pattern appears only once in the shared .gitignore template (look for the "*.obj" and "*.annot" entries in the file and remove the duplicates while preserving one occurrence of each).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/cli/templates/static/feature_filter_template/shared/.env.example`:
- Line 2: The .env.example line ENVIO_API_TOKEN currently uses surrounding
quotes which triggers dotenv-linter QuoteCharacter; open the template file and
remove the surrounding double quotes so the placeholder reads
ENVIO_API_TOKEN=<YOUR-API-TOKEN> (no quotes or extra whitespace), save and
commit the change so the placeholder satisfies dotenv-linter.
In `@packages/cli/templates/static/feature_filter_template/shared/README.md`:
- Line 81: The Markdown link in the README line "While the 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." is malformed;
replace the duplicated form with a proper Markdown link like "While the indexer
is running, visit the [Envio Console](https://envio.dev/console) to open the
GraphQL Playground and query your indexed data." by editing that sentence in the
README (search for the exact fragment "Envio
Console([https://envio.dev/console](https://envio.dev/console))").
In
`@packages/cli/templates/static/feature_filter_template/typescript/src/indexer.test.ts`:
- Around line 71-81: The expectedTransfer in the burn test uses contract:
ZERO_ADDRESS which doesn't match what the handler actually saves; update the
expectation to use the real contract value the handler stores (e.g., the
token/contract address used in the test event) instead of ZERO_ADDRESS so that
the object compared in indexer.Transfer.getOrThrow(FIRST_EVENT_ID) matches;
locate the expectedTransfer declaration and replace contract: ZERO_ADDRESS with
the correct contract identifier used when creating the burn event (or derive it
from the test's token/contract variable).
---
Nitpick comments:
In `@packages/cli/templates/static/feature_filter_template/shared/.gitignore`:
- Around line 1-36: The .gitignore contains duplicate patterns; remove the
repeated entries for "*.obj" and "*.annot" so each ignore pattern appears only
once in the shared .gitignore template (look for the "*.obj" and "*.annot"
entries in the file and remove the duplicates while preserving one occurrence of
each).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 91fc5056-6af6-41e7-b36a-0e55a70d9b40
📒 Files selected for processing (12)
packages/cli/src/cli_args/init_config.rspackages/cli/src/cli_args/interactive_init/mod.rspackages/cli/src/template_dirs.rspackages/cli/templates/static/feature_filter_template/shared/.env.examplepackages/cli/templates/static/feature_filter_template/shared/.gitignorepackages/cli/templates/static/feature_filter_template/shared/README.mdpackages/cli/templates/static/feature_filter_template/shared/schema.graphqlpackages/cli/templates/static/feature_filter_template/typescript/config.yamlpackages/cli/templates/static/feature_filter_template/typescript/src/handlers/ERC20.tspackages/cli/templates/static/feature_filter_template/typescript/src/indexer.test.tspackages/cli/templates/static/feature_filter_template/typescript/tsconfig.jsonpackages/e2e-tests/src/template-tests/templates.test.ts
DZakh
left a comment
There was a problem hiding this comment.
Nothing critical, just left a few nitpicks. Thank you for leading this project with templates.
|
|
||
| const result = await indexer.process({ | ||
| chains: { | ||
| 1: { startBlock: START_BLOCK, endBlock: END_BLOCK }, |
There was a problem hiding this comment.
I'd like to wait for alpha 21 release and use the automatic block detection feature. To process only the first block in the test
| const allTransfers = result.changes.flatMap((c) => c.Transfer?.sets ?? []); | ||
| const burns = allTransfers.filter((t) => t.to === ZERO_ADDRESS); | ||
|
|
||
| expect(burns.length, "Should have indexed at least one burn event").toBeGreaterThan(0); | ||
| expect(burns[0]).toMatchObject({ to: ZERO_ADDRESS, chainId: 1 }); |
There was a problem hiding this comment.
Also, if you want to test that both burn and mint exist, it makes sense to use a hard-coded range. But maybe shrink it to a specific block. Also, instead of validating changes, you can do indexer.Transfer.getAll() or getOrThrow
Summary by CodeRabbit
New Features
Documentation
Tests