use {
super::{account_state::AccountState, Initializable, PodCOption},
bytemuck::{Pod, Zeroable},
pinocchio::pubkey::Pubkey,
shank::ShankAccount,
};
#[repr(C)]
#[derive(ShankAccount, Copy, Clone, Pod, Zeroable)]
pub struct WhitelistAccount {
pub authority: Pubkey,
pub pending_authority: PodCOption<Pubkey>,
pub state: u8,
}
impl WhitelistAccount {
#[inline(always)]
pub fn set_pending_authority(&mut self, new_pending_authority: &Pubkey) {
self.pending_authority = PodCOption::some(*new_pending_authority);
}
#[inline(always)]
pub fn clear_pending_authority(&mut self) {
self.pending_authority = PodCOption::none();
}
#[inline(always)]
pub fn pending_authority(&self) -> Option<&Pubkey> {
if self.pending_authority.is_some() {
Some(&self.pending_authority.value)
} else {
None
}
}
#[inline(always)]
pub fn set_initialized(&mut self) {
self.state = AccountState::Initialized as u8;
}
}
impl Initializable for WhitelistAccount {
#[inline(always)]
fn is_initialized(&self) -> bool {
self.state != AccountState::Uninitialized as u8
}
}