Skip to content

feat(solana): add Marinade Finance visualizer preset#350

Draft
kyle-anchorage wants to merge 1 commit into
mainfrom
marinade
Draft

feat(solana): add Marinade Finance visualizer preset#350
kyle-anchorage wants to merge 1 commit into
mainfrom
marinade

Conversation

@kyle-anchorage

Copy link
Copy Markdown
Contributor

1. Why this PR exists

Solana stake-pool transactions to Marinade Finance (program MarBmsSgKXdrN1egZf5sqe1TMai9K1rChYNDJgjq7aD) fell through to the unknown-program catch-all visualizer. Signers saw raw instruction bytes instead of a human-readable instruction name, decoded arguments, and named accounts.

No ticket.

2. What changed

  • Adds a new Solana preset marinade_finance under chain_parsers/visualsign-solana/src/presets/, scaffolded from the program's on-chain Anchor IDL (bundled as marinade_finance.json via include_str!).
  • MarinadeFinanceVisualizer decodes each instruction by its 8-byte discriminator using the shared parse_instruction_with_idl path, then renders a preview layout: condensed view (program + instruction name) and expanded view (program id, instruction, discriminator, IDL-named accounts, and decoded args, all alphabetically sorted), with a raw-data field appended.
  • Falls back to a "IDL parsing failed - showing raw data" view when the discriminator is unknown or data is shorter than 8 bytes, so unrecognized instructions still degrade gracefully instead of erroring.
  • config.rs registers the program with a wildcard ("*", ["*"]) instruction allow-list.
  • No edits to presets/mod.rs or the visualizer registry: both are auto-generated by build.rs from the directory listing, so the preset is wired in purely by the directory drop-in (struct name MarinadeFinanceVisualizer matches the pascal-cased directory name).

3. Why this is safe

  • Backward compatibility: purely additive. Before this change, Marinade transactions matched the unknown_program catch-all; the catch-all still runs last (build.rs partitions it after all specific visualizers), so only Marinade-program instructions are newly claimed. No existing preset behavior changes.
  • How it was built: decoding reuses the existing solana_parser IDL machinery (decode_idl_data, parse_instruction_with_idl) already used by other presets. The IDL is parsed once and cached in a OnceLock. Field construction uses the mandated create_text_field / create_raw_data_field builders.
  • Risks mitigated: instruction data shorter than the 8-byte discriminator and unknown discriminators both return errors that route to the fallback view rather than panicking. No unwrap/expect/panic in non-test code, satisfying the workspace lint policy.

Checks run (by agent)

  • cargo test -p visualsign-solana marinade — 4 tests pass (IDL loads, all discriminators are 8 bytes, unknown discriminator errors, short data errors).
  • cargo clippy -p visualsign-solana --all-targets -- -D warnings — clean.

Manual steps needed (by human)

None — fully automated by CI.

4. How this is maintainable

  • The preset follows the established directory-drop-in convention documented in presets/mod.rs and enforced by build.rs; a fresh developer adds a chain integration by creating a presets/<name>/ directory with a <Name>Visualizer, no registry edits.
  • The bundled IDL is the source of truth for instruction names, discriminators, and account ordering, so the visualizer tracks the on-chain program without hand-maintained tables.
  • Tests guard the IDL contract (non-empty, 8-byte discriminators) and the error paths, catching regressions if the bundled IDL is replaced or the parser changes.
  • Mirrors the structure of sibling presets (e.g. kamino_vault, orca_whirlpool), so patterns are consistent across the crate.

🤖 Generated with Claude Code

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