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(core): add state mutability computation from world param #2049

Merged
merged 5 commits into from
Jun 13, 2024

Conversation

glihm
Copy link
Collaborator

@glihm glihm commented Jun 12, 2024

Description

On the last update, where self and ContractState were removed from the #[dojo::interface], we lost the ability of generating an ABI with the correct state mutability of the systems, everything was a view.

However, for client side code generation from ABI, we do want the systems to be identified as external in the ABI.

Also, now the use of self is definitely removed from dojo::interface and dojo::contract. Only the world parameter must be used.

  1. If the world parameter is present, the world is injected in the function + the state mutability is deduced from ref world: IWorldDispatcher or world: @IWorldDispatcher.
  2. If no world is injected, it defaults to view.

Related issue

Closes #1995.

Tests

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

Added to documentation?

  • README.md
  • Dojo Book << must be done.
  • Inline documentation in the code.

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

@glihm glihm requested a review from lambda-0x June 12, 2024 20:19
Copy link

codecov bot commented Jun 12, 2024

Codecov Report

Attention: Patch coverage is 95.54140% with 7 lines in your changes missing coverage. Please review.

Project coverage is 68.32%. Comparing base (78c88e5) to head (ff3e154).

Current head ff3e154 differs from pull request most recent head f055f75

Please upload reports for the commit f055f75 to get more accurate results.

Files Patch % Lines
crates/dojo-lang/src/syntax/world_param.rs 88.52% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2049      +/-   ##
==========================================
- Coverage   68.35%   68.32%   -0.03%     
==========================================
  Files         323      326       +3     
  Lines       40450    40426      -24     
==========================================
- Hits        27648    27620      -28     
- Misses      12802    12806       +4     

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

@glihm glihm added the dojo-core cairo core tasks label Jun 12, 2024
@glihm glihm changed the title rework: add state mutability computation from world param [core] add state mutability computation from world param Jun 12, 2024
@glihm glihm changed the title [core] add state mutability computation from world param feat(core): add state mutability computation from world param Jun 12, 2024
Copy link
Collaborator

@lambda-0x lambda-0x left a comment

Choose a reason for hiding this comment

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

few doc related suggestions, aside from that LGTM!

crates/dojo-lang/src/syntax/world_param.rs Outdated Show resolved Hide resolved
crates/dojo-lang/src/syntax/world_param.rs Outdated Show resolved Hide resolved
crates/dojo-lang/src/syntax/world_param.rs Outdated Show resolved Hide resolved
crates/dojo-lang/src/syntax/self_param.rs Outdated Show resolved Hide resolved
@glihm glihm merged commit af5be66 into dojoengine:main Jun 13, 2024
11 checks passed
@glihm glihm deleted the feat/world-state-mutability branch June 14, 2024 03:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dojo-core cairo core tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Function state mutability into dojo contract
2 participants