Skip to content

Conversation

@prasincs
Copy link
Contributor

@prasincs prasincs commented Oct 2, 2025

Allow callers to pass custom IDL JSON strings for any program with
optional override of built-in IDLs. Returns SHA256 hash of compressed
IDL and source tracking (built-in vs custom) for verification.

Key changes:

  • Add optional custom_idls parameter to parse_transaction()
  • Add ProgramType enum for 13 built-in IDL types
  • Add IdlSource and idl_hash fields to SolanaParsedInstructionData
  • Add compute_idl_hash() for IDL verification
  • Update CLI to accept --custom-idl flag with optional --override
  • Maintain backward compatibility (existing calls add , None)

  Allow callers to pass custom IDL JSON strings for any program with
  optional override of built-in IDLs. Returns SHA256 hash of compressed
  IDL and source tracking (built-in vs custom) for verification.

  Key changes:
  - Add optional custom_idls parameter to parse_transaction()
  - Add ProgramType enum for 13 built-in IDL types
  - Add IdlSource and idl_hash fields to SolanaParsedInstructionData
  - Add compute_idl_hash() for IDL verification
  - Update CLI to accept --custom-idl flag with optional --override
  - Maintain backward compatibility (existing calls add , None)
@prasincs prasincs force-pushed the custom-idl-support branch from 7fafccc to c18e1c9 Compare October 2, 2025 00:03
prasincs and others added 2 commits November 30, 2025 09:54
  - Add embedded_idls.rs with include_str!() for all 13 IDL files
  - Add ProgramType::all() and ProgramType::idl_json() methods
  - Create CustomIdl enum (Parsed/Json) and CustomIdlConfig struct
  - Add parse_transaction_with_idls() as new preferred API
  - Update IdlRecord to use program_type instead of file_path
  - Eliminate runtime file system access for built-in IDLs

  This fixes the bug where IDL lookups failed when running from
  directories other than the project root.
  Add a new public function that allows parsing individual Solana
  instruction data using a provided IDL, without requiring full
  transaction context. This enables parsing instruction data in isolation
  when only the raw bytes and IDL are available.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
prasanna-anchorage added a commit to anchorageoss/visualsign-parser that referenced this pull request Jan 1, 2026
  Address all review comments from lukehalasy-anchorage in PR #128:

  1. **Pin solana_parser dependency** (Cargo.toml)
    - Pin to specific revision: 8248d99e42ce8a56ad440ed9b2201607feb1a150
      from https://github.com/prasincs/solana-parser/tree/custom-idl-support
    - Add documentation explaining custom fork features
    - Tracking upstream PR: tkhq/solana-parser#20

  2. **Move imports to module level** (unknown_program/mod.rs)
    - Move SolanaParsedInstructionData and parse_instruction_with_idl to module-level
    - Remove HashMap import from function scope
    - Improves code organization and follows Rust idioms

  3. **Enhance Windows path documentation** (cli.rs)
    - Add detailed docstring explaining Windows path compatibility
    - Document colon-handling logic for paths like "C:/path/to/file.json"
    - Clarify parsing strategy (rsplit from right for file paths)

  4. **Extract IDL registry helper function** (visualsign.rs)
    - Create create_idl_registry_from_options() helper function
    - Replace duplicated 7-line blocks in convert_to_visual_sign_payload and convert_v0_to_visual_sign_payload
    - Reduces code duplication and improves maintainability

  5. **Remove unnecessary #[allow(dead_code)] attributes** (idl/mod.rs)
    - Remove blanket dead_code attributes from struct and impl
    - Add targeted attribute only to get_all_configs() method
    - Update documentation for reserved future functionality

  6. **Fix test compilation** (swig_wallet/mod.rs)
    - Add IdlRegistry parameter to VisualizerContext::new() call
    - Ensures tests compile with updated API signature

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
prasanna-anchorage added a commit to anchorageoss/visualsign-parser that referenced this pull request Jan 1, 2026
  Address all review comments from lukehalasy-anchorage in PR #128:

  1. **Pin solana_parser dependency** (Cargo.toml)
    - Pin to specific revision: 8248d99e42ce8a56ad440ed9b2201607feb1a150
      from https://github.com/prasincs/solana-parser/tree/custom-idl-support
    - Add documentation explaining custom fork features
    - Tracking upstream PR: tkhq/solana-parser#20

  2. **Move imports to module level** (unknown_program/mod.rs)
    - Move SolanaParsedInstructionData and parse_instruction_with_idl to module-level
    - Remove HashMap import from function scope
    - Improves code organization and follows Rust idioms

  3. **Enhance Windows path documentation** (cli.rs)
    - Add detailed docstring explaining Windows path compatibility
    - Document colon-handling logic for paths like "C:/path/to/file.json"
    - Clarify parsing strategy (rsplit from right for file paths)

  4. **Extract IDL registry helper function** (visualsign.rs)
    - Create create_idl_registry_from_options() helper function
    - Replace duplicated 7-line blocks in convert_to_visual_sign_payload and convert_v0_to_visual_sign_payload
    - Reduces code duplication and improves maintainability

  5. **Remove unnecessary #[allow(dead_code)] attributes** (idl/mod.rs)
    - Remove blanket dead_code attributes from struct and impl
    - Add targeted attribute only to get_all_configs() method
    - Update documentation for reserved future functionality

  6. **Fix test compilation** (swig_wallet/mod.rs)
    - Add IdlRegistry parameter to VisualizerContext::new() call
    - Ensures tests compile with updated API signature

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
prasanna-anchorage added a commit to anchorageoss/visualsign-parser that referenced this pull request Jan 2, 2026
  Address all review comments from lukehalasy-anchorage in PR #128:

  1. **Pin solana_parser dependency** (Cargo.toml)
    - Pin to specific revision: 8248d99e42ce8a56ad440ed9b2201607feb1a150
      from https://github.com/prasincs/solana-parser/tree/custom-idl-support
    - Add documentation explaining custom fork features
    - Tracking upstream PR: tkhq/solana-parser#20

  2. **Move imports to module level** (unknown_program/mod.rs)
    - Move SolanaParsedInstructionData and parse_instruction_with_idl to module-level
    - Remove HashMap import from function scope
    - Improves code organization and follows Rust idioms

  3. **Enhance Windows path documentation** (cli.rs)
    - Add detailed docstring explaining Windows path compatibility
    - Document colon-handling logic for paths like "C:/path/to/file.json"
    - Clarify parsing strategy (rsplit from right for file paths)

  4. **Extract IDL registry helper function** (visualsign.rs)
    - Create create_idl_registry_from_options() helper function
    - Replace duplicated 7-line blocks in convert_to_visual_sign_payload and convert_v0_to_visual_sign_payload
    - Reduces code duplication and improves maintainability

  5. **Remove unnecessary #[allow(dead_code)] attributes** (idl/mod.rs)
    - Remove blanket dead_code attributes from struct and impl
    - Add targeted attribute only to get_all_configs() method
    - Update documentation for reserved future functionality

  6. **Fix test compilation** (swig_wallet/mod.rs)
    - Add IdlRegistry parameter to VisualizerContext::new() call
    - Ensures tests compile with updated API signature

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
prasanna-anchorage added a commit to anchorageoss/visualsign-parser that referenced this pull request Jan 3, 2026
* feat(solana): add IDL.json support infrastructure

Integrate IDL parsing capabilities from prasincs/solana-parser to enable
Anchor program instruction decoding. This provides the foundation for
automatic instruction visualization using IDL definitions.

Changes:
- Switch to solana_parser custom-idl-support branch
- Add idl_mappings field to SolanaMetadata protobuf
- Create IdlRegistry library for managing program IDLs
- Support 13 built-in IDLs with user override capability
- Update parse_transaction() calls for new API

The IDL registry is exposed as a library module for future integration
with visualizers, following the pattern of providing utilities rather
than creating preset-specific visualizers.

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

* feat(solana): add CLI support for IDL testing and metadata pipeline

Implement --idl-json-mappings CLI argument to enable quick testing of
custom Anchor IDL files, mirroring the existing --abi-json-mappings
pattern for Ethereum. This establishes the complete data flow pipeline
from CLI input through protobuf metadata to instruction decoding.

Changes:
- Add --idl-json-mappings CLI argument (format: Name:ProgramId:/path/to/idl.json)
- Implement IDL file parsing and validation functions
- Populate SolanaMetadata.idl_mappings from CLI input
- Extract IDL metadata in Solana converter
- Pass IdlRegistry through instruction decoder pipeline
- Update decode_instructions() and decode_v0_instructions() signatures
- Add generated crate dependency to visualsign-solana

The IDL registry is now created from metadata and passed to instruction
decoders, ready for future integration with actual IDL-based instruction
parsing using solana_parser library capabilities.

Tested with Jupiter Lend IDL and confirmed metadata pipeline works correctly.
Next step: integrate IdlRegistry with visualizers to decode instructions.

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

* feat(solana): integrate IDL detection with unknown_program visualizer

Complete IDL support infrastructure by wiring IdlRegistry through
VisualizerContext and updating unknown_program visualizer to detect
and indicate when an IDL is available for instruction decoding.

Changes:
- Add IdlRegistry field to VisualizerContext
- Update all VisualizerContext::new() call sites with IdlRegistry parameter
- Enhance unknown_program visualizer to check for IDL availability
- Extract and display program name from IDL metadata.name field
- Show "(IDL available)" indicator when IDL is present
- Add Debug derive to IdlRegistry
- Update test fixtures to pass IdlRegistry
- Allow metadata creation with only IDL mappings (network optional)
- Add serde_json dependency for IDL name extraction
- Refactor metadata creation to use if/else for clippy compliance

Tested with Jupiter Lend transaction - complete flow working:
- CLI loads IDL from file and shows loading message
- Metadata pipeline passes IDL to converter
- Visualizer detects IDL and shows program name "lending (IDL)"
- Instruction discriminator f223c68952e1f2b6 matches deposit instruction

Full instruction decoding pending solana_parser API enhancement to accept
individual instructions rather than requiring full transaction reconstruction.

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

* feat(solana): integrate IDL detection with unknown_program visualizer

Complete IDL support infrastructure by wiring IdlRegistry through
VisualizerContext and updating unknown_program visualizer to detect
and indicate when an IDL is available for instruction decoding.

Changes:
- Add IdlRegistry field to VisualizerContext
- Update all VisualizerContext::new() call sites
- Enhance unknown_program visualizer to check for IDL availability
- Show "(IDL available)" indicator when IDL is present
- Add Debug derive to IdlRegistry
- Update test fixtures to pass IdlRegistry

Tested with Jupiter Lend transaction - IDL loading and detection confirmed
working. Visualizer now shows when an IDL is available for a program.

Full instruction decoding pending solana_parser API enhancement to accept
individual instructions rather than full transactions.

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

* fix(solana): address PR #128 review comments

  Address all review comments from lukehalasy-anchorage in PR #128:

  1. **Pin solana_parser dependency** (Cargo.toml)
    - Pin to specific revision: 8248d99e42ce8a56ad440ed9b2201607feb1a150
      from https://github.com/prasincs/solana-parser/tree/custom-idl-support
    - Add documentation explaining custom fork features
    - Tracking upstream PR: tkhq/solana-parser#20

  2. **Move imports to module level** (unknown_program/mod.rs)
    - Move SolanaParsedInstructionData and parse_instruction_with_idl to module-level
    - Remove HashMap import from function scope
    - Improves code organization and follows Rust idioms

  3. **Enhance Windows path documentation** (cli.rs)
    - Add detailed docstring explaining Windows path compatibility
    - Document colon-handling logic for paths like "C:/path/to/file.json"
    - Clarify parsing strategy (rsplit from right for file paths)

  4. **Extract IDL registry helper function** (visualsign.rs)
    - Create create_idl_registry_from_options() helper function
    - Replace duplicated 7-line blocks in convert_to_visual_sign_payload and convert_v0_to_visual_sign_payload
    - Reduces code duplication and improves maintainability

  5. **Remove unnecessary #[allow(dead_code)] attributes** (idl/mod.rs)
    - Remove blanket dead_code attributes from struct and impl
    - Add targeted attribute only to get_all_configs() method
    - Update documentation for reserved future functionality

  6. **Fix test compilation** (swig_wallet/mod.rs)
    - Add IdlRegistry parameter to VisualizerContext::new() call
    - Ensures tests compile with updated API signature

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* fix(solana): add missing protobuf fields and resolve clippy warnings

  - Add `program_name` field to Idl struct initializers in integration tests
  - Add `idl_mappings` field to SolanaMetadata initializer
  - Fix doc markdown formatting for Windows path example in CLI
  - Replace unwrap() with expect() for better error messages in CLI

  These changes address compilation errors after recent protobuf schema
  updates and resolve clippy linting warnings.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* fix(deps): pin vsock to 0.5.1 to resolve nix version conflict

  Between commits aeed179 and ea43097, vsock was automatically upgraded
  from 0.5.1 to 0.5.2. This upgrade brought in nix 0.30.1, which
  conflicts with qos_core's dependency on nix 0.29.0.

  The conflict causes type mismatches with VsockAddr, as both nix
  versions define this type incompatibly.

  Solution: Downgrade vsock to 0.5.1 in Cargo.lock, which uses
  nix 0.29.0 and aligns with qos_core's requirements.

  This pin should be maintained until qos_core upgrades to nix 0.30.x
  or newer.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* refactor(cli): unify IDL and ABI mapping formats with common parser

  Consolidate mapping format parsing into a shared library to ensure
  consistency across Ethereum ABI and Solana IDL mappings.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* Update src/parser/cli/src/cli.rs

Co-authored-by: Luke Halasy <107507807+lukehalasy-anchorage@users.noreply.github.com>
Signed-off-by: prasanna-anchorage <48452975+prasanna-anchorage@users.noreply.github.com>

* Update src/parser/cli/src/cli.rs

Co-authored-by: Luke Halasy <107507807+lukehalasy-anchorage@users.noreply.github.com>
Signed-off-by: prasanna-anchorage <48452975+prasanna-anchorage@users.noreply.github.com>

* ci: use larger runner with more disk space for tests

---------

Signed-off-by: prasanna-anchorage <48452975+prasanna-anchorage@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Luke Halasy <107507807+lukehalasy-anchorage@users.noreply.github.com>
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