Skip to content

MilestoneFundButton has no amount input, making partial milestone funding impossible from the UI #83

Closed

Description

@chonilius

Overview

src/app/milestones/MilestoneActions.tsx defines two sibling "fund something" components back to back, and only one of them lets the user say how much:

export function MilestoneFundButton({ milestoneId }: { milestoneId: string }) {
  const router = useRouter();
  const { address, connect, connecting } = useWallet();
  const [pending, setPending] = useState(false);
  const [error, setError] = useState<string | null>(null);

  async function handleFund() {
    setError(null);
    setPending(true);
    try {
      const walletAddress = address ?? (await connect());
      if (!walletAddress) {
        setError("Connect a Stellar wallet to fund this milestone.");
        return;
      }
      await apiPost(`/milestones/${milestoneId}/fund`, {
        funderAddress: walletAddress,
      });
      router.refresh();
    } catch (err) { ... }
    finally { setPending(false); }
  }

  return (
    <div className="mt-4">
      <Button size="sm" variant="outline" onClick={handleFund} disabled={pending || connecting}>
        {pending || connecting ? "Confirming in wallet..." : "Fund milestone"}
      </Button>
      {error && <p className="mt-2 text-xs text-rose-600">{error}</p>}
    </div>
  );
}

handleFund posts { funderAddress: walletAddress } — no amount field at all. Compare this to PoolDepositButton, defined a few lines later in the exact same file, for the conceptually near-identical action of depositing into a maintenance pool:

export function PoolDepositButton({ poolId }: { poolId: string }) {
  ...
  const [amount, setAmount] = useState("100");
  async function handleDeposit() {
    ...
    await apiPost(`/maintenance-pools/${poolId}/deposit`, {
      amount,
      funderAddress: walletAddress,
    });
    ...
  }
  return (
    <div className="mt-4 flex items-center gap-2">
      <input type="number" min="1" value={amount} onChange={(e) => setAmount(e.target.value)} ... />
      <Button ...>{pending || connecting ? "Confirming..." : "Deposit"}</Button>
      ...

PoolDepositButton correctly collects an amount from the user before posting. MilestoneFundButton collects nothing.

This is a real functional gap, not just a stylistic inconsistency, given how MilestonesPage itself describes and visualizes milestone funding: each milestone renders a progress bar showing distributed out of budget, explicitly modeling partial, incremental funding over time — "Sponsors can fund an entire release instead of a single issue. Budget is distributed automatically across the milestone's issues as each one resolves" (README) and "Sponsors deposit monthly so maintainers can reward ongoing upkeep" for the adjacent maintenance-pool section on the very same page. A progress bar that's meaningfully partway filled (e.g. m2's mock data: distributed: 2100 of budget: 6000) only makes sense if multiple funding contributions, of varying amounts, are expected over the milestone's lifetime — yet the one button that triggers a milestone-funding action provides no way to specify how much of that budget gap this particular contribution should cover.

Either the backend endpoint (POST /milestones/:id/fund) silently interprets a missing amount as "fund the entire remaining budget in one shot" (in which case the UI is misleadingly labeled — a button with no amount input reads as "fund this milestone," not "fund the entire remaining budget," and a sponsor clicking it with no amount field visible has no way to know or control that), or the endpoint requires an amount and this call is simply broken/incomplete and would fail or behave unpredictably against a real backend. Either way, this is worth resolving explicitly rather than left as an unexplained asymmetry with its sibling component two components down in the same file.

Requirements

  • Add an amount input to MilestoneFundButton, matching the pattern already established by PoolDepositButton in the same file (numeric input, validated per the separate amount-validation issue in this batch that also covers PoolDepositButton's current lack of validation — apply the same validation to this new input from the start rather than introducing a second unvalidated amount field).
  • Confirm with the actual mergefi-backend contract (or by testing against a running instance) what POST /milestones/:id/fund currently expects — if it already requires an amount and this frontend call has simply never sent one, this is a currently-broken/non-functional action end to end, which materially raises the priority of this fix. Document the finding in the PR.
  • Consider whether the amount should be capped/defaulted sensibly relative to the milestone's remaining budget (budget - distributed) — e.g. pre-filling or capping the input so a sponsor can't accidentally attempt to overfund past the stated budget, mirroring the divide-by-zero/overspend-display issue elsewhere in this batch for MilestonesPage's own progress-bar math.

Acceptance Criteria

  • MilestoneFundButton renders an amount input before its "Fund milestone" action, consistent with PoolDepositButton's existing pattern in the same file.
  • handleFund sends the user-entered amount to POST /milestones/:id/fund alongside funderAddress.
  • The input is validated using the same rules established for PoolDepositButton's amount field elsewhere in this batch (no empty/zero/negative/non-numeric/over-precision values reaching the backend).
  • The PR documents what the actual backend contract for this endpoint expects/expected, resolving the "was this ever functional" question raised above.
  • No regression to milestones that are being funded for the first time (a milestone with distributed: 0).

Additional Notes

Precise references:

  • src/app/milestones/MilestoneActions.tsx:9-43 — the full MilestoneFundButton component, handleFund at lines 15-33, no amount state or input anywhere in the component.
  • src/app/milestones/MilestoneActions.tsx:45-88 — PoolDepositButton, the sibling component in the same file with the correct amount-collection pattern this issue asks to mirror.
  • src/app/milestones/page.tsx:28-58 — the milestone card rendering, including the progress bar (m.distributed / m.budget) that establishes incremental/partial funding as the expected mental model for this feature, and :54 where <MilestoneFundButton milestoneId={m.id} /> is rendered with no budget/distributed context passed in at all (worth passing m.budget - m.distributed through as a prop if a remaining-budget cap/default is implemented).
  • src/lib/mock-data.ts:93-114 — mockMilestones, showing both m1 and m2 with distributed meaningfully less than budget, reinforcing that partial/incremental funding is the modeled, expected state, not an edge case.

Relationship to other issues: this issue's amount-validation requirement should reuse whatever comes out of the separate PoolDepositButton amount-validation issue in this batch, rather than duplicating that work independently — sequence or land them together given they touch the same file and the same underlying validation concern.

Test/reproduction plan: render MilestoneFundButton, assert an amount input is present and its value flows into the apiPost call's body when "Fund milestone" is clicked; assert the same invalid-input cases (empty, zero, negative, non-numeric) required of PoolDepositButton are also rejected here.

Activity

  1. added
    bug
    very hard
    Maybe Rewarded
    GrantFox OSS
    Official Campaign | FWC26
    on Aug 16, 2026
  2. added
    Third Campaign
    on Aug 16, 2026
  3. guptakumarranjeet150 commented on Sep 10, 2026

    @guptakumarranjeet150

    Hello! I'd like to work on this issue.

    I would love to take this on. My planned approach:

    • Build MilestoneFundButton has no amount input, making partial milestone funding impossible from the UI with clean React/Next.js components, responsive styling, and proper loading/error boundaries.
    • Add component unit tests and ensure zero TypeScript/ESLint warnings.

    Excited to work on this—please assign to me and I'll submit a clean PR shortly!

  4. added
    Stellar Wave
    on Sep 26, 2026
  5. eriifeomoniyi-hue commented on Sep 26, 2026

    @eriifeomoniyi-hue

    @eriifeomoniyi-hue has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

    I love to work on this issue

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @eriifeomoniyi-hue to this issue.

  6. Darkvader-ship-it commented on Sep 26, 2026

    @Darkvader-ship-it
    Contributor

    @Darkvader-ship-it has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

    hey maintainer can i work on this

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @Darkvader-ship-it to this issue.

  7. drips-wave commented on Sep 26, 2026

    @drips-wave

    Congratulations, @Darkvader-ship-it! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on September 30, 2026.

    🧑‍💻 @Darkvader-ship-it: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.

    Warning

    When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.

    🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.

    🌊 Happy Wave 🌊

  8. grantfox-oss commented on Sep 27, 2026

    @grantfox-oss

    🎉 This issue has been marked as completed on GrantFox!

    @Darkvader-ship-it's PR #567 was approved and merged by @chonilius.

    🏆 @Darkvader-ship-it: You earned 45 FoxPoints for this contribution! Your current tier: Specialist (5,349 total points). Track your full progress on GrantFox.

    👏 Great work, @Darkvader-ship-it! Keep contributing to MergeFi.

  9. drips-wave commented on Sep 27, 2026

    @drips-wave

    This issue has been completed by @Darkvader-ship-it as part of the Stellar Wave Program's 9th Wave 🥳

    😎 @Darkvader-ship-it: You earned 200 Points for completing this issue! After the current Wave ends, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here. You can also Leave a review to share your experience working on this issue.

    🧑‍💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.

  10. removed
    Stellar Wave
    on Oct 15, 2026
  11. added
    Stellar Wave
    on Oct 15, 2026
  12. removed
    Stellar Wave
    on Oct 15, 2026
  13. added
    Stellar Wave
    on Oct 15, 2026
  14. removed
    Stellar Wave
    on Oct 15, 2026
  15. added
    Stellar Wave
    on Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

GrantFox OSSMaybe RewardedOfficial Campaign | FWC26Stellar WaveThird Campaignbugvery hard

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions