Skip to content

fix: sdk remove old code #428

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

Merged
merged 1 commit into from
Apr 4, 2025
Merged

fix: sdk remove old code #428

merged 1 commit into from
Apr 4, 2025

Conversation

MartianGreed
Copy link
Collaborator

@MartianGreed MartianGreed commented Apr 4, 2025

Closes #

Introduced changes

Checklist

  • Linked relevant issue
  • Updated relevant documentation
  • Added relevant tests
  • Add a dedicated CI job for new examples
  • Performed self-review of the code

Summary by CodeRabbit

  • Chores

    • Removed outdated internal testing and query conversion utilities.
    • Refined import declarations to clearly distinguish between type information and runtime values.
  • Refactor

    • Streamlined internal logic in query transformation processes, improving code clarity and maintainability without impacting public functionality.

Copy link

coderabbitai bot commented Apr 4, 2025

Walkthrough

The changes consist of removing several unit test files and conversion functions that transformed query objects into clause formats, including entity key clause conversions. Additionally, existing files were updated to use type-only import syntax for various type declarations, clarifying their intent. A minor refactoring in the convertToPrimitive function was performed to replace a chain of else if statements with separate if statements, without changing functionality.

Changes

Files Change Summary
packages/sdk/src/__tests__/convertQueryToClause.test.ts,
packages/sdk/src/__tests__/convertQueryToEntityKeyClauses.test.ts,
packages/sdk/src/convertQueryToEntityKeyClauses.ts,
packages/sdk/src/convertQuerytoClause.ts
Removed test suites and conversion functions for transforming queries into clause formats and entity key clauses.
packages/sdk/src/clauseBuilder.ts Updated import statements to use type-only imports for types from @dojoengine/torii-client and local modules, while retaining non-type imports where necessary.
packages/sdk/src/convertToMemberValue.ts Refactored the convertToPrimitive function by replacing chained else if statements with separate if statements, keeping the conversion logic intact.
packages/sdk/src/queryBuilder.ts,
packages/sdk/src/toriiQueryBuilder.ts
Modified import statements to type-only imports for QueryType, SchemaType, SubscriptionQueryType, and for Clause, OrderBy, Query, clarifying that these are used solely for type annotations.

Poem

Hop along the code trail with glee,
I’m a rabbit delighted by refactoring spree!
Tests and extra files hopped away,
Type-only imports lead the way.
With whiskers twitching for cleaner days,
I celebrate these changes in joyful code plays! 🐇🎉

✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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

@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: 0

🧹 Nitpick comments (3)
packages/sdk/src/queryBuilder.ts (1)

7-9: Deprecated API Reminder
The class documentation still marks QueryBuilder (and related entities like Namespace) as deprecated with the suggestion to use ClauseBuilder instead. If the goal of the PR is to remove outdated SDK code, consider whether these deprecated components should be removed entirely in a future cleanup or if a migration/deprecation timeline should be documented.

packages/sdk/src/convertToMemberValue.ts (1)

30-36: BigInt Conversion Handling
Using torii.cairoShortStringToFelt on the bigint string representation to produce a Felt252 is a creative solution. Please verify that this conversion handles edge cases correctly (e.g., extremely large numbers) and that the invoked utility function behaves as expected.

packages/sdk/src/clauseBuilder.ts (1)

107-110: Improve Type Safety on Clause Initialization
The constructor uses an @ts-expect-error comment to bypass a type assignment issue for this.clause. Consider initializing this.clause with an explicit cast (e.g., using {} as Clause) to avoid suppressing TypeScript errors. This can improve maintainability and readability by making the intended type explicit.

Proposed Diff:

-    constructor() {
-        // @ts-expect-error It's ok if it's not assignable here.
-        this.clause = {};
-    }
+    constructor() {
+        this.clause = {} as Clause;
+    }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2567249 and 0811fc9.

📒 Files selected for processing (8)
  • packages/sdk/src/__tests__/convertQueryToClause.test.ts (0 hunks)
  • packages/sdk/src/__tests__/convertQueryToEntityKeyClauses.test.ts (0 hunks)
  • packages/sdk/src/clauseBuilder.ts (1 hunks)
  • packages/sdk/src/convertQueryToEntityKeyClauses.ts (0 hunks)
  • packages/sdk/src/convertQuerytoClause.ts (0 hunks)
  • packages/sdk/src/convertToMemberValue.ts (1 hunks)
  • packages/sdk/src/queryBuilder.ts (1 hunks)
  • packages/sdk/src/toriiQueryBuilder.ts (1 hunks)
💤 Files with no reviewable changes (4)
  • packages/sdk/src/tests/convertQueryToEntityKeyClauses.test.ts
  • packages/sdk/src/convertQuerytoClause.ts
  • packages/sdk/src/tests/convertQueryToClause.test.ts
  • packages/sdk/src/convertQueryToEntityKeyClauses.ts
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build
  • GitHub Check: check
🔇 Additional comments (7)
packages/sdk/src/queryBuilder.ts (1)

1-1: Type-Only Import Update
Changing the standard import to a type-only import for QueryType, SchemaType, and SubscriptionQueryType clarifies that these are used solely for type checking and will not be emitted in the runtime JavaScript. This aligns well with TypeScript best practices.

packages/sdk/src/convertToMemberValue.ts (4)

22-24: Number Conversion Check
The conversion for numbers maps the input to a U32 key as expected. Please ensure that existing test cases verify that numbers are correctly processed under all expected conditions.


26-28: Boolean Conversion Confirmation
The conversion for boolean values uses the Bool key, which matches the intended output for Torii primitives. This logic is straightforward and correct.


38-40: String Conversion Logic
Mapping a string value directly to an object with a String key is consistent with the expected output format. Ensure that any consumer of this conversion is prepared to handle the different key names compared to numeric/boolean cases.


42-44: Array Conversion Review
The conversion for arrays is implemented recursively, which is a good approach to ensure consistent conversion for nested structures. Please confirm that deeply nested arrays or mixed type arrays are covered in unit tests.

packages/sdk/src/toriiQueryBuilder.ts (1)

1-2: Type-Only Imports for Clarity
Switching imports for Clause, OrderBy, and Query (as well as for SchemaType) to type-only imports is a solid update that reduces runtime overhead and signals their purpose as annotations only.

packages/sdk/src/clauseBuilder.ts (1)

1-11: Consistency in Import Declarations
The update to use type-only imports for Clause, ComparisonOperator, MemberValue, PatternMatching, and SchemaType (while keeping convertToPrimitive as a regular import) improves clarity. This clearly separates the type information from the runtime values and is consistent with recent updates across the SDK.

@MartianGreed MartianGreed merged commit 54c2391 into main Apr 4, 2025
6 checks passed
@MartianGreed MartianGreed deleted the fix/sdk-clean branch April 4, 2025 13:13
@coderabbitai coderabbitai bot mentioned this pull request May 6, 2025
5 tasks
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.

1 participant