Skip to content

Schema codegen #2508

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

Open
wants to merge 34 commits into
base: main
Choose a base branch
from
Open

Schema codegen #2508

wants to merge 34 commits into from

Conversation

aumetra
Copy link
Contributor

@aumetra aumetra commented Jun 23, 2025

No description provided.

@aumetra aumetra force-pushed the aw/codegen branch 3 times, most recently from 1b2bcfb to 1ddefa1 Compare June 23, 2025 13:50
@aumetra aumetra force-pushed the aw/codegen branch 2 times, most recently from 434d799 to bb024bd Compare June 23, 2025 14:03
@aumetra aumetra force-pushed the aw/codegen branch 2 times, most recently from 9d27401 to b4662af Compare June 23, 2025 14:54
Copy link
Contributor

@chipshort chipshort left a comment

Choose a reason for hiding this comment

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

I've done a lot of bug fixes and some improvements in terms of tests, but there are still some problems here. Especially testing needs improvement.
For some reason the coverage job is also failing, even though the test works fine locally.

cw_schema::NodeType::Double => "z.number()".into(),
cw_schema::NodeType::Boolean => "z.boolean()".into(),
cw_schema::NodeType::String => "z.string()".into(),
cw_schema::NodeType::Integer { .. } => "z.string().or(z.number())".into(), // TODO: is this correct?
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems with the way this whole thing is set up, we cannot distinguish between stringified integers (like Uint128, etc.) and normal ones (like u128). Probably should have caught that during the review without codegen.

{{ doc }}
{% endfor %}"""
{% for field in fields %}
{{ field.name }}: {{ field.ty }}
Copy link
Contributor

Choose a reason for hiding this comment

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

Ultimately we need some sort of handling for keywords here. E.g. the crypto-verify contract uses from as a field name, which causes invalid python code to be generated here.

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

Successfully merging this pull request may close these issues.

2 participants