-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
example: update cli example #131
Conversation
📝 WalkthroughWalkthroughThis pull request introduces significant changes to the Apibara CLI example project, focusing on database schema and indexer configuration. The modifications involve updating the Drizzle ORM table definitions, removing the Changes
Sequence DiagramsequenceDiagram
participant Indexer
participant DrizzleStorage
participant Database
Indexer->>DrizzleStorage: Initialize with new configuration
DrizzleStorage->>Database: Connect with UUID primary key
Indexer->>Database: Transform and store data
Database-->>Indexer: Confirm storage with new schema
Possibly related PRs
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
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 (6)
examples/cli/indexers/2-starknet.indexer.ts (1)
61-66
: Nitpick: Consider condensing log statements.
Using multiple arguments across multiple lines is fine, but a single template string might be more readable:-logger.info( - "Transforming block | orderKey: ", - endCursor?.orderKey, - " | finality: ", - finality, -); +logger.info(`Transforming block | orderKey: ${endCursor?.orderKey} | finality: ${finality}`);examples/cli/lib/schema.ts (2)
3-4
: Adding_id
UUID primary key tostarknet_usdc_transfers
.
Using a random UUID might be sufficient for uniqueness, but if you expect rows to be inherently unique by block/orderKey + transaction hash, consider adding a unique index on those columns.
9-10
: Adding_id
UUID primary key toethereum_usdc_transfers
.
Same note applies here regarding the potential need for a unique index on existing fields.examples/cli/indexers/1-evm.indexer.ts (1)
70-75
: Nitpick: Consolidate multiline log messages.
Consider using one template string for clarity, similar to the suggestion in2-starknet.indexer.ts
.pnpm-workspace.yaml (1)
3-3
: Includeexamples/**
in the workspace + missing newline.
Great to have the CLI examples included in the workspace. Also, fix the missing newline at the end of the file to satisfy yamllint:3 - "examples/**" +
🧰 Tools
🪛 yamllint (1.35.1)
[error] 3-3: no new line character at the end of file
(new-line-at-end-of-file)
examples/cli/drizzle/meta/0000_snapshot.json (1)
11-17
: Consider adding indexes for query performanceWhile the UUID primary key provides uniqueness, consider adding indexes on
(number, hash)
columns if these fields are frequently used in queries. This would improve query performance for block number and transaction hash lookups.Also applies to: 43-49
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (11)
examples/cli/docker-compose.yml
(1 hunks)examples/cli/drizzle/0000_great_hobgoblin.sql
(0 hunks)examples/cli/drizzle/0000_plain_omega_red.sql
(1 hunks)examples/cli/drizzle/meta/0000_snapshot.json
(2 hunks)examples/cli/drizzle/meta/_journal.json
(1 hunks)examples/cli/indexers/1-evm.indexer.ts
(4 hunks)examples/cli/indexers/2-starknet.indexer.ts
(4 hunks)examples/cli/indexers/3-starknet-factory.indexer.ts
(1 hunks)examples/cli/lib/schema.ts
(1 hunks)examples/cli/package.json
(1 hunks)pnpm-workspace.yaml
(1 hunks)
💤 Files with no reviewable changes (1)
- examples/cli/drizzle/0000_great_hobgoblin.sql
✅ Files skipped from review due to trivial changes (2)
- examples/cli/drizzle/meta/_journal.json
- examples/cli/drizzle/0000_plain_omega_red.sql
🧰 Additional context used
🪛 yamllint (1.35.1)
pnpm-workspace.yaml
[error] 3-3: no new line character at the end of file
(new-line-at-end-of-file)
🔇 Additional comments (17)
examples/cli/indexers/2-starknet.indexer.ts (6)
1-2
: No issues with the new defineIndexer
import.
These lines appear to introduce or reorganize imports without changing functionality.
15-16
: Clean import of logging and Drizzle plugins.
Switching to these imports is consistent with the new plugin approach.
37-37
: Verify the updated orderKey
.
Please confirm that 10_30_000n
is the intended starting cursor for your Starknet indexer.
40-45
: Properly configured Drizzle storage plugin.
This appears correct for persisting indexing state with _id
as the primary key and custom indexer name.
56-56
: Updated transform signature with finality
.
Including finality
is useful for advanced indexer logic if you need to handle reorgs or partial finality states.
58-58
: Retrieving the database from Drizzle storage.
Looks good. Ensure the Drizzle storage usage aligns with other indexers for consistency.
examples/cli/lib/schema.ts (1)
1-1
: All necessary imports for Drizzle schema definitions.
This change looks good.
examples/cli/indexers/3-starknet-factory.indexer.ts (1)
2-2
: Refactored useLogger
import path.
No issues. This change aligns with the import style used throughout the indexers.
examples/cli/indexers/1-evm.indexer.ts (6)
2-3
: Drizzle plugin imports look correct.
This facilitates the move from older persistence mechanisms to Drizzle-based storage.
15-15
: Refactored logger import path.
Change appears consistent with other indexers.
42-42
: Verify the updated starting cursor.
Confirm that 215_30_000n
is the correct block range for your Ethereum indexer.
58-63
: Drizzle storage configuration.
Looks properly set up with persistState
, _id
, and a meaningful indexerName
.
65-65
: Enhanced transform signature.
Adding the finality
parameter is a useful addition for decisions based on chain finality.
67-67
: Retrieve database via useDrizzleStorage
.
Implementation matches the new approach used in 2-starknet.indexer.ts
.
examples/cli/docker-compose.yml (1)
9-9
: Verify the intentional removal of volume persistence
The removal of the named volume means that database data will not persist between container restarts. While this might be acceptable for an example project, please confirm if this is intentional.
Run this script to check for volume definitions in other compose files:
✅ Verification successful
Removal of volume persistence is appropriate for this example setup
The docker-compose.yml file is located in the examples/cli
directory, which indicates this is an example setup meant for demonstration or quick-start purposes. For such cases, it's common and acceptable to omit persistence to:
- Keep the setup simple and minimal
- Allow users to start with a clean state each time
- Avoid cluttering the user's system with persistent volumes
The other compose file found (packages/plugin-mongo/docker-compose.orbstack.yaml
) is unrelated as it's for a different database (MongoDB) and serves a different purpose in the project.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for volume definitions in other compose files
# to ensure this wasn't accidentally removed
fd -e yml -e yaml docker-compose --exec grep -l "volumes:"
Length of output: 111
Script:
#!/bin/bash
# Let's check the content of both compose files to understand the context better
echo "=== Content of examples/cli/docker-compose.yml ==="
cat examples/cli/docker-compose.yml
echo -e "\n=== Content of packages/plugin-mongo/docker-compose.orbstack.yaml ==="
cat packages/plugin-mongo/docker-compose.orbstack.yaml
Length of output: 1286
Script:
#!/bin/bash
# Let's check if there are any README files in the examples/cli directory
# that might explain the intended setup
echo "=== Checking for README in examples/cli ==="
fd README -e md --max-depth 2 examples/cli --exec cat {}
Length of output: 157
examples/cli/package.json (1)
32-32
: LGTM! Dependency addition aligns with storage plugin migration
The addition of @apibara/plugin-drizzle
is consistent with the broader changes to migrate to the Drizzle storage plugin and the removal of the checkpoints table.
examples/cli/drizzle/meta/0000_snapshot.json (1)
2-2
: Verify data migration strategy
The schema changes (new migration ID: 9d645b77-7634-42a6-9849-92477d936c41
) introduce significant changes:
- Removal of
_cursor
columns - Addition of UUID primary keys
- Removal of checkpoints table
Please ensure there's a data migration strategy in place for existing data.
Run this script to check for migration files:
Also applies to: 11-17, 43-49
No description provided.