Skip to main content

light_instruction_decoder/
lib.rs

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