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