Skip to main content

sendfun_sdk/launchpad/generated/events/
creator_claim_event.rs

1#![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
16//! This code was AUTOGENERATED using the codama library.
17//! Please DO NOT EDIT THIS FILE, instead use visitors
18//! to add features, then rerun codama to update it.
19//!
20//! <https://github.com/codama-idl/codama>
21//!
22
23use 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 CreatorClaimEvent {
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 coin_creator: Address,
57	pub padding0: [u64; 4],
58	#[cfg_attr(
59		feature = "serde",
60		serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
61	)]
62	pub claimer: Address,
63	#[cfg_attr(
64		feature = "serde",
65		serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
66	)]
67	pub destination_owner: Address,
68	#[cfg_attr(
69		feature = "serde",
70		serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
71	)]
72	pub amount: u64,
73	#[cfg_attr(
74		feature = "serde",
75		serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
76	)]
77	pub quote_transfer_fee: u64,
78	#[cfg_attr(
79		feature = "serde",
80		serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
81	)]
82	pub timestamp: i64,
83}
84
85pub const CREATOR_CLAIM_EVENT_DISCRIMINATOR: [u8; 8] =
86	[232, 58, 157, 141, 123, 5, 142, 9];
87
88impl CreatorClaimEvent {
89	/// Anchor discriminators are derived from names alone, so identical bytes recur across
90	/// programs and the bytes alone cannot tell this event from a foreign one.
91	#[inline(always)]
92	pub fn matches(program_id: &solana_address::Address, data: &[u8]) -> bool {
93		program_id == &crate::launchpad::generated::SEND_LAUNCHPAD_ID
94			&& data.get(..ANCHOR_EVENT_CPI_DISCRIMINATOR.len())
95				== Some(&ANCHOR_EVENT_CPI_DISCRIMINATOR[..])
96			&& data.get(8..16) == Some(&CREATOR_CLAIM_EVENT_DISCRIMINATOR[..])
97	}
98
99	/// `None` when [`Self::matches`] is false; `Some(Err(_))` when it matches but the body fails
100	/// to deserialize. Use [`Option::transpose`] to propagate the failure with `?`.
101	#[inline(always)]
102	pub fn try_parse(
103		program_id: &solana_address::Address,
104		data: &[u8],
105	) -> Option<Result<Self, std::io::Error>> {
106		if !Self::matches(program_id, data) {
107			return None;
108		}
109		// ANCHOR_EVENT_CPI_DISCRIMINATOR (8) + CREATOR_CLAIM_EVENT_DISCRIMINATOR (8)
110		let mut data = &data[16..];
111		Some(Self::deserialize(&mut data))
112	}
113}