Skip to content

feat(escrow): add material/labor tranche split with release_materials()#285

Open
AlonsoFi wants to merge 2 commits into
NOVUS-X:mainfrom
AlonsoFi:feat/escrow-material-labor-split
Open

feat(escrow): add material/labor tranche split with release_materials()#285
AlonsoFi wants to merge 2 commits into
NOVUS-X:mainfrom
AlonsoFi:feat/escrow-material-labor-split

Conversation

@AlonsoFi
Copy link
Copy Markdown

Escrow Tranching: Material & Labor Split with Instant Material Release

Overview

This PR implements smart contract escrow tranching as specified in issue #163. It splits the escrow funding into two
distinct tranches — materials and labor — so artisans can receive materials funding immediately upon job acceptance
while the labor portion remains locked until work is complete.

Closes #163

Changes

🔗 Smart Contract (Soroban)

Updated Escrow struct: Added material_amount, labor_amount, and materials_released fields to support split funding.

Updated initialize(): Signature changed from a single amount to (material_amount, labor_amount). The total is computed
internally so the client still deposits in one transaction.

New release_materials(): Transfers material_amount to the artisan immediately, keeping the escrow in Funded state with
labor_amount still locked.

Updated release(): When materials were pre-released, only transfers the remaining labor_amount to the artisan.

Updated reclaim() and arbitrate(): Both functions operate only on the locked portion — respecting any prior material
release.

New MaterialsReleasedEvent: Emitted upon successful material tranche release.

🧪 Testing

6 new unit tests added:

  • test_split_deposit_single_sign — client funds both tranches with a single deposit
  • test_release_materials_basic — artisan receives material_amount; labor_amount stays locked
  • test_release_materials_then_labor — full tranche workflow end-to-end
  • test_release_materials_wrong_state — guard against releasing on non-Funded escrow
  • test_release_materials_twice — double-release protection
  • test_reclaim_after_materials_released — only labor_amount returned after deadline

All existing tests updated to match the new initialize() signature.

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.

ISSUE-22 · 🔵 (Contracts)— Smart Contract Escrow Tranching

1 participant