Implement open dispute API for delivery issues - #79
Merged
Conversation
Allows a delivery's customer or driver to open a dispute before any on-chain dispute workflow runs. - New Dispute model tracking reason, description, evidence, and lifecycle status - disputeService validates the delivery exists and is in an active state (assigned or in progress), restricts the action to delivery participants, and prevents duplicate open disputes on the same delivery - POST /api/v1/disputes, authenticated, request body validated with zod - Stamps the current Soroban ledger sequence onto each dispute via the existing sorobanService for an audit trail - Tests cover the success path plus validation, auth, not-found, conflict, and business-rule failure cases
|
@Elizabethxxx Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #44
Summary
Allows a delivery's customer or driver to open a dispute before any corresponding on-chain dispute workflow is executed.
Disputemodel (src/models/Dispute.ts) withreason(enum),description, optionalevidenceUrls, and lifecyclestatus(open/under_review/resolved/rejected)disputeService.createDispute(src/services/disputeService.ts) enforces:assignedorin_progress) — pending, completed, and cancelled deliveries cannot be disputedsorobanService.getLatestLedger()) for an audit trail, non-blocking if the RPC call failsPOST /api/v1/disputes, protected byauthenticate, request body validated with a zod schema (src/validators/disputeValidator.ts)Architecture
Follows the existing layered pattern:
disputeRoutes.ts->validate(createDisputeSchema)->disputeController.ts->disputeService.ts->Disputemodel.Test plan
npx jest tests/dispute.test.ts— 13/13 passing, covering the success path (customer and driver), validation errors, missing auth, non-participant rejection, delivery-not-found, duplicate-open-dispute conflict, and non-active-delivery business rule violationsnpx tsc --noEmit— introduces no new TypeScript errors (pre-existing unrelated errors indeliveryController.tsare untouched by this change)npx eslinton all added/changed files — no errorsnpx jestsuite — same 4 pre-existing failing suites as onmainprior to this branch; no regressions introduced