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 data types passed to plugin hooks.
//!
//! Each type carries extracted fields plus the original `raw` JSON so plugins
//! can access any field the framework doesn't extract.

use serde::{Deserialize, Serialize};

/// Block-level data passed to `Plugin::on_block`.
///
/// Contains both extracted fields and the full raw JSON response
/// so plugins can access any field the framework doesn't extract.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BlockData {
    pub slot: u64,
    pub blockhash: String,
    pub parent_slot: u64,
    pub parent_blockhash: String,
    pub block_time: Option<i64>,
    pub block_height: Option<u64>,
    pub transaction_count: u64,
    pub raw: serde_json::Value,
}

/// Transaction-level data passed to `Plugin::on_transaction`.
///
/// One call per transaction in the block, in order of `tx_index`.
/// Carries the full transaction JSON in `raw` for custom parsing.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TransactionData {
    pub slot: u64,
    pub tx_index: u32,
    pub signature: String,
    pub success: bool,
    pub fee: u64,
    pub compute_units_consumed: Option<u64>,
    pub is_vote: bool,
    pub pre_balances: Vec<u64>,
    pub post_balances: Vec<u64>,
    pub log_messages: Option<Vec<String>>,
    pub block_time: Option<i64>,
    pub raw: serde_json::Value,
}

/// Token balance change data passed to `Plugin::on_token_transfer`.
///
/// Emitted when a token account's balance changes within a transaction.
/// Only emitted when `pre_amount != post_amount` (actual transfers).
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TokenTransferData {
    pub slot: u64,
    pub tx_index: u32,
    pub signature: String,
    pub mint: String,
    pub owner: String,
    pub pre_amount: String,
    pub post_amount: String,
    pub decimals: u8,
    pub block_time: Option<i64>,
}

/// SOL balance change data passed to `Plugin::on_account_activity`.
///
/// One entry per account key touched by the transaction.
/// Includes signer/fee-payer flags for filtering.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AccountActivityData {
    pub slot: u64,
    pub tx_index: u32,
    pub signature: String,
    pub account: String,
    pub pre_balance: u64,
    pub post_balance: u64,
    pub balance_change: i64,
    pub is_signer: bool,
    pub is_fee_payer: bool,
    pub block_time: Option<i64>,
}

/// All extracted data for a single slot.
///
/// Returned by [`extract_block()`](super::extract_block). Contains the block metadata,
/// all transactions, token balance changes, and account activity records.
pub struct SlotExtract {
    pub block: BlockData,
    pub transactions: Vec<TransactionData>,
    pub token_transfers: Vec<TokenTransferData>,
    pub account_activity: Vec<AccountActivityData>,
}