sla-escrow-api 0.2.9

SLA-Escrow: Service Level Agreement Enforcer for AI Agents
Documentation
use steel::*;

use crate::{
    consts::*,
    state::{AuthorityTransfer, 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_authority_transfer(&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_authority_transfer(&self) -> Result<&Self, ProgramError> {
        self.is_type::<AuthorityTransfer>(&crate::ID)
    }
}