UNPKG

@bsv/wallet-toolbox

Version:

BRC100 conforming wallet, wallet storage and wallet signer components

57 lines 2.15 kB
/** * Client for Arcade transaction status updates. * * Uses react-native-sse EventSource to connect to Arcade's * `GET /events?callbackToken=<token>` endpoint for real-time * status updates via SSE. * * Supports on-demand fetching via fetchEvents() for use on * app open, balance refresh, transaction list view, etc. * The EventSource stays connected between fetches for live updates. */ export interface ArcSSEEvent { txid: string; txStatus: string; timestamp: string; } export interface ArcSSEClientOptions { /** Base URL of the Arcade instance (e.g. "https://arcade-us-1.bsvb.tech") */ baseUrl: string; /** Stable per-wallet token matching the X-CallbackToken sent on broadcast */ callbackToken: string; /** Server-level API key for Authorization header (from ArcConfig.apiKey) */ arcApiKey?: string; /** Called for each status event received */ onEvent: (event: ArcSSEEvent) => void; /** Called when a connection error occurs */ onError?: (error: Error) => void; /** Initial lastEventId for catchup */ lastEventId?: string; /** Called whenever lastEventId changes, for persistence to storage */ onLastEventIdChanged?: (lastEventId: string) => void; /** The react-native-sse EventSource class — passed in to avoid import from wallet-toolbox */ EventSourceClass: any; } export declare class ArcSSEClient { private readonly options; private _lastEventId; private es; private readonly url; private connected; private connecting; constructor(options: ArcSSEClientOptions); get lastEventId(): string | undefined; /** * Open the SSE connection. Events will be dispatched via onEvent as they arrive. */ connect(): void; /** Close the connection and clean up */ close(): void; /** * Ensure connection is open. If already connected, this is a no-op. * If not connected, opens a new connection with catchup from lastEventId. * Returns immediately — events arrive asynchronously via onEvent callback. */ fetchEvents(): Promise<number>; } //# sourceMappingURL=ArcSSEClient.d.ts.map