Skip to main content

Class: Events

Service for handling real-time event streaming and socket connections. Manages the global socket connection for transaction status updates.

Constructors

Constructor

new Events(): Events;

Returns

Events

Properties

instance

readonly static instance: Events;

tradeEventEmitterConstructor()

static tradeEventEmitterConstructor: (url) => TradeEventEmitter = EventSocketClient;

Parameters

ParameterType
urlstring

Returns

TradeEventEmitter

Methods

connectEventSocket()

connectEventSocket(bundlerBaseUrl?): Promise<TradeEventEmitter>;

Establishes a global socket connection for real-time event streaming. This connection is shared across all service instances.

Parameters

ParameterTypeDescription
bundlerBaseUrl?stringOptional bundler base URL. If not provided, uses default.

Returns

Promise<TradeEventEmitter>

The connected EventSocketClient.

Example

await eventsService.connectEventSocket();

// Socket is now available for transaction updates

disconnectEventSocket()

disconnectEventSocket(): void;

Disconnects the global socket connection and cleans up resources.

Returns

void


eventSocketConnected()

eventSocketConnected(): boolean;

Checks if the global socket connection is active.

Returns

boolean

True if connected, false otherwise.


registerTxId()

registerTxId(txId, timeoutMs): void;

Registers a transaction ID for waiting and timeout handling.

Parameters

ParameterTypeDescription
txIdstringThe transaction ID to register.
timeoutMsnumberTimeout in milliseconds.

Returns

void


wait()

wait(txId): Promise<{
Data: Record<string, unknown>;
transactionHash: string;
txId: string;
}>;

Waits for a transaction to complete.

Parameters

ParameterTypeDescription
txIdstringThe transaction ID to wait for.

Returns

Promise<{ Data: Record<string, unknown>; transactionHash: string; txId: string; }>

Promise that resolves when the transaction completes.