Repository navigation
feat: add streamedTotalLocal and sumStreamedTotal utils - #886
Merged
Jaydbrown merged 2 commits intoOct 1, 2026
Merged
Conversation
|
@Yerimahjr 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
Adds
streamedTotalLocal(stream, nowSec?)andsumStreamedTotal(streams, nowSec?)tosrc/utils.ts, the client-side counterparts ofStreamsModule.streamedTotal(), mirroring the existingwithdrawableLocal/sumWithdrawablepair.Closes #796
Changes
streamedTotalLocal: cumulative amount streamed from aStreamInfosnapshot, with the sameendTime-then-pausedAtclamp order aswithdrawableLocal. UnlikewithdrawableLocal,withdrawnis not subtracted, so the value keeps counting up after withdrawals.sumStreamedTotal: sumsstreamedTotalLocalacross streams./utils; documented indocs/api.mdandCHANGELOG.md.src/tests/utils.test.ts, including a consistency check thatstreamedTotalLocal(s) - withdrawnmatcheswithdrawableLocal(s)so the two can't drift apart.Design note: cancelled streams
StreamInfohas no cancellation timestamp, so the amount streamed up to a cancel can't be projected locally. A cancelled stream reports itswithdrawnamount (a lower bound that never overstates) instead of continuing to accrue.withdrawableLocalreturns 0 for cancelled streams, but 0 would drop already-streamed amounts from a "total streamed" display. Happy to change this if the contract'sstreamed_totalbehaves differently after cancellation.Testing
src/tests/utils.test.ts: 94 passing (19 new).tsc --noEmitclean; eslint on the changed files has no new findings.factory.test.ts,governor.test.tsandrelayer-stress.test.ts(8 tests) occur identically on a cleanupstream/main.