Skip to content

feat: Read/query entrypoints: get_policy, get_claim, bounded pagination - #171

Merged
jhayniffy merged 1 commit into
InsurNiffy:mainfrom
Macnelson9:getters
Mar 27, 2026
Merged

feat: Read/query entrypoints: get_policy, get_claim, bounded pagination#171
jhayniffy merged 1 commit into
InsurNiffy:mainfrom
Macnelson9:getters

Conversation

@Macnelson9

Copy link
Copy Markdown
Contributor

This PR closes #19

feat(contract): read/query entrypoints with bounded pagination

Add get_policy, get_claim, list_policies, and list_claims to the
Soroban contract, plus matching frontend chain-read helpers.

Contract changes

  • list_policies(holder, start_after, limit) — paginated policy
    summaries, exclusive cursor over policy_id, limit hard-capped at 20
    (PAGE_SIZE_MAX)
  • list_claims(start_after, limit) — same pattern over claim_id
  • PolicySummary / ClaimSummary — lightweight structs (omit details,
    image_urls) to keep per-page byte cost predictable; callers follow
    up with get_policy / get_claim for full records
  • Stale cursors return an empty page — never panic, never skip
    records (IDs are monotonically increasing, never deleted)

Tests — 10 new cases in tests/storage.rs: empty page, first page,
cursor advance, last partial page, cursor-past-end, oversize limit
clamped to 20

Frontend changes

  • src/lib/api/chain.ts — new module: getPolicy, getClaim,
    listPolicies, listClaims via Soroban simulation; null return on 404
    for predictable unknown-id handling
  • src/types/claim.ts — OnChainPolicySummary, OnChainClaimSummary,
    CHAIN_PAGE_SIZE_MAX; documents chain-read vs indexer-read tradeoffs
    (lag, finality, trust, cost)

@drips-wave

drips-wave Bot commented Mar 27, 2026

Copy link
Copy Markdown

@Macnelson9 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 8f55b84 into InsurNiffy:main Mar 27, 2026
1 of 4 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 — Read/query entrypoints: get_policy, get_claim, bounded pagination

2 participants