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

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.5
1
+ 2.48.0-beta.6
@@ -67,6 +67,7 @@ export declare class UserMap implements UserMapInterface {
67
67
  updateWithEventRecord(record: WrappedEvent<any>): Promise<void>;
68
68
  values(): IterableIterator<User>;
69
69
  size(): number;
70
+ getUniqueAuthorities(useSyncCallbackCriteria?: boolean): PublicKey[];
70
71
  sync(): Promise<void>;
71
72
  unsubscribe(): Promise<void>;
72
73
  }
@@ -148,6 +148,19 @@ class UserMap {
148
148
  size() {
149
149
  return this.userMap.size;
150
150
  }
151
+ getUniqueAuthorities(useSyncCallbackCriteria = true) {
152
+ const usersMeetingCriteria = Array.from(this.userMap.values()).filter((user) => {
153
+ let pass = true;
154
+ if (useSyncCallbackCriteria &&
155
+ this.syncCallbackCriteria.hasOpenOrders) {
156
+ pass = pass && user.getUserAccount().hasOpenOrder;
157
+ }
158
+ return pass;
159
+ });
160
+ const userAuths = new Set(usersMeetingCriteria.map((user) => user.getUserAccount().authority.toBase58()));
161
+ const userAuthKeys = Array.from(userAuths).map((userAuth) => new web3_js_1.PublicKey(userAuth));
162
+ return userAuthKeys;
163
+ }
151
164
  async sync() {
152
165
  if (this.syncPromise) {
153
166
  return this.syncPromise;
@@ -197,16 +210,7 @@ class UserMap {
197
210
  }
198
211
  }
199
212
  if (this.syncCallback) {
200
- const usersMeetingCriteria = Array.from(this.userMap.values()).filter((user) => {
201
- let pass = true;
202
- if (this.syncCallbackCriteria.hasOpenOrders) {
203
- pass = pass && user.getUserAccount().hasOpenOrder;
204
- }
205
- return pass;
206
- });
207
- const userAuths = new Set(usersMeetingCriteria.map((user) => user.getUserAccount().authority.toBase58()));
208
- const userAuthKeys = Array.from(userAuths).map((userAuth) => new web3_js_1.PublicKey(userAuth));
209
- await this.syncCallback(userAuthKeys);
213
+ await this.syncCallback(this.getUniqueAuthorities());
210
214
  }
211
215
  }
212
216
  catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.48.0-beta.5",
3
+ "version": "2.48.0-beta.6",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -216,6 +216,30 @@ export class UserMap implements UserMapInterface {
216
216
  return this.userMap.size;
217
217
  }
218
218
 
219
+ public getUniqueAuthorities(useSyncCallbackCriteria = true): PublicKey[] {
220
+ const usersMeetingCriteria = Array.from(this.userMap.values()).filter(
221
+ (user) => {
222
+ let pass = true;
223
+ if (
224
+ useSyncCallbackCriteria &&
225
+ this.syncCallbackCriteria.hasOpenOrders
226
+ ) {
227
+ pass = pass && user.getUserAccount().hasOpenOrder;
228
+ }
229
+ return pass;
230
+ }
231
+ );
232
+ const userAuths = new Set(
233
+ usersMeetingCriteria.map((user) =>
234
+ user.getUserAccount().authority.toBase58()
235
+ )
236
+ );
237
+ const userAuthKeys = Array.from(userAuths).map(
238
+ (userAuth) => new PublicKey(userAuth)
239
+ );
240
+ return userAuthKeys;
241
+ }
242
+
219
243
  public async sync() {
220
244
  if (this.syncPromise) {
221
245
  return this.syncPromise;
@@ -296,24 +320,7 @@ export class UserMap implements UserMapInterface {
296
320
  }
297
321
 
298
322
  if (this.syncCallback) {
299
- const usersMeetingCriteria = Array.from(this.userMap.values()).filter(
300
- (user) => {
301
- let pass = true;
302
- if (this.syncCallbackCriteria.hasOpenOrders) {
303
- pass = pass && user.getUserAccount().hasOpenOrder;
304
- }
305
- return pass;
306
- }
307
- );
308
- const userAuths = new Set(
309
- usersMeetingCriteria.map((user) =>
310
- user.getUserAccount().authority.toBase58()
311
- )
312
- );
313
- const userAuthKeys = Array.from(userAuths).map(
314
- (userAuth) => new PublicKey(userAuth)
315
- );
316
- await this.syncCallback(userAuthKeys);
323
+ await this.syncCallback(this.getUniqueAuthorities());
317
324
  }
318
325
  } catch (e) {
319
326
  console.error(`Error in UserMap.sync()`);