Skip to content

feat(invoice-escrow): implement batch get_escrows read method - #258

Open
zinodict121 wants to merge 1 commit into
StellarState:devfrom
zinodict121:feature/get-escrows-batch-read
Open

feat(invoice-escrow): implement batch get_escrows read method#258
zinodict121 wants to merge 1 commit into
StellarState:devfrom
zinodict121:feature/get-escrows-batch-read

Conversation

@zinodict121

Copy link
Copy Markdown

Implement batch get_escrows read method

Fixes #87

Description

This PR implements a paginated batch read method for retrieving escrows, addressing the missing iteration capabilities in the contract as requested in issue #87.

Changes:

  • types.rs: Added StorageKey::EscrowCount and StorageKey::EscrowIdByIndex(u32) to maintain a global index of created escrows since Soroban cannot iterate persistent map keys natively.
  • storage.rs: Added helper functions to manage and read the escrow index.
  • lib.rs:
    • Updated create_escrow to append the newly generated invoice_id into the global index.
    • Implemented get_escrows(env, start, limit) function to fetch paginated escrow records.
    • Validates boundaries: rejects limit == 0 (InvalidLimit) and rejects limits above MAX_PAGE_SIZE of 100 (LimitExceeded). Handles start >= total_count gracefully by returning an empty vector.
  • errors.rs: Added Error::InvalidLimit (17) and Error::LimitExceeded (18) following the existing enumeration format.
  • test.rs: Added comprehensive test cases including empty state, populated page slicing, invalid limits, and pagination boundaries.

Notes

  • No events were added since read methods in this contract (e.g. get_escrow) do not emit events.
  • Tested boundary parameters meticulously to ensure no integer overflows occur.

@drips-wave

drips-wave Bot commented Jul 27, 2026

Copy link
Copy Markdown

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

@chizzy192
chizzy192 changed the base branch from main to dev July 29, 2026 15:54
@chizzy192 chizzy192 closed this Jul 29, 2026
@chizzy192 chizzy192 reopened this Jul 29, 2026
@chizzy192

Copy link
Copy Markdown
Contributor

Hi @zinodict121, please rebase your branch on dev to resolve line conflicts in contracts/invoice-escrow/src/lib.rs for the batch get_escrows getter implementation.

@chizzy192 chizzy192 closed this Jul 30, 2026
@chizzy192 chizzy192 reopened this Jul 30, 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.

[CONTRACTS] Invoice Escrow: Implement Batch Escrow Query Read Method

3 participants