Skip to content

feat(nodes-from-anchor): add event support to V00 anchor IDLs#998

Open
stegaBOB wants to merge 2 commits into
mainfrom
stegaBOB/feat/v0-events
Open

feat(nodes-from-anchor): add event support to V00 anchor IDLs#998
stegaBOB wants to merge 2 commits into
mainfrom
stegaBOB/feat/v0-events

Conversation

@stegaBOB
Copy link
Copy Markdown
Contributor

Old (V00) anchor IDLs define events inline with fields and rely on a SHA256("event:EventName") discriminator. Bring V00 in line with V01 by emitting EventNodes for these IDLs.

Old (V00) anchor IDLs define events inline with fields and rely on a
SHA256("event:EventName") discriminator. Bring V00 in line with V01 by
emitting EventNodes for these IDLs.
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 18, 2026

🦋 Changeset detected

Latest commit: f77f67e

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

This PR includes changesets to release 1 package
Name Type
@codama/nodes-from-anchor Minor

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

@stegaBOB stegaBOB marked this pull request as ready for review May 18, 2026 18:20
@stegaBOB stegaBOB requested a review from lorisleiva May 18, 2026 18:45
@stegaBOB
Copy link
Copy Markdown
Contributor Author

Could probably make an argument for this to be a patch bump? Minor seems like a lot. I don't have a preference one way or the other

@lorisleiva
Copy link
Copy Markdown
Member

@trevor-cortex

Copy link
Copy Markdown

@trevor-cortex trevor-cortex left a comment

Choose a reason for hiding this comment

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

Brings V00 anchor IDLs in line with V01 by emitting EventNodes, using the classic sha256("event:<PascalCase>")[0..8] discriminator scheme. The shape of the produced node (hidden-prefix struct + constant discriminator) matches eventNodeFromAnchorV01 exactly, which is what we want.

Things that look right:

  • Origin gating in ProgramNode.ts (origin === 'anchor' ? … : []) mirrors how accountNodeFromAnchorV00 only attaches anchor discriminators when origin === 'anchor'. Correct — shank IDLs reusing the V00 schema shouldn't get anchor event semantics.
  • 8-byte fixed-size constant matches Anchor's classic prefix.
  • IdlV00EventField is structurally compatible with what structTypeNodeFromAnchorV00 reads (name + type); the index flag is effectively ignored, which matches actual on-chain behavior for V00 anchor events (no real indexing in the emitted bytes).
  • Changeset is a minor bump on a pre-1.0 package — appropriate for a user-facing additive feature.

Notes for subsequent reviewers:

  • Worth a quick sanity check that the expected discriminator 60b8c5f38b025a94 for MyEvent matches what anchor itself emits — easy to verify against any real V00 anchor IDL with events (e.g. an older Metaplex program).
  • No "event type missing" error path like V01 has, but that's by design: V00 defines event fields inline, so there's no separate type def to look up.

LGTM.

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.

4 participants