-
Notifications
You must be signed in to change notification settings - Fork 188
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(dojo-lang): remove restriction for u256 as keys in models #2890
base: main
Are you sure you want to change the base?
Conversation
WalkthroughOhayo, sensei! The pull request introduces a new struct Changes
Sequence DiagramsequenceDiagram
participant Parser
participant Members
Parser->>Members: map() instead of filter_map()
Note over Parser,Members: Unconditional member creation
Members-->>Parser: Return all members without validation
Sensei, the changes look intriguing! The unconditional member parsing might introduce some interesting dynamics in the Dojo language processing. Ohayo and happy coding! 🥷🏼🔧 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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
Needs to be checked at Torii level, since multiple felt key are not supported at the moment. |
I think it should be all good as we directly use the raw felts to serialize them into our keys string. We should still do some testing to be sure there are no other unexpected issues though |
and at that point, we could also use any type as the key. as they are all serializable to felt. if at the dojo level it is supported, we could support enums as keys |
There was a problem hiding this 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 comments (1)
crates/dojo/lang/src/attribute_macros/element.rs (1)
Line range hint
42-42
: Unused parameterdiagnostics
Ohayo, sensei! The
diagnostics
parameter in theparse_members
function is now unused due to the removal of the validation logic. To keep the code clean, consider removing this parameter.Apply this diff to remove the unused parameter:
pub fn parse_members( db: &dyn SyntaxGroup, members: &[MemberAst], - diagnostics: &mut Vec<PluginDiagnostic>, ) -> Vec<Member> {
🧹 Nitpick comments (3)
crates/dojo/lang/src/attribute_macros/element.rs (1)
Line range hint
3-3
: Remove unused importsOhayo, sensei! The imports
cairo_lang_diagnostics::Severity
andTypedStablePtr
are no longer used and can be removed to tidy up the code.Apply this diff to remove the unused imports:
use cairo_lang_defs::patcher::RewriteNode; -use cairo_lang_diagnostics::Severity; use cairo_lang_defs::plugin::PluginDiagnostic; use cairo_lang_syntax::node::ast::Member as MemberAst; use cairo_lang_syntax::node::db::SyntaxGroup; -use cairo_lang_syntax::node::TypedStablePtr; use cairo_lang_syntax::node::helpers::QueryAttrs;Also applies to: 7-7
crates/dojo/core-cairo-test/src/tests/model/model.cairo (2)
28-37
: IncludeFoo3
innamespace_def()
for proper testingOhayo, sensei! The new model
Foo3
with au256
key has been defined but is not included in thenamespace_def()
function. To ensureFoo3
is properly registered and tested, please add it to thenamespace_def()
resources.Apply this diff to include
Foo3
:fn namespace_def() -> NamespaceDef { NamespaceDef { namespace: "dojo_cairo_test", resources: [ TestResource::Model(m_Foo::TEST_CLASS_HASH.try_into().unwrap()), TestResource::Model(m_Foo2::TEST_CLASS_HASH.try_into().unwrap()), + TestResource::Model(m_Foo3::TEST_CLASS_HASH.try_into().unwrap()), ].span() } }
28-37
: Add tests forFoo3
to validateu256
key functionalityOhayo, sensei! To fully ensure that the
u256
key functions correctly, consider adding tests forFoo3
similar to the existing tests forFoo
andFoo2
. This will help confirm that the changes meet the desired objectives.Do you want me to help generate the test cases for
Foo3
?
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
crates/dojo/core-cairo-test/Scarb.lock
is excluded by!**/*.lock
📒 Files selected for processing (2)
crates/dojo/core-cairo-test/src/tests/model/model.cairo
(1 hunks)crates/dojo/lang/src/attribute_macros/element.rs
(1 hunks)
🧰 Additional context used
🪛 GitHub Actions: ci
crates/dojo/lang/src/attribute_macros/element.rs
[error] 3-3: Unused import: 'cairo_lang_diagnostics::Severity'
[error] 7-7: Unused import: 'TypedStablePtr'
[error] 42-42: Unused variable: 'diagnostics'. Consider prefixing with underscore if intentional
[error] 42-42: Inefficient argument type: '&mut Vec' should be '&mut [PluginDiagnostic]'
🔇 Additional comments (1)
crates/dojo/lang/src/attribute_macros/element.rs (1)
46-49
: Simplification aligns with PR objectivesOhayo, sensei! The changes to the
parse_members
function remove the previous validation logic, allowingu256
to be used as keys. This aligns perfectly with the PR objective to remove restrictions onu256
keys. The simplification enhances code readability.
Description
Allows use of u256 as a key in a dojo model
Related issue
Tests
Added to documentation?
Checklist
scripts/prettier.sh
,scripts/rust_fmt.sh
,scripts/cairo_fmt.sh
)scripts/clippy.sh
,scripts/docs.sh
)Summary by CodeRabbit
New Features
Foo3
with modified key field typeCode Changes