dojo
dojo copied to clipboard
feat: generate contracts for Dojo events
Description
At the moment, a Dojo event is tagged with the attributes dojo::event and dojo::model. To avoid that, this PR implements contract management for Dojo events directly with the dojo::event. dojo::model is no more useful for Dojo events.
Depends on https://github.com/dojoengine/dojo-core/pull/11.
TODO: remove the dojo-core part as it has been moved to the dojo-core repo.
Tests
- [X] Yes
- [ ] No, because they aren't needed
- [ ] No, because I need help
Added to documentation?
- [ ] README.md
- [ ] Dojo Book
- [X] No documentation needed
Checklist
- [X] I've formatted my code (
scripts/prettier.sh,scripts/rust_fmt.sh,scripts/cairo_fmt.sh) - [X] I've linted my code (
scripts/clippy.sh,scripts/docs.sh) - [X] I've commented my code
- [X] I've requested a review after addressing the comments
Summary by CodeRabbit
-
New Features
- Enhanced event management capabilities with new methods for registering and upgrading events.
- Introduced asynchronous functions for structured event registration in the migration process, improving user feedback and error handling.
- Added support for events in the compiler and manifest structures, enhancing the overall functionality of the Dojo framework.
-
Bug Fixes
- Adjusted expected outputs in tests to align with new functionality.
-
Refactor
- Standardized output structure for registered elements to improve clarity.
- Updated test cases to reflect changes in underlying logic and expected results.
Walkthrough
Ohayo, sensei! This pull request introduces enhancements to the Dojo framework, focusing on the addition of new methods for event handling and improvements to the event registration process. It adds register_event and upgrade_event methods, modifies event extraction tests, and introduces new asynchronous functions for better event management during migrations. These changes reflect a move towards a more structured and efficient approach in handling events and their registrations across the codebase.
Changes
| Files | Change Summary |
|---|---|
bin/sozo/tests/test_data/policies.json |
Added new methods register_event and upgrade_event, expanding event handling capabilities for a specific target address. |
crates/dojo-lang/src/compiler.rs, crates/dojo-world/src/manifest/mod.rs |
Enhanced compiler and manifest handling by introducing support for events, including new data structures and functions to manage event artifacts and integrate them into the compilation workflow. |
crates/sozo/ops/src/events.rs |
Updated a test case to reflect a change in expected event count from the extract_events function, indicating modifications in event extraction logic. |
crates/sozo/ops/src/migration/migrate.rs |
Introduced new asynchronous functions for event registration, enhancing the migration process and standardizing output structures for registered elements. Existing functions were updated for consistency and improved error handling. |
crates/sozo/ops/src/tests/model.rs |
Modified a test function to change the expected output of an asynchronous test case, reflecting an updated expected result. |
crates/torii/core/src/sql_test.rs |
Adjusted the expected outcome of a test case by changing the expected length of fetched models from the database, indicating a potential adjustment in the underlying data or logic. |
Possibly related PRs
- #2303: The changes in this PR involve updates to the Controller dependencies, which may relate to the event handling capabilities introduced in the main PR, particularly if the Controller interacts with the newly added event methods.
- #2427: This PR focuses on optimizing partial updates, which could be relevant to the event management enhancements in the main PR, as efficient updates may be necessary for handling events effectively.
Suggested labels
sozo
Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
--
I pushed a fix in commit <commit_id>, please review it.--Generate unit testing code for this file.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin 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
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: --@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.--@coderabbitai read src/utils.ts and generate unit testing code.--@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.--@coderabbitai help me debug CodeRabbit configuration file.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
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.
Codecov Report
Attention: Patch coverage is 83.61858% with 201 lines in your changes missing coverage. Please review.
Project coverage is 68.30%. Comparing base (
8613c78) to head (6a9f753). Report is 108 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #2431 +/- ##
==========================================
+ Coverage 68.21% 68.30% +0.09%
==========================================
Files 365 366 +1
Lines 48022 48768 +746
==========================================
+ Hits 32757 33311 +554
- Misses 15265 15457 +192
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Has been tackled with rc.0.