Skip to content

feat: Escrow Lifecycle Service Layer#74

Merged
SudiptaPaul-31 merged 1 commit intoLumina-eX:mainfrom
pugsley76:feat/escrow-lifecycle-service
Apr 28, 2026
Merged

feat: Escrow Lifecycle Service Layer#74
SudiptaPaul-31 merged 1 commit intoLumina-eX:mainfrom
pugsley76:feat/escrow-lifecycle-service

Conversation

@pugsley76
Copy link
Copy Markdown

Closes #51

Summary

Implements the escrow lifecycle service layer, abstracting all blockchain
logic away from controllers.

Changes

Service Layer (lib/escrow/)

  • types.ts — All shared types, DTOs, and interfaces (IEscrowBlockchainAdapter, IEscrowRepository)
  • errors.ts — Typed domain errors with escrowErrorToHttpStatus() helper
  • blockchain.ts — SorobanEscrowAdapter encapsulating every on-chain call
  • repository.ts — EscrowRepository with all SQL isolated from service logic
  • service.ts — EscrowService: createEscrow, fundEscrow, releaseFunds, refundEscrow, raiseDispute, resolveDispute
  • index.ts — Clean public barrel export

API Routes (app/api/escrow/)

Route Method Action
/api/escrow/create POST Deploy escrow contract
/api/escrow/fund POST Record on-chain funding
/api/escrow/release POST Release milestone funds to freelancer
/api/escrow/refund POST Refund escrow to client
/api/escrow/dispute POST Raise a dispute
/api/escrow/dispute/resolve POST Admin resolves dispute

Architecture

  • Dependency injection — swap blockchain/repo adapters in tests
  • State machine enforcement — validates status before any side-effect
  • Typed errors — clean HTTP mapping via escrowErrorToHttpStatus()
  • Non-breaking — existing contracts/deploy route untouched

Closes Lumina-eX#51

- lib/escrow/types.ts: shared types, DTOs, IEscrowBlockchainAdapter and IEscrowRepository interfaces
- lib/escrow/errors.ts: typed domain errors with HTTP status mapping helper
- lib/escrow/blockchain.ts: SorobanEscrowAdapter encapsulating all on-chain calls
- lib/escrow/repository.ts: EscrowRepository with all SQL isolated from service logic
- lib/escrow/service.ts: EscrowService orchestrating create, fund, release, refund, dispute, resolveDispute
- lib/escrow/index.ts: clean public barrel export
- app/api/escrow/create/route.ts: POST deploy escrow contract
- app/api/escrow/fund/route.ts: POST record on-chain funding
- app/api/escrow/release/route.ts: POST release milestone funds to freelancer
- app/api/escrow/refund/route.ts: POST refund escrow to client
- app/api/escrow/dispute/route.ts: POST raise a dispute
- app/api/escrow/dispute/resolve/route.ts: POST admin resolves dispute

Blockchain logic fully encapsulated behind IEscrowBlockchainAdapter.
Service layer is dependency-injected and testable without DB or Soroban.
All state transitions validated before side-effects are triggered.
Extensible for DAO voting and advanced dispute handling.
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 27, 2026

@pugsley76 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

@SudiptaPaul-31 SudiptaPaul-31 merged commit d3a895e into Lumina-eX:main Apr 28, 2026
1 check passed
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]: Escrow Lifecycle Service Layer

2 participants