Skip to content

Tracking

trackOrderViaWebSocket accepts a serializable reference and emits the current state plus later status or transaction-hash changes. The compatibility name is stable; private mode uses browser SSE with a polling backstop, while Simple Bridge uses status polling.

import type {
  PrivateOrderReference,
  SilentSwapClient,
} from '@silentswap/sdk';
 
declare const client: SilentSwapClient;
declare const reference: PrivateOrderReference;
 
const unsubscribe = client.trackOrderViaWebSocket(
  reference,
  (state) => {
    console.log(state.status);
  },
  (error: unknown) => {
    console.error('tracking failed', error);
  },
);
 
unsubscribe;

Store and call unsubscribe when the owning screen unmounts. The watcher also closes on COMPLETED, FAILED, or ABORTED, and after its two-hour safety limit. It deliberately keeps watching DROPPED orders because a late source-chain deposit can resurrect them to OPEN.

Use getOrder(reference) for one-shot private recovery after navigation. Do not start a second custom polling loop beside trackOrderViaWebSocket.