carbon_srsly_decoder/instructions/
mod.rs1use crate::PROGRAM_ID;
3use crate::SrslyDecoder;
4
5pub mod accept_rental;
6pub mod cancel_rental;
7pub mod close_contract;
8pub mod close_rental;
9pub mod create_contract;
10pub mod pay_rental;
11pub mod reset_rental;
12
13pub use self::accept_rental::*;
14pub use self::cancel_rental::*;
15pub use self::close_contract::*;
16pub use self::close_rental::*;
17pub use self::create_contract::*;
18pub use self::pay_rental::*;
19pub use self::reset_rental::*;
20
21#[derive(Debug, Clone, PartialEq, Eq, Hash)]
22#[cfg_attr(
23 feature = "serde",
24 derive(carbon_core::InstructionType, serde::Serialize, serde::Deserialize)
25)]
26#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
27pub enum SrslyInstruction {
28 AcceptRental(AcceptRental),
29 CancelRental(CancelRental),
30 CloseContract(CloseContract),
31 CloseRental(CloseRental),
32 CreateContract(CreateContract),
33 PayRental(PayRental),
34 ResetRental(ResetRental),
35}
36
37impl carbon_core::instruction::InstructionDecoder<'_> for SrslyDecoder {
38 type InstructionType = SrslyInstruction;
39
40 fn decode_instruction(
41 &self,
42 instruction: &solana_instruction::Instruction,
43 ) -> Option<carbon_core::instruction::DecodedInstruction<Self::InstructionType>> {
44 if !instruction.program_id.eq(&PROGRAM_ID) {
45 return None;
46 }
47
48 let data = instruction.data.as_slice();
49
50 {
51 if let Some(decoded) = accept_rental::AcceptRental::decode(data) {
52 return Some(carbon_core::instruction::DecodedInstruction {
53 program_id: instruction.program_id,
54 data: SrslyInstruction::AcceptRental(decoded),
55 accounts: instruction.accounts.clone(),
56 });
57 }
58 }
59 {
60 if let Some(decoded) = cancel_rental::CancelRental::decode(data) {
61 return Some(carbon_core::instruction::DecodedInstruction {
62 program_id: instruction.program_id,
63 data: SrslyInstruction::CancelRental(decoded),
64 accounts: instruction.accounts.clone(),
65 });
66 }
67 }
68 {
69 if let Some(decoded) = close_contract::CloseContract::decode(data) {
70 return Some(carbon_core::instruction::DecodedInstruction {
71 program_id: instruction.program_id,
72 data: SrslyInstruction::CloseContract(decoded),
73 accounts: instruction.accounts.clone(),
74 });
75 }
76 }
77 {
78 if let Some(decoded) = close_rental::CloseRental::decode(data) {
79 return Some(carbon_core::instruction::DecodedInstruction {
80 program_id: instruction.program_id,
81 data: SrslyInstruction::CloseRental(decoded),
82 accounts: instruction.accounts.clone(),
83 });
84 }
85 }
86 {
87 if let Some(decoded) = create_contract::CreateContract::decode(data) {
88 return Some(carbon_core::instruction::DecodedInstruction {
89 program_id: instruction.program_id,
90 data: SrslyInstruction::CreateContract(decoded),
91 accounts: instruction.accounts.clone(),
92 });
93 }
94 }
95 {
96 if let Some(decoded) = pay_rental::PayRental::decode(data) {
97 return Some(carbon_core::instruction::DecodedInstruction {
98 program_id: instruction.program_id,
99 data: SrslyInstruction::PayRental(decoded),
100 accounts: instruction.accounts.clone(),
101 });
102 }
103 }
104 {
105 if let Some(decoded) = reset_rental::ResetRental::decode(data) {
106 return Some(carbon_core::instruction::DecodedInstruction {
107 program_id: instruction.program_id,
108 data: SrslyInstruction::ResetRental(decoded),
109 accounts: instruction.accounts.clone(),
110 });
111 }
112 }
113
114 None
115 }
116}