Skip to content

fix: sync #264

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 7 commits into from
Sep 2, 2024
Merged

fix: sync #264

merged 7 commits into from
Sep 2, 2024

Conversation

ponderingdemocritus
Copy link
Contributor

@ponderingdemocritus ponderingdemocritus commented Sep 1, 2024

  • bumps starter to alpha-9
  • fixes sync issue

Summary by CodeRabbit

  • New Features

    • Enhanced synchronization process for entities in the application setup, allowing for improved management of both events and entities.
    • Updated paths for downloading templates and simplified documentation URL for better user access.
    • Introduced a new TypeScript module for managing game entities and interactions, enhancing the structure of the game framework.
    • Streamlined movement direction handling using object representation for better extensibility.
  • Bug Fixes

    • Updated fetching logic to allow for multiple batches of entities to be retrieved, improving data handling.
    • Improved error handling in system calls to ensure UI synchronization with the game state.
  • Documentation

    • Revised instructions for starting the Torii service, reflecting updated configuration parameters.
  • Chores

    • Updated dependency versions for improved functionality and features in the build process.
    • Added base TypeScript configuration for standardized project settings.

Copy link

coderabbitai bot commented Sep 1, 2024

Warning

Rate limit exceeded

@ponderingdemocritus has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 11 minutes and 45 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between 69d0fe1 and 7c03d77.

Walkthrough

The changes involve multiple updates across various files in a project, focusing on enhancing entity synchronization, adjusting TypeScript configurations, and refining function parameters. Key modifications include the introduction of new parameters in system call functions, updates to movement direction handling, and the restructuring of import paths for better modularity. Overall, these changes aim to streamline functionality and maintain alignment with the latest project architecture.

Changes

Files Change Summary
examples/clients/react/react-app/src/App.tsx, examples/clients/react/react-pwa-app/src/App.tsx Updated movement direction handling from enumerated values to object representations for improved clarity and extensibility.
examples/clients/react/react-app/src/dojo/createSystemCalls.ts, examples/clients/react/react-pwa-app/src/dojo/createSystemCalls.ts, examples/clients/react-threejs/src/dojo/createSystemCalls.ts, examples/clients/vue/vue-app/src/dojo/createSystemCalls.ts Enhanced createSystemCalls function by adding a world parameter and changing account parameter types from AccountInterface to Account.
examples/clients/react/react-app/tsconfig.json, examples/clients/react/react-pwa-app/tsconfig.json, examples/clients/react-threejs/tsconfig.json, examples/clients/vue/vue-app/tsconfig.json Reduced TypeScript compiler options and added base configuration inheritance for streamlined management.
examples/clients/react/react-threejs/src/dojo/typescript/contracts.gen.ts, examples/clients/vanilla/phaser/src/dojo/typescript/contracts.gen.ts Introduced new contract generation files defining interactions with smart contracts and exporting necessary types and functions.
examples/clients/vue/vue-app/src/App.vue Updated the moveFun function to enhance type safety and streamline imports for direction handling.
examples/clients/vue/vue-app/src/dojo/setup.ts Modified the setup function to refine client and contract component creation, including changes to error handling and entity fetching logic.
examples/clients/vanilla/phaser/src/scenes/scene-main.ts Changed the type of the dojo property in the SceneMain class and updated movement function calls to use object representations for directions.
examples/clients/vue/vue-app/tsconfig.node.json Removed the moduleResolution property from TypeScript configuration, simplifying module resolution handling.
tsconfig.base.json Created a new base TypeScript configuration file with essential compiler options for project-wide consistency.

Sequence Diagram(s)

sequenceDiagram
    participant A as Client
    participant B as Server
    participant C as Database

    A->>B: Request to move
    B->>C: Update entity position
    C-->>B: Acknowledge position update
    B-->>A: Confirm move success
Loading

🐰 "Oh, what a hop, what a skip,
New worlds await, let’s take a trip!
Syncing events, entities too,
With fresh updates, we’ll leap right through!
Hooray for changes, let’s dance and play,
In our joyful code, we hop all day!" 🐇


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 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.
Early access features: disabled

We are currently testing the following features in early access:

  • Anthropic claude-3-5-sonnet for code reviews: Anthropic claims that the new Claude model has stronger code understanding and code generation capabilities than their previous models. Note: Our default code review model was also updated late last week. Please compare the quality of the reviews between the two models by toggling the early access feature.

Note:

  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.
  • Please join our Discord Community to provide feedback and report issues on the discussion post.

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

Outside diff range, codebase verification and nitpick comments (1)
examples/dojo/dojo-starter/manifests/dev/base/contracts/dojo_starter-actions-7a1c7102.toml (1)

2-3: LGTM! But ensure contract compatibility.

The code changes are approved. The updated class_hash and original_class_hash values indicate a change in the underlying contract. Please ensure that these contract changes are compatible with the rest of the system.

Verify that the updated contract:

  1. Implements all the required interfaces.
  2. Handles all the expected events and actions.
  3. Does not introduce any breaking changes to the existing functionality.
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 60d08ef and a10ad41.

Files ignored due to path filters (1)
  • examples/dojo/dojo-starter/Scarb.lock is excluded by !**/*.lock
Files selected for processing (11)
  • examples/clients/react/react-app/src/App.tsx (1 hunks)
  • examples/clients/react/react-app/src/dojo/setup.ts (3 hunks)
  • examples/dojo/dojo-starter/.github/workflows/test.yaml (1 hunks)
  • examples/dojo/dojo-starter/README.md (1 hunks)
  • examples/dojo/dojo-starter/Scarb.toml (1 hunks)
  • examples/dojo/dojo-starter/dojo_dev.toml (1 hunks)
  • examples/dojo/dojo-starter/manifests/dev/base/contracts/dojo_starter-actions-7a1c7102.toml (1 hunks)
  • examples/dojo/dojo-starter/manifests/dev/base/dojo-world.toml (1 hunks)
  • examples/dojo/dojo-starter/manifests/dev/deployment/manifest.json (3 hunks)
  • examples/dojo/dojo-starter/manifests/dev/deployment/manifest.toml (2 hunks)
  • packages/state/src/recs/index.ts (2 hunks)
Files skipped from review due to trivial changes (3)
  • examples/clients/react/react-app/src/App.tsx
  • examples/dojo/dojo-starter/.github/workflows/test.yaml
  • examples/dojo/dojo-starter/Scarb.toml
Additional comments not posted (16)
examples/dojo/dojo-starter/manifests/dev/base/dojo-world.toml (1)

2-3: Hashes updated. Provide more context on the implications.

The class_hash and original_class_hash values have been updated to the same new hash value, suggesting an update to the class definition or implementation.

Since the other fields in the manifest remain unchanged, it seems that the core structure and functionality of the class are intact.

To better understand the implications of these hash changes, could you please provide more context on:

  1. What specific changes were made to the dojo-world class that led to the hash updates?
  2. How do these changes affect the way the class is identified or interacted with in the broader application context?

This additional context will help ensure that the hash updates are appropriate and don't have any unintended consequences.

examples/dojo/dojo-starter/dojo_dev.toml (1)

23-23: Verify the correctness and implications of updating the world_address.

The change updates the world_address to a new hexadecimal string, which seems valid. Assuming this new address is correct and intended, the change looks good.

However, please verify that:

  1. The new address is indeed the one you intended to use.
  2. Updating to this new address won't cause any unexpected issues or side effects in the application's interactions with the associated blockchain or network environment.
examples/dojo/dojo-starter/README.md (1)

44-44: Verify the implications of the --world parameter change.

The --world parameter value has been updated to 0x3b34889efbdf01f707d5d7421f112e8fb85a42fb6f2e5422c75ce3253148b0e. This change suggests a shift in the target world configuration for the Torii service, which could have implications for its functionality or the data it processes.

Please ensure that:

  1. The new world configuration is intended and has been thoroughly tested.
  2. The change does not introduce any unintended side effects or compatibility issues.
  3. The documentation and any relevant configuration files are updated to reflect this change.

Consider running the following script to verify the usage of the --world parameter across the codebase:

This script searches for the --world parameter in configuration files (YAML, TOML, JSON), Markdown files, and plain text files. Review the results to ensure consistency and identify any potential issues.

examples/clients/react/react-app/src/dojo/setup.ts (4)

10-10: LGTM!

The code changes are approved.


32-37: LGTM!

The code changes are approved.


40-45: LGTM!

The code changes are approved. The new functionality to sync entities is a good addition.


86-86: LGTM!

The code changes are approved.

examples/dojo/dojo-starter/manifests/dev/deployment/manifest.toml (4)

3-4: LGTM!

The changes to the class_hash and original_class_hash values in the [world] section are approved. They align with the PR objectives of updating the contract deployment details.


6-7: LGTM!

The changes to the address and transaction_hash values in the [world] section are approved. They align with the PR objectives of updating the contract deployment details.


26-28: LGTM!

The changes to the address, class_hash, and original_class_hash values in the [[contracts]] section are approved. They align with the PR objectives of updating the contract deployment details.


Line range hint 1-120: File approved!

The changes in the examples/dojo/dojo-starter/manifests/dev/deployment/manifest.toml file have been thoroughly reviewed and are approved. They align with the PR objectives of updating the contract deployment details.

packages/state/src/recs/index.ts (1)

221-225: LGTM!

The code changes are approved. Moving the await client.getEntities call inside the while (continueFetching) loop ensures that entities are fetched repeatedly until the continueFetching condition becomes false. This change supports scenarios where multiple batches of entities need to be retrieved, such as pagination or continuous fetching.

examples/dojo/dojo-starter/manifests/dev/deployment/manifest.json (4)

Line range hint 1-1255: LGTM!

The remaining code changes in the JSON manifest are approved.


1232-1233: LGTM! But verify the correctness of the new deployment details.

The code changes to the address and transaction_hash fields are approved. However, ensure that the new deployment details are correct and match the actual deployment of the world contract.

Run the following script to verify the correctness:

Verification successful

Deployment details are consistent and correctly set.

The address and transaction_hash values are consistently used across multiple configuration files, including manifest.toml, manifest.json, and dojo_dev.toml. This consistency suggests that the deployment details are correctly set for the intended deployment. No issues were found with these values.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of the new world contract deployment details.

# Test: Retrieve the world contract deployment details. Expect: Matching `address` and `transaction_hash`.
fd -e cairo -x grep -A 10 -e $'World::constructor'

Length of output: 49


Script:

#!/bin/bash
# Search for the specific address and transaction_hash in the codebase to find references or validation points.
rg '0x3b34889efbdf01f707d5d7421f112e8fb85a42fb6f2e5422c75ce3253148b0e' -A 5
rg '0x4729b83525f0dddbfce0afd73e0b6a39303de51690efd756691356c21c30067' -A 5

Length of output: 3191


1253-1255: LGTM! But verify the correctness of the new contract deployment details.

The code changes to the address, class_hash, and original_class_hash fields are approved. However, ensure that the new deployment details are correct and match the actual deployment of the contract.

Run the following script to verify the correctness:

Verification successful

Deployment details are verified and consistent.

The address and class_hash values in the manifest.json file are consistent with other configuration files, confirming the correctness of the deployment details.

  • manifest.json and related .toml files contain the expected address and class_hash.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash  
# Description: Verify the correctness of the new contract deployment details.

# Test: Retrieve the contract deployment details. Expect: Matching `address` and `class_hash`.
fd -e cairo -x grep -A 10 -e $'constructor'

Length of output: 42


Script:

#!/bin/bash
# Search for JSON files that might contain deployment details.
fd -e json

# Search for the specific address and class_hash in the JSON files to verify their correctness.
rg '0x5e8df8a235031ba8e66e590a7289d27d7d54c026bcdbda62b791c0a69055225' -A 5
rg '0x7304354bfea03508e0a8beaca98c9580c852a0e350b74dcafb55192c62fa3f4' -A 5

Length of output: 7749


4-5: LGTM! But verify the impact of the world contract changes.

The code changes to the class_hash and original_class_hash fields are approved. However, ensure that the changes to the world contract's implementation or version do not have any unintended side effects.

Run the following script to verify the impact:

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a10ad41 and eb7ab00.

Files selected for processing (1)
  • packages/create-dojo/src/index.ts (2 hunks)
Additional comments not posted (2)
packages/create-dojo/src/index.ts (2)

49-49: LGTM!

The change to the template path reflects the updated project structure and is consistent with the AI-generated summary.


70-70: LGTM!

The simplification of the URL to the main documentation page streamlines user access to resources and is consistent with the AI-generated summary.

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

Outside diff range, codebase verification and nitpick comments (10)
examples/clients/react/react-phaser-example/src/phaser/config/constants.ts (1)

Update References to Removed Direction Enum

The Direction enum has been removed, but there are still multiple references to it across the codebase. These references need to be updated to use the new directionality management system to ensure the code functions correctly. Please address the following locations:

  • examples/clients/react/react-threejs/src/utils.ts
  • examples/clients/vue/vue-app/src/utils/index.ts
  • examples/clients/react/react-pwa-app/src/utils/index.ts
  • examples/clients/react/react-app/src/utils/index.ts
  • examples/clients/react/react-phaser-example/src/dojo/utils/index.ts
  • examples/clients/vue/vue-app/src/App.vue
Analysis chain

Line range hint 1-44: Verify the impact of removing the Direction enum on the codebase.

The Direction enum has been removed from this file. This change may impact any existing references to the Direction enum throughout the code, necessitating updates wherever these constants were utilized.

Run the following script to verify the impact of removing the Direction enum:

If the script yields any results, update those references to use the new directionality management system.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of removing the `Direction` enum on the codebase.

# Test 1: Search for references to the `Direction` enum in TypeScript files.
# Expect: No occurrences of `Direction.Unknown`, `Direction.Up`, `Direction.Down`, `Direction.Left`, or `Direction.Right`.
rg --type ts -w $'Direction.(Unknown|Up|Down|Left|Right)'

# Test 2: Search for references to the `Direction` enum in JavaScript files.
# Expect: No occurrences of `Direction.Unknown`, `Direction.Up`, `Direction.Down`, `Direction.Left`, or `Direction.Right`.
rg --type js -w $'Direction.(Unknown|Up|Down|Left|Right)'

Length of output: 2220

examples/clients/vue/vue-app/src/dojo/DojoContext.tsx (1)

11-83: LGTM!

The DojoContext and DojoProvider component are correctly implemented.

To improve the code readability, consider extracting the useBurnerManager hook call and its properties into a separate variable. For example:

+const burnerManager = useBurnerManager({
+    burnerManager,
+});
+
+const {
+    create,
+    list,
+    get,
+    select,
+    deselect,
+    remove,
+    clear,
+    account,
+    isDeploying,
+    count,
+    copyToClipboard,
+    applyFromClipboard,
+    checkIsDeployed,
+} = burnerManager;
examples/clients/react/react-pwa-app/src/dojo/setup.ts (2)

14-88: Improve the error handling for the burner manager initialization.

Instead of catching and logging the error, consider propagating the error to the caller of the setup function. This allows the caller to handle the error appropriately based on the specific use case.

Apply this diff to improve the error handling:

-    try {
-        await burnerManager.init();
-        if (burnerManager.list().length === 0) {
-            await burnerManager.create();
-        }
-    } catch (e) {
-        console.error(e);
-    }
+    await burnerManager.init();
+    if (burnerManager.list().length === 0) {
+        await burnerManager.create();
+    }

35-35: Avoid using any type assertions.

The contractComponents object is type asserted as any when passed to getSyncEvents and getSyncEntities functions. Type assertions, especially any, should be avoided as they can introduce type safety issues.

Consider properly typing the contractComponents object and updating the getSyncEvents and getSyncEntities functions to accept the correct type instead of using type assertions.

Also applies to: 43-43

examples/clients/vue/vue-app/src/dojo/setup.ts (2)

64-71: Improve error handling in the burner manager initialization.

Consider adding more specific error handling and logging in the catch block when initializing the burner manager. This will help in identifying and debugging issues more effectively.

try {
    await burnerManager.init();
    if (burnerManager.list().length === 0) {
        await burnerManager.create();
    }
} catch (e) {
-   console.error(e);
+   console.error("Error initializing burner manager:", e);
+   // Additional error handling or fallback logic
}

78-80: Add error handling and validation to the publish function.

The publish function in the returned object directly calls toriiClient.publishMessage without any error handling or validation. Consider adding try-catch block and validating the input parameters to ensure robustness.

publish: (typedData: string, signature: ArraySignatureType) => {
+   try {
+       // Validate typedData and signature
+       if (!typedData || !signature) {
+           throw new Error("Invalid input parameters");
+       }
        toriiClient.publishMessage(typedData, signature);
+   } catch (e) {
+       console.error("Error publishing message:", e);
+       // Additional error handling or fallback logic
+   }
},
examples/clients/react/react-phaser-example/src/dojo/typescript/contracts.gen.ts (1)

1-1: Reminder: Do not modify this file manually.

The comment indicates that this file is generated by dojo-bindgen and should not be modified manually. Any manual changes will be overwritten when the file is regenerated.

examples/clients/vanilla/phaser/src/dojo/createSystemCalls.ts (2)

23-77: Consider refactoring the spawn function to improve readability and maintainability.

The spawn function is well-structured and uses appropriate error handling, but there are a few areas that could be improved:

  1. Consider breaking the function down into smaller, more focused functions to improve readability and maintainability.
  2. Move the movesId and positionId variables into the try block to limit their scope, since they are only used within that block.
  3. Remove the Position and Moves overrides only in the finally block, as removing them in both the catch and finally blocks is redundant.

Here's an example of how the function could be refactored:

const addMoveOverride = (entityId: Entity, movesId: string) => {
  Moves.addOverride(movesId, {
    entity: entityId,
    value: {
      player: BigInt(entityId),
      remaining: (getComponentValue(Moves, entityId)?.remaining || 0) + 100,
    },
  });
};

const addPositionOverride = (entityId: Entity, positionId: string) => {
  Position.addOverride(positionId, {
    entity: entityId,
    value: {
      player: BigInt(entityId),
      vec: {
        x: 10 + (getComponentValue(Position, entityId)?.vec.x || 0),
        y: 10 + (getComponentValue(Position, entityId)?.vec.y || 0),
      },
    },
  });
};

const waitForIndexerUpdate = async (account: Account) => {
  await new Promise<void>((resolve) => {
    defineSystem(
      world,
      [Has(Moves), HasValue(Moves, { player: BigInt(account.address) })],
      () => {
        resolve();
      }
    );
  });
};

const spawn = async (account: Account) => {
  const entityId = getEntityIdFromKeys([BigInt(account.address)]) as Entity;

  try {
    const movesId = uuid();
    const positionId = uuid();

    addMoveOverride(entityId, movesId);
    addPositionOverride(entityId, positionId);

    await client.actions.spawn({ account });
    await waitForIndexerUpdate(account);
  } catch (e) {
    console.log(e);
  } finally {
    Position.removeOverride(positionId);
    Moves.removeOverride(movesId);
  }
};

79-103: Consider making minor improvements to the move function for consistency and better error handling.

The move function is generally well-written, but there are a couple of minor improvements that could be made:

  1. Log the actual error message instead of just the error object for more specific error handling.
  2. Return the promise instead of waiting for it to resolve, for consistency with the spawn function.

Here's an example of how the function could be updated:

const move = async (account: Account, direction: Direction) => {
  try {
    await client.actions.move({ account, direction });

    // Return the promise instead of waiting for it to resolve
    return new Promise<void>((resolve) => {
      defineSystem(
        world,
        [Has(Moves), HasValue(Moves, { player: BigInt(account.address) })],
        () => {
          resolve();
        }
      );
    });
  } catch (e) {
    // Log the actual error message
    console.error("Error in move function:", e.message);
    throw e;
  }
};
examples/clients/react/react-threejs/src/dojo/typescript/models.gen.ts (1)

39-39: Use lowercase primitives for consistency.

The file uses String, BigInt, Number, and Boolean types in various places. For consistency, please use lowercase primitives instead:

  • Use string instead of String
  • Use bigint instead of BigInt
  • Use number instead of Number
  • Use boolean instead of Boolean

Apply this diff to fix the primitive types:

-    data: String[];
+    data: string[];
-    pending_word: BigInt;
+    pending_word: bigint;
-    pending_word_len: Number;
+    pending_word_len: number;
-    selector: BigInt;
+    selector: bigint;
-    player: BigInt;
+    player: bigint;
-    remaining: Number;
+    remaining: number;
-    can_move: Boolean;
+    can_move: boolean;
-    player: BigInt;
+    player: bigint;
-    directions: String[];
+    directions: string[];
-    player: BigInt;
+    player: bigint;
-    x: Number;
+    x: number;
-    y: Number;
+    y: number;
-    player: BigInt;
+    player: bigint;

Also applies to: 40-40, 41-41, 51-51, 61-61, 62-62, 64-64, 75-75, 76-76, 85-85, 95-95, 96-96, 105-105

Tools
Biome

[error] 39-39: Don't use 'String' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'string' instead

(lint/complexity/noBannedTypes)

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between eb7ab00 and bef89ba.

Files selected for processing (42)
  • examples/clients/react/react-app/src/App.tsx (3 hunks)
  • examples/clients/react/react-app/src/dojo/createSystemCalls.ts (3 hunks)
  • examples/clients/react/react-phaser-example/src/dojo/createClientComponents.ts (1 hunks)
  • examples/clients/react/react-phaser-example/src/dojo/createNetworkLayer.ts (1 hunks)
  • examples/clients/react/react-phaser-example/src/dojo/createSystemCalls.ts (1 hunks)
  • examples/clients/react/react-phaser-example/src/dojo/setup.ts (4 hunks)
  • examples/clients/react/react-phaser-example/src/dojo/typescript/contracts.gen.ts (1 hunks)
  • examples/clients/react/react-phaser-example/src/dojo/typescript/models.gen.ts (1 hunks)
  • examples/clients/react/react-phaser-example/src/phaser/config/constants.ts (1 hunks)
  • examples/clients/react/react-phaser-example/src/phaser/systems/controls.ts (2 hunks)
  • examples/clients/react/react-pwa-app/src/App.tsx (2 hunks)
  • examples/clients/react/react-pwa-app/src/dojo/DojoContext.tsx (1 hunks)
  • examples/clients/react/react-pwa-app/src/dojo/createClientComponents.ts (1 hunks)
  • examples/clients/react/react-pwa-app/src/dojo/createSystemCalls.ts (2 hunks)
  • examples/clients/react/react-pwa-app/src/dojo/setup.ts (1 hunks)
  • examples/clients/react/react-pwa-app/src/dojo/typescript/contracts.gen.ts (1 hunks)
  • examples/clients/react/react-pwa-app/src/dojo/typescript/models.gen.ts (1 hunks)
  • examples/clients/react/react-pwa-app/src/main.tsx (1 hunks)
  • examples/clients/react/react-threejs/src/dojo/DojoContext.tsx (2 hunks)
  • examples/clients/react/react-threejs/src/dojo/createClientComponents.ts (1 hunks)
  • examples/clients/react/react-threejs/src/dojo/createSystemCalls.ts (2 hunks)
  • examples/clients/react/react-threejs/src/dojo/setup.ts (4 hunks)
  • examples/clients/react/react-threejs/src/dojo/typescript/contracts.gen.ts (1 hunks)
  • examples/clients/react/react-threejs/src/dojo/typescript/models.gen.ts (1 hunks)
  • examples/clients/react/react-threejs/src/gameComponents/Player.tsx (5 hunks)
  • examples/clients/react/react-threejs/src/main.tsx (1 hunks)
  • examples/clients/vanilla/phaser/src/dojo/DojoContext.tsx (1 hunks)
  • examples/clients/vanilla/phaser/src/dojo/createClientComponents.ts (1 hunks)
  • examples/clients/vanilla/phaser/src/dojo/createSystemCalls.ts (1 hunks)
  • examples/clients/vanilla/phaser/src/dojo/setup.ts (2 hunks)
  • examples/clients/vanilla/phaser/src/dojo/typescript/contracts.gen.ts (1 hunks)
  • examples/clients/vanilla/phaser/src/dojo/typescript/models.gen.ts (1 hunks)
  • examples/clients/vanilla/phaser/src/dojo/useDojo.tsx (1 hunks)
  • examples/clients/vanilla/phaser/src/scenes/scene-main.ts (3 hunks)
  • examples/clients/vue/vue-app/src/App.vue (2 hunks)
  • examples/clients/vue/vue-app/src/dojo/DojoContext.tsx (1 hunks)
  • examples/clients/vue/vue-app/src/dojo/createClientComponents.ts (1 hunks)
  • examples/clients/vue/vue-app/src/dojo/createSystemCalls.ts (2 hunks)
  • examples/clients/vue/vue-app/src/dojo/setup.ts (1 hunks)
  • examples/clients/vue/vue-app/src/dojo/typescript/contracts.gen.ts (1 hunks)
  • examples/clients/vue/vue-app/src/dojo/typescript/models.gen.ts (1 hunks)
  • examples/clients/vue/vue-app/src/dojo/useDojo.tsx (1 hunks)
Files skipped from review due to trivial changes (7)
  • examples/clients/react/react-phaser-example/src/dojo/createClientComponents.ts
  • examples/clients/react/react-pwa-app/src/dojo/DojoContext.tsx
  • examples/clients/react/react-pwa-app/src/dojo/createClientComponents.ts
  • examples/clients/react/react-threejs/src/dojo/typescript/contracts.gen.ts
  • examples/clients/vanilla/phaser/src/dojo/createClientComponents.ts
  • examples/clients/vue/vue-app/src/dojo/createClientComponents.ts
  • examples/clients/vue/vue-app/src/dojo/typescript/contracts.gen.ts
Additional context used
Biome
examples/clients/react/react-phaser-example/src/dojo/typescript/models.gen.ts

[error] 39-39: Don't use 'String' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'string' instead

(lint/complexity/noBannedTypes)


[error] 40-40: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)


[error] 41-41: Don't use 'Number' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'number' instead

(lint/complexity/noBannedTypes)


[error] 51-51: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)


[error] 61-61: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)


[error] 62-62: Don't use 'Number' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'number' instead

(lint/complexity/noBannedTypes)


[error] 64-64: Don't use 'Boolean' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'boolean' instead

(lint/complexity/noBannedTypes)


[error] 75-75: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)


[error] 76-76: Don't use 'String' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'string' instead

(lint/complexity/noBannedTypes)


[error] 85-85: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)


[error] 95-95: Don't use 'Number' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'number' instead

(lint/complexity/noBannedTypes)


[error] 96-96: Don't use 'Number' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'number' instead

(lint/complexity/noBannedTypes)


[error] 105-105: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)

examples/clients/react/react-pwa-app/src/dojo/typescript/models.gen.ts

[error] 39-39: Don't use 'String' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'string' instead

(lint/complexity/noBannedTypes)


[error] 40-40: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)


[error] 41-41: Don't use 'Number' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'number' instead

(lint/complexity/noBannedTypes)


[error] 51-51: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)


[error] 61-61: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)


[error] 62-62: Don't use 'Number' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'number' instead

(lint/complexity/noBannedTypes)


[error] 64-64: Don't use 'Boolean' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'boolean' instead

(lint/complexity/noBannedTypes)


[error] 75-75: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)


[error] 76-76: Don't use 'String' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'string' instead

(lint/complexity/noBannedTypes)


[error] 85-85: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)


[error] 95-95: Don't use 'Number' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'number' instead

(lint/complexity/noBannedTypes)


[error] 96-96: Don't use 'Number' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'number' instead

(lint/complexity/noBannedTypes)


[error] 105-105: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)

examples/clients/react/react-threejs/src/dojo/typescript/models.gen.ts

[error] 39-39: Don't use 'String' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'string' instead

(lint/complexity/noBannedTypes)


[error] 40-40: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)


[error] 41-41: Don't use 'Number' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'number' instead

(lint/complexity/noBannedTypes)


[error] 51-51: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)


[error] 61-61: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)


[error] 62-62: Don't use 'Number' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'number' instead

(lint/complexity/noBannedTypes)


[error] 64-64: Don't use 'Boolean' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'boolean' instead

(lint/complexity/noBannedTypes)


[error] 75-75: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)


[error] 76-76: Don't use 'String' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'string' instead

(lint/complexity/noBannedTypes)


[error] 85-85: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)


[error] 95-95: Don't use 'Number' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'number' instead

(lint/complexity/noBannedTypes)


[error] 96-96: Don't use 'Number' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'number' instead

(lint/complexity/noBannedTypes)


[error] 105-105: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)

examples/clients/vanilla/phaser/src/dojo/typescript/models.gen.ts

[error] 39-39: Don't use 'String' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'string' instead

(lint/complexity/noBannedTypes)


[error] 40-40: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)


[error] 41-41: Don't use 'Number' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'number' instead

(lint/complexity/noBannedTypes)


[error] 51-51: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)


[error] 61-61: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)


[error] 62-62: Don't use 'Number' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'number' instead

(lint/complexity/noBannedTypes)


[error] 64-64: Don't use 'Boolean' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'boolean' instead

(lint/complexity/noBannedTypes)


[error] 75-75: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)


[error] 76-76: Don't use 'String' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'string' instead

(lint/complexity/noBannedTypes)


[error] 85-85: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)


[error] 95-95: Don't use 'Number' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'number' instead

(lint/complexity/noBannedTypes)


[error] 96-96: Don't use 'Number' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'number' instead

(lint/complexity/noBannedTypes)


[error] 105-105: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)

examples/clients/vue/vue-app/src/dojo/typescript/models.gen.ts

[error] 39-39: Don't use 'String' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'string' instead

(lint/complexity/noBannedTypes)


[error] 40-40: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)


[error] 41-41: Don't use 'Number' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'number' instead

(lint/complexity/noBannedTypes)


[error] 51-51: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)


[error] 61-61: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)


[error] 62-62: Don't use 'Number' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'number' instead

(lint/complexity/noBannedTypes)


[error] 64-64: Don't use 'Boolean' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'boolean' instead

(lint/complexity/noBannedTypes)


[error] 75-75: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)


[error] 76-76: Don't use 'String' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'string' instead

(lint/complexity/noBannedTypes)


[error] 85-85: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)


[error] 95-95: Don't use 'Number' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'number' instead

(lint/complexity/noBannedTypes)


[error] 96-96: Don't use 'Number' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'number' instead

(lint/complexity/noBannedTypes)


[error] 105-105: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)

Additional comments not posted (95)
examples/clients/vanilla/phaser/src/dojo/useDojo.tsx (1)

4-15: LGTM!

The useDojo hook is implemented correctly:

  • It uses the useContext hook to access the DojoContext.
  • It throws an error if the DojoContext is not available, ensuring that the hook is used within a DojoProvider.
  • It returns an object with setup and account properties from the context, which is a good practice.

The code changes are approved.

examples/clients/vue/vue-app/src/dojo/useDojo.tsx (2)

1-2: LGTM!

The imports are correctly used for the custom hook implementation.


4-15: LGTM!

The custom useDojo hook is correctly implemented:

  • It uses the useContext hook to access the DojoContext.
  • It throws an error if the context is not available, indicating that the hook must be used within a DojoProvider.
  • It returns an object with the necessary properties from the context.
examples/clients/react/react-threejs/src/dojo/createClientComponents.ts (1)

2-2: LGTM!

The import path change for ContractComponents is approved. It aligns with the AI-generated summary, suggesting a potential restructuring of the project's file organization or a shift towards a more type-safe or organized module structure.

examples/clients/react/react-phaser-example/src/dojo/createNetworkLayer.ts (1)

6-6: Verify the functionality of the new setup module.

Ensure that the new setup module imported from ./setup provides the same functionality as the previous module imported from ./generated/setup.

Run the following script to compare the two modules:

If the modules differ significantly, further investigation may be required to ensure the change does not introduce any breaking changes or unintended side effects.

examples/clients/react/react-pwa-app/src/main.tsx (1)

7-7: LGTM! Verify the refactor.

The change in the import path for the setup function looks good. It aligns with the PR objective of fixing a sync issue and updating the starter version.

Please verify that the refactor from using an auto-generated setup module to a manually defined or differently structured setup module is complete and all the necessary changes have been made across the codebase.

You can use the following script to search for any remaining references to the old import path:

Verification successful

Refactor verified successfully.

The search for any remaining references to the old import path ./dojo/generated/setup.ts returned no results, confirming that the refactor was completed correctly and no references to the old path remain in the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for any remaining references to the old import path.

# Test: Search for the old import path. Expect: No results.
rg --type typescript $'./dojo/generated/setup.ts'

Length of output: 83


Script:

#!/bin/bash
# Description: Search for any remaining references to the old import path.

# Test: Search for the old import path in .ts files. Expect: No results.
rg './dojo/generated/setup.ts' --glob '*.ts'

Length of output: 44

examples/clients/react/react-threejs/src/main.tsx (1)

7-7: Verify the correctness of the new import path and ensure proper usage of the setup function.

The import path for the setup function has been changed from ./dojo/generated/setup.ts to ./dojo/setup.ts, indicating a refactoring of the project structure. This change may impact how the setup function is utilized within the application, potentially affecting initialization processes or configurations that rely on this function.

To verify the correctness of the new import path and ensure proper usage of the setup function, run the following script:

Verification successful

The import path and usage of the setup function are correct.

The new import path examples/clients/react/react-threejs/src/dojo/setup.ts exists, confirming the file's correct placement. Additionally, the setup function is being used correctly with the await keyword in another part of the codebase, indicating proper asynchronous usage. No issues were found with the changes.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of the new import path and ensure proper usage of the `setup` function.

# Test 1: Verify that the new import path exists. Expect: The file should exist.
if [ -f "examples/clients/react/react-threejs/src/dojo/setup.ts" ]; then
  echo "Test 1 passed: The new import path exists."
else
  echo "Test 1 failed: The new import path does not exist."
fi

# Test 2: Search for the usage of the `setup` function. Expect: The function should be used correctly.
rg --type typescript -A 5 $'setup\(' | rg --type typescript $'await setup\('
if [ $? -eq 0 ]; then
  echo "Test 2 passed: The `setup` function is being used correctly with the `await` keyword."
else
  echo "Test 2 failed: The `setup` function is not being used correctly with the `await` keyword."
fi

Length of output: 654


Script:

#!/bin/bash
# Description: Verify the correctness of the new import path and ensure proper usage of the `setup` function.

# Test 1: Verify that the new import path exists. Expect: The file should exist.
if [ -f "examples/clients/react/react-threejs/src/dojo/setup.ts" ]; then
  echo "Test 1 passed: The new import path exists."
else
  echo "Test 1 failed: The new import path does not exist."
fi

# Test 2: Search for the usage of the `setup` function. Expect: The function should be used correctly.
rg --glob '*.ts' -A 5 'setup\(' | rg --glob '*.ts' 'await setup\('
if [ $? -eq 0 ]; then
  echo "Test 2 passed: The `setup` function is being used correctly with the `await` keyword."
else
  echo "Test 2 failed: The `setup` function is not being used correctly with the `await` keyword."
fi

Length of output: 691

examples/clients/react/react-phaser-example/src/phaser/systems/controls.ts (8)

18-18: LGTM!

The code change is approved.


25-25: LGTM!

The code change is approved.


32-32: LGTM!

The code change is approved.


39-39: LGTM!

The code change is approved.


46-46: LGTM!

The code change is approved.


53-53: LGTM!

The code change is approved.


60-60: LGTM!

The code change is approved.


67-67: LGTM!

The code change is approved.

examples/clients/react/react-threejs/src/dojo/DojoContext.tsx (3)

3-4: LGTM!

The import statement changes align with the refactoring of the provider management.


24-37: LGTM!

The changes to the DojoProvider component simplify the account creation process and integrate better with the Dojo framework's provider system.


Line range hint 1-88: LGTM!

The changes in the file look good and align with the refactoring of the provider management.

examples/clients/vanilla/phaser/src/dojo/DojoContext.tsx (4)

1-4: LGTM!

The import statements are correctly written and include all the required dependencies for the file.


6-9: LGTM!

The DojoContextType interface is correctly defined and includes the necessary properties for the Dojo context.


13-83: LGTM!

The DojoProvider component is correctly implemented and provides the necessary context for the Dojo engine. It properly handles the setup and management of accounts using the useBurnerManager hook.


1-83: File Approved

The DojoContext.tsx file is well-structured, follows best practices, and provides the necessary context and provider components for the Dojo engine. No further changes or improvements are required.

examples/clients/vue/vue-app/src/dojo/DojoContext.tsx (1)

1-9: LGTM!

The imports and the DojoContextType interface are correctly defined.

examples/clients/react/react-phaser-example/src/dojo/setup.ts (5)

1-10: LGTM!

The changes to the imports improve clarity and remove unused imports. The updated import path for setupWorld aligns with the project structure.


29-31: LGTM!

The creation of dojoProvider using the DojoProvider constructor with the provided configuration arguments looks good.


32-45: LGTM!

The changes to event and entity synchronization using the getSyncEvents and getSyncEntities functions improve clarity and modularity. The emphasis on event synchronization enhances the setup process while preserving entity synchronization.


77-87: LGTM!

The adjustments to the systemCalls property by including world as a parameter align with the setup process. The addition of toriiClient, eventSync, and sync properties to the returned object improves their accessibility for further use.


19-19: Verify the impact of disabling the relay functionality.

Setting relayUrl to an empty string potentially disables relay functionality. Ensure that this change is intended and does not break any existing functionality.

Run the following script to verify the usage of relayUrl:

Verification successful

Consistent setting of relayUrl to an empty string across examples.

The relayUrl is set to an empty string in multiple client setup files, and there is a fallback mechanism in the core configuration file that defaults to LOCAL_RELAY if relayUrl is not provided. This suggests that the change is intentional and should not break functionality. Please ensure that LOCAL_RELAY is correctly configured as the default relay URL.

  • packages/core/src/config/index.ts: Fallback mechanism for relayUrl.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `relayUrl` in the codebase.

# Test: Search for the usage of `relayUrl`. Expect: No unintended usages.
rg --type typescript $'relayUrl'

Length of output: 66


Script:

#!/bin/bash
# Description: Verify the usage of `relayUrl` in TypeScript files.

# Test: Search for the usage of `relayUrl` in all `.ts` files.
rg 'relayUrl' --glob '*.ts'

Length of output: 620

examples/clients/react/react-threejs/src/dojo/setup.ts (5)

1-10: LGTM!

The changes to the import statements are approved. Removing unused imports and adjusting import paths improves clarity and consistency.


19-19: Verify the change to the relayUrl parameter.

The relayUrl parameter has been changed from config.relayUrl to an empty string. Please ensure that this change is intentional and will not cause any issues.


29-44: LGTM!

The changes to the synchronization logic are approved. Restructuring the logic to create the dojoProvider before the event and entity synchronization enhances the logical flow and improves clarity.


77-77: Verify the change to the createSystemCalls function call.

The createSystemCalls function call has been modified to pass world as an argument instead of contractComponents. Please ensure that this change is correct and will not cause any issues.


82-87: LGTM!

The changes to the return object are approved. Including dojoProvider, toriiClient, eventSync, sync, and world in the return object provides more comprehensive access to the various components and entities used in the setup process, enhancing functionality and usability.

examples/clients/vanilla/phaser/src/dojo/setup.ts (7)

1-10: LGTM!

The changes to the import statements are appropriate. The new imports are used in the updated code, and the unused imports have been removed, which helps streamline the codebase.


47-62: LGTM!

The refactoring of the burnerManager creation to utilize the dojoProvider for the RPC provider enhances the integration with the Dojo framework. This change is appropriate and aligns with the architecture of the Dojo framework.


75-85: LGTM!

The changes to the return object of the setup function reflect the new structure of the client components and the addition of the eventSync functionality. These changes are consistent with the updates made throughout the function and enhance the functionality of the setup process.


14-14: LGTM!

The change in the parameter type of the setup function from Config to DojoConfig is consistent with the updates made within the function.


12-12: LGTM!

The removal of the unused IDojo type alias helps streamline the codebase.


12-12: LGTM!

The SetupResult type alias remaining unchanged ensures backward compatibility.


14-21: Verify error handling at the caller level.

The error handling for the creation of the toriiClient has been removed, which simplifies the code. However, it's important to ensure that error handling is done appropriately at the caller level.

Run the following script to verify the error handling:

Verification successful

Error handling verified for setup function in some instances.

The setup function's error handling is confirmed at the caller level in examples/clients/vanilla/phaser/src/main.ts using a .catch block. However, ensure that all instances, especially in React applications, handle errors appropriately, possibly through React's error boundaries or other mechanisms.

  • examples/clients/vanilla/phaser/src/main.ts: Error handling present with .catch.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify error handling for the `setup` function at the caller level.

# Test: Search for the usage of the `setup` function. Expect: Error handling at the caller level.
rg --type typescript -A 10 $'setup\('

Length of output: 73


Script:

#!/bin/bash
# Description: Verify error handling for the `setup` function at the caller level.

# Test: Search for the usage of the `setup` function. Expect: Error handling at the caller level.
rg --type ts -A 10 $'setup\('

Length of output: 10013

examples/clients/react/react-pwa-app/src/dojo/setup.ts (3)

1-11: LGTM!

The import statements are correctly written and follow a consistent naming convention. There are no unused imports.


12-12: LGTM!

The SetupResult type definition is correctly written and improves the type safety of the code.


33-45: Clarify the purpose of the undefined argument in getSyncEvents.

The getSyncEvents function is called with undefined as the third argument. It's unclear what this argument represents and if it's required. Please provide clarification or remove the argument if it's not needed.

examples/clients/vue/vue-app/src/dojo/setup.ts (1)

1-10: LGTM!

The imports are well-organized and cover the necessary dependencies for the setup function.

examples/clients/react/react-phaser-example/src/dojo/typescript/contracts.gen.ts (1)

16-31: LGTM!

The code changes are approved.

examples/clients/react/react-pwa-app/src/dojo/typescript/contracts.gen.ts (3)

10-86: LGTM!

The setupWorld function is implemented correctly and follows the expected structure. It sets up the contract interactions by defining an inner actions function and returning it as a property of the exported object.


16-31: LGTM!

The spawn function is implemented correctly. It executes a contract call with the specified parameters and includes appropriate error handling and logging.


34-56: LGTM!

The move function is implemented correctly. It executes a contract call with the specified parameters, including the index of the Direction type in the calldata. It also includes appropriate error handling and logging.

examples/clients/vanilla/phaser/src/dojo/typescript/contracts.gen.ts (3)

1-3: Do not modify this file manually.

The comment indicates that this file is generated by dojo-bindgen and should not be manually modified. Any manual changes will be overwritten when the file is regenerated.


16-31: LGTM!

The code changes are approved.


34-56: LGTM!

The code changes are approved.

examples/clients/react/react-app/src/dojo/createSystemCalls.ts (2)

14-14: LGTM!

The code changes are approved.


83-83: Simplification of the move function looks good, but please verify the impact of the removed logic.

The code changes that simplify the move function by removing the logic for updating position and moves state before executing the move action are approved.

However, please verify the following:

  • The removed logic for updating position and moves state is not required.
  • The calling code handles the state updates correctly.
examples/clients/vue/vue-app/src/dojo/createSystemCalls.ts (4)

17-22: LGTM!

The changes to the function signature are approved. The additional world parameter and the reordering of parameters improve the function.


28-35: LGTM!

The change to dynamically update the remaining value based on the existing value is approved. This improves the logic and allows for dynamic updates.


38-48: LGTM!

The change to update the vec property by adding the current position values is approved. This improves the movement logic by considering the current position.


51-68: LGTM!

The changes to the error handling and synchronization logic in the spawn and move functions are approved. The removal of redundant override removal and the addition of waiting for the indexer to update the entity improve the code and keep the UI in sync with the actual state.

Also applies to: 81-99

examples/clients/react/react-pwa-app/src/dojo/createSystemCalls.ts (6)

18-21: LGTM!

The changes to the createSystemCalls function signature are approved.


23-46: LGTM!

The changes to the spawn function are approved. The updated logic for the Moves and Position components improves the game state management.


55-68: LGTM!

The changes to the spawn function's error handling are approved. Waiting for the indexer to synchronize the UI with the actual state improves the user experience.


79-79: LGTM!

The change to the move function signature is approved.


86-99: LGTM!

The changes to the move function's logic are approved. Waiting for the indexer to synchronize the UI with the actual state improves the user experience.


Line range hint 1-110: File Approved

The changes in the examples/clients/react/react-pwa-app/src/dojo/createSystemCalls.ts file are approved. The modifications improve the game state management and user experience.

examples/clients/react/react-threejs/src/dojo/createSystemCalls.ts (2)

23-68: LGTM!

The code changes in the spawn function are consistent with the provided summary and enhance the game mechanics. The changes include:

  • Updating the function signature to use Account instead of AccountInterface.
  • Altering the logic for setting the Moves component to calculate the remaining value dynamically.
  • Computing the Position component's vec value based on the current position for incremental updates.

79-99: LGTM!

The code changes in the move function are consistent with the provided summary and improve the functionality and user experience. The changes include:

  • Updating the function signature to use Account instead of AccountInterface.
  • Streamlining the logic for updating the Moves component by removing the need for temporary IDs for overrides.
  • Adjusting the handling of the transaction to wait for the indexer to update the entity, keeping the UI in sync with the actual game state.
examples/clients/react/react-phaser-example/src/dojo/createSystemCalls.ts (4)

1-14: LGTM!

The updated imports are necessary for the changes made in the file.


20-21: LGTM!

The updated function signature is consistent with the list of alterations provided and is necessary for the changes made in the file.


23-77: LGTM!

The changes in the spawn function are well-implemented and provide the following benefits:

  • The change from AccountInterface to Account is consistent with the list of alterations provided.
  • The addition of overrides for Moves and Position components enhances the dynamic interaction of entities in the game.
  • The refined error handling improves resource management and prevents potential memory leaks.

Line range hint 79-103: LGTM!

The changes in the move function are well-implemented and provide the following benefits:

  • The change from AccountInterface to Account is consistent with the list of alterations provided.
  • The promise-based system ensures that the UI remains in sync with the underlying data.
examples/clients/vue/vue-app/src/App.vue (2)

4-8: LGTM!

The changes to the import statements are approved. Importing Direction from ./dojo/typescript/models.gen.ts instead of ./utils improves the organization and clarity of the code.


37-37: LGTM!

The change to the moveFun function's parameter type is approved. Updating the type from any to Direction enhances type safety and improves the overall robustness of the code.

examples/clients/react/react-pwa-app/src/App.tsx (4)

122-123: LGTM!

The code changes are approved. The change from using direction constants to objects containing a type property enhances the clarity and potential extensibility of the direction handling in the application.


133-134: LGTM!

The code changes are approved. The change from using direction constants to objects containing a type property enhances the clarity and potential extensibility of the direction handling in the application.


147-147: Verify the missing position check.

Unlike the code segments for moving up and left, there is no condition checking the position of the account before calling the move function when moving down. This might allow the account to move beyond the bottom border of the world.

Run the following script to verify if there are any checks for the bottom border of the world:


140-140: Verify the missing position check.

Unlike the code segments for moving up and left, there is no condition checking the position of the account before calling the move function when moving right. This might allow the account to move beyond the right border of the world.

Run the following script to verify if there are any checks for the right border of the world:

examples/clients/vanilla/phaser/src/scenes/scene-main.ts (4)

3-4: LGTM!

The code changes are approved.


142-142: See the previous comment for verifying the usage of the move method across the codebase.

Also applies to: 148-148, 154-154


136-136: Verify the usage of the move method across the codebase.

The method call to this.dojo.systemCalls.move has been updated to replace the Direction enum with an object representation. Ensure that all usages of the move method are updated to match the new object representation.

Run the following script to verify the usage:

Verification successful

Verification successful: The move method uses the new object representation.

The move method has been consistently updated to use the new object representation with a type property in the scene-main.ts file. The directions "Up", "Down", "Left", and "Right" are all correctly represented. No instances of the old Direction enum were found.

  • examples/clients/vanilla/phaser/src/scenes/scene-main.ts: Lines using the new object representation for movement directions.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all usages of the `move` method match the new object representation.

# Test: Search for the method usage. Expect: Only occurrences of the new object representation.
rg --type typescript -A 5 $'this.dojo.systemCalls.move\(.*\{.*type:.*\}.*\)'

Length of output: 112


Script:

#!/bin/bash
# Description: Verify all usages of the `move` method match the new object representation.

# Test: Search for the method usage without specifying the file type.
rg -A 5 $'this.dojo.systemCalls.move\(.*\{.*type:.*\}.*\)'

Length of output: 2495


6-6: Verify the usage of the dojo property across the codebase.

The type of the dojo property has been changed from IDojo to SetupResult. Ensure that all usages of the dojo property are updated to match the new type.

Run the following script to verify the usage:

examples/clients/react/react-app/src/App.tsx (4)

154-155: The previous comment for line range 143-144 also applies to this code segment.


161-161: The previous comments for line ranges 143-144 and 154-155 also apply to this code segment.


168-168: The previous comments for line ranges 143-144, 154-155, and 161-161 also apply to this code segment.


143-144: Verify the impact of the change in the data structure passed to the move function.

Ensure that the move function and other parts of the codebase are updated to handle the new data structure { type: "Up" } instead of the enum value Direction.Up.

Run the following script to verify the usage of the move function:

Verification successful

The change to the move function's argument structure is consistently applied across the codebase.

The move function is being called with the new data structure { type: "Up" } and similar objects for other directions in various files. This indicates that the codebase has been updated to handle this change correctly. No further action is required.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the `move` function in the codebase.

# Test: Search for the `move` function calls. Expect: The arguments to match the new data structure.
rg --type typescript -A 5 $'move\('

Length of output: 71


Script:

#!/bin/bash
# Description: Verify the usage of the `move` function in the codebase.

# Test: Search for the `move` function calls without specifying a file type.
rg -A 5 $'move\('

Length of output: 22363

examples/clients/react/react-pwa-app/src/dojo/typescript/models.gen.ts (2)

1-3: Acknowledge the generated nature of the file.

This file is generated by dojo-bindgen and should not be manually modified. Skipping further review comments.


39-41: Ignore static analysis hints for uppercase types.

The usage of String, BigInt, Number, and Boolean types is flagged by static analysis, suggesting using lowercase primitives instead. However, since this file is generated by dojo-bindgen and is not meant to be manually modified, these hints can be safely ignored in this context. The consistency of the generated code should be maintained.

Also applies to: 51-51, 61-61, 62-62, 64-64, 75-76, 85-85, 95-96, 105-105

Tools
Biome

[error] 39-39: Don't use 'String' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'string' instead

(lint/complexity/noBannedTypes)


[error] 40-40: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)


[error] 41-41: Don't use 'Number' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'number' instead

(lint/complexity/noBannedTypes)

examples/clients/react/react-threejs/src/gameComponents/Player.tsx (10)

10-10: LGTM!

The import statement change is approved.


21-21: LGTM!

The changes to the hoveredTile state declaration are approved. They improve type safety and clarity.


51-54: LGTM!

The changes to the BlueCell interface declaration are approved. They improve code clarity.


56-56: LGTM!

The change to the blueCellsAroundPlayer array declaration is approved. It improves type safety.


58-58: LGTM!

The change to the direction property is approved. It improves code clarity and consistency.


66-66: LGTM!

The change to the direction property is approved. It improves code clarity and consistency.


74-74: LGTM!

The change to the direction property is approved. It improves code clarity and consistency.


82-82: LGTM!

The change to the direction property is approved. It improves code clarity and consistency.


137-137: LGTM!

The change to the setHoveredTile call is approved. It aligns with the new initialization approach for the hoveredTile state.


185-185: LGTM!

The change to the setHoveredTile call is approved. It aligns with the new initialization approach for the hoveredTile state.

Comment on lines +24 to +45
const contractComponents = defineContractComponents(world);

// create client components
const { models: clientModels } = models({ contractModels });
const clientComponents = createClientComponents({ contractComponents });

// fetch all existing entities from torii
let sync = null;
try {
sync = await getSyncEntities(
toriiClient,
contractModels as any,
[],
1000
);
} catch (e) {
console.error("Failed to fetch sync:", e);
throw e;
}
// create dojo provider
const dojoProvider = new DojoProvider(config.manifest, config.rpcUrl);

let client = null;
try {
client = await setupWorld(
new DojoProvider(config.manifest, config.rpcUrl),
config
);
} catch (e) {
console.error("Failed to create client:", e);
throw e;
}
// Sync all events
const eventSync = getSyncEvents(
toriiClient,
contractComponents as any,
undefined,
[]
);

const rpcProvider = new RpcProvider({
nodeUrl: config.rpcUrl,
});
// Sync all entities
const sync = await getSyncEntities(
toriiClient,
contractComponents as any,
[]
);
Copy link

Choose a reason for hiding this comment

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

LGTM with a minor suggestion!

The changes simplify the code and enhance the clarity of the component creation process. The altered logic for fetching existing entities streamlines the flow of the function.

Consider moving the entity sync logic to the end of the function for better readability:

- // Sync all entities
- const sync = await getSyncEntities(
-     toriiClient,
-     contractComponents as any,
-     []
- );

  // setup world
  const client = await setupWorld(dojoProvider);

  // create burner manager
  const burnerManager = new BurnerManager({
      masterAccount: new Account(
          {
              nodeUrl: config.rpcUrl,
          },
          config.masterAddress,
          config.masterPrivateKey
      ),
      accountClassHash: config.accountClassHash,
      rpcProvider: dojoProvider.provider,
      feeTokenAddress: config.feeTokenAddress,
  });

  try {
      await burnerManager.init();
      if (burnerManager.list().length === 0) {
          await burnerManager.create();
      }
  } catch (e) {
      console.error(e);
  }

+ // Sync all entities
+ const sync = await getSyncEntities(
+     toriiClient,
+     contractComponents as any,
+     []
+ );

  return {
      client,
      clientComponents,
      contractComponents,
      systemCalls: createSystemCalls({ client }, clientComponents, world),
      publish: (typedData: string, signature: ArraySignatureType) => {
          toriiClient.publishMessage(typedData, signature);
      },
      config,
      dojoProvider,
      account: burnerManager.account as Account,
      toriiClient,
      eventSync,
      sync,
  };

Committable suggestion was skipped due to low confidence.

"dojo_starter"
);
} catch (error) {
console.error("Error executing spawn:", error);
Copy link

Choose a reason for hiding this comment

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

Fix the error message.

The error message is incorrect and should be updated to reflect the move function.

Apply this diff to fix the error message:

-console.error("Error executing spawn:", error);
+console.error("Error executing move:", error);
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
console.error("Error executing spawn:", error);
console.error("Error executing move:", error);

"dojo_starter"
);
} catch (error) {
console.error("Error executing spawn:", error);
Copy link

Choose a reason for hiding this comment

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

Fix the error message.

The error message is incorrect and should be updated to reflect the world function.

Apply this diff to fix the error message:

-console.error("Error executing spawn:", error);
+console.error("Error executing world:", error);
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
console.error("Error executing spawn:", error);
console.error("Error executing world:", error);

Comment on lines +59 to +74
const world = async (props: { account: Account }) => {
try {
return await provider.execute(
props.account,
{
contractName: contract_name,
entrypoint: "world",
calldata: [],
},
"dojo_starter"
);
} catch (error) {
console.error("Error executing spawn:", error);
throw error;
}
};
Copy link

Choose a reason for hiding this comment

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

Fix the error message in the catch block.

The error message in the catch block of the world function is incorrect. It should be updated to reflect the correct function name.

Apply this diff to fix the error message:

-console.error("Error executing spawn:", error);
+console.error("Error executing world:", error);
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const world = async (props: { account: Account }) => {
try {
return await provider.execute(
props.account,
{
contractName: contract_name,
entrypoint: "world",
calldata: [],
},
"dojo_starter"
);
} catch (error) {
console.error("Error executing spawn:", error);
throw error;
}
};
const world = async (props: { account: Account }) => {
try {
return await provider.execute(
props.account,
{
contractName: contract_name,
entrypoint: "world",
calldata: [],
},
"dojo_starter"
);
} catch (error) {
console.error("Error executing world:", error);
throw error;
}
};

Comment on lines +59 to +74
const world = async (props: { account: Account }) => {
try {
return await provider.execute(
props.account,
{
contractName: contract_name,
entrypoint: "world",
calldata: [],
},
"dojo_starter"
);
} catch (error) {
console.error("Error executing spawn:", error);
throw error;
}
};
Copy link

Choose a reason for hiding this comment

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

Fix the error message in the catch block.

The error message in the catch block is incorrect. It should be updated to reflect the correct function name.

Apply this diff to fix the error message:

-console.error("Error executing spawn:", error);
+console.error("Error executing world:", error);
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const world = async (props: { account: Account }) => {
try {
return await provider.execute(
props.account,
{
contractName: contract_name,
entrypoint: "world",
calldata: [],
},
"dojo_starter"
);
} catch (error) {
console.error("Error executing spawn:", error);
throw error;
}
};
const world = async (props: { account: Account }) => {
try {
return await provider.execute(
props.account,
{
contractName: contract_name,
entrypoint: "world",
calldata: [],
},
"dojo_starter"
);
} catch (error) {
console.error("Error executing world:", error);
throw error;
}
};

Comment on lines +39 to +41
data: String[];
pending_word: BigInt;
pending_word_len: Number;
Copy link

Choose a reason for hiding this comment

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

Use lowercase primitives for consistency.

The static analysis tool flagged the usage of String, BigInt, Number, and Boolean types, suggesting using lowercase primitives for consistency.

Apply this diff to fix the issues:

-    data: String[];
+    data: string[];
-    pending_word: BigInt;
+    pending_word: bigint;
-    pending_word_len: Number;
+    pending_word_len: number;
-    selector: BigInt;
+    selector: bigint;
-    player: BigInt;
+    player: bigint;
-    remaining: Number;
+    remaining: number;
-    can_move: Boolean;
+    can_move: boolean;
-    player: BigInt;
+    player: bigint;
-    directions: String[];
+    directions: string[];
-    player: BigInt;
+    player: bigint;
-    x: Number;
+    x: number;
-    y: Number;
+    y: number;
-    player: BigInt;
+    player: bigint;

Also applies to: 51-51, 61-62, 64-64, 75-76, 85-85, 95-96, 105-105

Tools
Biome

[error] 39-39: Don't use 'String' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'string' instead

(lint/complexity/noBannedTypes)


[error] 40-40: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)


[error] 41-41: Don't use 'Number' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'number' instead

(lint/complexity/noBannedTypes)

Comment on lines +38 to +42
export interface ByteArray {
data: String[];
pending_word: BigInt;
pending_word_len: Number;
}
Copy link

Choose a reason for hiding this comment

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

Use lowercase primitives for consistency.

The static analysis tool has flagged the usage of String, BigInt, Number, and Boolean types in the interface definitions. For consistency, it is recommended to use lowercase primitives instead.

Apply this diff to fix the issues:

 export interface ByteArray {
-    data: String[];
+    data: string[];
-    pending_word: BigInt;
+    pending_word: bigint;
-    pending_word_len: Number;
+    pending_word_len: number;
 }

 export interface Moves {
-    player: BigInt;
+    player: bigint;
-    remaining: Number;
+    remaining: number;
-    can_move: Boolean;
+    can_move: boolean;
 }

 export interface DirectionsAvailable {
-    player: BigInt;
+    player: bigint;
-    directions: String[];
+    directions: string[];
 }

 export interface Moved {
-    player: BigInt;
+    player: bigint;
 }

 export interface Vec2 {
-    x: Number;
+    x: number;
-    y: Number;
+    y: number;
 }

 export interface Position {
-    player: BigInt;
+    player: bigint;
     vec: Vec2;
 }

Also applies to: 60-65, 74-77, 84-87, 93-97, 103-107

Tools
Biome

[error] 39-39: Don't use 'String' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'string' instead

(lint/complexity/noBannedTypes)


[error] 40-40: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)


[error] 41-41: Don't use 'Number' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'number' instead

(lint/complexity/noBannedTypes)


// Type definition for `core::byte_array::ByteArray` struct
export interface ByteArray {
data: String[];
Copy link

Choose a reason for hiding this comment

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

Use lowercase primitives for consistency.

The static analysis tool has flagged the usage of String, Number, Boolean, and BigInt types at multiple places in the file. For consistency, it is recommended to use lowercase primitives instead.

Please replace the following types with their lowercase counterparts:

  • Stringstring
  • Numbernumber
  • Booleanboolean
  • BigIntbigint

Do you want me to make these changes and submit a pull request?

Also applies to: 40-40, 41-41, 51-51, 61-61, 62-62, 64-64, 75-75, 76-76, 85-85, 95-95, 96-96, 105-105

Tools
Biome

[error] 39-39: Don't use 'String' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'string' instead

(lint/complexity/noBannedTypes)

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

Outside diff range, codebase verification and nitpick comments (2)
examples/clients/vanilla/phaser/src/dojo/setup.ts (2)

24-24: Lack of Error Handling for defineContractComponents

The function defineContractComponents is used in multiple files without any apparent error handling. This confirms the concern that error handling has been removed or is missing. It is important to ensure that potential errors are handled appropriately to prevent runtime issues.

  • Consider adding error handling around the invocation of defineContractComponents to manage any potential exceptions or errors that may arise during its execution.
Analysis chain

Verify the error handling for the creation of the contract components.

The error handling for the creation of the contract components has been removed. While this simplifies the code, it is important to ensure that any potential errors are still handled appropriately.

Please run the following script to verify the error handling:

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the error handling for the creation of the contract components.

# Test: Search for error handling related to the contract components. Expect: Relevant error handling code.
rg --type typescript -A 5 $'defineContractComponents'

Length of output: 87


Script:

#!/bin/bash
# Description: Verify the error handling for the creation of the contract components.

# Test: Search for error handling related to the contract components. Expect: Relevant error handling code.
rg --type ts -A 5 $'defineContractComponents'

Length of output: 14501


16-21: Potential Issue: Missing Error Handling for toriiClient Creation

The creation of the toriiClient in examples/clients/vanilla/phaser/src/dojo/setup.ts lacks error handling, which could lead to unhandled exceptions if the client creation fails. Consider adding appropriate error handling to ensure robustness.

  • File: examples/clients/vanilla/phaser/src/dojo/setup.ts
Analysis chain

Verify the error handling for the creation of the toriiClient.

The error handling for the creation of the toriiClient has been simplified by removing the try-catch block. While this improves the readability of the code, it is important to ensure that any potential errors are still handled appropriately.

Please run the following script to verify the error handling:

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the error handling for the creation of the `toriiClient`.

# Test: Search for error handling related to the `toriiClient`. Expect: Relevant error handling code.
rg --type typescript -A 5 $'toriiClient'

Length of output: 74


Script:

#!/bin/bash
# Description: Verify the error handling for the creation of the `toriiClient`.

# Test: Search for error handling related to the `toriiClient`. Expect: Relevant error handling code.
rg --type ts -A 5 $'toriiClient'

Length of output: 17110

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between bef89ba and 69d0fe1.

Files selected for processing (21)
  • examples/clients/react/react-app/src/App.tsx (4 hunks)
  • examples/clients/react/react-app/src/dojo/createSystemCalls.ts (4 hunks)
  • examples/clients/react/react-app/src/dojo/typescript/contracts.gen.ts (1 hunks)
  • examples/clients/react/react-app/tsconfig.json (1 hunks)
  • examples/clients/react/react-pwa-app/src/App.tsx (3 hunks)
  • examples/clients/react/react-pwa-app/src/dojo/createSystemCalls.ts (2 hunks)
  • examples/clients/react/react-pwa-app/src/dojo/typescript/contracts.gen.ts (1 hunks)
  • examples/clients/react/react-pwa-app/tsconfig.json (1 hunks)
  • examples/clients/react/react-threejs/src/dojo/createSystemCalls.ts (2 hunks)
  • examples/clients/react/react-threejs/src/dojo/typescript/contracts.gen.ts (1 hunks)
  • examples/clients/react/react-threejs/src/gameComponents/Players.tsx (1 hunks)
  • examples/clients/react/react-threejs/tsconfig.json (1 hunks)
  • examples/clients/vanilla/phaser/src/dojo/createSystemCalls.ts (1 hunks)
  • examples/clients/vanilla/phaser/src/dojo/setup.ts (2 hunks)
  • examples/clients/vanilla/phaser/src/dojo/typescript/contracts.gen.ts (1 hunks)
  • examples/clients/vanilla/phaser/src/scenes/scene-main.ts (4 hunks)
  • examples/clients/vue/vue-app/src/App.vue (4 hunks)
  • examples/clients/vue/vue-app/src/dojo/createSystemCalls.ts (2 hunks)
  • examples/clients/vue/vue-app/tsconfig.json (1 hunks)
  • examples/clients/vue/vue-app/tsconfig.node.json (1 hunks)
  • tsconfig.base.json (1 hunks)
Files skipped from review due to trivial changes (7)
  • examples/clients/react/react-app/src/dojo/typescript/contracts.gen.ts
  • examples/clients/react/react-app/tsconfig.json
  • examples/clients/react/react-threejs/src/dojo/typescript/contracts.gen.ts
  • examples/clients/react/react-threejs/src/gameComponents/Players.tsx
  • examples/clients/react/react-threejs/tsconfig.json
  • examples/clients/vue/vue-app/tsconfig.node.json
  • tsconfig.base.json
Files skipped from review as they are similar to previous changes (10)
  • examples/clients/react/react-app/src/App.tsx
  • examples/clients/react/react-app/src/dojo/createSystemCalls.ts
  • examples/clients/react/react-pwa-app/src/App.tsx
  • examples/clients/react/react-pwa-app/src/dojo/createSystemCalls.ts
  • examples/clients/react/react-pwa-app/src/dojo/typescript/contracts.gen.ts
  • examples/clients/vanilla/phaser/src/dojo/createSystemCalls.ts
  • examples/clients/vanilla/phaser/src/dojo/typescript/contracts.gen.ts
  • examples/clients/vanilla/phaser/src/scenes/scene-main.ts
  • examples/clients/vue/vue-app/src/App.vue
  • examples/clients/vue/vue-app/src/dojo/createSystemCalls.ts
Additional comments not posted (12)
examples/clients/react/react-pwa-app/tsconfig.json (2)

2-2: LGTM!

Extending from a base TypeScript configuration file is a good practice for maintaining a consistent configuration across the project. It reduces duplication and makes it easier to manage the configuration.


4-4: LGTM!

Setting the jsx option to "react-jsx" is correct for a React project using TypeScript.

Verify that the removed compiler options are defined in the base configuration file ../../../../tsconfig.base.json.

Run the following script to verify the removed options:

Verification successful

Verification Successful

The removed compiler options from the tsconfig.json file in the React PWA app are correctly defined in the tsconfig.base.json file at the root of the repository. This centralization ensures consistent configuration across the project.

  • The following options are defined in tsconfig.base.json: target, module, lib, skipLibCheck, moduleResolution, allowImportingTsExtensions, resolveJsonModule, isolatedModules, noEmit, strict, noUnusedLocals, noUnusedParameters, noFallthroughCasesInSwitch.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the removed compiler options are defined in the base configuration file.

# Test: Search for the removed options in the base configuration file. Expect: All removed options are found.
rg --type json $'(target|lib|module|skipLibCheck|moduleResolution|allowImportingTsExtensions|resolveJsonModule|isolatedModules|noEmit|strict|noUnusedLocals|noUnusedParameters|noFallthroughCasesInSwitch|allowSyntheticDefaultImports)' ../../../../tsconfig.base.json

Length of output: 335


Script:

#!/bin/bash
# Search for any tsconfig.base.json files in the repository to verify its existence and correct path.
fd tsconfig.base.json

Length of output: 42


Script:

#!/bin/bash
# Description: Verify the removed compiler options are defined in the base configuration file.

# Test: Search for the removed options in the base configuration file. Expect: All removed options are found.
rg --type json $'(target|lib|module|skipLibCheck|moduleResolution|allowImportingTsExtensions|resolveJsonModule|isolatedModules|noEmit|strict|noUnusedLocals|noUnusedParameters|noFallthroughCasesInSwitch|allowSyntheticDefaultImports)' tsconfig.base.json

Length of output: 734

examples/clients/vue/vue-app/tsconfig.json (4)

9-9: LGTM!

Setting esModuleInterop to true is a recommended practice for better compatibility between CommonJS and ES modules. It enables cleaner import statements.


17-17: LGTM!

Setting allowSyntheticDefaultImports to true is beneficial for smoother interoperability with CommonJS modules. It allows default imports from modules with no default export.


18-18: LGTM!

Setting baseUrl to "." is a good practice for cleaner module resolution. It establishes the base directory for resolving non-relative module names, allowing for shorter and cleaner import paths.


19-21: LGTM!

Configuring the paths option to map @/* to src/* is an excellent practice for improved code readability and maintainability. It allows using the @ prefix as an alias for the src directory in import statements, providing a consistent and shorter syntax for importing modules.

examples/clients/vanilla/phaser/src/dojo/setup.ts (4)

14-14: LGTM!

The changes to the setup function signature are approved. The update to accept DojoConfig instead of Config aligns with the current architecture of the Dojo framework. The removal of the IDojo type alias is also acceptable, as it is no longer needed.


41-45: LGTM!

The changes to the fetching of existing entities are approved. The new approach of directly calling getSyncEntities after defining contractComponents streamlines the code and improves its readability.


51-62: LGTM!

The changes to the creation of the burnerManager are approved. The refactoring to utilize the dojoProvider for the RPC provider enhances the integration with the Dojo framework and improves the consistency of the code.


75-87: LGTM!

The changes to the return object of the setup function are approved. The inclusion of clientComponents instead of clientModels reflects the new structure of the client components, and the addition of eventSync provides new functionality for synchronizing events. These updates align the code with the current architecture and enhance its capabilities.

examples/clients/react/react-threejs/src/dojo/createSystemCalls.ts (2)

Line range hint 23-78: LGTM!

The code changes in the spawn function are approved:

  • The function signature has been updated to use Account instead of AccountInterface, which is consistent with the list of alterations.
  • The updated logic for setting the Moves and Position components seems reasonable and matches the AI-generated summary.
  • Waiting for the indexer to update the entity is a good practice to keep the UI in sync with the actual state.

79-103: LGTM!

The code changes in the move function are approved:

  • The function signature has been updated to use Account instead of AccountInterface, which is consistent with the list of alterations.
  • Waiting for the indexer to update the entity is a good practice to keep the UI in sync with the actual state.

@ponderingdemocritus ponderingdemocritus merged commit 026e7f4 into main Sep 2, 2024
3 checks passed
@ponderingdemocritus ponderingdemocritus deleted the fix/sync branch September 2, 2024 17:29
@coderabbitai coderabbitai bot mentioned this pull request Sep 8, 2024
4 tasks
This was referenced Oct 3, 2024
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