Skip to content

Author IDL transforms with codama macros instead of render-time visitors - #500

Merged
lorisleiva merged 1 commit into
mainfrom
feat/move-idl-transforms-to-macros
Aug 19, 2026
Merged

Author IDL transforms with codama macros instead of render-time visitors#500
lorisleiva merged 1 commit into
mainfrom
feat/move-idl-transforms-to-macros

Conversation

@lorisleiva

Copy link
Copy Markdown
Member

This PR moves 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 bumps codama/codama-macros and the pinned codama-cli to 0.13.1, and drops the ./ path workaround in the Makefile now that the CLI handles bare relative paths.

idl.json semantic diff (key-sorted comparison vs main)

  • Discriminators: u8u32 on every instruction.
  • optionalAccountStrategy: "omitted" on every instruction.
  • Four of the six dangling definedTypeLinkNodes fixed (lockupArgslockupParams etc.); only epoch/unixTimestamp remain, resolved at render time as before.

Verification

  • make generate-clients leaves a clean tree — the generated JS/Rust clients are byte-identical.
  • Builds with and without --features codama; all interface + codama_schema tests pass.
  • cargo fmt --check and cargo clippy --all-targets --features codama -- --deny=warnings clean.

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.
@lorisleiva
lorisleiva merged commit 9c01d67 into main Aug 19, 2026
25 checks passed
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.

1 participant