@drift-labs/sdk 2.65.0-beta.5 → 2.65.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.65.0-beta.5
1
+ 2.65.0-beta.6
@@ -4,7 +4,7 @@ import { UserAccountFilterCriteria as UserFilterCriteria, UserMapConfig } from '
4
4
  export interface UserMapInterface {
5
5
  subscribe(): Promise<void>;
6
6
  unsubscribe(): Promise<void>;
7
- addPubkey(userAccountPublicKey: PublicKey): Promise<void>;
7
+ addPubkey(userAccountPublicKey: PublicKey, userAccount?: UserAccount, slot?: number, accountSubscription?: UserSubscriptionConfig): Promise<void>;
8
8
  has(key: string): boolean;
9
9
  get(key: string): User | undefined;
10
10
  getWithSlot(key: string): DataAndSlot<User> | undefined;
@@ -73,19 +73,16 @@ class UserMap {
73
73
  await this.subscription.subscribe();
74
74
  }
75
75
  async addPubkey(userAccountPublicKey, userAccount, slot, accountSubscription) {
76
- var _a;
76
+ var _a, _b;
77
77
  const user = new __1.User({
78
78
  driftClient: this.driftClient,
79
79
  userAccountPublicKey,
80
- accountSubscription: accountSubscription !== null && accountSubscription !== void 0 ? accountSubscription : {
81
- type: 'custom',
82
- userAccountSubscriber: new __1.OneShotUserAccountSubscriber(this.driftClient.program, userAccountPublicKey, userAccount, slot, this.commitment),
83
- },
80
+ accountSubscription: accountSubscription !== null && accountSubscription !== void 0 ? accountSubscription : this.driftClient.userAccountSubscriptionConfig,
84
81
  });
85
82
  await user.subscribe(userAccount);
86
83
  this.userMap.set(userAccountPublicKey.toString(), {
87
84
  data: user,
88
- slot: (_a = user.getUserAccountAndSlot().slot) !== null && _a !== void 0 ? _a : -1,
85
+ slot: (_b = (_a = user.getUserAccountAndSlot().slot) !== null && _a !== void 0 ? _a : slot) !== null && _b !== void 0 ? _b : -1,
89
86
  });
90
87
  }
91
88
  has(key) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.65.0-beta.5",
3
+ "version": "2.65.0-beta.6",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -13,7 +13,6 @@ import {
13
13
  LPRecord,
14
14
  StateAccount,
15
15
  DLOB,
16
- OneShotUserAccountSubscriber,
17
16
  BN,
18
17
  UserSubscriptionConfig,
19
18
  DataAndSlot,
@@ -38,7 +37,12 @@ import { decodeUser } from '../decode/user';
38
37
  export interface UserMapInterface {
39
38
  subscribe(): Promise<void>;
40
39
  unsubscribe(): Promise<void>;
41
- addPubkey(userAccountPublicKey: PublicKey): Promise<void>;
40
+ addPubkey(
41
+ userAccountPublicKey: PublicKey,
42
+ userAccount?: UserAccount,
43
+ slot?: number,
44
+ accountSubscription?: UserSubscriptionConfig
45
+ ): Promise<void>;
42
46
  has(key: string): boolean;
43
47
  get(key: string): User | undefined;
44
48
  getWithSlot(key: string): DataAndSlot<User> | undefined;
@@ -150,21 +154,13 @@ export class UserMap implements UserMapInterface {
150
154
  const user = new User({
151
155
  driftClient: this.driftClient,
152
156
  userAccountPublicKey,
153
- accountSubscription: accountSubscription ?? {
154
- type: 'custom',
155
- userAccountSubscriber: new OneShotUserAccountSubscriber(
156
- this.driftClient.program,
157
- userAccountPublicKey,
158
- userAccount,
159
- slot,
160
- this.commitment
161
- ),
162
- },
157
+ accountSubscription:
158
+ accountSubscription ?? this.driftClient.userAccountSubscriptionConfig,
163
159
  });
164
160
  await user.subscribe(userAccount);
165
161
  this.userMap.set(userAccountPublicKey.toString(), {
166
162
  data: user,
167
- slot: user.getUserAccountAndSlot().slot ?? -1,
163
+ slot: user.getUserAccountAndSlot().slot ?? slot ?? -1,
168
164
  });
169
165
  }
170
166