spherenet_program_whitelist_interface/state/
whitelist.rs1use {
2 super::{account_state::AccountState, Initializable, PodCOption},
3 bytemuck::{Pod, Zeroable},
4 pinocchio::pubkey::Pubkey,
5 shank::ShankAccount,
6};
7
8#[repr(C)]
9#[derive(ShankAccount, Copy, Clone, Pod, Zeroable)]
10pub struct WhitelistAccount {
11 pub authority: Pubkey,
12 pub pending_authority: PodCOption<Pubkey>,
13 pub state: u8,
14}
15
16impl WhitelistAccount {
17 #[inline(always)]
18 pub fn set_pending_authority(&mut self, new_pending_authority: &Pubkey) {
19 self.pending_authority = PodCOption::some(*new_pending_authority);
20 }
21
22 #[inline(always)]
23 pub fn clear_pending_authority(&mut self) {
24 self.pending_authority = PodCOption::none();
25 }
26
27 #[inline(always)]
28 pub fn pending_authority(&self) -> Option<&Pubkey> {
29 if self.pending_authority.is_some() {
30 Some(&self.pending_authority.value)
31 } else {
32 None
33 }
34 }
35
36 #[inline(always)]
37 pub fn set_initialized(&mut self) {
38 self.state = AccountState::Initialized as u8;
39 }
40}
41
42impl Initializable for WhitelistAccount {
43 #[inline(always)]
44 fn is_initialized(&self) -> bool {
45 self.state != AccountState::Uninitialized as u8
46 }
47}