switchboard_solana/oracle_program/accounts/
lease.rs1use crate::prelude::*;
2
3#[account(zero_copy(unsafe))]
4#[repr(packed)]
5pub struct LeaseAccountData {
6 pub escrow: Pubkey, pub queue: Pubkey,
10 pub aggregator: Pubkey,
12 pub token_program: Pubkey,
14 pub is_active: bool,
16 pub crank_row_count: u32,
18 pub created_at: i64,
20 pub update_count: u128,
22 pub withdraw_authority: Pubkey,
24 pub bump: u8,
26 pub _ebuf: [u8; 255],
28}
29impl Default for LeaseAccountData {
30 fn default() -> Self {
31 unsafe { std::mem::zeroed() }
32 }
33}
34
35impl LeaseAccountData {
36 pub fn size() -> usize {
37 8 + std::mem::size_of::<LeaseAccountData>()
38 }
39}
40
41impl TryInto<LeaseAccountData> for Option<Vec<u8>> {
42 type Error = SwitchboardError;
43
44 fn try_into(self) -> std::result::Result<LeaseAccountData, Self::Error> {
45 if let Some(data) = self {
46 bytemuck::try_from_bytes(&data)
47 .map(|&x| x)
48 .map_err(|_| SwitchboardError::AccountDeserializationError)
49 } else {
50 Err(SwitchboardError::AccountDeserializationError)
51 }
52 }
53}