Skip to content

Generate the IDL with the codama-rs CLI and rename the program to stake - #498

Merged
lorisleiva merged 2 commits into
mainfrom
feat/idl-generator-and-program-rename
Aug 18, 2026
Merged

Generate the IDL with the codama-rs CLI and rename the program to stake#498
lorisleiva merged 2 commits into
mainfrom
feat/idl-generator-and-program-rename

Conversation

@lorisleiva

Copy link
Copy Markdown
Member

This PR switches IDL generation to the codama-rs CLI and renames the program to stake at the source.

Generator (commit 1): the custom generate-idl bin round-tripped the IDL through serde_json::Value (a BTreeMap), which alphabetised every key — pushing static data like name/kind after large child arrays. It's replaced by codama-rs generate-idl --pretty (matching associated-token-account), which serialises the typed nodes directly and preserves declaration order. The large idl.json diff is a one-time reordering; a key-sorted comparison confirms it is otherwise semantically identical.

Rename (commit 2): the program is renamed solanaStakeInterfacestake via codama_macros::codama_program!(name = "stake"). The previous codama(name = "stake") attribute was inert, so the rename was applied downstream by an updateProgramsVisitor shim in codama.mjs; that shim is now removed. Generated clients are unaffected (make generate-clients leaves a clean tree).

Also bumps codama/codama-macros to 0.13.0.

Verification

  • Key-sorted (jq -S) comparison: commit 1 changes ordering only; commit 2 changes only the program name.
  • cargo test --features codama: 63 interface tests + 2 codama_schema tests pass on 0.13.0.
  • cargo fmt --check and cargo clippy --all-targets --features codama -- --deny=warnings clean.
  • make generate-clients leaves clients/ byte-identical.

Note: the Makefile target uses ./$(call make-path,$*) rather than a bare path — codama-rs generate-idl interface (bare single-segment relative path) currently fails with a manifest-not-found error while ./interface works. This looks like a path-canonicalisation bug in the codama-rs CLI worth fixing separately.

Replace the custom generate-idl bin with the codama-rs generate-idl CLI,
matching the associated-token-account repo. The bin round-tripped the IDL
through serde_json::Value (a BTreeMap), which alphabetised all keys; the CLI
serialises the typed nodes directly, preserving declaration order so static
data (kind, name, ...) appears before child arrays.

- Swap the Makefile generate-idl target to the pinned codama-cli.
- Delete interface/src/bin/generate-idl.rs.
- Bump codama / codama-macros to 0.13.0.
- Regenerate idl.json (ordering-only change; semantically identical).
Rename the program from solanaStakeInterface (derived from the crate name)
to stake at the source, using the codama_program! macro from codama-rs
0.13.0. The previous codama(name = "stake") attribute on the program module
was inert (the emitted IDL still used the crate-derived name), so the rename
was applied downstream by an updateProgramsVisitor shim in codama.mjs.

- Replace the inert attribute with codama_macros::codama_program!(name = "stake").
- Drop the now-redundant updateProgramsVisitor shim from codama.mjs.
- Regenerate idl.json (program name is the only change).

The generated clients are unaffected: they already rendered the program as
stake via the removed shim, so make generate-clients leaves a clean tree.
@lorisleiva
lorisleiva merged commit a0c34ce into main Aug 18, 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