Skip to content

Allow any type node as account data - #137

Merged
lorisleiva merged 1 commit into
mainfrom
account-data-any-type
Sep 1, 2026
Merged

Allow any type node as account data#137
lorisleiva merged 1 commit into
mainfrom
account-data-any-type

Conversation

@lorisleiva

Copy link
Copy Markdown
Member

This PR implements #126: accountNode.data widens from structTypeNode to the full typeNode union, matching eventNode.data. Accounts whose data is not a struct no longer need a fake single-field struct, and account data can be a definedTypeLinkNode — 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 data docs, accountFieldValueNode.path and fieldDiscriminatorNode.name now state they are only valid when the data type resolves to a struct (following links) — enforced by downstream validators, exactly as eventNode already 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.

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.
@lorisleiva
lorisleiva merged commit dbeced1 into main Sep 1, 2026
3 checks passed
@lorisleiva
lorisleiva deleted the account-data-any-type branch September 1, 2026 07:29
@lorisleiva lorisleiva linked an issue Sep 1, 2026 that may be closed by this pull request
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.

[v2] Allow any type node as account data

1 participant