carbon_crew_decoder/instructions/
mod.rs

1//! This code was AUTOGENERATED using the Codama library.
2use crate::CrewDecoder;
3use crate::PROGRAM_ID;
4
5pub mod mint_crew_member;
6pub mod redeem_crew_pack;
7pub mod register_crew_config;
8pub mod register_pack_tiers;
9pub mod register_pack_type;
10pub mod register_sft_redemption;
11pub mod update_pack_tiers;
12
13pub use self::mint_crew_member::*;
14pub use self::redeem_crew_pack::*;
15pub use self::register_crew_config::*;
16pub use self::register_pack_tiers::*;
17pub use self::register_pack_type::*;
18pub use self::register_sft_redemption::*;
19pub use self::update_pack_tiers::*;
20
21#[derive(Debug, Clone, PartialEq, Eq, Hash)]
22#[cfg_attr(
23    feature = "serde",
24    derive(carbon_core::InstructionType, serde::Serialize, serde::Deserialize)
25)]
26#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
27pub enum CrewInstruction {
28    MintCrewMember(MintCrewMember),
29    RedeemCrewPack(RedeemCrewPack),
30    RegisterCrewConfig(RegisterCrewConfig),
31    RegisterPackTiers(RegisterPackTiers),
32    RegisterPackType(RegisterPackType),
33    RegisterSftRedemption(RegisterSftRedemption),
34    UpdatePackTiers(UpdatePackTiers),
35}
36
37impl carbon_core::instruction::InstructionDecoder<'_> for CrewDecoder {
38    type InstructionType = CrewInstruction;
39
40    fn decode_instruction(
41        &self,
42        instruction: &solana_instruction::Instruction,
43    ) -> Option<carbon_core::instruction::DecodedInstruction<Self::InstructionType>> {
44        if !instruction.program_id.eq(&PROGRAM_ID) {
45            return None;
46        }
47
48        let data = instruction.data.as_slice();
49
50        {
51            if let Some(decoded) = mint_crew_member::MintCrewMember::decode(data) {
52                return Some(carbon_core::instruction::DecodedInstruction {
53                    program_id: instruction.program_id,
54                    data: CrewInstruction::MintCrewMember(decoded),
55                    accounts: instruction.accounts.clone(),
56                });
57            }
58        }
59        {
60            if let Some(decoded) = redeem_crew_pack::RedeemCrewPack::decode(data) {
61                return Some(carbon_core::instruction::DecodedInstruction {
62                    program_id: instruction.program_id,
63                    data: CrewInstruction::RedeemCrewPack(decoded),
64                    accounts: instruction.accounts.clone(),
65                });
66            }
67        }
68        {
69            if let Some(decoded) = register_crew_config::RegisterCrewConfig::decode(data) {
70                return Some(carbon_core::instruction::DecodedInstruction {
71                    program_id: instruction.program_id,
72                    data: CrewInstruction::RegisterCrewConfig(decoded),
73                    accounts: instruction.accounts.clone(),
74                });
75            }
76        }
77        {
78            if let Some(decoded) = register_pack_tiers::RegisterPackTiers::decode(data) {
79                return Some(carbon_core::instruction::DecodedInstruction {
80                    program_id: instruction.program_id,
81                    data: CrewInstruction::RegisterPackTiers(decoded),
82                    accounts: instruction.accounts.clone(),
83                });
84            }
85        }
86        {
87            if let Some(decoded) = register_pack_type::RegisterPackType::decode(data) {
88                return Some(carbon_core::instruction::DecodedInstruction {
89                    program_id: instruction.program_id,
90                    data: CrewInstruction::RegisterPackType(decoded),
91                    accounts: instruction.accounts.clone(),
92                });
93            }
94        }
95        {
96            if let Some(decoded) = register_sft_redemption::RegisterSftRedemption::decode(data) {
97                return Some(carbon_core::instruction::DecodedInstruction {
98                    program_id: instruction.program_id,
99                    data: CrewInstruction::RegisterSftRedemption(decoded),
100                    accounts: instruction.accounts.clone(),
101                });
102            }
103        }
104        {
105            if let Some(decoded) = update_pack_tiers::UpdatePackTiers::decode(data) {
106                return Some(carbon_core::instruction::DecodedInstruction {
107                    program_id: instruction.program_id,
108                    data: CrewInstruction::UpdatePackTiers(decoded),
109                    accounts: instruction.accounts.clone(),
110                });
111            }
112        }
113
114        None
115    }
116}