poseidon_client/transactions/
compiled_instruction.rs

1use borsh::{BorshDeserialize, BorshSerialize};
2use core::fmt;
3use serde::{Deserialize, Serialize};
4
5/// A compact encoding of an instruction.
6///
7/// A `CompiledInstruction` is a component of a multi-instruction [`Message`],
8/// which is the core of a Solana transaction. It is created during the
9/// construction of `Message`. Most users will not interact with it directly.
10///
11/// [`Message`]: crate::Message
12#[derive(PartialEq, Eq, Clone, BorshSerialize, BorshDeserialize, Deserialize, Serialize)]
13#[serde(rename_all = "camelCase")]
14pub struct CompiledInstruction {
15    /// Index into the transaction keys array indicating
16    /// the program account that executes this instruction.
17    pub program_id_index: u8,
18    /// Ordered indices into the transaction keys array indicating
19    /// which accounts to pass to the program.
20    #[serde(with = "short_vec")]
21    pub accounts: Vec<u8>,
22    /// The program input data.
23    #[serde(with = "short_vec")]
24    pub data: Vec<u8>,
25}
26
27impl fmt::Debug for CompiledInstruction {
28    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
29        f.debug_struct("CompiledInstruction")
30            .field("program_id_index", &self.program_id_index)
31            .field("accounts", &self.accounts)
32            .field("data", &blake3::hash(&self.data).to_hex())
33            .finish()
34    }
35}