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

Function state mutability into dojo contract #1995

Closed
glihm opened this issue May 24, 2024 · 0 comments · Fixed by #2049
Closed

Function state mutability into dojo contract #1995

glihm opened this issue May 24, 2024 · 0 comments · Fixed by #2049

Comments

@glihm
Copy link
Collaborator

glihm commented May 24, 2024

Is your feature request related to a problem? Please describe.
Currently, all the functions of a dojo contracts (mostly systems) are generated as views. Even if dojo contracts are meant to be state less (we're not supposed to write any data into their storage), the ABI is then generated with state_mutability = view for those function.

Describe the solution you'd like
We should give the user the possibility to choose between view and external in the ABI, without having to pass ref self: ContractState or self: @ContractState.

In dojo, a system must be external if it writes data to the world storage. This is done using the set! macro. We should then inject the world with this information: ref world: IWorldDispatcher.

In the case we do need a view (to have some data returned from this view), we can omit the world injection, or inject it as it's done currently: world: IWorldDispatcher.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant