Expand description
§sologger-idl-decoder
Overview
Decodes what Anchor programs emit — Program data: events and custom program error
codes — into structured form, driven purely by the program’s IDL JSON. Supports both
the legacy (pre-0.30) and the 0.30+ IDL spec, and depends on serde rather than
anchor-lang so it stays small and WASM-friendly.
Example Usage
let mut registry = IdlRegistry::new();
registry.insert_json("CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C", idl_json)?;
// log_contexts from LogContext::parse_logs / the transformer crates
registry.enrich_all(&mut log_contexts);
// Each matching context now carries:
// decoded_events: [r#"{"name":"SwapEvent","data":{...}}"#]
// error_name: Some("NotApproved") // when error_code matched the IDLStandalone decoding without the registry:
let idl = Idl::from_json(idl_json)?;
let event = decode_event(&idl, base64_payload)?; // Option<DecodedEvent>
let error = idl.lookup_error(6001); // Option<&IdlErrorCode>Re-exports§
pub use decoder::decode_event;pub use decoder::decode_events;pub use decoder::event_discriminator;pub use decoder::DecodeError;pub use decoder::DecodedEvent;pub use idl::Idl;pub use idl::IdlErrorCode;pub use idl::IdlEvent;pub use registry::IdlRegistry;