Repository navigation
feat(react): batch cost estimate, cancel refund, pause flag, resume guard - #1012
Merged
Jaydbrown merged 5 commits intoOct 18, 2026
Conversation
…tate, resume validation Covers four Stellar Wave hook gaps: - useCreateBatchStreams: no way to preview the total deposit of a batch before submitting it (estimateTotalBatchCost). - useCancelStream: the sender's refund is only available inside the nested settlement object; expose estimatedRefund as a top-level field. - usePauseStream: no pause-specific loading flag, so UI cannot show "Pausing Stream..." distinct from resume or cancel. - useResumeStream: resume is submitted even when the stream is active or cancelled, wasting gas on a transaction the contract will reject. These tests are expected to fail on upstream/main until the implementation commit lands.
…uard - useCreateBatchStreams: add estimateTotalBatchCost, which sums every config's depositAmount into stroops via toStroops so the total can be shown before submitting a batch. Pure; no network call. - useCancelStream: expose estimatedRefund at the top level of the result (the sender's unstreamed balance, rate × remaining duration). It is null for open-ended streams, whose funded balance is not known. - usePauseStream: add isPausing, true only while the pause transaction is pending, so UIs can label the button distinctly from resume or cancel. - useResumeStream: reject before any optimistic update or wallet submission when the loaded stream is active or cancelled. Unloaded or partial snapshots are passed through so existing callers are unaffected. Closes conduit-protocol#986 Closes conduit-protocol#987 Closes conduit-protocol#988 Closes conduit-protocol#989
Adds deterministic coverage for the boundaries of the new hook behaviour: - fractional deposit amounts in the batch total - partially accrued refund (time pinned via Date.now) and a fully ended stream, which must refund 0n rather than a negative balance
…uard Adds a "Stream lifecycle helpers" section to docs/react-hooks.md covering the four new hook fields, including the null/unknown cases and that the resume guard does not pre-check streams that have not loaded yet. Adds the matching CHANGELOG entry under Unreleased.
|
@opepraise 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
Resolves four React hook gaps in one PR, as five-stage commits (tests → impl → edge cases → docs).
useCreateBatchStreams: addsestimateTotalBatchCost(configs), which sums everydepositAmountinto stroops viatoStroopsso the treasury total can be shown before submitting. Pure, no network call.useCancelStream: addsestimatedRefund: bigint | nullat the top level of the result (the sender's unstreamed balance).nulluntil the stream loads and for open-ended streams, whose funded balance is not known.usePauseStream: addsisPausing, true only while the pause transaction is pending, so the UI can show "Pausing Stream..." distinct from resume or cancel.useResumeStream:resume()rejects before any optimistic update or wallet submission when the loaded stream is active (paused === false) or cancelled. An unloaded or partial snapshot is passed through, so existing callers are unaffected.Notes for review
estimateTotalBatchCostand its suggested approach namescalculateTotalDeposit. I used the title's name.StreamStatus: the issue suggestsstream.status === StreamStatus.Paused, but no such enum exists in the SDK. The check uses the existingpaused/cancelledbooleans onStreamInfo.Test plan
packages/reacttests:issue-986-987-988-989.test.tsx(new), plus the existinguseStreamLifecycleActionssuite, which exercisesresumewith a mock stream that has nopausedfield.Closes #986
Closes #987
Closes #988
Closes #989