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

Bad Cairo source file content stored in model metadata #2137

Closed
remybar opened this issue Jul 4, 2024 · 4 comments
Closed

Bad Cairo source file content stored in model metadata #2137

remybar opened this issue Jul 4, 2024 · 4 comments
Assignees
Labels
bug Something isn't working dojo-lang sozo
Milestone

Comments

@remybar
Copy link
Contributor

remybar commented Jul 4, 2024

Describe the bug

When a Dojo project is compiled, some artifact files are produced in target/<profile_name>/models. Some of these artifacts are the Cairo source code used to build the corresponding model contract. These artifacts are then uploaded as model metadata during the project migration.

For example, in the spawn-and-move example, target/dev/models/dojo_examples-Position-1e145e26.cairo should contain the Cairo code of the Position model Starknet contract.

Unfortunately, at the moment, this source file only contains the original Cairo file. That means, the model contract is not visible at all, only the struct of the model is visible, which is useless.

To Reproduce

Just build the spawn-and-move project.

Expected behavior

Ideally, this source file should only contain the full model contract Cairo code, after code expansion done through Dojo plugins. But, as it might be complicated to isolate this part of code from a Cairo file containing several models, this source file should at least contain the corresponding full Cairo source file after code expansion.

Additional context

This part is done in the save_expanded_source_file function of crates/dojo-lang/src/compiler.rs. A lot of db/module_id methods are available to access to real/virtual files so it might be quite tricky to find the right way to handle this point.

Note that everything works fine for Dojo contract.

@remybar remybar added the bug Something isn't working label Jul 4, 2024
@glihm glihm changed the title [BUG] Bad Cairo source file content stored in model metadata Bad Cairo source file content stored in model metadata Jul 4, 2024
@Ppixelbro
Copy link

Hello @remybar and @glihm,

I would like to help with this issue. Please assign it to me.

Thanks!

@glihm glihm added this to the 1.0.0-rc milestone Jul 7, 2024
@glihm
Copy link
Collaborator

glihm commented Jul 10, 2024

@Ppixelbro thanks for the interest in contributing here! We've some check on the compiler side that needs to be realized first. This may delay this issue and @remybar will probably tackle it as it's bounded to something he is working on currently.

We should have some new good first issue coming soon.

@Ppixelbro
Copy link

Thank you for the update, @glihm I'll keep an eye out for new issues. If there's anything else I can help with in the meantime, please let me know.

@glihm
Copy link
Collaborator

glihm commented Jul 16, 2024

Done in #2175.

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 sozo
Projects
None yet
Development

No branches or pull requests

3 participants