Skip to content
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

fix: update get-starknet-core version #372

Merged
merged 2 commits into from
Jan 14, 2025

Conversation

rsodre
Copy link
Contributor

@rsodre rsodre commented Jan 13, 2025

Introduced changes

  • Update version: get-starknet-core: ^4.0.0

This is the version used by @starknet-react/core v.3.6.2

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

Summary by CodeRabbit

  • Dependency Update
    • Updated get-starknet-core package to version 4.0.0
    • Potential for new features or breaking changes in the package
    • Added TypeScript as a development dependency in the example project
    • Transitioned to a catalog-based approach for several dependencies in the create-burner package
  • New Features
    • Introduced a new request handling method in the BurnerConnector class
    • Updated class implementations to utilize the StarknetWindowObject interface

Copy link

coderabbitai bot commented Jan 13, 2025

Walkthrough

The pull request involves updating the version specification for the get-starknet-core package in the pnpm-workspace.yaml file from version ^3.3.4 to ^4.0.0. Additionally, it introduces TypeScript as a new development dependency in the example-vite-react-sql project and modifies several package dependencies in the create-burner package to reference the catalog instead of specific versions. Furthermore, it updates the BurnerConnector class with a new request method and modifies the implementation of classes to utilize StarknetWindowObject.

Changes

File Change Summary
pnpm-workspace.yaml Updated get-starknet-core package version from ^3.3.4 to ^4.0.0
examples/example-vite-react-sql/package.json Added TypeScript as a new devDependency: "typescript": "^5.6.2"
packages/create-burner/package.json Updated dependencies: "@starknet-react/core": "2.3.0" to "catalog:", "get-starknet-core": "^3.3.3" to "catalog:"
packages/create-burner/src/connectors/burner.ts Added method async request(call: any) and updated ConnectorIcons type to StarknetWindowObject["icon"]
packages/create-burner/src/connectors/dojoBurnerSWO.ts Updated class to implement StarknetWindowObject instead of IStarknetWindowObject
packages/create-burner/src/connectors/dojoPredeployedSWO.ts Updated class to implement StarknetWindowObject instead of IStarknetWindowObject
packages/react/package.json Updated get-starknet-core dependency from "^3.3.3" to "catalog:"

Possibly related issues

  • dojoengine/dojo.js#345: This issue directly matches the package upgrade, requesting an update to get-starknet-core from version 3.3.4 to 4.0.0 to resolve dependency warnings and compatibility issues.

Possibly related PRs

  • feat: use changeset instead of lerna #369: The changes in the main PR involve updating the version of the get-starknet-core package, which is also referenced in the retrieved PR that transitions from using specific versioning to a catalog reference for the same package. This indicates a related change in how the package is managed across different parts of the project.

Poem

🐰 Hop, hop, version upgrade dance!
Starknet core leaps to version four
Dependencies now align with grace
Breaking changes knocking at the door
A rabbit's code refresh, what a score! 🚀

Finishing Touches

  • 📝 Generate Docstrings (Beta)

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?

❤️ 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. (Beta)
  • @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.

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 (1)
pnpm-workspace.yaml (1)

7-7: Consider adding changeset for this update

This version bump might affect consumers of your package. Consider adding a changeset to document the change and its impact.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a50c3d1 and 926ba0a.

📒 Files selected for processing (1)
  • pnpm-workspace.yaml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build
  • GitHub Check: check
🔇 Additional comments (2)
pnpm-workspace.yaml (2)

7-9: Update documentation to reflect version changes

Since this is a major version update, please ensure:

  1. Documentation is updated to reflect any breaking changes
  2. Examples are tested with the new version
  3. Migration steps are documented if needed

This aligns with your PR checklist items for documentation updates.


7-7: Verify compatibility and migration requirements for get-starknet-core v4

The update from v3 to v4 represents a major version bump which may include breaking changes.

Let's verify the compatibility and migration requirements:

@rsodre rsodre force-pushed the get-starknet-core-version branch from 926ba0a to df4b3e4 Compare January 13, 2025 21:08
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: 2

🔭 Outside diff range comments (2)
packages/create-burner/src/connectors/dojoBurnerSWO.ts (2)

Line range hint 44-44: Remove @ts-ignore annotations by implementing proper types.

Multiple @ts-ignore annotations suggest incomplete type safety. Consider implementing proper types for:

  • enable() parameters
  • event handlers (on/off methods)

This will improve type safety and maintainability.

Also applies to: 77-77, 84-84


Implement request method with minimum required functionality

The request method should handle at least the wallet_requestAccounts call type and provide proper error handling for unsupported operations. Here's what needs to be implemented:

async request(call: any) {
    switch (call.type) {
        case "wallet_requestAccounts": {
            return [this._account.address];
        }
        default:
            throw new Error(
                `DojoBurnerStarknetWindowObject: request not implemented [${call.type}]`
            );
    }
}
🔗 Analysis chain

Line range hint 39-41: Implement the request method according to StarknetWindowObject interface.

The empty request method with @ts-ignore suggests incomplete implementation. This method is crucial for wallet functionality.

Let's verify the required implementation:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for request method implementations in similar files
rg -A 10 "async request\(" --type typescript

# Find StarknetWindowObject interface definition
ast-grep --pattern 'interface StarknetWindowObject {
  $$$
  request($$$) {
    $$$
  }
  $$$
}'

Length of output: 180


Script:

#!/bin/bash
# Search for StarknetWindowObject interface definition and request method
rg -t ts "interface StarknetWindowObject" -A 20

# Search for request method implementations
rg -t ts "async request\(" -A 10

# Search in potential starknet-related files
fd -e ts -e js starknet --exec rg -l "request.*\("

Length of output: 2899


Script:

#!/bin/bash
# Search for request call types
rg -t ts "case.*wallet_" -A 2

# Search for any other files importing or using StarknetWindowObject
rg -t ts "StarknetWindowObject"

Length of output: 5115

🧹 Nitpick comments (1)
packages/create-burner/src/connectors/dojoPredeployedSWO.ts (1)

Line range hint 39-41: Consider extracting common wallet functionality.

Both DojoPredeployedStarknetWindowObject and DojoBurnerStarknetWindowObject share similar patterns:

  1. Empty request implementation
  2. @ts-ignore annotations
  3. Similar event handling

Consider creating a base class to reduce code duplication.

Example approach:

abstract class BaseDojoWindowObject implements StarknetWindowObject {
    // Common properties and implementations
    abstract request(call: any): Promise<any>;
    // Other shared methods
}

class DojoBurnerStarknetWindowObject extends BaseDojoWindowObject {
    // Specific implementations
}

class DojoPredeployedStarknetWindowObject extends BaseDojoWindowObject {
    // Specific implementations
}

Also applies to: 44-44, 84-84, 91-91

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 926ba0a and df4b3e4.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (7)
  • examples/example-vite-react-sql/package.json (1 hunks)
  • packages/create-burner/package.json (1 hunks)
  • packages/create-burner/src/connectors/burner.ts (3 hunks)
  • packages/create-burner/src/connectors/dojoBurnerSWO.ts (2 hunks)
  • packages/create-burner/src/connectors/dojoPredeployedSWO.ts (2 hunks)
  • packages/react/package.json (1 hunks)
  • pnpm-workspace.yaml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • pnpm-workspace.yaml
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build
  • GitHub Check: check
🔇 Additional comments (6)
packages/react/package.json (1)

44-44: Verify compatibility with peer dependencies after version update.

The change to use "catalog:" for get-starknet-core aligns with workspace-level version management. However, since this is a major version update (v3 to v4), please ensure compatibility with the peer dependency 'starknet' which is also using "catalog:".

Run this script to check version compatibility:

✅ Verification successful

Dependencies are properly configured with workspace catalog

The workspace catalog ensures compatibility by managing get-starknet-core (^4.0.0) and starknet (6.21.0) versions centrally. The use of "catalog:" references maintains consistent versioning across the workspace.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check peer dependencies compatibility
jq -r '.peerDependencies | to_entries[] | .key + ": " + .value' packages/react/package.json
echo "Workspace versions:"
cat pnpm-workspace.yaml

Length of output: 391

packages/create-burner/package.json (1)

45-47: Verify version compatibility between @starknet-react/core and get-starknet-core.

Both dependencies are now using "catalog:" which aligns with workspace-level version management. Since @starknet-react/core requires get-starknet-core ^4.0.0, this change supports the PR objective.

Run this script to verify version compatibility:

✅ Verification successful

Version compatibility between dependencies is correct

The change to use "catalog:" for both @starknet-react/core and get-starknet-core is safe as @starknet-react/core requires get-starknet-core ^4.0.0 as a peer dependency, which will be properly managed at the workspace level.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check dependencies in @starknet-react/core
echo "Checking @starknet-react/core dependencies:"
npm view @starknet-react/core dependencies --json | jq '."get-starknet-core"'

Length of output: 181


Script:

#!/bin/bash
# Check peer dependencies
echo "Checking @starknet-react/core peer dependencies:"
npm view @starknet-react/core peerDependencies --json

echo -e "\nChecking local package files:"
fd "package.json" --exec cat {} \; | jq -c 'select(.name == "@starknet-react/core" or .name == "get-starknet-core") | {name: .name, version: .version, dependencies, peerDependencies}'

Length of output: 505

examples/example-vite-react-sql/package.json (1)

28-28: LGTM! TypeScript dependency added appropriately.

Adding TypeScript as a devDependency is correct since the project uses TypeScript (as evidenced by the build script using tsc). The version ^5.6.2 is recent and stable.

packages/create-burner/src/connectors/dojoBurnerSWO.ts (1)

1-1: LGTM: Interface update aligns with get-starknet-core v4.

The change from IStarknetWindowObject to StarknetWindowObject correctly implements the new interface from get-starknet-core v4.

Also applies to: 11-11

packages/create-burner/src/connectors/dojoPredeployedSWO.ts (1)

1-1: LGTM: Interface update matches dojoBurnerSWO.ts.

The change to StarknetWindowObject is consistent with the other file.

Also applies to: 11-12

packages/create-burner/src/connectors/burner.ts (1)

2-2: LGTM! Type definition aligned with get-starknet-core.

The update to use StarknetWindowObject["icon"] ensures type consistency with the core library.

Also applies to: 20-21

Comment on lines +105 to +115
async request(call: any) {
switch (call.type) {
case "wallet_requestAccounts": {
return [this._account.address];
}
default:
throw new Error(
`BurnerConnector: request not implemented [${call.type}]`
);
}
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improve type safety and documentation of the request method.

Several improvements are recommended:

  1. Replace any with proper request type from get-starknet-core.
  2. Add JSDoc documentation explaining the method's purpose and parameters.
  3. Consider implementing other standard wallet request types.

Apply this diff to improve the implementation:

+    /**
+     * Handles wallet requests as per the Starknet wallet standard.
+     * @param {StarknetWindowObject['request']['parameters'][0]} call - The request parameters
+     * @returns {Promise<any>} The request result
+     */
-    async request(call: any) {
+    async request(call: StarknetWindowObject['request']['parameters'][0]) {
         switch (call.type) {
             case "wallet_requestAccounts": {
                 return [this._account.address];
             }
+            case "wallet_switchChain": {
+                // TODO: Implement chain switching
+                throw new Error("Chain switching not implemented");
+            }
             default:
                 throw new Error(
-                    `BurnerConnector: request not implemented [${call.type}]`
+                    `BurnerConnector: The request type "${call.type}" is not supported. ` +
+                    `Supported types: wallet_requestAccounts`
                 );
         }
     }

Committable suggestion skipped: line range outside the PR's diff.


💡 Codebase verification

Implement missing wallet standard methods

The BurnerConnector is missing several standard wallet methods that are implemented in the predeployed connector. At minimum, implement:

  • wallet_getPermissions: Required for permission management
  • wallet_requestChainId: Required for network identification
  • wallet_addInvokeTransaction: Required for transaction execution
  • wallet_signTypedData: Required for message signing
🔗 Analysis chain

Verify implementation against Starknet wallet standard.

Let's verify if we're implementing all required wallet methods.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for wallet method implementations in get-starknet-core
rg -A 5 'wallet_[a-zA-Z]+' $(fd -t f -e ts -e js get-starknet-core)

# Search for other burner wallet implementations for comparison
rg -A 5 'class.*extends.*Connector.*{' $(fd -t f -e ts)

Length of output: 19212


Script:

#!/bin/bash
# Search for wallet interface definitions
ast-grep --pattern 'interface $_ {
  $$$
  wallet_$$$
  $$$
}'

# Search for any type definitions related to wallet methods
rg -A 5 'type.*Wallet' 

Length of output: 564


Script:

#!/bin/bash
# Find connector/provider interface files
fd -t f -e ts "(connector|provider|interface)" 

# Search for interface definitions in those files
rg -A 10 "interface.*Connector|interface.*Provider|interface.*Wallet"

# Look for documentation files
fd -t f "README|SPEC|standard" -e md

Length of output: 3115


Script:

#!/bin/bash
# Search for Starknet-related files
fd -t f -e ts "starknet|wallet"

# Search for Starknet-related types and interfaces
rg -A 10 "type.*Starknet|interface.*Starknet|enum.*Starknet"

# Search for wallet method constants or types
rg -A 5 "const.*WALLET_|type.*WALLET_|enum.*Wallet"

Length of output: 889

@MartianGreed MartianGreed merged commit 2847bde into dojoengine:main Jan 14, 2025
5 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Jan 14, 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