release_test_client/generated/accounts/
program_whitelist_account.rs1use borsh::BorshDeserialize;
9use borsh::BorshSerialize;
10use solana_program::pubkey::Pubkey;
11
12#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
13#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
14pub struct ProgramWhitelistAccount {
15 #[cfg_attr(
16 feature = "serde",
17 serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
18 )]
19 pub authority: Pubkey,
20 #[cfg_attr(
21 feature = "serde",
22 serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
23 )]
24 pub pending_authority: Pubkey,
25 pub state: u8,
26}
27
28impl ProgramWhitelistAccount {
29 pub const LEN: usize = 65;
30
31 #[inline(always)]
32 pub fn from_bytes(data: &[u8]) -> Result<Self, std::io::Error> {
33 let mut data = data;
34 Self::deserialize(&mut data)
35 }
36}
37
38impl<'a> TryFrom<&solana_program::account_info::AccountInfo<'a>> for ProgramWhitelistAccount {
39 type Error = std::io::Error;
40
41 fn try_from(
42 account_info: &solana_program::account_info::AccountInfo<'a>,
43 ) -> Result<Self, Self::Error> {
44 let mut data: &[u8] = &(*account_info.data).borrow();
45 Self::deserialize(&mut data)
46 }
47}
48
49#[cfg(feature = "fetch")]
50pub fn fetch_program_whitelist_account(
51 rpc: &solana_client::rpc_client::RpcClient,
52 address: &Pubkey,
53) -> Result<crate::shared::DecodedAccount<ProgramWhitelistAccount>, std::io::Error> {
54 let accounts = fetch_all_program_whitelist_account(rpc, &[*address])?;
55 Ok(accounts[0].clone())
56}
57
58#[cfg(feature = "fetch")]
59pub fn fetch_all_program_whitelist_account(
60 rpc: &solana_client::rpc_client::RpcClient,
61 addresses: &[Pubkey],
62) -> Result<Vec<crate::shared::DecodedAccount<ProgramWhitelistAccount>>, std::io::Error> {
63 let accounts = rpc
64 .get_multiple_accounts(&addresses)
65 .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?;
66 let mut decoded_accounts: Vec<crate::shared::DecodedAccount<ProgramWhitelistAccount>> =
67 Vec::new();
68 for i in 0..addresses.len() {
69 let address = addresses[i];
70 let account = accounts[i].as_ref().ok_or(std::io::Error::new(
71 std::io::ErrorKind::Other,
72 format!("Account not found: {}", address),
73 ))?;
74 let data = ProgramWhitelistAccount::from_bytes(&account.data)?;
75 decoded_accounts.push(crate::shared::DecodedAccount {
76 address,
77 account: account.clone(),
78 data,
79 });
80 }
81 Ok(decoded_accounts)
82}
83
84#[cfg(feature = "fetch")]
85pub fn fetch_maybe_program_whitelist_account(
86 rpc: &solana_client::rpc_client::RpcClient,
87 address: &Pubkey,
88) -> Result<crate::shared::MaybeAccount<ProgramWhitelistAccount>, std::io::Error> {
89 let accounts = fetch_all_maybe_program_whitelist_account(rpc, &[*address])?;
90 Ok(accounts[0].clone())
91}
92
93#[cfg(feature = "fetch")]
94pub fn fetch_all_maybe_program_whitelist_account(
95 rpc: &solana_client::rpc_client::RpcClient,
96 addresses: &[Pubkey],
97) -> Result<Vec<crate::shared::MaybeAccount<ProgramWhitelistAccount>>, std::io::Error> {
98 let accounts = rpc
99 .get_multiple_accounts(&addresses)
100 .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?;
101 let mut decoded_accounts: Vec<crate::shared::MaybeAccount<ProgramWhitelistAccount>> =
102 Vec::new();
103 for i in 0..addresses.len() {
104 let address = addresses[i];
105 if let Some(account) = accounts[i].as_ref() {
106 let data = ProgramWhitelistAccount::from_bytes(&account.data)?;
107 decoded_accounts.push(crate::shared::MaybeAccount::Exists(
108 crate::shared::DecodedAccount {
109 address,
110 account: account.clone(),
111 data,
112 },
113 ));
114 } else {
115 decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address));
116 }
117 }
118 Ok(decoded_accounts)
119}
120
121#[cfg(feature = "anchor")]
122impl anchor_lang::AccountDeserialize for ProgramWhitelistAccount {
123 fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result<Self> {
124 Ok(Self::deserialize(buf)?)
125 }
126}
127
128#[cfg(feature = "anchor")]
129impl anchor_lang::AccountSerialize for ProgramWhitelistAccount {}
130
131#[cfg(feature = "anchor")]
132impl anchor_lang::Owner for ProgramWhitelistAccount {
133 fn owner() -> Pubkey {
134 crate::RELEASE_TEST_PROGRAM_ID
135 }
136}
137
138#[cfg(feature = "anchor-idl-build")]
139impl anchor_lang::IdlBuild for ProgramWhitelistAccount {}
140
141#[cfg(feature = "anchor-idl-build")]
142impl anchor_lang::Discriminator for ProgramWhitelistAccount {
143 const DISCRIMINATOR: [u8; 8] = [0; 8];
144}