Skip to content

feat(solana): add Drift Protocol visualizer preset (rebased #239)#366

Merged
prasanna-anchorage merged 1 commit into
mainfrom
add-drift-visualizer-rebased
Jun 12, 2026
Merged

feat(solana): add Drift Protocol visualizer preset (rebased #239)#366
prasanna-anchorage merged 1 commit into
mainfrom
add-drift-visualizer-rebased

Conversation

@shahan-khatchadourian-anchorage

Copy link
Copy Markdown
Contributor

Supersedes #239 — rebases @prasanna-anchorage's Drift Protocol v2 preset onto current main and adapts it to the post-refactor APIs so it builds, lints, and tests cleanly.

Summary

Adds an IDL-based visualizer preset for Drift Protocol v2 (dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH), decoding instructions via the embedded Anchor IDL and rendering a condensed/expanded preview with named accounts, falling back to a raw-data view on decode failure.

Changes vs #239

The original branch was ~168 commits behind main and predated two refactors, so it no longer compiled. Fixed:

  • config.rs / named-accounts map use BTreeMap, not HashMapSolanaIntegrationConfigData.programs is now BTreeMap, and the local account map needs deterministic ordering for stable metadata hashing.
  • Dropped the presets/mod.rs edit — since build(solana,sui): auto-generate presets/mod.rs from filesystem to eliminate per-PR conflicts #278 that file is auto-generated by build.rs from the directory listing; the preset auto-registers as a directory drop-in.
  • visualize_tx_commands uses the current VisualizerContext API (resolve_program_id / resolve_accounts / data) — the previous current_instruction() was removed upstream.
  • Test module carries the standard #[allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)] so clippy -D warnings passes.

Test plan

  • cargo clippy -p visualsign-solana --all-targets -- -D warnings — clean
  • cargo test -p visualsign-solana — all pass, including the pre-existing semantic_drift_deposit (stays on the generic IDL path; preset correctly does not intercept its random program id)
  • Confirmed drift::DriftVisualizer is auto-registered in the generated available_visualizers()

Note for reviewers

The parser already embeds a Drift IDL (embedded_idls::DRIFT_IDL via ProgramType::Drift), so the bundled drift.json is a second copy. This matches the existing preset convention (every IDL preset vendors its own JSON; jupiter_swap is the same situation), so it is kept for consistency and per-program IDL version independence rather than changed here.

🤖 Generated with Claude Code

Rebased onto current main and adapted to the post-refactor APIs:
- config.rs and the local named-accounts map use BTreeMap (deterministic
  ordering for stable metadata hashing), not HashMap
- visualize_tx_commands uses the current VisualizerContext API
  (resolve_program_id / resolve_accounts / data) instead of the removed
  current_instruction()
- preset is auto-registered by build.rs via the directory drop-in; no
  presets/mod.rs edit
- test module carries the standard clippy unwrap/expect/panic allow

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Copilot AI 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.

Pull request overview

Adds a new Solana preset visualizer for Drift Protocol v2 that decodes instructions via a vendored Anchor IDL and renders condensed/expanded preview layouts with a raw-data fallback.

Changes:

  • Introduces DriftVisualizer preset that parses Drift instructions using an embedded drift.json IDL and renders preview fields.
  • Adds DriftConfig integration config wiring the Drift program ID into the preset selection map.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/chain_parsers/visualsign-solana/src/presets/drift/mod.rs Implements the Drift IDL-backed instruction visualization and associated unit tests.
src/chain_parsers/visualsign-solana/src/presets/drift/config.rs Registers the Drift program ID in SolanaIntegrationConfigData so the preset can be selected.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +154 to +164
if let Ok(f) = create_text_field("Program", "Drift") {
condensed_fields.push(f);
}
if let Ok(f) = create_text_field("Instruction", &parsed.instruction_name) {
condensed_fields.push(f);
}
for (key, value) in &parsed.program_call_args {
if let Ok(f) = create_text_field(key, &format_arg_value(value)) {
condensed_fields.push(f);
}
}
@prasanna-anchorage prasanna-anchorage merged commit 3ec42f0 into main Jun 12, 2026
10 checks passed
@prasanna-anchorage prasanna-anchorage deleted the add-drift-visualizer-rebased branch June 12, 2026 17:11
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.

3 participants