@drift-labs/sdk 2.85.0-beta.7 → 2.85.0-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
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.85.0-beta.
|
|
1
|
+
2.85.0-beta.9
|
|
@@ -45,23 +45,30 @@ class BlockhashSubscriber {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
async updateBlockhash() {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (
|
|
59
|
-
|
|
60
|
-
|
|
48
|
+
try {
|
|
49
|
+
const [resp, lastConfirmedBlockHeight] = await Promise.all([
|
|
50
|
+
this.connection.getLatestBlockhashAndContext({
|
|
51
|
+
commitment: this.commitment,
|
|
52
|
+
}),
|
|
53
|
+
this.connection.getBlockHeight({ commitment: this.commitment }),
|
|
54
|
+
]);
|
|
55
|
+
this.latestBlockHeight = lastConfirmedBlockHeight;
|
|
56
|
+
this.latestBlockHeightContext = resp.context;
|
|
57
|
+
// avoid caching duplicate blockhashes
|
|
58
|
+
if (this.blockhashes.length > 0) {
|
|
59
|
+
if (resp.value.blockhash ===
|
|
60
|
+
this.blockhashes[this.blockhashes.length - 1].blockhash) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
61
63
|
}
|
|
64
|
+
this.blockhashes.push(resp.value);
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
console.error('Error updating blockhash:\n', e);
|
|
68
|
+
}
|
|
69
|
+
finally {
|
|
70
|
+
this.pruneBlockhashes();
|
|
62
71
|
}
|
|
63
|
-
this.blockhashes.push(resp.value);
|
|
64
|
-
this.pruneBlockhashes();
|
|
65
72
|
}
|
|
66
73
|
async subscribe() {
|
|
67
74
|
if (this.isSubscribed) {
|
package/lib/driftClient.d.ts
CHANGED
|
@@ -293,7 +293,7 @@ export declare class DriftClient {
|
|
|
293
293
|
* @deprecated use {@link placePerpOrder} or {@link placeAndTakePerpOrder} instead
|
|
294
294
|
*/
|
|
295
295
|
openPosition(direction: PositionDirection, amount: BN, marketIndex: number, limitPrice?: BN, subAccountId?: number): Promise<TransactionSignature>;
|
|
296
|
-
sendSignedTx(tx: Transaction, opts?: ConfirmOptions): Promise<TransactionSignature>;
|
|
296
|
+
sendSignedTx(tx: Transaction | VersionedTransaction, opts?: ConfirmOptions): Promise<TransactionSignature>;
|
|
297
297
|
prepareMarketOrderTxs(orderParams: OptionalOrderParams, userAccountPublicKey: PublicKey, userAccount: UserAccount, makerInfo?: MakerInfo | MakerInfo[], txParams?: TxParams, bracketOrdersParams?: OptionalOrderParams[], referrerInfo?: ReferrerInfo, cancelExistingOrders?: boolean, settlePnl?: boolean): Promise<{
|
|
298
298
|
cancelExistingOrdersTx?: Transaction | VersionedTransaction;
|
|
299
299
|
settlePnlTx?: Transaction | VersionedTransaction;
|
package/package.json
CHANGED
|
@@ -75,27 +75,32 @@ export class BlockhashSubscriber {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
async updateBlockhash() {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
if (
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
78
|
+
try {
|
|
79
|
+
const [resp, lastConfirmedBlockHeight] = await Promise.all([
|
|
80
|
+
this.connection.getLatestBlockhashAndContext({
|
|
81
|
+
commitment: this.commitment,
|
|
82
|
+
}),
|
|
83
|
+
this.connection.getBlockHeight({ commitment: this.commitment }),
|
|
84
|
+
]);
|
|
85
|
+
this.latestBlockHeight = lastConfirmedBlockHeight;
|
|
86
|
+
this.latestBlockHeightContext = resp.context;
|
|
87
|
+
|
|
88
|
+
// avoid caching duplicate blockhashes
|
|
89
|
+
if (this.blockhashes.length > 0) {
|
|
90
|
+
if (
|
|
91
|
+
resp.value.blockhash ===
|
|
92
|
+
this.blockhashes[this.blockhashes.length - 1].blockhash
|
|
93
|
+
) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
94
96
|
}
|
|
95
|
-
}
|
|
96
97
|
|
|
97
|
-
|
|
98
|
-
|
|
98
|
+
this.blockhashes.push(resp.value);
|
|
99
|
+
} catch (e) {
|
|
100
|
+
console.error('Error updating blockhash:\n', e);
|
|
101
|
+
} finally {
|
|
102
|
+
this.pruneBlockhashes();
|
|
103
|
+
}
|
|
99
104
|
}
|
|
100
105
|
|
|
101
106
|
async subscribe() {
|
package/src/driftClient.ts
CHANGED
|
@@ -2770,7 +2770,7 @@ export class DriftClient {
|
|
|
2770
2770
|
}
|
|
2771
2771
|
|
|
2772
2772
|
public async sendSignedTx(
|
|
2773
|
-
tx: Transaction,
|
|
2773
|
+
tx: Transaction | VersionedTransaction,
|
|
2774
2774
|
opts?: ConfirmOptions
|
|
2775
2775
|
): Promise<TransactionSignature> {
|
|
2776
2776
|
const { txSig } = await this.sendTransaction(
|