feat(solana): add SPL Memo program visualizer preset#360
Draft
kyle-anchorage wants to merge 1 commit into
Draft
Conversation
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.
1. Why this PR exists
The SPL Memo program (
MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr) is one of the most common instructions in Solana transactions, but the parser had no visualizer for it. A memo instruction fell through to theunknown_programcatch-all and rendered as raw hex, so a signer could not read the memo text they were about to sign. The program was already a trusted, canonically-named entry (Memo Program) inbuiltin_programs.rs, but nothing drove its instruction-body rendering.No ticket.
2. What changed
memopreset (MemoVisualizer) that decodes a memo instruction's data as its UTF-8 text and renders it underVisualizerKind::Payments.compute_budget/associated_token_account(direct decode), not the Anchor IDL/discriminator path used bydflow_aggregatorand the dApp presets. No JSON IDL file is bundled.Memo; condensed view showsProgram: Memo Programplus the memo text; expanded view adds the resolved Program ID and the raw-data hex.(empty memo), non-UTF-8 data renders(non-UTF-8 data; see Raw Data), and the raw bytes stay visible in the Raw Data field in every case.Memo1Uhk...) has an identical interface and could be added with a one-line config change.3. Why this is safe
Backward compatibility. Purely additive. Before, memo instructions rendered via
unknown_program; now they get a dedicated, richer rendering. No existing preset, dispatch order, or output changes —build.rskeeps the catch-allunknown_programordered last, and the new visualizer only claims the memo program ID.How it was built. Dispatch is driven by
SolanaIntegrationConfig: the preset registers the memo program ID, andvisualize_with_anyselectsMemoVisualizerahead of the catch-all becausebuild.rsorders specific visualizers first. The decode is a singlestd::str::from_utf8with explicit fallbacks; there is nounwrap/expect/panic/unsafe(all denied by workspace lints).Risks mitigated.
Memo Programis already a reserved canonical name and the program ID is in the trusted set inbuiltin_programs.rs, so a caller-supplied IDL cannot impersonate or override it.Checks run (by agent)
cargo fmt -p visualsign-solana— cleancargo clippy -p visualsign-solana --all-targets -- -D warnings— cleancargo clippy -p visualsign-solana --features diagnostics --all-targets -- -D warnings— cleancargo test -p visualsign-solanaandcargo test -p visualsign-solana --features diagnostics— pass (8 new memo unit tests)make -C src test(full workspace + gRPC integration) — exit 0, 0 failuresVersionedTransactionand ran it throughparser_cli --chain solana --output human; confirmed it dispatches toMemoVisualizerand renders the decoded memo text. The throwaway harness used to mint that transaction was removed before commit.Manual steps needed (by human)
4. How this is maintainable
compute_budget/associated_token_accountas siblings.build.rsdiscoversMemoVisualizerfrom the directory name, so there is no hand-edited registry — adding or removing a preset is a directory drop-in.render_memo(program_id, data, index)function so it is unit-testable without constructing aVisualizerContext. The 8 tests cover UTF-8/unicode/empty/invalid decode, preview structure, the 1-indexed instruction label, config dispatch, andkind().InstructionVisualizer/SolanaIntegrationConfigcontract are identical to every other Solana preset.🤖 Generated with Claude Code