Skip to content

Add clear signing display metadata to the IDL - #409

Merged
lorisleiva merged 2 commits into
mainfrom
loris/clear-signing-idl
Aug 12, 2026
Merged

Add clear signing display metadata to the IDL#409
lorisleiva merged 2 commits into
mainfrom
loris/clear-signing-idl

Conversation

@lorisleiva

Copy link
Copy Markdown
Member

This PR enriches the Codama IDL with display metadata for clear signing, per sRFC 39. The addMemo instruction gains an intent (Add memo), an interpolated intent quoting the memo text, and labels for the memo argument and the signer remaining accounts.

This allows wallets (including hardware wallets such as Ledger) to render human-readable messages for memo instructions via @codama/dynamic-instructions:

intent:       Add memo
interpolated: Add memo "gm, paying you back for lunch"

Clients were regenerated and are unaffected: renderers pass display metadata through untouched.

@lorisleiva

Copy link
Copy Markdown
Member Author

Retrofit: labels identical to the renderer's derived titleCase(name) are redundant; keeping only genuine renames makes the IDL smaller and the convention self-documenting. Kept labels are now Title Case to match the derived casing.

@lorisleiva

Copy link
Copy Markdown
Member Author

Rendered output for review

To make this JSON diff easier to review, every instruction below is rendered end-to-end through @codama/dynamic-instructions#getInstructionDisplay using synthetic sample data. Each collapsed line shows the interpolated intent at a glance (addresses abridged); expand for the full render showing both presentation modes a wallet chooses between — the interpolated sentence, or the intent-with-fields fallback screen. Address formatting (truncation, .sol names, token symbols) is left to the consuming wallet, so raw base58 appears in the full renders.

Note: the Signers label on the remaining accounts is not yet surfaced by the fallback renderer (tracked upstream); it is included for forward compatibility.

addMemo (simple memo with one signer) — Add memo "gm, paying you back for lunch"
Interpolated intent:
│ Add memo "gm, paying you back for lunch"

Intent + fields (fallback):
│ Add memo
│   Memo: gm, paying you back for lunch
addMemo (memo without signers) — Add memo "no signers"
Interpolated intent:
│ Add memo "no signers"

Intent + fields (fallback):
│ Add memo
│   Memo: no signers

@lorisleiva
lorisleiva requested a review from joncinque August 11, 2026 09:36

@joncinque joncinque left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

Comment thread idl.json
"display": {
"kind": "instructionDisplayNode",
"intent": "Add memo",
"interpolatedIntent": "Add memo \"${data.memo}\""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my own information, how do the signers get shown?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They don't in the interpolatedIntent which is supposed to be this dynamic one-liner summary that doesn't contain all the information.

They should in the intent + fields version which is a static title with some dynamic fields in case the one-liner can't be safely displayed (e.g. the decimals can't be resolved and therefore the sentence can appear ambiguous). This is currently not working because the @codama/dynamic-instructions currently doesn't support it but I'm fixing this here: codama-idl/codama#1065.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah gotcha that makes sense, thanks!

@lorisleiva
lorisleiva merged commit 3f19b65 into main Aug 12, 2026
28 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.

2 participants