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 }
16
17impl EscrowAccountInfoValidation for AccountInfo<'_> {
18 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 }