quicknode-cascade 0.2.3

Stream blockchain data at scale. Plugin-based framework powered by QuickNode Cascade — start with Solana, more chains coming.
Documentation
//! Solana chain support.
//!
//! Implements structured extraction of Solana blocks, transactions, token
//! transfers, and account activity from JSON-RPC `getBlock` responses.
//!
//! # Two Approaches
//!
//! **Custom extraction** — implement [`Plugin::on_raw`] and parse raw JSON yourself:
//!
//! ```rust,no_run
//! use quicknode_cascade::solana::{Plugin, PluginFuture};
//!
//! struct MyParser;
//! impl Plugin for MyParser {
//!     fn name(&self) -> &'static str { "my-parser" }
//!     fn on_raw<'a>(&'a self, slot: u64, raw: &'a serde_json::Value) -> PluginFuture<'a> {
//!         Box::pin(async move {
//!             // parse raw JSON however you need
//!             Ok(())
//!         })
//!     }
//! }
//! ```
//!
//! **Built-in extraction** — use [`Plugin::on_block`], [`Plugin::on_transaction`], etc.
//! and let the framework extract structured data for you.
//!
//! Both can be combined. [`extract_block()`] is also exposed as a public utility
//! you can call from `on_raw` if you want the framework's extraction as a starting point.

mod plugin;
mod types;
pub(crate) mod extract;

pub use plugin::{Plugin, PluginFuture};
pub use types::{AccountActivityData, BlockData, TokenTransferData, TransactionData};

/// Extract structured data from a raw `getBlock` JSON-RPC response.
///
/// Takes ownership of the JSON Value (zero-copy where possible).
/// Returns block metadata, transactions, token transfers, and account activity.
///
/// Use this from [`Plugin::on_raw`] if you want the framework's extraction
/// as a starting point alongside your own custom parsing.
///
/// # Example
///
/// ```rust,no_run
/// use quicknode_cascade::solana::{self, Plugin, PluginFuture};
///
/// struct HybridPlugin;
/// impl Plugin for HybridPlugin {
///     fn name(&self) -> &'static str { "hybrid" }
///     fn on_raw<'a>(&'a self, slot: u64, raw: &'a serde_json::Value) -> PluginFuture<'a> {
///         Box::pin(async move {
///             // Use the framework's extraction
///             let extracted = solana::extract_block(slot, raw.clone());
///             println!("{} txs", extracted.transactions.len());
///
///             // PLUS do your own custom parsing from the same raw JSON
///             if let Some(rewards) = raw.get("rewards") {
///                 println!("rewards: {}", rewards);
///             }
///             Ok(())
///         })
///     }
/// }
/// ```
pub fn extract_block(slot: u64, block: serde_json::Value) -> SlotExtract {
    extract::extract_block(slot, block)
}

/// All extracted data for a single slot.
///
/// Returned by [`extract_block()`]. Contains the block metadata, all transactions,
/// token balance changes, and account activity records.
pub use types::SlotExtract;

/// Re-exports for convenience. `use quicknode_cascade::solana::prelude::*;`
pub mod prelude {
    pub use super::{
        AccountActivityData, BlockData, Plugin, PluginFuture, SlotExtract,
        TokenTransferData, TransactionData, extract_block,
    };
    pub use crate::CascadeRunner;
}