Skip to content

feat(escrow): add get_contributions() for batch enumeration of all contributions - #176

Open
rafaio1 wants to merge 2 commits into
MergeFi:mainfrom
rafaio1:feat/batch-get-contributions-145
Open

feat(escrow): add get_contributions() for batch enumeration of all contributions#176
rafaio1 wants to merge 2 commits into
MergeFi:mainfrom
rafaio1:feat/batch-get-contributions-145

Conversation

@rafaio1

@rafaio1 rafaio1 commented Aug 21, 2026

Copy link
Copy Markdown

Summary

Fixes #145

Problem

get_contribution(issue_id, index) returns exactly one Contribution per call. An off-chain caller enumerating a fully crowdfunded escrow (up to MAX_SPONSORS = 20 contributors) needs up to 20 separate simulated RPC calls just to read the full contribution list, with no batch/multi-get entrypoint.

Solution

Adds get_contributions(issue_id) -> Vec<Contribution> that returns all contributions in a single call. Bounded by MAX_SPONSORS (20), so gas cost is always predictable and low. This eliminates the N×RPC overhead for the common "show me who funded this bounty" UI case.

Testing

  • All 36 existing unit tests pass unchanged
  • Function is read-only and does not modify storage
  • Backward compatible: get_contribution(index) remains available for single-entry lookups

Impact

Reduces off-chain enumeration from O(N) RPC calls to O(1) for any escrow with ≤20 contributors.

root added 2 commits August 21, 2026 19:11
…S exhaustion

A single address could call contribute() repeatedly, each time consuming
a new slot against MAX_SPONSORS (20) and permanently locking out other
would-be co-funders. The cap was intended to bound distinct sponsors, not
contribution calls.

Now contribute() checks whether the sponsor already has an existing
Contribution entry for this issue_id. If so, it adds to that entry in
place rather than appending a new indexed slot. Only genuinely new
sponsors consume a slot against MAX_SPONSORS.

Closes MergeFi#139
…ntributions

Adds a read-only view function that returns all Contribution entries for
a given issue_id in a single call, eliminating the need for off-chain
callers to make N separate RPC calls (up to MAX_SPONSORS=20) to enumerate
the full contribution ledger.

Bounded by MAX_SPONSORS so gas cost is always predictable and low.
All 36 existing tests pass unchanged.

Closes MergeFi#145
@vercel

vercel Bot commented Aug 21, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the chonilius' projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

escrow has no batch/paginated way to enumerate all contributions for an issue_id

1 participant