#![allow(
clippy::all,
clippy::pedantic,
clippy::nursery,
clippy::expect_used,
clippy::unwrap_used,
clippy::indexing_slicing,
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
clippy::mem_forget,
unfulfilled_lint_expectations,
unexpected_cfgs,
unused_imports
)]
use crate::launchpad::generated::events::ANCHOR_EVENT_CPI_DISCRIMINATOR;
use borsh::BorshDeserialize;
use borsh::BorshSerialize;
use solana_address::Address;
#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
pub struct RecycleEvent {
#[cfg_attr(
feature = "serde",
serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
)]
pub bonding_curve: Address,
#[cfg_attr(
feature = "serde",
serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
)]
pub base_mint: Address,
#[cfg_attr(
feature = "serde",
serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
)]
pub quote_mint: Address,
#[cfg_attr(
feature = "serde",
serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
)]
pub platform_config: Address,
#[cfg_attr(
feature = "serde",
serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
)]
pub quote_recycled: u64,
#[cfg_attr(
feature = "serde",
serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
)]
pub rent_recycled: u64,
#[cfg_attr(
feature = "serde",
serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
)]
pub timestamp: i64,
}
pub const RECYCLE_EVENT_DISCRIMINATOR: [u8; 8] =
[63, 115, 223, 82, 233, 208, 57, 35];
impl RecycleEvent {
#[inline(always)]
pub fn matches(program_id: &solana_address::Address, data: &[u8]) -> bool {
program_id == &crate::launchpad::generated::SEND_LAUNCHPAD_ID
&& data.get(..ANCHOR_EVENT_CPI_DISCRIMINATOR.len())
== Some(&ANCHOR_EVENT_CPI_DISCRIMINATOR[..])
&& data.get(8..16) == Some(&RECYCLE_EVENT_DISCRIMINATOR[..])
}
#[inline(always)]
pub fn try_parse(
program_id: &solana_address::Address,
data: &[u8],
) -> Option<Result<Self, std::io::Error>> {
if !Self::matches(program_id, data) {
return None;
}
let mut data = &data[16..];
Some(Self::deserialize(&mut data))
}
}