Feature/cancel stream endpoint 413#444
Merged
ogazboiz merged 1 commit intoLabsCrypt:mainfrom Apr 30, 2026
Merged
Conversation
Contributor
|
hey, main was failing CI from broken auth imports + frontend parse errors. fixed and pushed to main now. please rebase to pick up the fixes: git fetch upstream
git rebase upstream/main
git push --force-with-leaseif there's a conflict, resolve it locally and we'll review once CI is green. |
a483503 to
dd745ee
Compare
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.
closes #413
This PR implements the
POST /v1/streams/:streamId/cancelendpoint, enabling users to cancel active payment streams directly from the backend. The implementation includes the full workflow from request validation and authorization to on-chain execution via the Soroban RPC and subsequent database state synchronization.Key Changes
1. Soroban Service Enhancement (
backend/src/services/sorobanService.ts)submitContractCall: Introduced a new internal helper to handle the complete lifecycle of a Soroban write transaction:rpc.assembleTransaction.cancelStream: Exposed a method to invoke thecancel_streamfunction on the smart contract for a specificstreamId.2. Controller Implementation (
backend/src/controllers/stream/cancel.ts)cancelStreamHandler: A dedicated controller for the cancellation logic:req.user.publicKey(from JWT/SIWX) matches the stream'ssender.txHash.3. Repository Layer (
backend/src/repositories/stream.repository.ts)updateStatus: A helper function to synchronize the databaseisActiveflag once an on-chain operation succeeds.4. Routing (
backend/src/routes/v1/stream.routes.ts)POST /:streamId/cancelroute.authMiddlewareto ensure only authenticated users can trigger cancellations.5. Testing (
backend/tests/integration/streams/cancel.test.ts)txHash.Acceptance Criteria Verification
POST /api/v1/streams/:streamId/cancelroute is registered and documented.authMiddleware.sorobanService.cancelStream()on-chain.txHashin the JSON response.isActive: false) on success.Environment Requirements
SOROBAN_SECRET_KEY: Must be set in the backend environment to enable transaction signing for on-chain writes.