Skip to content

Feature/claims withdrawal reopen - #272

Merged
jhayniffy merged 2 commits into
InsurNiffy:mainfrom
Mimah97:feature/claims-withdrawal-reopen
Mar 29, 2026
Merged

Feature/claims withdrawal reopen#272
jhayniffy merged 2 commits into
InsurNiffy:mainfrom
Mimah97:feature/claims-withdrawal-reopen

Conversation

@Mimah97

@Mimah97 Mimah97 commented Mar 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds claimant-only withdraw_claim so a filing mistake can be undone before any vote is cast. After the first ballot, withdrawal is blocked. Withdrawn claims stay on-chain for audit, are not finalizable into approve/reject outcomes for payout, and are surfaced distinctly for indexers/UI.
closes #197

Contract

  • New ClaimStatus::Withdrawn (terminal): finalize_claim / vote_on_claim treat as terminal; process_claim still requires Approved only.
  • withdraw_claim(claimant, claim_id): claimant auth; only while Processing and approve_votes + reject_votes == 0; clears open-claim flag; respects claims_paused like other claim mutators.
  • ClaimWithdrawn event: ["niffyinsure", "claim_withdrawn", claim_id] with policy_id, claimant, at_ledger.
  • Rate limit: persistent ClaimRateLimitPrev(claim_id) snapshots LastClaimLedger before each successful file_claim; restored on withdraw (or last-ledger key removed if first-ever filing). Key cleared when leaving Processing via vote, finalize, or payout (no restore on those paths).
  • Errors (no new contracterror variants): wrong caller → NotEligibleVoter; wrong status or any vote → ClaimAlreadyTerminal. map_quote_error copy updated accordingly.

Tests

  • contracts/niffyinsure/tests/withdraw_claim.rs: success path; revert after first vote; non-claimant; rate-limit refile after withdraw; finalize + process_claim both fail when withdrawn.

Frontend / docs

  • Withdrawn in Zod ClaimStatus + isTerminal; claims board / vote tally badges; education panel + claims.mdx (incl. rate limit does not persist after withdraw for per-holder spacing); en/es status strings; indexer note in events.rs.

How to verify

cd contracts/niffyinsure && cargo test && cargo clippy --all-targets -- -D warnings

Mimah97 added 2 commits March 28, 2026 22:00
- Store instance quorum_bps (1–10_000); initialize default 5000; admin_set + QuorumUpdated event
- Snapshot ClaimQuorumBps at file_claim; finalize/vote use R = ceil(E*Q/10000) cast-ballot quorum + plurality
- Below R at deadline → Rejected; admin quorum changes do not alter open claims
- Tests: boundary quorum, ACL, e2e/voting/rejection/storage updates
- Frontend: voting.mdx, vote education/tally, vote schema helper; events catalog note
…it restore

- Add ClaimStatus::Withdrawn (terminal); block finalize/process payout
- withdraw_claim: claimant auth, Processing + zero tallies, open-claim clear
- Persist per-claim rate-limit anchor in ClaimRateLimitPrev; restore on withdraw
- Clean anchor when claim leaves Processing via vote/finalize/payout
- Emit claim_withdrawn event; document for indexers in events.rs
- Reuse validate errors: NotEligibleVoter (wrong claimant), ClaimAlreadyTerminal
- Tests: success, post-vote reject, unauthorized, rate-limit refile, no finalize/pay
- Frontend: Withdrawn in schemas, board badge, vote tally, i18n, claims.mdx

Made-with: Cursor
@jhayniffy
jhayniffy merged commit 97c0620 into InsurNiffy:main Mar 29, 2026
1 of 6 checks passed
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.

Contract — Claim withdrawal: holder cancels own claim before voting starts

2 participants