carbon_tcomp_decoder/instructions/
mod.rs1use crate::PROGRAM_ID;
3use crate::TcompDecoder;
4#[cfg(feature = "postgres")]
5pub mod postgres;
6
7#[cfg(feature = "graphql")]
8pub mod graphql;
9
10pub mod bid;
11pub mod buy;
12pub mod buy_core;
13pub mod buy_spl;
14pub mod cancel_bid;
15pub mod close_expired_bid;
16pub mod close_expired_listing;
17pub mod close_expired_listing_core;
18pub mod delist;
19pub mod delist_core;
20pub mod edit;
21pub mod list;
22pub mod list_core;
23pub mod take_bid_core;
24pub mod take_bid_full_meta;
25pub mod take_bid_legacy;
26pub mod take_bid_meta_hash;
27pub mod take_bid_t22;
28pub mod take_bid_wns;
29pub mod tcomp_noop;
30pub mod withdraw_fees;
31
32pub use self::bid::*;
33pub use self::buy::*;
34pub use self::buy_core::*;
35pub use self::buy_spl::*;
36pub use self::cancel_bid::*;
37pub use self::close_expired_bid::*;
38pub use self::close_expired_listing::*;
39pub use self::close_expired_listing_core::*;
40pub use self::delist::*;
41pub use self::delist_core::*;
42pub use self::edit::*;
43pub use self::list::*;
44pub use self::list_core::*;
45pub use self::take_bid_core::*;
46pub use self::take_bid_full_meta::*;
47pub use self::take_bid_legacy::*;
48pub use self::take_bid_meta_hash::*;
49pub use self::take_bid_t22::*;
50pub use self::take_bid_wns::*;
51pub use self::tcomp_noop::*;
52pub use self::withdraw_fees::*;
53
54#[derive(Debug, Clone, PartialEq)]
55#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
56#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
57pub enum TcompInstruction {
58 Bid(Bid),
59 Buy(Buy),
60 BuyCore(BuyCore),
61 BuySpl(BuySpl),
62 CancelBid(CancelBid),
63 CloseExpiredBid(CloseExpiredBid),
64 CloseExpiredListing(CloseExpiredListing),
65 CloseExpiredListingCore(CloseExpiredListingCore),
66 Delist(Delist),
67 DelistCore(DelistCore),
68 Edit(Edit),
69 List(List),
70 ListCore(ListCore),
71 TakeBidCore(TakeBidCore),
72 TakeBidFullMeta(TakeBidFullMeta),
73 TakeBidLegacy(TakeBidLegacy),
74 TakeBidMetaHash(TakeBidMetaHash),
75 TakeBidT22(TakeBidT22),
76 TakeBidWns(TakeBidWns),
77 TcompNoop(TcompNoop),
78 WithdrawFees(WithdrawFees),
79}
80
81impl carbon_core::instruction::InstructionDecoder<'_> for TcompDecoder {
82 type InstructionType = TcompInstruction;
83
84 fn decode_instruction(
85 &self,
86 instruction: &solana_instruction::Instruction,
87 ) -> Option<carbon_core::instruction::DecodedInstruction<Self::InstructionType>> {
88 if !instruction.program_id.eq(&PROGRAM_ID) {
89 return None;
90 }
91
92 let data = instruction.data.as_slice();
93
94 {
95 if let Some(decoded) = tcomp_noop::TcompNoop::decode(data) {
96 return Some(carbon_core::instruction::DecodedInstruction {
97 program_id: instruction.program_id,
98 data: TcompInstruction::TcompNoop(decoded),
99 accounts: instruction.accounts.clone(),
100 });
101 }
102 }
103 {
104 if let Some(decoded) = withdraw_fees::WithdrawFees::decode(data) {
105 return Some(carbon_core::instruction::DecodedInstruction {
106 program_id: instruction.program_id,
107 data: TcompInstruction::WithdrawFees(decoded),
108 accounts: instruction.accounts.clone(),
109 });
110 }
111 }
112 {
113 if let Some(decoded) = buy::Buy::decode(data) {
114 return Some(carbon_core::instruction::DecodedInstruction {
115 program_id: instruction.program_id,
116 data: TcompInstruction::Buy(decoded),
117 accounts: instruction.accounts.clone(),
118 });
119 }
120 }
121 {
122 if let Some(decoded) = buy_spl::BuySpl::decode(data) {
123 return Some(carbon_core::instruction::DecodedInstruction {
124 program_id: instruction.program_id,
125 data: TcompInstruction::BuySpl(decoded),
126 accounts: instruction.accounts.clone(),
127 });
128 }
129 }
130 {
131 if let Some(decoded) = buy_core::BuyCore::decode(data) {
132 return Some(carbon_core::instruction::DecodedInstruction {
133 program_id: instruction.program_id,
134 data: TcompInstruction::BuyCore(decoded),
135 accounts: instruction.accounts.clone(),
136 });
137 }
138 }
139 {
140 if let Some(decoded) = list::List::decode(data) {
141 return Some(carbon_core::instruction::DecodedInstruction {
142 program_id: instruction.program_id,
143 data: TcompInstruction::List(decoded),
144 accounts: instruction.accounts.clone(),
145 });
146 }
147 }
148 {
149 if let Some(decoded) = delist::Delist::decode(data) {
150 return Some(carbon_core::instruction::DecodedInstruction {
151 program_id: instruction.program_id,
152 data: TcompInstruction::Delist(decoded),
153 accounts: instruction.accounts.clone(),
154 });
155 }
156 }
157 {
158 if let Some(decoded) = edit::Edit::decode(data) {
159 return Some(carbon_core::instruction::DecodedInstruction {
160 program_id: instruction.program_id,
161 data: TcompInstruction::Edit(decoded),
162 accounts: instruction.accounts.clone(),
163 });
164 }
165 }
166 {
167 if let Some(decoded) = list_core::ListCore::decode(data) {
168 return Some(carbon_core::instruction::DecodedInstruction {
169 program_id: instruction.program_id,
170 data: TcompInstruction::ListCore(decoded),
171 accounts: instruction.accounts.clone(),
172 });
173 }
174 }
175 {
176 if let Some(decoded) = delist_core::DelistCore::decode(data) {
177 return Some(carbon_core::instruction::DecodedInstruction {
178 program_id: instruction.program_id,
179 data: TcompInstruction::DelistCore(decoded),
180 accounts: instruction.accounts.clone(),
181 });
182 }
183 }
184 {
185 if let Some(decoded) = bid::Bid::decode(data) {
186 return Some(carbon_core::instruction::DecodedInstruction {
187 program_id: instruction.program_id,
188 data: TcompInstruction::Bid(decoded),
189 accounts: instruction.accounts.clone(),
190 });
191 }
192 }
193 {
194 if let Some(decoded) = cancel_bid::CancelBid::decode(data) {
195 return Some(carbon_core::instruction::DecodedInstruction {
196 program_id: instruction.program_id,
197 data: TcompInstruction::CancelBid(decoded),
198 accounts: instruction.accounts.clone(),
199 });
200 }
201 }
202 {
203 if let Some(decoded) = close_expired_bid::CloseExpiredBid::decode(data) {
204 return Some(carbon_core::instruction::DecodedInstruction {
205 program_id: instruction.program_id,
206 data: TcompInstruction::CloseExpiredBid(decoded),
207 accounts: instruction.accounts.clone(),
208 });
209 }
210 }
211 {
212 if let Some(decoded) = close_expired_listing::CloseExpiredListing::decode(data) {
213 return Some(carbon_core::instruction::DecodedInstruction {
214 program_id: instruction.program_id,
215 data: TcompInstruction::CloseExpiredListing(decoded),
216 accounts: instruction.accounts.clone(),
217 });
218 }
219 }
220 {
221 if let Some(decoded) = close_expired_listing_core::CloseExpiredListingCore::decode(data)
222 {
223 return Some(carbon_core::instruction::DecodedInstruction {
224 program_id: instruction.program_id,
225 data: TcompInstruction::CloseExpiredListingCore(decoded),
226 accounts: instruction.accounts.clone(),
227 });
228 }
229 }
230 {
231 if let Some(decoded) = take_bid_meta_hash::TakeBidMetaHash::decode(data) {
232 return Some(carbon_core::instruction::DecodedInstruction {
233 program_id: instruction.program_id,
234 data: TcompInstruction::TakeBidMetaHash(decoded),
235 accounts: instruction.accounts.clone(),
236 });
237 }
238 }
239 {
240 if let Some(decoded) = take_bid_full_meta::TakeBidFullMeta::decode(data) {
241 return Some(carbon_core::instruction::DecodedInstruction {
242 program_id: instruction.program_id,
243 data: TcompInstruction::TakeBidFullMeta(decoded),
244 accounts: instruction.accounts.clone(),
245 });
246 }
247 }
248 {
249 if let Some(decoded) = take_bid_legacy::TakeBidLegacy::decode(data) {
250 return Some(carbon_core::instruction::DecodedInstruction {
251 program_id: instruction.program_id,
252 data: TcompInstruction::TakeBidLegacy(decoded),
253 accounts: instruction.accounts.clone(),
254 });
255 }
256 }
257 {
258 if let Some(decoded) = take_bid_t22::TakeBidT22::decode(data) {
259 return Some(carbon_core::instruction::DecodedInstruction {
260 program_id: instruction.program_id,
261 data: TcompInstruction::TakeBidT22(decoded),
262 accounts: instruction.accounts.clone(),
263 });
264 }
265 }
266 {
267 if let Some(decoded) = take_bid_wns::TakeBidWns::decode(data) {
268 return Some(carbon_core::instruction::DecodedInstruction {
269 program_id: instruction.program_id,
270 data: TcompInstruction::TakeBidWns(decoded),
271 accounts: instruction.accounts.clone(),
272 });
273 }
274 }
275 {
276 if let Some(decoded) = take_bid_core::TakeBidCore::decode(data) {
277 return Some(carbon_core::instruction::DecodedInstruction {
278 program_id: instruction.program_id,
279 data: TcompInstruction::TakeBidCore(decoded),
280 accounts: instruction.accounts.clone(),
281 });
282 }
283 }
284
285 None
286 }
287}