@drift-labs/sdk 2.65.0-beta.3 → 2.65.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 +1 -1
- package/lib/userMap/userMap.d.ts +2 -0
- package/lib/userMap/userMap.js +6 -0
- package/package.json +1 -1
- package/src/userMap/userMap.ts +15 -0
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.65.0-beta.
|
|
1
|
+
2.65.0-beta.4
|
package/lib/userMap/userMap.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export interface UserMapInterface {
|
|
|
9
9
|
get(key: string): User | undefined;
|
|
10
10
|
getWithSlot(key: string): DataAndSlot<User> | undefined;
|
|
11
11
|
mustGet(key: string): Promise<User>;
|
|
12
|
+
mustGetWithSlot(key: string): Promise<DataAndSlot<User>>;
|
|
12
13
|
getUserAuthority(key: string): PublicKey | undefined;
|
|
13
14
|
updateWithOrderRecord(record: OrderRecord): Promise<void>;
|
|
14
15
|
values(): IterableIterator<User>;
|
|
@@ -50,6 +51,7 @@ export declare class UserMap implements UserMapInterface {
|
|
|
50
51
|
* @returns User
|
|
51
52
|
*/
|
|
52
53
|
mustGet(key: string, accountSubscription?: UserSubscriptionConfig): Promise<User>;
|
|
54
|
+
mustGetWithSlot(key: string, accountSubscription?: UserSubscriptionConfig): Promise<DataAndSlot<User>>;
|
|
53
55
|
/**
|
|
54
56
|
* gets the Authority for a particular userAccountPublicKey, if no User exists, undefined is returned
|
|
55
57
|
* @param key userAccountPublicKey to get User for
|
package/lib/userMap/userMap.js
CHANGED
|
@@ -113,6 +113,12 @@ class UserMap {
|
|
|
113
113
|
}
|
|
114
114
|
return this.userMap.get(key).data;
|
|
115
115
|
}
|
|
116
|
+
async mustGetWithSlot(key, accountSubscription) {
|
|
117
|
+
if (!this.has(key)) {
|
|
118
|
+
await this.addPubkey(new web3_js_1.PublicKey(key), undefined, undefined, accountSubscription);
|
|
119
|
+
}
|
|
120
|
+
return this.userMap.get(key);
|
|
121
|
+
}
|
|
116
122
|
/**
|
|
117
123
|
* gets the Authority for a particular userAccountPublicKey, if no User exists, undefined is returned
|
|
118
124
|
* @param key userAccountPublicKey to get User for
|
package/package.json
CHANGED
package/src/userMap/userMap.ts
CHANGED
|
@@ -43,6 +43,7 @@ export interface UserMapInterface {
|
|
|
43
43
|
get(key: string): User | undefined;
|
|
44
44
|
getWithSlot(key: string): DataAndSlot<User> | undefined;
|
|
45
45
|
mustGet(key: string): Promise<User>;
|
|
46
|
+
mustGetWithSlot(key: string): Promise<DataAndSlot<User>>;
|
|
46
47
|
getUserAuthority(key: string): PublicKey | undefined;
|
|
47
48
|
updateWithOrderRecord(record: OrderRecord): Promise<void>;
|
|
48
49
|
values(): IterableIterator<User>;
|
|
@@ -196,6 +197,20 @@ export class UserMap implements UserMapInterface {
|
|
|
196
197
|
}
|
|
197
198
|
return this.userMap.get(key).data;
|
|
198
199
|
}
|
|
200
|
+
public async mustGetWithSlot(
|
|
201
|
+
key: string,
|
|
202
|
+
accountSubscription?: UserSubscriptionConfig
|
|
203
|
+
): Promise<DataAndSlot<User>> {
|
|
204
|
+
if (!this.has(key)) {
|
|
205
|
+
await this.addPubkey(
|
|
206
|
+
new PublicKey(key),
|
|
207
|
+
undefined,
|
|
208
|
+
undefined,
|
|
209
|
+
accountSubscription
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
return this.userMap.get(key);
|
|
213
|
+
}
|
|
199
214
|
|
|
200
215
|
/**
|
|
201
216
|
* gets the Authority for a particular userAccountPublicKey, if no User exists, undefined is returned
|