solana_svm_transaction/
instruction.rs

1use solana_message::compiled_instruction::CompiledInstruction;
2
3/// A non-owning version of [`CompiledInstruction`] that references
4/// slices of account indexes and data.
5// `program_id_index` is still owned, as it is a simple u8.
6#[derive(Debug, PartialEq, Eq, Clone)]
7pub struct SVMInstruction<'a> {
8    /// Index into the transaction keys array indicating the program account that executes this instruction.
9    pub program_id_index: u8,
10    /// Ordered indices into the transaction keys array indicating which accounts to pass to the program.
11    pub accounts: &'a [u8],
12    /// The program input data.
13    pub data: &'a [u8],
14}
15
16impl<'a> From<&'a CompiledInstruction> for SVMInstruction<'a> {
17    fn from(ix: &'a CompiledInstruction) -> Self {
18        Self {
19            program_id_index: ix.program_id_index,
20            accounts: ix.accounts.as_slice(),
21            data: ix.data.as_slice(),
22        }
23    }
24}