@streamflow/stream 8.6.0 → 8.7.0-alpha.p304.6732440

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.
@@ -2,8 +2,8 @@ import { A as AptosStreamClient, I as ICreateStreamAptosExt, a as ITransactionAp
2
2
  export { i as StreamflowAptos } from './index-DYIamO0j.cjs';
3
3
  import { E as EvmStreamClient } from './index-BMZATAYa.cjs';
4
4
  export { i as StreamflowEVM } from './index-BMZATAYa.cjs';
5
- import { S as SolanaStreamClient, I as ICreateStreamSolanaExt, a as IInteractStreamSolanaExt, b as ITopUpStreamSolanaExt } from './index-BAZFUaQL.cjs';
6
- export { s as AIRDROP_AMOUNT, q as AIRDROP_TEST_TOKEN, j as ALIGNED_COMPUTE_LIMIT, A as ALIGNED_PRECISION_FACTOR_POW, h as ALIGNED_UNLOCKS_PROGRAM_ID, k as CONTRACT_DISCRIMINATOR, m as CONTRACT_SEED, C as CREATE_PARAMS_PADDING, D as DEFAULT_STREAMFLOW_FEE, E as ESCROW_SEED, r as FEES_METADATA_SEED, F as FEE_ORACLE_PUBLIC_KEY, O as ORIGINAL_CONTRACT_SENDER_OFFSET, u as PARTNERS_SCHEMA, o as PARTNER_ORACLE_PROGRAM_ID, t as PARTNER_SCHEMA, P as PROGRAM_ID, w as SOLANA_ERROR_MAP, v as SOLANA_ERROR_MATCH_REGEX, p as STREAMFLOW_TREASURY_PUBLIC_KEY, g as STREAM_STRUCT_OFFSETS, f as STREAM_STRUCT_OFFSET_CLOSED, e as STREAM_STRUCT_OFFSET_MINT, d as STREAM_STRUCT_OFFSET_RECIPIENT, c as STREAM_STRUCT_OFFSET_SENDER, i as StreamflowSolana, l as TEST_ORACLE_DISCRIMINATOR, n as TEST_ORACLE_SEED, T as TX_FINALITY_CONFIRMED, W as WITHDRAWOR_PUBLIC_KEY } from './index-BAZFUaQL.cjs';
5
+ import { S as SolanaStreamClient, I as ICreateStreamSolanaExt, a as IInteractStreamSolanaExt, b as ITopUpStreamSolanaExt } from './index-Bll7jg8V.cjs';
6
+ export { s as AIRDROP_AMOUNT, q as AIRDROP_TEST_TOKEN, j as ALIGNED_COMPUTE_LIMIT, A as ALIGNED_PRECISION_FACTOR_POW, h as ALIGNED_UNLOCKS_PROGRAM_ID, k as CONTRACT_DISCRIMINATOR, m as CONTRACT_SEED, C as CREATE_PARAMS_PADDING, D as DEFAULT_STREAMFLOW_FEE, E as ESCROW_SEED, r as FEES_METADATA_SEED, F as FEE_ORACLE_PUBLIC_KEY, O as ORIGINAL_CONTRACT_SENDER_OFFSET, u as PARTNERS_SCHEMA, o as PARTNER_ORACLE_PROGRAM_ID, t as PARTNER_SCHEMA, P as PROGRAM_ID, w as SOLANA_ERROR_MAP, v as SOLANA_ERROR_MATCH_REGEX, p as STREAMFLOW_TREASURY_PUBLIC_KEY, g as STREAM_STRUCT_OFFSETS, f as STREAM_STRUCT_OFFSET_CLOSED, e as STREAM_STRUCT_OFFSET_MINT, d as STREAM_STRUCT_OFFSET_RECIPIENT, c as STREAM_STRUCT_OFFSET_SENDER, i as StreamflowSolana, l as TEST_ORACLE_DISCRIMINATOR, n as TEST_ORACLE_SEED, T as TX_FINALITY_CONFIRMED, W as WITHDRAWOR_PUBLIC_KEY } from './index-Bll7jg8V.cjs';
7
7
  import { S as SuiStreamClient } from './index-Y0HH2ugY.cjs';
8
8
  export { i as StreamflowSui } from './index-Y0HH2ugY.cjs';
9
9
  import { S as Stream, A as AlignedStream, I as ICreateStreamData, a as ICreateAlignedStreamData, b as StreamType, B as BaseStreamClient, c as SolanaStreamClientOptions, d as AptosStreamClientOptions, e as SuiStreamClientOptions, E as EvmStreamClientOptions, f as ICreateStreamSuiExt, g as ICreateResult, h as ICreateMultipleStreamData, i as IMultiTransactionResult, j as IWithdrawData, k as ITransactionSuiExt, l as ITransactionResult, m as ICancelData, n as ITransferData, o as ITopUpData, p as IGetOneData, q as IGetAllData, r as IUpdateData, s as IGetFeesData, t as IFees } from './BaseStreamClient-DOyJqO7R.cjs';
@@ -2455,40 +2455,99 @@ var SolanaStreamClient = class extends BaseStreamClient {
2455
2455
  return this.programId.toBase58();
2456
2456
  }
2457
2457
  /**
2458
- * Creates a new stream/vesting contract.
2458
+ * Builds transaction instructions for creating a new stream/vesting contract without creating a transaction.
2459
2459
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
2460
+ *
2461
+ * For native SOL (isNative: true), SOL wrapping instructions are automatically included in the correct order
2462
+ * (before stream creation) to ensure the WSOL account exists when the stream creation instruction executes.
2463
+ *
2464
+ * @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
2465
+ * @param {Omit<ICreateStreamSolanaExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
2466
+ * @returns Transaction instructions and metadata ID
2460
2467
  */
2461
- async create(data, extParams) {
2468
+ async buildCreateTransactionInstructions(data, extParams) {
2462
2469
  const { partner, amount, tokenProgramId } = data;
2463
- const { isNative, sender, customInstructions } = extParams;
2470
+ const { isNative, senderPublicKey, customInstructions } = extParams;
2464
2471
  const partnerPublicKey = partner ? new web3_js.PublicKey(partner) : WITHDRAWOR_PUBLIC_KEY;
2465
2472
  const mintPublicKey = new web3_js.PublicKey(data.tokenId);
2466
- if (!sender.publicKey) {
2467
- throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
2468
- }
2473
+ const tempSender = { publicKey: senderPublicKey };
2469
2474
  const ixs = await this.getCreateATAInstructions(
2470
2475
  [partnerPublicKey],
2471
2476
  mintPublicKey,
2472
- sender,
2477
+ tempSender,
2473
2478
  true,
2474
2479
  tokenProgramId ? new web3_js.PublicKey(tokenProgramId) : void 0
2475
2480
  );
2476
- const { ixs: createIxs, metadata, metadataPubKey } = await this.prepareCreateInstructions(data, extParams);
2477
- ixs.push(...createIxs);
2478
2481
  if (isNative) {
2479
2482
  const totalFee = await this.getTotalFee({
2480
2483
  address: partnerPublicKey.toString()
2481
2484
  });
2482
2485
  const totalAmount = calculateTotalAmountToDeposit(amount, totalFee);
2483
- ixs.push(...await solana.prepareWrappedAccount(this.connection, sender.publicKey, totalAmount));
2486
+ ixs.push(...await solana.prepareWrappedAccount(this.connection, tempSender.publicKey, totalAmount));
2484
2487
  }
2488
+ const {
2489
+ ixs: createIxs,
2490
+ metadata,
2491
+ metadataPubKey
2492
+ } = await this.prepareCreateInstructions(data, {
2493
+ ...extParams,
2494
+ sender: tempSender
2495
+ });
2496
+ ixs.push(...createIxs);
2485
2497
  await this.applyCustomAfterInstructions(ixs, customInstructions, metadataPubKey);
2498
+ return {
2499
+ ixs,
2500
+ metadataId: metadataPubKey.toBase58(),
2501
+ metadata
2502
+ };
2503
+ }
2504
+ /**
2505
+ * Builds a transaction for creating a new stream/vesting contract without signing or executing it.
2506
+ * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
2507
+ *
2508
+ * For native SOL (isNative: true), SOL wrapping instructions are automatically included in the correct order
2509
+ * (before stream creation) to ensure the WSOL account exists when the stream creation instruction executes.
2510
+ *
2511
+ * @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
2512
+ * @param {Omit<ICreateStreamSolanaExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
2513
+ * @returns Transaction and metadata information
2514
+ */
2515
+ async buildCreateTransaction(data, extParams) {
2516
+ const { senderPublicKey } = extParams;
2517
+ const { ixs, metadataId, metadata } = await this.buildCreateTransactionInstructions(data, extParams);
2518
+ const { tx, hash, context } = await solana.prepareTransaction(this.connection, ixs, senderPublicKey, void 0, [
2519
+ metadata
2520
+ ]);
2521
+ return {
2522
+ tx,
2523
+ metadataId,
2524
+ metadata,
2525
+ hash: hash.blockhash,
2526
+ context
2527
+ };
2528
+ }
2529
+ /**
2530
+ * Creates a new stream/vesting contract.
2531
+ * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
2532
+ * @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
2533
+ * @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, native token handling, and compute settings
2534
+ * @returns Create result
2535
+ */
2536
+ async create(data, extParams) {
2537
+ const { sender } = extParams;
2538
+ if (!sender.publicKey) {
2539
+ throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
2540
+ }
2541
+ const { ixs, metadataId, metadata } = await this.buildCreateTransactionInstructions(data, {
2542
+ ...extParams,
2543
+ senderPublicKey: sender.publicKey
2544
+ });
2486
2545
  const { tx, hash, context } = await solana.prepareTransaction(this.connection, ixs, sender.publicKey, void 0, [
2487
2546
  metadata
2488
2547
  ]);
2489
2548
  const signature = await solana.signAndExecuteTransaction(
2490
2549
  this.connection,
2491
- extParams.sender,
2550
+ sender,
2492
2551
  tx,
2493
2552
  {
2494
2553
  hash,
@@ -2497,7 +2556,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
2497
2556
  },
2498
2557
  this.schedulingParams
2499
2558
  );
2500
- return { ixs, txId: signature, metadataId: metadataPubKey.toBase58() };
2559
+ return { ixs, txId: signature, metadataId };
2501
2560
  }
2502
2561
  async prepareCreateInstructions(streamParams, extParams) {
2503
2562
  const { ixs, metadata, metadataPubKey } = isCreateAlignedStreamData(streamParams) ? await this.prepareCreateAlignedUnlockInstructions(streamParams, extParams) : await this.prepareCreateStreamInstructions(streamParams, extParams);
@@ -2607,6 +2666,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
2607
2666
  /**
2608
2667
  * Creates a new stream/vesting contract.
2609
2668
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
2669
+ * @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
2670
+ * @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
2671
+ * @returns Create stream instructions
2610
2672
  */
2611
2673
  async prepareCreateStreamInstructions({
2612
2674
  recipient,
@@ -2707,6 +2769,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
2707
2769
  * - initialized contract PDA off chain
2708
2770
  *
2709
2771
  * If you are not sure if you should use create or create_unchecked, go for create to be safer.
2772
+ * @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
2773
+ * @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
2774
+ * @returns Create result
2710
2775
  */
2711
2776
  async createUnchecked(data, extParams) {
2712
2777
  const { ixs, metadata, metadataPubKey } = await this.prepareCreateUncheckedInstructions(data, extParams);
@@ -2824,24 +2889,17 @@ var SolanaStreamClient = class extends BaseStreamClient {
2824
2889
  return { ixs, metadata, metadataPubKey };
2825
2890
  }
2826
2891
  /**
2827
- * Creates multiple stream/vesting contracts.
2892
+ * Builds transaction instructions for creating multiple stream/vesting contracts without creating transactions.
2828
2893
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
2894
+ * @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
2895
+ * @param {Omit<ICreateStreamSolanaExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
2896
+ * @returns Create multiple transaction instructions
2829
2897
  */
2830
- async createMultiple(data, extParams) {
2898
+ async buildCreateMultipleTransactionInstructions(data, extParams) {
2831
2899
  const { recipients, ...streamParams } = data;
2832
- const {
2833
- sender,
2834
- metadataPubKeys: metadataPubKeysExt,
2835
- isNative,
2836
- computePrice,
2837
- computeLimit,
2838
- customInstructions
2839
- } = extParams;
2900
+ const { senderPublicKey, metadataPubKeys: metadataPubKeysExt, isNative, customInstructions } = extParams;
2840
2901
  const metadatas = [];
2841
2902
  const metadataToRecipient = {};
2842
- const errors = [];
2843
- const signatures = [];
2844
- const batch = [];
2845
2903
  const instructionsBatch = [];
2846
2904
  const metadataPubKeys = metadataPubKeysExt || [];
2847
2905
  const partnerPublicKey = data.partner ? new web3_js.PublicKey(data.partner) : WITHDRAWOR_PUBLIC_KEY;
@@ -2849,18 +2907,14 @@ var SolanaStreamClient = class extends BaseStreamClient {
2849
2907
  if (recipients.length === 0) {
2850
2908
  throw new Error("Recipients array is empty!");
2851
2909
  }
2852
- if (!sender.publicKey) {
2853
- throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
2854
- }
2910
+ const tempSender = { publicKey: senderPublicKey };
2855
2911
  for (let i = 0; i < recipients.length; i++) {
2856
2912
  const recipientData = recipients[i];
2857
2913
  const createStreamData = { ...streamParams, ...recipientData };
2858
2914
  const createStreamExtParams = {
2859
- sender,
2915
+ sender: tempSender,
2860
2916
  metadataPubKeys: metadataPubKeys[i] ? [metadataPubKeys[i]] : void 0,
2861
- computePrice,
2862
- computeLimit,
2863
- customInstructions
2917
+ ...extParams
2864
2918
  };
2865
2919
  const { ixs, metadata, metadataPubKey } = await this.prepareCreateInstructions(
2866
2920
  createStreamData,
@@ -2875,21 +2929,99 @@ var SolanaStreamClient = class extends BaseStreamClient {
2875
2929
  recipient: recipientData.recipient
2876
2930
  });
2877
2931
  }
2878
- const { value: hash, context } = await this.connection.getLatestBlockhashAndContext();
2879
- for (const { ixs, metadata, recipient } of instructionsBatch) {
2880
- batch.push({ tx: solana.createVersionedTransaction(ixs, sender.publicKey, hash.blockhash, [metadata]), recipient });
2881
- }
2882
2932
  const prepareInstructions = await this.getCreateATAInstructions(
2883
2933
  [partnerPublicKey],
2884
2934
  mintPublicKey,
2885
- sender,
2935
+ tempSender,
2886
2936
  true
2887
2937
  );
2888
2938
  if (isNative) {
2889
2939
  const totalDepositedAmount = recipients.reduce((acc, recipient) => recipient.amount.add(acc), new BN4__default.default(0));
2890
- const nativeInstructions = await solana.prepareWrappedAccount(this.connection, sender.publicKey, totalDepositedAmount);
2940
+ const nativeInstructions = await solana.prepareWrappedAccount(
2941
+ this.connection,
2942
+ tempSender.publicKey,
2943
+ totalDepositedAmount
2944
+ );
2891
2945
  prepareInstructions.push(...nativeInstructions);
2892
2946
  }
2947
+ return {
2948
+ instructionsBatch,
2949
+ metadatas,
2950
+ metadataToRecipient,
2951
+ prepareInstructions
2952
+ };
2953
+ }
2954
+ /**
2955
+ * Builds multiple transactions for creating stream/vesting contracts without signing or executing them.
2956
+ * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
2957
+ *
2958
+ * IMPORTANT: When using native SOL (isNative: true), you MUST execute the prepareTx FIRST and wait for confirmation
2959
+ * before executing the stream creation transactions. Otherwise, stream creation will fail with "InvalidAccountData".
2960
+ *
2961
+ * @example
2962
+ * ```typescript
2963
+ * const result = await streamClient.buildCreateMultipleTransactions(data, { isNative: true, senderPublicKey });
2964
+ *
2965
+ * // CRITICAL: Execute prepareTx first if it exists
2966
+ * if (result.prepareTx) {
2967
+ * await connection.sendAndConfirmTransaction(result.prepareTx, [signer]);
2968
+ * }
2969
+ *
2970
+ * // Only then execute stream creation transactions
2971
+ * for (const item of result.transactions) {
2972
+ * await connection.sendAndConfirmTransaction(item.tx, [signer]);
2973
+ * }
2974
+ * ```
2975
+ *
2976
+ * @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
2977
+ * @param {Omit<ICreateStreamSolanaExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
2978
+ * @returns Multiple transaction information
2979
+ */
2980
+ async buildCreateMultipleTransactions(data, extParams) {
2981
+ const { senderPublicKey } = extParams;
2982
+ const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, extParams);
2983
+ const { value: hash, context } = await this.connection.getLatestBlockhashAndContext();
2984
+ const batch = [];
2985
+ for (const { ixs, metadata, recipient } of instructionsBatch) {
2986
+ batch.push({ tx: solana.createVersionedTransaction(ixs, senderPublicKey, hash.blockhash, [metadata]), recipient });
2987
+ }
2988
+ let prepareTx;
2989
+ if (prepareInstructions.length > 0) {
2990
+ prepareTx = solana.createVersionedTransaction(prepareInstructions, senderPublicKey, hash.blockhash);
2991
+ }
2992
+ return {
2993
+ transactions: batch,
2994
+ metadatas,
2995
+ metadataToRecipient,
2996
+ hash,
2997
+ context,
2998
+ prepareTx
2999
+ };
3000
+ }
3001
+ /**
3002
+ * Creates multiple stream/vesting contracts.
3003
+ * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
3004
+ * @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
3005
+ * @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
3006
+ * @returns Multiple transaction information
3007
+ */
3008
+ async createMultiple(data, extParams) {
3009
+ const { sender, metadataPubKeys: metadataPubKeysExt } = extParams;
3010
+ if (!sender.publicKey) {
3011
+ throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
3012
+ }
3013
+ const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, {
3014
+ ...extParams,
3015
+ senderPublicKey: sender.publicKey
3016
+ });
3017
+ const errors = [];
3018
+ const signatures = [];
3019
+ const metadataPubKeys = metadataPubKeysExt || [];
3020
+ const batch = [];
3021
+ const { value: hash, context } = await this.connection.getLatestBlockhashAndContext();
3022
+ for (const { ixs, metadata, recipient } of instructionsBatch) {
3023
+ batch.push({ tx: solana.createVersionedTransaction(ixs, sender.publicKey, hash.blockhash, [metadata]), recipient });
3024
+ }
2893
3025
  if (prepareInstructions.length > 0) {
2894
3026
  batch.push({
2895
3027
  tx: solana.createVersionedTransaction(prepareInstructions, sender.publicKey, hash.blockhash),
@@ -2937,55 +3069,22 @@ var SolanaStreamClient = class extends BaseStreamClient {
2937
3069
  * Creates multiple stream/vesting contracts, and send all transactions sequentially.
2938
3070
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
2939
3071
  * In most cases, createMultiple should be used instead.
3072
+ * @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
3073
+ * @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
3074
+ * @returns Multiple transaction information
2940
3075
  */
2941
3076
  async createMultipleSequential(data, extParams) {
2942
- const { recipients, ...streamParams } = data;
2943
- const {
2944
- sender,
2945
- metadataPubKeys: metadataPubKeysExt,
2946
- isNative,
2947
- computePrice,
2948
- computeLimit,
2949
- customInstructions
2950
- } = extParams;
2951
- const metadatas = [];
2952
- const metadataToRecipient = {};
2953
- const errors = [];
2954
- const signatures = [];
2955
- const batch = [];
2956
- const instructionsBatch = [];
2957
- const metadataPubKeys = metadataPubKeysExt || [];
2958
- const partnerPublicKey = data.partner ? new web3_js.PublicKey(data.partner) : WITHDRAWOR_PUBLIC_KEY;
2959
- const mintPublicKey = new web3_js.PublicKey(data.tokenId);
2960
- if (recipients.length === 0) {
2961
- throw new Error("Recipients array is empty!");
2962
- }
3077
+ const { sender } = extParams;
2963
3078
  if (!sender.publicKey) {
2964
3079
  throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
2965
3080
  }
2966
- for (let i = 0; i < recipients.length; i++) {
2967
- const recipientData = recipients[i];
2968
- const createStreamData = { ...streamParams, ...recipientData };
2969
- const createStreamExtParams = {
2970
- sender,
2971
- metadataPubKeys: metadataPubKeys[i] ? [metadataPubKeys[i]] : void 0,
2972
- computePrice,
2973
- computeLimit,
2974
- customInstructions
2975
- };
2976
- const { ixs, metadata, metadataPubKey } = await this.prepareCreateInstructions(
2977
- createStreamData,
2978
- createStreamExtParams
2979
- );
2980
- await this.applyCustomAfterInstructions(ixs, customInstructions, metadataPubKey);
2981
- metadataToRecipient[metadataPubKey.toBase58()] = recipientData;
2982
- metadatas.push(metadataPubKey.toBase58());
2983
- instructionsBatch.push({
2984
- ixs,
2985
- metadata,
2986
- recipient: recipientData.recipient
2987
- });
2988
- }
3081
+ const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, {
3082
+ ...extParams,
3083
+ senderPublicKey: sender.publicKey
3084
+ });
3085
+ const errors = [];
3086
+ const signatures = [];
3087
+ const batch = [];
2989
3088
  const { value: hash, context } = await this.connection.getLatestBlockhashAndContext();
2990
3089
  for (const { ixs, metadata, recipient } of instructionsBatch) {
2991
3090
  const messageV0 = new web3_js.TransactionMessage({
@@ -2999,17 +3098,6 @@ var SolanaStreamClient = class extends BaseStreamClient {
2999
3098
  }
3000
3099
  batch.push({ tx, recipient });
3001
3100
  }
3002
- const prepareInstructions = await this.getCreateATAInstructions(
3003
- [partnerPublicKey],
3004
- mintPublicKey,
3005
- sender,
3006
- true
3007
- );
3008
- if (isNative) {
3009
- const totalDepositedAmount = recipients.reduce((acc, recipient) => recipient.amount.add(acc), new BN4__default.default(0));
3010
- const nativeInstructions = await solana.prepareWrappedAccount(this.connection, sender.publicKey, totalDepositedAmount);
3011
- prepareInstructions.push(...nativeInstructions);
3012
- }
3013
3101
  if (prepareInstructions.length > 0) {
3014
3102
  const messageV0 = new web3_js.TransactionMessage({
3015
3103
  payerKey: sender.publicKey,
@@ -3050,6 +3138,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
3050
3138
  }
3051
3139
  /**
3052
3140
  * Attempts withdrawing from the specified stream.
3141
+ * @param {IWithdrawData} withdrawData - Withdrawal parameters including stream ID and amount to withdraw
3142
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
3143
+ * @returns Transaction result
3053
3144
  */
3054
3145
  async withdraw({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, extParams) {
3055
3146
  const { invoker, customInstructions } = extParams;
@@ -3075,6 +3166,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
3075
3166
  }
3076
3167
  /**
3077
3168
  * Creates Transaction Instructions for withdrawal
3169
+ * @param {IWithdrawData} withdrawData - Withdrawal parameters including stream ID and amount to withdraw
3170
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
3171
+ * @returns Transaction instructions
3078
3172
  */
3079
3173
  async prepareWithdrawInstructions({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
3080
3174
  if (!invoker.publicKey) {
@@ -3121,6 +3215,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
3121
3215
  }
3122
3216
  /**
3123
3217
  * Attempts canceling the specified stream.
3218
+ * @param {ICancelData} cancelData - Cancellation parameters including stream ID
3219
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
3220
+ * @returns Transaction result
3124
3221
  */
3125
3222
  async cancel(cancelData, extParams) {
3126
3223
  const ixs = await this.prepareCancelInstructions(cancelData, extParams);
@@ -3138,6 +3235,12 @@ var SolanaStreamClient = class extends BaseStreamClient {
3138
3235
  );
3139
3236
  return { ixs, txId: signature };
3140
3237
  }
3238
+ /**
3239
+ * Creates Transaction Instructions for cancel
3240
+ * @param {ICancelData} cancelData - Cancellation parameters including stream ID
3241
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
3242
+ * @returns Transaction instructions
3243
+ */
3141
3244
  async prepareCancelInstructions(cancelData, extParams) {
3142
3245
  const streamPublicKey = new web3_js.PublicKey(cancelData.id);
3143
3246
  const account = await this.connection.getAccountInfo(streamPublicKey);
@@ -3149,6 +3252,12 @@ var SolanaStreamClient = class extends BaseStreamClient {
3149
3252
  const ixs = isAlignedUnlock ? await this.prepareCancelAlignedUnlockInstructions(cancelData, extParams) : await this.prepareCancelStreamInstructions(cancelData, extParams);
3150
3253
  return ixs;
3151
3254
  }
3255
+ /**
3256
+ * Creates Transaction Instructions for cancel
3257
+ * @param {ICancelData} cancelData - Cancellation parameters including stream ID
3258
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
3259
+ * @returns Transaction instructions
3260
+ */
3152
3261
  async prepareCancelAlignedUnlockInstructions({ id }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
3153
3262
  if (!invoker.publicKey) {
3154
3263
  throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
@@ -3188,6 +3297,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
3188
3297
  }
3189
3298
  /**
3190
3299
  * Creates Transaction Instructions for cancel
3300
+ * @param {ICancelData} cancelData - Cancellation parameters including stream ID
3301
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
3302
+ * @returns Transaction instructions
3191
3303
  */
3192
3304
  async prepareCancelStreamInstructions({ id }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
3193
3305
  if (!invoker.publicKey) {
@@ -3237,6 +3349,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
3237
3349
  /**
3238
3350
  * Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
3239
3351
  * Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
3352
+ * @param {ITransferData} transferData - Transfer parameters including stream ID and new recipient address
3353
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
3354
+ * @returns Transaction result
3240
3355
  */
3241
3356
  async transfer({ id, newRecipient }, extParams) {
3242
3357
  const ixs = await this.prepareTransferInstructions({ id, newRecipient }, extParams);
@@ -3257,6 +3372,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
3257
3372
  /**
3258
3373
  * Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
3259
3374
  * Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
3375
+ * @param {ITransferData} transferData - Transfer parameters including stream ID and new recipient address
3376
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
3377
+ * @returns Transaction instructions
3260
3378
  */
3261
3379
  async prepareTransferInstructions({ id, newRecipient }, { invoker, computePrice, computeLimit = 100001 }) {
3262
3380
  if (!invoker.publicKey) {
@@ -3292,6 +3410,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
3292
3410
  }
3293
3411
  /**
3294
3412
  * Tops up stream account with specified amount.
3413
+ * @param {ITopUpData} topupData - Top-up parameters including stream ID and amount to add
3414
+ * @param {ITopUpStreamSolanaExt} extParams - Transaction configuration including invoker wallet, native token handling, and compute settings
3415
+ * @returns Transaction result
3295
3416
  */
3296
3417
  async topup({ id, amount }, extParams) {
3297
3418
  const ixs = await this.prepareTopupInstructions({ id, amount }, extParams);
@@ -3311,6 +3432,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
3311
3432
  }
3312
3433
  /**
3313
3434
  * Create Transaction instructions for topup
3435
+ * @param {ITopUpData} topupData - Top-up parameters including stream ID and amount to add
3436
+ * @param {ITopUpStreamSolanaExt} extParams - Transaction configuration including invoker wallet, native token handling, and compute settings
3437
+ * @returns Transaction instructions
3314
3438
  */
3315
3439
  async prepareTopupInstructions({ id, amount }, { invoker, isNative, computePrice, computeLimit }) {
3316
3440
  if (!invoker.publicKey) {
@@ -3352,6 +3476,8 @@ var SolanaStreamClient = class extends BaseStreamClient {
3352
3476
  }
3353
3477
  /**
3354
3478
  * Fetch stream data by its id (address).
3479
+ * @param {IGetOneData} getData - Query parameters containing the stream ID to fetch
3480
+ * @returns Stream data
3355
3481
  */
3356
3482
  async getOne({ id }) {
3357
3483
  const streamPublicKey = new web3_js.PublicKey(id);
@@ -3373,6 +3499,8 @@ var SolanaStreamClient = class extends BaseStreamClient {
3373
3499
  }
3374
3500
  /**
3375
3501
  * Fetch all aligned outgoing streams/contracts by the provided public key.
3502
+ * @param {string} sender - Sender public key
3503
+ * @returns Record of stream data
3376
3504
  */
3377
3505
  async getOutgoingAlignedStreams(sender) {
3378
3506
  const streams = {};
@@ -3418,6 +3546,8 @@ var SolanaStreamClient = class extends BaseStreamClient {
3418
3546
  /**
3419
3547
  * Fetch streams/contracts by providing direction.
3420
3548
  * Streams are sorted by start time in ascending order.
3549
+ * @param {IGetAllData} getData - Query parameters including address, stream type filter, and direction filter
3550
+ * @returns Record of stream data
3421
3551
  */
3422
3552
  async get({
3423
3553
  address,
@@ -3467,6 +3597,11 @@ var SolanaStreamClient = class extends BaseStreamClient {
3467
3597
  if (type === "all" /* All */) return sortedStreams;
3468
3598
  return sortedStreams.filter((stream) => stream[1].type === type);
3469
3599
  }
3600
+ /**
3601
+ * Searches for streams/contracts by providing filters.
3602
+ * @param {ISearchStreams} data - Search by mint, sender, recipient or closed status
3603
+ * @returns Record of stream data
3604
+ */
3470
3605
  async searchStreams(data) {
3471
3606
  const filters = Object.entries(data).filter(([_, value]) => value !== void 0).map(([key, value]) => ({
3472
3607
  memcmp: {
@@ -3485,6 +3620,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
3485
3620
  }
3486
3621
  /**
3487
3622
  * Attempts updating the stream auto withdrawal params and amount per period
3623
+ * @param {IUpdateData} data - Update parameters including stream ID and new settings
3624
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
3625
+ * @returns Transaction result
3488
3626
  */
3489
3627
  async update(data, extParams) {
3490
3628
  const ixs = await this.prepareUpdateInstructions(data, extParams);
@@ -3507,6 +3645,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
3507
3645
  }
3508
3646
  /**
3509
3647
  * Create Transaction instructions for update
3648
+ * @param {IUpdateData} data - Update parameters including stream ID and new settings
3649
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
3650
+ * @returns Transaction instructions
3510
3651
  */
3511
3652
  async prepareUpdateInstructions(data, { invoker, computePrice, computeLimit }) {
3512
3653
  if (!invoker.publicKey) {
@@ -3531,6 +3672,11 @@ var SolanaStreamClient = class extends BaseStreamClient {
3531
3672
  );
3532
3673
  return ixs;
3533
3674
  }
3675
+ /**
3676
+ * Gets fees for a given address
3677
+ * @param {IGetFeesData} getData - Query parameters containing the partner address to check for custom fees
3678
+ * @returns Fees
3679
+ */
3534
3680
  async getFees({ address }) {
3535
3681
  const [metadataPubKey] = web3_js.PublicKey.findProgramAddressSync(
3536
3682
  [buffer.Buffer.from(FEES_METADATA_SEED)],
@@ -3550,9 +3696,18 @@ var SolanaStreamClient = class extends BaseStreamClient {
3550
3696
  partnerFee: Number(filteredPartners[0].partner_fee.toFixed(4))
3551
3697
  };
3552
3698
  }
3699
+ /**
3700
+ * Gets default streamflow fee
3701
+ * @returns Default streamflow fee
3702
+ */
3553
3703
  async getDefaultStreamflowFee() {
3554
3704
  return DEFAULT_STREAMFLOW_FEE;
3555
3705
  }
3706
+ /**
3707
+ * Extracts error code from an error
3708
+ * @param {Error} err - Error
3709
+ * @returns Error code
3710
+ */
3556
3711
  extractErrorCode(err) {
3557
3712
  const logs = "logs" in err && Array.isArray(err.logs) ? err.logs : void 0;
3558
3713
  return extractSolanaErrorCode(err.toString() ?? "Unknown error!", logs);