Skip to content

feat: add get_allocation view to milestones contract (#802) - #914

Merged
chonilius merged 2 commits into
MergeFi:mainfrom
oluwagbemigaphilip:feat/get-allocation-view-802
Nov 21, 2026
Merged

chonilius merged 2 commits into
MergeFi:mainfrom
oluwagbemigaphilip:feat/get-allocation-view-802

Conversation

@oluwagbemigaphilip

@oluwagbemigaphilip oluwagbemigaphilip commented Nov 21, 2026 •

Copy link
Copy Markdown

Summary

Adds get_allocation(env, milestone_id, issue_id) -> Result<i128, Error> to the milestones contract, placed next to get_issue_status.

Problem

The only way to read "how much is allocated to issue X?" was get_milestone, which returns the full Milestone record — including the unbounded allocations Map. 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), returning IssueNotAllocated when 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_allocation function added after get_issue_status
  • contracts/milestones/src/test.rs — 4 tests: happy path, unknown issue, unknown milestone, amount after re-allocate

Closes #802


To be completed in follow-up PRs:

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.
@vercel

vercel Bot commented Nov 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.

@drips-wave

drips-wave Bot commented Nov 21, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@chonilius
chonilius merged commit e147a46 into MergeFi:main Nov 21, 2026
1 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment