// file: kb_lib/src/db/entities/chain_instruction.rs

//! Database entity for one normalized Solana instruction row.

/// Persisted Solana instruction row.
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, sqlx::FromRow)]
pub struct ChainInstructionEntity {
    /// Internal row id.
    pub id: i64,
    /// Parent transaction id.
    pub transaction_id: i64,
    /// Optional parent instruction id for inner instructions.
    pub parent_instruction_id: std::option::Option<i64>,
    /// Top-level instruction index.
    pub instruction_index: i64,
    /// Optional inner instruction index.
    pub inner_instruction_index: std::option::Option<i64>,
    /// Optional program id.
    pub program_id: std::option::Option<std::string::String>,
    /// Optional program name.
    pub program_name: std::option::Option<std::string::String>,
    /// Optional stack height.
    pub stack_height: std::option::Option<i64>,
    /// Accounts JSON array.
    pub accounts_json: std::string::String,
    /// Optional data JSON.
    pub data_json: std::option::Option<std::string::String>,
    /// Optional parsed type.
    pub parsed_type: std::option::Option<std::string::String>,
    /// Optional parsed payload JSON.
    pub parsed_json: std::option::Option<std::string::String>,
    /// Creation timestamp.
    pub created_at: std::string::String,
}
