1use anchor_lang::prelude::*;
2
3#[account]
4pub struct RoleRegistry {
5 pub bump: u8,
6 pub config: Pubkey,
7 pub master_authority: Pubkey,
8 pub pauser: Pubkey,
9 pub blacklister: Pubkey,
11 pub seizer: Pubkey,
12}
13
14impl RoleRegistry {
15 pub const SEED_PREFIX: &'static [u8] = b"roles";
16
17 pub const SPACE: usize = 8 + 1 + 32 + 32 + 32 + 32 + 32;
19
20 pub fn has_role(&self, authority: &Pubkey, role: Role) -> bool {
21 match role {
22 Role::MasterAuthority => self.master_authority == *authority,
23 Role::Pauser => self.pauser == *authority || self.master_authority == *authority,
24 Role::Blacklister => {
25 self.blacklister == *authority || self.master_authority == *authority
26 }
27 Role::Seizer => self.seizer == *authority || self.master_authority == *authority,
28 }
29 }
30}
31
32#[derive(AnchorSerialize, AnchorDeserialize, Clone, Copy, PartialEq, Eq, Debug)]
33pub enum Role {
34 MasterAuthority,
35 Pauser,
36 Blacklister,
37 Seizer,
38}