Author IDL transforms with codama macros instead of render-time visitors - #500
Merged
Conversation
Move several IDL transforms from render-time codama.mjs visitors into codama macros on the interface crate, so the canonical idl.json carries them directly: - The StakeInstruction discriminator is authored as a u32 via codama(enum_discriminator(size = number(u32))). - Every instruction uses the omitted optional-account strategy via an enum-level codama(optional_account_strategy = omitted) (new in codama-rs 0.13.1). - The four *Args tuple arguments now link to their renamed *Params defined types via codama(type = link(...)), fixing links that dangled in the committed IDL, and retiring the updateDefinedTypesVisitor. - Two dead visitors forcing stakeState/stakeStateV2 enum sizes to u32 are removed — those enums already carry enum_discriminator attributes, so the raw IDL was already correct. - The empty-account-list backfill in the before section is removed as redundant; the one in the rust script remains, since @codama/renderers-rust 3.1.3 renders NaN into zero-account instructions without it. Also bump codama/codama-macros and the pinned codama-cli to 0.13.1, and drop the ./ path workaround in the Makefile now that the CLI handles bare relative paths. The generated clients are unaffected: make generate-clients leaves a clean tree.
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 moves several IDL transforms from render-time
codama.mjsvisitors into codama macros on the interface crate, so the canonicalidl.jsoncarries them directly:StakeInstructiondiscriminator is authored as au32viacodama(enum_discriminator(size = number(u32))).codama(optional_account_strategy = omitted)(new in codama-rs 0.13.1).*Argstuple arguments now link to their renamed*Paramsdefined types viacodama(type = link(...)), fixing links that dangled in the committed IDL, and retiring theupdateDefinedTypesVisitor.stakeState/stakeStateV2enum sizes tou32are removed — those enums already carryenum_discriminatorattributes, so the raw IDL was already correct.beforesection is removed as redundant; the one in therustscript remains, since@codama/renderers-rust3.1.3 rendersNaNinto zero-account instructions without it.Also bumps
codama/codama-macrosand the pinnedcodama-clito0.13.1, and drops the./path workaround in the Makefile now that the CLI handles bare relative paths.idl.jsonsemantic diff (key-sorted comparison vsmain)u8→u32on every instruction.optionalAccountStrategy: "omitted"on every instruction.definedTypeLinkNodes fixed (lockupArgs→lockupParamsetc.); onlyepoch/unixTimestampremain, resolved at render time as before.Verification
make generate-clientsleaves a clean tree — the generated JS/Rust clients are byte-identical.--features codama; all interface + codama_schema tests pass.cargo fmt --checkandcargo clippy --all-targets --features codama -- --deny=warningsclean.