feat(visualsign-solana): add Titan Swap preset visualizer#415
Open
kyle-anchorage wants to merge 1 commit into
Open
feat(visualsign-solana): add Titan Swap preset visualizer#415kyle-anchorage wants to merge 1 commit into
kyle-anchorage wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new Solana preset visualizer for the Titan Swap program so key instructions decode via the bundled Anchor IDL and render as structured fields instead of falling back to unknown_program.
Changes:
- Added a
titan_swappreset visualizer that IDL-parses instruction data and renders condensed/expanded field layouts. - Added preset config registering Titan Swap’s program ID for visualizer dispatch.
- Bundled Titan Swap’s Anchor IDL JSON to drive discriminator + argument parsing (with preset-level regression tests in the module).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/chain_parsers/visualsign-solana/src/presets/titan_swap/mod.rs |
Implements TitanSwapVisualizer, IDL loading/parsing, field rendering, and preset tests. |
src/chain_parsers/visualsign-solana/src/presets/titan_swap/config.rs |
Registers the Titan Swap program ID in SolanaIntegrationConfigData so the visualizer can be selected. |
src/chain_parsers/visualsign-solana/src/presets/titan_swap/titan_swap.json |
Bundled Anchor IDL used for discriminator matching and argument decoding. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+252
to
+255
| /// Strips `"` and `\` (to preserve the quote-free rendering above) and any | ||
| /// other non-printable-ASCII bytes (`SignablePayload::validate_charset` forbids | ||
| /// them). IDL strings here (pubkeys, enum names) are already clean; this is a | ||
| /// defensive guard so the function's charset-safe contract always holds. |
Comment on lines
+454
to
+461
| #[test] | ||
| fn test_short_data_returns_error() { | ||
| let short_data = [0x01, 0x02, 0x03]; | ||
| let accounts = vec![]; | ||
| let result = parse_titan_swap_instruction(&short_data, &accounts); | ||
| assert!(result.is_err(), "Short data should return error"); | ||
| } | ||
| } |
Adds an IDL-based visualizer preset for Titan Swap (T1TANpTeScyeqVzzgNViGDNrkQ6qHz9KrSBS4aNXvGT), covering initialize, swap_route, and swap_route_v2. Follows the dflow_aggregator template: InstructionView-based resolution, IDL-driven parsing, and a quote-free format_arg_value renderer for nested args. Tests cover IDL/discriminator validation, error paths (short/unknown data), successful parsing of swap_route and swap_route_v2 (including their differing nested SwapSpecInput/SwapSpecInputV2 shapes), and named/remaining-account mapping. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
kyle-anchorage
marked this pull request as ready for review
July 16, 2026 18:41
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.
Why this PR exists
Adds a Solana visualizer preset for Titan Swap (program
T1TANpTeScyeqVzzgNViGDNrkQ6qHz9KrSBS4aNXvGT), soinitialize,swap_route, andswap_route_v2instructions render as structured, human-readable fields instead of falling through to the genericunknown_programfallback.Titan is a swap-routing program; the IDL was pulled directly from Titan's public CPI example repo (
Titan-Pathfinder/titan-v2-cpi-example) and validated to have a well-formedinstructionsarray with 8-byte discriminators before scaffolding.This follows the established IDL-preset pattern (
dflow_aggregatoras the template):InstructionView::from_contextfor infallible account/program resolution, IDL-driven parsing viasolana_parser, and a quote-freeformat_arg_valuerenderer so nested args (e.g.swap_route'sswaps: Vec<SwapSpecInput>) don't explode into per-field noise.What changed (architecture + key decisions)
src/chain_parsers/visualsign-solana/src/presets/titan_swap/module:config.rs(program ID registration, wildcard instruction match),mod.rs(TitanSwapVisualizer,VisualizerKind::Dex),titan_swap.json(bundled IDL).build.rsauto-discoversTitanSwapVisualizerfrom the new preset directory and generatespresets/mod.rsat build time.Test plan
Agent-verified (automated)
cargo fmt -p visualsign-solana— cleancargo clippy -p visualsign-solana --all-targets -- -D warnings— clean (both with and without--features diagnostics)cargo test -p visualsign-solana— 264 passed, 0 failed. 8titan_swaptests: IDL loads, discriminators are 8 bytes, unknown-discriminator/short-data error paths, successful parse of bothswap_routeandswap_route_v2(exercising their differing nestedSwapSpecInput/SwapSpecInputV2shapes via hand-built instruction bytes), named-account mapping with overflow intoextra_accounts, and "Remaining Account N" label renderingcargo test -p visualsign-solana --features diagnostics— same, all greenmake -C src test(full workspace build + test) — all greenreview-changes) run against the diff. Lens 3 (goal coverage) flagged that the initial 4-test scaffold only covered error paths, not a successful parse of either instruction or the named-accounts mapping — both gaps fixed by adding the 4 tests above. Lenses 1, 2, 4 had no titan_swap-specific findings; noted pre-existing crate-wideformat_arg_valueduplication as out-of-scope debt, not introduced by this PR.Human QA (manual checklist)
parser_cli/parser_app/gRPC server, covered by the automated fixture-style tests above.How this is maintainable by Claude
dflow_aggregator,kamino_vault, etc.) — a fresh agent can orient from any sibling preset without extra exploration.config.rs+mod.rs+ bundled.jsonIDL is the whole surface area; no cross-cutting changes.unwrap_used/expect_used/panicdenied outside tests) and the four required preset tests, which will fail loudly if the bundled IDL or discriminator logic regresses.CLAUDE.md's field-builder rule (create_text_field/create_raw_data_field, never raw field structs) and ASCII-only rule are both followed.Manual steps needed (by human)
None — fully automated by CI. No migrations, flags, or backfills.