carbon_profile_vault_decoder/instructions/
mod.rs

1//! This code was AUTOGENERATED using the Codama library.
2use crate::PROGRAM_ID;
3use crate::ProfileVaultDecoder;
4
5pub mod close_vault;
6pub mod create_vault_authority;
7pub mod drain_vault;
8
9pub use self::close_vault::*;
10pub use self::create_vault_authority::*;
11pub use self::drain_vault::*;
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 ProfileVaultInstruction {
20    CloseVault(CloseVault),
21    CreateVaultAuthority(CreateVaultAuthority),
22    DrainVault(DrainVault),
23}
24
25impl carbon_core::instruction::InstructionDecoder<'_> for ProfileVaultDecoder {
26    type InstructionType = ProfileVaultInstruction;
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) = close_vault::CloseVault::decode(data) {
40                return Some(carbon_core::instruction::DecodedInstruction {
41                    program_id: instruction.program_id,
42                    data: ProfileVaultInstruction::CloseVault(decoded),
43                    accounts: instruction.accounts.clone(),
44                });
45            }
46        }
47        {
48            if let Some(decoded) = create_vault_authority::CreateVaultAuthority::decode(data) {
49                return Some(carbon_core::instruction::DecodedInstruction {
50                    program_id: instruction.program_id,
51                    data: ProfileVaultInstruction::CreateVaultAuthority(decoded),
52                    accounts: instruction.accounts.clone(),
53                });
54            }
55        }
56        {
57            if let Some(decoded) = drain_vault::DrainVault::decode(data) {
58                return Some(carbon_core::instruction::DecodedInstruction {
59                    program_id: instruction.program_id,
60                    data: ProfileVaultInstruction::DrainVault(decoded),
61                    accounts: instruction.accounts.clone(),
62                });
63            }
64        }
65
66        None
67    }
68}