feat: get_policies_batch contract cap + chain simulation API - #245
Merged
Conversation
- Add PolicyLookupKey, POLICY_BATCH_GET_MAX (20), and get_policies_batch: enforce cap before storage reads; None for missing keys; revert on over-cap with validate::Error::PolicyBatchTooLarge (49). - Extend quote_error_message / map_quote_error for new and appeal error codes. - Fix duplicate file_claim/vote_on_claim/finalize_claim definitions and admin events import so the contract crate builds. - Add integration tests (empty, full 20, mixed None, over-cap). - Nest: ChainModule POST /api/chain/policies/batch calling SorobanService simulateGetPoliciesBatch with scvSortedMap-encoded keys. - Frontend: getPoliciesBatch, POLICY_BATCH_GET_MAX, and Nest-style error parsing in chain handleResponse. Made-with: Cursor
|
@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! 🚀 |
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
get_policies_batchto the niffyinsure contract (hard cap 20, aligned withPAGE_SIZE_MAX), exposes it via NestPOST /api/chain/policies/batch, and adds a frontendgetPoliciesBatchhelper for bulk chain reads.closes #192
Contract
PolicyLookupKey { holder, policy_id }andPOLICY_BATCH_GET_MAX(= 20, same as pagination cap).get_policies_batch(ids) -> Vec<Option<Policy>>: cap enforced before any storage reads; missing keys →Noneat that index; over cap →validate::Error::PolicyBatchTooLarge(49).quote_error_message/map_quote_errorupdated for error 49 and appeal-related codes 43–48.file_claim/vote_on_claim/finalize_claimdefinitions and fixesadminimport so the crate builds.Tests
cargo test --test get_policies_batch(empty, full 20, mixed None, over-cap).Backend
ChainModule:POST /api/chain/policies/batch→SorobanService.simulateGetPoliciesBatch(sorted-map encoding forPolicyLookupKey).source_account(defaults to first holder).Frontend
getPoliciesBatch,POLICY_BATCH_GET_MAX,PolicyBatchKey.handleResponseparses NestBadRequestException({ code, message })bodies.Deploy / ops
get_policies_batchexists on the target network before relying on the new simulation path.Notes
cargo test/nest buildmay still fail on unrelated pre-existing issues (e.g.tests/events.rs, indexer/idempotency).