[Contracts] Add get_remaining_balance(stream_id) read-only view function to stream contract
Overview
Callers inspecting a stream via contracts/stream_contract/src/lib.rs can query get_stream(stream_id) and get_claimable(stream_id), but there is no direct view helper to query the unwithdrawn remaining token balance (deposited_amount - withdrawn_amount).
Problem
- External contracts and off-chain clients frequently need a lightweight read call to check how many tokens remain locked in a stream.
Proposed Changes
- Add
pub fn get_remaining_balance(env: Env, stream_id: u64) -> Result<i128, ContractError>toStreamContractincontracts/stream_contract/src/lib.rs. - Return
0if the stream is already cancelled/completed, orstream.deposited_amount.saturating_sub(stream.withdrawn_amount).
Acceptance Criteria
- [ ] Returns accurate remaining balance before, during, and after partial withdrawals.
- [ ] Returns
ContractError::StreamNotFoundfor non-existent stream IDs. - [ ] Unit test added in
contracts/stream_contract/src/test.rs.
@elonwachineke-dot has applied to work on this issue as part of the Stellar Wave Program's 10th wave.
Hello maintainer please kindly review my application and assign this issues to me and I will deliver as soon as possible
ℹ️ Repo Maintainers: To accept this application, review their application or assign @elonwachineke-dot to this issue.
@Holer8 has applied to work on this issue as part of the Stellar Wave Program's 10th wave.
Hello Maintainer, I’ve reviewed the issue description and I’m confident I can work on it effectively. Please assign it to me.
ℹ️ Repo Maintainers: To accept this application, review their application or assign @Holer8 to this issue.
@ngoziimmaculatar-star has applied to work on this issue as part of the Stellar Wave Program's 10th wave.
Hi Maintainer, I'd like to work on this issue. Could you assign it to me?
ℹ️ Repo Maintainers: To accept this application, review their application or assign @ngoziimmaculatar-star to this issue.
Congratulations, @ngoziimmaculatar-star! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on October 22, 2026.
🧑💻 @ngoziimmaculatar-star: 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 🌊
This issue has been completed by @ngoziimmaculatar-star as part of the Stellar Wave Program's 10th Wave 🥳
😎 @ngoziimmaculatar-star: You earned 200 Points for completing this issue! Once the Wave's rewards are finalized, 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.