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/game client #2656

Merged
merged 5 commits into from
Jan 22, 2025
Merged

Fix/game client #2656

merged 5 commits into from
Jan 22, 2025

Conversation

bob0005
Copy link
Collaborator

@bob0005 bob0005 commented Jan 22, 2025

Summary by CodeRabbit

Release Notes

  • Dependencies

    • Updated Cartridge dependencies to version 0.6.x
  • Code Improvements

    • Enhanced getStructure function to support more flexible entity ID types
    • Modified player name decoding in player retrieval process
    • Simplified army querying logic
  • Configuration

    • Removed explicit color mode settings in Starknet provider
    • Added placeholder policies configuration
  • Minor Updates

    • Minor syntactical adjustments in export statements

Copy link
Contributor

mentatbot bot commented Jan 22, 2025

Hi @bob0005! You need to be added as a user to interact with me. Please ask @ponderingdemocritus to add you on the settings page.

You are receiving this comment because I am set to review all PRs. That is configurable here.

Copy link

vercel bot commented Jan 22, 2025

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 Jan 22, 2025 3:07pm
eternum-docs ❌ Failed (Inspect) Jan 22, 2025 3:07pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
eternum-landing ⬜️ Ignored (Inspect) Visit Preview Jan 22, 2025 3:07pm

Copy link
Contributor

coderabbitai bot commented Jan 22, 2025

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This pull request encompasses changes across multiple files in the client and packages directories. The modifications include updates to environment variable comments, adjustments in the Starknet provider configuration, dependency version upgrades, and refinements in utility functions and hooks. The changes primarily focus on improving type handling, simplifying query logic, and updating library dependencies to a newer version range.

Changes

File Change Summary
client/apps/landing/env.ts Added comments for Ark Marketplace API environment variable schemas
client/apps/landing/src/components/providers/starknet-provider.tsx Removed ColorMode import and added empty policies property to ControllerConnector
client/apps/landing/src/components/ui/sidebar.tsx Added trailing comma in useSidebar export
package.json Updated @cartridge/connector and @cartridge/controller dependencies to ^0.6.x
packages/core/src/utils/structure.ts Modified getStructure function to accept `Entity
packages/react/src/hooks/helpers/use-armies.ts Removed specific conditions from useEntityQuery call
packages/react/src/hooks/helpers/use-entities.ts Changed id handling in usePlayerStructures function
packages/react/src/hooks/helpers/use-players.ts Added shortString import and used decodeShortString for player names

Sequence Diagram

sequenceDiagram
    participant Client as Client Application
    participant Provider as Starknet Provider
    participant Controller as Cartridge Controller
    
    Client->>Provider: Initialize Connection
    Provider->>Controller: Create ControllerConnector
    Provider-->>Controller: Set Empty Policies
    Controller-->>Provider: Connection Established
Loading

Possibly related PRs

Suggested reviewers

  • aymericdelab

Poem

🐰 Hop, hop, through the code we go,
Upgrading versions with a rabbit's glow
Policies empty, types now free
Dependencies dancing with jubilee
A small refactor, a gentle breeze 🌿


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

Failed to generate code suggestions for PR

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 UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4b3c5b3 and 5f5fb45.

📒 Files selected for processing (8)
  • client/apps/landing/env.ts (1 hunks)
  • client/apps/landing/src/components/providers/starknet-provider.tsx (1 hunks)
  • client/apps/landing/src/components/ui/sidebar.tsx (1 hunks)
  • package.json (1 hunks)
  • packages/core/src/utils/structure.ts (1 hunks)
  • packages/react/src/hooks/helpers/use-armies.ts (0 hunks)
  • packages/react/src/hooks/helpers/use-entities.ts (1 hunks)
  • packages/react/src/hooks/helpers/use-players.ts (2 hunks)
💤 Files with no reviewable changes (1)
  • packages/react/src/hooks/helpers/use-armies.ts
✅ Files skipped from review due to trivial changes (2)
  • client/apps/landing/env.ts
  • client/apps/landing/src/components/ui/sidebar.tsx
🔇 Additional comments (5)
packages/react/src/hooks/helpers/use-players.ts (1)

5-5: LGTM! Proper handling of Starknet short strings.

The change correctly uses shortString.decodeShortString for proper decoding of player names from Starknet's short string format.

Let's verify the string handling across the codebase:

Also applies to: 20-24

✅ Verification successful

Short string handling is properly implemented across the codebase

All instances of Starknet short strings are correctly decoded using shortString.decodeShortString(). The implementation is consistent throughout the codebase, with no instances of incorrect string handling found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other instances of toString() on short strings that might need similar fixes
rg -A 2 "toString\(\)" --type ts

Length of output: 32266

packages/core/src/utils/structure.ts (1)

26-26: LGTM! Enhanced type flexibility with proper type guards.

The change improves type handling by:

  1. Supporting both Entity and ID types
  2. Adding proper type guards for safe type handling

Also applies to: 30-30

packages/react/src/hooks/helpers/use-entities.ts (1)

49-49: LGTM! Aligned with structure.ts type improvements.

The removal of Number(id) conversion properly utilizes the enhanced type flexibility introduced in structure.ts.

client/apps/landing/src/components/providers/starknet-provider.tsx (2)

27-27: Verify the empty policies configuration.

The addition of an empty policies object might be insufficient. According to the version upgrade in package.json from 0.5.7 to 0.6.x, there may be new required policy configurations.

Run this script to check the required policies configuration:

✅ Verification successful

Empty policies configuration is valid

The empty policies object is the correct configuration, as evidenced by consistent usage across other ControllerConnector instances in the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for policies usage examples and documentation
# in the codebase to verify the correct configuration

# Look for other ControllerConnector instantiations
rg -A 5 "new ControllerConnector\(" 

# Search for policies-related types or interfaces
ast-grep --pattern 'interface $name {
  $$$
  policies
  $$$
}'

Length of output: 1761


Script:

#!/bin/bash
# Check package version and search for documentation
rg "@cartridge/controller" -A 2 "package.json"

# Look for documentation files
fd -e md -e mdx . | xargs rg -l "policies|ControllerConnector" 

Length of output: 248


Line range hint 1-31: Verify the removal of color mode handling.

The AI summary indicates that ColorMode-related code was removed, but the theme is still being used in the configuration. Let's verify that this doesn't cause any issues.

Run this script to check theme-related dependencies and usage:

✅ Verification successful

ColorMode removal is safe to proceed

The theme configuration remains consistent with the game app, and the landing app has its own theme management system. The removal of ColorMode doesn't affect the ControllerConnector configuration as theme and ColorMode are separate concerns.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify theme handling after ColorMode removal

# Search for ColorMode usage
rg "ColorMode"

# Look for theme-related configurations
rg "theme.*=.*['\"]eternum['\"]"

Length of output: 445


Script:

#!/bin/bash
# Check ControllerConnector implementation for theme and ColorMode handling
ast-grep --pattern 'interface $_ {
  $$$
  theme$_
  $$$
}'

# Also search for any theme-related types or configurations
rg -A 3 "theme.*:.*" --type typescript

Length of output: 137


Script:

#!/bin/bash
# Search for theme-related configurations and types
rg -A 3 "theme.*:.*"

# Look for ColorMode usage with theme configurations
rg -A 5 "ColorMode.*theme"

# Search for controller configuration types
rg -A 5 "interface.*Controller"

Length of output: 6246

Comment on lines +89 to +90
"@cartridge/connector": "^0.6.x",
"@cartridge/controller": "^0.6.x",
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

⚠️ Potential issue

Fix the version range specification while maintaining package coupling

The version range ^0.6.x is non-standard in npm. Since these packages are tightly coupled (as seen in starknet-provider.tsx), they should maintain version alignment using standard semver:

-    "@cartridge/connector": "^0.6.x",
-    "@cartridge/controller": "^0.6.x",
+    "@cartridge/connector": "^0.6.0",
+    "@cartridge/controller": "^0.6.0",
🔗 Analysis chain

Fix the version range specification.

The version range ^0.6.x is non-standard and might cause issues:

  1. It's unclear if x is meant to be a wildcard
  2. npm semver doesn't recognize this format

Apply this diff to fix the version ranges:

-    "@cartridge/connector": "^0.6.x",
-    "@cartridge/controller": "^0.6.x",
+    "@cartridge/connector": "^0.6.0",
+    "@cartridge/controller": "^0.6.0",

Also, since this is a major version upgrade from 0.5.7, please verify compatibility with the new versions.

Run this script to check for breaking changes:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for breaking changes in the new versions

# Fetch release notes or changelogs
curl -s "https://registry.npmjs.org/@cartridge/connector" | jq '.versions["0.6.0"].dist.tarball' -r
curl -s "https://registry.npmjs.org/@cartridge/controller" | jq '.versions["0.6.0"].dist.tarball' -r

# Look for migration guides or breaking changes in the repository
rg -i "breaking.*changes|migration.*guide" README.md docs/

Length of output: 499


Script:

#!/bin/bash
# Search for usage patterns of both packages
echo "=== Searching for import/require patterns ==="
rg -l "@cartridge/connector.*@cartridge/controller|@cartridge/controller.*@cartridge/connector"

echo -e "\n=== Checking for other package.json files with these dependencies ==="
fd package.json --exec grep -l "@cartridge/\(connector\|controller\)"

echo -e "\n=== Verify if these packages are commonly imported together ==="
rg -B2 -A2 "require\(['\"']@cartridge/(connector|controller)['\"']\)|import.*from.*['\"']@cartridge/(connector|controller)['\"']"

Length of output: 1852

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