feat(insurance): add claims dispute resolution (#255)#411
Merged
LaGodxy merged 2 commits intoMettaChain:mainfrom Apr 29, 2026
Merged
Conversation
Implement a three-step dispute resolution flow for rejected insurance claims: 1. raise_dispute – claimant disputes a rejected claim (one per claim) 2. vote_on_dispute – authorized assessors/admin cast votes 3. resolve_dispute – admin closes the dispute and applies the outcome; ClaimantWins re-approves the claim and executes payout, InsurerWins keeps the claim rejected. Changes: - types.rs: DisputeStatus (Open/Resolved/Dismissed), DisputeOutcome (ClaimantWins/InsurerWins), ClaimDispute struct - errors.rs: DisputeNotFound, DisputeAlreadyExists, DisputeNotOpen, AlreadyVoted, ClaimNotRejected - lib.rs: dispute storage fields, DisputeRaised/DisputeVoteCast/ DisputeResolved events, raise_dispute/vote_on_dispute/resolve_dispute messages, get_dispute/get_claim_dispute_id/get_dispute_count queries - tests.rs: 11 unit tests covering the full lifecycle Closes MettaChain#255
|
@Nuel-ship-it 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.
Summary
Implements a three-step dispute resolution flow for rejected insurance claims, allowing claimants to challenge decisions through a voting process.
Flow
raise_dispute(claim_id, reason)— Only the original claimant may call this on aRejectedclaim. One dispute per claim. Sets claim status toDisputed.vote_on_dispute(dispute_id, in_favour_of_claimant)— Authorized assessors or admin cast votes. Each address may vote once per dispute.resolve_dispute(dispute_id, outcome)— Admin closes the dispute:ClaimantWins: claim re-approved, payout executed from poolInsurerWins: claim stays rejectedChanges
contracts/insurance/src/types.rsDisputeStatus:Open/Resolved/DismissedDisputeOutcome:ClaimantWins/InsurerWinsClaimDisputestruct: dispute_id, claim_id, claimant, reason, status, outcome, vote tallies, timestampscontracts/insurance/src/errors.rsDisputeNotFound,DisputeAlreadyExists,DisputeNotOpen,AlreadyVoted,ClaimNotRejectedcontracts/insurance/src/lib.rsdisputes,dispute_count,claim_dispute(claim→dispute mapping),dispute_voters(double-vote guard)DisputeRaised,DisputeVoteCast,DisputeResolvedraise_dispute,vote_on_dispute,resolve_dispute,get_dispute,get_claim_dispute_id,get_dispute_countcontracts/insurance/src/tests.rs11 unit tests covering: raise dispute (happy path, non-claimant, non-rejected claim, duplicate), vote (happy path, unauthorized, double-vote), resolve (claimant wins, insurer wins, unauthorized, already resolved).
Closes #255