sendfun_sdk/launchpad/generated/events/
recycle_event.rs1#![allow(
2 clippy::all,
3 clippy::pedantic,
4 clippy::nursery,
5 clippy::expect_used,
6 clippy::unwrap_used,
7 clippy::indexing_slicing,
8 clippy::allow_attributes,
9 clippy::allow_attributes_without_reason,
10 clippy::mem_forget,
11 unfulfilled_lint_expectations,
12 unexpected_cfgs,
13 unused_imports
14)]
15
16use crate::launchpad::generated::events::ANCHOR_EVENT_CPI_DISCRIMINATOR;
24use borsh::BorshDeserialize;
25use borsh::BorshSerialize;
26use solana_address::Address;
27
28#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
29#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
30#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
31pub struct RecycleEvent {
32 #[cfg_attr(
33 feature = "serde",
34 serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
35 )]
36 pub bonding_curve: Address,
37 #[cfg_attr(
38 feature = "serde",
39 serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
40 )]
41 pub base_mint: Address,
42 #[cfg_attr(
43 feature = "serde",
44 serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
45 )]
46 pub quote_mint: Address,
47 #[cfg_attr(
48 feature = "serde",
49 serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
50 )]
51 pub platform_config: Address,
52 #[cfg_attr(
53 feature = "serde",
54 serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
55 )]
56 pub quote_recycled: u64,
57 #[cfg_attr(
58 feature = "serde",
59 serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
60 )]
61 pub rent_recycled: u64,
62 #[cfg_attr(
63 feature = "serde",
64 serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
65 )]
66 pub timestamp: i64,
67}
68
69pub const RECYCLE_EVENT_DISCRIMINATOR: [u8; 8] =
70 [63, 115, 223, 82, 233, 208, 57, 35];
71
72impl RecycleEvent {
73 #[inline(always)]
76 pub fn matches(program_id: &solana_address::Address, data: &[u8]) -> bool {
77 program_id == &crate::launchpad::generated::SEND_LAUNCHPAD_ID
78 && data.get(..ANCHOR_EVENT_CPI_DISCRIMINATOR.len())
79 == Some(&ANCHOR_EVENT_CPI_DISCRIMINATOR[..])
80 && data.get(8..16) == Some(&RECYCLE_EVENT_DISCRIMINATOR[..])
81 }
82
83 #[inline(always)]
86 pub fn try_parse(
87 program_id: &solana_address::Address,
88 data: &[u8],
89 ) -> Option<Result<Self, std::io::Error>> {
90 if !Self::matches(program_id, data) {
91 return None;
92 }
93 let mut data = &data[16..];
95 Some(Self::deserialize(&mut data))
96 }
97}