Add clear-signing display directives to the interface - #494
Conversation
This PR annotates all 17 active stake instructions with clear-signing display metadata, using the display directives introduced in codama 0.11.0, and regenerates the IDL and clients.
- Intents and interpolated sentences for every instruction (e.g. `Withdraw ${data.args} from ${accounts.stake} to ${accounts.recipient}`); the four lamport arguments (`split`, `withdraw`, `moveStake`, `moveLamports`) render as SOL (`Amount: 2.5 SOL`).
- Struct-typed tuple args (`initialize`, `setLockup*`, `authorize*WithSeed`) are flattened into the fallback list, with field labels authored on the target types (`Locked Until`, `Authority Type`, `New Authority`, …) so account-state rendering benefits too.
- The `unixTimestamp` fields carry labels in Rust; the date-time display lives on the `unixTimestamp` alias in `codama.mjs`, where the alias is created. Account-state extras: SOL displays on `rentExemptReserve` and `delegation.stake`, `_reserved` hidden.
- Sysvars, the `unused` account, and discriminators are hidden from the fallback list; renames follow the conventions of the other annotated programs (`From`/`To`, `Stake Account`, `Base Key`, …).
- Bumps `codama`/`codama-macros` to 0.11.0, JS `codama` to ^1.10.1, and `@codama/renderers-rust` to ^3.1.3 (its bundled visitors crash on the new IDL otherwise). Two small `codama.mjs` guards compensate for empty child arrays now being omitted from the generated IDL; the remaining renderer template gap is tracked upstream.
**Note on the regenerated Rust client diffs**: the changes to the 17 generated instruction files come from the renderers-rust 3.1.0 → 3.1.3 bump, not from the display work (display metadata does not affect client codegen — the JS client output is byte-identical). In particular, renderers-rust 3.1.1 ([renderers-rust#82](codama-idl/renderers-rust#82)) fixed swapped `is_writable`/`is_signer` flags on remaining accounts in the CPI builders, which means the currently published `solana-stake-client` sets those flags incorrectly for callers of `invoke_with_remaining_accounts` / `invoke_signed_with_remaining_accounts`. This PR picks up that fix; a patch release of the Rust client may be worth cutting after merge.
Verified with `cargo check --features codama`, clippy, fmt, the interface test suite (63 tests), compilation of the regenerated Rust client, and by rendering every instruction end-to-end through `@codama/dynamic-instructions` 0.4.0.
Rendered output for reviewTo make this JSON diff easier to review, every instruction below is rendered end-to-end through
|
joncinque
left a comment
There was a problem hiding this comment.
Looks good! For the set-authority variants, is it possible to include what kind of authority it is? ie have "Set stake authority..." and "Set withdrawal authority..."?
Review feedback on #494: the interpolated intents for authorize and authorizeChecked now render the StakeAuthorize variant, e.g. "Set the Withdrawer authority of ... to ...", instead of the generic "Set an authority of ...". Enum placeholders resolve through the variant's display label since @codama/dynamic-instructions 0.4.0. The authorizeWithSeed and authorizeCheckedWithSeed sentences are unchanged: their StakeAuthorize sits inside the args struct and interpolation placeholders do not support nested paths yet; their fallback field lists still carry the Authority Type field. Clients are unaffected (display metadata does not drive codegen).
|
Good shout for the authority type, I couldn't do it with the two |
This PR annotates all 17 active stake instructions with clear-signing display metadata, using the display directives introduced in codama 0.11.0, and regenerates the IDL and clients.
Withdraw ${data.args} from ${accounts.stake} to ${accounts.recipient}); the four lamport arguments (split,withdraw,moveStake,moveLamports) render as SOL (Amount: 2.5 SOL).initialize,setLockup*,authorize*WithSeed) are flattened into the fallback list, with field labels authored on the target types (Locked Until,Authority Type,New Authority, …) so account-state rendering benefits too.unixTimestampfields carry labels in Rust; the date-time display lives on theunixTimestampalias incodama.mjs, where the alias is created. Account-state extras: SOL displays onrentExemptReserveanddelegation.stake,_reservedhidden.unusedaccount, and discriminators are hidden from the fallback list; renames follow the conventions of the other annotated programs (From/To,Stake Account,Base Key, …).codama/codama-macrosto 0.11.0, JScodamato ^1.10.1, and@codama/renderers-rustto ^3.1.3 (its bundled visitors crash on the new IDL otherwise). Two smallcodama.mjsguards compensate for empty child arrays now being omitted from the generated IDL; the remaining renderer template gap is tracked upstream.Note on the regenerated Rust client diffs: the changes to the 17 generated instruction files come from the renderers-rust 3.1.0 → 3.1.3 bump, not from the display work (display metadata does not affect client codegen — the JS client output is byte-identical). In particular, renderers-rust 3.1.1 (renderers-rust#82) fixed swapped
is_writable/is_signerflags on remaining accounts in the CPI builders, which means the currently publishedsolana-stake-clientsets those flags incorrectly for callers ofinvoke_with_remaining_accounts/invoke_signed_with_remaining_accounts. This PR picks up that fix; a patch release of the Rust client may be worth cutting after merge.Verified with
cargo check --features codama, clippy, fmt, the interface test suite (63 tests), compilation of the regenerated Rust client, and by rendering every instruction end-to-end through@codama/dynamic-instructions0.4.0.