sla-escrow-api 0.2.5

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

#[derive(Debug, Error, Clone, Copy, PartialEq, Eq, IntoPrimitive)]
#[repr(u32)]
pub enum EscrowError {
    // Authority Errors
    #[error("The authority is invalid")]
    InvalidAuthority = 0,
    #[error("The authority is unchanged")]
    AuthorityUnchanged = 1,
    #[error("Only the authority can perform this action")]
    Unauthorized = 2,

    // Payment State Errors
    #[error("Payment is not in the correct state for this operation")]
    InvalidPaymentState = 10,
    #[error("Payment has already expired")]
    PaymentExpired = 11,
    #[error("Payment is not funded")]
    PaymentNotFunded = 12,

    // Escrow Errors
    #[error("Escrow is paused")]
    EscrowPaused = 20,
    #[error("Escrow has non-zero balance")]
    EscrowHasBalance = 21,
    #[error("Escrow has non-zero fee balance")]
    EscrowHasFeeBalance = 22,
    #[error("Invalid escrow settings")]
    InvalidEscrowSettings = 23,
    #[error("Fee basis points too high")]
    FeeTooHigh = 24,
    #[error("Minimum payment amount must be greater than zero")]
    InvalidMinPaymentAmount = 25,
    #[error("Maximum payment amount must be greater than minimum")]
    InvalidMaxPaymentAmount = 26,

    // Amount Errors
    #[error("Amount exceeds maximum payment limit")]
    AmountExceedsLimit = 30,
    #[error("Amount below minimum payment limit")]
    AmountBelowLimit = 31,
    #[error("Insufficient funds")]
    InsufficientFunds = 32,
    #[error("Insufficient storage balance for SOL operations")]
    InsufficientStorageBalance = 33,

    // TTL & Delivery Errors
    #[error("Invalid TTL extension")]
    InvalidTTLExtension = 40,
    #[error("TTL extension too large")]
    TTLExtensionTooLarge = 41,
    #[error("Payment cannot be canceled after expiration")]
    CannotCancelExpiredPayment = 42,
    #[error("Cannot refund a fulfilled payment")]
    CannotRefundFulfilledPayment = 43,
    #[error("Cannot refund a payment after delivery is submitted")]
    CannotRefundDeliveredPayment = 44,
    #[error("Cannot refund a delivered expired payment")]
    CannotRefundDeliveredExpiredPayment = 45,
    #[error("Refund cooldown period is still active")]
    RefundCooldownPeriodActive = 46,
    #[error("Cannot release an undelivered expired payment")]
    CannotReleaseUndeliveredExpiredPayment = 47,
    #[error("Cannot confirm oracle before delivery is submitted")]
    DeliveryNotSubmitted = 48,

    // Account Errors
    #[error("Invalid account provided")]
    InvalidAccount = 50,
    #[error("Account is not writable")]
    AccountNotWritable = 51,
    #[error("Account is not signer")]
    AccountNotSigner = 52,
    #[error("Account is not empty")]
    AccountNotEmpty = 53,
    #[error("Account is empty")]
    AccountEmpty = 54,

    // Token Errors
    #[error("Invalid token account")]
    InvalidTokenAccount = 60,
    #[error("Token transfer failed")]
    TokenTransferFailed = 61,
    #[error("Token account close failed")]
    TokenAccountCloseFailed = 62,

    // Program Errors
    #[error("Invalid program ID")]
    InvalidProgramId = 70,
    #[error("Invalid instruction data")]
    InvalidInstructionData = 71,
    #[error("Account not found")]
    AccountNotFound = 72,
    #[error("Not enough account keys")]
    NotEnoughAccountKeys = 73,
    #[error("Missing required field")]
    MissingRequiredField = 74,
    #[error("Cannot close active payment")]
    CannotCloseActivePayment = 75,
    #[error("Too early to close payment")]
    TooEarlyToClose = 76,

    // Balance Validation Errors
    #[error("Insufficient token balance in escrow account")]
    InsufficientTokenBalance = 80,
    #[error("Insufficient liquidity for this operation")]
    InsufficientLiquidity = 81,
    #[error("Fee balance exceeds actual token balance")]
    FeeBalanceExceedsBalance = 82,
}

error!(EscrowError);