carbon_points_decoder/instructions/
mod.rs

1//! This code was AUTOGENERATED using the Codama library.
2use crate::PROGRAM_ID;
3use crate::PointsDecoder;
4
5pub mod add_point_category_level;
6pub mod create_point_category;
7pub mod create_user_point_account;
8pub mod create_user_point_account_with_license;
9pub mod decrement_level;
10pub mod decrement_points;
11pub mod deregister_point_modifier;
12pub mod increment_level;
13pub mod increment_level_beyond_threshold;
14pub mod increment_points;
15pub mod register_point_modifier;
16pub mod remove_point_category_level;
17pub mod spend_points;
18pub mod update_point_category;
19
20pub use self::add_point_category_level::*;
21pub use self::create_point_category::*;
22pub use self::create_user_point_account::*;
23pub use self::create_user_point_account_with_license::*;
24pub use self::decrement_level::*;
25pub use self::decrement_points::*;
26pub use self::deregister_point_modifier::*;
27pub use self::increment_level::*;
28pub use self::increment_level_beyond_threshold::*;
29pub use self::increment_points::*;
30pub use self::register_point_modifier::*;
31pub use self::remove_point_category_level::*;
32pub use self::spend_points::*;
33pub use self::update_point_category::*;
34
35#[derive(Debug, Clone, PartialEq, Eq, Hash)]
36#[cfg_attr(
37    feature = "serde",
38    derive(carbon_core::InstructionType, serde::Serialize, serde::Deserialize)
39)]
40#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
41pub enum PointsInstruction {
42    AddPointCategoryLevel(AddPointCategoryLevel),
43    CreatePointCategory(CreatePointCategory),
44    CreateUserPointAccount(CreateUserPointAccount),
45    CreateUserPointAccountWithLicense(CreateUserPointAccountWithLicense),
46    DecrementLevel(DecrementLevel),
47    DecrementPoints(DecrementPoints),
48    DeregisterPointModifier(DeregisterPointModifier),
49    IncrementLevel(IncrementLevel),
50    IncrementLevelBeyondThreshold(IncrementLevelBeyondThreshold),
51    IncrementPoints(IncrementPoints),
52    RegisterPointModifier(RegisterPointModifier),
53    RemovePointCategoryLevel(RemovePointCategoryLevel),
54    SpendPoints(SpendPoints),
55    UpdatePointCategory(UpdatePointCategory),
56}
57
58impl carbon_core::instruction::InstructionDecoder<'_> for PointsDecoder {
59    type InstructionType = PointsInstruction;
60
61    fn decode_instruction(
62        &self,
63        instruction: &solana_instruction::Instruction,
64    ) -> Option<carbon_core::instruction::DecodedInstruction<Self::InstructionType>> {
65        if !instruction.program_id.eq(&PROGRAM_ID) {
66            return None;
67        }
68
69        let data = instruction.data.as_slice();
70
71        {
72            if let Some(decoded) = add_point_category_level::AddPointCategoryLevel::decode(data) {
73                return Some(carbon_core::instruction::DecodedInstruction {
74                    program_id: instruction.program_id,
75                    data: PointsInstruction::AddPointCategoryLevel(decoded),
76                    accounts: instruction.accounts.clone(),
77                });
78            }
79        }
80        {
81            if let Some(decoded) = create_point_category::CreatePointCategory::decode(data) {
82                return Some(carbon_core::instruction::DecodedInstruction {
83                    program_id: instruction.program_id,
84                    data: PointsInstruction::CreatePointCategory(decoded),
85                    accounts: instruction.accounts.clone(),
86                });
87            }
88        }
89        {
90            if let Some(decoded) = create_user_point_account::CreateUserPointAccount::decode(data) {
91                return Some(carbon_core::instruction::DecodedInstruction {
92                    program_id: instruction.program_id,
93                    data: PointsInstruction::CreateUserPointAccount(decoded),
94                    accounts: instruction.accounts.clone(),
95                });
96            }
97        }
98        {
99            if let Some(decoded) =
100                create_user_point_account_with_license::CreateUserPointAccountWithLicense::decode(
101                    data,
102                )
103            {
104                return Some(carbon_core::instruction::DecodedInstruction {
105                    program_id: instruction.program_id,
106                    data: PointsInstruction::CreateUserPointAccountWithLicense(decoded),
107                    accounts: instruction.accounts.clone(),
108                });
109            }
110        }
111        {
112            if let Some(decoded) = decrement_level::DecrementLevel::decode(data) {
113                return Some(carbon_core::instruction::DecodedInstruction {
114                    program_id: instruction.program_id,
115                    data: PointsInstruction::DecrementLevel(decoded),
116                    accounts: instruction.accounts.clone(),
117                });
118            }
119        }
120        {
121            if let Some(decoded) = decrement_points::DecrementPoints::decode(data) {
122                return Some(carbon_core::instruction::DecodedInstruction {
123                    program_id: instruction.program_id,
124                    data: PointsInstruction::DecrementPoints(decoded),
125                    accounts: instruction.accounts.clone(),
126                });
127            }
128        }
129        {
130            if let Some(decoded) = deregister_point_modifier::DeregisterPointModifier::decode(data)
131            {
132                return Some(carbon_core::instruction::DecodedInstruction {
133                    program_id: instruction.program_id,
134                    data: PointsInstruction::DeregisterPointModifier(decoded),
135                    accounts: instruction.accounts.clone(),
136                });
137            }
138        }
139        {
140            if let Some(decoded) = increment_level::IncrementLevel::decode(data) {
141                return Some(carbon_core::instruction::DecodedInstruction {
142                    program_id: instruction.program_id,
143                    data: PointsInstruction::IncrementLevel(decoded),
144                    accounts: instruction.accounts.clone(),
145                });
146            }
147        }
148        {
149            if let Some(decoded) =
150                increment_level_beyond_threshold::IncrementLevelBeyondThreshold::decode(data)
151            {
152                return Some(carbon_core::instruction::DecodedInstruction {
153                    program_id: instruction.program_id,
154                    data: PointsInstruction::IncrementLevelBeyondThreshold(decoded),
155                    accounts: instruction.accounts.clone(),
156                });
157            }
158        }
159        {
160            if let Some(decoded) = increment_points::IncrementPoints::decode(data) {
161                return Some(carbon_core::instruction::DecodedInstruction {
162                    program_id: instruction.program_id,
163                    data: PointsInstruction::IncrementPoints(decoded),
164                    accounts: instruction.accounts.clone(),
165                });
166            }
167        }
168        {
169            if let Some(decoded) = register_point_modifier::RegisterPointModifier::decode(data) {
170                return Some(carbon_core::instruction::DecodedInstruction {
171                    program_id: instruction.program_id,
172                    data: PointsInstruction::RegisterPointModifier(decoded),
173                    accounts: instruction.accounts.clone(),
174                });
175            }
176        }
177        {
178            if let Some(decoded) =
179                remove_point_category_level::RemovePointCategoryLevel::decode(data)
180            {
181                return Some(carbon_core::instruction::DecodedInstruction {
182                    program_id: instruction.program_id,
183                    data: PointsInstruction::RemovePointCategoryLevel(decoded),
184                    accounts: instruction.accounts.clone(),
185                });
186            }
187        }
188        {
189            if let Some(decoded) = spend_points::SpendPoints::decode(data) {
190                return Some(carbon_core::instruction::DecodedInstruction {
191                    program_id: instruction.program_id,
192                    data: PointsInstruction::SpendPoints(decoded),
193                    accounts: instruction.accounts.clone(),
194                });
195            }
196        }
197        {
198            if let Some(decoded) = update_point_category::UpdatePointCategory::decode(data) {
199                return Some(carbon_core::instruction::DecodedInstruction {
200                    program_id: instruction.program_id,
201                    data: PointsInstruction::UpdatePointCategory(decoded),
202                    accounts: instruction.accounts.clone(),
203                });
204            }
205        }
206
207        None
208    }
209}