@drift-labs/sdk 2.31.1-beta.8 → 2.31.1-beta.9
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/driftClient.d.ts +2 -1
- package/lib/driftClient.js +8 -2
- package/lib/idl/drift.json +1 -1
- package/package.json +1 -1
- package/src/driftClient.ts +10 -2
- package/src/idl/drift.json +1 -1
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.31.1-beta.
|
|
1
|
+
2.31.1-beta.9
|
package/lib/driftClient.d.ts
CHANGED
|
@@ -124,6 +124,7 @@ export declare class DriftClient {
|
|
|
124
124
|
getReferrerNameAccountsForAuthority(authority: PublicKey): Promise<ReferrerNameAccount[]>;
|
|
125
125
|
deleteUser(subAccountId?: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
126
126
|
getUser(subAccountId?: number, authority?: PublicKey): User;
|
|
127
|
+
hasUser(subAccountId?: number, authority?: PublicKey): boolean;
|
|
127
128
|
getUsers(): User[];
|
|
128
129
|
getUserStats(): UserStats;
|
|
129
130
|
fetchReferrerNameAccount(name: string): Promise<ReferrerNameAccount | undefined>;
|
|
@@ -191,7 +192,7 @@ export declare class DriftClient {
|
|
|
191
192
|
private getWrappedSolAccountCreationIxs;
|
|
192
193
|
getAssociatedTokenAccountCreationIx(tokenMintAddress: PublicKey, associatedTokenAddress: PublicKey): anchor.web3.TransactionInstruction;
|
|
193
194
|
/**
|
|
194
|
-
* Creates the
|
|
195
|
+
* Creates the User account for a user, and deposits some initial collateral
|
|
195
196
|
* @param amount
|
|
196
197
|
* @param userTokenAccount
|
|
197
198
|
* @param marketIndex
|
package/lib/driftClient.js
CHANGED
|
@@ -624,10 +624,16 @@ class DriftClient {
|
|
|
624
624
|
authority = authority !== null && authority !== void 0 ? authority : this.authority;
|
|
625
625
|
const userMapKey = this.getUserMapKey(subAccountId, authority);
|
|
626
626
|
if (!this.users.has(userMapKey)) {
|
|
627
|
-
throw new Error(`
|
|
627
|
+
throw new Error(`DriftClient has no user for user id ${userMapKey}`);
|
|
628
628
|
}
|
|
629
629
|
return this.users.get(userMapKey);
|
|
630
630
|
}
|
|
631
|
+
hasUser(subAccountId, authority) {
|
|
632
|
+
subAccountId = subAccountId !== null && subAccountId !== void 0 ? subAccountId : this.activeSubAccountId;
|
|
633
|
+
authority = authority !== null && authority !== void 0 ? authority : this.authority;
|
|
634
|
+
const userMapKey = this.getUserMapKey(subAccountId, authority);
|
|
635
|
+
return this.users.has(userMapKey);
|
|
636
|
+
}
|
|
631
637
|
getUsers() {
|
|
632
638
|
// delegate users get added to the end
|
|
633
639
|
return [...this.users.values()]
|
|
@@ -1082,7 +1088,7 @@ class DriftClient {
|
|
|
1082
1088
|
return (0, spl_token_1.createAssociatedTokenAccountInstruction)(this.wallet.publicKey, associatedTokenAddress, this.wallet.publicKey, tokenMintAddress);
|
|
1083
1089
|
}
|
|
1084
1090
|
/**
|
|
1085
|
-
* Creates the
|
|
1091
|
+
* Creates the User account for a user, and deposits some initial collateral
|
|
1086
1092
|
* @param amount
|
|
1087
1093
|
* @param userTokenAccount
|
|
1088
1094
|
* @param marketIndex
|
package/lib/idl/drift.json
CHANGED
package/package.json
CHANGED
package/src/driftClient.ts
CHANGED
|
@@ -1050,11 +1050,19 @@ export class DriftClient {
|
|
|
1050
1050
|
const userMapKey = this.getUserMapKey(subAccountId, authority);
|
|
1051
1051
|
|
|
1052
1052
|
if (!this.users.has(userMapKey)) {
|
|
1053
|
-
throw new Error(`
|
|
1053
|
+
throw new Error(`DriftClient has no user for user id ${userMapKey}`);
|
|
1054
1054
|
}
|
|
1055
1055
|
return this.users.get(userMapKey);
|
|
1056
1056
|
}
|
|
1057
1057
|
|
|
1058
|
+
public hasUser(subAccountId?: number, authority?: PublicKey): boolean {
|
|
1059
|
+
subAccountId = subAccountId ?? this.activeSubAccountId;
|
|
1060
|
+
authority = authority ?? this.authority;
|
|
1061
|
+
const userMapKey = this.getUserMapKey(subAccountId, authority);
|
|
1062
|
+
|
|
1063
|
+
return this.users.has(userMapKey);
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1058
1066
|
public getUsers(): User[] {
|
|
1059
1067
|
// delegate users get added to the end
|
|
1060
1068
|
return [...this.users.values()]
|
|
@@ -1712,7 +1720,7 @@ export class DriftClient {
|
|
|
1712
1720
|
}
|
|
1713
1721
|
|
|
1714
1722
|
/**
|
|
1715
|
-
* Creates the
|
|
1723
|
+
* Creates the User account for a user, and deposits some initial collateral
|
|
1716
1724
|
* @param amount
|
|
1717
1725
|
* @param userTokenAccount
|
|
1718
1726
|
* @param marketIndex
|
package/src/idl/drift.json
CHANGED