@lavarage/sdk 6.8.9 → 6.8.92

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/dist/index.js CHANGED
@@ -1170,7 +1170,7 @@ function depositFunds(lavarageProgram, params) {
1170
1170
  return __async(this, null, function* () {
1171
1171
  var _a, _b, _c;
1172
1172
  const { blockhash } = yield lavarageProgram.provider.connection.getLatestBlockhash("finalized");
1173
- let instruction;
1173
+ let instruction, createTokenAccountIx;
1174
1174
  if (params.mint === void 0) {
1175
1175
  const computeFeeIx2 = import_web3.ComputeBudgetProgram.setComputeUnitPrice({
1176
1176
  microLamports: (_a = params.computeBudgetMicroLamports) != null ? _a : 15e4
@@ -1194,6 +1194,19 @@ function depositFunds(lavarageProgram, params) {
1194
1194
  const computeFeeIx2 = import_web3.ComputeBudgetProgram.setComputeUnitPrice({
1195
1195
  microLamports: (_b = params.computeBudgetMicroLamports) != null ? _b : 15e4
1196
1196
  });
1197
+ const destinationTokenAccount = (0, import_spl_token.getAssociatedTokenAddressSync)(
1198
+ mintPubkey,
1199
+ new import_web3.PublicKey(params.nodeWallet),
1200
+ true,
1201
+ mintOwner == null ? void 0 : mintOwner.owner
1202
+ );
1203
+ createTokenAccountIx = (0, import_spl_token.createAssociatedTokenAccountIdempotentInstruction)(
1204
+ lavarageProgram.provider.publicKey,
1205
+ destinationTokenAccount,
1206
+ params.nodeWallet,
1207
+ new import_web3.PublicKey(params.mint),
1208
+ mintOwner == null ? void 0 : mintOwner.owner
1209
+ );
1197
1210
  instruction = (0, import_spl_token.createTransferCheckedInstruction)(
1198
1211
  (0, import_spl_token.getAssociatedTokenAddressSync)(
1199
1212
  mintPubkey,
@@ -1202,12 +1215,7 @@ function depositFunds(lavarageProgram, params) {
1202
1215
  mintOwner == null ? void 0 : mintOwner.owner
1203
1216
  ),
1204
1217
  new import_web3.PublicKey(params.mint),
1205
- (0, import_spl_token.getAssociatedTokenAddressSync)(
1206
- mintPubkey,
1207
- new import_web3.PublicKey(params.nodeWallet),
1208
- true,
1209
- mintOwner == null ? void 0 : mintOwner.owner
1210
- ),
1218
+ destinationTokenAccount,
1211
1219
  lavarageProgram.provider.publicKey,
1212
1220
  params.amount,
1213
1221
  mintAccount.decimals,
@@ -1221,7 +1229,7 @@ function depositFunds(lavarageProgram, params) {
1221
1229
  const messageV0 = new import_web3.TransactionMessage({
1222
1230
  payerKey: lavarageProgram.provider.publicKey,
1223
1231
  recentBlockhash: blockhash,
1224
- instructions: [instruction, computeFeeIx]
1232
+ instructions: [createTokenAccountIx, instruction, computeFeeIx].filter(Boolean)
1225
1233
  }).compileToV0Message();
1226
1234
  return new import_web3.VersionedTransaction(messageV0);
1227
1235
  });