anchor
anchor copied to clipboard
Stopped serializing enums that are not serializable
Currently all enums are being added to the idl even ones that don't meet the requirements. This fixes it by adding the same checks as structs
@Buzzec is attempting to deploy a commit to the 200ms Team on Vercel.
A member of the Team first needs to authorize it.
This has the thumbs up from armani, which is some indication that it's needed / was missing.
The code itself looks good. It checks that the enum has serializable on it and that's public. Seems reasonable. Not sure if this should be in the changelog?
@Buzzec would like to merge this but it needs a changelog added to it. It appears that allow edits from maintainers might not be activated on this PR?
- lang: Stop serializing enums that are not serializable ([#2042](https://github.com/coral-xyz/anchor/pull/2042)) here's the line to add to the fixes section of the changelog anyway.
I will probably just repurpose this into a new PR and merge it because trying to include private enums in the IDL (which some people have been complaining about) seems like clearly incorrect behaviour.
Just reading through how the attributes checks are done. I'm assuming this is comprehensive to all the enum types that serializable in anchor but don't know for certain? It seems like if there are any missing enum types that should be being serialized we will find out very soon, although I'm not a fan of that approach.
I'm probably going to switch up the variable names as well to isSerializable since it's a bool and serializable by itself is minorly confusing.
I also don't like how let attr_serializable = ["account", "associated", "event", "zero_copy"]; is just hard coded there. That seems like a recipe for disaster down the line. But I don't know if we maintain a canonical list of serializable attributes somewhere else in the code base?
Ugh, this really needs a test as well
Was fixed in #2310