@drift-labs/sdk 2.136.0-beta.2 → 2.136.0-beta.4

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.136.0-beta.2
1
+ 2.136.0-beta.4
@@ -622,12 +622,13 @@ class DriftClient {
622
622
  return [txSig, userAccountPublicKey];
623
623
  }
624
624
  async getInitializeUserStatsIx() {
625
+ var _a, _b;
625
626
  return await this.program.instruction.initializeUserStats({
626
627
  accounts: {
627
628
  userStats: (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, this.wallet.publicKey // only allow payer to initialize own user stats account
628
629
  ),
629
630
  authority: this.wallet.publicKey,
630
- payer: this.wallet.publicKey,
631
+ payer: (_b = (_a = this.wallet.payer) === null || _a === void 0 ? void 0 : _a.publicKey) !== null && _b !== void 0 ? _b : this.wallet.publicKey,
631
632
  rent: anchor.web3.SYSVAR_RENT_PUBKEY,
632
633
  systemProgram: anchor.web3.SystemProgram.programId,
633
634
  state: await this.getStatePublicKey(),
@@ -643,12 +644,13 @@ class DriftClient {
643
644
  return [txSig, signedMsgUserAccountPublicKey];
644
645
  }
645
646
  async getInitializeSignedMsgUserOrdersAccountIx(authority, numOrders) {
647
+ var _a, _b;
646
648
  const signedMsgUserAccountPublicKey = (0, pda_1.getSignedMsgUserAccountPublicKey)(this.program.programId, authority);
647
649
  const initializeUserAccountIx = await this.program.instruction.initializeSignedMsgUserOrders(numOrders, {
648
650
  accounts: {
649
651
  signedMsgUserOrders: signedMsgUserAccountPublicKey,
650
652
  authority,
651
- payer: this.wallet.publicKey,
653
+ payer: (_b = (_a = this.wallet.payer) === null || _a === void 0 ? void 0 : _a.publicKey) !== null && _b !== void 0 ? _b : this.wallet.publicKey,
652
654
  rent: anchor.web3.SYSVAR_RENT_PUBKEY,
653
655
  systemProgram: anchor.web3.SystemProgram.programId,
654
656
  },
@@ -662,12 +664,13 @@ class DriftClient {
662
664
  return txSig;
663
665
  }
664
666
  async getResizeSignedMsgUserOrdersInstruction(authority, numOrders, userSubaccountId) {
667
+ var _a, _b;
665
668
  const signedMsgUserAccountPublicKey = (0, pda_1.getSignedMsgUserAccountPublicKey)(this.program.programId, authority);
666
669
  const resizeUserAccountIx = await this.program.instruction.resizeSignedMsgUserOrders(numOrders, {
667
670
  accounts: {
668
671
  signedMsgUserOrders: signedMsgUserAccountPublicKey,
669
672
  authority,
670
- payer: this.wallet.publicKey,
673
+ payer: (_b = (_a = this.wallet.payer) === null || _a === void 0 ? void 0 : _a.publicKey) !== null && _b !== void 0 ? _b : this.wallet.publicKey,
671
674
  systemProgram: anchor.web3.SystemProgram.programId,
672
675
  user: await (0, pda_1.getUserAccountPublicKey)(this.program.programId, authority, userSubaccountId),
673
676
  },
@@ -733,12 +736,13 @@ class DriftClient {
733
736
  return txSig;
734
737
  }
735
738
  async getInitializeFuelOverflowIx(authority) {
739
+ var _a, _b;
736
740
  return await this.program.instruction.initializeFuelOverflow({
737
741
  accounts: {
738
742
  fuelOverflow: (0, pda_1.getFuelOverflowAccountPublicKey)(this.program.programId, authority !== null && authority !== void 0 ? authority : this.wallet.publicKey),
739
743
  userStats: (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, authority !== null && authority !== void 0 ? authority : this.wallet.publicKey),
740
744
  authority: authority !== null && authority !== void 0 ? authority : this.wallet.publicKey,
741
- payer: this.wallet.publicKey,
745
+ payer: (_b = (_a = this.wallet.payer) === null || _a === void 0 ? void 0 : _a.publicKey) !== null && _b !== void 0 ? _b : this.wallet.publicKey,
742
746
  rent: anchor.web3.SYSVAR_RENT_PUBKEY,
743
747
  systemProgram: anchor.web3.SystemProgram.programId,
744
748
  },
@@ -761,6 +765,7 @@ class DriftClient {
761
765
  });
762
766
  }
763
767
  async getInitializeUserInstructions(subAccountId = 0, name, referrerInfo) {
768
+ var _a, _b;
764
769
  const userAccountPublicKey = await (0, pda_1.getUserAccountPublicKey)(this.program.programId, this.wallet.publicKey, subAccountId);
765
770
  const remainingAccounts = new Array();
766
771
  if (referrerInfo !== undefined) {
@@ -798,7 +803,7 @@ class DriftClient {
798
803
  user: userAccountPublicKey,
799
804
  userStats: this.getUserStatsAccountPublicKey(),
800
805
  authority: this.wallet.publicKey,
801
- payer: this.wallet.publicKey,
806
+ payer: (_b = (_a = this.wallet.payer) === null || _a === void 0 ? void 0 : _a.publicKey) !== null && _b !== void 0 ? _b : this.wallet.publicKey,
802
807
  rent: anchor.web3.SYSVAR_RENT_PUBKEY,
803
808
  systemProgram: anchor.web3.SystemProgram.programId,
804
809
  state: await this.getStatePublicKey(),
@@ -819,6 +824,7 @@ class DriftClient {
819
824
  return userStatsAccount.numberOfSubAccountsCreated;
820
825
  }
821
826
  async initializeReferrerName(name) {
827
+ var _a, _b;
822
828
  const userAccountPublicKey = (0, pda_1.getUserAccountPublicKeySync)(this.program.programId, this.wallet.publicKey, 0);
823
829
  const nameBuffer = (0, userName_1.encodeName)(name);
824
830
  const referrerNameAccountPublicKey = (0, pda_1.getReferrerNamePublicKeySync)(this.program.programId, nameBuffer);
@@ -828,7 +834,7 @@ class DriftClient {
828
834
  user: userAccountPublicKey,
829
835
  authority: this.wallet.publicKey,
830
836
  userStats: this.getUserStatsAccountPublicKey(),
831
- payer: this.wallet.publicKey,
837
+ payer: (_b = (_a = this.wallet.payer) === null || _a === void 0 ? void 0 : _a.publicKey) !== null && _b !== void 0 ? _b : this.wallet.publicKey,
832
838
  rent: anchor.web3.SYSVAR_RENT_PUBKEY,
833
839
  systemProgram: anchor.web3.SystemProgram.programId,
834
840
  },
@@ -4492,6 +4498,7 @@ class DriftClient {
4492
4498
  return txSig;
4493
4499
  }
4494
4500
  async getInitializeInsuranceFundStakeIx(marketIndex) {
4501
+ var _a, _b;
4495
4502
  const ifStakeAccountPublicKey = (0, pda_1.getInsuranceFundStakeAccountPublicKey)(this.program.programId, this.wallet.publicKey, marketIndex);
4496
4503
  const accounts = {
4497
4504
  insuranceFundStake: ifStakeAccountPublicKey,
@@ -4499,7 +4506,7 @@ class DriftClient {
4499
4506
  userStats: (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, this.wallet.publicKey // only allow payer to initialize own insurance fund stake account
4500
4507
  ),
4501
4508
  authority: this.wallet.publicKey,
4502
- payer: this.wallet.publicKey,
4509
+ payer: (_b = (_a = this.wallet.payer) === null || _a === void 0 ? void 0 : _a.publicKey) !== null && _b !== void 0 ? _b : this.wallet.publicKey,
4503
4510
  rent: anchor.web3.SYSVAR_RENT_PUBKEY,
4504
4511
  systemProgram: anchor.web3.SystemProgram.programId,
4505
4512
  state: await this.getStatePublicKey(),
@@ -5076,6 +5083,7 @@ class DriftClient {
5076
5083
  return pullIx[0];
5077
5084
  }
5078
5085
  async postSwitchboardOnDemandUpdate(feed, recentSlothash, numSignatures = 3) {
5086
+ var _a, _b;
5079
5087
  const pullIx = await this.getPostSwitchboardOnDemandUpdateAtomicIx(feed, recentSlothash, numSignatures);
5080
5088
  if (!pullIx) {
5081
5089
  return undefined;
@@ -5083,7 +5091,7 @@ class DriftClient {
5083
5091
  const tx = await (0, on_demand_1.asV0Tx)({
5084
5092
  connection: this.connection,
5085
5093
  ixs: [pullIx],
5086
- payer: this.wallet.publicKey,
5094
+ payer: (_b = (_a = this.wallet.payer) === null || _a === void 0 ? void 0 : _a.publicKey) !== null && _b !== void 0 ? _b : this.wallet.publicKey,
5087
5095
  computeUnitLimitMultiple: 1.3,
5088
5096
  lookupTables: await this.fetchAllLookupTableAccounts(),
5089
5097
  });
@@ -66,15 +66,14 @@ class BaseTxSender {
66
66
  let signedTx;
67
67
  if (preSigned) {
68
68
  signedTx = tx;
69
- // @ts-ignore
70
- }
71
- else if (this.wallet.payer) {
72
- // @ts-ignore
73
- tx.sign((additionalSigners !== null && additionalSigners !== void 0 ? additionalSigners : []).concat(this.wallet.payer));
74
- signedTx = tx;
75
69
  }
76
70
  else {
71
+ // Sign with user first for instruction authorities
77
72
  signedTx = await this.txHandler.signVersionedTx(tx, additionalSigners, undefined, this.wallet);
73
+ // Add payer signature if available
74
+ if (this.wallet.payer) {
75
+ signedTx.sign([this.wallet.payer]);
76
+ }
78
77
  }
79
78
  if (opts === undefined) {
80
79
  opts = this.opts;
@@ -79,11 +79,12 @@ class TxHandler {
79
79
  * @returns
80
80
  */
81
81
  async prepareTx(tx, additionalSigners, wallet, confirmationOpts, preSigned, recentBlockhash) {
82
+ var _a, _b;
82
83
  if (preSigned) {
83
84
  return tx;
84
85
  }
85
86
  [wallet, confirmationOpts] = this.getProps(wallet, confirmationOpts);
86
- tx.feePayer = wallet.publicKey;
87
+ tx.feePayer = (_b = (_a = wallet.payer) === null || _a === void 0 ? void 0 : _a.publicKey) !== null && _b !== void 0 ? _b : wallet.publicKey;
87
88
  recentBlockhash = recentBlockhash
88
89
  ? recentBlockhash
89
90
  : await this.getLatestBlockhashForTransaction();
@@ -222,9 +223,10 @@ class TxHandler {
222
223
  return new web3_js_1.VersionedTransaction(message);
223
224
  }
224
225
  generateLegacyVersionedTransaction(recentBlockhash, ixs, wallet) {
226
+ var _a, _b;
225
227
  [wallet] = this.getProps(wallet);
226
228
  const message = new web3_js_1.TransactionMessage({
227
- payerKey: wallet.publicKey,
229
+ payerKey: (_b = (_a = wallet.payer) === null || _a === void 0 ? void 0 : _a.publicKey) !== null && _b !== void 0 ? _b : wallet.publicKey,
228
230
  recentBlockhash: recentBlockhash.blockhash,
229
231
  instructions: ixs,
230
232
  }).compileToLegacyMessage();
@@ -234,9 +236,10 @@ class TxHandler {
234
236
  return tx;
235
237
  }
236
238
  generateVersionedTransaction(recentBlockhash, ixs, lookupTableAccounts, wallet) {
239
+ var _a, _b;
237
240
  [wallet] = this.getProps(wallet);
238
241
  const message = new web3_js_1.TransactionMessage({
239
- payerKey: wallet.publicKey,
242
+ payerKey: (_b = (_a = wallet.payer) === null || _a === void 0 ? void 0 : _a.publicKey) !== null && _b !== void 0 ? _b : wallet.publicKey,
240
243
  recentBlockhash: recentBlockhash.blockhash,
241
244
  instructions: ixs,
242
245
  }).compileToV0Message(lookupTableAccounts);
@@ -384,7 +387,7 @@ class TxHandler {
384
387
  * @returns
385
388
  */
386
389
  async getPreparedAndSignedLegacyTransactionMap(txsMap, wallet, commitment, recentBlockhash) {
387
- var _a, _b;
390
+ var _a, _b, _c, _d;
388
391
  recentBlockhash = recentBlockhash
389
392
  ? recentBlockhash
390
393
  : await this.getLatestBlockhashForTransaction();
@@ -393,7 +396,8 @@ class TxHandler {
393
396
  if (!tx)
394
397
  continue;
395
398
  tx.recentBlockhash = recentBlockhash.blockhash;
396
- tx.feePayer = (_a = wallet === null || wallet === void 0 ? void 0 : wallet.publicKey) !== null && _a !== void 0 ? _a : (_b = this.wallet) === null || _b === void 0 ? void 0 : _b.publicKey;
399
+ tx.feePayer =
400
+ (_c = (_b = (_a = wallet === null || wallet === void 0 ? void 0 : wallet.payer) === null || _a === void 0 ? void 0 : _a.publicKey) !== null && _b !== void 0 ? _b : wallet === null || wallet === void 0 ? void 0 : wallet.publicKey) !== null && _c !== void 0 ? _c : (_d = this.wallet) === null || _d === void 0 ? void 0 : _d.publicKey;
397
401
  // @ts-ignore
398
402
  tx.SIGNATURE_BLOCK_AND_EXPIRY = recentBlockhash;
399
403
  }
@@ -407,7 +411,7 @@ class TxHandler {
407
411
  * @returns
408
412
  */
409
413
  async getSignedTransactionMap(txsToSignMap, wallet) {
410
- var _a;
414
+ var _a, _b, _c;
411
415
  [wallet] = this.getProps(wallet);
412
416
  const txsToSignEntries = Object.entries(txsToSignMap);
413
417
  // Create a map of the same keys as the input map, but with the values set to undefined. We'll populate the filtered (non-undefined) values with signed transactions.
@@ -419,10 +423,11 @@ class TxHandler {
419
423
  // Extra handling for legacy transactions
420
424
  for (const [_key, tx] of filteredTxEntries) {
421
425
  if (this.isLegacyTransaction(tx)) {
422
- tx.feePayer = wallet.publicKey;
426
+ tx.feePayer =
427
+ (_b = (_a = wallet.payer) === null || _a === void 0 ? void 0 : _a.publicKey) !== null && _b !== void 0 ? _b : wallet.publicKey;
423
428
  }
424
429
  }
425
- (_a = this.preSignedCb) === null || _a === void 0 ? void 0 : _a.call(this);
430
+ (_c = this.preSignedCb) === null || _c === void 0 ? void 0 : _c.call(this);
426
431
  const signedFilteredTxs = await wallet.signAllTransactions(filteredTxEntries.map(([_, tx]) => tx));
427
432
  signedFilteredTxs.forEach((signedTx, index) => {
428
433
  var _a;
@@ -160,6 +160,7 @@ class WhileValidTxSender extends baseTxSender_1.BaseTxSender {
160
160
  }
161
161
  finally {
162
162
  stopWaiting();
163
+ this.untilValid.delete(txid);
163
164
  }
164
165
  return { txSig: txid, slot };
165
166
  }
@@ -622,12 +622,13 @@ class DriftClient {
622
622
  return [txSig, userAccountPublicKey];
623
623
  }
624
624
  async getInitializeUserStatsIx() {
625
+ var _a, _b;
625
626
  return await this.program.instruction.initializeUserStats({
626
627
  accounts: {
627
628
  userStats: (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, this.wallet.publicKey // only allow payer to initialize own user stats account
628
629
  ),
629
630
  authority: this.wallet.publicKey,
630
- payer: this.wallet.publicKey,
631
+ payer: (_b = (_a = this.wallet.payer) === null || _a === void 0 ? void 0 : _a.publicKey) !== null && _b !== void 0 ? _b : this.wallet.publicKey,
631
632
  rent: anchor.web3.SYSVAR_RENT_PUBKEY,
632
633
  systemProgram: anchor.web3.SystemProgram.programId,
633
634
  state: await this.getStatePublicKey(),
@@ -643,12 +644,13 @@ class DriftClient {
643
644
  return [txSig, signedMsgUserAccountPublicKey];
644
645
  }
645
646
  async getInitializeSignedMsgUserOrdersAccountIx(authority, numOrders) {
647
+ var _a, _b;
646
648
  const signedMsgUserAccountPublicKey = (0, pda_1.getSignedMsgUserAccountPublicKey)(this.program.programId, authority);
647
649
  const initializeUserAccountIx = await this.program.instruction.initializeSignedMsgUserOrders(numOrders, {
648
650
  accounts: {
649
651
  signedMsgUserOrders: signedMsgUserAccountPublicKey,
650
652
  authority,
651
- payer: this.wallet.publicKey,
653
+ payer: (_b = (_a = this.wallet.payer) === null || _a === void 0 ? void 0 : _a.publicKey) !== null && _b !== void 0 ? _b : this.wallet.publicKey,
652
654
  rent: anchor.web3.SYSVAR_RENT_PUBKEY,
653
655
  systemProgram: anchor.web3.SystemProgram.programId,
654
656
  },
@@ -662,12 +664,13 @@ class DriftClient {
662
664
  return txSig;
663
665
  }
664
666
  async getResizeSignedMsgUserOrdersInstruction(authority, numOrders, userSubaccountId) {
667
+ var _a, _b;
665
668
  const signedMsgUserAccountPublicKey = (0, pda_1.getSignedMsgUserAccountPublicKey)(this.program.programId, authority);
666
669
  const resizeUserAccountIx = await this.program.instruction.resizeSignedMsgUserOrders(numOrders, {
667
670
  accounts: {
668
671
  signedMsgUserOrders: signedMsgUserAccountPublicKey,
669
672
  authority,
670
- payer: this.wallet.publicKey,
673
+ payer: (_b = (_a = this.wallet.payer) === null || _a === void 0 ? void 0 : _a.publicKey) !== null && _b !== void 0 ? _b : this.wallet.publicKey,
671
674
  systemProgram: anchor.web3.SystemProgram.programId,
672
675
  user: await (0, pda_1.getUserAccountPublicKey)(this.program.programId, authority, userSubaccountId),
673
676
  },
@@ -733,12 +736,13 @@ class DriftClient {
733
736
  return txSig;
734
737
  }
735
738
  async getInitializeFuelOverflowIx(authority) {
739
+ var _a, _b;
736
740
  return await this.program.instruction.initializeFuelOverflow({
737
741
  accounts: {
738
742
  fuelOverflow: (0, pda_1.getFuelOverflowAccountPublicKey)(this.program.programId, authority !== null && authority !== void 0 ? authority : this.wallet.publicKey),
739
743
  userStats: (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, authority !== null && authority !== void 0 ? authority : this.wallet.publicKey),
740
744
  authority: authority !== null && authority !== void 0 ? authority : this.wallet.publicKey,
741
- payer: this.wallet.publicKey,
745
+ payer: (_b = (_a = this.wallet.payer) === null || _a === void 0 ? void 0 : _a.publicKey) !== null && _b !== void 0 ? _b : this.wallet.publicKey,
742
746
  rent: anchor.web3.SYSVAR_RENT_PUBKEY,
743
747
  systemProgram: anchor.web3.SystemProgram.programId,
744
748
  },
@@ -761,6 +765,7 @@ class DriftClient {
761
765
  });
762
766
  }
763
767
  async getInitializeUserInstructions(subAccountId = 0, name, referrerInfo) {
768
+ var _a, _b;
764
769
  const userAccountPublicKey = await (0, pda_1.getUserAccountPublicKey)(this.program.programId, this.wallet.publicKey, subAccountId);
765
770
  const remainingAccounts = new Array();
766
771
  if (referrerInfo !== undefined) {
@@ -798,7 +803,7 @@ class DriftClient {
798
803
  user: userAccountPublicKey,
799
804
  userStats: this.getUserStatsAccountPublicKey(),
800
805
  authority: this.wallet.publicKey,
801
- payer: this.wallet.publicKey,
806
+ payer: (_b = (_a = this.wallet.payer) === null || _a === void 0 ? void 0 : _a.publicKey) !== null && _b !== void 0 ? _b : this.wallet.publicKey,
802
807
  rent: anchor.web3.SYSVAR_RENT_PUBKEY,
803
808
  systemProgram: anchor.web3.SystemProgram.programId,
804
809
  state: await this.getStatePublicKey(),
@@ -819,6 +824,7 @@ class DriftClient {
819
824
  return userStatsAccount.numberOfSubAccountsCreated;
820
825
  }
821
826
  async initializeReferrerName(name) {
827
+ var _a, _b;
822
828
  const userAccountPublicKey = (0, pda_1.getUserAccountPublicKeySync)(this.program.programId, this.wallet.publicKey, 0);
823
829
  const nameBuffer = (0, userName_1.encodeName)(name);
824
830
  const referrerNameAccountPublicKey = (0, pda_1.getReferrerNamePublicKeySync)(this.program.programId, nameBuffer);
@@ -828,7 +834,7 @@ class DriftClient {
828
834
  user: userAccountPublicKey,
829
835
  authority: this.wallet.publicKey,
830
836
  userStats: this.getUserStatsAccountPublicKey(),
831
- payer: this.wallet.publicKey,
837
+ payer: (_b = (_a = this.wallet.payer) === null || _a === void 0 ? void 0 : _a.publicKey) !== null && _b !== void 0 ? _b : this.wallet.publicKey,
832
838
  rent: anchor.web3.SYSVAR_RENT_PUBKEY,
833
839
  systemProgram: anchor.web3.SystemProgram.programId,
834
840
  },
@@ -4492,6 +4498,7 @@ class DriftClient {
4492
4498
  return txSig;
4493
4499
  }
4494
4500
  async getInitializeInsuranceFundStakeIx(marketIndex) {
4501
+ var _a, _b;
4495
4502
  const ifStakeAccountPublicKey = (0, pda_1.getInsuranceFundStakeAccountPublicKey)(this.program.programId, this.wallet.publicKey, marketIndex);
4496
4503
  const accounts = {
4497
4504
  insuranceFundStake: ifStakeAccountPublicKey,
@@ -4499,7 +4506,7 @@ class DriftClient {
4499
4506
  userStats: (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, this.wallet.publicKey // only allow payer to initialize own insurance fund stake account
4500
4507
  ),
4501
4508
  authority: this.wallet.publicKey,
4502
- payer: this.wallet.publicKey,
4509
+ payer: (_b = (_a = this.wallet.payer) === null || _a === void 0 ? void 0 : _a.publicKey) !== null && _b !== void 0 ? _b : this.wallet.publicKey,
4503
4510
  rent: anchor.web3.SYSVAR_RENT_PUBKEY,
4504
4511
  systemProgram: anchor.web3.SystemProgram.programId,
4505
4512
  state: await this.getStatePublicKey(),
@@ -5076,6 +5083,7 @@ class DriftClient {
5076
5083
  return pullIx[0];
5077
5084
  }
5078
5085
  async postSwitchboardOnDemandUpdate(feed, recentSlothash, numSignatures = 3) {
5086
+ var _a, _b;
5079
5087
  const pullIx = await this.getPostSwitchboardOnDemandUpdateAtomicIx(feed, recentSlothash, numSignatures);
5080
5088
  if (!pullIx) {
5081
5089
  return undefined;
@@ -5083,7 +5091,7 @@ class DriftClient {
5083
5091
  const tx = await (0, on_demand_1.asV0Tx)({
5084
5092
  connection: this.connection,
5085
5093
  ixs: [pullIx],
5086
- payer: this.wallet.publicKey,
5094
+ payer: (_b = (_a = this.wallet.payer) === null || _a === void 0 ? void 0 : _a.publicKey) !== null && _b !== void 0 ? _b : this.wallet.publicKey,
5087
5095
  computeUnitLimitMultiple: 1.3,
5088
5096
  lookupTables: await this.fetchAllLookupTableAccounts(),
5089
5097
  });
@@ -66,15 +66,14 @@ class BaseTxSender {
66
66
  let signedTx;
67
67
  if (preSigned) {
68
68
  signedTx = tx;
69
- // @ts-ignore
70
- }
71
- else if (this.wallet.payer) {
72
- // @ts-ignore
73
- tx.sign((additionalSigners !== null && additionalSigners !== void 0 ? additionalSigners : []).concat(this.wallet.payer));
74
- signedTx = tx;
75
69
  }
76
70
  else {
71
+ // Sign with user first for instruction authorities
77
72
  signedTx = await this.txHandler.signVersionedTx(tx, additionalSigners, undefined, this.wallet);
73
+ // Add payer signature if available
74
+ if (this.wallet.payer) {
75
+ signedTx.sign([this.wallet.payer]);
76
+ }
78
77
  }
79
78
  if (opts === undefined) {
80
79
  opts = this.opts;
@@ -1 +1 @@
1
- {"version":3,"file":"txHandler.d.ts","sourceRoot":"","sources":["../../../src/tx/txHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,yBAAyB,EACzB,8BAA8B,EAC9B,UAAU,EAEV,cAAc,EACd,UAAU,EAGV,MAAM,EACN,4BAA4B,EAC5B,WAAW,EACX,sBAAsB,EAEtB,kBAAkB,EAClB,oBAAoB,EACpB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAEN,wBAAwB,EACxB,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,MAAM,UAAU,CAAC;AAqBlB,eAAO,MAAM,qBAAqB,SAAU,CAAC;AAM7C,MAAM,MAAM,eAAe,GAAG;IAC7B,YAAY,EAAE,sBAAsB,GAAG,sBAAsB,EAAE,CAAC;IAChE,SAAS,EAAE,kBAAkB,CAAC;IAC9B,UAAU,EAAE,UAAU,CAAC;IACvB,mBAAmB,EAAE,UAAU,CAAC;IAChC,iCAAiC,EAAE,MAAM,OAAO,CAAC,yBAAyB,EAAE,CAAC,CAAC;IAC9E,YAAY,CAAC,EAAE,yBAAyB,EAAE,CAAC;IAC3C,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,eAAe,CAAC,EAAE,8BAA8B,CAAC;IACjD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,sBAAsB,EAAE,CAAC;I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,CAAC,CAAC;QACf,YAAY,EAAE,YAAY,EAAE,CAAC;KAC7B,CAAC;IAqDF;;;;OAIG;IACU,oBAAoB,CAChC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,sBAAsB,GAAG,sBAAsB,EAAE,CAAC,EAE3E,KAAK,EAAE,IAAI,CAAC,eAAe,EAAE,cAAc,CAAC,GAAG;QAC9C,eAAe,EAAE,CAAC,CAAC;KACnB,GACC,OAAO,CAAC,YAAY,CAAC,CAAC,EAAE,WAAW,GAAG,oBAAoB,CAAC,CAAC;IAY/D;;;;OAIG;IACU,0BAA0B,CACtC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,sBAAsB,GAAG,sBAAsB,EAAE,CAAC,EAE3E,KAAK,EAAE,IAAI,CAAC,eAAe,EAAE,cAAc,CAAC,GAAG;QAC9C,eAAe,EAAE,CAAC,CAAC;KACnB;;;;;;;IAeW,gCAAgC,CAC5C,eAAe,EAAE,eAAe,EAChC,oBAAoB,GAAE,sBAAsB,EAAO,EACnD,oBAAoB,UAAO,EAC3B,mBAAmB,GAAE,yBAAyB,EAAO,GACnD,OAAO,CACT;QAAC,sBAAsB,EAAE;QAAE,4BAA4B,GAAG,SAAS;KAAC,CACpE;CAmDD"}
@@ -79,11 +79,12 @@ class TxHandler {
79
79
  * @returns
80
80
  */
81
81
  async prepareTx(tx, additionalSigners, wallet, confirmationOpts, preSigned, recentBlockhash) {
82
+ var _a, _b;
82
83
  if (preSigned) {
83
84
  return tx;
84
85
  }
85
86
  [wallet, confirmationOpts] = this.getProps(wallet, confirmationOpts);
86
- tx.feePayer = wallet.publicKey;
87
+ tx.feePayer = (_b = (_a = wallet.payer) === null || _a === void 0 ? void 0 : _a.publicKey) !== null && _b !== void 0 ? _b : wallet.publicKey;
87
88
  recentBlockhash = recentBlockhash
88
89
  ? recentBlockhash
89
90
  : await this.getLatestBlockhashForTransaction();
@@ -222,9 +223,10 @@ class TxHandler {
222
223
  return new web3_js_1.VersionedTransaction(message);
223
224
  }
224
225
  generateLegacyVersionedTransaction(recentBlockhash, ixs, wallet) {
226
+ var _a, _b;
225
227
  [wallet] = this.getProps(wallet);
226
228
  const message = new web3_js_1.TransactionMessage({
227
- payerKey: wallet.publicKey,
229
+ payerKey: (_b = (_a = wallet.payer) === null || _a === void 0 ? void 0 : _a.publicKey) !== null && _b !== void 0 ? _b : wallet.publicKey,
228
230
  recentBlockhash: recentBlockhash.blockhash,
229
231
  instructions: ixs,
230
232
  }).compileToLegacyMessage();
@@ -234,9 +236,10 @@ class TxHandler {
234
236
  return tx;
235
237
  }
236
238
  generateVersionedTransaction(recentBlockhash, ixs, lookupTableAccounts, wallet) {
239
+ var _a, _b;
237
240
  [wallet] = this.getProps(wallet);
238
241
  const message = new web3_js_1.TransactionMessage({
239
- payerKey: wallet.publicKey,
242
+ payerKey: (_b = (_a = wallet.payer) === null || _a === void 0 ? void 0 : _a.publicKey) !== null && _b !== void 0 ? _b : wallet.publicKey,
240
243
  recentBlockhash: recentBlockhash.blockhash,
241
244
  instructions: ixs,
242
245
  }).compileToV0Message(lookupTableAccounts);
@@ -384,7 +387,7 @@ class TxHandler {
384
387
  * @returns
385
388
  */
386
389
  async getPreparedAndSignedLegacyTransactionMap(txsMap, wallet, commitment, recentBlockhash) {
387
- var _a, _b;
390
+ var _a, _b, _c, _d;
388
391
  recentBlockhash = recentBlockhash
389
392
  ? recentBlockhash
390
393
  : await this.getLatestBlockhashForTransaction();
@@ -393,7 +396,8 @@ class TxHandler {
393
396
  if (!tx)
394
397
  continue;
395
398
  tx.recentBlockhash = recentBlockhash.blockhash;
396
- tx.feePayer = (_a = wallet === null || wallet === void 0 ? void 0 : wallet.publicKey) !== null && _a !== void 0 ? _a : (_b = this.wallet) === null || _b === void 0 ? void 0 : _b.publicKey;
399
+ tx.feePayer =
400
+ (_c = (_b = (_a = wallet === null || wallet === void 0 ? void 0 : wallet.payer) === null || _a === void 0 ? void 0 : _a.publicKey) !== null && _b !== void 0 ? _b : wallet === null || wallet === void 0 ? void 0 : wallet.publicKey) !== null && _c !== void 0 ? _c : (_d = this.wallet) === null || _d === void 0 ? void 0 : _d.publicKey;
397
401
  // @ts-ignore
398
402
  tx.SIGNATURE_BLOCK_AND_EXPIRY = recentBlockhash;
399
403
  }
@@ -407,7 +411,7 @@ class TxHandler {
407
411
  * @returns
408
412
  */
409
413
  async getSignedTransactionMap(txsToSignMap, wallet) {
410
- var _a;
414
+ var _a, _b, _c;
411
415
  [wallet] = this.getProps(wallet);
412
416
  const txsToSignEntries = Object.entries(txsToSignMap);
413
417
  // Create a map of the same keys as the input map, but with the values set to undefined. We'll populate the filtered (non-undefined) values with signed transactions.
@@ -419,10 +423,11 @@ class TxHandler {
419
423
  // Extra handling for legacy transactions
420
424
  for (const [_key, tx] of filteredTxEntries) {
421
425
  if (this.isLegacyTransaction(tx)) {
422
- tx.feePayer = wallet.publicKey;
426
+ tx.feePayer =
427
+ (_b = (_a = wallet.payer) === null || _a === void 0 ? void 0 : _a.publicKey) !== null && _b !== void 0 ? _b : wallet.publicKey;
423
428
  }
424
429
  }
425
- (_a = this.preSignedCb) === null || _a === void 0 ? void 0 : _a.call(this);
430
+ (_c = this.preSignedCb) === null || _c === void 0 ? void 0 : _c.call(this);
426
431
  const signedFilteredTxs = await wallet.signAllTransactions(filteredTxEntries.map(([_, tx]) => tx));
427
432
  signedFilteredTxs.forEach((signedTx, index) => {
428
433
  var _a;
@@ -1 +1 @@
1
- {"version":3,"file":"whileValidTxSender.d.ts","sourceRoot":"","sources":["../../../src/tx/whileValidTxSender.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EACN,cAAc,EACd,UAAU,EAEV,MAAM,EACN,WAAW,EACX,oBAAoB,EACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAA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OAAO,CAAC,YAAY,CAAC;IA6ClB,kBAAkB,CACvB,cAAc,EAAE,MAAM,GAAG,UAAU,EACnC,IAAI,EAAE,cAAc,GAClB,OAAO,CAAC,YAAY,CAAC;CA6DxB"}
@@ -160,6 +160,7 @@ class WhileValidTxSender extends baseTxSender_1.BaseTxSender {
160
160
  }
161
161
  finally {
162
162
  stopWaiting();
163
+ this.untilValid.delete(txid);
163
164
  }
164
165
  return { txSig: txid, slot };
165
166
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.136.0-beta.2",
3
+ "version": "2.136.0-beta.4",
4
4
  "main": "lib/node/index.js",
5
5
  "types": "lib/node/index.d.ts",
6
6
  "browser": "./lib/browser/index.js",
@@ -1102,7 +1102,7 @@ export class DriftClient {
1102
1102
  this.wallet.publicKey // only allow payer to initialize own user stats account
1103
1103
  ),
1104
1104
  authority: this.wallet.publicKey,
1105
- payer: this.wallet.publicKey,
1105
+ payer: this.wallet.payer?.publicKey ?? this.wallet.publicKey,
1106
1106
  rent: anchor.web3.SYSVAR_RENT_PUBKEY,
1107
1107
  systemProgram: anchor.web3.SystemProgram.programId,
1108
1108
  state: await this.getStatePublicKey(),
@@ -1142,7 +1142,7 @@ export class DriftClient {
1142
1142
  accounts: {
1143
1143
  signedMsgUserOrders: signedMsgUserAccountPublicKey,
1144
1144
  authority,
1145
- payer: this.wallet.publicKey,
1145
+ payer: this.wallet.payer?.publicKey ?? this.wallet.publicKey,
1146
1146
  rent: anchor.web3.SYSVAR_RENT_PUBKEY,
1147
1147
  systemProgram: anchor.web3.SystemProgram.programId,
1148
1148
  },
@@ -1183,7 +1183,7 @@ export class DriftClient {
1183
1183
  accounts: {
1184
1184
  signedMsgUserOrders: signedMsgUserAccountPublicKey,
1185
1185
  authority,
1186
- payer: this.wallet.publicKey,
1186
+ payer: this.wallet.payer?.publicKey ?? this.wallet.publicKey,
1187
1187
  systemProgram: anchor.web3.SystemProgram.programId,
1188
1188
  user: await getUserAccountPublicKey(
1189
1189
  this.program.programId,
@@ -1321,7 +1321,7 @@ export class DriftClient {
1321
1321
  authority ?? this.wallet.publicKey
1322
1322
  ),
1323
1323
  authority: authority ?? this.wallet.publicKey,
1324
- payer: this.wallet.publicKey,
1324
+ payer: this.wallet.payer?.publicKey ?? this.wallet.publicKey,
1325
1325
  rent: anchor.web3.SYSVAR_RENT_PUBKEY,
1326
1326
  systemProgram: anchor.web3.SystemProgram.programId,
1327
1327
  },
@@ -1407,7 +1407,7 @@ export class DriftClient {
1407
1407
  user: userAccountPublicKey,
1408
1408
  userStats: this.getUserStatsAccountPublicKey(),
1409
1409
  authority: this.wallet.publicKey,
1410
- payer: this.wallet.publicKey,
1410
+ payer: this.wallet.payer?.publicKey ?? this.wallet.publicKey,
1411
1411
  rent: anchor.web3.SYSVAR_RENT_PUBKEY,
1412
1412
  systemProgram: anchor.web3.SystemProgram.programId,
1413
1413
  state: await this.getStatePublicKey(),
@@ -1457,7 +1457,7 @@ export class DriftClient {
1457
1457
  user: userAccountPublicKey,
1458
1458
  authority: this.wallet.publicKey,
1459
1459
  userStats: this.getUserStatsAccountPublicKey(),
1460
- payer: this.wallet.publicKey,
1460
+ payer: this.wallet.payer?.publicKey ?? this.wallet.publicKey,
1461
1461
  rent: anchor.web3.SYSVAR_RENT_PUBKEY,
1462
1462
  systemProgram: anchor.web3.SystemProgram.programId,
1463
1463
  },
@@ -8630,7 +8630,7 @@ export class DriftClient {
8630
8630
  this.wallet.publicKey // only allow payer to initialize own insurance fund stake account
8631
8631
  ),
8632
8632
  authority: this.wallet.publicKey,
8633
- payer: this.wallet.publicKey,
8633
+ payer: this.wallet.payer?.publicKey ?? this.wallet.publicKey,
8634
8634
  rent: anchor.web3.SYSVAR_RENT_PUBKEY,
8635
8635
  systemProgram: anchor.web3.SystemProgram.programId,
8636
8636
  state: await this.getStatePublicKey(),
@@ -9743,7 +9743,7 @@ export class DriftClient {
9743
9743
  const tx = await asV0Tx({
9744
9744
  connection: this.connection,
9745
9745
  ixs: [pullIx],
9746
- payer: this.wallet.publicKey,
9746
+ payer: this.wallet.payer?.publicKey ?? this.wallet.publicKey,
9747
9747
  computeUnitLimitMultiple: 1.3,
9748
9748
  lookupTables: await this.fetchAllLookupTableAccounts(),
9749
9749
  });
@@ -173,18 +173,18 @@ export abstract class BaseTxSender implements TxSender {
173
173
 
174
174
  if (preSigned) {
175
175
  signedTx = tx;
176
- // @ts-ignore
177
- } else if (this.wallet.payer) {
178
- // @ts-ignore
179
- tx.sign((additionalSigners ?? []).concat(this.wallet.payer));
180
- signedTx = tx;
181
176
  } else {
177
+ // Sign with user first for instruction authorities
182
178
  signedTx = await this.txHandler.signVersionedTx(
183
179
  tx,
184
180
  additionalSigners,
185
181
  undefined,
186
182
  this.wallet
187
183
  );
184
+ // Add payer signature if available
185
+ if (this.wallet.payer) {
186
+ signedTx.sign([this.wallet.payer]);
187
+ }
188
188
  }
189
189
 
190
190
  if (opts === undefined) {
@@ -191,7 +191,7 @@ export class TxHandler {
191
191
 
192
192
  [wallet, confirmationOpts] = this.getProps(wallet, confirmationOpts);
193
193
 
194
- tx.feePayer = wallet.publicKey;
194
+ tx.feePayer = wallet.payer?.publicKey ?? wallet.publicKey;
195
195
  recentBlockhash = recentBlockhash
196
196
  ? recentBlockhash
197
197
  : await this.getLatestBlockhashForTransaction();
@@ -398,7 +398,7 @@ export class TxHandler {
398
398
  [wallet] = this.getProps(wallet);
399
399
 
400
400
  const message = new TransactionMessage({
401
- payerKey: wallet.publicKey,
401
+ payerKey: wallet.payer?.publicKey ?? wallet.publicKey,
402
402
  recentBlockhash: recentBlockhash.blockhash,
403
403
  instructions: ixs,
404
404
  }).compileToLegacyMessage();
@@ -420,7 +420,7 @@ export class TxHandler {
420
420
  [wallet] = this.getProps(wallet);
421
421
 
422
422
  const message = new TransactionMessage({
423
- payerKey: wallet.publicKey,
423
+ payerKey: wallet.payer?.publicKey ?? wallet.publicKey,
424
424
  recentBlockhash: recentBlockhash.blockhash,
425
425
  instructions: ixs,
426
426
  }).compileToV0Message(lookupTableAccounts);
@@ -649,7 +649,8 @@ export class TxHandler {
649
649
  for (const tx of Object.values(txsMap)) {
650
650
  if (!tx) continue;
651
651
  tx.recentBlockhash = recentBlockhash.blockhash;
652
- tx.feePayer = wallet?.publicKey ?? this.wallet?.publicKey;
652
+ tx.feePayer =
653
+ wallet?.payer?.publicKey ?? wallet?.publicKey ?? this.wallet?.publicKey;
653
654
 
654
655
  // @ts-ignore
655
656
  tx.SIGNATURE_BLOCK_AND_EXPIRY = recentBlockhash;
@@ -689,7 +690,8 @@ export class TxHandler {
689
690
  // Extra handling for legacy transactions
690
691
  for (const [_key, tx] of filteredTxEntries) {
691
692
  if (this.isLegacyTransaction(tx)) {
692
- (tx as Transaction).feePayer = wallet.publicKey;
693
+ (tx as Transaction).feePayer =
694
+ wallet.payer?.publicKey ?? wallet.publicKey;
693
695
  }
694
696
  }
695
697
 
@@ -258,6 +258,7 @@ export class WhileValidTxSender extends BaseTxSender {
258
258
  throw e;
259
259
  } finally {
260
260
  stopWaiting();
261
+ this.untilValid.delete(txid);
261
262
  }
262
263
 
263
264
  return { txSig: txid, slot };