Skip to content

Commit

Permalink
ts-sdk: filter out erroneous logs in EventSubscriber (#815)
Browse files Browse the repository at this point in the history
  • Loading branch information
wphan authored Jan 11, 2024
1 parent da1fc8d commit dffa9c5
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions sdk/src/events/webSocketLogProvider.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { LogProvider, logProviderCallback } from './types';
import { Commitment, Connection, PublicKey } from '@solana/web3.js';
import {
Commitment,
Connection,
Context,
Logs,
PublicKey,
} from '@solana/web3.js';
import { EventEmitter } from 'events';

export class WebSocketLogProvider implements LogProvider {
Expand Down Expand Up @@ -45,7 +51,7 @@ export class WebSocketLogProvider implements LogProvider {
public setSubscription(callback: logProviderCallback): void {
this.subscriptionId = this.connection.onLogs(
this.address,
(logs, ctx) => {
(logs: Logs, ctx: Context) => {
if (this.resubTimeoutMs && !this.isUnsubscribing) {
this.receivingData = true;
clearTimeout(this.timeoutId);
Expand All @@ -55,6 +61,9 @@ export class WebSocketLogProvider implements LogProvider {
}
this.reconnectAttempts = 0;
}
if (logs.err !== null) {
return;
}
callback(logs.signature, ctx.slot, logs.logs, undefined);
},
this.commitment
Expand Down

0 comments on commit dffa9c5

Please sign in to comment.