escrow_api/
loaders.rs

1use steel::*;
2
3use crate::{
4    consts::*,
5    state::{Bank, Config, Escrow, Payment},
6};
7
8pub trait EscrowAccountInfoValidation {
9    fn is_bank(&self) -> Result<&Self, ProgramError>;
10    fn is_config(&self) -> Result<&Self, ProgramError>;
11    fn is_escrow(&self) -> Result<&Self, ProgramError>;
12    fn is_payment(&self) -> Result<&Self, ProgramError>;
13    // fn is_treasury(&self) -> Result<&Self, ProgramError>;
14    // fn is_treasury_tokens(&self) -> Result<&Self, ProgramError>;
15}
16
17impl EscrowAccountInfoValidation for AccountInfo<'_> {
18    // fn is_config(&self) -> Result<&Self, ProgramError> {
19    //     self.is_type::<Config>(&crate::ID)
20    // }
21
22    fn is_config(&self) -> Result<&Self, ProgramError> {
23        self.has_address(&CONFIG_ADDRESS)?
24            .is_type::<Config>(&crate::ID)
25    }
26
27    fn is_bank(&self) -> Result<&Self, ProgramError> {
28        self.has_address(&BANK_ADDRESS)?.is_type::<Bank>(&crate::ID)
29    }
30
31    fn is_escrow(&self) -> Result<&Self, ProgramError> {
32        self.is_type::<Escrow>(&crate::ID)
33    }
34
35    fn is_payment(&self) -> Result<&Self, ProgramError> {
36        self.is_type::<Payment>(&crate::ID)
37    }
38
39    // fn is_treasury_tokens(&self) -> Result<&Self, ProgramError> {
40    //     self.has_address(&TREASURY_TOKENS_ADDRESS)
41    // }
42}