@drift-labs/sdk 2.53.0-beta.5 → 2.53.0-beta.6

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.5
1
+ 2.53.0-beta.6
@@ -11,7 +11,7 @@ export declare class FastSingleTxSender extends BaseTxSender {
11
11
  blockhashRefreshInterval: number;
12
12
  additionalConnections: Connection[];
13
13
  timoutCount: number;
14
- blockhashQueue: string[];
14
+ recentBlockhash: string;
15
15
  skipConfirmation: boolean;
16
16
  constructor({ connection, wallet, opts, timeout, blockhashRefreshInterval, additionalConnections, skipConfirmation, }: {
17
17
  connection: Connection;
@@ -23,7 +23,6 @@ export declare class FastSingleTxSender extends BaseTxSender {
23
23
  skipConfirmation?: boolean;
24
24
  });
25
25
  startBlockhashRefreshLoop(): void;
26
- addBlockhashToQueue(blockhash: string): void;
27
26
  prepareTx(tx: Transaction, additionalSigners: Array<Signer>, opts: ConfirmOptions): Promise<Transaction>;
28
27
  getVersionedTransaction(ixs: TransactionInstruction[], lookupTableAccounts: AddressLookupTableAccount[], additionalSigners?: Array<Signer>, opts?: ConfirmOptions): Promise<VersionedTransaction>;
29
28
  sendRawTransaction(rawTransaction: Buffer | Uint8Array, opts: ConfirmOptions): Promise<TxSigAndSlot>;
@@ -5,13 +5,11 @@ const web3_js_1 = require("@solana/web3.js");
5
5
  const anchor_1 = require("@coral-xyz/anchor");
6
6
  const baseTxSender_1 = require("./baseTxSender");
7
7
  const DEFAULT_TIMEOUT = 35000;
8
- const DEFAULT_BLOCKHASH_REFRESH = 500;
9
- const MAX_BLOCKHASH_QUEUE_LENGTH = 100;
8
+ const DEFAULT_BLOCKHASH_REFRESH = 10000;
10
9
  class FastSingleTxSender extends baseTxSender_1.BaseTxSender {
11
10
  constructor({ connection, wallet, opts = anchor_1.AnchorProvider.defaultOptions(), timeout = DEFAULT_TIMEOUT, blockhashRefreshInterval = DEFAULT_BLOCKHASH_REFRESH, additionalConnections = new Array(), skipConfirmation = false, }) {
12
11
  super({ connection, wallet, opts, timeout, additionalConnections });
13
12
  this.timoutCount = 0;
14
- this.blockhashQueue = [];
15
13
  this.connection = connection;
16
14
  this.wallet = wallet;
17
15
  this.opts = opts;
@@ -24,29 +22,18 @@ class FastSingleTxSender extends baseTxSender_1.BaseTxSender {
24
22
  startBlockhashRefreshLoop() {
25
23
  setInterval(async () => {
26
24
  try {
27
- const blockhash = (await this.connection.getLatestBlockhash(this.opts))
28
- .blockhash;
29
- this.addBlockhashToQueue(blockhash);
25
+ this.recentBlockhash = (await this.connection.getLatestBlockhash(this.opts)).blockhash;
30
26
  }
31
27
  catch (e) {
32
28
  console.error('Error in startBlockhashRefreshLoop: ', e);
33
29
  }
34
30
  }, this.blockhashRefreshInterval);
35
31
  }
36
- addBlockhashToQueue(blockhash) {
37
- if (blockhash !== this.blockhashQueue[0]) {
38
- this.blockhashQueue.push(blockhash);
39
- return;
40
- }
41
- if (this.blockhashQueue.length > MAX_BLOCKHASH_QUEUE_LENGTH) {
42
- this.blockhashQueue.shift();
43
- }
44
- }
45
32
  async prepareTx(tx, additionalSigners, opts) {
46
33
  var _a;
47
34
  tx.feePayer = this.wallet.publicKey;
48
35
  tx.recentBlockhash =
49
- (_a = this.blockhashQueue.shift()) !== null && _a !== void 0 ? _a : (await this.connection.getLatestBlockhash(opts.preflightCommitment))
36
+ (_a = this.recentBlockhash) !== null && _a !== void 0 ? _a : (await this.connection.getLatestBlockhash(opts.preflightCommitment))
50
37
  .blockhash;
51
38
  additionalSigners
52
39
  .filter((s) => s !== undefined)
@@ -66,7 +53,7 @@ class FastSingleTxSender extends baseTxSender_1.BaseTxSender {
66
53
  }
67
54
  const message = new web3_js_1.TransactionMessage({
68
55
  payerKey: this.wallet.publicKey,
69
- recentBlockhash: (_a = this.blockhashQueue.shift()) !== null && _a !== void 0 ? _a : (await this.connection.getLatestBlockhash(opts.preflightCommitment))
56
+ recentBlockhash: (_a = this.recentBlockhash) !== null && _a !== void 0 ? _a : (await this.connection.getLatestBlockhash(opts.preflightCommitment))
70
57
  .blockhash,
71
58
  instructions: ixs,
72
59
  }).compileToV0Message(lookupTableAccounts);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.53.0-beta.5",
3
+ "version": "2.53.0-beta.6",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -15,8 +15,7 @@ import { IWallet } from '../types';
15
15
  import { BaseTxSender } from './baseTxSender';
16
16
 
17
17
  const DEFAULT_TIMEOUT = 35000;
18
- const DEFAULT_BLOCKHASH_REFRESH = 500;
19
- const MAX_BLOCKHASH_QUEUE_LENGTH = 100;
18
+ const DEFAULT_BLOCKHASH_REFRESH = 10000;
20
19
 
21
20
  export class FastSingleTxSender extends BaseTxSender {
22
21
  connection: Connection;
@@ -26,7 +25,7 @@ export class FastSingleTxSender extends BaseTxSender {
26
25
  blockhashRefreshInterval: number;
27
26
  additionalConnections: Connection[];
28
27
  timoutCount = 0;
29
- blockhashQueue: string[] = [];
28
+ recentBlockhash: string;
30
29
  skipConfirmation: boolean;
31
30
 
32
31
  public constructor({
@@ -60,25 +59,15 @@ export class FastSingleTxSender extends BaseTxSender {
60
59
  startBlockhashRefreshLoop(): void {
61
60
  setInterval(async () => {
62
61
  try {
63
- const blockhash = (await this.connection.getLatestBlockhash(this.opts))
64
- .blockhash;
65
- this.addBlockhashToQueue(blockhash);
62
+ this.recentBlockhash = (
63
+ await this.connection.getLatestBlockhash(this.opts)
64
+ ).blockhash;
66
65
  } catch (e) {
67
66
  console.error('Error in startBlockhashRefreshLoop: ', e);
68
67
  }
69
68
  }, this.blockhashRefreshInterval);
70
69
  }
71
70
 
72
- addBlockhashToQueue(blockhash: string): void {
73
- if (blockhash !== this.blockhashQueue[0]) {
74
- this.blockhashQueue.push(blockhash);
75
- return;
76
- }
77
- if (this.blockhashQueue.length > MAX_BLOCKHASH_QUEUE_LENGTH) {
78
- this.blockhashQueue.shift();
79
- }
80
- }
81
-
82
71
  async prepareTx(
83
72
  tx: Transaction,
84
73
  additionalSigners: Array<Signer>,
@@ -87,7 +76,7 @@ export class FastSingleTxSender extends BaseTxSender {
87
76
  tx.feePayer = this.wallet.publicKey;
88
77
 
89
78
  tx.recentBlockhash =
90
- this.blockhashQueue.shift() ??
79
+ this.recentBlockhash ??
91
80
  (await this.connection.getLatestBlockhash(opts.preflightCommitment))
92
81
  .blockhash;
93
82
 
@@ -118,7 +107,7 @@ export class FastSingleTxSender extends BaseTxSender {
118
107
  const message = new TransactionMessage({
119
108
  payerKey: this.wallet.publicKey,
120
109
  recentBlockhash:
121
- this.blockhashQueue.shift() ??
110
+ this.recentBlockhash ??
122
111
  (await this.connection.getLatestBlockhash(opts.preflightCommitment))
123
112
  .blockhash,
124
113
  instructions: ixs,