@drift-labs/sdk 2.63.0-beta.3 → 2.63.0-beta.4

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.63.0-beta.3
1
+ 2.63.0-beta.4
@@ -1,4 +1,4 @@
1
- import { User, DriftClient, UserAccount, OrderRecord, WrappedEvent, DLOB } from '..';
1
+ import { User, DriftClient, UserAccount, OrderRecord, WrappedEvent, DLOB, UserSubscriptionConfig } from '..';
2
2
  import { PublicKey } from '@solana/web3.js';
3
3
  import { UserAccountFilterCriteria as UserFilterCriteria, UserMapConfig } from './userMapConfig';
4
4
  export interface UserMapInterface {
@@ -31,7 +31,7 @@ export declare class UserMap implements UserMapInterface {
31
31
  */
32
32
  constructor(config: UserMapConfig);
33
33
  subscribe(): Promise<void>;
34
- addPubkey(userAccountPublicKey: PublicKey, userAccount?: UserAccount, slot?: number): Promise<void>;
34
+ addPubkey(userAccountPublicKey: PublicKey, userAccount?: UserAccount, slot?: number, accountSubscription?: UserSubscriptionConfig): Promise<void>;
35
35
  has(key: string): boolean;
36
36
  /**
37
37
  * gets the User for a particular userAccountPublicKey, if no User exists, undefined is returned
@@ -44,7 +44,7 @@ export declare class UserMap implements UserMapInterface {
44
44
  * @param key userAccountPublicKey to get User for
45
45
  * @returns User
46
46
  */
47
- mustGet(key: string): Promise<User>;
47
+ mustGet(key: string, accountSubscription?: UserSubscriptionConfig): Promise<User>;
48
48
  /**
49
49
  * gets the Authority for a particular userAccountPublicKey, if no User exists, undefined is returned
50
50
  * @param key userAccountPublicKey to get User for
@@ -72,11 +72,11 @@ class UserMap {
72
72
  }
73
73
  await this.subscription.subscribe();
74
74
  }
75
- async addPubkey(userAccountPublicKey, userAccount, slot) {
75
+ async addPubkey(userAccountPublicKey, userAccount, slot, accountSubscription) {
76
76
  const user = new __1.User({
77
77
  driftClient: this.driftClient,
78
78
  userAccountPublicKey,
79
- accountSubscription: {
79
+ accountSubscription: accountSubscription !== null && accountSubscription !== void 0 ? accountSubscription : {
80
80
  type: 'custom',
81
81
  userAccountSubscriber: new __1.OneShotUserAccountSubscriber(this.driftClient.program, userAccountPublicKey, userAccount, slot, this.commitment),
82
82
  },
@@ -100,9 +100,9 @@ class UserMap {
100
100
  * @param key userAccountPublicKey to get User for
101
101
  * @returns User
102
102
  */
103
- async mustGet(key) {
103
+ async mustGet(key, accountSubscription) {
104
104
  if (!this.has(key)) {
105
- await this.addPubkey(new web3_js_1.PublicKey(key));
105
+ await this.addPubkey(new web3_js_1.PublicKey(key), undefined, undefined, accountSubscription);
106
106
  }
107
107
  const user = this.userMap.get(key);
108
108
  return user;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.63.0-beta.3",
3
+ "version": "2.63.0-beta.4",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -15,6 +15,7 @@ import {
15
15
  DLOB,
16
16
  OneShotUserAccountSubscriber,
17
17
  BN,
18
+ UserSubscriptionConfig,
18
19
  } from '..';
19
20
 
20
21
  import {
@@ -131,12 +132,13 @@ export class UserMap implements UserMapInterface {
131
132
  public async addPubkey(
132
133
  userAccountPublicKey: PublicKey,
133
134
  userAccount?: UserAccount,
134
- slot?: number
135
+ slot?: number,
136
+ accountSubscription?: UserSubscriptionConfig
135
137
  ) {
136
138
  const user = new User({
137
139
  driftClient: this.driftClient,
138
140
  userAccountPublicKey,
139
- accountSubscription: {
141
+ accountSubscription: accountSubscription ?? {
140
142
  type: 'custom',
141
143
  userAccountSubscriber: new OneShotUserAccountSubscriber(
142
144
  this.driftClient.program,
@@ -169,9 +171,17 @@ export class UserMap implements UserMapInterface {
169
171
  * @param key userAccountPublicKey to get User for
170
172
  * @returns User
171
173
  */
172
- public async mustGet(key: string): Promise<User> {
174
+ public async mustGet(
175
+ key: string,
176
+ accountSubscription?: UserSubscriptionConfig
177
+ ): Promise<User> {
173
178
  if (!this.has(key)) {
174
- await this.addPubkey(new PublicKey(key));
179
+ await this.addPubkey(
180
+ new PublicKey(key),
181
+ undefined,
182
+ undefined,
183
+ accountSubscription
184
+ );
175
185
  }
176
186
  const user = this.userMap.get(key);
177
187
  return user;