Skip to content

Add custom IDL support and parse_instruction_with_idl#2

Closed
shahan-khatchadourian-anchorage wants to merge 3 commits into
add-ci-workflowfrom
prasincs/custom-idl-support
Closed

Add custom IDL support and parse_instruction_with_idl#2
shahan-khatchadourian-anchorage wants to merge 3 commits into
add-ci-workflowfrom
prasincs/custom-idl-support

Conversation

@shahan-khatchadourian-anchorage
Copy link
Copy Markdown

Summary

This PR carries forward work originally authored by @prasincs, pending as tkhq/solana-parser#20. It is being opened here on the anchorageoss fork to unblock downstream work that depends on these features.

  • Custom IDL support: CustomIdlConfig, CustomIdl, construct_idl_records_map — allows callers to provide their own IDL (either pre-parsed or as JSON) alongside or instead of built-in IDLs
  • Embedded IDLs: IDL JSON files compiled into the binary at build time, removing the need for runtime file access
  • parse_instruction_with_idl: parses a raw instruction byte slice against a provided Idl struct without requiring full transaction context

Attribution

All commits in this PR are authored by @prasincs. This PR recreates his pending upstream PR on this repo.

Merge order

This PR should merge before #1, which adds the proptest feature on top of these changes.

Test plan

  • Existing tests pass
  • Downstream: visualsign-parser pipeline integration tests pass with these features enabled

🤖 Generated with Claude Code

prasincs and others added 3 commits March 13, 2026 19:28
  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)
  - 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>
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.

2 participants