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

fix: allow empty structs in v1 anchor to be parsed #452

Merged
merged 2 commits into from
Feb 15, 2025

Conversation

stegaBOB
Copy link
Contributor

@stegaBOB stegaBOB commented Feb 11, 2025

Anchor will skip serializing the fields field in v1 structs if there are no fields. This change allows Codama to recognize those types as struct types. The logic to default the fields is already in place, so this just allows it to be used.

Copy link

changeset-bot bot commented Feb 11, 2025

🦋 Changeset detected

Latest commit: edda2b5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 17 packages
Name Type
@codama/nodes-from-anchor Patch
@codama/cli Patch
@codama/renderers-js Patch
@codama/renderers-rust Patch
@codama/renderers-vixen-parser Patch
codama Patch
@codama/renderers Patch
@codama/errors Patch
@codama/node-types Patch
@codama/nodes Patch
@codama/validators Patch
@codama/visitors-core Patch
@codama/visitors Patch
@codama/dynamic-codecs Patch
@codama/dynamic-parsers Patch
@codama/renderers-core Patch
@codama/renderers-js-umi Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@lorisleiva
Copy link
Member

Hey Sammy, thanks for this! I'm not sure I understand how this works though because this PR is making the if-statement condition stronger which means the use-case where fields doesn't exist is just gonna jump to the throw statement below, right?

P.S.: Could you add a patch changeset by running changeset locally? This will make sure a new version can be released from this PR.

@stegaBOB
Copy link
Contributor Author

Just added the changeset and got all the tests to pass! They were probably failing due to me being on a mac earlier. I think you may have misread the change. It's should be removing the && 'fields' in idlType clause.

Copy link
Member

@lorisleiva lorisleiva left a comment

Choose a reason for hiding this comment

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

You're totally right, thank you!

@stegaBOB stegaBOB force-pushed the stegaBOB/fix/empty-anchor-struct branch from 22091c0 to edda2b5 Compare February 14, 2025 21:27
@lorisleiva lorisleiva merged commit 59125a8 into codama-idl:main Feb 15, 2025
4 checks passed
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