@drift-labs/sdk 2.48.0-beta.3 → 2.48.0-beta.5

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.3
1
+ 2.48.0-beta.5
package/lib/user.js CHANGED
@@ -22,7 +22,7 @@ class User {
22
22
  this._isSubscribed = val;
23
23
  }
24
24
  constructor(config) {
25
- var _a, _b, _c;
25
+ var _a, _b;
26
26
  this._isSubscribed = false;
27
27
  this.driftClient = config.driftClient;
28
28
  this.userAccountPublicKey = config.userAccountPublicKey;
@@ -32,7 +32,7 @@ class User {
32
32
  else if (((_b = config.accountSubscription) === null || _b === void 0 ? void 0 : _b.type) === 'custom') {
33
33
  this.accountSubscriber = config.accountSubscription.userAccountSubscriber;
34
34
  }
35
- else if (((_c = config.accountSubscription) === null || _c === void 0 ? void 0 : _c.type) === 'websocket') {
35
+ else {
36
36
  this.accountSubscriber = new webSocketUserAccountSubscriber_1.WebSocketUserAccountSubscriber(config.driftClient.program, config.userAccountPublicKey, config.accountSubscription.resubTimeoutMs, config.accountSubscription.commitment);
37
37
  }
38
38
  this.eventEmitter = this.accountSubscriber.eventEmitter;
@@ -35,6 +35,7 @@ export declare class UserMap implements UserMapInterface {
35
35
  * @param {SyncCallbackCriteria} syncCallbackCriteria - The criteria for the sync callback. Defaults to having no filters
36
36
  */
37
37
  constructor(driftClient: DriftClient, accountSubscription: UserSubscriptionConfig, includeIdle?: boolean, syncCallback?: (authorities: PublicKey[]) => Promise<void>, syncCallbackCriteria?: SyncCallbackCriteria);
38
+ addSyncCallback(syncCallback?: (authorities: PublicKey[]) => Promise<void>, syncCallbackCriteria?: SyncCallbackCriteria): void;
38
39
  subscribe(): Promise<void>;
39
40
  addPubkey(userAccountPublicKey: PublicKey, userAccount?: UserAccount): Promise<void>;
40
41
  has(key: string): boolean;
@@ -29,6 +29,10 @@ class UserMap {
29
29
  this.syncCallback = syncCallback;
30
30
  this.syncCallbackCriteria = syncCallbackCriteria;
31
31
  }
32
+ addSyncCallback(syncCallback, syncCallbackCriteria = { hasOpenOrders: false }) {
33
+ this.syncCallback = syncCallback;
34
+ this.syncCallbackCriteria = syncCallbackCriteria;
35
+ }
32
36
  async subscribe() {
33
37
  if (this.size() > 0) {
34
38
  return;
@@ -152,7 +152,6 @@ class UserStatsMap {
152
152
  * You may want to get this list from UserMap in order to filter out idle users
153
153
  */
154
154
  async sync(authorities) {
155
- console.log(`USER MAP SIYCING AUTHS: ${authorities.length}`);
156
155
  await Promise.all(authorities.map((authority) => this.addUserStat(authority, undefined, true)));
157
156
  await this.bulkAccountLoader.load();
158
157
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.48.0-beta.3",
3
+ "version": "2.48.0-beta.5",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
package/src/user.ts CHANGED
@@ -109,7 +109,7 @@ export class User {
109
109
  );
110
110
  } else if (config.accountSubscription?.type === 'custom') {
111
111
  this.accountSubscriber = config.accountSubscription.userAccountSubscriber;
112
- } else if (config.accountSubscription?.type === 'websocket') {
112
+ } else {
113
113
  this.accountSubscriber = new WebSocketUserAccountSubscriber(
114
114
  config.driftClient.program,
115
115
  config.userAccountPublicKey,
@@ -79,6 +79,14 @@ export class UserMap implements UserMapInterface {
79
79
  this.syncCallbackCriteria = syncCallbackCriteria;
80
80
  }
81
81
 
82
+ public addSyncCallback(
83
+ syncCallback?: (authorities: PublicKey[]) => Promise<void>,
84
+ syncCallbackCriteria: SyncCallbackCriteria = { hasOpenOrders: false }
85
+ ) {
86
+ this.syncCallback = syncCallback;
87
+ this.syncCallbackCriteria = syncCallbackCriteria;
88
+ }
89
+
82
90
  public async subscribe() {
83
91
  if (this.size() > 0) {
84
92
  return;
@@ -201,7 +201,6 @@ export class UserStatsMap {
201
201
  * You may want to get this list from UserMap in order to filter out idle users
202
202
  */
203
203
  public async sync(authorities: PublicKey[]) {
204
- console.log(`USER MAP SIYCING AUTHS: ${authorities.length}`);
205
204
  await Promise.all(
206
205
  authorities.map((authority) =>
207
206
  this.addUserStat(authority, undefined, true)