escrow-api 0.2.1

Signer-Payer Payment Escrow Program
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 is already disputed")]
    PaymentAlreadyDisputed = 11,
    #[error("Payment is not disputed")]
    PaymentNotDisputed = 12,
    #[error("Payment is not arbitrated")]
    PaymentNotArbitrated = 13,
    #[error("Payment has already expired")]
    PaymentExpired = 14,
    #[error("Payment is not funded")]
    PaymentNotFunded = 15,
    #[error("Payment is already funded")]
    PaymentAlreadyFunded = 16,
    #[error("Payment is already released")]
    PaymentAlreadyReleased = 17,
    #[error("Payment is already refunded")]
    PaymentAlreadyRefunded = 18,
    #[error("Payment is already canceled")]
    PaymentAlreadyCanceled = 19,

    // Dispute Errors
    #[error("Only buyer or seller can dispute this payment")]
    InvalidDisputer = 20,
    #[error("Invalid dispute reason")]
    InvalidDisputeReason = 21,
    #[error("Dispute already exists for this payment")]
    DisputeAlreadyExists = 22,
    #[error("Arbitration required for this dispute")]
    ArbitrationRequired = 23,

    // Escrow Errors
    #[error("Escrow is paused")]
    EscrowPaused = 30,
    #[error("Escrow has non-zero balance")]
    EscrowHasBalance = 31,
    #[error("Escrow has non-zero fee balance")]
    EscrowHasFeeBalance = 32,
    #[error("Invalid escrow settings")]
    InvalidEscrowSettings = 33,
    #[error("Fee basis points too high")]
    FeeTooHigh = 34,
    #[error("Minimum payment amount must be greater than zero")]
    InvalidMinPaymentAmount = 35,
    #[error("Maximum payment amount must be greater than minimum")]
    InvalidMaxPaymentAmount = 36,

    // Amount Errors
    #[error("Invalid amount for split decision")]
    InvalidSplitAmount = 40,
    #[error("Amount exceeds maximum payment limit")]
    AmountExceedsLimit = 41,
    #[error("Amount below minimum payment limit")]
    AmountBelowLimit = 42,
    #[error("Insufficient funds")]
    InsufficientFunds = 43,
    #[error("Insufficient storage balance for SOL operations")]
    InsufficientStorageBalance = 44,

    // TTL Errors
    #[error("Invalid TTL extension")]
    InvalidTTLExtension = 50,
    #[error("TTL extension too large")]
    TTLExtensionTooLarge = 51,
    #[error("Payment cannot be canceled after expiration")]
    CannotCancelExpiredPayment = 52,

    // Account Errors
    #[error("Invalid account provided")]
    InvalidAccount = 60,
    #[error("Account is not writable")]
    AccountNotWritable = 61,
    #[error("Account is not signer")]
    AccountNotSigner = 62,
    #[error("Account is not empty")]
    AccountNotEmpty = 63,
    #[error("Account is empty")]
    AccountEmpty = 64,

    // Token Errors
    #[error("Invalid token account")]
    InvalidTokenAccount = 70,
    #[error("Token transfer failed")]
    TokenTransferFailed = 71,
    #[error("Token account close failed")]
    TokenAccountCloseFailed = 72,

    // Program Errors
    #[error("Invalid program ID")]
    InvalidProgramId = 80,
    #[error("Invalid instruction data")]
    InvalidInstructionData = 81,
    #[error("Account not found")]
    AccountNotFound = 82,
    #[error("Not enough account keys")]
    NotEnoughAccountKeys = 83,
    #[error("Missing required field")]
    MissingRequiredField = 84,
    #[error("Cannot close active payment")]
    CannotCloseActivePayment = 85,
    #[error("Too early to close payment")]
    TooEarlyToClose = 86,
    #[error("Appeal window has expired")]
    AppealWindowExpired = 87,
    #[error("Maximum appeals reached")]
    MaxAppealsReached = 88,
}

error!(EscrowError);