feat: escrow balance guard, mark_in_transit, delivery state machine, and dispute trigger - #43
Merged
Merged
Conversation
… and dispute trigger
|
@noevidence1017 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! 🚀 |
Collaborator
|
@noevidence1017 Please ensure you open an individual PR for their issues implementation, respectively. |
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
- shared_types: add missing Address import (used by EscrowRecord) - escrow_contract/lib.rs: import EscrowRecord/EscrowStatus from shared_types, remove local duplicate definitions, keep InsufficientFunds guard and pub mod constants - escrow_contract/test.rs: use register_stellar_asset_contract_v2, check events before subsequent client calls (env.events().all() is cleared per invocation) - delivery_contract/test.rs: move events check before env.as_contract() call to avoid event queue being cleared Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
closes Smart Contract: Implement Escrow Balance Verification Guard #17 — Added
InsufficientFundserror and a pre-transfer balance verification guard inrelease_escrowandrefund_escrow. The guard queries the contract's own token balance viatoken::Client::balanceafter all state validations but before any state mutation. Also added the previously-missingEscrowStatus,EscrowRecord, helper functions, andconstantsmodule required for the escrow contract to compile. Underfunded scenario unit tests useenv.as_contractto artificially inflate the stored escrow amount beyond the actual contract balance.closes Smart Contract: Implement Mark In-Transit Status Update #22 — Implemented
mark_in_transit(env, driver, delivery_id)which requires driver auth, verifies the caller matchesDeliveryRecord.driver, validates theActive → InTransittransition via the state machine, recordstransit_started_atledger timestamp, extends TTL, and emits aDeliveryInTransitevent.closes Smart Contract: Implement Delivery State Machine Enforcement Layer #25 — Implemented a standalone
validate_transition(from, to) -> Result<(), DeliveryError>function encoding the full transition matrix (Pending→Active/Cancelled, Active→InTransit/Disputed/Cancelled, InTransit→Delivered/Disputed, Disputed→Delivered/Cancelled, terminal states block all transitions). All state-mutating contract functions now call this helper. Unit tests cover every valid and invalid transition pair.closes Smart Contract: Implement Delivery Dispute Trigger with Cross-Contract Escrow Pause #27 — Implemented
raise_dispute(env, caller, delivery_id)restricted to sender or recipient, validatesActive/InTransit → Disputedvia the state machine, makes the cross-contract escrow pause call before mutating delivery state (so a failing escrow call leaves delivery state untouched), then updates storage and emitsdelivery_disputed.