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