Skip to content

refactor(torii-sqlite): move types into its own crate#3170

Merged
glihm merged 2 commits intomainfrom
torii-sqlite-types
Apr 16, 2025
Merged

refactor(torii-sqlite): move types into its own crate#3170
glihm merged 2 commits intomainfrom
torii-sqlite-types

Conversation

@kariy
Copy link
Member

@kariy kariy commented Apr 16, 2025

having a version conflict issue when importing torii-cli from slot.

error: failed to select a version for `starknet-types-core`.
    ... required by package `cainome v0.5.1`
    ... which satisfies dependency `cainome = "^0.5.0"` (locked to 0.5.1) of package `torii-sqlite v1.4.0 (https://github.com/dojoengine/dojo?rev=234823291281c6522ff6a48ea5739d85d59bcdf9#23482329)`
    ... which satisfies git dependency `torii-sqlite` (locked to 1.4.0) of package `torii-cli v1.4.0 (https://github.com/dojoengine/dojo?rev=234823291281c6522ff6a48ea5739d85d59bcdf9#23482329)`
    ... which satisfies git dependency `torii-cli` (locked to 1.4.0) of package `slot-cli v0.39.3 (/Users/kariy/Project/work/cartridge/slot/cli)`
versions that meet the requirements `^0.1.6` (locked to 0.1.7) are: 0.1.7

cainome here isn't even being used by torii-cli. so this refactor removes that reliance.

Summary by CodeRabbit

  • Chores
    • Updated internal dependencies to use a new, dedicated types package.
    • Adjusted workspace configuration to include the new types package.
    • Updated import paths and dependency references for improved modularity and consistency.
    • Added configuration for the new types package.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 16, 2025

Walkthrough

Ohayo sensei! This update restructures the handling of SQLite-related types within the workspace. The torii-sqlite-types crate is introduced as a new, standalone crate for shared SQLite types, and dependencies are updated throughout the workspace to reference this new crate directly. The torii-sqlite crate's path is adjusted to a nested location, and internal type imports are switched to use torii-sqlite-types. Additionally, dependency resolution is streamlined by leveraging workspace settings in several Cargo.toml files.

Changes

Files/Paths Change Summary
Cargo.toml, crates/torii/sqlite/sqlite/Cargo.toml, crates/torii/grpc/Cargo.toml Updated workspace dependencies: added torii-sqlite-types, changed torii-sqlite path, and used workspace resolution.
crates/torii/cli/Cargo.toml Switched dependency from torii-sqlite to torii-sqlite-types.
crates/torii/cli/src/args.rs, crates/torii/cli/src/options.rs Updated import paths to use torii_sqlite_types instead of torii_sqlite::types.
crates/torii/sqlite/sqlite/src/lib.rs Replaced internal types module with a re-export of the external torii_sqlite_types crate.
crates/torii/sqlite/types/Cargo.toml Added new manifest for the torii-sqlite-types crate with workspace-inherited dependencies and metadata.

Sequence Diagram(s)

sequenceDiagram
    participant CLI
    participant torii-sqlite-types
    participant torii-sqlite

    CLI->>torii-sqlite-types: Import types (Contract, ContractType, ModelIndices)
    torii-sqlite->>torii-sqlite-types: Re-export types as public API
Loading

Suggested reviewers

  • glihm

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 1606eee and 821845a.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (8)
  • Cargo.toml (2 hunks)
  • crates/torii/cli/Cargo.toml (1 hunks)
  • crates/torii/cli/src/args.rs (1 hunks)
  • crates/torii/cli/src/options.rs (1 hunks)
  • crates/torii/grpc/Cargo.toml (1 hunks)
  • crates/torii/sqlite/sqlite/Cargo.toml (1 hunks)
  • crates/torii/sqlite/sqlite/src/lib.rs (1 hunks)
  • crates/torii/sqlite/types/Cargo.toml (1 hunks)
✅ Files skipped from review due to trivial changes (3)
  • crates/torii/cli/src/options.rs
  • crates/torii/cli/src/args.rs
  • Cargo.toml
🚧 Files skipped from review as they are similar to previous changes (5)
  • crates/torii/sqlite/sqlite/Cargo.toml
  • crates/torii/cli/Cargo.toml
  • crates/torii/sqlite/sqlite/src/lib.rs
  • crates/torii/sqlite/types/Cargo.toml
  • crates/torii/grpc/Cargo.toml
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6300eb4 and fe38bcd.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (8)
  • Cargo.toml (1 hunks)
  • crates/torii/cli/Cargo.toml (1 hunks)
  • crates/torii/cli/src/args.rs (1 hunks)
  • crates/torii/cli/src/options.rs (1 hunks)
  • crates/torii/grpc/Cargo.toml (1 hunks)
  • crates/torii/sqlite/sqlite/Cargo.toml (1 hunks)
  • crates/torii/sqlite/sqlite/src/lib.rs (1 hunks)
  • crates/torii/sqlite/types/Cargo.toml (1 hunks)
🔇 Additional comments (8)
crates/torii/sqlite/types/Cargo.toml (2)

1-6: Ohayo sensei — New crate manifest with workspace inheritance
The [package] section correctly establishes torii-sqlite-types and inherits version, edition, and repository from the workspace to keep metadata consistent.


7-13: Ohayo sensei — Centralized dependency declarations
Dependencies (chrono, dojo-types, serde, anyhow, sqlx, starknet) are all declared with workspace = true, ensuring a single source of truth for versions across crates.

crates/torii/cli/src/options.rs (1)

10-10: Ohayo sensei — Updated types import
The import path for Contract, ContractType, and ModelIndices has been switched to the new torii_sqlite_types crate, aligning with the refactoring.

crates/torii/cli/src/args.rs (1)

118-118: Ohayo sensei — Corrected test module import
Tests now correctly import Contract, ContractType, and ModelIndices from torii_sqlite_types instead of the old internal module.

crates/torii/cli/Cargo.toml (1)

16-16: Ohayo sensei — Added workspace dependency on torii-sqlite-types
The torii-cli crate now includes torii-sqlite-types via the workspace, reflecting the separation of shared SQLite types into its own crate.

crates/torii/sqlite/sqlite/Cargo.toml (1)

12-12: Ohayo sensei — Added workspace dependency on torii-sqlite-types
This ensures the torii-sqlite implementation crate depends on the newly extracted types crate for consistency and reuse.

crates/torii/grpc/Cargo.toml (1)

17-17: Switch to workspace dependency for torii-sqlite
Ohayo sensei, using workspace = true in place of a relative path aligns with the refactor and keeps dependency resolution in-sync across the workspace.

crates/torii/sqlite/sqlite/src/lib.rs (1)

38-38: Re-export external types crate
Ohayo sensei, re-exporting torii_sqlite_types as types replaces the internal module and maintains backward compatibility with existing imports (use types::ParsedCall).

Comment on lines +133 to +134
torii-sqlite = { path = "crates/torii/sqlite/sqlite" }
torii-sqlite-types = { path = "crates/torii/sqlite/types" }
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Update workspace dependencies for SQLite crates
Ohayo sensei, updating the path for torii-sqlite and introducing torii-sqlite-types under crates/torii/sqlite/types correctly modularizes the types into their own crate.

Run this script to verify that all internal types imports have been migrated:


🏁 Script executed:

#!/usr/bin/env bash
rg "torii_sqlite::types" -n .

Length of output: 2416


Fix remaining types imports to use the new crate
Ohayo sensei, after moving the types into the torii-sqlite-types crate, all imports should reference torii_sqlite_types instead of torii_sqlite::types. The following files still use the old path and need updating:

  • crates/torii/runner/src/lib.rs:42
  • crates/torii/graphql/src/schema.rs:5
  • crates/torii/indexer/src/test.rs:26
  • crates/torii/graphql/src/tests/mod.rs:33
  • crates/torii/libp2p/src/test.rs:33
  • crates/torii/graphql/src/tests/subscription_test.rs:22
  • crates/torii/indexer/src/task_manager.rs:10
  • crates/torii/graphql/src/object/event.rs:8
  • crates/torii/graphql/src/object/model.rs:8
  • crates/torii/graphql/src/tests/metadata_test.rs:13
  • crates/torii/graphql/src/object/erc/erc_token.rs:10
  • crates/torii/graphql/src/object/erc/token_balance.rs:13
  • crates/torii/graphql/src/object/transaction.rs:11
  • crates/torii/graphql/src/object/event_message.rs:11
  • crates/torii/graphql/src/object/entity.rs:11
  • crates/torii/indexer/src/engine.rs:28
  • crates/torii/indexer/src/processors/store_transaction.rs:10
  • crates/torii/grpc/src/server/mod.rs:50
  • crates/torii/grpc/src/server/subscriptions/event_message.rs:19
  • crates/torii/grpc/src/server/subscriptions/event.rs:19
  • crates/torii/grpc/src/server/subscriptions/token.rs:18
  • crates/torii/grpc/src/server/tests/entities_test.rs:28
  • crates/torii/grpc/src/server/subscriptions/token_balance.rs:18
  • crates/torii/grpc/src/server/subscriptions/indexer.rs:18
  • crates/torii/grpc/src/server/subscriptions/entity.rs:19

Please update each to, for example:

use torii_sqlite_types::{Contract, ContractType, Model};

This will ensure all references point to the extracted types crate.

@kariy kariy force-pushed the torii-sqlite-types branch from fe38bcd to 1606eee Compare April 16, 2025 20:27
@kariy kariy force-pushed the torii-sqlite-types branch from 1606eee to eb821fb Compare April 16, 2025 20:38
@glihm glihm enabled auto-merge (squash) April 16, 2025 20:48
@codecov
Copy link

codecov bot commented Apr 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 55.63%. Comparing base (6300eb4) to head (821845a).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3170      +/-   ##
==========================================
- Coverage   55.63%   55.63%   -0.01%     
==========================================
  Files         443      443              
  Lines       62987    62987              
==========================================
- Hits        35041    35040       -1     
- Misses      27946    27947       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@glihm glihm merged commit a64d6ad into main Apr 16, 2025
15 checks passed
@glihm glihm deleted the torii-sqlite-types branch April 16, 2025 21:23
kariy added a commit that referenced this pull request Apr 28, 2025
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.

2 participants