feat(solana): add Drift Protocol visualizer preset (rebased #239)#366
Merged
Conversation
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 started reviewing on behalf of
shahan-khatchadourian-anchorage
June 12, 2026 01:40
View session
3 tasks
Contributor
There was a problem hiding this comment.
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
DriftVisualizerpreset that parses Drift instructions using an embeddeddrift.jsonIDL and renders preview fields. - Adds
DriftConfigintegration 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
approved these changes
Jun 12, 2026
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.
Supersedes #239 — rebases @prasanna-anchorage's Drift Protocol v2 preset onto current
mainand 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
mainand predated two refactors, so it no longer compiled. Fixed:config.rs/ named-accounts map useBTreeMap, notHashMap—SolanaIntegrationConfigData.programsis nowBTreeMap, and the local account map needs deterministic ordering for stable metadata hashing.presets/mod.rsedit — since build(solana,sui): auto-generate presets/mod.rs from filesystem to eliminate per-PR conflicts #278 that file is auto-generated bybuild.rsfrom the directory listing; the preset auto-registers as a directory drop-in.visualize_tx_commandsuses the currentVisualizerContextAPI (resolve_program_id/resolve_accounts/data) — the previouscurrent_instruction()was removed upstream.#[allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]soclippy -D warningspasses.Test plan
cargo clippy -p visualsign-solana --all-targets -- -D warnings— cleancargo test -p visualsign-solana— all pass, including the pre-existingsemantic_drift_deposit(stays on the generic IDL path; preset correctly does not intercept its random program id)drift::DriftVisualizeris auto-registered in the generatedavailable_visualizers()Note for reviewers
The parser already embeds a Drift IDL (
embedded_idls::DRIFT_IDLviaProgramType::Drift), so the bundleddrift.jsonis a second copy. This matches the existing preset convention (every IDL preset vendors its own JSON;jupiter_swapis the same situation), so it is kept for consistency and per-program IDL version independence rather than changed here.🤖 Generated with Claude Code