spherenet-program-whitelist-interface 0.2.0

Interface of SphereNet's Program Whitelist Program
Documentation
use {
    super::{AccountState, Initializable},
    bytemuck::{Pod, Zeroable},
    pinocchio::pubkey::Pubkey,
    shank::ShankAccount,
};

/// Offset of the entry_address field in the account data
pub const ENTRY_ADDRESS_OFFSET: usize = 0;
/// Offset of the state field in the account data
pub const STATE_OFFSET: usize = 32;

#[repr(C)]
#[derive(Copy, Clone, Pod, Zeroable, ShankAccount)]
pub struct ProgramWhitelistEntry {
    pub entry_address: Pubkey,
    pub state: u8,
}

impl ProgramWhitelistEntry {
    #[inline(always)]
    pub fn set_initialized(&mut self) {
        self.state = AccountState::Initialized as u8;
    }
}

impl Initializable for ProgramWhitelistEntry {
    #[inline(always)]
    fn is_initialized(&self) -> bool {
        self.state != AccountState::Uninitialized as u8
    }
}