Skip to content

feat(react): batch cost estimate, cancel refund, pause flag, resume guard - #1012

Merged
Jaydbrown merged 5 commits into
conduit-protocol:mainfrom
opepraise:feat/react-hooks-batch-cost-cancel-refund-pause-resume
Oct 18, 2026
Merged

Jaydbrown merged 5 commits into
conduit-protocol:mainfrom
opepraise:feat/react-hooks-batch-cost-cancel-refund-pause-resume

Conversation

@opepraise

@opepraise opepraise commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Resolves four React hook gaps in one PR, as five-stage commits (tests → impl → edge cases → docs).

Notes for review

Test plan

  • packages/react tests: issue-986-987-988-989.test.tsx (new), plus the existing useStreamLifecycleActions suite, which exercises resume with a mock stream that has no paused field.
  • Typecheck and lint, which were not run for this PR.

Closes #986
Closes #987
Closes #988
Closes #989

…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.
@drips-wave

drips-wave Bot commented Oct 18, 2026

Copy link
Copy Markdown

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

Learn more about application limits

@Jaydbrown
Jaydbrown merged commit 9a10eb7 into conduit-protocol:main Oct 18, 2026
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment