Allow any type node as account data - #137
Merged
Merged
Conversation
accountNode.data widens from structTypeNode to the full typeNode union, matching eventNode.data: accounts can be non-structs or reuse a shared defined type via definedTypeLinkNode. The struct requirement moves into semantics — accountFieldValueNode.path and fieldDiscriminatorNode.name document that field references are only valid when the data type resolves to a struct, following links — enforced by downstream validators. Adds a worked example of an account linking its data to a defined type.
This was referenced Sep 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements #126:
accountNode.datawidens fromstructTypeNodeto the fulltypeNodeunion, matchingeventNode.data. Accounts whose data is not a struct no longer need a fake single-field struct, and account data can be adefinedTypeLinkNode— unblocking Anchor conversion linking (codama-idl/codama#690) and defined-type reuse (codama-idl/codama#68, closed as subsumed).The struct requirement moves from the shape of the spec into semantics: the
datadocs,accountFieldValueNode.pathandfieldDiscriminatorNode.namenow state they are only valid when the data type resolves to a struct (following links) — enforced by downstream validators, exactly aseventNodealready behaves. A new worked example shows an account reusing a defined type via a link.Upgrade lens note (for
upgradeV1ToV2): none needed beyond #136's — every v1 struct is already valid v2 data.Closes #126 (manual close — default branch is
1.x). Part of #102.