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

test new import #2654

Merged
merged 3 commits into from
Jan 22, 2025
Merged

test new import #2654

merged 3 commits into from
Jan 22, 2025

Conversation

aymericdelab
Copy link
Collaborator

@aymericdelab aymericdelab commented Jan 22, 2025

Summary by CodeRabbit

Release Notes

  • Configuration Updates

    • Updated environment variables for game slot and version
    • Removed network-specific address configuration files for mainnet, sepolia, and slot
  • Type Changes

    • Modified resource and configuration type definitions to support more flexible data structures
    • Updated address representations from numeric to string types
  • Utility Changes

    • Simplified configuration retrieval methods
    • Removed "local" chain support
    • Streamlined address and manifest loading processes

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

Copy link
Contributor

mentatbot bot commented Jan 22, 2025

Hi @aymericdelab! 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
Contributor

coderabbitai bot commented Jan 22, 2025

Walkthrough

This pull request involves significant configuration and type changes across multiple files in the client and core packages. The changes primarily focus on updating environment variables, removing several JSON configuration files related to addresses and resources, and modifying type definitions. The modifications suggest a refactoring of how network-specific configurations are handled, with a shift towards more flexible type definitions and simplified configuration management.

Changes

File Change Summary
client/apps/game/.env.sepolia Updated VITE_PUBLIC_SLOT from sepolia-rc-17 to eternum and VITE_PUBLIC_GAME_VERSION from "v1.0.0-rc7" to "v0.0.0"
client/apps/game/src/hooks/context/starknet-provider.tsx Modified handling of LORDS and otherResources to explicitly convert addresses to strings
client/public/contracts/common/addresses/ Removed mainnet.json, sepolia.json, and slot.json files containing contract addresses
client/public/resource_addresses/ Removed resource address JSON files for local, mainnet, and sepolia environments
config/utils/utils.ts Updated chain type, modified address and manifest retrieval functions, added getConfigFromNetwork function
packages/core/src/types/common.ts Updated interfaces to allow more flexible type definitions for resources and configuration properties

Sequence Diagram

sequenceDiagram
    participant Config as Configuration Management
    participant Utils as Utility Functions
    participant Network as Network Resolver

    Config->>Utils: Request season addresses
    Utils->>Network: Determine chain type
    Network-->>Utils: Return appropriate addresses
    Utils-->>Config: Provide configuration
Loading

Possibly related PRs

Suggested reviewers

  • bob0005

Poem

🐰 Config changes hop along the way,
Addresses dance, types sway and play,
JSON files vanish like morning dew,
Flexibility blooms, a configuration breakthrough!
Rabbit's code hops with glee today! 🌈


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a2c4bfa and 603f16c.

📒 Files selected for processing (1)
  • client/apps/game/.env.sepolia (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • client/apps/game/.env.sepolia

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

🔭 Outside diff range comments (1)
client/apps/landing/.env.mainnet (1)

Line range hint 1-2: Security: Remove sensitive information from version control.

The file contains sensitive information (private keys and addresses) that should not be committed to version control. Consider:

  1. Moving sensitive values to a local .env file
  2. Using a secrets management service
  3. Providing a template file (e.g., .env.example) with placeholder values
🧹 Nitpick comments (7)
contracts/common/scripts/deploy.sh (2)

Line range hint 1-71: Security: Avoid hardcoded sensitive values.

The script contains several security concerns:

  1. Hardcoded private keys and addresses in environment variables
  2. Disabled fees in the initial deployment (--disable-fee true)
  3. Hardcoded world address

Consider:

  1. Using environment variables or secure secret management for sensitive values
  2. Documenting the security implications of disabled fees
  3. Making the world address configurable through environment variables

Line range hint 1-71: Improve script maintainability and error handling.

The script lacks:

  1. Input validation for critical parameters
  2. Error handling for failed commands
  3. Documentation for required environment setup

Consider adding:

  1. Parameter validation
  2. Error handling with proper exit codes
  3. A README or documentation section explaining the deployment process and prerequisites
client/apps/landing/codegen.ts (1)

7-7: Simplify the schema URL definition.

The URL string concatenation (+ "/graphql") is unnecessary and could be error-prone. Consider using a template literal or including the full URL directly.

-  schema: "https://api.cartridge.gg/x/eternum/torii" + "/graphql",
+  schema: "https://api.cartridge.gg/x/eternum/torii/graphql",
packages/react/src/hooks/helpers/use-rewards.ts (1)

5-5: Consider adding loading and error states.

While the null safety improvements are good, the hook could benefit from providing more information about its state.

Consider enhancing the hook to return a more comprehensive state:

interface PrizePoolState {
  prizePool: bigint;
  isLoading: boolean;
  error: Error | null;
}

export const usePrizePool = (lordsAddress: string | undefined): PrizePoolState => {
  const [state, setState] = useState<PrizePoolState>({
    prizePool: 0n,
    isLoading: false,
    error: null
  });
  // ... rest of the implementation
}

Also applies to: 13-13, 54-54

config/utils/utils.ts (1)

23-34: Consider performance implications of static imports.

The conversion from dynamic to static imports and async to sync functions has several implications:

  1. Increased initial bundle size due to all configurations being loaded upfront
  2. Potential memory overhead from loading unused configurations
  3. Loss of lazy-loading benefits

Consider keeping the async implementation if lazy-loading of configurations is beneficial for performance.

Also applies to: 54-65, 87-101

client/apps/game/src/dojo/sync.ts (1)

216-216: Consider removing or conditionalizing debug logging.

The console.log of eternumConfig might expose sensitive configuration details in production. Consider:

  1. Removing the log statement
  2. Making it conditional based on environment
  3. Sanitizing sensitive data before logging
-  console.log({ eternumConfig });
+  if (process.env.NODE_ENV === 'development') {
+    console.log('Loading eternum config...');
+  }
packages/core/src/modelManager/ConfigManager.ts (1)

35-37: Remove debug logging statements.

The added console.log statements should be removed to avoid polluting production logs.

Apply this diff to remove the debug statements:

-    console.log("setting dojo for config manager");
-
-    console.log({ resourceBuildingCosts: this.resourceBuildingCosts });

Also applies to: 45-46

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f6b88d4 and a2c4bfa.

📒 Files selected for processing (27)
  • client/apps/game/.env.sepolia (1 hunks)
  • client/apps/game/dojoConfig.ts (1 hunks)
  • client/apps/game/src/dojo/sync.ts (1 hunks)
  • client/apps/game/src/hooks/context/starknet-provider.tsx (1 hunks)
  • client/apps/game/src/three/game-renderer.ts (1 hunks)
  • client/apps/game/src/ui/modules/rewards/rewards.tsx (2 hunks)
  • client/apps/game/src/utils/addresses.ts (1 hunks)
  • client/apps/game/src/utils/config.ts (1 hunks)
  • client/apps/game/src/utils/utils.ts (0 hunks)
  • client/apps/game/tsconfig.json (2 hunks)
  • client/apps/game/vite.config.ts (1 hunks)
  • client/apps/landing/.env.mainnet (1 hunks)
  • client/apps/landing/.env.slot (1 hunks)
  • client/apps/landing/codegen.ts (1 hunks)
  • client/public/contracts/common/addresses/mainnet.json (0 hunks)
  • client/public/contracts/common/addresses/sepolia.json (0 hunks)
  • client/public/contracts/common/addresses/slot.json (0 hunks)
  • client/public/resource_addresses/local/resource_addresses.json (0 hunks)
  • client/public/resource_addresses/mainnet/resource_addresses.json (0 hunks)
  • client/public/resource_addresses/sepolia/resource_addresses.json (0 hunks)
  • config/deployer/index.ts (1 hunks)
  • config/utils/environment.ts (0 hunks)
  • config/utils/utils.ts (2 hunks)
  • contracts/common/scripts/deploy.sh (1 hunks)
  • packages/core/src/modelManager/ConfigManager.ts (1 hunks)
  • packages/core/src/types/common.ts (3 hunks)
  • packages/react/src/hooks/helpers/use-rewards.ts (2 hunks)
💤 Files with no reviewable changes (8)
  • client/public/contracts/common/addresses/sepolia.json
  • client/public/resource_addresses/local/resource_addresses.json
  • client/public/resource_addresses/mainnet/resource_addresses.json
  • client/public/resource_addresses/sepolia/resource_addresses.json
  • config/utils/environment.ts
  • client/apps/game/src/utils/utils.ts
  • client/public/contracts/common/addresses/mainnet.json
  • client/public/contracts/common/addresses/slot.json
✅ Files skipped from review due to trivial changes (4)
  • client/apps/game/dojoConfig.ts
  • client/apps/game/src/three/game-renderer.ts
  • client/apps/game/.env.sepolia
  • client/apps/landing/.env.slot
🔇 Additional comments (12)
contracts/common/scripts/deploy.sh (1)

71-71: ⚠️ Potential issue

Environment naming inconsistency detected.

The script uses different environment names:

  • 'eternum-rc1-1' at the start of the script
  • 'eternum' in the deployment creation command
    This inconsistency could lead to deployment issues.

Please standardize the environment name throughout the script. Also verify:

  1. The RPC URL still points to sepolia: https://api.cartridge.gg/x/starknet/sepolia
  2. The config file name torii-sepolia.toml contains references to the old environment
client/apps/landing/codegen.ts (1)

7-7: Verify the new GraphQL endpoint accessibility.

Please ensure that the new eternum GraphQL endpoint is accessible and returns the expected schema.

✅ Verification successful

GraphQL endpoint is accessible and functional
The endpoint successfully returned a complete schema containing all the required game-specific types.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the GraphQL endpoint accessibility and schema

# Test the endpoint with a simple introspection query
curl -X POST \
  -H "Content-Type: application/json" \
  -d '{"query": "query { __schema { types { name } } }"}' \
  "https://api.cartridge.gg/x/eternum/torii/graphql"

Length of output: 31048

client/apps/landing/.env.mainnet (2)

Line range hint 8-9: Review environment consistency.

There seems to be an inconsistency in the environment configuration:

  • VITE_PUBLIC_CHAIN and VITE_PUBLIC_SLOT still reference "sepolia"
  • VITE_PUBLIC_TORII_RELAY has been updated to "eternum"

Please verify if these variables should all reference the same environment.

Also applies to: 13-13


13-13: Verify the new TORII_RELAY endpoint functionality.

Ensure that the new eternum relay endpoint is accessible and functioning as expected.

client/apps/game/src/utils/config.ts (1)

1-1: Verify the Chain type compatibility across the codebase.

The change from NetworkType to Chain type appears to be part of a broader refactoring. Let's verify that this type is consistently used across the codebase.

Also applies to: 5-5

✅ Verification successful

Type usage is correctly implemented across the codebase

The change from NetworkType to Chain type is consistent with the codebase architecture, where:

  • Client applications uniformly use the Chain type
  • Deployment configuration tools maintain NetworkType
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining NetworkType usages that might need updating
rg "NetworkType" --type ts

# Search for Chain type usage to ensure consistency
rg "as Chain" --type ts

Length of output: 2763

client/apps/game/src/utils/addresses.ts (1)

1-1: Verify the @config import path resolution.

The import path has been updated to use the @config alias. Let's verify that this alias is properly configured in the build system.

✅ Verification successful

The @config import path is properly configured

The import path is correctly set up in the Vite configuration and the target module exports the required functionality.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for tsconfig paths configuration
fd tsconfig.json | xargs cat | jq '.compilerOptions.paths'

# Check for vite config alias definition
fd "vite.config.ts" | xargs cat

Length of output: 4470


Script:

#!/bin/bash
# Check if the config utils file exists and contains the exports
fd "utils.ts" -p "config/utils" | xargs cat

# Alternatively, search for the exports directly
ast-grep --pattern 'export const getSeasonAddresses = $_'

Length of output: 4169

config/utils/utils.ts (1)

15-15: Verify impact of removing "local" chain type.

The removal of "local" from the Chain type might break local development environments. Please ensure this change is intentional and that local development workflows have been updated accordingly.

✅ Verification successful

Removal of "local" chain type appears safe

The codebase analysis shows the Chain type modification aligns with the actual supported environments (sepolia, mainnet, slot) as evidenced by the configuration files and usage patterns. No references to a "local" chain type were found in the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for usage of "local" chain type in the codebase
rg -l '"local".*Chain' 

Length of output: 24


Script:

#!/bin/bash
# Search for Chain type usage patterns
rg -l 'Chain.*=|:.*Chain'

# Search for chain-related configuration
fd -e ts -e js -e json . config/ --exec grep -l "chain"

# Search for environment setup files
fd -g '.env*' -g '*.config.*' -g 'setup*' -g 'dev*' --exec grep -l -i "chain\|network"

Length of output: 811

client/apps/game/src/hooks/context/starknet-provider.tsx (1)

18-18: Verify type safety of address conversions.

The explicit toString() calls might be masking underlying type issues. Consider:

  1. Adding type assertions or validation before conversion
  2. Documenting the expected types in comments
  3. Adding error handling for invalid addresses

Also applies to: 20-22

client/apps/game/vite.config.ts (1)

64-64: Verify @config alias usage across the codebase.

The new alias looks good, but ensure all imports are consistently using it.

✅ Verification successful

@config alias usage is correctly implemented

The alias is properly used within the game app, while the landing app appropriately uses relative imports as it's a separate application.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for relative imports that should use @config
rg -l '\.\./\.\./\.\./config/utils/utils'

Length of output: 249


Script:

#!/bin/bash
# Show the actual import statements
echo "=== Relative imports ==="
rg "from.*\.\./\.\./\.\./config/utils/utils" -A 1

echo -e "\n=== @config alias usage ==="
rg "from.*@config" -A 1

Length of output: 1332

client/apps/game/src/ui/modules/rewards/rewards.tsx (1)

39-39: LGTM! Type safety improvements.

The changes enhance type safety by:

  1. Making the undefined state of lordsAddress explicit in the type system
  2. Removing the empty string fallback in favor of passing the actual state to usePrizePool

Also applies to: 49-49

packages/core/src/types/common.ts (1)

26-26: Verify the impact of type changes.

The changes involve significant type modifications:

  1. The resources property now accepts a more flexible array type
  2. Bridge fee recipients changed from ContractAddress (bigint) to string

These changes could affect data handling across the application.

Let's verify the usage of these types:

Also applies to: 490-491

✅ Verification successful

Type changes are properly handled across the codebase

The type modifications are safe:

  • Resources property changes provide more flexibility while maintaining type safety in each usage context
  • Fee recipient type changes are properly handled with appropriate string-to-BigInt conversions where needed
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for potential issues with the type changes

# Test 1: Check for direct usage of the resources property
rg -A 5 "resources: \{" --type ts

# Test 2: Check for bridge fee recipient usage
rg -A 5 "(velords|season_pool)_fee_recipient" --type ts

# Test 3: Check for ContractAddress type usage with these properties
ast-grep --pattern 'ContractAddress($$$)' --lang ts

Length of output: 21105

client/apps/game/tsconfig.json (1)

5-6: LGTM! Import path improvements.

The changes improve the project structure by:

  1. Adding a clear @config path alias
  2. Including the config utils directory in TypeScript compilation

Also applies to: 28-28

Comment on lines 4 to 5
import { logNetwork, saveConfigJsonFromConfigTsFile, type NetworkType } from "../utils/environment";
import { getConfigFromNetwork, getGameManifest, type Chain } from "../utils/utils";
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Resolve type inconsistency between NetworkType and Chain.

The file uses both NetworkType and Chain types for the same environment variable (VITE_PUBLIC_CHAIN). This inconsistency could lead to type-related issues.

Consider standardizing to use either NetworkType or Chain consistently:

-import { logNetwork, saveConfigJsonFromConfigTsFile, type NetworkType } from "../utils/environment";
-import { getConfigFromNetwork, getGameManifest, type Chain } from "../utils/utils";
+import { logNetwork, saveConfigJsonFromConfigTsFile } from "../utils/environment";
+import { getConfigFromNetwork, getGameManifest, type Chain } from "../utils/utils";

Then update the type casting consistently:

-await saveConfigJsonFromConfigTsFile(VITE_PUBLIC_CHAIN! as NetworkType);
-const configuration = await getConfigFromNetwork(VITE_PUBLIC_CHAIN! as NetworkType);
+await saveConfigJsonFromConfigTsFile(VITE_PUBLIC_CHAIN! as Chain);
+const configuration = await getConfigFromNetwork(VITE_PUBLIC_CHAIN! as Chain);

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

@aymericdelab aymericdelab merged commit f8a2dcd into next Jan 22, 2025
6 of 27 checks passed
@aymericdelab aymericdelab deleted the raschel/game branch January 22, 2025 09:13
@coderabbitai coderabbitai bot mentioned this pull request Jan 22, 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.

1 participant