feat(contracts): add dispute resolution lifecycle#394
Open
Peolite001 wants to merge 20 commits into
Open
Conversation
- Add Disputed, ResolvedRelease, ResolvedRefund states to GiveawayStatus and HelpRequestStatus - Add dispute errors: AlreadyDisputed, NotDisputed, NotAuthorizedResolver - Add dispute metadata tracking keys (DisputeRaisedAt, DisputeRaisedBy) - Implement dispute_request() and resolve_dispute() for help requests - Implement dispute_giveaway() and resolve_giveaway_dispute() for giveaways - Block all normal flows (donate, refund, cancel, enter, pick_winner, distribute) while disputed - Restrict resolution to admin via check_admin() - Emit dispute lifecycle events (RequestDisputed, RequestResolved, GiveawayDisputed, GiveawayResolved) - Add admin wrapper functions in AdminContract - Add 14 unit tests covering dispute, block, resolution, and auth paths Closes geevapp#313
|
@Peolite001 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! 🚀 |
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.
Closes #313
Description
This PR implements a full dispute resolution lifecycle for both Help Requests (mutual aid) and Giveaways on-chain. The contract previously ended at donation, refund, or cancellation with no formal path to resolve conflicts between creators and participants/donors.
What changed
Disputed,ResolvedRelease, andResolvedRefundto bothGiveawayStatusandHelpRequestStatusenums.dispute_request()(creator or donor) anddispute_giveaway()(creator or participant) mark an item as disputed, record the timestamp and raiser, and emit a*Disputedevent.donate,claim_refund,cancel_request,enter_giveaway,pick_winner,distribute_prize) now panic withInvalidStatuswhile the item is inDisputedstate.resolve_dispute()andresolve_giveaway_dispute()are restricted to the admin viacheck_admin(). They accept arelease_fundsboolean:true→ transfer funds to the entitled party (creator for requests, winners for giveaways)false→ refund the original funder (donors for requests, creator for giveaways)RequestDisputed,RequestResolved,GiveawayDisputed,GiveawayResolvedare emitted for indexer visibility.AdminContractexposesresolve_help_request_dispute()andresolve_giveaway_dispute()for frontend/admin-tool convenience.Motivation
The README explicitly called out dispute resolution as a future enhancement. Without this flow, a malicious creator could cancel a funded request, or a dishonest donor could block a legitimate payout with no recourse. This change gives the protocol a trust-minimized escalation path while keeping final arbitration under admin control.
Checklist
cargo testpasses all 14 new tests plus existing suitenpx prisma generateafter schema changes — N/A (no Prisma schema changes)npx prisma migrate devornpx prisma migrate deployas appropriate — N/A (Soroban contract only)Post-Merge Steps for Maintainers
If this PR includes changes to the Prisma schema:
However, after merge: