Skip to content

feat(donate): add a Max button with a fee reserve - #285

Merged
github-actions[bot] merged 1 commit into
StreamGive:mainfrom
Favourof:feat/donate-max-button
Oct 18, 2026
Merged

github-actions[bot] merged 1 commit into
StreamGive:mainfrom
Favourof:feat/donate-max-button

Conversation

@Favourof

Copy link
Copy Markdown
Contributor

Description

close #237.

The donation form previously lacked a "Max" button. Additionally, the insufficient balance validation did not account for the native XLM network fee or minimum base account reserve. If a donor tried to stream their entire XLM balance, the frontend check would pass but the transaction would fail on-chain during signing/submission.

This PR introduces a "Max" quick-fill button and reserves a safe balance buffer for native XLM transactions.

Changes

  • In src/lib/stellar.ts:
    • Exported NATIVE_ACCOUNT_RESERVE = 10_000_000n (1.0 XLM).
    • Exported NATIVE_FEE_ESTIMATE = 1_000_000n (0.1 XLM).
    • Exported NATIVE_FEE_RESERVE = 11_000_000n (1.1 XLM buffer).
  • In src/lib/format.ts:
    • Added and exported formatAmountInput(raw: bigint, decimals: number).
  • In src/components/donate/CreateStreamForm.tsx:
    • Added a "Max" button next to the existing preset buttons.
    • For native XLM, clicking "Max" deducts NATIVE_FEE_RESERVE so the account retains necessary reserve and fee funds.
    • Updated the balance check so users attempting to deposit more than balance - NATIVE_FEE_RESERVE are warned about insufficient reserve buffer before signing.
    • For non-native/custom tokens, "Max" populates the entire token balance scaled by token decimals.
  • Added test coverage in:
    • src/lib/format.test.ts: Added unit tests for formatAmountInput.
    • src/components/donate/CreateStreamForm.test.tsx: Added tests for native fee reserve deduction, non-native token max balance, and boundary conditions.

How to Test

  1. Run npx vitest run src/components/donate/CreateStreamForm.test.tsx src/lib/format.test.ts.
  2. Connect a wallet and verify clicking "Max" with XLM reserves 1.1 XLM.
  3. Switch to a custom token and verify "Max" fills the full token balance.

@vercel

vercel Bot commented Oct 18, 2026

Copy link
Copy Markdown

@Favourof is attempting to deploy a commit to the Ashborne team Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Oct 18, 2026

Copy link
Copy Markdown

@Favourof 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

@github-actions
github-actions Bot merged commit 1f7d10d into StreamGive:main Oct 18, 2026
1 of 3 checks passed
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.

Add a Max button to the donate form that leaves a fee reserve

1 participant