Skip to content

feat(sdk): implement subscribeToContract with WebSocket reconnect #19

@Depo-dev

Description

@Depo-dev

Summary

TridentClient.subscribeToContract throws "not yet implemented". Needs a real WebSocket connection with automatic reconnect and clean unsubscribe.

Acceptance Criteria

  • Connect to {apiUrl}/ws?contractId=...&topic0=... (replace https:// with wss://)
  • Call onEvent(event: SorobanEvent) callback for each received message
  • Validate inbound messages with SorobanEvent Zod schema; log and skip invalid frames
  • Auto-reconnect with exponential backoff (500ms initial, 30s max) on unexpected close
  • Subscription.unsubscribe() closes the socket and cancels reconnect
  • Call onError(err) callback on parse errors or terminal failures

Files

sdk/typescript/src/index.ts, sdk/typescript/src/subscription.ts (new)

Metadata

Metadata

Assignees

No one assigned

    Labels

    phase-1MVP phase 1 scopetypescriptTypeScript SDK work

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions