token_acl_client/generated/accounts/
mint_config.rs1use borsh::BorshDeserialize;
9use borsh::BorshSerialize;
10use solana_pubkey::Pubkey;
11
12#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
13#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
14pub struct MintConfig {
15 pub discriminator: u8,
16 pub bump: u8,
17 pub enable_permissionless_thaw: bool,
18 pub enable_permissionless_freeze: bool,
19 #[cfg_attr(
20 feature = "serde",
21 serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
22 )]
23 pub mint: Pubkey,
24 #[cfg_attr(
25 feature = "serde",
26 serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
27 )]
28 pub freeze_authority: Pubkey,
29 #[cfg_attr(
30 feature = "serde",
31 serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
32 )]
33 pub gating_program: Pubkey,
34}
35
36pub const MINT_CONFIG_DISCRIMINATOR: u8 = 1;
37
38impl MintConfig {
39 pub const LEN: usize = 0;
40
41 pub const PREFIX: &'static [u8] = "MINT_CONFIG".as_bytes();
48
49 pub fn create_pda(
50 mint: Pubkey,
51 bump: u8,
52 ) -> Result<solana_pubkey::Pubkey, solana_pubkey::PubkeyError> {
53 solana_pubkey::Pubkey::create_program_address(
54 &["MINT_CONFIG".as_bytes(), mint.as_ref(), &[bump]],
55 &crate::TOKEN_ACL_ID,
56 )
57 }
58
59 pub fn find_pda(mint: &Pubkey) -> (solana_pubkey::Pubkey, u8) {
60 solana_pubkey::Pubkey::find_program_address(
61 &["MINT_CONFIG".as_bytes(), mint.as_ref()],
62 &crate::TOKEN_ACL_ID,
63 )
64 }
65
66 #[inline(always)]
67 pub fn from_bytes(data: &[u8]) -> Result<Self, std::io::Error> {
68 let mut data = data;
69 Self::deserialize(&mut data)
70 }
71}
72
73impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for MintConfig {
74 type Error = std::io::Error;
75
76 fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result<Self, Self::Error> {
77 let mut data: &[u8] = &(*account_info.data).borrow();
78 Self::deserialize(&mut data)
79 }
80}
81
82#[cfg(feature = "fetch")]
83pub fn fetch_mint_config(
84 rpc: &solana_client::rpc_client::RpcClient,
85 address: &solana_pubkey::Pubkey,
86) -> Result<crate::shared::DecodedAccount<MintConfig>, std::io::Error> {
87 let accounts = fetch_all_mint_config(rpc, &[*address])?;
88 Ok(accounts[0].clone())
89}
90
91#[cfg(feature = "fetch")]
92pub fn fetch_all_mint_config(
93 rpc: &solana_client::rpc_client::RpcClient,
94 addresses: &[solana_pubkey::Pubkey],
95) -> Result<Vec<crate::shared::DecodedAccount<MintConfig>>, std::io::Error> {
96 let accounts = rpc
97 .get_multiple_accounts(addresses)
98 .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?;
99 let mut decoded_accounts: Vec<crate::shared::DecodedAccount<MintConfig>> = Vec::new();
100 for i in 0..addresses.len() {
101 let address = addresses[i];
102 let account = accounts[i].as_ref().ok_or(std::io::Error::new(
103 std::io::ErrorKind::Other,
104 format!("Account not found: {}", address),
105 ))?;
106 let data = MintConfig::from_bytes(&account.data)?;
107 decoded_accounts.push(crate::shared::DecodedAccount {
108 address,
109 account: account.clone(),
110 data,
111 });
112 }
113 Ok(decoded_accounts)
114}
115
116#[cfg(feature = "fetch")]
117pub fn fetch_maybe_mint_config(
118 rpc: &solana_client::rpc_client::RpcClient,
119 address: &solana_pubkey::Pubkey,
120) -> Result<crate::shared::MaybeAccount<MintConfig>, std::io::Error> {
121 let accounts = fetch_all_maybe_mint_config(rpc, &[*address])?;
122 Ok(accounts[0].clone())
123}
124
125#[cfg(feature = "fetch")]
126pub fn fetch_all_maybe_mint_config(
127 rpc: &solana_client::rpc_client::RpcClient,
128 addresses: &[solana_pubkey::Pubkey],
129) -> Result<Vec<crate::shared::MaybeAccount<MintConfig>>, std::io::Error> {
130 let accounts = rpc
131 .get_multiple_accounts(addresses)
132 .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?;
133 let mut decoded_accounts: Vec<crate::shared::MaybeAccount<MintConfig>> = Vec::new();
134 for i in 0..addresses.len() {
135 let address = addresses[i];
136 if let Some(account) = accounts[i].as_ref() {
137 let data = MintConfig::from_bytes(&account.data)?;
138 decoded_accounts.push(crate::shared::MaybeAccount::Exists(
139 crate::shared::DecodedAccount {
140 address,
141 account: account.clone(),
142 data,
143 },
144 ));
145 } else {
146 decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address));
147 }
148 }
149 Ok(decoded_accounts)
150}
151
152#[cfg(feature = "anchor")]
153impl anchor_lang::AccountDeserialize for MintConfig {
154 fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result<Self> {
155 Ok(Self::deserialize(buf)?)
156 }
157}
158
159#[cfg(feature = "anchor")]
160impl anchor_lang::AccountSerialize for MintConfig {}
161
162#[cfg(feature = "anchor")]
163impl anchor_lang::Owner for MintConfig {
164 fn owner() -> Pubkey {
165 crate::TOKEN_ACL_ID
166 }
167}
168
169#[cfg(feature = "anchor-idl-build")]
170impl anchor_lang::IdlBuild for MintConfig {}
171
172#[cfg(feature = "anchor-idl-build")]
173impl anchor_lang::Discriminator for MintConfig {
174 const DISCRIMINATOR: &[u8] = &[0; 8];
175}