Overview
Add a subscribeInvoice(invoiceId, callback) method to StellarSplitClient that opens a long-lived Soroban event stream and fires the callback on every state change for the given invoice. The subscription must handle reconnection, backpressure, and deduplication of events.
Requirements
client.subscribeInvoice(invoiceId: bigint, callback: (event: InvoiceEvent) => void): Subscription
Subscription type with .unsubscribe() method to cancel the stream
- Use Soroban
getEvents RPC polling with a configurable pollIntervalMs (default 3000ms)
- Deduplicate events by ledger sequence + topic hash to prevent duplicate callbacks
- Automatic reconnection with exponential backoff (max 5 retries, then emit
error event)
- Export
InvoiceEvent union type covering all contract event types
- Write unit tests with a mock RPC server using
msw (Mock Service Worker)
- Test: normal event stream, deduplication, reconnect after failure, unsubscribe stops polling
Acceptance Criteria
Definition of Done
All CI checks must pass before the PR is reviewed.
Overview
Add a
subscribeInvoice(invoiceId, callback)method toStellarSplitClientthat opens a long-lived Soroban event stream and fires the callback on every state change for the given invoice. The subscription must handle reconnection, backpressure, and deduplication of events.Requirements
client.subscribeInvoice(invoiceId: bigint, callback: (event: InvoiceEvent) => void): SubscriptionSubscriptiontype with.unsubscribe()method to cancel the streamgetEventsRPC polling with a configurablepollIntervalMs(default 3000ms)errorevent)InvoiceEventunion type covering all contract event typesmsw(Mock Service Worker)Acceptance Criteria
subscribeInvoiceimplemented and exported from the packageunsubscribe()stops polling (no memory leaks)npm testpasses with zero failurestsc --noEmit)Definition of Done
All CI checks must pass before the PR is reviewed.