carbon_snapshots_decoder/instructions/
mod.rs

1//! This code was AUTOGENERATED using the Codama library.
2use crate::PROGRAM_ID;
3use crate::SnapshotsDecoder;
4
5pub mod create_escrow_history;
6pub mod create_locker_history;
7pub mod sync;
8
9pub use self::create_escrow_history::*;
10pub use self::create_locker_history::*;
11pub use self::sync::*;
12
13#[derive(Debug, Clone, PartialEq, Eq, Hash)]
14#[cfg_attr(
15    feature = "serde",
16    derive(carbon_core::InstructionType, serde::Serialize, serde::Deserialize)
17)]
18#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
19pub enum SnapshotsInstruction {
20    CreateEscrowHistory(CreateEscrowHistory),
21    CreateLockerHistory(CreateLockerHistory),
22    Sync(Sync),
23}
24
25impl carbon_core::instruction::InstructionDecoder<'_> for SnapshotsDecoder {
26    type InstructionType = SnapshotsInstruction;
27
28    fn decode_instruction(
29        &self,
30        instruction: &solana_instruction::Instruction,
31    ) -> Option<carbon_core::instruction::DecodedInstruction<Self::InstructionType>> {
32        if !instruction.program_id.eq(&PROGRAM_ID) {
33            return None;
34        }
35
36        let data = instruction.data.as_slice();
37
38        {
39            if let Some(decoded) = create_escrow_history::CreateEscrowHistory::decode(data) {
40                return Some(carbon_core::instruction::DecodedInstruction {
41                    program_id: instruction.program_id,
42                    data: SnapshotsInstruction::CreateEscrowHistory(decoded),
43                    accounts: instruction.accounts.clone(),
44                });
45            }
46        }
47        {
48            if let Some(decoded) = create_locker_history::CreateLockerHistory::decode(data) {
49                return Some(carbon_core::instruction::DecodedInstruction {
50                    program_id: instruction.program_id,
51                    data: SnapshotsInstruction::CreateLockerHistory(decoded),
52                    accounts: instruction.accounts.clone(),
53                });
54            }
55        }
56        {
57            if let Some(decoded) = sync::Sync::decode(data) {
58                return Some(carbon_core::instruction::DecodedInstruction {
59                    program_id: instruction.program_id,
60                    data: SnapshotsInstruction::Sync(decoded),
61                    accounts: instruction.accounts.clone(),
62                });
63            }
64        }
65
66        None
67    }
68}