Skip to content

feat(contracts): add dispute resolution lifecycle#394

Open
Peolite001 wants to merge 20 commits into
geevapp:mainfrom
Peolite001:feat/dispute-resolution
Open

feat(contracts): add dispute resolution lifecycle#394
Peolite001 wants to merge 20 commits into
geevapp:mainfrom
Peolite001:feat/dispute-resolution

Conversation

@Peolite001

Copy link
Copy Markdown

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

  • New states: Added Disputed, ResolvedRelease, and ResolvedRefund to both GiveawayStatus and HelpRequestStatus enums.
  • Dispute raising: dispute_request() (creator or donor) and dispute_giveaway() (creator or participant) mark an item as disputed, record the timestamp and raiser, and emit a *Disputed event.
  • Flow blocking: All normal operations (donate, claim_refund, cancel_request, enter_giveaway, pick_winner, distribute_prize) now panic with InvalidStatus while the item is in Disputed state.
  • Admin resolution: resolve_dispute() and resolve_giveaway_dispute() are restricted to the admin via check_admin(). They accept a release_funds boolean:
    • true → transfer funds to the entitled party (creator for requests, winners for giveaways)
    • false → refund the original funder (donors for requests, creator for giveaways)
  • Events: RequestDisputed, RequestResolved, GiveawayDisputed, GiveawayResolved are emitted for indexer visibility.
  • Admin wrappers: AdminContract exposes resolve_help_request_dispute() and resolve_giveaway_dispute() for frontend/admin-tool convenience.
  • Tests: 14 new unit tests cover dispute creation by creator and donor, blocked operations during dispute, admin resolution with both outcomes, and non-admin rejection.

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

  • I have tested my changes locally — cargo test passes all 14 new tests plus existing suite
  • I have updated documentation as needed — README update pending review
  • I have run npx prisma generate after schema changes — N/A (no Prisma schema changes)
  • I have run npx prisma migrate dev or npx prisma migrate deploy as appropriate — N/A (Soroban contract only)

Post-Merge Steps for Maintainers

If this PR includes changes to the Prisma schema:

This PR does not touch the Prisma schema. No database migration is required.

However, after merge:

  1. Rebuild and redeploy the contract WASM to Stellar testnet/mainnet.
  2. Update the contract ID in backend environment variables.
  3. Regenerate TypeScript bindings from the updated contract ABI if applicable.

- 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
@drips-wave

drips-wave Bot commented Jun 29, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

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.

[Contracts] Add dispute resolution flow

1 participant