carbon_crafting_decoder/instructions/
mod.rs1use crate::CraftingDecoder;
3use crate::PROGRAM_ID;
4#[cfg(feature = "postgres")]
5pub mod postgres;
6
7#[cfg(feature = "graphql")]
8pub mod graphql;
9
10pub mod add_consumable_input_to_recipe;
11pub mod add_crafting_facility_recipe_category;
12pub mod add_non_consumable_input_to_recipe;
13pub mod add_output_to_recipe;
14pub mod add_recipe_ingredient;
15pub mod burn_consumable_ingredient;
16pub mod cancel_crafting_process;
17pub mod claim_non_consumable_ingredient;
18pub mod claim_recipe_output;
19pub mod close_crafting_process;
20pub mod create_crafting_process;
21pub mod deregister_crafting_facility;
22pub mod deregister_recipe_category;
23pub mod drain_craftable_item_bank;
24pub mod initialize_domain;
25pub mod legitimize_recipe_ingredient;
26pub mod register_craftable_item;
27pub mod register_crafting_facility;
28pub mod register_recipe;
29pub mod register_recipe_category;
30pub mod remove_consumable_input_from_recipe;
31pub mod remove_crafting_facility_recipe_category;
32pub mod remove_non_consumable_input_from_recipe;
33pub mod remove_output_from_recipe;
34pub mod remove_recipe_ingredient;
35pub mod start_crafting_process;
36pub mod stop_crafting_process;
37pub mod update_crafting_facility;
38pub mod update_domain;
39pub mod update_recipe;
40pub mod update_recipe_category;
41
42pub use self::add_consumable_input_to_recipe::*;
43pub use self::add_crafting_facility_recipe_category::*;
44pub use self::add_non_consumable_input_to_recipe::*;
45pub use self::add_output_to_recipe::*;
46pub use self::add_recipe_ingredient::*;
47pub use self::burn_consumable_ingredient::*;
48pub use self::cancel_crafting_process::*;
49pub use self::claim_non_consumable_ingredient::*;
50pub use self::claim_recipe_output::*;
51pub use self::close_crafting_process::*;
52pub use self::create_crafting_process::*;
53pub use self::deregister_crafting_facility::*;
54pub use self::deregister_recipe_category::*;
55pub use self::drain_craftable_item_bank::*;
56pub use self::initialize_domain::*;
57pub use self::legitimize_recipe_ingredient::*;
58pub use self::register_craftable_item::*;
59pub use self::register_crafting_facility::*;
60pub use self::register_recipe::*;
61pub use self::register_recipe_category::*;
62pub use self::remove_consumable_input_from_recipe::*;
63pub use self::remove_crafting_facility_recipe_category::*;
64pub use self::remove_non_consumable_input_from_recipe::*;
65pub use self::remove_output_from_recipe::*;
66pub use self::remove_recipe_ingredient::*;
67pub use self::start_crafting_process::*;
68pub use self::stop_crafting_process::*;
69pub use self::update_crafting_facility::*;
70pub use self::update_domain::*;
71pub use self::update_recipe::*;
72pub use self::update_recipe_category::*;
73
74#[derive(Debug, Clone, PartialEq)]
75#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
76#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
77pub enum CraftingInstruction {
78 AddConsumableInputToRecipe(AddConsumableInputToRecipe),
79 AddCraftingFacilityRecipeCategory(AddCraftingFacilityRecipeCategory),
80 AddNonConsumableInputToRecipe(AddNonConsumableInputToRecipe),
81 AddOutputToRecipe(AddOutputToRecipe),
82 AddRecipeIngredient(AddRecipeIngredient),
83 BurnConsumableIngredient(BurnConsumableIngredient),
84 CancelCraftingProcess(CancelCraftingProcess),
85 ClaimNonConsumableIngredient(ClaimNonConsumableIngredient),
86 ClaimRecipeOutput(ClaimRecipeOutput),
87 CloseCraftingProcess(CloseCraftingProcess),
88 CreateCraftingProcess(CreateCraftingProcess),
89 DeregisterCraftingFacility(DeregisterCraftingFacility),
90 DeregisterRecipeCategory(DeregisterRecipeCategory),
91 DrainCraftableItemBank(DrainCraftableItemBank),
92 InitializeDomain(InitializeDomain),
93 LegitimizeRecipeIngredient(LegitimizeRecipeIngredient),
94 RegisterCraftableItem(RegisterCraftableItem),
95 RegisterCraftingFacility(RegisterCraftingFacility),
96 RegisterRecipe(RegisterRecipe),
97 RegisterRecipeCategory(RegisterRecipeCategory),
98 RemoveConsumableInputFromRecipe(RemoveConsumableInputFromRecipe),
99 RemoveCraftingFacilityRecipeCategory(RemoveCraftingFacilityRecipeCategory),
100 RemoveNonConsumableInputFromRecipe(RemoveNonConsumableInputFromRecipe),
101 RemoveOutputFromRecipe(RemoveOutputFromRecipe),
102 RemoveRecipeIngredient(RemoveRecipeIngredient),
103 StartCraftingProcess(StartCraftingProcess),
104 StopCraftingProcess(StopCraftingProcess),
105 UpdateCraftingFacility(UpdateCraftingFacility),
106 UpdateDomain(UpdateDomain),
107 UpdateRecipe(UpdateRecipe),
108 UpdateRecipeCategory(UpdateRecipeCategory),
109}
110
111impl carbon_core::instruction::InstructionDecoder<'_> for CraftingDecoder {
112 type InstructionType = CraftingInstruction;
113
114 fn decode_instruction(
115 &self,
116 instruction: &solana_instruction::Instruction,
117 ) -> Option<carbon_core::instruction::DecodedInstruction<Self::InstructionType>> {
118 if !instruction.program_id.eq(&PROGRAM_ID) {
119 return None;
120 }
121
122 let data = instruction.data.as_slice();
123
124 {
125 if let Some(decoded) =
126 add_consumable_input_to_recipe::AddConsumableInputToRecipe::decode(data)
127 {
128 return Some(carbon_core::instruction::DecodedInstruction {
129 program_id: instruction.program_id,
130 data: CraftingInstruction::AddConsumableInputToRecipe(decoded),
131 accounts: instruction.accounts.clone(),
132 });
133 }
134 }
135 {
136 if let Some(decoded) =
137 add_crafting_facility_recipe_category::AddCraftingFacilityRecipeCategory::decode(
138 data,
139 )
140 {
141 return Some(carbon_core::instruction::DecodedInstruction {
142 program_id: instruction.program_id,
143 data: CraftingInstruction::AddCraftingFacilityRecipeCategory(decoded),
144 accounts: instruction.accounts.clone(),
145 });
146 }
147 }
148 {
149 if let Some(decoded) =
150 add_non_consumable_input_to_recipe::AddNonConsumableInputToRecipe::decode(data)
151 {
152 return Some(carbon_core::instruction::DecodedInstruction {
153 program_id: instruction.program_id,
154 data: CraftingInstruction::AddNonConsumableInputToRecipe(decoded),
155 accounts: instruction.accounts.clone(),
156 });
157 }
158 }
159 {
160 if let Some(decoded) = add_output_to_recipe::AddOutputToRecipe::decode(data) {
161 return Some(carbon_core::instruction::DecodedInstruction {
162 program_id: instruction.program_id,
163 data: CraftingInstruction::AddOutputToRecipe(decoded),
164 accounts: instruction.accounts.clone(),
165 });
166 }
167 }
168 {
169 if let Some(decoded) = add_recipe_ingredient::AddRecipeIngredient::decode(data) {
170 return Some(carbon_core::instruction::DecodedInstruction {
171 program_id: instruction.program_id,
172 data: CraftingInstruction::AddRecipeIngredient(decoded),
173 accounts: instruction.accounts.clone(),
174 });
175 }
176 }
177 {
178 if let Some(decoded) =
179 burn_consumable_ingredient::BurnConsumableIngredient::decode(data)
180 {
181 return Some(carbon_core::instruction::DecodedInstruction {
182 program_id: instruction.program_id,
183 data: CraftingInstruction::BurnConsumableIngredient(decoded),
184 accounts: instruction.accounts.clone(),
185 });
186 }
187 }
188 {
189 if let Some(decoded) = cancel_crafting_process::CancelCraftingProcess::decode(data) {
190 return Some(carbon_core::instruction::DecodedInstruction {
191 program_id: instruction.program_id,
192 data: CraftingInstruction::CancelCraftingProcess(decoded),
193 accounts: instruction.accounts.clone(),
194 });
195 }
196 }
197 {
198 if let Some(decoded) =
199 claim_non_consumable_ingredient::ClaimNonConsumableIngredient::decode(data)
200 {
201 return Some(carbon_core::instruction::DecodedInstruction {
202 program_id: instruction.program_id,
203 data: CraftingInstruction::ClaimNonConsumableIngredient(decoded),
204 accounts: instruction.accounts.clone(),
205 });
206 }
207 }
208 {
209 if let Some(decoded) = claim_recipe_output::ClaimRecipeOutput::decode(data) {
210 return Some(carbon_core::instruction::DecodedInstruction {
211 program_id: instruction.program_id,
212 data: CraftingInstruction::ClaimRecipeOutput(decoded),
213 accounts: instruction.accounts.clone(),
214 });
215 }
216 }
217 {
218 if let Some(decoded) = close_crafting_process::CloseCraftingProcess::decode(data) {
219 return Some(carbon_core::instruction::DecodedInstruction {
220 program_id: instruction.program_id,
221 data: CraftingInstruction::CloseCraftingProcess(decoded),
222 accounts: instruction.accounts.clone(),
223 });
224 }
225 }
226 {
227 if let Some(decoded) = create_crafting_process::CreateCraftingProcess::decode(data) {
228 return Some(carbon_core::instruction::DecodedInstruction {
229 program_id: instruction.program_id,
230 data: CraftingInstruction::CreateCraftingProcess(decoded),
231 accounts: instruction.accounts.clone(),
232 });
233 }
234 }
235 {
236 if let Some(decoded) =
237 deregister_crafting_facility::DeregisterCraftingFacility::decode(data)
238 {
239 return Some(carbon_core::instruction::DecodedInstruction {
240 program_id: instruction.program_id,
241 data: CraftingInstruction::DeregisterCraftingFacility(decoded),
242 accounts: instruction.accounts.clone(),
243 });
244 }
245 }
246 {
247 if let Some(decoded) =
248 deregister_recipe_category::DeregisterRecipeCategory::decode(data)
249 {
250 return Some(carbon_core::instruction::DecodedInstruction {
251 program_id: instruction.program_id,
252 data: CraftingInstruction::DeregisterRecipeCategory(decoded),
253 accounts: instruction.accounts.clone(),
254 });
255 }
256 }
257 {
258 if let Some(decoded) = drain_craftable_item_bank::DrainCraftableItemBank::decode(data) {
259 return Some(carbon_core::instruction::DecodedInstruction {
260 program_id: instruction.program_id,
261 data: CraftingInstruction::DrainCraftableItemBank(decoded),
262 accounts: instruction.accounts.clone(),
263 });
264 }
265 }
266 {
267 if let Some(decoded) = initialize_domain::InitializeDomain::decode(data) {
268 return Some(carbon_core::instruction::DecodedInstruction {
269 program_id: instruction.program_id,
270 data: CraftingInstruction::InitializeDomain(decoded),
271 accounts: instruction.accounts.clone(),
272 });
273 }
274 }
275 {
276 if let Some(decoded) =
277 legitimize_recipe_ingredient::LegitimizeRecipeIngredient::decode(data)
278 {
279 return Some(carbon_core::instruction::DecodedInstruction {
280 program_id: instruction.program_id,
281 data: CraftingInstruction::LegitimizeRecipeIngredient(decoded),
282 accounts: instruction.accounts.clone(),
283 });
284 }
285 }
286 {
287 if let Some(decoded) = register_craftable_item::RegisterCraftableItem::decode(data) {
288 return Some(carbon_core::instruction::DecodedInstruction {
289 program_id: instruction.program_id,
290 data: CraftingInstruction::RegisterCraftableItem(decoded),
291 accounts: instruction.accounts.clone(),
292 });
293 }
294 }
295 {
296 if let Some(decoded) =
297 register_crafting_facility::RegisterCraftingFacility::decode(data)
298 {
299 return Some(carbon_core::instruction::DecodedInstruction {
300 program_id: instruction.program_id,
301 data: CraftingInstruction::RegisterCraftingFacility(decoded),
302 accounts: instruction.accounts.clone(),
303 });
304 }
305 }
306 {
307 if let Some(decoded) = register_recipe::RegisterRecipe::decode(data) {
308 return Some(carbon_core::instruction::DecodedInstruction {
309 program_id: instruction.program_id,
310 data: CraftingInstruction::RegisterRecipe(decoded),
311 accounts: instruction.accounts.clone(),
312 });
313 }
314 }
315 {
316 if let Some(decoded) = register_recipe_category::RegisterRecipeCategory::decode(data) {
317 return Some(carbon_core::instruction::DecodedInstruction {
318 program_id: instruction.program_id,
319 data: CraftingInstruction::RegisterRecipeCategory(decoded),
320 accounts: instruction.accounts.clone(),
321 });
322 }
323 }
324 {
325 if let Some(decoded) =
326 remove_consumable_input_from_recipe::RemoveConsumableInputFromRecipe::decode(data)
327 {
328 return Some(carbon_core::instruction::DecodedInstruction {
329 program_id: instruction.program_id,
330 data: CraftingInstruction::RemoveConsumableInputFromRecipe(decoded),
331 accounts: instruction.accounts.clone(),
332 });
333 }
334 }
335 {
336 if let Some(decoded) = remove_crafting_facility_recipe_category::RemoveCraftingFacilityRecipeCategory::decode(data) {
337 return Some(carbon_core::instruction::DecodedInstruction {
338 program_id: instruction.program_id,
339 data: CraftingInstruction::RemoveCraftingFacilityRecipeCategory(decoded),
340 accounts: instruction.accounts.clone(),
341 });
342 }
343 }
344 {
345 if let Some(decoded) =
346 remove_non_consumable_input_from_recipe::RemoveNonConsumableInputFromRecipe::decode(
347 data,
348 )
349 {
350 return Some(carbon_core::instruction::DecodedInstruction {
351 program_id: instruction.program_id,
352 data: CraftingInstruction::RemoveNonConsumableInputFromRecipe(decoded),
353 accounts: instruction.accounts.clone(),
354 });
355 }
356 }
357 {
358 if let Some(decoded) = remove_output_from_recipe::RemoveOutputFromRecipe::decode(data) {
359 return Some(carbon_core::instruction::DecodedInstruction {
360 program_id: instruction.program_id,
361 data: CraftingInstruction::RemoveOutputFromRecipe(decoded),
362 accounts: instruction.accounts.clone(),
363 });
364 }
365 }
366 {
367 if let Some(decoded) = remove_recipe_ingredient::RemoveRecipeIngredient::decode(data) {
368 return Some(carbon_core::instruction::DecodedInstruction {
369 program_id: instruction.program_id,
370 data: CraftingInstruction::RemoveRecipeIngredient(decoded),
371 accounts: instruction.accounts.clone(),
372 });
373 }
374 }
375 {
376 if let Some(decoded) = start_crafting_process::StartCraftingProcess::decode(data) {
377 return Some(carbon_core::instruction::DecodedInstruction {
378 program_id: instruction.program_id,
379 data: CraftingInstruction::StartCraftingProcess(decoded),
380 accounts: instruction.accounts.clone(),
381 });
382 }
383 }
384 {
385 if let Some(decoded) = stop_crafting_process::StopCraftingProcess::decode(data) {
386 return Some(carbon_core::instruction::DecodedInstruction {
387 program_id: instruction.program_id,
388 data: CraftingInstruction::StopCraftingProcess(decoded),
389 accounts: instruction.accounts.clone(),
390 });
391 }
392 }
393 {
394 if let Some(decoded) = update_crafting_facility::UpdateCraftingFacility::decode(data) {
395 return Some(carbon_core::instruction::DecodedInstruction {
396 program_id: instruction.program_id,
397 data: CraftingInstruction::UpdateCraftingFacility(decoded),
398 accounts: instruction.accounts.clone(),
399 });
400 }
401 }
402 {
403 if let Some(decoded) = update_domain::UpdateDomain::decode(data) {
404 return Some(carbon_core::instruction::DecodedInstruction {
405 program_id: instruction.program_id,
406 data: CraftingInstruction::UpdateDomain(decoded),
407 accounts: instruction.accounts.clone(),
408 });
409 }
410 }
411 {
412 if let Some(decoded) = update_recipe::UpdateRecipe::decode(data) {
413 return Some(carbon_core::instruction::DecodedInstruction {
414 program_id: instruction.program_id,
415 data: CraftingInstruction::UpdateRecipe(decoded),
416 accounts: instruction.accounts.clone(),
417 });
418 }
419 }
420 {
421 if let Some(decoded) = update_recipe_category::UpdateRecipeCategory::decode(data) {
422 return Some(carbon_core::instruction::DecodedInstruction {
423 program_id: instruction.program_id,
424 data: CraftingInstruction::UpdateRecipeCategory(decoded),
425 accounts: instruction.accounts.clone(),
426 });
427 }
428 }
429
430 None
431 }
432}