carbon_proxy_rewarder_decoder/accounts/
mod.rs1use crate::PROGRAM_ID;
3use crate::ProxyRewarderDecoder;
4
5pub mod proxy;
6pub mod proxy_escrow;
7pub mod registered_locker;
8pub mod treasury_authority;
9
10#[derive(Debug, Clone, PartialEq)]
11#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
12#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
13pub enum ProxyRewarderAccount {
14 Proxy(Box<proxy::Proxy>),
15 ProxyEscrow(Box<proxy_escrow::ProxyEscrow>),
16 RegisteredLocker(Box<registered_locker::RegisteredLocker>),
17 TreasuryAuthority(Box<treasury_authority::TreasuryAuthority>),
18}
19
20impl<'a> carbon_core::account::AccountDecoder<'a> for ProxyRewarderDecoder {
21 type AccountType = ProxyRewarderAccount;
22
23 fn decode_account(
24 &self,
25 account: &'a solana_account::Account,
26 ) -> Option<carbon_core::account::DecodedAccount<Self::AccountType>> {
27 if account.owner != PROGRAM_ID {
28 return None;
29 }
30
31 let data = account.data.as_slice();
32
33 {
34 if let Some(decoded) = proxy::Proxy::decode(data) {
35 return Some(carbon_core::account::DecodedAccount {
36 lamports: account.lamports,
37 data: ProxyRewarderAccount::Proxy(Box::new(decoded)),
38 owner: account.owner,
39 executable: account.executable,
40 rent_epoch: account.rent_epoch,
41 });
42 }
43 }
44 {
45 if let Some(decoded) = proxy_escrow::ProxyEscrow::decode(data) {
46 return Some(carbon_core::account::DecodedAccount {
47 lamports: account.lamports,
48 data: ProxyRewarderAccount::ProxyEscrow(Box::new(decoded)),
49 owner: account.owner,
50 executable: account.executable,
51 rent_epoch: account.rent_epoch,
52 });
53 }
54 }
55 {
56 if let Some(decoded) = registered_locker::RegisteredLocker::decode(data) {
57 return Some(carbon_core::account::DecodedAccount {
58 lamports: account.lamports,
59 data: ProxyRewarderAccount::RegisteredLocker(Box::new(decoded)),
60 owner: account.owner,
61 executable: account.executable,
62 rent_epoch: account.rent_epoch,
63 });
64 }
65 }
66 {
67 if let Some(decoded) = treasury_authority::TreasuryAuthority::decode(data) {
68 return Some(carbon_core::account::DecodedAccount {
69 lamports: account.lamports,
70 data: ProxyRewarderAccount::TreasuryAuthority(Box::new(decoded)),
71 owner: account.owner,
72 executable: account.executable,
73 rent_epoch: account.rent_epoch,
74 });
75 }
76 }
77
78 None
79 }
80}