@drift-labs/sdk 2.53.0-beta.6 → 2.53.0-beta.7
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.53.0-beta.
|
|
1
|
+
2.53.0-beta.7
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { TxSigAndSlot } from './types';
|
|
3
|
-
import { ConfirmOptions, Signer, Transaction, Connection, VersionedTransaction, TransactionInstruction, AddressLookupTableAccount } from '@solana/web3.js';
|
|
3
|
+
import { ConfirmOptions, Signer, Transaction, Connection, VersionedTransaction, TransactionInstruction, AddressLookupTableAccount, Commitment } from '@solana/web3.js';
|
|
4
4
|
import { IWallet } from '../types';
|
|
5
5
|
import { BaseTxSender } from './baseTxSender';
|
|
6
6
|
export declare class FastSingleTxSender extends BaseTxSender {
|
|
@@ -13,7 +13,8 @@ export declare class FastSingleTxSender extends BaseTxSender {
|
|
|
13
13
|
timoutCount: number;
|
|
14
14
|
recentBlockhash: string;
|
|
15
15
|
skipConfirmation: boolean;
|
|
16
|
-
|
|
16
|
+
blockhashCommitment: Commitment;
|
|
17
|
+
constructor({ connection, wallet, opts, timeout, blockhashRefreshInterval, additionalConnections, skipConfirmation, blockhashCommitment, }: {
|
|
17
18
|
connection: Connection;
|
|
18
19
|
wallet: IWallet;
|
|
19
20
|
opts?: ConfirmOptions;
|
|
@@ -21,9 +22,10 @@ export declare class FastSingleTxSender extends BaseTxSender {
|
|
|
21
22
|
blockhashRefreshInterval?: number;
|
|
22
23
|
additionalConnections?: any;
|
|
23
24
|
skipConfirmation?: boolean;
|
|
25
|
+
blockhashCommitment?: Commitment;
|
|
24
26
|
});
|
|
25
27
|
startBlockhashRefreshLoop(): void;
|
|
26
|
-
prepareTx(tx: Transaction, additionalSigners: Array<Signer>,
|
|
28
|
+
prepareTx(tx: Transaction, additionalSigners: Array<Signer>, _opts: ConfirmOptions): Promise<Transaction>;
|
|
27
29
|
getVersionedTransaction(ixs: TransactionInstruction[], lookupTableAccounts: AddressLookupTableAccount[], additionalSigners?: Array<Signer>, opts?: ConfirmOptions): Promise<VersionedTransaction>;
|
|
28
30
|
sendRawTransaction(rawTransaction: Buffer | Uint8Array, opts: ConfirmOptions): Promise<TxSigAndSlot>;
|
|
29
31
|
}
|
|
@@ -7,7 +7,7 @@ const baseTxSender_1 = require("./baseTxSender");
|
|
|
7
7
|
const DEFAULT_TIMEOUT = 35000;
|
|
8
8
|
const DEFAULT_BLOCKHASH_REFRESH = 10000;
|
|
9
9
|
class FastSingleTxSender extends baseTxSender_1.BaseTxSender {
|
|
10
|
-
constructor({ connection, wallet, opts = anchor_1.AnchorProvider.defaultOptions(), timeout = DEFAULT_TIMEOUT, blockhashRefreshInterval = DEFAULT_BLOCKHASH_REFRESH, additionalConnections = new Array(), skipConfirmation = false, }) {
|
|
10
|
+
constructor({ connection, wallet, opts = anchor_1.AnchorProvider.defaultOptions(), timeout = DEFAULT_TIMEOUT, blockhashRefreshInterval = DEFAULT_BLOCKHASH_REFRESH, additionalConnections = new Array(), skipConfirmation = false, blockhashCommitment = 'finalized', }) {
|
|
11
11
|
super({ connection, wallet, opts, timeout, additionalConnections });
|
|
12
12
|
this.timoutCount = 0;
|
|
13
13
|
this.connection = connection;
|
|
@@ -17,23 +17,24 @@ class FastSingleTxSender extends baseTxSender_1.BaseTxSender {
|
|
|
17
17
|
this.blockhashRefreshInterval = blockhashRefreshInterval;
|
|
18
18
|
this.additionalConnections = additionalConnections;
|
|
19
19
|
this.skipConfirmation = skipConfirmation;
|
|
20
|
+
this.blockhashCommitment = blockhashCommitment;
|
|
20
21
|
this.startBlockhashRefreshLoop();
|
|
21
22
|
}
|
|
22
23
|
startBlockhashRefreshLoop() {
|
|
23
24
|
setInterval(async () => {
|
|
24
25
|
try {
|
|
25
|
-
this.recentBlockhash = (await this.connection.getLatestBlockhash(this.
|
|
26
|
+
this.recentBlockhash = (await this.connection.getLatestBlockhash(this.blockhashCommitment)).blockhash;
|
|
26
27
|
}
|
|
27
28
|
catch (e) {
|
|
28
29
|
console.error('Error in startBlockhashRefreshLoop: ', e);
|
|
29
30
|
}
|
|
30
31
|
}, this.blockhashRefreshInterval);
|
|
31
32
|
}
|
|
32
|
-
async prepareTx(tx, additionalSigners,
|
|
33
|
+
async prepareTx(tx, additionalSigners, _opts) {
|
|
33
34
|
var _a;
|
|
34
35
|
tx.feePayer = this.wallet.publicKey;
|
|
35
36
|
tx.recentBlockhash =
|
|
36
|
-
(_a = this.recentBlockhash) !== null && _a !== void 0 ? _a : (await this.connection.getLatestBlockhash(
|
|
37
|
+
(_a = this.recentBlockhash) !== null && _a !== void 0 ? _a : (await this.connection.getLatestBlockhash(this.blockhashCommitment))
|
|
37
38
|
.blockhash;
|
|
38
39
|
additionalSigners
|
|
39
40
|
.filter((s) => s !== undefined)
|
package/package.json
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
TransactionMessage,
|
|
10
10
|
TransactionInstruction,
|
|
11
11
|
AddressLookupTableAccount,
|
|
12
|
+
Commitment,
|
|
12
13
|
} from '@solana/web3.js';
|
|
13
14
|
import { AnchorProvider } from '@coral-xyz/anchor';
|
|
14
15
|
import { IWallet } from '../types';
|
|
@@ -27,6 +28,7 @@ export class FastSingleTxSender extends BaseTxSender {
|
|
|
27
28
|
timoutCount = 0;
|
|
28
29
|
recentBlockhash: string;
|
|
29
30
|
skipConfirmation: boolean;
|
|
31
|
+
blockhashCommitment: Commitment;
|
|
30
32
|
|
|
31
33
|
public constructor({
|
|
32
34
|
connection,
|
|
@@ -36,6 +38,7 @@ export class FastSingleTxSender extends BaseTxSender {
|
|
|
36
38
|
blockhashRefreshInterval = DEFAULT_BLOCKHASH_REFRESH,
|
|
37
39
|
additionalConnections = new Array<Connection>(),
|
|
38
40
|
skipConfirmation = false,
|
|
41
|
+
blockhashCommitment = 'finalized',
|
|
39
42
|
}: {
|
|
40
43
|
connection: Connection;
|
|
41
44
|
wallet: IWallet;
|
|
@@ -44,6 +47,7 @@ export class FastSingleTxSender extends BaseTxSender {
|
|
|
44
47
|
blockhashRefreshInterval?: number;
|
|
45
48
|
additionalConnections?;
|
|
46
49
|
skipConfirmation?: boolean;
|
|
50
|
+
blockhashCommitment?: Commitment;
|
|
47
51
|
}) {
|
|
48
52
|
super({ connection, wallet, opts, timeout, additionalConnections });
|
|
49
53
|
this.connection = connection;
|
|
@@ -53,6 +57,7 @@ export class FastSingleTxSender extends BaseTxSender {
|
|
|
53
57
|
this.blockhashRefreshInterval = blockhashRefreshInterval;
|
|
54
58
|
this.additionalConnections = additionalConnections;
|
|
55
59
|
this.skipConfirmation = skipConfirmation;
|
|
60
|
+
this.blockhashCommitment = blockhashCommitment;
|
|
56
61
|
this.startBlockhashRefreshLoop();
|
|
57
62
|
}
|
|
58
63
|
|
|
@@ -60,7 +65,7 @@ export class FastSingleTxSender extends BaseTxSender {
|
|
|
60
65
|
setInterval(async () => {
|
|
61
66
|
try {
|
|
62
67
|
this.recentBlockhash = (
|
|
63
|
-
await this.connection.getLatestBlockhash(this.
|
|
68
|
+
await this.connection.getLatestBlockhash(this.blockhashCommitment)
|
|
64
69
|
).blockhash;
|
|
65
70
|
} catch (e) {
|
|
66
71
|
console.error('Error in startBlockhashRefreshLoop: ', e);
|
|
@@ -71,13 +76,13 @@ export class FastSingleTxSender extends BaseTxSender {
|
|
|
71
76
|
async prepareTx(
|
|
72
77
|
tx: Transaction,
|
|
73
78
|
additionalSigners: Array<Signer>,
|
|
74
|
-
|
|
79
|
+
_opts: ConfirmOptions
|
|
75
80
|
): Promise<Transaction> {
|
|
76
81
|
tx.feePayer = this.wallet.publicKey;
|
|
77
82
|
|
|
78
83
|
tx.recentBlockhash =
|
|
79
84
|
this.recentBlockhash ??
|
|
80
|
-
(await this.connection.getLatestBlockhash(
|
|
85
|
+
(await this.connection.getLatestBlockhash(this.blockhashCommitment))
|
|
81
86
|
.blockhash;
|
|
82
87
|
|
|
83
88
|
additionalSigners
|