Open
Conversation
🦋 Changeset detectedLatest commit: 1f2038e The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
ioxde
commented
Apr 15, 2026
| leavesOnly: !renderParentInstructions, | ||
| }); | ||
| const definedTypesToExport = getAllDefinedTypes(node); | ||
| const eventsToExport = getAllEvents(node).filter(Boolean); |
Author
There was a problem hiding this comment.
Same issue as the renderers-js PR.
This guard and the *events ?? [] pattern should probably be fixed upstream so they can be removed.
7e56daa to
1f2038e
Compare
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.
NOTE: I don't like throwing out AI generated PRs, but I think in this instance it is the right move. I made the typescript and rust version at the same time. Close if this is not the direction you want to go in.
What this does
Generates Rust code from Codama event definitions:
events/{name}.rs) — Borsh-derived structs, discriminator constants, and a conditionalfrom_bytes()methodevents/{program}_events.rs) — enum of all events,identify_*()to match raw data against discriminators, andtry_parse_*()to deserialize into typed variantsFollows the same visitor pattern used for instructions and accounts. Events reuse
typeManifestVisitorby wrappingevent data in a synthetic
definedTypeNode.Discriminator handling
Supports constant, field, and size discriminators (and combinations).
from_bytes()is only generated when the event has at least one constant discriminator inside ahiddenPrefixTypeNodewith all fixed-size entries. If the prefix contains variable-length fields,from_bytes()is skipped and a warning is logged.Program-level
identify/try_parseare only generated for events with resolvable discriminators.try_parsedeserializes viaBorshDeserializedirectly rather than delegating to per-eventfrom_bytes()— this keeps the program-level API self-contained and avoids double-checking discriminators.Key implementation details
constantDiscriminatorNameandgetDiscriminatorConditionswere extracted fromdiscriminatorConstant.tsas shared utilities — instructions only needed constants, events also need match conditions for the program-levelidentifyfunctionprogramsWithEventEnumis populated beforeeventsMod.njkchecks membershipLimitations
from_bytes()generation (can't calculate a static skip offset)defaultValueare excluded from program-level aggregation (no default = no way to generate a match condition)Tests
eventsPage.test.ts— 17 test cases covering struct generation, all discriminator variants, hidden prefix offsetlogic, program-level enum/identify/parse, and module structure. E2E fixtures for Raydium CPMM (
LpChangeEvent,SwapEvent).