feat(escrow): add material/labor tranche split with release_materials()#285
Open
AlonsoFi wants to merge 2 commits into
Open
feat(escrow): add material/labor tranche split with release_materials()#285AlonsoFi wants to merge 2 commits into
AlonsoFi wants to merge 2 commits into
Conversation
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.
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:
All existing tests updated to match the new initialize() signature.