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

[BUG] injection of self and world into dojo contract should be scoped #1730

Closed
glihm opened this issue Mar 29, 2024 · 1 comment
Closed

[BUG] injection of self and world into dojo contract should be scoped #1730

glihm opened this issue Mar 29, 2024 · 1 comment
Labels
bug Something isn't working dojo-lang

Comments

@glihm
Copy link
Collaborator

glihm commented Mar 29, 2024

Describe the bug
Currently, when an #[dojo::interface] is defined, we inject automatically the self: @ContractState into the functions it contains. Same for the world, if a function contains world: IWorldDispatcher as it's first argument, we inline it.

The issue with that, is when we have internal functions or standalone function, we're applying this rule everywhere.

To Reproduce
Write a simple function into a contract that takes no argument, and when you try to call it, it will ask for an argument (being self). Also, if you have an internal implementation with a function that takes world: IWorldDispatcher as argument, it will be removed and cause compilation error.

Expected behavior
The inlining of the world: IWorldDispatcher and the auto management of world: IWorldDispatcher must only be done for #[dojo::interfaces] implementations.

The related code for contract macro is here:

pub fn check_self_parameter(

And the one for interfaces here:
pub fn rewrite_parameters(

@glihm glihm added bug Something isn't working dojo-lang labels Mar 29, 2024
@glihm
Copy link
Collaborator Author

glihm commented Mar 31, 2024

Closed in #1733.

@glihm glihm closed this as completed Mar 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dojo-lang
Projects
None yet
Development

No branches or pull requests

1 participant