Skip to content

Feature: add a stream cancellation preview endpoint — no way to see the refund split before cancelling #7

Description

@ijeoma270

When a stream gets cancelled, the deposit gets split between sender and recipient based on how much time has elapsed, the on-chain event already carries that split. But there's no way to see that split ahead of time. On the frontend, the cancel button on the stream detail page just fires a placeholder toast right now, it doesn't show the sender anything about what they or the recipient would actually walk away with.

Add a read-only preview endpoint that takes a stream and, based on its rate, start time, stop time and what's already been withdrawn, works out what the recipient would get and what would go back to the sender if it were cancelled right now. Use the same elapsed-time math the frontend already has in useStreamBalance and the progress calculation on the stream card, so the preview and what the UI shows never disagree. Should 404 for a stream that doesn't exist, and return a clear error if the stream's already cancelled or completed. Important that this only reads, it shouldn't touch any stream state.

Relevant files are streams.service.ts and streams.controller.ts on the backend, and the stream detail page plus useStreamBalance on the frontend for the math to match.

Before submitting your PR, make sure all checks pass locally and the build succeeds. Each issue will be thoroughly reviewed and only merged if it fully meets the requirements. In your PR, specify the issue number and title, and include tests for a stream that hasn't started yet, one mid-stream, and one past its stop time. On the issue, comment tagging the author to let them know you're working on it. On the PR, tag the maintainer to notify that review is ready.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions