use steel::*;
use crate::{
consts::*,
state::{Bank, Config, Escrow, Payment},
};
pub trait EscrowAccountInfoValidation {
fn is_bank(&self) -> Result<&Self, ProgramError>;
fn is_config(&self) -> Result<&Self, ProgramError>;
fn is_escrow(&self) -> Result<&Self, ProgramError>;
fn is_payment(&self) -> Result<&Self, ProgramError>;
}
impl EscrowAccountInfoValidation for AccountInfo<'_> {
fn is_config(&self) -> Result<&Self, ProgramError> {
self.has_address(&CONFIG_ADDRESS)?
.is_type::<Config>(&crate::ID)
}
fn is_bank(&self) -> Result<&Self, ProgramError> {
self.has_address(&BANK_ADDRESS)?.is_type::<Bank>(&crate::ID)
}
fn is_escrow(&self) -> Result<&Self, ProgramError> {
self.is_type::<Escrow>(&crate::ID)
}
fn is_payment(&self) -> Result<&Self, ProgramError> {
self.is_type::<Payment>(&crate::ID)
}
}