Repository navigation
feat(disputes): dispute workflow, evidence and authorized on-chain resolution API (#247) - #268
Open
garbaaandekuba-source wants to merge 1 commit into
Conversation
Collaborator
|
@garbaaandekuba-source fix ci |
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
Adds a secure backend workflow for disputes: submission, evidence, authorized resolution, and tracking of on-chain resolution state with retry support.
Closes #247
Changes
scripts/00N_disputes.sql:disputes,dispute_evidence,dispute_events(audit trail). Unique partial index allows one unresolved dispute per contract;UNIQUE (dispute_id, uri)prevents duplicate evidencePOST /api/contracts/:id/disputes(participants only; contract status must be eligible)POST /api/disputes/:id/evidence(participants; https/ipfs references with optional sha256; duplicates are no-ops)GET /api/disputes/:id(participants and arbitrators; returns evidence and audit events)POST /api/disputes/:id/resolve(arbitrators only, not a party to the contract; reason and metadata required)open→resolution_pending(tx hash stored) →resolved(confirmed), withresolution_failedas a recoverable state. Pending and confirmed are tracked separately (resolution_submitted_atvsresolution_confirmed_at)UPDATEclaims the dispute; concurrent or repeated calls get409/202and never submit twice. Retries after failure must use the same outcome; stuck pending claims (crash before submission) become retryable after 5 minuteslib/disputes.ts#reconcileDisputechecks pending transactions and moves the dispute toresolvedorresolution_failed; it runs onGETand on repeatedresolvelib/escrow-chain.ts(submitResolution,getTxStatus). Backend checks are an extra layer; the contract remains the final authority on who may resolvedispute_eventsin the same statement as the state changedocs/dispute-resolution-api.md;DISPUTE_ARBITRATOR_IDSadded toenv.exampleTesting
npx vitest run,npm run lintandnpm run buildpass locallyNotes
DISPUTE_ARBITRATOR_IDSunless the repo gets a role system