Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for model from other libraries #2172

Merged
merged 16 commits into from
Jul 15, 2024

Conversation

glihm
Copy link
Collaborator

@glihm glihm commented Jul 11, 2024

Description

This PR enables Dojo models/contracts from an other projects to be imported with current project namespace. This opens door to more reusability of models, like Origami.

The current limitation is that, when writing a library of Dojo models/contracts, the namespace argument of the dojo::model or dojo::contract must be specified. This is because inside dojo-lang, when the model/contract is processed by the Dojo plugin, we don't have any relationship between the code and the crates from which it comes from.

#[dojo::model(namespace: "mylib")]
struct MyLibModel { ... }

Doing so, anytime a model/contract is processed by the Dojo plugin, we can know the origin of the model/contract, and apply some mappings.

To use a model from a library, the steps are:

  1. The build-external-contracts must be used, with the exact same casing that was defined, and the fully qualified path of the model/contract. We force the snake case under the hood to follow the compiler nomenclature, but the user can use the exact same casing.
  2. The namespace is now a struct NamespaceConfig, where one must define the default namespace and some mappings can be added. If no mapping is used, the default namespace of the crate root is used. For the namespace mapping, we use the model/contract tag.

Example

# Scarb.toml
[dependencies]
armory = { path = "../game-lib/armory" }
// ./game-lib/armory/src/lib.cairo
#[dojo::model(namespace: "armory")]
struct FlatBow {...}
# ./spawn-and-move/Scarb.toml
build-external-contracts = [
    "armory::FlatBow",
]

[tool.dojo.world.namespace]
default = "dojo_examples"
# This mapping is only valid for the specified tag.
# The namespace for `FlatBow` will be `dojo_examples_weapons`.
mappings = { "armory-FlatBow" = "dojo_examples_weapons" }

If the whole models of a library may go in the same namespace, then only the namespace
can be specified in the mapping:

[tool.dojo.world.namespace]
default = "dojo_examples"
# All the models/contracts inside `armory` will use `dojo_examples_weapons` as namespace.
mappings = { "armory" = "dojo_examples_weapons" }

Finally, anything that is not found into the mappings, will use the default namespace.
This means, any library model without a specified namespace in the attribute will use the default namespace of the crate root.

Related issue

Closes #1786.
Closes #2151.
Closes #2111.

Tests

Compiler utility function has been reworked to support multi package copying to the tmp folder. This also support namespace to enable compilation of workspaces in tests.

Summary by CodeRabbit

  • New Features

    • Introduced a new inline macro module for generating selectors based on tags.
  • Refactor

    • Replaced package_id with namespace_config across various modules to streamline namespace handling.
  • Bug Fixes

    • Fixed issues related to attribute errors and unsupported attributes in system tests.
  • Chores

    • Updated dojo-world.json and dojo-world.toml files to improve function clarity and update class hashes.
  • Tests

    • Added error messages for missing namespaces and plugins in test data.

Copy link

coderabbitai bot commented Jul 11, 2024

Walkthrough

Recent updates focus on improving contract selectors, upgrades, and namespace handling within the Dojo framework. Significant changes include the introduction of the selector_from_tag macro, refactoring functions to use namespace_config, and enhancing contract registration within the world. These updates ensure clarity and better functionality for compiling libraries, handling namespaces, and registering contracts.

Changes

File(s) Change Summary
crates/dojo-core/src/base_test.cairo, crates/dojo-core/src/world.cairo Updated contract upgrade logic to use selector_from_tag macro for better selector handling.
crates/dojo-lang/src/contract.rs, crates/dojo-lang/src/model.rs, crates/dojo-lang/src/plugin.rs Refactored to use namespace_config instead of package_id, simplifying namespace handling.
crates/dojo-lang/src/inline_macros/mod.rs, crates/dojo-lang/src/inline_macros/selector_from_tag.rs Introduced a new module and macro selector_from_tag for generating contract selectors based on input tags.
crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/dojo-world.json Updated function definitions to improve clarity and functionality.
crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo-world.toml Updated class_hash and original_class_hash values.
crates/dojo-lang/src/plugin_test_data/print, crates/dojo-lang/src/plugin_test_data/system Added error messages for missing namespaces and plugins, addressed attribute errors, unsupported attributes, and unknown derives.

Assessment against linked issues

Objective Addressed Explanation
Add more test cases for Scarb projects (#1786) The PR includes improvements but does not explicitly cover new tests.
Debug the library compilation with namespaces (#2151)
Add contract registry to the world (#2111)

Poem

In the land of code where Dojo reigns,
Selectors now are clear, no strains.
Namespaces dance with joyful grace,
Contracts upgrade, a seamless pace.
Errors fixed, and tests are nigh,
In Dojo's world, we'll reach the sky.
🌐✨


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

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented Jul 11, 2024

Codecov Report

Attention: Patch coverage is 88.40580% with 64 lines in your changes missing coverage. Please review.

Project coverage is 67.21%. Comparing base (dd576ae) to head (3bc5cf6).

Files Patch % Lines
bin/sozo/src/commands/migrate.rs 47.22% 19 Missing ⚠️
crates/dojo-lang/src/utils.rs 34.48% 19 Missing ⚠️
...ates/dojo-bindgen/src/plugins/typescript_v2/mod.rs 0.00% 9 Missing ⚠️
crates/dojo-lang/src/model.rs 64.70% 6 Missing ⚠️
crates/dojo-lang/src/contract.rs 44.44% 5 Missing ⚠️
crates/dojo-lang/src/plugin.rs 83.33% 3 Missing ⚠️
...s/dojo-lang/src/inline_macros/selector_from_tag.rs 98.07% 1 Missing ⚠️
crates/dojo-test-utils/src/compiler.rs 97.67% 1 Missing ⚠️
crates/sozo/ops/src/migration/mod.rs 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2172      +/-   ##
==========================================
- Coverage   68.12%   67.21%   -0.91%     
==========================================
  Files         333      334       +1     
  Lines       42720    43022     +302     
==========================================
- Hits        29101    28917     -184     
- Misses      13619    14105     +486     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@glihm glihm requested a review from lambda-0x July 11, 2024 02:57
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: 3

Outside diff range, codebase verification and nitpick comments (5)
examples/game-lib/armory/src/lib.cairo (1)

1-2: Ensure correct derivation attributes.

The Drop trait is typically used to run code when a value goes out of scope. Ensure that this is intentional and necessary for the Flatbow struct.

examples/game-lib/bestiary/src/lib.cairo (1)

1-2: Ensure correct derivation attributes.

The Drop trait is typically used to run code when a value goes out of scope. Ensure that this is intentional and necessary for the RiverSkale struct.

examples/game-lib/manifests/dev/base/models/armory-Flatbow-f269a4c3.toml (1)

1-21: Missing ABI file and potential metadata inconsistency

The referenced ABI file manifests/dev/base/abis/models/armory-Flatbow-f269a4c3.json does not exist in the project. This needs to be corrected to ensure proper functionality. Additionally, the class_hash and original_class_hash values are not found elsewhere in the project, which might indicate they are unique identifiers, but this should be verified.

  • ABI file does not exist: manifests/dev/base/abis/models/armory-Flatbow-f269a4c3.json
  • class_hash and original_class_hash: Only found in examples/game-lib/manifests/dev/base/models/armory-Flatbow-f269a4c3.toml
Analysis chain

Ensure correctness and consistency of metadata.

The manifest file correctly specifies metadata for the Dojo model. Verify that the class_hash, original_class_hash, abi path, and member definitions are accurate and consistent with the rest of the project.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify metadata for the model in the manifest file.

# Test: Search for the model's class hash, ABI path, and other metadata in the project.
rg --type toml 'class_hash = "0x3a448f0a99ccf65cc1d2c888ba5fafb4a2f85c4e70d2e022147e5b1fe7ce1bf"'
rg --type toml 'original_class_hash = "0x3a448f0a99ccf65cc1d2c888ba5fafb4a2f85c4e70d2e022147e5b1fe7ce1bf"'
rg --type toml 'abi = "manifests/dev/base/abis/models/armory-Flatbow-f269a4c3.json"'

Length of output: 916


Script:

#!/bin/bash
# Verify if the class_hash and original_class_hash are used consistently across the project
rg '0x3a448f0a99ccf65cc1d2c888ba5fafb4a2f85c4e70d2e022147e5b1fe7ce1bf'

# Check if the ABI file exists
if [ -f "manifests/dev/base/abis/models/armory-Flatbow-f269a4c3.json" ]; then
  echo "ABI file exists: manifests/dev/base/abis/models/armory-Flatbow-f269a4c3.json"
else
  echo "ABI file does not exist: manifests/dev/base/abis/models/armory-Flatbow-f269a4c3.json"
fi

Length of output: 639

bin/sozo/tests/register_test.rs (1)

31-31: Ensure proper error handling for prepare_migration function.

Consider adding error handling to provide more context in case of failure.

let migration = prepare_migration(
    config.manifest_path().parent().unwrap().into(),
    target_path,
    dojo_metadata.skip_migration,
    &default_namespace,
).expect("Failed to prepare migration.");
examples/spawn-and-move/manifests/dev/deployment/abis/contracts/dojo_examples-actions-40b6994c.json (1)

299-310: Test coverage missing for enter_dungeon function

It appears that the enter_dungeon function is not currently tested in the codebase. To ensure comprehensive test coverage, please add test cases for this function.

  • Location to address: examples/spawn-and-move/src/actions.cairo
Analysis chain

New function enter_dungeon added to dojo_examples::actions::IActions.

The new function takes a dungeon_address as input and has external state mutability. Ensure that this new function is properly tested.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the `enter_dungeon` function is tested.

# Test: Search for test cases related to `enter_dungeon`. Expect: Test cases should be present.
rg --type rust 'enter_dungeon'

Length of output: 30


Script:

#!/bin/bash
# Description: Verify that the `enter_dungeon` function is tested.

# Test: Search for occurrences of `enter_dungeon` in all files to ensure it is tested somewhere.
rg 'enter_dungeon'

Length of output: 780


Script:

#!/bin/bash
# Description: Verify if there are any test files that might include `enter_dungeon` indirectly.

# Test: Search for test files that might contain references to `enter_dungeon`.
fd --type f --name '*test*'

Length of output: 280


Script:

#!/bin/bash
# Description: Verify if there are any test files that might include `enter_dungeon` indirectly.

# Corrected Test: Search for test files that might contain references to `enter_dungeon`.
fd --type f test

Length of output: 2042


Script:

#!/bin/bash
# Description: Search for `enter_dungeon` references within identified test files.

# Test: Search for occurrences of `enter_dungeon` in the identified test files.
rg 'enter_dungeon' $(fd --type f test)

Length of output: 2062


Script:

#!/bin/bash
# Description: Search for indirect references to `enter_dungeon` within identified test files.

# Test: Search for occurrences of related functions or modules that might invoke `enter_dungeon`.
rg 'enter_dungeon' $(fd --type f test)

Length of output: 2062

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f8776ba and 18dfea2.

Files ignored due to path filters (3)
  • examples/game-lib/Scarb.lock is excluded by !**/*.lock
  • examples/game-lib/armory/Scarb.lock is excluded by !**/*.lock
  • examples/spawn-and-move/Scarb.lock is excluded by !**/*.lock
Files selected for processing (55)
  • bin/sozo/src/commands/build.rs (2 hunks)
  • bin/sozo/src/commands/clean.rs (3 hunks)
  • bin/sozo/src/commands/migrate.rs (1 hunks)
  • bin/sozo/tests/register_test.rs (3 hunks)
  • bin/sozo/tests/test_migrate.rs (3 hunks)
  • crates/dojo-bindgen/src/lib.rs (1 hunks)
  • crates/dojo-bindgen/src/plugins/typescript_v2/mod.rs (2 hunks)
  • crates/dojo-core/Scarb.toml (1 hunks)
  • crates/dojo-lang/src/compiler.rs (1 hunks)
  • crates/dojo-lang/src/contract.rs (2 hunks)
  • crates/dojo-lang/src/model.rs (1 hunks)
  • crates/dojo-lang/src/plugin.rs (8 hunks)
  • crates/dojo-lang/src/plugin_test_data/print (1 hunks)
  • crates/dojo-lang/src/plugin_test_data/system (2 hunks)
  • crates/dojo-lang/src/semantics/test_data/get (3 hunks)
  • crates/dojo-lang/src/semantics/test_data/set (3 hunks)
  • crates/dojo-lang/src/utils.rs (2 hunks)
  • crates/dojo-test-utils/src/compiler.rs (5 hunks)
  • crates/dojo-world/src/contracts/model_test.rs (2 hunks)
  • crates/dojo-world/src/contracts/world_test.rs (2 hunks)
  • crates/dojo-world/src/manifest/manifest_test.rs (3 hunks)
  • crates/sozo/ops/src/migration/mod.rs (5 hunks)
  • crates/sozo/ops/src/tests/setup.rs (2 hunks)
  • crates/torii/core/src/sql_test.rs (5 hunks)
  • crates/torii/graphql/src/tests/mod.rs (4 hunks)
  • crates/torii/grpc/src/server/tests/entities_test.rs (2 hunks)
  • examples/game-lib/Scarb.toml (1 hunks)
  • examples/game-lib/armory/Scarb.toml (1 hunks)
  • examples/game-lib/armory/manifests/dev/base/abis/dojo-base.json (1 hunks)
  • examples/game-lib/armory/manifests/dev/base/abis/dojo-world.json (1 hunks)
  • examples/game-lib/armory/manifests/dev/base/abis/models/armory-ModelA-19290fb7.json (1 hunks)
  • examples/game-lib/armory/manifests/dev/base/dojo-base.toml (1 hunks)
  • examples/game-lib/armory/manifests/dev/base/dojo-world.toml (1 hunks)
  • examples/game-lib/armory/manifests/dev/base/models/armory-ModelA-19290fb7.toml (1 hunks)
  • examples/game-lib/armory/src/lib.cairo (1 hunks)
  • examples/game-lib/bestiary/Scarb.toml (1 hunks)
  • examples/game-lib/bestiary/src/lib.cairo (1 hunks)
  • examples/game-lib/manifests/dev/base/abis/dojo-base.json (1 hunks)
  • examples/game-lib/manifests/dev/base/abis/dojo-world.json (1 hunks)
  • examples/game-lib/manifests/dev/base/abis/models/armory-Flatbow-f269a4c3.json (1 hunks)
  • examples/game-lib/manifests/dev/base/abis/models/bestiary-RiverSkale-1bce2040.json (1 hunks)
  • examples/game-lib/manifests/dev/base/dojo-base.toml (1 hunks)
  • examples/game-lib/manifests/dev/base/dojo-world.toml (1 hunks)
  • examples/game-lib/manifests/dev/base/models/armory-Flatbow-f269a4c3.toml (1 hunks)
  • examples/game-lib/manifests/dev/base/models/bestiary-RiverSkale-1bce2040.toml (1 hunks)
  • examples/spawn-and-move/Scarb.toml (1 hunks)
  • examples/spawn-and-move/manifests/dev/base/abis/contracts/dojo_examples-actions-40b6994c.json (1 hunks)
  • examples/spawn-and-move/manifests/dev/base/abis/contracts/dojo_examples-dungeon-6620e0e6.json (3 hunks)
  • examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples-Flatbow-3632af69.json (1 hunks)
  • examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples-RiverSkale-27fcbc29.json (1 hunks)
  • examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-actions-40b6994c.toml (1 hunks)
  • examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-dungeon-6620e0e6.toml (1 hunks)
  • examples/spawn-and-move/manifests/dev/base/models/dojo_examples-Flatbow-3632af69.toml (1 hunks)
  • examples/spawn-and-move/manifests/dev/base/models/dojo_examples-RiverSkale-27fcbc29.toml (1 hunks)
  • examples/spawn-and-move/manifests/dev/deployment/abis/contracts/dojo_examples-actions-40b6994c.json (1 hunks)
Files not processed due to max files limit (19)
  • examples/spawn-and-move/manifests/dev/deployment/abis/contracts/dojo_examples-dungeon-6620e0e6.json
  • examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-Flatbow-3632af69.json
  • examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-ModelA-689f21bc.json
  • examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-RiverSkale-27fcbc29.json
  • examples/spawn-and-move/manifests/dev/deployment/manifest.json
  • examples/spawn-and-move/manifests/dev/deployment/manifest.toml
  • examples/spawn-and-move/manifests/release/base/abis/contracts/dojo_examples-actions-40b6994c.json
  • examples/spawn-and-move/manifests/release/base/abis/contracts/dojo_examples-dungeon-6620e0e6.json
  • examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples-Flatbow-3632af69.json
  • examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples-RiverSkale-27fcbc29.json
  • examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-actions-40b6994c.toml
  • examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-dungeon-6620e0e6.toml
  • examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-something-71cfad55.toml
  • examples/spawn-and-move/manifests/release/base/models/dojo_examples-Flatbow-3632af69.toml
  • examples/spawn-and-move/manifests/release/base/models/dojo_examples-RiverSkale-27fcbc29.toml
  • examples/spawn-and-move/src/actions.cairo
  • examples/spawn-and-move/src/dungeon.cairo
  • examples/spawn-and-move/src/lib.cairo
  • examples/spawn-and-move/src/something.cairo
Files not summarized due to errors (1)
  • crates/dojo-lang/src/plugin_test_data/system: Error: Message exceeds token limit
Files skipped from review due to trivial changes (9)
  • bin/sozo/src/commands/migrate.rs
  • crates/dojo-core/Scarb.toml
  • examples/game-lib/Scarb.toml
  • examples/game-lib/armory/Scarb.toml
  • examples/game-lib/armory/manifests/dev/base/dojo-base.toml
  • examples/game-lib/armory/manifests/dev/base/dojo-world.toml
  • examples/game-lib/manifests/dev/base/dojo-base.toml
  • examples/game-lib/manifests/dev/base/dojo-world.toml
  • examples/spawn-and-move/manifests/dev/base/models/dojo_examples-RiverSkale-27fcbc29.toml
Additional comments not posted (182)
examples/game-lib/armory/src/lib.cairo (2)

2-2: Check the usage of dojo::model.

Verify if additional configuration for dojo::model is required, especially if there are specific attributes or namespace settings needed.


3-8: LGTM!

The struct definition looks good. Each field is defined with appropriate types and key annotations.

examples/game-lib/bestiary/src/lib.cairo (2)

2-2: Check the usage of dojo::model.

Verify if additional configuration for dojo::model is required, especially if there are specific attributes or namespace settings needed.


3-9: LGTM!

The struct definition looks good. Each field is defined with appropriate types and key annotations.

examples/game-lib/bestiary/Scarb.toml (3)

1-4: LGTM!

The package metadata is defined correctly.


6-8: LGTM!

The dependencies are set up correctly.


9-16: Verify namespace usage.

Ensure that the namespace configuration aligns with the new functionality for importing models/contracts.

examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-actions-40b6994c.toml (3)

1-1: LGTM!

The contract type is correctly specified.


2-3: Verify class hashes.

Ensure that the class hashes are correct and match the deployed contract.


4-4: LGTM!

The ABI path is correctly specified.

examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-dungeon-6620e0e6.toml (1)

1-11: Ensure correctness and consistency of metadata.

The manifest file correctly specifies metadata for the Dojo contract. Verify that the class_hash, original_class_hash, base_class_hash, and abi path are accurate and consistent with the rest of the project.

Verification successful

The metadata in the manifest file is accurate and consistent.

The class_hash, original_class_hash, base_class_hash, and abi path specified in the manifest file are consistent with other parts of the project.

  • class_hash and original_class_hash are correctly referenced in multiple manifest files.
  • base_class_hash value of "0x0" is consistently used across different manifest files.
  • The abi path is correctly specified in the given manifest file.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify metadata for the contract in the manifest file.

# Test: Search for the contract's class hash, ABI path, and other metadata in the project.
rg --type toml 'class_hash = "0x14b3096b82a761f63dd47277c2b5ac18925dea43586418483939a2f1f57f674"'
rg --type toml 'original_class_hash = "0x14b3096b82a761f63dd47277c2b5ac18925dea43586418483939a2f1f57f674"'
rg --type toml 'base_class_hash = "0x0"'
rg --type toml 'abi = "manifests/dev/base/abis/contracts/dojo_examples-dungeon-6620e0e6.json"'

Length of output: 3231

examples/game-lib/armory/manifests/dev/base/models/armory-ModelA-19290fb7.toml (1)

1-16: Ensure correctness and consistency of metadata.

The manifest file correctly specifies metadata for the Dojo model. Verify that the class_hash, original_class_hash, abi path, and member definitions are accurate and consistent with the rest of the project.

Verification successful

Metadata is correctly specified and consistent.

  • The class_hash, original_class_hash, and abi path are present and consistent within the file examples/game-lib/armory/manifests/dev/base/models/armory-ModelA-19290fb7.toml.
  • These values are not duplicated elsewhere in the project, ensuring no inconsistencies.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify metadata for the model in the manifest file.

# Test: Search for the model's class hash, ABI path, and other metadata in the project.
rg --type toml 'class_hash = "0xc9cbc616fe628f80bb6d80181100c50e2053c811bcd1ae148bdaebc472a602"'
rg --type toml 'original_class_hash = "0xc9cbc616fe628f80bb6d80181100c50e2053c811bcd1ae148bdaebc472a602"'
rg --type toml 'abi = "manifests/dev/base/abis/models/armory-ModelA-19290fb7.json"'

Length of output: 933


Script:

#!/bin/bash
# Description: Verify metadata consistency for the model across the project.

# Test: Search for the model's class hash, original class hash, and ABI path in the entire project.
rg '0xc9cbc616fe628f80bb6d80181100c50e2053c811bcd1ae148bdaebc472a602'
rg 'manifests/dev/base/abis/models/armory-ModelA-19290fb7.json'

Length of output: 606

examples/spawn-and-move/manifests/dev/base/models/dojo_examples-Flatbow-3632af69.toml (1)

1-21: Ensure correctness and consistency of metadata.

The manifest file correctly specifies metadata for the Dojo model. Verify that the class_hash, original_class_hash, abi path, and member definitions are accurate and consistent with the rest of the project.

Verification successful

Metadata verification successful.

The class_hash, original_class_hash, and abi path specified in the manifest file are consistent across the project.

  • class_hash: 0x452abb4fc0af6e0e08e6f652ce77d7330000d4e4bec995005785c7d3f12ea1a
  • original_class_hash: 0x452abb4fc0af6e0e08e6f652ce77d7330000d4e4bec995005785c7d3f12ea1a
  • abi path: manifests/dev/base/abis/models/dojo_examples-Flatbow-3632af69.json
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify metadata for the model in the manifest file.

# Test: Search for the model's class hash, ABI path, and other metadata in the project.
rg --type toml 'class_hash = "0x452abb4fc0af6e0e08e6f652ce77d7330000d4e4bec995005785c7d3f12ea1a"'
rg --type toml 'original_class_hash = "0x452abb4fc0af6e0e08e6f652ce77d7330000d4e4bec995005785c7d3f12ea1a"'
rg --type toml 'abi = "manifests/dev/base/abis/models/dojo_examples-Flatbow-3632af69.json"'

Length of output: 1963

examples/game-lib/manifests/dev/base/models/bestiary-RiverSkale-1bce2040.toml (2)

1-6: Review Dojo model metadata.

The metadata for the Dojo model includes the class_hash, original_class_hash, abi path, tag, and manifest_name. Ensure these values are correct and correspond to the actual model and its ABI.

Please verify that the class hashes, ABI path, tag, and manifest name are correct and correspond to the actual model.


8-26: Review Dojo model members.

The model members are defined with their names, types, and key status. Ensure that the member definitions are correct and consistent with the model's requirements.

The member definitions look correct and consistent with the model's requirements.

examples/spawn-and-move/Scarb.toml (2)

14-21: Review new dependencies and build targets.

The new dependencies for armory and bestiary and the build-external-contracts target are defined. Ensure these dependencies and targets are correctly defined and consistent with the project's requirements.

The new dependencies and build targets are correctly defined and consistent with the project's requirements.


24-25: Review feature definitions.

The default and dungeon features are defined. Ensure these features are correctly defined and consistent with the project's requirements.

The feature definitions look correct and consistent with the project's requirements.

bin/sozo/tests/test_migrate.rs (2)

12-13: Review test setup.

The test setup uses CompilerTestSetup to configure the test environment. Ensure the setup is correctly defined and consistent with the migration functionality.

The test setup using CompilerTestSetup is correctly defined and consistent with the migration functionality.


45-45: Review test assertions.

The test assertions check the output for expected values. Ensure the assertions are correct and consistent with the migration functionality.

The test assertions are correct and consistent with the migration functionality.

crates/dojo-lang/src/utils.rs (2)

13-15: Ensure proper error handling in the get_default_namespace function.

The function should handle errors properly when reading and parsing the configuration file.

Ensure the function handles errors properly when reading and parsing the Scarb.toml file.


41-48: Review namespace extraction logic.

The logic for extracting the namespace from the configuration file is correct. Ensure the function correctly identifies and returns the namespace.

The namespace extraction logic is correct and consistent with the project's requirements.

examples/game-lib/armory/manifests/dev/base/abis/dojo-base.json (6)

3-5: LGTM! Entity WorldProviderImpl is correctly defined.

The implementation of the interface dojo::world::IWorldProvider is accurate.


8-14: LGTM! Entity IWorldDispatcher is correctly defined.

The struct dojo::world::IWorldDispatcher is accurate.


18-31: LGTM! Entity IWorldProvider is correctly defined.

The interface dojo::world::IWorldProvider with the function world is accurate.


35-37: LGTM! Entity UpgradableImpl is correctly defined.

The implementation of the interface dojo::components::upgradeable::IUpgradeable is accurate.


40-54: LGTM! Entity IUpgradeable is correctly defined.

The interface dojo::components::upgradeable::IUpgradeable with the function upgrade is accurate.


63-97: LGTM! Event entities are correctly defined.

The events Upgraded, Event, and Event are accurately defined with the necessary fields and variants.

examples/game-lib/manifests/dev/base/abis/dojo-base.json (6)

3-5: LGTM! Entity WorldProviderImpl is correctly defined.

The implementation of the interface dojo::world::IWorldProvider is accurate.


8-14: LGTM! Entity IWorldDispatcher is correctly defined.

The struct dojo::world::IWorldDispatcher is accurate.


18-31: LGTM! Entity IWorldProvider is correctly defined.

The interface dojo::world::IWorldProvider with the function world is accurate.


35-37: LGTM! Entity UpgradableImpl is correctly defined.

The implementation of the interface dojo::components::upgradeable::IUpgradeable is accurate.


40-54: LGTM! Entity IUpgradeable is correctly defined.

The interface dojo::components::upgradeable::IUpgradeable with the function upgrade is accurate.


63-97: LGTM! Event entities are correctly defined.

The events Upgraded, Event, and Event are accurately defined with the necessary fields and variants.

bin/sozo/tests/register_test.rs (1)

17-18: LGTM! Configuration setup using CompilerTestSetup is correct.

The usage of CompilerTestSetup to build the test configuration is accurate and improves code maintainability.

crates/dojo-lang/src/plugin_test_data/print (1)

80-133: LGTM! Expected diagnostics for missing namespace are correctly defined.

The diagnostics provide meaningful error messages to help users identify and fix issues related to missing the default namespace in the Scarb.toml file.

crates/sozo/ops/src/tests/setup.rs (2)

2-2: Import CompilerTestSetup is correct.

The import statement for CompilerTestSetup aligns with the objectives of streamlining configuration processes.


30-31: Correct usage of CompilerTestSetup in load_config.

The CompilerTestSetup::from_examples method is used correctly to initialize the setup and build the test configuration.

crates/dojo-world/src/contracts/model_test.rs (2)

1-1: Import CompilerTestSetup is correct.

The import statement for CompilerTestSetup aligns with the objectives of streamlining configuration processes.


20-21: Correct usage of CompilerTestSetup in test_model.

The CompilerTestSetup::from_examples method is used correctly to initialize the setup and build the test configuration.

examples/spawn-and-move/manifests/dev/base/abis/contracts/dojo_examples-dungeon-6620e0e6.json (5)

131-132: Addition of IDungeonImpl implementation.

The IDungeonImpl implementation for the dojo_examples::dungeon::IDungeon interface is correctly added.


136-140: Addition of IDungeon interface.

The dojo_examples::dungeon::IDungeon interface is correctly added with the enter function.


150-150: Addition of IDojoInitImpl implementation.

The IDojoInitImpl implementation for the dojo_examples::dungeon::dungeon::IDojoInit interface is correctly added.


154-154: Addition of IDojoInit interface.

The dojo_examples::dungeon::dungeon::IDojoInit interface is correctly added with the dojo_init function.


214-214: Addition of Event for dojo_examples::dungeon::dungeon.

The Event enum for dojo_examples::dungeon::dungeon is correctly added with the UpgradeableEvent variant.

crates/torii/grpc/src/server/tests/entities_test.rs (2)

4-4: Import CompilerTestSetup is correct.

The import statement for CompilerTestSetup aligns with the objectives of streamlining configuration processes.


39-40: Correct usage of CompilerTestSetup in test_entities_queries.

The CompilerTestSetup::from_examples method is used correctly to initialize the setup and build the test configuration.

crates/dojo-world/src/contracts/world_test.rs (3)

4-4: LGTM!

The import statement for CompilerTestSetup is consistent with the objective of centralizing and streamlining the configuration process.


22-23: LGTM!

The test setup using CompilerTestSetup improves code clarity and maintainability by centralizing the configuration process.


24-24: LGTM!

The usage of config to read the workspace and obtain the default namespace is consistent with the centralized configuration process and ensures the correct namespace is used.

crates/sozo/ops/src/migration/mod.rs (3)

57-57: LGTM!

The change in the return type of the migrate function to Result<Option<MigrationOutput>> allows the function to return None when no migration is needed, improving flexibility.


119-119: LGTM!

The usage of default_namespace to update the order of the world diff ensures that the correct namespace is applied during the migration process.


182-182: LGTM!

The usage of default_namespace during auto-authorization ensures that the correct namespace is applied during this process.

crates/dojo-bindgen/src/lib.rs (3)

216-216: LGTM!

The import statement for CompilerTestSetup is consistent with the objective of centralizing and streamlining the configuration process.


224-225: LGTM!

The test setup using CompilerTestSetup improves code clarity and maintainability by centralizing the configuration process.


233-238: LGTM!

The usage of config to read the workspace and obtain the dojo metadata is consistent with the centralized configuration process and ensures the correct metadata is used.

examples/spawn-and-move/manifests/dev/base/abis/contracts/dojo_examples-actions-40b6994c.json (1)

302-310: LGTM!

The addition of the enter_dungeon function to the dojo_examples::actions::IActions interface is consistent with the interface structure and follows the correct format.

bin/sozo/src/commands/clean.rs (2)

175-177: Refactor: Use CompilerTestSetup in all_profile_clean_works test function.

The introduction of CompilerTestSetup improves code clarity and maintainability. Ensure that the changes do not introduce any issues in the test setup or execution.


Line range hint 94-104:
Refactor: Use CompilerTestSetup in default_clean_works test function.

The introduction of CompilerTestSetup improves code clarity and maintainability. Ensure that the changes do not introduce any issues in the test setup or execution.

Verification successful

Refactor: Use CompilerTestSetup in default_clean_works test function.

The introduction of CompilerTestSetup improves code clarity and maintainability. Ensure that the changes do not introduce any issues in the test setup or execution.

  • The Profile enum is correctly used and referenced from scarb::compiler::Profile.
  • The CompilerTestSetup struct is correctly utilized in the default_clean_works function.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the `default_clean_works` test function executes correctly.

# Test: Run the `default_clean_works` test. Expect: Test should pass.
cargo test default_clean_works

Length of output: 105


Script:

#!/bin/bash
# Description: Search for the `default_clean_works` function and its dependencies in the codebase.

# Search for the `default_clean_works` function in the codebase
rg -A 10 'fn default_clean_works' 

# Search for the `CompilerTestSetup` struct implementation
rg 'struct CompilerTestSetup'

# Search for the `Profile` enum or struct implementation
rg 'enum Profile' 

Length of output: 1047


Script:

#!/bin/bash
# Description: Verify the usage of `Profile` in `bin/sozo/src/commands/clean.rs` and related files.

# Search for the usage of `Profile` in `bin/sozo/src/commands/clean.rs`
rg 'Profile' bin/sozo/src/commands/clean.rs

# Search for the usage of `Profile` in the entire codebase to confirm its correct implementation
rg 'Profile'

Length of output: 8955

crates/torii/core/src/sql_test.rs (2)

Line range hint 63-107:
Refactor: Use CompilerTestSetup in test_load_from_remote test function.

The introduction of CompilerTestSetup improves code clarity and maintainability. Ensure that the changes do not introduce any issues in the test setup or execution.


Line range hint 184-266:
Refactor: Use CompilerTestSetup in test_load_from_remote_del test function.

The introduction of CompilerTestSetup improves code clarity and maintainability. Ensure that the changes do not introduce any issues in the test setup or execution.

examples/game-lib/armory/manifests/dev/base/abis/models/armory-ModelA-19290fb7.json (1)

1-407: New models and interfaces added.

The changes include various model interfaces, structures, and implementations. Ensure that these new models are properly tested and integrated.

examples/game-lib/manifests/dev/base/abis/models/armory-Flatbow-f269a4c3.json (21)

1-6: Correct structure and type definitions for DojoModelImpl.

The JSON structure and type definitions for DojoModelImpl are correct.


7-24: Correct structure and type definitions for ByteArray.

The JSON structure and type definitions for ByteArray are correct.


25-38: Correct structure and type definitions for Option::<core::integer::u32>.

The JSON structure and type definitions for Option::<core::integer::u32> are correct.


39-48: Correct structure and type definitions for Span::<core::integer::u8>.

The JSON structure and type definitions for Span::<core::integer::u8> are correct.


49-62: Correct structure and type definitions for FieldLayout.

The JSON structure and type definitions for FieldLayout are correct.


63-72: Correct structure and type definitions for Span::<dojo::database::introspect::FieldLayout>.

The JSON structure and type definitions for Span::<dojo::database::introspect::FieldLayout> are correct.


73-82: Correct structure and type definitions for Span::<dojo::database::introspect::Layout>.

The JSON structure and type definitions for Span::<dojo::database::introspect::Layout> are correct.


83-112: Correct structure and type definitions for Layout.

The JSON structure and type definitions for Layout are correct.


113-122: Correct structure and type definitions for Span::<core::felt252>.

The JSON structure and type definitions for Span::<core::felt252> are correct.


123-140: Correct structure and type definitions for Member.

The JSON structure and type definitions for Member are correct.


141-150: Correct structure and type definitions for Span::<dojo::database::introspect::Member>.

The JSON structure and type definitions for Span::<dojo::database::introspect::Member> are correct.


151-168: Correct structure and type definitions for Struct.

The JSON structure and type definitions for Struct are correct.


169-178: Correct structure and type definitions for Span::<(core::felt252, dojo::database::introspect::Ty)>.

The JSON structure and type definitions for Span::<(core::felt252, dojo::database::introspect::Ty)> are correct.


179-196: Correct structure and type definitions for Enum.

The JSON structure and type definitions for Enum are correct.


197-206: Correct structure and type definitions for Span::<dojo::database::introspect::Ty>.

The JSON structure and type definitions for Span::<dojo::database::introspect::Ty> are correct.


207-236: Correct structure and type definitions for Ty.

The JSON structure and type definitions for Ty are correct.


237-363: Correct structure and type definitions for IModel.

The JSON structure and type definitions for IModel are correct.


364-368: Correct structure and type definitions for flatbowImpl.

The JSON structure and type definitions for flatbowImpl are correct.


369-386: Correct structure and type definitions for Flatbow.

The JSON structure and type definitions for Flatbow are correct.


387-404: Correct structure and type definitions for Iflatbow.

The JSON structure and type definitions for Iflatbow are correct.


405-410: Correct structure and type definitions for Event.

The JSON structure and type definitions for Event are correct.

examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples-RiverSkale-27fcbc29.json (21)

1-6: LGTM: DojoModelImpl implementation

The implementation of DojoModelImpl with the interface dojo::model::IModel is correctly defined.


7-24: LGTM: ByteArray struct

The struct core::byte_array::ByteArray with members data, pending_word, and pending_word_len is correctly defined.


25-37: LGTM: Option enum

The enum core::option::Option::<core::integer::u32> with variants Some and None is correctly defined.


38-48: LGTM: Span struct

The struct core::array::Span::<core::integer::u8> with the member snapshot is correctly defined.


49-62: LGTM: FieldLayout struct

The struct dojo::database::introspect::FieldLayout with members selector and layout is correctly defined.


63-72: LGTM: Span struct

The struct core::array::Span::<dojo::database::introspect::FieldLayout> with the member snapshot is correctly defined.


73-82: LGTM: Span struct

The struct core::array::Span::<dojo::database::introspect::Layout> with the member snapshot is correctly defined.


83-111: LGTM: Layout enum

The enum dojo::database::introspect::Layout with variants Fixed, Struct, Tuple, Array, ByteArray, and Enum is correctly defined.


112-121: LGTM: Span struct

The struct core::array::Span::<core::felt252> with the member snapshot is correctly defined.


122-140: LGTM: Member struct

The struct dojo::database::introspect::Member with members name, attrs, and ty is correctly defined.


141-149: LGTM: Span struct

The struct core::array::Span::<dojo::database::introspect::Member> with the member snapshot is correctly defined.


150-167: LGTM: Struct struct

The struct dojo::database::introspect::Struct with members name, attrs, and children is correctly defined.


168-177: LGTM: Span struct

The struct core::array::Span::<(core::felt252, dojo::database::introspect::Ty)> with the member snapshot is correctly defined.


178-196: LGTM: Enum struct

The struct dojo::database::introspect::Enum with members name, attrs, and children is correctly defined.


197-205: LGTM: Span struct

The struct core::array::Span::<dojo::database::introspect::Ty> with the member snapshot is correctly defined.


206-235: LGTM: Ty enum

The enum dojo::database::introspect::Ty with variants Primitive, Struct, Enum, Tuple, Array, and ByteArray is correctly defined.


236-362: LGTM: IModel interface

The interface dojo::model::IModel with functions name, namespace, tag, version, selector, name_hash, namespace_hash, unpacked_size, packed_size, layout, and schema is correctly defined.


363-368: LGTM: river_skaleImpl implementation

The implementation of river_skaleImpl with the interface bestiary::Iriver_skale is correctly defined.


369-390: LGTM: RiverSkale struct

The struct bestiary::RiverSkale with members id, health, armor, and attack is correctly defined.


391-408: LGTM: Iriver_skale interface

The interface bestiary::Iriver_skale with the function ensure_abi is correctly defined.


409-414: Verify the event definition

The event bestiary::river_skale::Event has an empty variants array. Ensure this is intentional and correct.

crates/dojo-lang/src/semantics/test_data/set (3)

21-25: LGTM: No params test case

The test case for no params with the expression set!() and the expected result indicating a missing expression with appropriate diagnostics is correctly defined.


53-57: LGTM: Incorrect args test case

The test case for incorrect args with the expression set!(world) and the expected result indicating a missing expression with appropriate diagnostics is correctly defined.


237-266: LGTM: Set successful expansion test case

The test case for set successful expansion with the expression set!(world, (Health{id: 0xb0b, health: 79})) and the expected result indicating a block with several statements and the final type being Health is correctly defined.

crates/dojo-test-utils/src/compiler.rs (5)

19-24: Struct Definition Approved

The struct CompilerTestSetup is well-defined with appropriate fields.


27-36: Function Logic Approved

The function from_examples correctly processes the example paths to create a CompilerTestSetup instance.


38-61: Function Logic Approved

The function from_paths correctly processes the given paths to create a CompilerTestSetup instance and handles temporary directories appropriately.


63-69: Function Logic Approved

The function build_test_config correctly builds a test configuration from the manifest path and profile.


Line range hint 174-209: Function Logic Approved

The function copy_project_temp correctly copies a project to a new location, excluding certain directories, and handles paths appropriately.

crates/dojo-lang/src/model.rs (2)

Line range hint 102-161: Function Logic Approved

The function get_model_parameters correctly extracts model parameters from the struct's AST and handles errors appropriately.


Line range hint 195-509: Function Logic Approved

The function handle_model_struct correctly processes a model struct and generates a RewriteNode with appropriate diagnostics.

crates/dojo-lang/src/plugin.rs (3)

114-118: Function Logic Approved

The function handle_mod correctly processes a module and returns a PluginResult with appropriate handling of dojo::contract attributes.


Line range hint 153-179: Function Logic Approved

The function handle_fn correctly processes a function and returns a PluginResult with appropriate handling of computed attributes.


Line range hint 345-547: Function Logic Approved

The function generate_code correctly generates code based on the given AST item and metadata, handling different module items appropriately.

crates/dojo-lang/src/compiler.rs (3)

172-183: Function Logic Approved

The function find_project_contracts correctly finds internal and external contracts in the project, ensuring proper handling of paths and contract selectors.


Line range hint 236-236: Function Logic Approved

The function update_files correctly updates files with compiled artifacts and metadata, ensuring proper handling of paths and directories.


Line range hint 729-729: Function Logic Approved

The function get_dojo_model_artifacts correctly retrieves model artifacts from the database, ensuring proper handling of paths and namespaces.

crates/dojo-bindgen/src/plugins/typescript_v2/mod.rs (3)

630-630: Add CompilerTestSetup import.

The CompilerTestSetup import is correctly added to facilitate the new test configuration setup.


649-650: Replace manual path setup with CompilerTestSetup.

The new CompilerTestSetup correctly replaces the manual path setup, making the test configuration more concise and maintainable.


657-662: Use CompilerTestSetup for test configuration.

The test configuration is correctly set up using CompilerTestSetup, ensuring consistency and reducing boilerplate code.

crates/dojo-world/src/manifest/manifest_test.rs (7)

5-5: Add CompilerTestSetup import.

The CompilerTestSetup import is correctly added to facilitate the new test configuration setup.


307-308: Replace manual path setup with CompilerTestSetup.

The new CompilerTestSetup correctly replaces the manual path setup, making the test configuration more concise and maintainable.


315-315: Use CompilerTestSetup for test configuration.

The test configuration is correctly set up using CompilerTestSetup, ensuring consistency and reducing boilerplate code.


323-324: Pass configuration paths to deploy_world.

The updated paths are correctly passed to the deploy_world function, ensuring the correct deployment of the world for testing.


332-332: Load the local manifest from the correct path.

The local manifest is correctly loaded from the path set up by CompilerTestSetup, ensuring the correct manifest is used for testing.


340-340: Load the overlay manifest if it exists.

The overlay manifest is correctly loaded if it exists, ensuring the test handles overlays properly.


352-355: Assert the correct number of models and contracts.

The assertions for the number of models and contracts in the local and remote manifests are correctly set up, ensuring the manifests are correctly compared.

crates/dojo-lang/src/contract.rs (2)

43-44: Update DojoContract to use default_namespace.

The from_module method is updated to use default_namespace, which is correctly passed as a parameter.


57-57: Use default_namespace if namespace is not provided.

The default_namespace is correctly used if the namespace parameter is not provided, ensuring that a namespace is always available.

crates/dojo-lang/src/plugin_test_data/system (32)

358-358: Clear error message for missing default namespace

The error message clearly indicates that the default namespace is missing and provides guidance on the required configuration in the Scarb.toml file.


363-363: Consistent error message for missing default namespace

The error message is consistent with the previous one and provides clear guidance on the required configuration in the Scarb.toml file.


368-368: Consistent error message for missing default namespace

The error message is consistent with the previous ones and provides clear guidance on the required configuration in the Scarb.toml file.


373-373: Consistent error message for missing default namespace

The error message is consistent with the previous ones and provides clear guidance on the required configuration in the Scarb.toml file.


378-378: Consistent error message for missing default namespace

The error message is consistent with the previous ones and provides clear guidance on the required configuration in the Scarb.toml file.


383-383: Consistent error message for missing default namespace

The error message is consistent with the previous ones and provides clear guidance on the required configuration in the Scarb.toml file.


388-388: Clear error message for unsupported attribute

The error message clearly indicates an unsupported attribute.


393-393: Consistent error message for missing default namespace

The error message is consistent with the previous ones and provides clear guidance on the required configuration in the Scarb.toml file.


398-398: Clear error message for unsupported attribute

The error message clearly indicates an unsupported attribute.


403-403: Consistent error message for missing default namespace

The error message is consistent with the previous ones and provides clear guidance on the required configuration in the Scarb.toml file.


408-408: Consistent error message for missing default namespace

The error message is consistent with the previous ones and provides clear guidance on the required configuration in the Scarb.toml file.


413-413: Consistent error message for missing default namespace

The error message is consistent with the previous ones and provides clear guidance on the required configuration in the Scarb.toml file.


419-419: Clear error message for unsupported attribute

The error message clearly indicates an unsupported attribute.


423-423: Consistent error message for missing default namespace

The error message is consistent with the previous ones and provides clear guidance on the required configuration in the Scarb.toml file.


428-428: Consistent error message for missing default namespace

The error message is consistent with the previous ones and provides clear guidance on the required configuration in the Scarb.toml file.


433-433: Consistent error message for missing default namespace

The error message is consistent with the previous ones and provides clear guidance on the required configuration in the Scarb.toml file.


438-438: Consistent error message for missing default namespace

The error message is consistent with the previous ones and provides clear guidance on the required configuration in the Scarb.toml file.


443-443: Consistent error message for missing default namespace

The error message is consistent with the previous ones and provides clear guidance on the required configuration in the Scarb.toml file.


448-448: Consistent error message for missing default namespace

The error message is consistent with the previous ones and provides clear guidance on the required configuration in the Scarb.toml file.


453-453: Consistent error message for missing default namespace

The error message is consistent with the previous ones and provides clear guidance on the required configuration in the Scarb.toml file.


458-458: Consistent error message for missing default namespace

The error message is consistent with the previous ones and provides clear guidance on the required configuration in the Scarb.toml file.


463-463: Consistent error message for missing default namespace

The error message is consistent with the previous ones and provides clear guidance on the required configuration in the Scarb.toml file.


468-468: Consistent error message for missing default namespace

The error message is consistent with the previous ones and provides clear guidance on the required configuration in the Scarb.toml file.


473-473: Consistent error message for missing default namespace

The error message is consistent with the previous ones and provides clear guidance on the required configuration in the Scarb.toml file.


478-478: Consistent error message for missing default namespace

The error message is consistent with the previous ones and provides clear guidance on the required configuration in the Scarb.toml file.


483-483: Consistent error message for missing default namespace

The error message is consistent with the previous ones and provides clear guidance on the required configuration in the Scarb.toml file.


488-488: Consistent error message for missing default namespace

The error message is consistent with the previous ones and provides clear guidance on the required configuration in the Scarb.toml file.


493-493: Consistent error message for missing default namespace

The error message is consistent with the previous ones and provides clear guidance on the required configuration in the Scarb.toml file.


498-498: Consistent error message for missing default namespace

The error message is consistent with the previous ones and provides clear guidance on the required configuration in the Scarb.toml file.


504-504: Clear error message for unknown derive attribute

The error message clearly indicates an unknown derive attribute and suggests a missing plugin.


508-508: Consistent error message for missing default namespace

The error message is consistent with the previous ones and provides clear guidance on the required configuration in the Scarb.toml file.


514-514: Clear error message for unsupported attribute

The error message clearly indicates an unsupported attribute.

examples/game-lib/armory/manifests/dev/base/abis/dojo-world.json (5)

1-6: LGTM!

The type World implements the interface dojo::world::IWorld correctly.


7-24: LGTM!

The struct core::byte_array::ByteArray is defined correctly with the appropriate members.


25-38: LGTM!

The struct dojo::resource_metadata::ResourceMetadata is defined correctly with the appropriate members.


39-48: LGTM!

The struct core::array::Span::<core::felt252> is defined correctly with the appropriate member.


137-524: LGTM!

The interface dojo::world::IWorld and its functions are defined correctly.

examples/game-lib/manifests/dev/base/abis/dojo-world.json (5)

1-6: LGTM!

The type World implements the interface dojo::world::IWorld correctly.


7-24: LGTM!

The struct core::byte_array::ByteArray is defined correctly with the appropriate members.


25-38: LGTM!

The struct dojo::resource_metadata::ResourceMetadata is defined correctly with the appropriate members.


39-48: LGTM!

The struct core::array::Span::<core::felt252> is defined correctly with the appropriate member.


137-524: LGTM!

The interface dojo::world::IWorld and its functions are defined correctly.

examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples-Flatbow-3632af69.json (1)

1-411: Correctness of JSON structure.

The JSON structure appears to be well-formed and follows the expected schema for defining models, enums, interfaces, and structs. Ensure that all fields and types are correctly defined and used in the project.

crates/torii/graphql/src/tests/mod.rs (3)

5-19: Review new imports.

The new imports appear to be necessary for the added functionality. Ensure that all imported modules and items are used correctly in the code.


276-294: Use of CompilerTestSetup in spinup_types_test.

The setup and configuration for the test have been refactored to use CompilerTestSetup. This improves code clarity and maintainability. Ensure that the paths and configurations are correct.


Line range hint 317-340:
Transaction handling and engine synchronization.

The added code handles transactions and synchronizes the engine to the head. Ensure that the transaction handling and synchronization logic is correct.

examples/game-lib/manifests/dev/base/abis/models/bestiary-RiverSkale-1bce2040.json (1)

1-415: Correctness of JSON structure.

The JSON structure appears to be well-formed and follows the expected schema for defining models, enums, interfaces, and structs. Ensure that all fields and types are correctly defined and used in the project.

bin/sozo/src/commands/build.rs (1)

Line range hint 217-231:
Use of CompilerTestSetup in tests.

The test setup has been refactored to use CompilerTestSetup. This improves code clarity and maintainability. Ensure that the paths and configurations are correct.

crates/dojo-lang/src/semantics/test_data/get (3)

32-66: Useful error messages for missing namespaces.

The added error messages provide clear guidance on ensuring the default namespace is specified in the Scarb.toml file. This will help users quickly identify and fix missing namespace issues.


115-149: Consistent and useful error messages for missing namespaces.

These error messages continue to provide clear and specific guidance on ensuring the default namespace is specified in the Scarb.toml file, maintaining consistency with the previous segment.


324-358: Specific error message for missing trait implementation.

The error message clearly indicates that the dojo::model::Model trait has no implementation in the context. This will help users identify and fix issues with missing trait implementations when using the get! macro.

crates/sozo/ops/src/tests/setup.rs Show resolved Hide resolved
crates/dojo-world/src/contracts/model_test.rs Show resolved Hide resolved
)
.await
})
.map(|_| ()),
Copy link
Collaborator

Choose a reason for hiding this comment

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

didnt understand why this was added

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The outer function is expecting a result with () unit type, but in our case, we now return MigrationOutput, which in other places can be very useful to access.

Using .map(|_| ()) ensures that whatever is returned with Ok, we return the unit type discarding the returned value.

@@ -192,17 +192,14 @@ pub fn handle_model_struct(
db: &dyn SyntaxGroup,
aux_data: &mut DojoAuxData,
struct_ast: ItemStruct,
package_id: String,
default_namespace: String,
Copy link
Collaborator

Choose a reason for hiding this comment

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

doc comment above this got outdated

crates/dojo-lang/src/plugin_test_data/model Show resolved Hide resolved
crates/dojo-lang/src/plugin_test_data/print Outdated Show resolved Hide resolved
crates/dojo-lang/src/semantics/test_data/get Outdated Show resolved Hide resolved
crates/dojo-lang/src/semantics/test_data/set Outdated Show resolved Hide resolved
crates/dojo-lang/src/plugin_test_data/system Outdated Show resolved Hide resolved
crates/dojo-lang/src/utils.rs Outdated Show resolved Hide resolved
crates/dojo-test-utils/src/compiler.rs Show resolved Hide resolved
examples/spawn-and-move/src/actions.cairo Show resolved Hide resolved
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: 10

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 18dfea2 and 112175f.

Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
Files selected for processing (37)
  • crates/dojo-core/Scarb.toml (1 hunks)
  • crates/dojo-lang/src/compiler.rs (7 hunks)
  • crates/dojo-lang/src/contract.rs (4 hunks)
  • crates/dojo-lang/src/manifest_test_data/compiler_cairo/Scarb.toml (1 hunks)
  • crates/dojo-lang/src/model.rs (5 hunks)
  • crates/dojo-lang/src/plugin.rs (9 hunks)
  • crates/dojo-lang/src/plugin_test_data/introspect (12 hunks)
  • crates/dojo-lang/src/plugin_test_data/print (1 hunks)
  • crates/dojo-lang/src/plugin_test_data/system (2 hunks)
  • crates/dojo-lang/src/semantics/test_data/get (3 hunks)
  • crates/dojo-lang/src/semantics/test_data/set (3 hunks)
  • crates/dojo-lang/src/utils.rs (2 hunks)
  • crates/dojo-world/Cargo.toml (1 hunks)
  • crates/dojo-world/src/contracts/world_test.rs (3 hunks)
  • crates/dojo-world/src/metadata.rs (5 hunks)
  • crates/dojo-world/src/metadata_test.rs (4 hunks)
  • crates/torii/graphql/src/tests/metadata_test.rs (1 hunks)
  • crates/torii/types-test/Scarb.toml (1 hunks)
  • examples/game-lib/armory/Scarb.toml (1 hunks)
  • examples/game-lib/armory/src/lib.cairo (1 hunks)
  • examples/game-lib/bestiary/Scarb.toml (1 hunks)
  • examples/game-lib/bestiary/src/lib.cairo (1 hunks)
  • examples/spawn-and-move/Scarb.toml (1 hunks)
  • examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples_foes-RiverSkale-39535c12.json (1 hunks)
  • examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples_weapons-Flatbow-22f5bd16.json (1 hunks)
  • examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-actions-40b6994c.toml (1 hunks)
  • examples/spawn-and-move/manifests/dev/base/models/dojo_examples_foes-RiverSkale-39535c12.toml (1 hunks)
  • examples/spawn-and-move/manifests/dev/base/models/dojo_examples_weapons-Flatbow-22f5bd16.toml (1 hunks)
  • examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples_foes-RiverSkale-39535c12.json (1 hunks)
  • examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples_weapons-Flatbow-22f5bd16.json (1 hunks)
  • examples/spawn-and-move/manifests/dev/deployment/manifest.json (4 hunks)
  • examples/spawn-and-move/manifests/dev/deployment/manifest.toml (3 hunks)
  • examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples_foes-RiverSkale-39535c12.json (1 hunks)
  • examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples_weapons-Flatbow-22f5bd16.json (1 hunks)
  • examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-actions-40b6994c.toml (1 hunks)
  • examples/spawn-and-move/manifests/release/base/models/dojo_examples_foes-RiverSkale-39535c12.toml (1 hunks)
  • examples/spawn-and-move/manifests/release/base/models/dojo_examples_weapons-Flatbow-22f5bd16.toml (1 hunks)
Files not summarized due to errors (2)
  • crates/dojo-lang/src/plugin_test_data/introspect: Error: Message exceeds token limit
  • crates/dojo-lang/src/plugin_test_data/system: Error: Message exceeds token limit
Files skipped from review due to trivial changes (3)
  • crates/dojo-lang/src/manifest_test_data/compiler_cairo/Scarb.toml
  • crates/torii/types-test/Scarb.toml
  • examples/spawn-and-move/manifests/dev/base/models/dojo_examples_weapons-Flatbow-22f5bd16.toml
Files skipped from review as they are similar to previous changes (15)
  • crates/dojo-core/Scarb.toml
  • crates/dojo-lang/src/compiler.rs
  • crates/dojo-lang/src/contract.rs
  • crates/dojo-lang/src/model.rs
  • crates/dojo-lang/src/plugin.rs
  • crates/dojo-lang/src/plugin_test_data/print
  • crates/dojo-lang/src/semantics/test_data/get
  • crates/dojo-lang/src/semantics/test_data/set
  • crates/dojo-lang/src/utils.rs
  • crates/dojo-world/src/contracts/world_test.rs
  • examples/game-lib/armory/Scarb.toml
  • examples/game-lib/armory/src/lib.cairo
  • examples/game-lib/bestiary/src/lib.cairo
  • examples/spawn-and-move/Scarb.toml
  • examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-actions-40b6994c.toml
Additional comments not posted (105)
examples/game-lib/bestiary/Scarb.toml (1)

16-16: Namespace Configuration

The namespace configuration has been updated to include a default namespace. This change is consistent with the objective of enhancing namespace handling. Ensure that this namespace is correctly used in the rest of the codebase.

examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-actions-40b6994c.toml (1)

2-3: Update Class Hashes and Metadata

The class hashes and metadata have been updated. Ensure these values are correct and match the actual class definitions.

Verify that these class hashes are correctly referenced in the rest of the codebase.

examples/spawn-and-move/manifests/release/base/models/dojo_examples_weapons-Flatbow-22f5bd16.toml (2)

8-21: Verify Member Definitions

The member definitions have been updated. Ensure these values are correct and match the actual class definitions.

Verify that these member definitions are correctly referenced in the rest of the codebase.


2-3: Update Class Hashes and Metadata

The class hashes and metadata have been updated. Ensure these values are correct and match the actual class definitions.

Verify that these class hashes are correctly referenced in the rest of the codebase.

examples/spawn-and-move/manifests/dev/base/models/dojo_examples_foes-RiverSkale-39535c12.toml (2)

2-3: Update Class Hashes and Metadata

The class hashes and metadata have been updated. Ensure these values are correct and match the actual class definitions.

Verify that these class hashes are correctly referenced in the rest of the codebase.

Verification successful

Verified Class Hash References

The updated class hash 0x34e17c9bad7ccfa7286e07ed3a9af0b2922c7ee77a4889a1c59d0a6dd7aeacc is correctly referenced in the following files:

  • examples/spawn-and-move/manifests/dev/deployment/manifest.toml
  • examples/spawn-and-move/manifests/release/base/models/dojo_examples_foes-RiverSkale-39535c12.toml
  • examples/spawn-and-move/manifests/dev/base/models/dojo_examples_foes-RiverSkale-39535c12.toml
  • examples/spawn-and-move/manifests/dev/deployment/manifest.json
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the updated class hashes are correctly referenced in the codebase.

# Test: Search for the class hash usage. Expect: Only occurances of the new class hashes.
rg --type toml --type yaml --type json '0x34e17c9bad7ccfa7286e07ed3a9af0b2922c7ee77a4889a1c59d0a6dd7aeacc'

Length of output: 1442


8-26: Verify Member Definitions

The member definitions have been updated. Ensure these values are correct and match the actual class definitions.

Verify that these member definitions are correctly referenced in the rest of the codebase.

Verification successful

Member Definitions Verified

The member definitions 'health', 'armor', and 'attack' are correctly referenced across various configuration and manifest files in the codebase.

  • examples/spawn-and-move/manifests/dev/base/models/dojo_examples_foes-RiverSkale-39535c12.toml
  • examples/spawn-and-move/manifests/release/base/models/dojo_examples_foes-RiverSkale-39535c12.toml
  • examples/spawn-and-move/manifests/dev/deployment/manifest.toml
  • examples/spawn-and-move/manifests/dev/deployment/manifest.json
  • examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples_foes-RiverSkale-39535c12.json
  • examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples_foes-RiverSkale-39535c12.json
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the updated member definitions are correctly referenced in the codebase.

# Test: Search for the member definitions usage. Expect: Only occurances of the new member definitions.
rg --type toml --type yaml --type json 'health' 'armor' 'attack'

Length of output: 153


Script:

#!/bin/bash
# Description: Verify that the updated member definitions are correctly referenced in the codebase.

# Test: Search for the member definitions usage across all file types.
rg 'health' -t toml -t yaml -t json
rg 'armor' -t toml -t yaml -t json
rg 'attack' -t toml -t yaml -t json

Length of output: 9103


Script:

#!/bin/bash
# Description: Verify that the updated member definitions are correctly referenced in the codebase.

# Test: Search for the member definitions usage across all relevant file types.
rg 'health' -t toml -t yaml -t json -t js -t ts -t py
rg 'armor' -t toml -t yaml -t json -t js -t ts -t py
rg 'attack' -t toml -t yaml -t json -t js -t ts -t py

Length of output: 9157

examples/spawn-and-move/manifests/release/base/models/dojo_examples_foes-RiverSkale-39535c12.toml (2)

1-6: Ensure Consistency of Metadata Properties

The metadata properties kind, class_hash, original_class_hash, abi, tag, and manifest_name appear consistent and correctly formatted. Ensure these values are consistent with the rest of the project.


8-26: Verify Member Definitions

The member definitions id, health, armor, and attack are correctly defined with appropriate data types and key designations. Ensure these definitions align with the project's requirements and data model.

crates/dojo-world/Cargo.toml (1)

20-20: Dependency Addition: regex

The addition of the regex dependency is correctly formatted and consistent with the existing workspace dependencies. Ensure that this dependency is necessary and used appropriately in the project.

crates/torii/graphql/src/tests/metadata_test.rs (2)

60-60: Verify Namespace Configuration in Test

The namespace configuration in the test_metadata function is correctly defined. Ensure that this configuration is consistent with the rest of the project and that the test covers all necessary cases.


60-60: Ensure Complete Coverage in Test

The test_empty_content function correctly tests for empty content in metadata. Ensure that all edge cases are covered in this test.

crates/dojo-world/src/metadata_test.rs (4)

13-13: Verify Namespace Configuration in Test

The namespace configuration in the check_metadata_deserialization function is correctly defined. Ensure that this configuration is consistent with the rest of the project and that the test covers all necessary cases.


76-76: Verify Namespace Configuration in Test

The namespace configuration in the world_metadata_hash_and_upload function is correctly defined. Ensure that this configuration is consistent with the rest of the project and that the test covers all necessary cases.


109-109: Verify Namespace Configuration in Test

The namespace configuration in the parse_world_metadata_without_socials function is correctly defined. Ensure that this configuration is consistent with the rest of the project and that the test covers all necessary cases.


109-109: Ensure Complete Coverage in Test

The get_full_dojo_metadata_from_workspace function correctly tests the retrieval of full metadata from the workspace. Ensure that all edge cases are covered in this test.

examples/spawn-and-move/manifests/dev/deployment/manifest.toml (6)

27-28: Verify the class hash.

Ensure that the class hash value is correct and consistent with the contract's actual deployment.


41-45: Verify the class hash.

Ensure that the class hash value is correct and consistent with the contract's actual deployment.

Verification successful

Class hash verification successful

The class hash value "0x14b3096b82a761f63dd47277c2b5ac18925dea43586418483939a2f1f57f674" is consistently used across multiple manifest files within the repository, indicating it is correct.

  • examples/spawn-and-move/manifests/dev/deployment/manifest.toml
  • examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-dungeon-6620e0e6.toml
  • examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-dungeon-6620e0e6.toml
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the class hash value for the contract.

# Test: Search for the class hash value in the repository. Expect: Only occurances of the correct value.
rg --type toml -A 5 $'class_hash = "0x14b3096b82a761f63dd47277c2b5ac18925dea43586418483939a2f1f57f674"'

Length of output: 2825


Line range hint 65-66:
Verify the class hash.

Ensure that the class hash value is correct and consistent with the contract's actual deployment.

Verification successful

The class hash value is consistent across the relevant files.

  • examples/spawn-and-move/manifests/dev/deployment/manifest.toml
  • examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-others-61de2c18.toml
  • examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-others-61de2c18.toml

Please ensure that this class hash corresponds to the actual deployment details of the contract.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the class hash value for the contract.

# Test: Search for the class hash value in the repository. Expect: Only occurances of the correct value.
rg --type toml -A 5 $'class_hash = "0x479bfb12dcba5398d77303e7a665fc3fedb16f2d7f9cb1f5d7e2beb3b7e2ba7"'

Length of output: 2808


266-272: Verify the class hash.

Ensure that the class hash value is correct and consistent with the model's actual deployment.

Verification successful

The class hash value is correct and consistent across the repository.

The class hash "0x34e17c9bad7ccfa7286e07ed3a9af0b2922c7ee77a4889a1c59d0a6dd7aeacc" appears consistently in the relevant files, confirming its accuracy.

  • examples/spawn-and-move/manifests/dev/deployment/manifest.toml
  • examples/spawn-and-move/manifests/release/base/models/dojo_examples_foes-RiverSkale-39535c12.toml
  • examples/spawn-and-move/manifests/dev/base/models/dojo_examples_foes-RiverSkale-39535c12.toml
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the class hash value for the model.

# Test: Search for the class hash value in the repository. Expect: Only occurances of the correct value.
rg --type toml -A 5 $'class_hash = "0x34e17c9bad7ccfa7286e07ed3a9af0b2922c7ee77a4889a1c59d0a6dd7aeacc"'

Length of output: 2998


54-55: Verify the class hash.

Ensure that the class hash value is correct and consistent with the contract's actual deployment.

Verification successful

Class hash verification successful.

The class hash "0x97cd4fb3acfe9e6a024589ea34db2fc587586d699ef3732ce627e1771158ef" is consistent across multiple configuration files within the repository.

  • examples/spawn-and-move/manifests/dev/deployment/manifest.toml
  • examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-mock_token-31599eb2.toml
  • examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-mock_token-31599eb2.toml
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the class hash value for the contract.

# Test: Search for the class hash value in the repository. Expect: Only occurances of the correct value.
rg --type toml -A 5 $'class_hash = "0x97cd4fb3acfe9e6a024589ea34db2fc587586d699ef3732ce627e1771158ef"'

Length of output: 2869


295-300: Verify the class hash.

Ensure that the class hash value is correct and consistent with the model's actual deployment.

Verification successful

Class hash value is correct and consistent.

The class hash "0x672ce1913b025af73d80030f0e7e8d5fa4debe9b011cf0a39a27514cac4a3b5" has been verified to be consistent across multiple files and environments in the repository.

  • examples/spawn-and-move/manifests/dev/deployment/manifest.toml
  • examples/spawn-and-move/manifests/release/base/models/dojo_examples_weapons-Flatbow-22f5bd16.toml
  • examples/spawn-and-move/manifests/dev/base/models/dojo_examples_weapons-Flatbow-22f5bd16.toml
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the class hash value for the model.

# Test: Search for the class hash value in the repository. Expect: Only occurances of the correct value.
rg --type toml -A 5 $'class_hash = "0x672ce1913b025af73d80030f0e7e8d5fa4debe9b011cf0a39a27514cac4a3b5"'

Length of output: 2998

examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples_foes-RiverSkale-39535c12.json (1)

1-415: Ensure ABI Consistency and Completeness

The ABI file for RiverSkale looks comprehensive and well-structured. Verify that all necessary functions and members are included and correctly defined. Ensure that the types and state mutability are appropriately specified.

examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples_foes-RiverSkale-39535c12.json (1)

1-415: Ensure ABI Consistency and Completeness

The ABI file for RiverSkale looks comprehensive and well-structured. Verify that all necessary functions and members are included and correctly defined. Ensure that the types and state mutability are appropriately specified.

examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples_foes-RiverSkale-39535c12.json (1)

1-415: Ensure ABI Consistency and Completeness

The ABI file for RiverSkale looks comprehensive and well-structured. Verify that all necessary functions and members are included and correctly defined. Ensure that the types and state mutability are appropriately specified.

crates/dojo-world/src/metadata.rs (8)

58-60: Ensure Correct Namespace Extraction

The function get_default_namespace_from_ws extracts the default namespace from the workspace metadata. Ensure that this function is correctly extracting and returning the default namespace.


62-71: Ensure Correct Namespace Configuration Extraction

The function get_namespace_config_from_ws extracts the namespace configuration from the workspace metadata. Ensure that this function is correctly extracting and returning the namespace configuration.


266-269: Validate Namespace Format

The function is_name_valid uses a regex to validate the namespace format. Ensure that the regex correctly matches valid namespace formats and rejects invalid ones.


271-275: Ensure Proper NamespaceConfig Struct Definition

The NamespaceConfig struct is defined with a default namespace and optional mappings. Ensure that this struct is correctly defined and used in the codebase.


278-355: Validate NamespaceConfig Methods

The methods in the NamespaceConfig implementation provide functionality for creating, adding mappings, getting mappings, and validating the namespace configuration. Ensure that these methods are correctly implemented and used in the codebase.


Line range hint 362-375:
Ensure Proper ProjectWorldMetadata Struct Definition

The ProjectWorldMetadata struct is defined with various fields, including the namespace configuration. Ensure that this struct is correctly defined and used in the codebase.


375-375: Ensure Proper WorldMetadata Struct Definition

The WorldMetadata struct is defined with various fields, including the namespace configuration. Ensure that this struct is correctly defined and used in the codebase.


564-650: Ensure Comprehensive Unit Tests

The unit tests for the NamespaceConfig struct and related functions are comprehensive. Ensure that these tests cover all edge cases and provide sufficient test coverage for the namespace configuration functionality.

crates/dojo-lang/src/plugin_test_data/introspect (68)

751-752: Approve the Copy and Drop traits implementation for StructWithPrimitives.

The Copy and Drop traits are correctly implemented for the StructWithPrimitives struct.


753-754: Approve the Copy and Drop traits implementation for StructWithStruct.

The Copy and Drop traits are correctly implemented for the StructWithStruct struct.


755-756: Approve the Copy and Drop traits implementation for StructWithSimpleArray.

The Copy and Drop traits are correctly implemented for the StructWithSimpleArray struct.


757-758: Approve the Copy and Drop traits implementation for StructWithByteArray.

The Copy and Drop traits are correctly implemented for the StructWithByteArray struct.


759-760: Approve the Copy and Drop traits implementation for StructWithComplexArray.

The Copy and Drop traits are correctly implemented for the StructWithComplexArray struct.


761-762: Approve the Copy and Drop traits implementation for StructWithSimpleTuple.

The Copy and Drop traits are correctly implemented for the StructWithSimpleTuple struct.


763-764: Approve the Copy and Drop traits implementation for StructWithComplexTuple.

The Copy and Drop traits are correctly implemented for the StructWithComplexTuple struct.


765-766: Approve the Copy and Drop traits implementation for StructWithNestedArrays.

The Copy and Drop traits are correctly implemented for the StructWithNestedArrays struct.


767-768: Approve the Copy and Drop traits implementation for StructWithNestedTuples.

The Copy and Drop traits are correctly implemented for the StructWithNestedTuples struct.


769-770: Approve the Copy and Drop traits implementation for StructWithNestedTuplesAndByteArray.

The Copy and Drop traits are correctly implemented for the StructWithNestedTuplesAndByteArray struct.


771-772: Approve the Copy and Drop traits implementation for StructWithNestedEverything.

The Copy and Drop traits are correctly implemented for the StructWithNestedEverything struct.


773-774: Approve the Copy and Drop traits implementation for GenericStruct.

The Copy and Drop traits are correctly implemented for the GenericStruct struct.


775-782: Approve the Serde trait implementation for GenericStruct.

The Serde trait is correctly implemented for the GenericStruct struct.


785-786: Approve the Copy and Drop traits implementation for StructWithBadOption.

The Copy and Drop traits are correctly implemented for the StructWithBadOption struct.


787-794: Approve the Serde trait implementation for StructWithBadOption.

The Serde trait is correctly implemented for the StructWithBadOption struct.


797-810: Approve the Copy, Drop, and Serde traits implementation for EnumWithBadOption.

The Copy, Drop, and Serde traits are correctly implemented for the EnumWithBadOption enum.


817-818: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


822-823: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


827-828: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


832-833: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


837-838: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


842-843: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


847-848: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


852-853: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


857-858: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


862-863: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


867-868: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


872-873: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


877-878: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


882-883: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


887-888: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


892-893: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


897-898: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


902-903: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


907-908: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


912-913: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


917-918: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


922-923: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


927-928: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


932-933: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


937-938: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


942-943: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


947-948: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


952-953: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


957-958: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


962-963: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


967-968: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


972-973: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


977-978: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


982-983: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


987-988: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


992-993: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


997-998: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


1002-1003: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


1007-1008: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


1012-1013: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


1017-1018: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


1022-1023: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


1027-1028: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


1032-1033: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


1037-1038: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


1042-1043: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


1047-1048: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


1052-1053: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


1057-1058: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


1062-1063: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


1067-1068: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.


1072-1073: Approve the diagnostic error message for missing or invalid namespace configuration.

The error message accurately indicates that the namespace configuration is expected but not found or invalid.

examples/spawn-and-move/manifests/dev/deployment/manifest.json (5)

1133-1134: LGTM!

The class hashes and addresses for the DojoContract are correctly formatted.


1434-1445: LGTM!

The function enter_dungeon is correctly defined with appropriate inputs and state mutability.


1537-1541: LGTM!

The class hashes and addresses for the DojoContract are correctly formatted.


5781-5807: LGTM!

The model members and class hashes for the DojoModel are correctly defined and formatted.


6226-6246: LGTM!

The model members and class hashes for the DojoModel are correctly defined and formatted.

@@ -355,590 +355,330 @@ mod ctxnamed {
}

//! > expected_diagnostics
error: The contract namespace 'My@Namespace' can only contain characters (a-z/A-Z), numbers (0-9) and underscore (_)
error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid.
Copy link

Choose a reason for hiding this comment

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

Namespace configuration expected.

Ensure that the namespace configuration is correctly specified in the Scarb.toml file.

^***********^

error: Unsupported attribute.
error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid.
Copy link

Choose a reason for hiding this comment

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

Namespace configuration expected.

Ensure that the namespace configuration is correctly specified in the Scarb.toml file.

--> test_src/lib.cairo:11:1
#[dojo::contract(namespace: 'my_namespace')]
^******************************************^

error: Unsupported attribute.
error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid.
Copy link

Choose a reason for hiding this comment

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

Namespace configuration expected.

Ensure that the namespace configuration is correctly specified in the Scarb.toml file.

--> test_src/lib.cairo:21:1
#[dojo::contract(namespace: "my_namespace")]
^******************************************^

error: Unsupported attribute.
error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid.
Copy link

Choose a reason for hiding this comment

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

Namespace configuration expected.

Ensure that the namespace configuration is correctly specified in the Scarb.toml file.

--> test_src/lib.cairo:28:1
#[dojo::contract]
^***************^

error: Unsupported attribute.
error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid.
Copy link

Choose a reason for hiding this comment

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

Namespace configuration expected.

Ensure that the namespace configuration is correctly specified in the Scarb.toml file.

--> test_src/lib.cairo:38:1
#[dojo::contract]
^***************^

error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid.
Copy link

Choose a reason for hiding this comment

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

Unsupported attribute.

Ensure that the attribute used is supported by the compiler.

#[starknet::component]
^********************^

error: Unsupported attribute.
Copy link

Choose a reason for hiding this comment

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

Unsupported attribute.

Ensure that the attribute used is supported by the compiler.

#[starknet::component]
^********************^

error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid.
Copy link

Choose a reason for hiding this comment

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

Namespace configuration expected.

Ensure that the namespace configuration is correctly specified in the Scarb.toml file.

error: Unsupported attribute.
--> test_src/lib.cairo:58:1
Copy link

Choose a reason for hiding this comment

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

Unsupported attribute.

Ensure that the attribute used is supported by the compiler.

#[starknet::component]
^********************^

error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid.
Copy link

Choose a reason for hiding this comment

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

Namespace configuration expected.

Ensure that the namespace configuration is correctly specified in the Scarb.toml file.

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)
crates/dojo-lang/src/plugin_test_data/introspect (1)

514-514: Ensure proper formatting and spacing.

The impl Vec2Copy line should be properly spaced for readability.

-}impl Vec2Copy of core::traits::Copy::<Vec2>;
+}
+
+impl Vec2Copy of core::traits::Copy::<Vec2>;
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 112175f and e43f0ee.

Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
Files selected for processing (8)
  • crates/benches/contracts/Scarb.toml (1 hunks)
  • crates/dojo-lang/Cargo.toml (1 hunks)
  • crates/dojo-lang/src/plugin_test.rs (3 hunks)
  • crates/dojo-lang/src/plugin_test_data/introspect (2 hunks)
  • crates/dojo-lang/src/plugin_test_data/print (2 hunks)
  • crates/dojo-lang/src/semantics/test_data/get (3 hunks)
  • crates/dojo-lang/src/semantics/test_data/set (3 hunks)
  • crates/dojo-lang/src/utils.rs (2 hunks)
Files skipped from review due to trivial changes (1)
  • crates/benches/contracts/Scarb.toml
Files skipped from review as they are similar to previous changes (4)
  • crates/dojo-lang/src/plugin_test_data/print
  • crates/dojo-lang/src/semantics/test_data/get
  • crates/dojo-lang/src/semantics/test_data/set
  • crates/dojo-lang/src/utils.rs
Additional comments not posted (7)
crates/dojo-lang/Cargo.toml (1)

58-58: Add context for the newly added dependency.

The assert_fs dependency has been added. Ensure that its purpose is clear and justified.

What is the specific use case for this dependency? Does it align with the project's goals and requirements?

crates/dojo-lang/src/plugin_test.rs (2)

10-14: Import changes acknowledged.

The import of assert_fs aligns with its addition in Cargo.toml. This indicates its use in the test setup.


100-136: Verify the correctness and purpose of temporary directory setup and file creation.

Ensure that the setup aligns with the test objectives and is error-free.

What specific scenarios are these changes testing? Are there any edge cases that need to be considered?

crates/dojo-lang/src/plugin_test_data/introspect (4)

2904-2904: Ensure error messages provide clear guidance.

The error message for Option<T> with tuples should suggest using a struct instead.


2914-2914: Ensure error messages provide clear guidance.

The error message for using Introspect and IntrospectPacked attributes together is clear and accurate.


2934-2934: Ensure error messages provide clear guidance.

The error message for packing arrays is clear and accurate.


514-514: Remove duplicate implementation of Vec2Introspect.

The Vec2Introspect implementation appears twice, which may cause issues.

-impl Vec2Introspect<> of dojo::database::introspect::Introspect<Vec2<>> {
+// Duplicate implementation, remove one of them.
-impl Vec2Introspect<> of dojo::database::introspect::Introspect<Vec2<>> {

Likely invalid or redundant comment.

@glihm
Copy link
Collaborator Author

glihm commented Jul 12, 2024

The mappings are great, but we're still having an issue.

Usually if a namespace is given in the attribute, this is because we want to override the default namespace...
Hence, in the proposed behavior, the namespace is no longer overriding the default one, even in a crate that is not a library.

So we're still need to find a better solution.

We could also add namespace mapping for models inside our crate into the Scarb.toml, and we no longer support #[dojo::model(namespace: "overriding_nm")]. This can solves both problem, but a bit less maintainable for big projects with a lot of models.

Would be happy to have a discussion on that with you @remybar @lambda-0x or any contributor around.

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 e43f0ee and 73201e8.

Files selected for processing (3)
  • crates/dojo-core/src/world_test.cairo (2 hunks)
  • crates/dojo-lang/src/contract.rs (5 hunks)
  • crates/dojo-lang/src/model.rs (6 hunks)
Files skipped from review as they are similar to previous changes (2)
  • crates/dojo-lang/src/contract.rs
  • crates/dojo-lang/src/model.rs
Additional comments not posted (2)
crates/dojo-core/src/world_test.cairo (2)

48-50: LGTM! Namespace and nomapping attributes are correctly applied.

The Buzz struct has been correctly updated with namespace: "another_namespace" and nomapping: true attributes.


943-945: LGTM! Namespace and nomapping attributes are correctly applied.

The buzz_contract module has been correctly updated with namespace: "buzz_namespace" and nomapping: true attributes.

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/spawn-and-move/manifests/dev/deployment/manifest.json (2)

259-260: Update upgrade_contract function input.

The upgrade_contract function still uses original_base_class_hash instead of selector. Ensure that the function definition and all calls to this function are updated accordingly.

  • crates/sozo/ops/src/migration/migrate.rs:
    • Function definition
    • Function call
Analysis chain

Update upgrade_contract function input.

The upgrade_contract function now takes a selector instead of base_address. Ensure that all calls to this function are updated accordingly.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all calls to `upgrade_contract` are updated.

# Test: Search for the function calls to `upgrade_contract`. Expect: Only occurances of the new function signature.
rg --type rust 'upgrade_contract'

Length of output: 381


Script:

#!/bin/bash
# Extract lines around occurrences of `upgrade_contract` to verify the parameters being used.

# Extract context around the function definition
rg --type rust -A 5 -B 5 'async fn upgrade_contract' crates/sozo/ops/src/migration/migrate.rs

# Extract context around the function call
rg --type rust -A 5 -B 5 'upgrade_contract(' crates/sozo/ops/src/migration/migrate.rs

Length of output: 523


Script:

#!/bin/bash
# Extract lines around occurrences of `upgrade_contract` to verify the parameters being used.

# Extract context around the function definition
rg --type rust -A 5 -B 5 'async fn upgrade_contract' crates/sozo/ops/src/migration/migrate.rs

# Extract context around the function call with corrected regex
rg --type rust -A 5 -B 5 'upgrade_contract\(' crates/sozo/ops/src/migration/migrate.rs

Length of output: 931


Ensure tests for can_write_contract and can_write_namespace functions

The can_write_contract and can_write_namespace functions are implemented in crates/dojo-core/src/world.cairo. However, no test cases were found for these functions. Please ensure that these functions are correctly tested to verify their functionality.

  • crates/dojo-core/src/world.cairo: Implementation of can_write_contract and can_write_namespace.
Analysis chain

Line range hint 524-549:
Addition of can_write_contract and can_write_namespace functions.

The can_write_contract and can_write_namespace functions have been added to the IWorld interface. Ensure that these functions are correctly implemented and tested.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify implementation and testing of the `can_write_contract` and `can_write_namespace` functions.

# Test: Search for the implementation and tests of the `can_write_contract` and `can_write_namespace` functions. Expect: Implementation and tests present.
rg --type rust 'fn can_write_contract'
rg --type rust 'fn can_write_namespace'

Length of output: 82


Script:

#!/bin/bash
# Description: Verify the presence and testing of the `can_write_contract` and `can_write_namespace` functions.

# Search for the implementation of the `can_write_contract` function in all file types.
rg 'fn can_write_contract'

# Search for the implementation of the `can_write_namespace` function in all file types.
rg 'fn can_write_namespace'

# Search for test cases that might use the `can_write_contract` function.
rg 'can_write_contract' --type test

# Search for test cases that might use the `can_write_namespace` function.
rg 'can_write_namespace' --type test

Length of output: 567


Script:

#!/bin/bash
# Description: Verify the presence of tests for the `can_write_contract` and `can_write_namespace` functions.

# Search for test cases that might use the `can_write_contract` function in common test directories.
rg 'can_write_contract' tests/
rg 'can_write_contract' test/
rg 'can_write_contract' spec/

# Search for test cases that might use the `can_write_namespace` function in common test directories.
rg 'can_write_namespace' tests/
rg 'can_write_namespace' test/
rg 'can_write_namespace' spec/

Length of output: 462


Script:

#!/bin/bash
# Description: Verify the presence of tests for the `can_write_contract` and `can_write_namespace` functions.

# Search for test cases that might use the `can_write_contract` function in the entire repository.
rg 'can_write_contract'

# Search for test cases that might use the `can_write_namespace` function in the entire repository.
rg 'can_write_namespace'

Length of output: 2133

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 73201e8 and 64ef17a.

Files selected for processing (26)
  • crates/dojo-core/src/base_test.cairo (4 hunks)
  • crates/dojo-core/src/world.cairo (12 hunks)
  • crates/dojo-core/src/world_test.cairo (3 hunks)
  • crates/dojo-lang/src/inline_macros/mod.rs (1 hunks)
  • crates/dojo-lang/src/inline_macros/selector_from_tag.rs (1 hunks)
  • crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/dojo-world.json (4 hunks)
  • crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo-world.toml (1 hunks)
  • crates/dojo-lang/src/plugin.rs (10 hunks)
  • crates/dojo-lang/src/plugin_test_data/introspect (2 hunks)
  • crates/dojo-lang/src/plugin_test_data/print (2 hunks)
  • crates/dojo-lang/src/semantics/test_data/selector_from_tag (1 hunks)
  • crates/dojo-lang/src/semantics/test_utils.rs (1 hunks)
  • crates/dojo-lang/src/semantics/tests.rs (1 hunks)
  • crates/dojo-lang/src/utils.rs (2 hunks)
  • crates/dojo-world/src/contracts/abi/world.rs (4 hunks)
  • crates/dojo-world/src/contracts/naming.rs (2 hunks)
  • crates/sozo/ops/src/migration/migrate.rs (2 hunks)
  • examples/spawn-and-move/Scarb.toml (1 hunks)
  • examples/spawn-and-move/manifests/dev/base/abis/dojo-world.json (4 hunks)
  • examples/spawn-and-move/manifests/dev/base/dojo-world.toml (1 hunks)
  • examples/spawn-and-move/manifests/dev/deployment/abis/dojo-world.json (4 hunks)
  • examples/spawn-and-move/manifests/dev/deployment/manifest.json (29 hunks)
  • examples/spawn-and-move/manifests/dev/deployment/manifest.toml (5 hunks)
  • examples/spawn-and-move/manifests/release/base/abis/dojo-world.json (4 hunks)
  • examples/spawn-and-move/manifests/release/base/dojo-world.toml (1 hunks)
  • scripts/rebuild_test_artifacts.sh (1 hunks)
Files not summarized due to errors (1)
  • examples/spawn-and-move/manifests/dev/deployment/manifest.json: Error: Message exceeds token limit
Files skipped from review due to trivial changes (5)
  • crates/dojo-lang/src/inline_macros/mod.rs
  • crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo-world.toml
  • examples/spawn-and-move/manifests/dev/base/dojo-world.toml
  • examples/spawn-and-move/manifests/release/base/dojo-world.toml
  • scripts/rebuild_test_artifacts.sh
Files skipped from review as they are similar to previous changes (6)
  • crates/dojo-core/src/world_test.cairo
  • crates/dojo-lang/src/plugin_test_data/introspect
  • crates/dojo-lang/src/plugin_test_data/print
  • crates/dojo-lang/src/utils.rs
  • examples/spawn-and-move/Scarb.toml
  • examples/spawn-and-move/manifests/dev/deployment/manifest.toml
Additional comments not posted (75)
crates/dojo-lang/src/semantics/tests.rs (1)

19-20: Test case addition approved.

The addition of the selector_from_tag test case to the test_file_test! macro is correct and follows the existing pattern.

crates/dojo-lang/src/semantics/test_data/selector_from_tag (16)

1-2: Test case approved: Valid tag.

The test case for a valid tag correctly verifies the expected output.


6-7: Test case approved: Valid tag expression.

The test case for a valid tag expression correctly verifies the expected output.


9-15: Test case approved: Expected output for valid tag.

The expected output for a valid tag is correctly specified.


17-18: Test case approved: No diagnostics for valid tag.

The absence of diagnostics for a valid tag is correctly specified.


21-22: Test case approved: No parameters.

The test case for missing parameters correctly verifies the expected output and diagnostics.


26-27: Test case approved: No parameters expression.

The test case for missing parameters expression correctly verifies the expected output and diagnostics.


29-34: Test case approved: Expected output for missing parameters.

The expected output for missing parameters is correctly specified.


36-41: Test case approved: Diagnostics for missing parameters.

The diagnostics for missing parameters are correctly specified.


44-45: Test case approved: Invalid tag.

The test case for an invalid tag correctly verifies the expected output and diagnostics.


49-50: Test case approved: Invalid tag expression.

The test case for an invalid tag expression correctly verifies the expected output and diagnostics.


52-57: Test case approved: Expected output for invalid tag.

The expected output for an invalid tag is correctly specified.


59-64: Test case approved: Diagnostics for invalid tag.

The diagnostics for an invalid tag are correctly specified.


67-68: Test case approved: Wrong parameter.

The test case for wrong parameters correctly verifies the expected output and diagnostics.


72-73: Test case approved: Wrong parameter expression.

The test case for wrong parameters expression correctly verifies the expected output and diagnostics.


75-80: Test case approved: Expected output for wrong parameters.

The expected output for wrong parameters is correctly specified.


82-86: Test case approved: Diagnostics for wrong parameters.

The diagnostics for wrong parameters are correctly specified.

crates/dojo-lang/src/inline_macros/selector_from_tag.rs (3)

10-11: Struct addition approved.

The addition of the SelectorFromTagMacro struct with a default implementation is correct.


13-15: NamedPlugin implementation approved.

The implementation of the NamedPlugin trait for SelectorFromTagMacro with the NAME constant is correct.


17-71: InlineMacroExprPlugin implementation approved.

The implementation of the InlineMacroExprPlugin trait for SelectorFromTagMacro with the generate_code method is correct. The method handles various cases for generating selectors from tags.

crates/dojo-world/src/contracts/naming.rs (3)

32-41: Function addition approved.

The addition of the is_valid_tag function for validating tags based on a regex pattern is correct.


155-160: Test cases approved: Success scenarios.

The test cases for is_valid_tag success scenarios are correctly specified.


162-169: Test cases approved: Failure scenarios.

The test cases for is_valid_tag failure scenarios are correctly specified.

crates/dojo-core/src/base_test.cairo (2)

71-72: LGTM!

The change to use selector_from_tag!("dojo-test_contract") instead of a direct address is a good practice. It improves readability and maintainability.


92-93: LGTM!

The change to use selector_from_tag!("dojo-test_contract") instead of a direct address is a good practice. It improves readability and maintainability.

crates/dojo-lang/src/semantics/test_utils.rs (1)

60-64: LGTM!

The changes to ensure the crate configuration for the core crate and initialize the development core library are good improvements. They enhance the setup process for the semantic database.

crates/dojo-lang/src/plugin.rs (5)

116-120: LGTM!

The change to use namespace_config instead of package_id aligns with the new namespace handling approach. This is a good improvement.


Line range hint 155-182:
LGTM!

The change to use namespace_config to get the tag for the model aligns with the new namespace handling approach. This is a good improvement.


Line range hint 348-365:
LGTM!

The change to use namespace_config to handle namespaces aligns with the new namespace handling approach. This is a good improvement.


505-510: LGTM!

The change to use namespace_config to handle namespaces aligns with the new namespace handling approach. This is a good improvement.


268-269: LGTM!

The addition of the SelectorFromTagMacro to the plugin suite enhances its functionality. This is a good improvement.

crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/dojo-world.json (3)

185-200: LGTM!

The addition of the contract function to the dojo::world::IWorld interface aligns with the new namespace handling approach. This is a good improvement.


254-255: LGTM!

The modification to use a selector instead of a direct address in the upgrade_contract function aligns with the new namespace handling approach. This is a good improvement.


504-510: LGTM!

The addition of the can_write_model, can_write_contract, and can_write_namespace functions to the dojo::world::IWorld interface enhances its functionality. This is a good improvement.

Also applies to: 519-524, 544-548

examples/spawn-and-move/manifests/dev/base/abis/dojo-world.json (4)

185-200: Addition of contract function looks good.

The contract function is correctly defined and consistent with other functions in the ABI.


504-518: Addition of can_write_model function looks good.

The can_write_model function is correctly defined and consistent with other functions in the ABI.


Line range hint 519-528: Addition of can_write_contract function looks good.

The can_write_contract function is correctly defined and consistent with other functions in the ABI.


Line range hint 544-553: Addition of can_write_namespace function looks good.

The can_write_namespace function is correctly defined and consistent with other functions in the ABI.

examples/spawn-and-move/manifests/dev/deployment/abis/dojo-world.json (4)

185-200: Addition of contract function looks good.

The contract function is correctly defined and consistent with other functions in the ABI.


504-518: Addition of can_write_model function looks good.

The can_write_model function is correctly defined and consistent with other functions in the ABI.


Line range hint 519-528: Addition of can_write_contract function looks good.

The can_write_contract function is correctly defined and consistent with other functions in the ABI.


Line range hint 544-553: Addition of can_write_namespace function looks good.

The can_write_namespace function is correctly defined and consistent with other functions in the ABI.

examples/spawn-and-move/manifests/release/base/abis/dojo-world.json (3)

185-200: Addition of contract function in IWorld interface looks good.

The function contract takes a selector and returns a tuple of class hash and contract address, which aligns with the existing interface structure.


254-255: Change in upgrade_contract function signature looks good.

The function now takes a selector as an input, which is consistent with the namespace handling improvements.


504-524: Addition of can_write_model function looks good.

The function checks write permissions for models, which is consistent with the existing permission-checking functions.

crates/dojo-world/src/contracts/abi/world.rs (3)

191-206: Addition of contract function in IWorld interface looks good.

The function contract takes a selector and returns a tuple of class hash and contract address, which aligns with the existing interface structure.


260-261: Change in upgrade_contract function signature looks good.

The function now takes a selector as an input, which is consistent with the namespace handling improvements.


510-524: Addition of can_write_model function looks good.

The function checks write permissions for models, which is consistent with the existing permission-checking functions.

crates/sozo/ops/src/migration/migrate.rs (2)

8-8: Verify the usage of get_namespace_from_tag.

Ensure that the new import get_namespace_from_tag is correctly used in the file.

Verification successful

Verified the usage of get_namespace_from_tag.

The function get_namespace_from_tag is correctly used in the file crates/sozo/ops/src/migration/migrate.rs for mapping operations on strategy.models and strategy.contracts.

  • crates/sozo/ops/src/migration/migrate.rs: Correct usage in mapping operations for strategy.models and strategy.contracts.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `get_namespace_from_tag` in the file.

# Test: Search for the function usage. Expect: Correct usage of the function.
rg --type rust 'get_namespace_from_tag'

Length of output: 740


362-362: Verify the correctness of the naming::compute_selector_from_tag usage.

Ensure that the naming module is correctly imported and the function call is valid.

Verification successful

Verify the import statement for naming::compute_selector_from_tag in crates/sozo/ops/src/migration/migrate.rs.

Ensure that the naming module is correctly imported in the file where the function is used.


Verify the import statement for the naming module in crates/sozo/ops/src/migration/migrate.rs.

Ensure that the naming module is correctly imported in the file where the function is used.


The naming::compute_selector_from_tag function is correctly used and the naming module is properly imported.

  • crates/sozo/ops/src/migration/migrate.rs: The naming module is imported from dojo_world::contracts.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of the `naming::compute_selector_from_tag` usage.

# Test: Search for the `naming` module import and the function usage. Expect: Correct import and usage.
rg --type rust 'naming::compute_selector_from_tag'

Length of output: 381


Script:

#!/bin/bash
# Description: Verify the import statement for `naming::compute_selector_from_tag` in `crates/sozo/ops/src/migration/migrate.rs`.

# Test: Search for the import statement in the specified file. Expect: Correct import statement.
rg --type rust 'use .*naming::compute_selector_from_tag;' crates/sozo/ops/src/migration/migrate.rs

Length of output: 100


Script:

#!/bin/bash
# Description: Verify the import statement for the `naming` module in `crates/sozo/ops/src/migration/migrate.rs`.

# Test: Search for any import statements related to `naming` in the specified file. Expect: Correct import statement.
rg --type rust 'use .*naming' crates/sozo/ops/src/migration/migrate.rs

Length of output: 109

crates/dojo-core/src/world.cairo (8)

481-497: LGTM! Verify _check_model_write_access function.

The implementation of the can_write_model function looks good. Ensure that the _check_model_write_access function is correctly defined and used.

Verification successful

Let's perform a more extensive search to locate the _check_model_write_access function and verify its implementation.


LGTM! The _check_model_write_access function is correctly defined and used.

The implementation of the can_write_model function and the _check_model_write_access function looks good. No further issues were found.

  • _check_model_write_access is defined and performs necessary permission checks.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the `_check_model_write_access` function is correctly defined and used.

# Test: Search for the `_check_model_write_access` function definition. Expect: The function is correctly defined and used.
rg --type rust '_check_model_write_access' -A 5

Length of output: 47


Script:

#!/bin/bash
# Search for the `_check_model_write_access` function definition in the entire codebase.
rg '_check_model_write_access' -A 10

Length of output: 2869


657-663: LGTM! Verify ResourceData enum.

The implementation of the contract function looks good. Ensure that the ResourceData enum is correctly defined and includes the Contract variant.

Verification successful

Verified: The ResourceData enum includes the Contract variant.

The ResourceData enum is correctly defined in the crates/dojo-core/src/world.cairo file and includes the Contract variant, ensuring the contract function implementation is correct.

  • crates/dojo-core/src/world.cairo:
    enum ResourceData {
        Model: (ClassHash, ContractAddress),
        Contract: (ClassHash, ContractAddress),
        Namespace,
        World,
        #[default]
        None,
    }
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the `ResourceData` enum includes the `Contract` variant.

# Test: Search for the `ResourceData` enum definition. Expect: The enum includes the `Contract` variant.
rg --type rust 'enum ResourceData' -A 10

Length of output: 42


Script:

#!/bin/bash
# Description: Verify the `ResourceData` enum includes the `Contract` variant in Cairo files.

# Test: Search for the `ResourceData` enum definition in Cairo files. Expect: The enum includes the `Contract` variant.
rg --type cairo 'enum ResourceData' -A 10

Length of output: 73


Script:

#!/bin/bash
# Description: Verify the `ResourceData` enum includes the `Contract` variant in all files.

# Test: Search for the `ResourceData` enum definition in all files. Expect: The enum includes the `Contract` variant.
rg 'enum ResourceData' -A 10

Length of output: 667


533-545: LGTM! Verify _check_basic_write_access function.

The implementation of the can_write_namespace function looks good. Ensure that the _check_basic_write_access function is correctly defined and used.

Verification successful

The _check_basic_write_access function is correctly defined and used.

The function _check_basic_write_access is properly implemented and checks if the provided contract can write to the model by verifying if the contract is a writer, the account owner, or an account writer for the given resource ID.

  • Location: crates/dojo-core/src/world.cairo
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the `_check_basic_write_access` function is correctly defined and used.

# Test: Search for the `_check_basic_write_access` function definition. Expect: The function is correctly defined and used.
rg --type rust '_check_basic_write_access' -A 5

Length of output: 47


Script:

#!/bin/bash
# Description: Verify the `_check_basic_write_access` function is correctly defined and used.

# Test: Search for the `_check_basic_write_access` function definition in all file types, with a focus on Cairo files.
rg '_check_basic_write_access' -A 5

Length of output: 2316


701-713: LGTM! Verify initialized_contract map.

The implementation of the deploy_contract function looks good. Ensure that the initialized_contract map is correctly defined and used.

Verification successful

The initialized_contract map is correctly defined and used.

The initialized_contract map is defined as Map::<felt252, bool> in crates/dojo-core/src/world.cairo and is appropriately used in the deploy_contract function to manage contract initialization status.

  • Definition: crates/dojo-core/src/world.cairo: initialized_contract: Map::<felt252, bool>
  • Usage: crates/dojo-core/src/world.cairo in the deploy_contract function
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the `initialized_contract` map is correctly defined and used.

# Test: Search for the `initialized_contract` map definition. Expect: The map is correctly defined and used.
rg --type rust 'initialized_contract' -A 5

Length of output: 42


Script:

#!/bin/bash
# Description: Verify the `initialized_contract` map is correctly defined and used.

# Test: Search for the `initialized_contract` map definition and usage across all file types.
rg 'initialized_contract' -A 5

Length of output: 1311


499-520: LGTM! Verify _check_contract_write_access function.

The implementation of the can_write_contract function looks good. Ensure that the _check_contract_write_access function is correctly defined and used.

Verification successful

Verification Successful: _check_contract_write_access Function

The _check_contract_write_access function is correctly defined and used within crates/dojo-core/src/world.cairo. It performs the necessary checks to determine if a contract has write access.

  • Location: crates/dojo-core/src/world.cairo
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the `_check_contract_write_access` function is correctly defined and used.

# Test: Search for the `_check_contract_write_access` function definition. Expect: The function is correctly defined and used.
rg --type rust '_check_contract_write_access' -A 5

Length of output: 50


Script:

#!/bin/bash
# Description: Verify the `_check_contract_write_access` function is correctly defined and used.

# Test: Search for the `_check_contract_write_access` function definition in the entire repository.
rg '_check_contract_write_access' -A 5

Length of output: 1513


Script:

#!/bin/bash
# Description: Extract the full implementation of the `_check_contract_write_access` function from `crates/dojo-core/src/world.cairo`.

# Test: Extract lines around the `_check_contract_write_access` function definition.
rg '_check_contract_write_access' -A 20 -B 5 crates/dojo-core/src/world.cairo

Length of output: 3619


465-468: LGTM! Verify _check_*_write_access functions.

The implementation of the can_write_resource function looks good. Ensure that the _check_*_write_access functions are correctly defined and used.

Verification successful

Verification Successful: _check_*_write_access functions are correctly defined and used.

The _check_model_write_access, _check_contract_write_access, and _check_basic_write_access functions are properly defined and utilized within the crates/dojo-core/src/world.cairo file. The implementation of the can_write_resource function is validated.

  • _check_model_write_access: Defined at line 465
  • _check_contract_write_access: Defined at line 478
  • _check_basic_write_access: Defined at line 491
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the `_check_*_write_access` functions are correctly defined and used.

# Test: Search for the `_check_*_write_access` functions definitions. Expect: The functions are correctly defined and used.
rg --type rust '_check_.*_write_access' -A 5

Length of output: 46


Script:

#!/bin/bash
# Description: Verify the `_check_*_write_access` functions are correctly defined and used.

# Test: Search for the `_check_*_write_access` functions definitions across all files.
rg '_check_.*_write_access' -A 5

Length of output: 4412


Line range hint 992-1007:
LGTM! Verify is_writer, is_account_owner, and is_account_writer functions.

The implementation of the _check_model_write_access function looks good. Ensure that the is_writer, is_account_owner, and is_account_writer functions are correctly defined and used.

Verification successful

Functions is_writer, is_account_owner, and is_account_writer are correctly defined and used.

The functions is_writer, is_account_owner, and is_account_writer are defined in the crates/dojo-core/src/world.cairo file and appear to be implemented correctly.

  • is_writer:

    fn is_writer(self: @ContractState, resource: felt252, contract: ContractAddress) -> bool {
        self.writers.read((resource, contract))
    }
  • is_account_owner:

    fn is_account_owner(self: @ContractState, resource: felt252) -> bool {
        IWorld::is_owner(self, self._get_account_address(), resource)
            || self.is_account_world_owner()
    }
  • is_account_writer:

    fn is_account_writer(self: @ContractState, resource: felt252) -> bool {
        IWorld::is_writer(self, resource, self._get_account_address())
    }

These functions are correctly defined and used within the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the `is_writer`, `is_account_owner`, and `is_account_writer` functions are correctly defined and used.

# Test: Search for the `is_writer`, `is_account_owner`, and `is_account_writer` functions definitions. Expect: The functions are correctly defined and used.
rg --type rust 'fn is_writer' -A 5
rg --type rust 'fn is_account_owner' -A 5
rg --type rust 'fn is_account_writer' -A 5

Length of output: 125


Script:

#!/bin/bash
# Description: Verify the `is_writer`, `is_account_owner`, and `is_account_writer` functions are correctly defined and used.

# Test: Search for the `is_writer`, `is_account_owner`, and `is_account_writer` functions definitions using ast-grep.
ast-grep --lang rust --pattern 'fn is_writer($$) { $$$ }'
ast-grep --lang rust --pattern 'fn is_account_owner($$) { $$$ }'
ast-grep --lang rust --pattern 'fn is_account_writer($$) { $$$ }'

Length of output: 194


Script:

#!/bin/bash
# Description: Verify the `is_writer`, `is_account_owner`, and `is_account_writer` functions are correctly defined and used in Cairo files.

# Test: Search for the `is_writer`, `is_account_owner`, and `is_account_writer` functions definitions in Cairo files using ast-grep.
ast-grep --lang cairo --pattern 'fn is_writer($$) { $$$ }'
ast-grep --lang cairo --pattern 'fn is_account_owner($$) { $$$ }'
ast-grep --lang cairo --pattern 'fn is_account_writer($$) { $$$ }'

Length of output: 530


Script:

#!/bin/bash
# Description: Verify the `is_writer`, `is_account_owner`, and `is_account_writer` functions are correctly defined and used in Cairo files.

# Test: Search for the `is_writer`, `is_account_owner`, and `is_account_writer` functions definitions in Cairo files using rg.
rg --type cairo 'fn is_writer' -A 5
rg --type cairo 'fn is_account_owner' -A 5
rg --type cairo 'fn is_account_writer' -A 5

Length of output: 218


Script:

#!/bin/bash
# Description: Verify the `is_writer`, `is_account_owner`, and `is_account_writer` functions are correctly defined and used.

# Test: Search for the `is_writer`, `is_account_owner`, and `is_account_writer` functions definitions using rg without specifying the file type.
rg 'fn is_writer' -A 5
rg 'fn is_account_owner' -A 5
rg 'fn is_account_writer' -A 5

Length of output: 2157


727-741: LGTM! Verify contract function.

The implementation of the upgrade_contract function looks good. Ensure that the contract function is correctly defined and used.

examples/spawn-and-move/manifests/dev/deployment/manifest.json (17)

4-5: Ensure consistency of class hashes.

The class_hash and original_class_hash have been updated. Verify that these values are correct and consistent with the intended contract deployment.


1147-1148: Ensure correctness of address and transaction hash.

The address and transaction_hash values have been updated. Verify that these values are correct and consistent with the intended contract deployment.


190-205: Addition of contract function.

The contract function has been added to the IWorld interface. Ensure that this function is correctly implemented and tested.


2030-2033: Ensure correctness of contract address and class hashes.

The address, class_hash, and original_class_hash values have been updated for the DojoContract. Verify that these values are correct and consistent with the intended contract deployment.


6694-6695: Ensure correctness of model configuration.

A new DojoModel has been added. Verify that the model configuration is correct and consistent with the intended deployment.


1812-1814: Ensure correctness of contract address and class hashes.

The address, class_hash, and original_class_hash values have been updated for the DojoContract. Verify that these values are correct and consistent with the intended contract deployment.


509-523: Addition of can_write_model function.

The can_write_model function has been added to the IWorld interface. Ensure that this function is correctly implemented and tested.


4510-4511: Ensure correctness of model configuration.

A new DojoModel has been added. Verify that the model configuration is correct and consistent with the intended deployment.


4957-4958: Ensure correctness of model configuration.

A new DojoModel has been added. Verify that the model configuration is correct and consistent with the intended deployment.

Verification successful

Model configuration verified.

The DojoModel configuration in the manifest.json file appears to be correct and consistent with the intended deployment. The structure and content of the model configuration are comprehensive and well-formed.

  • The class_hash and original_class_hash are correctly included.
  • The members section defines the model's attributes, including their names, types, and key status.
  • The abi section specifies the implementation details.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify correctness of model configuration.

# Test: Search for the model configuration in the codebase. Expect: Only occurances of the new model configuration.
rg --type json '0x7104c882f56f62ef1f2453319bf6a1f5784b5f33b63b65506c38d62c3e3fd40'

Length of output: 395


Script:

#!/bin/bash
# Description: Display the context around the identified lines in the manifest.json file to inspect the model configuration.

# Show 10 lines before and after the identified lines for better context.
rg --type json -A 10 -B 10 '0x7104c882f56f62ef1f2453319bf6a1f5784b5f33b63b65506c38d62c3e3fd40'

Length of output: 2125


Script:

#!/bin/bash
# Description: Extract and inspect the entire model configuration block from the manifest.json file.

# Search for the beginning of the model configuration block and display its context.
rg --type json -A 50 -B 50 '"class_hash": "0x7104c882f56f62ef1f2453319bf6a1f5784b5f33b63b65506c38d62c3e3fd40"'

Length of output: 9192


2265-2267: Ensure correctness of model configuration.

A new DojoModel has been added. Verify that the model configuration is correct and consistent with the intended deployment.

Verification successful

Model configuration is correct and consistent.

The DojoModelImpl has been correctly integrated into the system, with extensive references across various manifest files and proper implementation in the Rust source files.

  • examples/spawn-and-move/manifests/dev/deployment/manifest.json
  • crates/dojo-lang/src/model.rs
  • Various other manifest files and Rust source files.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify correctness of model configuration.

# Test: Search for the model configuration in the codebase. Expect: Only occurances of the new model configuration.
rg --type json '0x1da39caefeb15d61baa9d1d71f21ed79cf5650aa215b583e7f453c0d7d4ee65'

Length of output: 395


Script:

#!/bin/bash
# Extract the context around the class_hash and original_class_hash in the manifest.json file.
rg --type json -A 10 -B 10 '0x1da39caefeb15d61baa9d1d71f21ed79cf5650aa215b583e7f453c0d7d4ee65' examples/spawn-and-move/manifests/dev/deployment/manifest.json

Length of output: 805


Script:

#!/bin/bash
# Search for the definition and usage of DojoModelImpl in the codebase.
rg 'DojoModelImpl'

Length of output: 83032


1575-1577: Ensure correctness of contract address and class hashes.

The address, class_hash, and original_class_hash values have been updated for the DojoContract. Verify that these values are correct and consistent with the intended contract deployment.


5842-5843: Ensure correctness of model configuration.

A new DojoModel has been added. Verify that the model configuration is correct and consistent with the intended deployment.

Verification successful

Model configuration is correct and consistent.

The DojoModel configuration with class_hash 0x34e17c9bad7ccfa7286e07ed3a9af0b2922c7ee77a4889a1c59d0a6dd7aeacc is correctly referenced and consistent with other model configurations in the deployment manifest.

  • The class_hash appears only once in the relevant context.
  • The configuration aligns with other DojoModel entries.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify correctness of model configuration.

# Test: Search for the model configuration in the codebase. Expect: Only occurances of the new model configuration.
rg --type json '0x34e17c9bad7ccfa7286e07ed3a9af0b2922c7ee77a4889a1c59d0a6dd7aeacc'

Length of output: 395


Script:

#!/bin/bash
# Search for the term 'DojoModel' in the codebase to identify all related configurations.
rg --type json 'DojoModel'

Length of output: 5940


Script:

#!/bin/bash
# Extract the relevant sections from the JSON files where 'DojoModel' and 'DojoModelImpl' are mentioned.
rg --type json -A 5 -B 5 'DojoModel' examples/spawn-and-move/manifests/dev/deployment/manifest.json

Length of output: 6967


3586-3587: Ensure correctness of model configuration.

A new DojoModel has been added. Verify that the model configuration is correct and consistent with the intended deployment.

Verification successful

Ensure correctness of model configuration.

The DojoModelImpl configuration appears correct and consistent with the intended deployment. The class_hash and original_class_hash fields are likely part of deployment metadata and do not conflict with the model definition.

  • examples/spawn-and-move/manifests/dev/deployment/manifest.json: Lines 3586-3587
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify correctness of model configuration.

# Test: Search for the model configuration in the codebase. Expect: Only occurances of the new model configuration.
rg --type json '0x36b7886db455f41fac4263da9f0d21190bb575c8555bde1c3357486495c0be1'

Length of output: 395


Script:

#!/bin/bash
# Search for any references to DojoModel in the codebase to find documentation or schema defining its correct structure.
rg --type json --type md --type yaml 'DojoModel'

Length of output: 5962


Script:

#!/bin/bash
# Extract and review the structure of a DojoModelImpl from one of the JSON files.
rg --type json --json 'DojoModelImpl' examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-Position-1e145e26.json

Length of output: 1180


Script:

#!/bin/bash
# Retrieve the full content of the JSON file to examine the structure of the DojoModel.
cat examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-Position-1e145e26.json

Length of output: 9153


6281-6282: Ensure correctness of model configuration.

A new DojoModel has been added. Verify that the model configuration is correct and consistent with the intended deployment.

Verification successful

The DojoModel configuration is correct and consistent.

The class_hash and original_class_hash values are correctly placed within the DojoModel entries, and the overall structure appears to be properly configured.

  • manifest.json contains consistent and correct DojoModel configurations.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify correctness of model configuration.

# Test: Search for the model configuration in the codebase. Expect: Only occurances of the new model configuration.
rg --type json '0x672ce1913b025af73d80030f0e7e8d5fa4debe9b011cf0a39a27514cac4a3b5'

Length of output: 395


Script:

#!/bin/bash
# Description: Verify the correctness of DojoModel configuration.

# Test: Search for the DojoModel configuration in the codebase.
rg --type json 'DojoModel'

Length of output: 5940


Script:

#!/bin/bash
# Description: Extract DojoModel configurations from manifest.json for verification.

# Extract lines around DojoModel entries in manifest.json
rg --type json -A 5 -B 5 '"kind": "DojoModel"' examples/spawn-and-move/manifests/dev/deployment/manifest.json

Length of output: 2739


Script:

#!/bin/bash
# Description: Extract lines containing class_hash and original_class_hash from manifest.json for verification.

# Extract lines around class_hash and original_class_hash entries in manifest.json
rg --type json -A 5 -B 5 '"class_hash"' examples/spawn-and-move/manifests/dev/deployment/manifest.json

Length of output: 10118


5402-5403: Ensure correctness of model configuration.

A new DojoModel has been added. Verify that the model configuration is correct and consistent with the intended deployment.

Verification successful

Model configuration verified.

The DojoModel and its implementation DojoModelImpl are correctly configured and consistent with the intended deployment. The class_hash and original_class_hash are appropriately associated with the correct model implementation and interface.

  • manifest.json correctly associates class_hash and original_class_hash with DojoModelImpl and dojo::model::IModel.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify correctness of model configuration.

# Test: Search for the model configuration in the codebase. Expect: Only occurances of the new model configuration.
rg --type json '0x48dfe99daae31ced8d121079c148d084311483f047519d2d3fae363f15c7a1f'

Length of output: 395


Script:

#!/bin/bash
# Description: Verify the configuration and usage of the DojoModel.

# Search for references to DojoModel in the codebase to understand its configuration and usage.
rg --type json 'DojoModel'

Length of output: 5940


Script:

#!/bin/bash
# Extract relevant sections from the manifest.json and related files to inspect the configuration of DojoModel and DojoModelImpl.

# Extract sections from manifest.json
rg --type json -A 10 '"kind": "DojoModel"' examples/spawn-and-move/manifests/dev/deployment/manifest.json

# Extract sections from other related files
rg --type json -A 10 '"name": "DojoModelImpl"' examples/spawn-and-move/manifests/dev/base/abis/models/

Length of output: 15802


Script:

#!/bin/bash
# Extract sections from manifest.json where class_hash and original_class_hash are defined to ensure they are correctly associated with DojoModel configurations.

# Extract sections from manifest.json
rg --type json -A 10 '"class_hash": "0x48dfe99daae31ced8d121079c148d084311483f047519d2d3fae363f15c7a1f"' examples/spawn-and-move/manifests/dev/deployment/manifest.json

Length of output: 590


4043-4044: Ensure correctness of model configuration.

A new DojoModel has been added. Verify that the model configuration is correct and consistent with the intended deployment.

Verification successful

Model configuration is correct and consistent.

The DojoModel and DojoModelImpl are extensively referenced and consistently implemented across the codebase. The methods implemented in DojoModelImpl align with the expected functionality, indicating that the model configuration is correct and consistent with the intended deployment.

  • The DojoModel and DojoModelImpl are referenced in various manifest files and the crates directory.
  • The implementation details of DojoModelImpl include methods like name, namespace, tag, version, and selector, which are consistent across different models.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify correctness of model configuration.

# Test: Search for the model configuration in the codebase. Expect: Only occurances of the new model configuration.
rg --type json '0x23ec6500e0f3e8c64c6fb3ee3ed3259d81c0bde627c8c9c1177da098189dd89'

Length of output: 395


Script:

#!/bin/bash
# Description: Extract context around the model configuration entries in the manifest.json file.

# Extract 10 lines before and after the first occurrence of the class hash in the manifest.json file.
rg --type json -A 10 -B 10 '0x23ec6500e0f3e8c64c6fb3ee3ed3259d81c0bde627c8c9c1177da098189dd89' examples/spawn-and-move/manifests/dev/deployment/manifest.json

Length of output: 809


Script:

#!/bin/bash
# Description: Search for the DojoModel implementation and references in the codebase.

# Search for the DojoModel implementation.
rg --type json 'DojoModel' 

# Search for references to DojoModel in the codebase.
rg 'DojoModel'

Length of output: 99403


Script:

#!/bin/bash
# Description: Extract the implementation details of DojoModelImpl from the crates/dojo-lang/src/plugin_test_data/model file.

# Extract the implementation details of DojoModelImpl.
rg --type rust 'impl DojoModelImpl' -A 20 crates/dojo-lang/src/plugin_test_data/model

Length of output: 14139


1168-1170: Ensure correctness of contract address and class hashes.

The address, class_hash, and original_class_hash values have been updated for the DojoContract. Verify that these values are correct and consistent with the intended contract deployment.

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 64ef17a and 63d928f.

Files selected for processing (5)
  • crates/dojo-lang/src/plugin_test.rs (4 hunks)
  • crates/torii/core/src/sql_test.rs (5 hunks)
  • crates/torii/graphql/src/tests/metadata_test.rs (1 hunks)
  • crates/torii/graphql/src/tests/mod.rs (4 hunks)
  • crates/torii/grpc/src/server/tests/entities_test.rs (2 hunks)
Files skipped from review as they are similar to previous changes (3)
  • crates/dojo-lang/src/plugin_test.rs
  • crates/torii/graphql/src/tests/metadata_test.rs
  • crates/torii/grpc/src/server/tests/entities_test.rs
Additional comments not posted (26)
crates/torii/core/src/sql_test.rs (16)

3-3: Import CompilerTestSetup

The CompilerTestSetup import is introduced to set up the compiler for the test environment. This is necessary for building the test configuration.


10-12: Import migration and ConnectedAccount

The migration module and ConnectedAccount are imported to handle migrations and account connections, respectively. These imports are essential for the test setup and execution.


63-64: Initialize CompilerTestSetup

The CompilerTestSetup is initialized with paths to the core and examples directories. This sets up the environment for the test.


66-66: Build Test Configuration

The test configuration is built using the build_test_config method. This configuration is necessary for the subsequent steps in the test.


68-69: Start Katana Runner and Get Account

The KatanaRunner is started, and an account is retrieved from the runner. This sets up the environment for executing transactions.


71-82: Run Migration

The migration::migrate function is called to run the migration. This step is crucial for setting up the test environment with the necessary contracts and data.


102-103: Wait for Transaction

The TransactionWaiter is used to wait for the transaction to complete. This ensures that the transaction is fully processed before moving on to the next steps.


104-113: Initialize WorldContractReader and Sql

The WorldContractReader and Sql instances are initialized with the necessary parameters. These instances are used to interact with the world contract and the database.


117-118: Bootstrap Engine

The bootstrap_engine function is called to initialize the engine with the necessary components. This sets up the engine for the test.


122-122: Assert Models Length

The length of the models is asserted to ensure that the correct number of models have been loaded. This is a crucial validation step in the test.


195-196: Initialize CompilerTestSetup

The CompilerTestSetup is initialized with paths to the core and examples directories. This sets up the environment for the test.


200-201: Start Katana Runner and Get Account

The KatanaRunner is started, and an account is retrieved from the runner. This sets up the environment for executing transactions.


203-214: Run Migration

The migration::migrate function is called to run the migration. This step is crucial for setting up the test environment with the necessary contracts and data.


274-275: Initialize WorldContractReader

The WorldContractReader instance is initialized with the necessary parameters. This instance is used to interact with the world contract.


278-283: Initialize Sql

The Sql instance is initialized with the necessary parameters. This instance is used to interact with the database.


288-288: Bootstrap Engine

The bootstrap_engine function is called to initialize the engine with the necessary components. This sets up the engine for the test.

crates/torii/graphql/src/tests/mod.rs (10)

5-5: Import CompilerTestSetup

The CompilerTestSetup import is introduced to set up the compiler for the test environment. This is necessary for building the test configuration.


16-19: Import migration and ConnectedAccount

The migration module and ConnectedAccount are imported to handle migrations and account connections, respectively. These imports are essential for the test setup and execution.


276-277: Initialize CompilerTestSetup

The CompilerTestSetup is initialized with paths to the core and types-test directories. This sets up the environment for the test.


279-279: Build Test Configuration

The test configuration is built using the build_test_config method. This configuration is necessary for the subsequent steps in the test.


284-296: Run Migration

The migration::migrate function is called to run the migration. This step is crucial for setting up the test environment with the necessary contracts and data.


Line range hint 299-317: Execute create Transaction

The create transaction is executed to insert records into the storage. This step is necessary for setting up the test data.


330-331: Wait for Transaction

The TransactionWaiter is used to wait for the transaction to complete. This ensures that the transaction is fully processed before moving on to the next steps.


332-333: Initialize WorldContractReader

The WorldContractReader instance is initialized with the necessary parameters. This instance is used to interact with the world contract.


334-334: Initialize Sql

The Sql instance is initialized with the necessary parameters. This instance is used to interact with the database.


340-340: Bootstrap Engine

The bootstrap_engine function is called to initialize the engine with the necessary components. This sets up the engine for the test.

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

Outside diff range, codebase verification and nitpick comments (2)
crates/dojo-lang/src/plugin_test_data/introspect (1)

Line range hint 297-376:
Address unknown derive Print errors.

The diagnostics indicate that the Print derive is unknown and a plugin might be missing. Ensure that the required plugin is included and correctly configured.

crates/dojo-lang/src/plugin_test_data/system (1)

Line range hint 262-263:
Fix the namespace format in bad_namespace_format module.

The namespace format in the bad_namespace_format module is incorrect. Use a valid namespace format.

- #[dojo::contract(namespace: "My@Namespace")]
+ #[dojo::contract(namespace: "my_namespace")]
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 63d928f and 3bc5cf6.

Files selected for processing (3)
  • crates/dojo-lang/src/plugin_test_data/introspect (1 hunks)
  • crates/dojo-lang/src/plugin_test_data/print (2 hunks)
  • crates/dojo-lang/src/plugin_test_data/system (1 hunks)
Files not summarized due to errors (1)
  • crates/dojo-lang/src/plugin_test_data/introspect: Error: Message exceeds token limit
Files skipped from review as they are similar to previous changes (1)
  • crates/dojo-lang/src/plugin_test_data/print
Additional comments not posted (9)
crates/dojo-lang/src/plugin_test_data/introspect (5)

262-263: Ensure that the Serde and PrintTrait imports are necessary.

The imports for Serde and PrintTrait have been added. Verify that these imports are required and used in the code.


265-270: Define Position struct with Print derive.

The Position struct is defined with the Print derive. Ensure that the Print trait is implemented for this struct and that it is used correctly.


273-275: Define Roles struct with Print derive.

The Roles struct is defined with the Print derive. Ensure that the Print trait is implemented for this struct and that it is used correctly.


278-286: Define Player struct with Print derive.

The Player struct is defined with the Print derive. Ensure that the Print trait is implemented for this struct and that it is used correctly.


289-293: Define Enemy enum with Print derive.

The Enemy enum is defined with the Print derive. Ensure that the Print trait is implemented for this enum and that it is used correctly.

crates/dojo-lang/src/plugin_test_data/system (4)

Line range hint 265-270:
Define spawn module with namespace attribute.

The spawn module is defined with the namespace attribute. Ensure that the namespace is correctly used and matches the expected format.


Line range hint 273-275:
Define proxy module with namespace attribute.

The proxy module is defined with the namespace attribute. Ensure that the namespace is correctly used and matches the expected format.


Line range hint 278-286:
Define ctxnamed module without namespace attribute.

The ctxnamed module is defined without the namespace attribute. Ensure that this is intentional and does not cause issues with the namespace configuration.


Line range hint 289-293:
Define withevent module with event definitions.

The withevent module includes event definitions. Ensure that the events are correctly defined and used.

Comment on lines +358 to +376
error: Unknown derive `Print` - a plugin might be missing.
--> /tmp/plugin_test/src/lib.cairo:4:10
#[derive(Print)]
^***^

error: Unknown derive `Print` - a plugin might be missing.
--> /tmp/plugin_test/src/lib.cairo:12:10
#[derive(Print)]
^***^

error: Unknown derive `Print` - a plugin might be missing.
--> /tmp/plugin_test/src/lib.cairo:19:10
#[derive(Print)]
^***^

error: Unknown derive `Print` - a plugin might be missing.
--> /tmp/plugin_test/src/lib.cairo:28:10
#[derive(Print)]
^***^
Copy link

Choose a reason for hiding this comment

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

Address unknown derive Print errors.

The diagnostics indicate that the Print derive is unknown and a plugin might be missing. Ensure that the required plugin is included and correctly configured.

@glihm glihm merged commit 307653b into dojoengine:main Jul 15, 2024
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants