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

feat: bump controller version + use controller presets #2430

Merged
merged 2 commits into from
Dec 11, 2024

Conversation

edisontim
Copy link
Collaborator

@edisontim edisontim commented Dec 11, 2024

Summary by CodeRabbit

  • New Features

    • Updated dependency versions for @cartridge/connector and @cartridge/controller.
    • Introduced a new configuration constant preset for the ControllerConnector.
    • Enhanced the instantiation logic of the ControllerConnector based on the environment.
  • Chores

    • Added a new field specifying the package manager and its version in package.json.

Copy link

vercel bot commented Dec 11, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
eternum ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 11, 2024 3:02pm
eternum-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 11, 2024 3:02pm
eternum-landing ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 11, 2024 3:02pm

Copy link
Contributor

coderabbitai bot commented Dec 11, 2024

Walkthrough

The pull request includes updates to several files, primarily focusing on dependency version increments in client/package.json and package.json, as well as modifications to the starknet-provider.tsx file. The dependency versions for @cartridge/connector and @cartridge/controller have been updated from 0.5.4 to 0.5.5. Additionally, the starknet-provider.tsx file has been altered to streamline the instantiation logic of the ControllerConnector, introducing a new constant preset and modifying the configuration based on the environment variable env.VITE_PUBLIC_CHAIN. A new field for the package manager has also been added to package.json.

Changes

File Change Summary
client/package.json Updated dependencies: @cartridge/connector and @cartridge/controller from 0.5.4 to 0.5.5
client/src/hooks/context/starknet-provider.tsx Added constant preset set to "eternum"; modified controller instantiation logic based on env.VITE_PUBLIC_CHAIN
package.json Added new field "packageManager" specifying [email protected] with SHA-512 hash

Sequence Diagram(s)

sequenceDiagram
    participant Env as Environment Variable
    participant Provider as Starknet Provider
    participant Connector as ControllerConnector

    Env->>Provider: Check env.VITE_PUBLIC_CHAIN
    alt Mainnet
        Provider->>Connector: Instantiate without policies
    else Other Chains
        Provider->>Connector: Instantiate with policies (signingPolicy, policies, vrfPolicy)
    end
    Connector->>Provider: Return controller instance
Loading

🐇 "In the garden where we play,
New versions hop in every day.
With presets bright and policies clear,
Our code now sings, oh so dear!
Dependencies dance, and all is right,
In our coding burrow, joy takes flight!" 🐇


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. (Experiment)
  • @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
Contributor

mentatbot bot commented Dec 11, 2024

You are out of MentatBot reviews. Your usage will refresh December 16 at 08:00 AM.

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

🧹 Outside diff range and nitpick comments (1)
client/src/hooks/context/starknet-provider.tsx (1)

23-46: Refactor to reduce configuration duplication

The controller instantiation contains duplicated configuration. Consider extracting common properties into a base configuration object.

 const controller =
+  const baseConfig = {
+    rpc: env.VITE_PUBLIC_NODE_URL,
+    namespace,
+    slot,
+    preset,
+    tokens: {
+      erc20: ["0x0124aeb495b947201f5fac96fd1138e326ad86195b98df6dec9009158a533b49"],
+    },
+    colorMode,
+  };
+
   env.VITE_PUBLIC_CHAIN === "mainnet"
-    ? new ControllerConnector({
-        rpc: env.VITE_PUBLIC_NODE_URL,
-        namespace,
-        slot,
-        preset,
-        tokens: {
-          erc20: ["0x0124aeb495b947201f5fac96fd1138e326ad86195b98df6dec9009158a533b49"],
-        },
-        colorMode,
-      })
-    : new ControllerConnector({
-        rpc: env.VITE_PUBLIC_NODE_URL,
-        namespace,
-        slot,
-        preset,
-        policies: [...signingPolicy, ...policies, vrfPolicy],
-        theme,
-        tokens: {
-          erc20: ["0x0124aeb495b947201f5fac96fd1138e326ad86195b98df6dec9009158a533b49"],
-        },
-        colorMode,
-      });
+    ? new ControllerConnector(baseConfig)
+    : new ControllerConnector({
+        ...baseConfig,
+        policies: [...signingPolicy, ...policies, vrfPolicy],
+        theme,
+      });

Consider moving the hardcoded token address to a constant or environment variable

The ERC20 token address is hardcoded. Consider moving it to a constant or environment variable for better maintainability.

+const ERC20_TOKEN_ADDRESS = "0x0124aeb495b947201f5fac96fd1138e326ad86195b98df6dec9009158a533b49";
+
 const baseConfig = {
   // ...
   tokens: {
-    erc20: ["0x0124aeb495b947201f5fac96fd1138e326ad86195b98df6dec9009158a533b49"],
+    erc20: [ERC20_TOKEN_ADDRESS],
   },
   // ...
 };
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between bbfe2b6 and 2411f7f.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • client/package.json (2 hunks)
  • client/src/hooks/context/starknet-provider.tsx (2 hunks)
  • package.json (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • package.json
🔇 Additional comments (2)
client/src/hooks/context/starknet-provider.tsx (1)

11-11: 🛠️ Refactor suggestion

Consider removing the redundant theme constant

The newly added preset constant appears to serve the same purpose as the existing theme constant, both set to "eternum". Since theme is only used in the non-mainnet configuration while preset is used in both configurations, this suggests a transition from theme to preset.

client/package.json (1)

20-21: Verify compatibility with the updated cartridge packages

The version updates from 0.5.4 to 0.5.5 for both @Cartridge packages should be verified for:

  • Breaking changes
  • Latest stable versions
  • Compatibility between the packages
✅ Verification successful

Let me try to gather more information about these packages by checking the repository for any documentation or changelog files.


Let me try one more search with corrected commands to find any relevant information.


Based on the search results, I can now provide a final response:

Version updates for cartridge packages are appropriate

The version updates to 0.5.5 for both @cartridge/connector and @cartridge/controller are verified to be:

  • The latest stable versions available on npm
  • Compatible with each other, as evidenced by their paired usage in pnpm-lock.yaml
  • A minor version bump (0.5.4 -> 0.5.5) suggesting no breaking changes
  • Already in use together in other parts of the monorepo (as seen in landing package)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for latest versions and changelogs
for pkg in "@cartridge/connector" "@cartridge/controller"; do
  echo "Checking $pkg..."
  # Get latest version from npm
  npm view "$pkg" version
  # Get changelog if available
  npm view "$pkg" changelog
done

Length of output: 449


Script:

#!/bin/bash
# Search for changelog or documentation files related to cartridge packages
fd -i -g 'changelog*' -g 'cartridge*' -g 'packages*' -g 'readme*'

# Check package-lock.json for dependency details
if [ -f package-lock.json ]; then
  echo "Checking package-lock.json for cartridge dependencies..."
  jq '.dependencies | with_entries(select(.key | contains("@cartridge")))' package-lock.json
fi

# Look for any documentation mentioning cartridge versions
rg -i "cartridge.*0\.5\.[45]" --type md --type txt

Length of output: 359


Script:

#!/bin/bash
# Search for files with proper fd syntax
fd -e md -e txt -e json

# Check if package-lock.json exists in client directory
if [ -f client/package-lock.json ]; then
  echo "Checking client/package-lock.json for cartridge dependencies..."
  jq '.dependencies | with_entries(select(.key | contains("@cartridge")))' client/package-lock.json
fi

# Look for any documentation mentioning cartridge packages
rg "@cartridge/(connector|controller)" -A 2 -B 2

Length of output: 9032

@aymericdelab aymericdelab self-requested a review December 11, 2024 15:16
@aymericdelab aymericdelab merged commit 6f7e906 into next Dec 11, 2024
11 of 13 checks passed
@aymericdelab aymericdelab deleted the feat/use-controller-presets branch December 11, 2024 15:16
Copy link

Failed to generate code suggestions for PR

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