tensor_amm/generated/accounts/
nft_deposit_receipt.rs1use borsh::BorshDeserialize;
9use borsh::BorshSerialize;
10use solana_program::pubkey::Pubkey;
11
12#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
16#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
17pub struct NftDepositReceipt {
18 pub discriminator: [u8; 8],
19 pub bump: u8,
20 #[cfg_attr(
21 feature = "serde",
22 serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
23 )]
24 pub mint: Pubkey,
25 #[cfg_attr(
26 feature = "serde",
27 serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
28 )]
29 pub pool: Pubkey,
30}
31
32impl NftDepositReceipt {
33 pub const LEN: usize = 73;
34
35 pub const PREFIX: &'static [u8] = "nft_receipt".as_bytes();
43
44 pub fn create_pda(
45 mint: Pubkey,
46 pool: Pubkey,
47 bump: u8,
48 ) -> Result<solana_program::pubkey::Pubkey, solana_program::pubkey::PubkeyError> {
49 solana_program::pubkey::Pubkey::create_program_address(
50 &[
51 "nft_receipt".as_bytes(),
52 mint.as_ref(),
53 pool.as_ref(),
54 &[bump],
55 ],
56 &crate::TENSOR_AMM_ID,
57 )
58 }
59
60 pub fn find_pda(mint: &Pubkey, pool: &Pubkey) -> (solana_program::pubkey::Pubkey, u8) {
61 solana_program::pubkey::Pubkey::find_program_address(
62 &["nft_receipt".as_bytes(), mint.as_ref(), pool.as_ref()],
63 &crate::TENSOR_AMM_ID,
64 )
65 }
66
67 #[inline(always)]
68 pub fn from_bytes(data: &[u8]) -> Result<Self, std::io::Error> {
69 let mut data = data;
70 Self::deserialize(&mut data)
71 }
72}
73
74impl<'a> TryFrom<&solana_program::account_info::AccountInfo<'a>> for NftDepositReceipt {
75 type Error = std::io::Error;
76
77 fn try_from(
78 account_info: &solana_program::account_info::AccountInfo<'a>,
79 ) -> Result<Self, Self::Error> {
80 let mut data: &[u8] = &(*account_info.data).borrow();
81 Self::deserialize(&mut data)
82 }
83}
84
85#[cfg(feature = "anchor")]
86impl anchor_lang::AccountDeserialize for NftDepositReceipt {
87 fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result<Self> {
88 Ok(Self::deserialize(buf)?)
89 }
90}
91
92#[cfg(feature = "anchor")]
93impl anchor_lang::AccountSerialize for NftDepositReceipt {}
94
95#[cfg(feature = "anchor")]
96impl anchor_lang::Owner for NftDepositReceipt {
97 fn owner() -> Pubkey {
98 crate::TENSOR_AMM_ID
99 }
100}
101
102#[cfg(feature = "anchor-idl-build")]
103impl anchor_lang::IdlBuild for NftDepositReceipt {}
104
105#[cfg(feature = "anchor-idl-build")]
106impl anchor_lang::Discriminator for NftDepositReceipt {
107 const DISCRIMINATOR: [u8; 8] = [0; 8];
108}