Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix cairo file metadata for contracts and models #2175

Merged
merged 1 commit into from
Jul 16, 2024

Conversation

remybar
Copy link
Contributor

@remybar remybar commented Jul 15, 2024

Description

Cairo files of every models/contracts are stored in the ResourceMetadata model of the world.
Unfortunately, for models, only the original file containing the model Cairo structure was stored instead of the file generated from Dojo plugins (with the model smart-contract).

Related issue

#2137

Tests

  • Yes
  • No, because they aren't needed
  • No, because I need help

Added to documentation?

  • README.md
  • Dojo Book
  • No documentation needed

Checklist

  • I've formatted my code (scripts/prettier.sh, scripts/rust_fmt.sh, scripts/cairo_fmt.sh)
  • I've linted my code (scripts/clippy.sh, scripts/docs.sh)
  • I've commented my code
  • I've requested a review after addressing the comments

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced logic for saving expanded contract source files to improve accuracy and reliability.
    • Improved error handling and file retrieval mechanisms.
  • Refactor

    • Updated function signatures for better clarity and consistency.

Copy link

coderabbitai bot commented Jul 15, 2024

Walkthrough

The recent update to compiler.rs in crates/dojo-lang streamlines the handling of contract source files. Notably, the process for saving these files now utilizes contract names to retrieve content, with enhancements in error handling and file retrieval mechanisms. Additionally, some import statements and function signatures have been refined for better clarity and functionality.

Changes

Files Change Summary
crates/dojo-lang/src/compiler.rs Updated logic for saving expanded source files to use contract names for content retrieval; revised error handling and file retrieval mechanisms. Adjusted import statements and function signatures.

Poem

In the world of code, changes bloom,
Handling contracts with a brighter plume.
Errors caught with a deft hand,
File retrievals, oh so grand.
With tweaks and turns, the compiler's tune,
Now sings a more efficient rune.
🌸🐇


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

@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 307653b and a7c5e00.

Files selected for processing (1)
  • crates/dojo-lang/src/compiler.rs (2 hunks)
Additional comments not posted (2)
crates/dojo-lang/src/compiler.rs (2)

23-23: Import statement modification.

The import statement for the naming module has been modified to use self. This is a minor change and does not affect functionality.


556-573: Improve error handling and file retrieval logic.

The changes in the save_expanded_source_file function improve error handling and file retrieval logic. Ensure that the function correctly retrieves and writes the file content based on the contract name.

@remybar remybar force-pushed the fix-cairo_file_in_metadata branch from a7c5e00 to 6e26334 Compare July 15, 2024 09:46
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 a7c5e00 and 6e26334.

Files selected for processing (1)
  • crates/dojo-lang/src/compiler.rs (2 hunks)
Additional comments not posted (3)
crates/dojo-lang/src/compiler.rs (3)

23-23: LGTM! Import statement modification is correct.

The change to use dojo_world::contracts::naming::{self}; is syntactically correct and does not impact functionality.


556-573: LGTM! File retrieval logic is sound.

The logic for retrieving the correct file content based on contract names is well-implemented. Error handling is appropriate.


574-574: LGTM! File writing logic is correct.

The logic for writing the file content to the specified directory is well-implemented. The use of format_string ensures proper formatting.

Copy link

codecov bot commented Jul 15, 2024

Codecov Report

Attention: Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.

Project coverage is 67.22%. Comparing base (307653b) to head (fe145a2).

Files Patch % Lines
crates/dojo-lang/src/compiler.rs 91.66% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2175   +/-   ##
=======================================
  Coverage   67.21%   67.22%           
=======================================
  Files         334      334           
  Lines       43022    43033   +11     
=======================================
+ Hits        28917    28928   +11     
  Misses      14105    14105           

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

@remybar remybar force-pushed the fix-cairo_file_in_metadata branch from 6e26334 to fe145a2 Compare July 15, 2024 11:14
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 6e26334 and fe145a2.

Files selected for processing (1)
  • crates/dojo-lang/src/compiler.rs (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • crates/dojo-lang/src/compiler.rs

Copy link
Collaborator

@glihm glihm left a comment

Choose a reason for hiding this comment

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

Good catch, and nice improvement. This will be perfect for automated contract verification. :)

@glihm glihm merged commit 9485d3f into dojoengine:main Jul 16, 2024
15 checks passed
Larkooo pushed a commit to Larkooo/dojo that referenced this pull request Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants