carbon_cargo_decoder/instructions/
mod.rs

1//! This code was AUTOGENERATED using the Codama library.
2use crate::CargoDecoder;
3use crate::PROGRAM_ID;
4#[cfg(feature = "postgres")]
5pub mod postgres;
6
7#[cfg(feature = "graphql")]
8pub mod graphql;
9
10pub mod add_cargo;
11pub mod close_cargo_pod;
12pub mod close_token_account;
13pub mod consume_cargo;
14pub mod init_cargo_pod;
15pub mod init_cargo_type;
16pub mod init_cargo_type_for_next_seq_id;
17pub mod init_cargo_type_from_old_cargo_type;
18pub mod init_definition;
19pub mod legitimize_cargo;
20pub mod mint_to;
21pub mod remove_cargo;
22pub mod transfer_authority;
23pub mod transfer_cargo;
24pub mod update_cargo_pod;
25pub mod update_definition;
26pub mod update_pod_token_account;
27
28pub use self::add_cargo::*;
29pub use self::close_cargo_pod::*;
30pub use self::close_token_account::*;
31pub use self::consume_cargo::*;
32pub use self::init_cargo_pod::*;
33pub use self::init_cargo_type::*;
34pub use self::init_cargo_type_for_next_seq_id::*;
35pub use self::init_cargo_type_from_old_cargo_type::*;
36pub use self::init_definition::*;
37pub use self::legitimize_cargo::*;
38pub use self::mint_to::*;
39pub use self::remove_cargo::*;
40pub use self::transfer_authority::*;
41pub use self::transfer_cargo::*;
42pub use self::update_cargo_pod::*;
43pub use self::update_definition::*;
44pub use self::update_pod_token_account::*;
45
46#[derive(Debug, Clone, PartialEq)]
47#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
48#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
49pub enum CargoInstruction {
50    AddCargo(AddCargo),
51    CloseCargoPod(CloseCargoPod),
52    CloseTokenAccount(CloseTokenAccount),
53    ConsumeCargo(ConsumeCargo),
54    InitCargoPod(InitCargoPod),
55    InitCargoType(InitCargoType),
56    InitCargoTypeForNextSeqId(InitCargoTypeForNextSeqId),
57    InitCargoTypeFromOldCargoType(InitCargoTypeFromOldCargoType),
58    InitDefinition(InitDefinition),
59    LegitimizeCargo(LegitimizeCargo),
60    MintTo(MintTo),
61    RemoveCargo(RemoveCargo),
62    TransferAuthority(TransferAuthority),
63    TransferCargo(TransferCargo),
64    UpdateCargoPod(UpdateCargoPod),
65    UpdateDefinition(UpdateDefinition),
66    UpdatePodTokenAccount(UpdatePodTokenAccount),
67}
68
69impl carbon_core::instruction::InstructionDecoder<'_> for CargoDecoder {
70    type InstructionType = CargoInstruction;
71
72    fn decode_instruction(
73        &self,
74        instruction: &solana_instruction::Instruction,
75    ) -> Option<carbon_core::instruction::DecodedInstruction<Self::InstructionType>> {
76        if !instruction.program_id.eq(&PROGRAM_ID) {
77            return None;
78        }
79
80        let data = instruction.data.as_slice();
81
82        {
83            if let Some(decoded) = add_cargo::AddCargo::decode(data) {
84                return Some(carbon_core::instruction::DecodedInstruction {
85                    program_id: instruction.program_id,
86                    data: CargoInstruction::AddCargo(decoded),
87                    accounts: instruction.accounts.clone(),
88                });
89            }
90        }
91        {
92            if let Some(decoded) = close_cargo_pod::CloseCargoPod::decode(data) {
93                return Some(carbon_core::instruction::DecodedInstruction {
94                    program_id: instruction.program_id,
95                    data: CargoInstruction::CloseCargoPod(decoded),
96                    accounts: instruction.accounts.clone(),
97                });
98            }
99        }
100        {
101            if let Some(decoded) = close_token_account::CloseTokenAccount::decode(data) {
102                return Some(carbon_core::instruction::DecodedInstruction {
103                    program_id: instruction.program_id,
104                    data: CargoInstruction::CloseTokenAccount(decoded),
105                    accounts: instruction.accounts.clone(),
106                });
107            }
108        }
109        {
110            if let Some(decoded) = consume_cargo::ConsumeCargo::decode(data) {
111                return Some(carbon_core::instruction::DecodedInstruction {
112                    program_id: instruction.program_id,
113                    data: CargoInstruction::ConsumeCargo(decoded),
114                    accounts: instruction.accounts.clone(),
115                });
116            }
117        }
118        {
119            if let Some(decoded) = init_cargo_pod::InitCargoPod::decode(data) {
120                return Some(carbon_core::instruction::DecodedInstruction {
121                    program_id: instruction.program_id,
122                    data: CargoInstruction::InitCargoPod(decoded),
123                    accounts: instruction.accounts.clone(),
124                });
125            }
126        }
127        {
128            if let Some(decoded) = init_cargo_type::InitCargoType::decode(data) {
129                return Some(carbon_core::instruction::DecodedInstruction {
130                    program_id: instruction.program_id,
131                    data: CargoInstruction::InitCargoType(decoded),
132                    accounts: instruction.accounts.clone(),
133                });
134            }
135        }
136        {
137            if let Some(decoded) =
138                init_cargo_type_for_next_seq_id::InitCargoTypeForNextSeqId::decode(data)
139            {
140                return Some(carbon_core::instruction::DecodedInstruction {
141                    program_id: instruction.program_id,
142                    data: CargoInstruction::InitCargoTypeForNextSeqId(decoded),
143                    accounts: instruction.accounts.clone(),
144                });
145            }
146        }
147        {
148            if let Some(decoded) =
149                init_cargo_type_from_old_cargo_type::InitCargoTypeFromOldCargoType::decode(data)
150            {
151                return Some(carbon_core::instruction::DecodedInstruction {
152                    program_id: instruction.program_id,
153                    data: CargoInstruction::InitCargoTypeFromOldCargoType(decoded),
154                    accounts: instruction.accounts.clone(),
155                });
156            }
157        }
158        {
159            if let Some(decoded) = init_definition::InitDefinition::decode(data) {
160                return Some(carbon_core::instruction::DecodedInstruction {
161                    program_id: instruction.program_id,
162                    data: CargoInstruction::InitDefinition(decoded),
163                    accounts: instruction.accounts.clone(),
164                });
165            }
166        }
167        {
168            if let Some(decoded) = legitimize_cargo::LegitimizeCargo::decode(data) {
169                return Some(carbon_core::instruction::DecodedInstruction {
170                    program_id: instruction.program_id,
171                    data: CargoInstruction::LegitimizeCargo(decoded),
172                    accounts: instruction.accounts.clone(),
173                });
174            }
175        }
176        {
177            if let Some(decoded) = mint_to::MintTo::decode(data) {
178                return Some(carbon_core::instruction::DecodedInstruction {
179                    program_id: instruction.program_id,
180                    data: CargoInstruction::MintTo(decoded),
181                    accounts: instruction.accounts.clone(),
182                });
183            }
184        }
185        {
186            if let Some(decoded) = remove_cargo::RemoveCargo::decode(data) {
187                return Some(carbon_core::instruction::DecodedInstruction {
188                    program_id: instruction.program_id,
189                    data: CargoInstruction::RemoveCargo(decoded),
190                    accounts: instruction.accounts.clone(),
191                });
192            }
193        }
194        {
195            if let Some(decoded) = transfer_authority::TransferAuthority::decode(data) {
196                return Some(carbon_core::instruction::DecodedInstruction {
197                    program_id: instruction.program_id,
198                    data: CargoInstruction::TransferAuthority(decoded),
199                    accounts: instruction.accounts.clone(),
200                });
201            }
202        }
203        {
204            if let Some(decoded) = transfer_cargo::TransferCargo::decode(data) {
205                return Some(carbon_core::instruction::DecodedInstruction {
206                    program_id: instruction.program_id,
207                    data: CargoInstruction::TransferCargo(decoded),
208                    accounts: instruction.accounts.clone(),
209                });
210            }
211        }
212        {
213            if let Some(decoded) = update_cargo_pod::UpdateCargoPod::decode(data) {
214                return Some(carbon_core::instruction::DecodedInstruction {
215                    program_id: instruction.program_id,
216                    data: CargoInstruction::UpdateCargoPod(decoded),
217                    accounts: instruction.accounts.clone(),
218                });
219            }
220        }
221        {
222            if let Some(decoded) = update_definition::UpdateDefinition::decode(data) {
223                return Some(carbon_core::instruction::DecodedInstruction {
224                    program_id: instruction.program_id,
225                    data: CargoInstruction::UpdateDefinition(decoded),
226                    accounts: instruction.accounts.clone(),
227                });
228            }
229        }
230        {
231            if let Some(decoded) = update_pod_token_account::UpdatePodTokenAccount::decode(data) {
232                return Some(carbon_core::instruction::DecodedInstruction {
233                    program_id: instruction.program_id,
234                    data: CargoInstruction::UpdatePodTokenAccount(decoded),
235                    accounts: instruction.accounts.clone(),
236                });
237            }
238        }
239
240        None
241    }
242}