Repository navigation
feat: add get_allocation view to milestones contract (#802) - #914
Merged
chonilius merged 2 commits intoNov 21, 2026
Merged
Conversation
Adds a cheap single-entry read for the token amount allocated to a specific issue within a milestone. Previously callers had to fetch the entire Milestone record (which grows with each allocation) just to read one issue's amount. The new view reads only the milestone record and returns the allocation map entry for the requested issue_id, returning IssueNotAllocated when no entry exists. Also adds four tests: happy path, unknown issue, unknown milestone, and amount update after a second allocate call.
|
Someone is attempting to deploy a commit to the chonilius' projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@oluwagbemigaphilip 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_allocation(env, milestone_id, issue_id) -> Result<i128, Error>to the milestones contract, placed next toget_issue_status.Problem
The only way to read "how much is allocated to issue X?" was
get_milestone, which returns the fullMilestonerecord — including the unboundedallocationsMap. This means the cost of a single allocation lookup scales with the number of issues sharing that milestone.Fix
The new view reads the milestone record and returns
milestone.allocations.get(issue_id), returningIssueNotAllocatedwhen no entry exists. This is a cheap, targeted read; the milestone record is a fixed-size base object.Changes
contracts/milestones/src/lib.rs—get_allocationfunction added afterget_issue_statuscontracts/milestones/src/test.rs— 4 tests: happy path, unknown issue, unknown milestone, amount after re-allocateCloses #802
To be completed in follow-up PRs: