odra_modules/cep18/
utils.rs

1/// Security badge that can be assigned to an account to grant it certain permissions.
2#[odra::odra_type]
3pub enum SecurityBadge {
4    /// The account is an admin.
5    Admin = 0,
6    /// The account is a minter.
7    Minter = 1,
8    /// The account has no special permissions.
9    None = 2
10}
11
12impl SecurityBadge {
13    /// Returns true if the account has admin permissions.
14    pub fn can_admin(&self) -> bool {
15        matches!(self, SecurityBadge::Admin)
16    }
17
18    /// Returns true if the account has minter or admin permissions.
19    pub fn can_mint(&self) -> bool {
20        matches!(self, SecurityBadge::Minter | SecurityBadge::Admin)
21    }
22}
23/// Modality of the CEP-18 contract.
24#[derive(Default)]
25#[odra::odra_type]
26pub enum Cep18Modality {
27    /// No modailities are set.
28    #[default]
29    None = 0,
30    /// The contract can mint and burn tokens.
31    MintAndBurn = 1
32}
33
34impl Cep18Modality {
35    /// Returns true if the mint and burn functionality is enabled.
36    pub fn mint_and_burn_enabled(&self) -> bool {
37        matches!(self, Cep18Modality::MintAndBurn)
38    }
39}
40
41// implement conversion from modality into u8
42impl From<Cep18Modality> for u8 {
43    fn from(modality: Cep18Modality) -> u8 {
44        modality as u8
45    }
46}