carbon_proxy_rewarder_decoder/instructions/
mod.rs1use crate::PROGRAM_ID;
3use crate::ProxyRewarderDecoder;
4
5pub mod claim_rewards;
6pub mod cpi_event;
7pub mod new_proxy;
8pub mod new_proxy_escrow;
9pub mod proxy_exit;
10pub mod proxy_lock;
11pub mod register_locker;
12pub mod update_registered_locker;
13
14pub use self::claim_rewards::*;
15pub use self::cpi_event::*;
16pub use self::new_proxy::*;
17pub use self::new_proxy_escrow::*;
18pub use self::proxy_exit::*;
19pub use self::proxy_lock::*;
20pub use self::register_locker::*;
21pub use self::update_registered_locker::*;
22
23#[derive(Debug, Clone, PartialEq, Eq, Hash)]
24#[cfg_attr(
25 feature = "serde",
26 derive(carbon_core::InstructionType, serde::Serialize, serde::Deserialize)
27)]
28#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
29pub enum ProxyRewarderInstruction {
30 ClaimRewards(ClaimRewards),
31 NewProxy(NewProxy),
32 NewProxyEscrow(NewProxyEscrow),
33 ProxyExit(ProxyExit),
34 ProxyLock(ProxyLock),
35 RegisterLocker(RegisterLocker),
36 UpdateRegisteredLocker(UpdateRegisteredLocker),
37 CpiEvent(CpiEvent),
39}
40
41impl carbon_core::instruction::InstructionDecoder<'_> for ProxyRewarderDecoder {
42 type InstructionType = ProxyRewarderInstruction;
43
44 fn decode_instruction(
45 &self,
46 instruction: &solana_instruction::Instruction,
47 ) -> Option<carbon_core::instruction::DecodedInstruction<Self::InstructionType>> {
48 if !instruction.program_id.eq(&PROGRAM_ID) {
49 return None;
50 }
51
52 let data = instruction.data.as_slice();
53
54 {
55 if let Some(decoded) = register_locker::RegisterLocker::decode(data) {
56 return Some(carbon_core::instruction::DecodedInstruction {
57 program_id: instruction.program_id,
58 data: ProxyRewarderInstruction::RegisterLocker(decoded),
59 accounts: instruction.accounts.clone(),
60 });
61 }
62 }
63 {
64 if let Some(decoded) = update_registered_locker::UpdateRegisteredLocker::decode(data) {
65 return Some(carbon_core::instruction::DecodedInstruction {
66 program_id: instruction.program_id,
67 data: ProxyRewarderInstruction::UpdateRegisteredLocker(decoded),
68 accounts: instruction.accounts.clone(),
69 });
70 }
71 }
72 {
73 if let Some(decoded) = new_proxy_escrow::NewProxyEscrow::decode(data) {
74 return Some(carbon_core::instruction::DecodedInstruction {
75 program_id: instruction.program_id,
76 data: ProxyRewarderInstruction::NewProxyEscrow(decoded),
77 accounts: instruction.accounts.clone(),
78 });
79 }
80 }
81 {
82 if let Some(decoded) = new_proxy::NewProxy::decode(data) {
83 return Some(carbon_core::instruction::DecodedInstruction {
84 program_id: instruction.program_id,
85 data: ProxyRewarderInstruction::NewProxy(decoded),
86 accounts: instruction.accounts.clone(),
87 });
88 }
89 }
90 {
91 if let Some(decoded) = proxy_lock::ProxyLock::decode(data) {
92 return Some(carbon_core::instruction::DecodedInstruction {
93 program_id: instruction.program_id,
94 data: ProxyRewarderInstruction::ProxyLock(decoded),
95 accounts: instruction.accounts.clone(),
96 });
97 }
98 }
99 {
100 if let Some(decoded) = proxy_exit::ProxyExit::decode(data) {
101 return Some(carbon_core::instruction::DecodedInstruction {
102 program_id: instruction.program_id,
103 data: ProxyRewarderInstruction::ProxyExit(decoded),
104 accounts: instruction.accounts.clone(),
105 });
106 }
107 }
108 {
109 if let Some(decoded) = claim_rewards::ClaimRewards::decode(data) {
110 return Some(carbon_core::instruction::DecodedInstruction {
111 program_id: instruction.program_id,
112 data: ProxyRewarderInstruction::ClaimRewards(decoded),
113 accounts: instruction.accounts.clone(),
114 });
115 }
116 }
117 {
118 if let Some(decoded) = cpi_event::CpiEvent::decode(data) {
119 return Some(carbon_core::instruction::DecodedInstruction {
120 program_id: instruction.program_id,
121 data: ProxyRewarderInstruction::CpiEvent(decoded),
122 accounts: instruction.accounts.clone(),
123 });
124 }
125 }
126
127 None
128 }
129}