Skip to content

[Backend] Wire top-up stream endpoint to Soroban contract #415

@ogazboiz

Description

@ogazboiz

https://t.me/+DOylgFv1jyJlNzM0

Description

The smart contract has a top_up_stream function allowing the sender to add more tokens to a running stream, but the backend has no corresponding POST /streams/:streamId/top-up route in v1. Adding this endpoint unlocks a key use-case: streams that are close to being depleted can be refuelled without cancellation. The handler should validate the caller, accept an amount in the body, call sorobanService.topUpStream(), and return the txHash.

Acceptance Criteria

  • POST /api/v1/streams/:streamId/top-up route exists and is registered
  • Request body contains amount (positive integer, XLM stroops); validation returns 400 on invalid input
  • Endpoint verifies JWT/SIWX; only the stream sender may top up
  • sorobanService.topUpStream(streamId, amount, callerAddress) called; txHash returned
  • DB deposit_amount / remaining_balance fields updated on success
  • Covered by at least one integration test

Files to Touch

  • app/api/routes/v1/streams/ — add top-up.ts handler
  • app/services/soroban.service.ts — expose topUpStream method
  • app/api/routes/v1/streams/index.ts — register route
  • app/repositories/stream.repository.tsupdateBalance helper
  • tests/integration/streams/top-up.test.ts

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programbackendBackend related tasks

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions