1use anchor_lang::prelude::*;
2use std::borrow::Borrow;
3
4pub const MAX_ROLE_NAME_LEN: usize = 32;
6
7#[derive(Clone, AnchorSerialize, AnchorDeserialize, InitSpace, PartialEq, Eq, PartialOrd, Ord)]
9#[cfg_attr(feature = "debug", derive(Debug))]
10pub struct RoleKey {
11 #[max_len(MAX_ROLE_NAME_LEN)]
12 name: String,
13}
14
15impl RoleKey {
16 pub const ORACLE_CONTROLLER: &'static str = "ORACLE_CONTROLLER";
18
19 pub const GT_CONTROLLER: &'static str = "GT_CONTROLLER";
21
22 pub const MARKET_KEEPER: &'static str = "MARKET_KEEPER";
24
25 pub const ORDER_KEEPER: &'static str = "ORDER_KEEPER";
27
28 pub const FEATURE_KEEPER: &'static str = "FEATURE_KEEPER";
30
31 pub const CONFIG_KEEPER: &'static str = "CONFIG_KEEPER";
33
34 pub const RESTART_ADMIN: &'static str = "RESTART_ADMIN";
37
38 pub const PRICE_KEEPER: &'static str = "PRICE_KEEPER";
40
41 pub const MIGRATION_KEEPER: &'static str = "MIGRATION_KEEPER";
43}
44
45impl Borrow<str> for RoleKey {
46 fn borrow(&self) -> &str {
47 &self.name
48 }
49}
50
51impl<'a> From<&'a str> for RoleKey {
52 fn from(value: &'a str) -> Self {
53 Self {
54 name: value.to_owned(),
55 }
56 }
57}