@drift-labs/sdk 2.94.0-beta.1 → 2.94.0-beta.2

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.94.0-beta.1
1
+ 2.94.0-beta.2
@@ -19,7 +19,7 @@ export declare class BankrunContextWrapper {
19
19
  readonly context: ProgramTestContext;
20
20
  readonly provider: BankrunProvider;
21
21
  readonly commitment: Commitment;
22
- constructor(context: ProgramTestContext);
22
+ constructor(context: ProgramTestContext, verifySignatures?: boolean);
23
23
  sendTransaction(tx: Transaction, additionalSigners?: Keypair[]): Promise<TransactionSignature>;
24
24
  getMinimumBalanceForRentExemption(_: number): Promise<number>;
25
25
  fundKeypair(keypair: Keypair | Wallet, lamports: number | bigint): Promise<TransactionSignature>;
@@ -36,7 +36,8 @@ export declare class BankrunConnection {
36
36
  private nextClientSubscriptionId;
37
37
  private onLogCallbacks;
38
38
  private onAccountChangeCallbacks;
39
- constructor(banksClient: BanksClient, context: ProgramTestContext);
39
+ private verifySignatures;
40
+ constructor(banksClient: BanksClient, context: ProgramTestContext, verifySignatures?: boolean);
40
41
  getSlot(): Promise<bigint>;
41
42
  toConnection(): SolanaConnection;
42
43
  getTokenAccount(publicKey: PublicKey): Promise<Account>;
@@ -11,11 +11,11 @@ const bs58_1 = __importDefault(require("bs58"));
11
11
  const anchor_1 = require("@coral-xyz/anchor");
12
12
  const spl_token_1 = require("@solana/spl-token");
13
13
  class BankrunContextWrapper {
14
- constructor(context) {
14
+ constructor(context, verifySignatures = true) {
15
15
  this.commitment = 'confirmed';
16
16
  this.context = context;
17
17
  this.provider = new anchor_bankrun_1.BankrunProvider(context);
18
- this.connection = new BankrunConnection(this.context.banksClient, this.context);
18
+ this.connection = new BankrunConnection(this.context.banksClient, this.context, verifySignatures);
19
19
  }
20
20
  async sendTransaction(tx, additionalSigners) {
21
21
  tx.recentBlockhash = (await this.getLatestBlockhash()).toString();
@@ -62,13 +62,14 @@ class BankrunContextWrapper {
62
62
  }
63
63
  exports.BankrunContextWrapper = BankrunContextWrapper;
64
64
  class BankrunConnection {
65
- constructor(banksClient, context) {
65
+ constructor(banksClient, context, verifySignatures = true) {
66
66
  this.transactionToMeta = new Map();
67
67
  this.nextClientSubscriptionId = 0;
68
68
  this.onLogCallbacks = new Map();
69
69
  this.onAccountChangeCallbacks = new Map();
70
70
  this._banksClient = banksClient;
71
71
  this.context = context;
72
+ this.verifySignatures = verifySignatures;
72
73
  }
73
74
  getSlot() {
74
75
  return this._banksClient.getSlot();
@@ -103,7 +104,15 @@ class BankrunConnection {
103
104
  return signature;
104
105
  }
105
106
  async sendTransaction(tx) {
106
- const banksTransactionMeta = await this._banksClient.tryProcessTransaction(tx);
107
+ const serialized = tx.serialize({
108
+ verifySignatures: this.verifySignatures,
109
+ });
110
+ // @ts-ignore
111
+ const internal = this._banksClient.inner;
112
+ const inner = tx instanceof web3_js_1.Transaction
113
+ ? await internal.tryProcessLegacyTransaction(serialized)
114
+ : await internal.tryProcessVersionedTransaction(serialized);
115
+ const banksTransactionMeta = new solana_bankrun_1.BanksTransactionResultWithMeta(inner);
107
116
  if (banksTransactionMeta.result) {
108
117
  throw new Error(banksTransactionMeta.result);
109
118
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.94.0-beta.1",
3
+ "version": "2.94.0-beta.2",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -55,12 +55,13 @@ export class BankrunContextWrapper {
55
55
  public readonly provider: BankrunProvider;
56
56
  public readonly commitment: Commitment = 'confirmed';
57
57
 
58
- constructor(context: ProgramTestContext) {
58
+ constructor(context: ProgramTestContext, verifySignatures = true) {
59
59
  this.context = context;
60
60
  this.provider = new BankrunProvider(context);
61
61
  this.connection = new BankrunConnection(
62
62
  this.context.banksClient,
63
- this.context
63
+ this.context,
64
+ verifySignatures
64
65
  );
65
66
  }
66
67
 
@@ -149,9 +150,16 @@ export class BankrunConnection {
149
150
  [PublicKey, AccountChangeCallback]
150
151
  >();
151
152
 
152
- constructor(banksClient: BanksClient, context: ProgramTestContext) {
153
+ private verifySignatures: boolean;
154
+
155
+ constructor(
156
+ banksClient: BanksClient,
157
+ context: ProgramTestContext,
158
+ verifySignatures = true
159
+ ) {
153
160
  this._banksClient = banksClient;
154
161
  this.context = context;
162
+ this.verifySignatures = verifySignatures;
155
163
  }
156
164
 
157
165
  getSlot(): Promise<bigint> {
@@ -205,9 +213,17 @@ export class BankrunConnection {
205
213
  }
206
214
 
207
215
  async sendTransaction(tx: Transaction): Promise<TransactionSignature> {
208
- const banksTransactionMeta = await this._banksClient.tryProcessTransaction(
209
- tx
210
- );
216
+ const serialized = tx.serialize({
217
+ verifySignatures: this.verifySignatures,
218
+ });
219
+ // @ts-ignore
220
+ const internal = this._banksClient.inner;
221
+ const inner =
222
+ tx instanceof Transaction
223
+ ? await internal.tryProcessLegacyTransaction(serialized)
224
+ : await internal.tryProcessVersionedTransaction(serialized);
225
+ const banksTransactionMeta = new BanksTransactionResultWithMeta(inner);
226
+
211
227
  if (banksTransactionMeta.result) {
212
228
  throw new Error(banksTransactionMeta.result);
213
229
  }