anchor icon indicating copy to clipboard operation
anchor copied to clipboard

Stopped serializing enums that are not serializable

Open Buzzec opened this issue 3 years ago • 1 comments

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 avatar Jul 07 '22 20:07 Buzzec

@Buzzec is attempting to deploy a commit to the 200ms Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Jul 07 '22 20:07 vercel[bot]

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?

Henry-E avatar Nov 28 '22 17:11 Henry-E

@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.

Henry-E avatar Nov 28 '22 17:11 Henry-E

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.

Henry-E avatar Dec 07 '22 10:12 Henry-E

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?

Henry-E avatar Dec 07 '22 11:12 Henry-E

Ugh, this really needs a test as well

Henry-E avatar Dec 07 '22 11:12 Henry-E

Was fixed in #2310

Buzzec avatar Apr 21 '23 19:04 Buzzec