satrush_client/generated/accounts/
public_deployment.rs1use solana_address::Address;
9use borsh::BorshSerialize;
10use borsh::BorshDeserialize;
11
12
13#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
14pub struct PublicDeployment {
15pub discriminator: [u8; 8],
16pub version: u16,
18pub bump: u8,
20pub authority: Address,
22pub round_id: u32,
24pub deployed_usd_amount: u64,
26pub total_stake_usd_amount: u64,
28pub selection_mask: u32,
30pub streak_multiplier: u32,
34pub automation: Option<Address>,
37pub reserved: [u8; 32],
39}
40
41
42pub const PUBLIC_DEPLOYMENT_DISCRIMINATOR: [u8; 8] = [209, 64, 180, 169, 40, 181, 110, 236];
43
44impl PublicDeployment {
45
46
47
48 #[inline(always)]
49 pub fn from_bytes(data: &[u8]) -> Result<Self, std::io::Error> {
50 let mut data = data;
51 Self::deserialize(&mut data)
52 }
53}
54
55impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for PublicDeployment {
56 type Error = std::io::Error;
57
58 fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result<Self, Self::Error> {
59 let mut data: &[u8] = &(*account_info.data).borrow();
60 Self::deserialize(&mut data)
61 }
62}
63
64#[cfg(feature = "fetch")]
65pub fn fetch_public_deployment(
66 rpc: &solana_rpc_client::rpc_client::RpcClient,
67 address: &solana_address::Address,
68) -> Result<crate::shared::DecodedAccount<PublicDeployment>, std::io::Error> {
69 let accounts = fetch_all_public_deployment(rpc, &[*address])?;
70 Ok(accounts[0].clone())
71}
72
73#[cfg(feature = "fetch")]
74pub fn fetch_all_public_deployment(
75 rpc: &solana_rpc_client::rpc_client::RpcClient,
76 addresses: &[solana_address::Address],
77) -> Result<Vec<crate::shared::DecodedAccount<PublicDeployment>>, std::io::Error> {
78 let accounts = rpc.get_multiple_accounts(addresses)
79 .map_err(|e| std::io::Error::other(e.to_string()))?;
80 let mut decoded_accounts: Vec<crate::shared::DecodedAccount<PublicDeployment>> = Vec::new();
81 for i in 0..addresses.len() {
82 let address = addresses[i];
83 let account = accounts[i].as_ref()
84 .ok_or(std::io::Error::other(format!("Account not found: {address}")))?;
85 let data = PublicDeployment::from_bytes(&account.data)?;
86 decoded_accounts.push(crate::shared::DecodedAccount { address, account: account.clone(), data });
87 }
88 Ok(decoded_accounts)
89}
90
91#[cfg(feature = "fetch")]
92pub fn fetch_maybe_public_deployment(
93 rpc: &solana_rpc_client::rpc_client::RpcClient,
94 address: &solana_address::Address,
95) -> Result<crate::shared::MaybeAccount<PublicDeployment>, std::io::Error> {
96 let accounts = fetch_all_maybe_public_deployment(rpc, &[*address])?;
97 Ok(accounts[0].clone())
98}
99
100#[cfg(feature = "fetch")]
101pub fn fetch_all_maybe_public_deployment(
102 rpc: &solana_rpc_client::rpc_client::RpcClient,
103 addresses: &[solana_address::Address],
104) -> Result<Vec<crate::shared::MaybeAccount<PublicDeployment>>, std::io::Error> {
105 let accounts = rpc.get_multiple_accounts(addresses)
106 .map_err(|e| std::io::Error::other(e.to_string()))?;
107 let mut decoded_accounts: Vec<crate::shared::MaybeAccount<PublicDeployment>> = Vec::new();
108 for i in 0..addresses.len() {
109 let address = addresses[i];
110 if let Some(account) = accounts[i].as_ref() {
111 let data = PublicDeployment::from_bytes(&account.data)?;
112 decoded_accounts.push(crate::shared::MaybeAccount::Exists(crate::shared::DecodedAccount { address, account: account.clone(), data }));
113 } else {
114 decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address));
115 }
116 }
117 Ok(decoded_accounts)
118}
119
120 #[cfg(feature = "anchor")]
121 impl anchor_lang::AccountDeserialize for PublicDeployment {
122 fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result<Self> {
123 Ok(Self::deserialize(buf)?)
124 }
125 }
126
127 #[cfg(feature = "anchor")]
128 impl anchor_lang::AccountSerialize for PublicDeployment {}
129
130 #[cfg(feature = "anchor")]
131 impl anchor_lang::Owner for PublicDeployment {
132 fn owner() -> anchor_lang::solana_program::pubkey::Pubkey {
133 anchor_lang::solana_program::pubkey::Pubkey::from(
134 crate::SATRUSH_ID.to_bytes()
135 )
136 }
137 }
138
139 #[cfg(feature = "anchor-idl-build")]
140 impl anchor_lang::IdlBuild for PublicDeployment {}
141
142
143 #[cfg(feature = "anchor-idl-build")]
144 impl anchor_lang::Discriminator for PublicDeployment {
145 const DISCRIMINATOR: &[u8] = &[0; 8];
146 }
147