sla-escrow-api 0.2.6

SLA-Escrow: Service Level Agreement Enforcer for AI Agents
Documentation
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>;
    // fn is_treasury(&self) -> Result<&Self, ProgramError>;
    // fn is_treasury_tokens(&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)
    }

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