Skip to content

feat(contract): bounded claim status_history + get_claim_history - #247

Merged
jhayniffy merged 2 commits into
InsurNiffy:mainfrom
aji70:feat/claim-status-history
Mar 28, 2026
Merged

feat(contract): bounded claim status_history + get_claim_history#247
jhayniffy merged 2 commits into
InsurNiffy:mainfrom
aji70:feat/claim-status-history

Conversation

@aji70

@aji70 aji70 commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds an append-only, bounded per-claim status timeline so the Next.js timeline can render lifecycle steps from chain state without relying only on indexer events (which can lag during reindex).
closes #193

Contract

  • New ClaimStatusHistoryEntry { status, ledger } (Soroban-friendly stand-in for (ClaimStatus, u32) tuples).
  • CLAIM_STATUS_HISTORY_MAX = 24: FIFO eviction of oldest entries when exceeded; documented that early history may be missing while status stays canonical.
  • Claim.status_history: initialized on file_claim (Processing); appended on real transitions in vote_on_claim, finalize_claim, and process_claim (Paid). Overflow handling never reverts the underlying transition.
  • New read-only entrypoint get_claim_history(claim_id) returning the same Vec as on Claim.

Build fixes (on main)

  • Remove duplicate Result / panic file_claim / vote_on_claim / finalize_claim / get_claim definitions; single get_claimClaim; file_claim uses soroban_sdk::String.
  • admin.rs: drop invalid events import.

Tests

  • cargo test --lib fifo_cap_drops_oldest (FIFO cap).
  • cargo test --test claim_status_history (approve→pay sequence + get_claim_history parity; finalize reject sequence).

Types (app / API)

  • Frontend: OnChainClaimStatusHistoryEntry in claim.ts.
  • Backend: optional status_history on Claim in policy.ts.

Migration / deploy

  • Claim layout changes: existing persisted claims will not decode until migration or redeploy; coordinate WASM upgrade.

Notes

  • Soroban test snapshots updated for new tests and set_and_get_claim_round_trip.

- Add ClaimStatusHistoryEntry { status, ledger } and CLAIM_STATUS_HISTORY_MAX (24)
  with FIFO eviction of oldest entries on overflow (documented incompleteness).
- Claim.status_history: seeded on file_claim; append on vote/finalize/process_claim
  transitions without reverting when the cap is exceeded.
- New entrypoint get_claim_history(claim_id) returns the same Vec as on Claim.
- Lib: remove duplicate Result claim entrypoints; fix admin events import;
  get_claim returns Claim; file_claim uses soroban_sdk::String.
- Tests: lib fifo cap, integration approve/payout + finalize/reject sequences;
  update Claim literals (asset + status_history) in fixtures.
- Frontend OnChainClaimStatusHistoryEntry; optional backend Claim.status_history.

Made-with: Cursor
@drips-wave

drips-wave Bot commented Mar 27, 2026

Copy link
Copy Markdown

@aji70 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

@jhayniffy
jhayniffy merged commit d763edd into InsurNiffy:main Mar 28, 2026
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 status history log: append-only transition records per claim

2 participants