ore_api/
loaders.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use steel::*;

use crate::{
    consts::*,
    state::{Config, Treasury},
};

pub trait OreAccountInfoValidation {
    fn is_config(&self) -> Result<&Self, ProgramError>;
    fn is_treasury(&self) -> Result<&Self, ProgramError>;
    fn is_treasury_tokens(&self) -> Result<&Self, ProgramError>;
}

impl OreAccountInfoValidation for AccountInfo<'_> {
    fn is_config(&self) -> Result<&Self, ProgramError> {
        self.has_address(&CONFIG_ADDRESS)?
            .is_type::<Config>(&crate::ID)
    }

    fn is_treasury(&self) -> Result<&Self, ProgramError> {
        self.has_address(&TREASURY_ADDRESS)?
            .is_type::<Treasury>(&crate::ID)
    }

    fn is_treasury_tokens(&self) -> Result<&Self, ProgramError> {
        self.has_address(&TREASURY_TOKENS_ADDRESS)
    }
}