Skip to main content

satrush_client/generated/accounts/
board.rs

1//! This code was AUTOGENERATED using the codama library.
2//! Please DO NOT EDIT THIS FILE, instead use visitors
3//! to add features, then rerun codama to update it.
4//!
5//! <https://github.com/codama-idl/codama>
6//!
7
8use borsh::BorshSerialize;
9use borsh::BorshDeserialize;
10
11
12#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
13pub struct Board {
14pub discriminator: [u8; 8],
15/// Struct version.
16pub version: u16,
17/// PDA bump seed.
18pub bump: u8,
19/// Current active round id.
20pub round_id: u32,
21/// Round duration in slots.
22pub round_duration: u32,
23/// The slot at which the current round starts mining.
24pub start_slot: u64,
25/// The slot at which the current round ends mining.
26pub end_slot: u64,
27/// Strike jackpot USD amount waiting to be swapped.
28/// Swaps are executed in the background when pending
29/// amount reaches the certain threshold.
30pub strike_pending_usd_amount: u64,
31/// Strike jackpot USD amount after the swap
32pub strike_usd_amount: u64,
33/// Strike jackpot BTC amount after the swap
34pub strike_btc_amount: u64,
35/// Last round_id when Strike jackpot was triggered
36pub strike_last_trigger_round_id: u32,
37/// Reserved
38pub reserved: [u8; 30],
39}
40
41
42pub const BOARD_DISCRIMINATOR: [u8; 8] = [79, 48, 160, 63, 153, 132, 240, 56];
43
44impl Board {
45      pub const LEN: usize = 93;
46  
47  
48  
49  #[inline(always)]
50  pub fn from_bytes(data: &[u8]) -> Result<Self, std::io::Error> {
51    let mut data = data;
52    Self::deserialize(&mut data)
53  }
54}
55
56impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for Board {
57  type Error = std::io::Error;
58
59  fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result<Self, Self::Error> {
60      let mut data: &[u8] = &(*account_info.data).borrow();
61      Self::deserialize(&mut data)
62  }
63}
64
65#[cfg(feature = "fetch")]
66pub fn fetch_board(
67  rpc: &solana_rpc_client::rpc_client::RpcClient,
68  address: &solana_address::Address,
69) -> Result<crate::shared::DecodedAccount<Board>, std::io::Error> {
70  let accounts = fetch_all_board(rpc, &[*address])?;
71  Ok(accounts[0].clone())
72}
73
74#[cfg(feature = "fetch")]
75pub fn fetch_all_board(
76  rpc: &solana_rpc_client::rpc_client::RpcClient,
77  addresses: &[solana_address::Address],
78) -> Result<Vec<crate::shared::DecodedAccount<Board>>, std::io::Error> {
79    let accounts = rpc.get_multiple_accounts(addresses)
80      .map_err(|e| std::io::Error::other(e.to_string()))?;
81    let mut decoded_accounts: Vec<crate::shared::DecodedAccount<Board>> = Vec::new();
82    for i in 0..addresses.len() {
83      let address = addresses[i];
84      let account = accounts[i].as_ref()
85        .ok_or(std::io::Error::other(format!("Account not found: {address}")))?;
86      let data = Board::from_bytes(&account.data)?;
87      decoded_accounts.push(crate::shared::DecodedAccount { address, account: account.clone(), data });
88    }
89    Ok(decoded_accounts)
90}
91
92#[cfg(feature = "fetch")]
93pub fn fetch_maybe_board(
94  rpc: &solana_rpc_client::rpc_client::RpcClient,
95  address: &solana_address::Address,
96) -> Result<crate::shared::MaybeAccount<Board>, std::io::Error> {
97    let accounts = fetch_all_maybe_board(rpc, &[*address])?;
98    Ok(accounts[0].clone())
99}
100
101#[cfg(feature = "fetch")]
102pub fn fetch_all_maybe_board(
103  rpc: &solana_rpc_client::rpc_client::RpcClient,
104  addresses: &[solana_address::Address],
105) -> Result<Vec<crate::shared::MaybeAccount<Board>>, std::io::Error> {
106    let accounts = rpc.get_multiple_accounts(addresses)
107      .map_err(|e| std::io::Error::other(e.to_string()))?;
108    let mut decoded_accounts: Vec<crate::shared::MaybeAccount<Board>> = Vec::new();
109    for i in 0..addresses.len() {
110      let address = addresses[i];
111      if let Some(account) = accounts[i].as_ref() {
112        let data = Board::from_bytes(&account.data)?;
113        decoded_accounts.push(crate::shared::MaybeAccount::Exists(crate::shared::DecodedAccount { address, account: account.clone(), data }));
114      } else {
115        decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address));
116      }
117    }
118  Ok(decoded_accounts)
119}
120
121  #[cfg(feature = "anchor")]
122  impl anchor_lang::AccountDeserialize for Board {
123      fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result<Self> {
124        Ok(Self::deserialize(buf)?)
125      }
126  }
127
128  #[cfg(feature = "anchor")]
129  impl anchor_lang::AccountSerialize for Board {}
130
131  #[cfg(feature = "anchor")]
132  impl anchor_lang::Owner for Board {
133      fn owner() -> anchor_lang::solana_program::pubkey::Pubkey {
134        anchor_lang::solana_program::pubkey::Pubkey::from(
135          crate::SATRUSH_ID.to_bytes()
136        )
137      }
138  }
139
140  #[cfg(feature = "anchor-idl-build")]
141  impl anchor_lang::IdlBuild for Board {}
142
143  
144  #[cfg(feature = "anchor-idl-build")]
145  impl anchor_lang::Discriminator for Board {
146    const DISCRIMINATOR: &[u8] = &[0; 8];
147  }
148