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