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.

Private order access

Requires @silentswap/sdk 2.2.0 or later. A ticket is public on-chain and is not a read credential. Fresh private quotes include an accessToken; the SDK remembers it and carries it in the returned PrivateOrderReference. Keep the reference private and persist it securely if tracking must survive a reload, or provide orderAccessTokenStore in the SDK configuration. The application can track with that credential without another wallet signature.

Direct HTTP integrations must send Authorization: Bearer <accessToken> to GET /order/:ticket, GET /order/:ticket/events, and POST /order/:ticket/deposit-tx. Never put the token in a URL, log, analytics payload, public link or transaction calldata. Browser SSE uses fetch so this header can be sent; native EventSource cannot send it.

A missing or wrong credential returns HTTP 401 with order_access_required. For legacy orders, an authenticated Activity session belonging to the recorded EVM signer can recover access. A public ticket or a claimed sender address is insufficient. Old orders created with an ephemeral signer and no saved credential cannot recover tracking this way; this does not change processing or on-chain refund rights. Existing integrations must upgrade to 2.2.0+ or send the header from their HTTP calls.

The credential authorizes that order's reads and deposit-hash notification; it cannot sign or spend funds. It persists across wallet disconnects and expires on server secret rotation, not Activity sign-out. Treat a saved reference as private browser/app data. Clearing saved data loses access unless owner recovery is available.

Estimated payouts

While state.payoutsAreEstimates is true, the order is exact-input and still awaiting its deposit: every payout figure is a preview that the gateway event's credited amount will resize pro-rata. Render amounts with "≈" until the flag clears, so a number that is about to move is never shown as final.

import type { OrderState } from '@silentswap/sdk';
 
export function formatPayout(state: OrderState, amount: string): string {
  return state.payoutsAreEstimates ? `≈ ${amount}` : amount;
}

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