Skip to content

feat(dispute): implement escrow dispute resolution (models, service, … - #176

Merged
Tybravo merged 3 commits into
SwiftChainn:mainfrom
GiftedGiftB:Implement-an-Escrow
Aug 31, 2026
Merged

feat(dispute): implement escrow dispute resolution (models, service, …#176
Tybravo merged 3 commits into
SwiftChainn:mainfrom
GiftedGiftB:Implement-an-Escrow

Conversation

@GiftedGiftB

@GiftedGiftB GiftedGiftB commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Closes #129

Summary

Provide a concise description of the change and the motivation.

What I changed

  • Added Escrow, Dispute and AuditLog Mongoose models
  • Implemented a DisputeService with lock and resolution logic
  • Added DisputeController and versioned routes under /api/v1/disputes
  • Added audit logging for admin actions

Files of interest

  • src/models/Escrow.ts
  • src/models/Dispute.ts
  • src/models/AuditLog.ts
  • src/services/disputeService.ts
  • src/controllers/disputeController.ts
  • src/routes/disputeRoutes.ts
  • src/routes/index.ts

How to test locally

  1. Ensure .env contains a working MONGODB_URI (or run MongoDB locally).
  2. Install dependencies:
pnpm install
  1. Run tests:
pnpm test
  1. Start the dev server:
pnpm run dev
  1. Example API calls (adjust host/port if needed):

Lock an escrow (admin):

curl -X POST http://localhost:3000/api/v1/disputes/<ESCROW_ID>/lock \
  -H "Content-Type: application/json" \
  -d '{"adminId":"<ADMIN_USER_ID>", "reason":"Buyer reports damaged goods"}'

Resolve a dispute (refund or release):

curl -X POST http://localhost:3000/api/v1/disputes/<DISPUTE_ID>/resolve \
  -H "Content-Type: application/json" \
  -d '{"adminId":"<ADMIN_USER_ID>", "action":"refund", "notes":"Refund approved"}'

Fetch dispute details:

curl http://localhost:3000/api/v1/disputes/<DISPUTE_ID>

Acceptance Criteria Mapping

  • Controller -> Service -> Model architecture: implemented
  • Persistence: data saved to MongoDB; no hardcoded mocks
  • API Versioning: endpoints registered under /api/v1
  • Robust error handling: service and controller validate inputs and return errors

Checklist

Proof of Work

Attach a screenshot of successful API response or test output. Example: terminal output of pnpm test or a Postman request showing success.

Notes for reviewers

  • This PR adds new models and routes; ensure DB indices and migration steps are acceptable.
  • Admin authorization is not enforced in this change — recommend adding RBAC middleware in a follow-up.

@drips-wave

drips-wave Bot commented Aug 31, 2026

Copy link
Copy Markdown

@GiftedGiftB 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! 🚀

Learn more about application limits

@Tybravo

Tybravo commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

@GiftedGiftB

Well done

@Tybravo
Tybravo merged commit 8ebdc40 into SwiftChainn:main Aug 31, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Implement an Escrow Dispute Resolution flow

2 participants