light_instruction_decoder/
lib.rs

1//! Instruction decoder library for Light Protocol.
2//!
3//! This crate provides:
4//! - Core types for instruction decoding (DecodedField, DecodedInstruction, InstructionDecoder trait)
5//! - Decoder registry for managing multiple program decoders
6//! - Built-in decoders for Light Protocol programs (System, Compressed Token, etc.)
7//! - Transaction logging configuration and formatting utilities
8//!
9//! The crate is designed to be independent of LiteSVM/test infrastructure,
10//! enabling use in both test environments and standalone tools.
11//!
12//! Note: Most functionality is only available off-chain (not on Solana targets).
13
14// Re-export solana types for use by dependent crates (available on all targets)
15// Re-export derive macro for #[instruction_decoder]
16pub use light_instruction_decoder_derive::instruction_decoder;
17pub use solana_instruction;
18pub use solana_pubkey;
19pub use solana_signature;
20
21// Core types available on all targets (needed by derive macros)
22mod core;
23pub use core::{DecodedField, DecodedInstruction, InstructionDecoder};
24
25// Off-chain only modules (uses tabled, derive macros, DecoderRegistry)
26#[cfg(not(target_os = "solana"))]
27pub mod config;
28#[cfg(not(target_os = "solana"))]
29pub mod formatter;
30#[cfg(not(target_os = "solana"))]
31pub mod programs;
32#[cfg(not(target_os = "solana"))]
33pub mod registry;
34#[cfg(not(target_os = "solana"))]
35pub mod types;
36
37// Re-export main types from types module
38// Re-export config types
39#[cfg(not(target_os = "solana"))]
40pub use config::{EnhancedLoggingConfig, LogVerbosity};
41// Re-export formatter
42#[cfg(not(target_os = "solana"))]
43pub use formatter::{Colors, TransactionFormatter};
44// Re-export Light Protocol program decoders (requires light-protocol feature)
45#[cfg(all(not(target_os = "solana"), feature = "light-protocol"))]
46pub use programs::{
47    AccountCompressionInstructionDecoder, CTokenInstructionDecoder, LightSystemInstructionDecoder,
48    RegistryInstructionDecoder,
49};
50// Re-export program decoders (generic Solana programs)
51#[cfg(not(target_os = "solana"))]
52pub use programs::{
53    ComputeBudgetInstructionDecoder, SplTokenInstructionDecoder, SystemInstructionDecoder,
54    Token2022InstructionDecoder,
55};
56// Re-export registry
57#[cfg(not(target_os = "solana"))]
58pub use registry::DecoderRegistry;
59#[cfg(not(target_os = "solana"))]
60pub use types::{
61    AccountAccess, AccountChange, AccountStateSnapshot, CompressedAccountInfo,
62    EnhancedInstructionLog, EnhancedTransactionLog, LightProtocolEvent, MerkleTreeChange,
63    TransactionStatus,
64};