@drift-labs/sdk 2.48.0-beta.23 → 2.48.0-beta.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/VERSION CHANGED
@@ -1 +1 @@
1
- 2.48.0-beta.23
1
+ 2.48.0-beta.25
@@ -39,6 +39,10 @@ class WebSocketLogProvider {
39
39
  this.receivingData = true;
40
40
  clearTimeout(this.timeoutId);
41
41
  this.setTimeout();
42
+ if (this.reconnectAttempts > 0) {
43
+ console.log('Resetting reconnect attempts to 0');
44
+ }
45
+ this.reconnectAttempts = 0;
42
46
  }
43
47
  callback(logs.signature, ctx.slot, logs.logs, undefined);
44
48
  }, this.commitment);
@@ -8,6 +8,7 @@ const DLOB_1 = require("../dlob/DLOB");
8
8
  const PollingSubscription_1 = require("./PollingSubscription");
9
9
  const WebsocketSubscription_1 = require("./WebsocketSubscription");
10
10
  const events_1 = require("events");
11
+ const index_1 = require("../index");
11
12
  class OrderSubscriber {
12
13
  constructor(config) {
13
14
  this.usersAccounts = new Map();
@@ -85,6 +86,10 @@ class OrderSubscriber {
85
86
  if (dataType === 'raw') {
86
87
  // @ts-ignore
87
88
  const buffer = buffer_1.Buffer.from(data[0], data[1]);
89
+ const newLastActiveSlot = new index_1.BN(buffer.subarray(4328, 4328 + 8), undefined, 'le');
90
+ if (slotAndUserAccount.userAccount.lastActiveSlot.gt(newLastActiveSlot)) {
91
+ return;
92
+ }
88
93
  userAccount =
89
94
  this.driftClient.program.account.user.coder.accounts.decodeUnchecked('User', buffer);
90
95
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.48.0-beta.23",
3
+ "version": "2.48.0-beta.25",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -50,6 +50,10 @@ export class WebSocketLogProvider implements LogProvider {
50
50
  this.receivingData = true;
51
51
  clearTimeout(this.timeoutId);
52
52
  this.setTimeout();
53
+ if (this.reconnectAttempts > 0) {
54
+ console.log('Resetting reconnect attempts to 0');
55
+ }
56
+ this.reconnectAttempts = 0;
53
57
  }
54
58
  callback(logs.signature, ctx.slot, logs.logs, undefined);
55
59
  },
@@ -9,6 +9,7 @@ import { PollingSubscription } from './PollingSubscription';
9
9
  import { WebsocketSubscription } from './WebsocketSubscription';
10
10
  import StrictEventEmitter from 'strict-event-emitter-types';
11
11
  import { EventEmitter } from 'events';
12
+ import { BN } from '../index';
12
13
 
13
14
  export class OrderSubscriber {
14
15
  driftClient: DriftClient;
@@ -126,6 +127,17 @@ export class OrderSubscriber {
126
127
  // @ts-ignore
127
128
  const buffer = Buffer.from(data[0], data[1]);
128
129
 
130
+ const newLastActiveSlot = new BN(
131
+ buffer.subarray(4328, 4328 + 8),
132
+ undefined,
133
+ 'le'
134
+ );
135
+ if (
136
+ slotAndUserAccount.userAccount.lastActiveSlot.gt(newLastActiveSlot)
137
+ ) {
138
+ return;
139
+ }
140
+
129
141
  userAccount =
130
142
  this.driftClient.program.account.user.coder.accounts.decodeUnchecked(
131
143
  'User',