feat(escrow): add get_contributions() for batch enumeration of all contributions - #176
Open
rafaio1 wants to merge 2 commits into
Open
feat(escrow): add get_contributions() for batch enumeration of all contributions#176rafaio1 wants to merge 2 commits into
rafaio1 wants to merge 2 commits into
Conversation
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
|
Someone is attempting to deploy a commit to the chonilius' projects Team on Vercel. A member of the Team first needs to authorize it. |
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
Fixes #145
Problem
get_contribution(issue_id, index)returns exactly oneContributionper call. An off-chain caller enumerating a fully crowdfunded escrow (up toMAX_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 byMAX_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
get_contribution(index)remains available for single-entry lookupsImpact
Reduces off-chain enumeration from O(N) RPC calls to O(1) for any escrow with ≤20 contributors.