From f260ae03c30ca3d5934525dda55b6a672f2316b4 Mon Sep 17 00:00:00 2001 From: Deywumi-debug Date: Sun, 31 May 2026 06:40:47 +0000 Subject: [PATCH] feat: add dispute and timeout error codes (500-503) --- contracts/src/dispute_error.rs | 21 +++++++++++++++++++++ src/common/exceptions/error-codes.enum.ts | 4 ++++ 2 files changed, 25 insertions(+) create mode 100644 contracts/src/dispute_error.rs diff --git a/contracts/src/dispute_error.rs b/contracts/src/dispute_error.rs new file mode 100644 index 000000000..9b41de20d --- /dev/null +++ b/contracts/src/dispute_error.rs @@ -0,0 +1,21 @@ +use soroban_sdk::contracterror; + +#[contracterror] +#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] +#[repr(u32)] +pub enum DisputeError { + /// Cannot auto-refund yet + DisputeWindowNotElapsed = 500, + /// Dispute already exists for session + DisputeAlreadyOpen = 501, + /// No open dispute to resolve + DisputeNotOpen = 502, + /// Session not eligible for resolution + ResolutionNotAllowed = 503, +} + +impl From for u32 { + fn from(error: DisputeError) -> Self { + error as u32 + } +} diff --git a/src/common/exceptions/error-codes.enum.ts b/src/common/exceptions/error-codes.enum.ts index 5949668e5..6c2b1f250 100644 --- a/src/common/exceptions/error-codes.enum.ts +++ b/src/common/exceptions/error-codes.enum.ts @@ -5,6 +5,10 @@ export enum ErrorCodes { NOT_ADMIN = 201, // Caller is not contract admin NOT_BUYER = 202, // Caller is not session buyer NOT_SELLER = 203, // Caller is not session seller + DISPUTE_WINDOW_NOT_ELAPSED = 500, // Cannot auto-refund yet + DISPUTE_ALREADY_OPEN = 501, // Dispute already exists for session + DISPUTE_NOT_OPEN = 502, // No open dispute to resolve + RESOLUTION_NOT_ALLOWED = 503, // Session not eligible for resolution FORBIDDEN = 'FORBIDDEN', BAD_REQUEST = 'BAD_REQUEST', INTERNAL_ERROR = 'INTERNAL_ERROR',