Generate the IDL with the codama-rs CLI and rename the program to stake - #498
Merged
Conversation
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.
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 switches IDL generation to the
codama-rsCLI and renames the program tostakeat the source.Generator (commit 1): the custom
generate-idlbin round-tripped the IDL throughserde_json::Value(aBTreeMap), which alphabetised every key — pushing static data likename/kindafter large child arrays. It's replaced bycodama-rs generate-idl --pretty(matching associated-token-account), which serialises the typed nodes directly and preserves declaration order. The largeidl.jsondiff is a one-time reordering; a key-sorted comparison confirms it is otherwise semantically identical.Rename (commit 2): the program is renamed
solanaStakeInterface→stakeviacodama_macros::codama_program!(name = "stake"). The previouscodama(name = "stake")attribute was inert, so the rename was applied downstream by anupdateProgramsVisitorshim incodama.mjs; that shim is now removed. Generated clients are unaffected (make generate-clientsleaves a clean tree).Also bumps
codama/codama-macrosto0.13.0.Verification
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 --checkandcargo clippy --all-targets --features codama -- --deny=warningsclean.make generate-clientsleavesclients/byte-identical.