@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.
@@ -1,4 +1,4 @@
1
- export { Z as Account, a3 as AlignedContract, M as AlignedUnlocksContract, a6 as BatchItem, a8 as BatchItemError, a9 as BatchItemResult, a7 as BatchItemSuccess, U as ChangeOracleParams, y as ClientCreationOptions, a2 as Contract, R as CreateParams, V as CreateTestOracleParams, a4 as DecodedStream, $ as ICreateSolanaExt, a1 as ICreateStreamInstructions, I as ICreateStreamSolanaExt, a as IInteractStreamSolanaExt, Y as ISearchStreams, b as ITopUpStreamSolanaExt, a0 as ITransactionSolanaExtWithInstructions, aa as InstructionGenerator, a5 as MetadataRecipientHashMap, N as OracleType, S as SolanaStreamClient, Q as TestOracle, X as UpdateTestOracleParams, af as cancelStreamInstruction, x as constants, ab as createStreamInstruction, ac as createUncheckedStreamInstruction, z as decodeStream, J as deriveContractPDA, K as deriveEscrowPDA, L as deriveTestOraclePDA, H as extractSolanaErrorCode, G as sendAndConfirmStreamRawTransaction, B as signAllTransactionWithRecipients, _ as timelockIDL, ah as topupStreamInstruction, ag as transferStreamInstruction, ae as updateStreamInstruction, ad as withdrawStreamInstruction } from '../index-DKkJbavt.js';
1
+ export { Z as Account, a3 as AlignedContract, M as AlignedUnlocksContract, a6 as BatchItem, a8 as BatchItemError, a9 as BatchItemResult, a7 as BatchItemSuccess, U as ChangeOracleParams, y as ClientCreationOptions, a2 as Contract, R as CreateParams, V as CreateTestOracleParams, a4 as DecodedStream, $ as ICreateSolanaExt, a1 as ICreateStreamInstructions, I as ICreateStreamSolanaExt, a as IInteractStreamSolanaExt, Y as ISearchStreams, b as ITopUpStreamSolanaExt, a0 as ITransactionSolanaExtWithInstructions, aa as InstructionGenerator, a5 as MetadataRecipientHashMap, N as OracleType, S as SolanaStreamClient, Q as TestOracle, X as UpdateTestOracleParams, af as cancelStreamInstruction, x as constants, ab as createStreamInstruction, ac as createUncheckedStreamInstruction, z as decodeStream, J as deriveContractPDA, K as deriveEscrowPDA, L as deriveTestOraclePDA, H as extractSolanaErrorCode, G as sendAndConfirmStreamRawTransaction, B as signAllTransactionWithRecipients, _ as timelockIDL, ah as topupStreamInstruction, ag as transferStreamInstruction, ae as updateStreamInstruction, ad as withdrawStreamInstruction } from '../index-D-w3ZCyC.js';
2
2
  export { ContractError, IChain, ICluster } from '@streamflow/common';
3
3
  import 'p-queue';
4
4
  import '@solana/web3.js';
@@ -2429,40 +2429,99 @@ var SolanaStreamClient = class extends BaseStreamClient {
2429
2429
  return this.programId.toBase58();
2430
2430
  }
2431
2431
  /**
2432
- * Creates a new stream/vesting contract.
2432
+ * Builds transaction instructions for creating a new stream/vesting contract without creating a transaction.
2433
2433
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
2434
+ *
2435
+ * For native SOL (isNative: true), SOL wrapping instructions are automatically included in the correct order
2436
+ * (before stream creation) to ensure the WSOL account exists when the stream creation instruction executes.
2437
+ *
2438
+ * @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
2439
+ * @param {Omit<ICreateStreamSolanaExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
2440
+ * @returns Transaction instructions and metadata ID
2434
2441
  */
2435
- async create(data, extParams) {
2442
+ async buildCreateTransactionInstructions(data, extParams) {
2436
2443
  const { partner, amount, tokenProgramId } = data;
2437
- const { isNative, sender, customInstructions } = extParams;
2444
+ const { isNative, senderPublicKey, customInstructions } = extParams;
2438
2445
  const partnerPublicKey = partner ? new PublicKey(partner) : WITHDRAWOR_PUBLIC_KEY;
2439
2446
  const mintPublicKey = new PublicKey(data.tokenId);
2440
- if (!sender.publicKey) {
2441
- throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
2442
- }
2447
+ const tempSender = { publicKey: senderPublicKey };
2443
2448
  const ixs = await this.getCreateATAInstructions(
2444
2449
  [partnerPublicKey],
2445
2450
  mintPublicKey,
2446
- sender,
2451
+ tempSender,
2447
2452
  true,
2448
2453
  tokenProgramId ? new PublicKey(tokenProgramId) : void 0
2449
2454
  );
2450
- const { ixs: createIxs, metadata, metadataPubKey } = await this.prepareCreateInstructions(data, extParams);
2451
- ixs.push(...createIxs);
2452
2455
  if (isNative) {
2453
2456
  const totalFee = await this.getTotalFee({
2454
2457
  address: partnerPublicKey.toString()
2455
2458
  });
2456
2459
  const totalAmount = calculateTotalAmountToDeposit(amount, totalFee);
2457
- ixs.push(...await prepareWrappedAccount(this.connection, sender.publicKey, totalAmount));
2460
+ ixs.push(...await prepareWrappedAccount(this.connection, tempSender.publicKey, totalAmount));
2458
2461
  }
2462
+ const {
2463
+ ixs: createIxs,
2464
+ metadata,
2465
+ metadataPubKey
2466
+ } = await this.prepareCreateInstructions(data, {
2467
+ ...extParams,
2468
+ sender: tempSender
2469
+ });
2470
+ ixs.push(...createIxs);
2459
2471
  await this.applyCustomAfterInstructions(ixs, customInstructions, metadataPubKey);
2472
+ return {
2473
+ ixs,
2474
+ metadataId: metadataPubKey.toBase58(),
2475
+ metadata
2476
+ };
2477
+ }
2478
+ /**
2479
+ * Builds a transaction for creating a new stream/vesting contract without signing or executing it.
2480
+ * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
2481
+ *
2482
+ * For native SOL (isNative: true), SOL wrapping instructions are automatically included in the correct order
2483
+ * (before stream creation) to ensure the WSOL account exists when the stream creation instruction executes.
2484
+ *
2485
+ * @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
2486
+ * @param {Omit<ICreateStreamSolanaExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
2487
+ * @returns Transaction and metadata information
2488
+ */
2489
+ async buildCreateTransaction(data, extParams) {
2490
+ const { senderPublicKey } = extParams;
2491
+ const { ixs, metadataId, metadata } = await this.buildCreateTransactionInstructions(data, extParams);
2492
+ const { tx, hash, context } = await prepareTransaction(this.connection, ixs, senderPublicKey, void 0, [
2493
+ metadata
2494
+ ]);
2495
+ return {
2496
+ tx,
2497
+ metadataId,
2498
+ metadata,
2499
+ hash: hash.blockhash,
2500
+ context
2501
+ };
2502
+ }
2503
+ /**
2504
+ * Creates a new stream/vesting contract.
2505
+ * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
2506
+ * @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
2507
+ * @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, native token handling, and compute settings
2508
+ * @returns Create result
2509
+ */
2510
+ async create(data, extParams) {
2511
+ const { sender } = extParams;
2512
+ if (!sender.publicKey) {
2513
+ throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
2514
+ }
2515
+ const { ixs, metadataId, metadata } = await this.buildCreateTransactionInstructions(data, {
2516
+ ...extParams,
2517
+ senderPublicKey: sender.publicKey
2518
+ });
2460
2519
  const { tx, hash, context } = await prepareTransaction(this.connection, ixs, sender.publicKey, void 0, [
2461
2520
  metadata
2462
2521
  ]);
2463
2522
  const signature = await signAndExecuteTransaction(
2464
2523
  this.connection,
2465
- extParams.sender,
2524
+ sender,
2466
2525
  tx,
2467
2526
  {
2468
2527
  hash,
@@ -2471,7 +2530,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
2471
2530
  },
2472
2531
  this.schedulingParams
2473
2532
  );
2474
- return { ixs, txId: signature, metadataId: metadataPubKey.toBase58() };
2533
+ return { ixs, txId: signature, metadataId };
2475
2534
  }
2476
2535
  async prepareCreateInstructions(streamParams, extParams) {
2477
2536
  const { ixs, metadata, metadataPubKey } = isCreateAlignedStreamData(streamParams) ? await this.prepareCreateAlignedUnlockInstructions(streamParams, extParams) : await this.prepareCreateStreamInstructions(streamParams, extParams);
@@ -2581,6 +2640,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
2581
2640
  /**
2582
2641
  * Creates a new stream/vesting contract.
2583
2642
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
2643
+ * @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
2644
+ * @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
2645
+ * @returns Create stream instructions
2584
2646
  */
2585
2647
  async prepareCreateStreamInstructions({
2586
2648
  recipient,
@@ -2681,6 +2743,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
2681
2743
  * - initialized contract PDA off chain
2682
2744
  *
2683
2745
  * If you are not sure if you should use create or create_unchecked, go for create to be safer.
2746
+ * @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
2747
+ * @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
2748
+ * @returns Create result
2684
2749
  */
2685
2750
  async createUnchecked(data, extParams) {
2686
2751
  const { ixs, metadata, metadataPubKey } = await this.prepareCreateUncheckedInstructions(data, extParams);
@@ -2798,24 +2863,17 @@ var SolanaStreamClient = class extends BaseStreamClient {
2798
2863
  return { ixs, metadata, metadataPubKey };
2799
2864
  }
2800
2865
  /**
2801
- * Creates multiple stream/vesting contracts.
2866
+ * Builds transaction instructions for creating multiple stream/vesting contracts without creating transactions.
2802
2867
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
2868
+ * @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
2869
+ * @param {Omit<ICreateStreamSolanaExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
2870
+ * @returns Create multiple transaction instructions
2803
2871
  */
2804
- async createMultiple(data, extParams) {
2872
+ async buildCreateMultipleTransactionInstructions(data, extParams) {
2805
2873
  const { recipients, ...streamParams } = data;
2806
- const {
2807
- sender,
2808
- metadataPubKeys: metadataPubKeysExt,
2809
- isNative,
2810
- computePrice,
2811
- computeLimit,
2812
- customInstructions
2813
- } = extParams;
2874
+ const { senderPublicKey, metadataPubKeys: metadataPubKeysExt, isNative, customInstructions } = extParams;
2814
2875
  const metadatas = [];
2815
2876
  const metadataToRecipient = {};
2816
- const errors = [];
2817
- const signatures = [];
2818
- const batch = [];
2819
2877
  const instructionsBatch = [];
2820
2878
  const metadataPubKeys = metadataPubKeysExt || [];
2821
2879
  const partnerPublicKey = data.partner ? new PublicKey(data.partner) : WITHDRAWOR_PUBLIC_KEY;
@@ -2823,18 +2881,14 @@ var SolanaStreamClient = class extends BaseStreamClient {
2823
2881
  if (recipients.length === 0) {
2824
2882
  throw new Error("Recipients array is empty!");
2825
2883
  }
2826
- if (!sender.publicKey) {
2827
- throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
2828
- }
2884
+ const tempSender = { publicKey: senderPublicKey };
2829
2885
  for (let i = 0; i < recipients.length; i++) {
2830
2886
  const recipientData = recipients[i];
2831
2887
  const createStreamData = { ...streamParams, ...recipientData };
2832
2888
  const createStreamExtParams = {
2833
- sender,
2889
+ sender: tempSender,
2834
2890
  metadataPubKeys: metadataPubKeys[i] ? [metadataPubKeys[i]] : void 0,
2835
- computePrice,
2836
- computeLimit,
2837
- customInstructions
2891
+ ...extParams
2838
2892
  };
2839
2893
  const { ixs, metadata, metadataPubKey } = await this.prepareCreateInstructions(
2840
2894
  createStreamData,
@@ -2849,21 +2903,99 @@ var SolanaStreamClient = class extends BaseStreamClient {
2849
2903
  recipient: recipientData.recipient
2850
2904
  });
2851
2905
  }
2852
- const { value: hash, context } = await this.connection.getLatestBlockhashAndContext();
2853
- for (const { ixs, metadata, recipient } of instructionsBatch) {
2854
- batch.push({ tx: createVersionedTransaction(ixs, sender.publicKey, hash.blockhash, [metadata]), recipient });
2855
- }
2856
2906
  const prepareInstructions = await this.getCreateATAInstructions(
2857
2907
  [partnerPublicKey],
2858
2908
  mintPublicKey,
2859
- sender,
2909
+ tempSender,
2860
2910
  true
2861
2911
  );
2862
2912
  if (isNative) {
2863
2913
  const totalDepositedAmount = recipients.reduce((acc, recipient) => recipient.amount.add(acc), new BN4(0));
2864
- const nativeInstructions = await prepareWrappedAccount(this.connection, sender.publicKey, totalDepositedAmount);
2914
+ const nativeInstructions = await prepareWrappedAccount(
2915
+ this.connection,
2916
+ tempSender.publicKey,
2917
+ totalDepositedAmount
2918
+ );
2865
2919
  prepareInstructions.push(...nativeInstructions);
2866
2920
  }
2921
+ return {
2922
+ instructionsBatch,
2923
+ metadatas,
2924
+ metadataToRecipient,
2925
+ prepareInstructions
2926
+ };
2927
+ }
2928
+ /**
2929
+ * Builds multiple transactions for creating stream/vesting contracts without signing or executing them.
2930
+ * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
2931
+ *
2932
+ * IMPORTANT: When using native SOL (isNative: true), you MUST execute the prepareTx FIRST and wait for confirmation
2933
+ * before executing the stream creation transactions. Otherwise, stream creation will fail with "InvalidAccountData".
2934
+ *
2935
+ * @example
2936
+ * ```typescript
2937
+ * const result = await streamClient.buildCreateMultipleTransactions(data, { isNative: true, senderPublicKey });
2938
+ *
2939
+ * // CRITICAL: Execute prepareTx first if it exists
2940
+ * if (result.prepareTx) {
2941
+ * await connection.sendAndConfirmTransaction(result.prepareTx, [signer]);
2942
+ * }
2943
+ *
2944
+ * // Only then execute stream creation transactions
2945
+ * for (const item of result.transactions) {
2946
+ * await connection.sendAndConfirmTransaction(item.tx, [signer]);
2947
+ * }
2948
+ * ```
2949
+ *
2950
+ * @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
2951
+ * @param {Omit<ICreateStreamSolanaExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
2952
+ * @returns Multiple transaction information
2953
+ */
2954
+ async buildCreateMultipleTransactions(data, extParams) {
2955
+ const { senderPublicKey } = extParams;
2956
+ const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, extParams);
2957
+ const { value: hash, context } = await this.connection.getLatestBlockhashAndContext();
2958
+ const batch = [];
2959
+ for (const { ixs, metadata, recipient } of instructionsBatch) {
2960
+ batch.push({ tx: createVersionedTransaction(ixs, senderPublicKey, hash.blockhash, [metadata]), recipient });
2961
+ }
2962
+ let prepareTx;
2963
+ if (prepareInstructions.length > 0) {
2964
+ prepareTx = createVersionedTransaction(prepareInstructions, senderPublicKey, hash.blockhash);
2965
+ }
2966
+ return {
2967
+ transactions: batch,
2968
+ metadatas,
2969
+ metadataToRecipient,
2970
+ hash,
2971
+ context,
2972
+ prepareTx
2973
+ };
2974
+ }
2975
+ /**
2976
+ * Creates multiple stream/vesting contracts.
2977
+ * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
2978
+ * @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
2979
+ * @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
2980
+ * @returns Multiple transaction information
2981
+ */
2982
+ async createMultiple(data, extParams) {
2983
+ const { sender, metadataPubKeys: metadataPubKeysExt } = extParams;
2984
+ if (!sender.publicKey) {
2985
+ throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
2986
+ }
2987
+ const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, {
2988
+ ...extParams,
2989
+ senderPublicKey: sender.publicKey
2990
+ });
2991
+ const errors = [];
2992
+ const signatures = [];
2993
+ const metadataPubKeys = metadataPubKeysExt || [];
2994
+ const batch = [];
2995
+ const { value: hash, context } = await this.connection.getLatestBlockhashAndContext();
2996
+ for (const { ixs, metadata, recipient } of instructionsBatch) {
2997
+ batch.push({ tx: createVersionedTransaction(ixs, sender.publicKey, hash.blockhash, [metadata]), recipient });
2998
+ }
2867
2999
  if (prepareInstructions.length > 0) {
2868
3000
  batch.push({
2869
3001
  tx: createVersionedTransaction(prepareInstructions, sender.publicKey, hash.blockhash),
@@ -2911,55 +3043,22 @@ var SolanaStreamClient = class extends BaseStreamClient {
2911
3043
  * Creates multiple stream/vesting contracts, and send all transactions sequentially.
2912
3044
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
2913
3045
  * In most cases, createMultiple should be used instead.
3046
+ * @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
3047
+ * @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
3048
+ * @returns Multiple transaction information
2914
3049
  */
2915
3050
  async createMultipleSequential(data, extParams) {
2916
- const { recipients, ...streamParams } = data;
2917
- const {
2918
- sender,
2919
- metadataPubKeys: metadataPubKeysExt,
2920
- isNative,
2921
- computePrice,
2922
- computeLimit,
2923
- customInstructions
2924
- } = extParams;
2925
- const metadatas = [];
2926
- const metadataToRecipient = {};
2927
- const errors = [];
2928
- const signatures = [];
2929
- const batch = [];
2930
- const instructionsBatch = [];
2931
- const metadataPubKeys = metadataPubKeysExt || [];
2932
- const partnerPublicKey = data.partner ? new PublicKey(data.partner) : WITHDRAWOR_PUBLIC_KEY;
2933
- const mintPublicKey = new PublicKey(data.tokenId);
2934
- if (recipients.length === 0) {
2935
- throw new Error("Recipients array is empty!");
2936
- }
3051
+ const { sender } = extParams;
2937
3052
  if (!sender.publicKey) {
2938
3053
  throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
2939
3054
  }
2940
- for (let i = 0; i < recipients.length; i++) {
2941
- const recipientData = recipients[i];
2942
- const createStreamData = { ...streamParams, ...recipientData };
2943
- const createStreamExtParams = {
2944
- sender,
2945
- metadataPubKeys: metadataPubKeys[i] ? [metadataPubKeys[i]] : void 0,
2946
- computePrice,
2947
- computeLimit,
2948
- customInstructions
2949
- };
2950
- const { ixs, metadata, metadataPubKey } = await this.prepareCreateInstructions(
2951
- createStreamData,
2952
- createStreamExtParams
2953
- );
2954
- await this.applyCustomAfterInstructions(ixs, customInstructions, metadataPubKey);
2955
- metadataToRecipient[metadataPubKey.toBase58()] = recipientData;
2956
- metadatas.push(metadataPubKey.toBase58());
2957
- instructionsBatch.push({
2958
- ixs,
2959
- metadata,
2960
- recipient: recipientData.recipient
2961
- });
2962
- }
3055
+ const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, {
3056
+ ...extParams,
3057
+ senderPublicKey: sender.publicKey
3058
+ });
3059
+ const errors = [];
3060
+ const signatures = [];
3061
+ const batch = [];
2963
3062
  const { value: hash, context } = await this.connection.getLatestBlockhashAndContext();
2964
3063
  for (const { ixs, metadata, recipient } of instructionsBatch) {
2965
3064
  const messageV0 = new TransactionMessage({
@@ -2973,17 +3072,6 @@ var SolanaStreamClient = class extends BaseStreamClient {
2973
3072
  }
2974
3073
  batch.push({ tx, recipient });
2975
3074
  }
2976
- const prepareInstructions = await this.getCreateATAInstructions(
2977
- [partnerPublicKey],
2978
- mintPublicKey,
2979
- sender,
2980
- true
2981
- );
2982
- if (isNative) {
2983
- const totalDepositedAmount = recipients.reduce((acc, recipient) => recipient.amount.add(acc), new BN4(0));
2984
- const nativeInstructions = await prepareWrappedAccount(this.connection, sender.publicKey, totalDepositedAmount);
2985
- prepareInstructions.push(...nativeInstructions);
2986
- }
2987
3075
  if (prepareInstructions.length > 0) {
2988
3076
  const messageV0 = new TransactionMessage({
2989
3077
  payerKey: sender.publicKey,
@@ -3024,6 +3112,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
3024
3112
  }
3025
3113
  /**
3026
3114
  * Attempts withdrawing from the specified stream.
3115
+ * @param {IWithdrawData} withdrawData - Withdrawal parameters including stream ID and amount to withdraw
3116
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
3117
+ * @returns Transaction result
3027
3118
  */
3028
3119
  async withdraw({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, extParams) {
3029
3120
  const { invoker, customInstructions } = extParams;
@@ -3049,6 +3140,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
3049
3140
  }
3050
3141
  /**
3051
3142
  * Creates Transaction Instructions for withdrawal
3143
+ * @param {IWithdrawData} withdrawData - Withdrawal parameters including stream ID and amount to withdraw
3144
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
3145
+ * @returns Transaction instructions
3052
3146
  */
3053
3147
  async prepareWithdrawInstructions({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
3054
3148
  if (!invoker.publicKey) {
@@ -3095,6 +3189,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
3095
3189
  }
3096
3190
  /**
3097
3191
  * Attempts canceling the specified stream.
3192
+ * @param {ICancelData} cancelData - Cancellation parameters including stream ID
3193
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
3194
+ * @returns Transaction result
3098
3195
  */
3099
3196
  async cancel(cancelData, extParams) {
3100
3197
  const ixs = await this.prepareCancelInstructions(cancelData, extParams);
@@ -3112,6 +3209,12 @@ var SolanaStreamClient = class extends BaseStreamClient {
3112
3209
  );
3113
3210
  return { ixs, txId: signature };
3114
3211
  }
3212
+ /**
3213
+ * Creates Transaction Instructions for cancel
3214
+ * @param {ICancelData} cancelData - Cancellation parameters including stream ID
3215
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
3216
+ * @returns Transaction instructions
3217
+ */
3115
3218
  async prepareCancelInstructions(cancelData, extParams) {
3116
3219
  const streamPublicKey = new PublicKey(cancelData.id);
3117
3220
  const account = await this.connection.getAccountInfo(streamPublicKey);
@@ -3123,6 +3226,12 @@ var SolanaStreamClient = class extends BaseStreamClient {
3123
3226
  const ixs = isAlignedUnlock ? await this.prepareCancelAlignedUnlockInstructions(cancelData, extParams) : await this.prepareCancelStreamInstructions(cancelData, extParams);
3124
3227
  return ixs;
3125
3228
  }
3229
+ /**
3230
+ * Creates Transaction Instructions for cancel
3231
+ * @param {ICancelData} cancelData - Cancellation parameters including stream ID
3232
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
3233
+ * @returns Transaction instructions
3234
+ */
3126
3235
  async prepareCancelAlignedUnlockInstructions({ id }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
3127
3236
  if (!invoker.publicKey) {
3128
3237
  throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
@@ -3162,6 +3271,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
3162
3271
  }
3163
3272
  /**
3164
3273
  * Creates Transaction Instructions for cancel
3274
+ * @param {ICancelData} cancelData - Cancellation parameters including stream ID
3275
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
3276
+ * @returns Transaction instructions
3165
3277
  */
3166
3278
  async prepareCancelStreamInstructions({ id }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
3167
3279
  if (!invoker.publicKey) {
@@ -3211,6 +3323,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
3211
3323
  /**
3212
3324
  * Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
3213
3325
  * Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
3326
+ * @param {ITransferData} transferData - Transfer parameters including stream ID and new recipient address
3327
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
3328
+ * @returns Transaction result
3214
3329
  */
3215
3330
  async transfer({ id, newRecipient }, extParams) {
3216
3331
  const ixs = await this.prepareTransferInstructions({ id, newRecipient }, extParams);
@@ -3231,6 +3346,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
3231
3346
  /**
3232
3347
  * Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
3233
3348
  * Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
3349
+ * @param {ITransferData} transferData - Transfer parameters including stream ID and new recipient address
3350
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
3351
+ * @returns Transaction instructions
3234
3352
  */
3235
3353
  async prepareTransferInstructions({ id, newRecipient }, { invoker, computePrice, computeLimit = 100001 }) {
3236
3354
  if (!invoker.publicKey) {
@@ -3266,6 +3384,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
3266
3384
  }
3267
3385
  /**
3268
3386
  * Tops up stream account with specified amount.
3387
+ * @param {ITopUpData} topupData - Top-up parameters including stream ID and amount to add
3388
+ * @param {ITopUpStreamSolanaExt} extParams - Transaction configuration including invoker wallet, native token handling, and compute settings
3389
+ * @returns Transaction result
3269
3390
  */
3270
3391
  async topup({ id, amount }, extParams) {
3271
3392
  const ixs = await this.prepareTopupInstructions({ id, amount }, extParams);
@@ -3285,6 +3406,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
3285
3406
  }
3286
3407
  /**
3287
3408
  * Create Transaction instructions for topup
3409
+ * @param {ITopUpData} topupData - Top-up parameters including stream ID and amount to add
3410
+ * @param {ITopUpStreamSolanaExt} extParams - Transaction configuration including invoker wallet, native token handling, and compute settings
3411
+ * @returns Transaction instructions
3288
3412
  */
3289
3413
  async prepareTopupInstructions({ id, amount }, { invoker, isNative, computePrice, computeLimit }) {
3290
3414
  if (!invoker.publicKey) {
@@ -3326,6 +3450,8 @@ var SolanaStreamClient = class extends BaseStreamClient {
3326
3450
  }
3327
3451
  /**
3328
3452
  * Fetch stream data by its id (address).
3453
+ * @param {IGetOneData} getData - Query parameters containing the stream ID to fetch
3454
+ * @returns Stream data
3329
3455
  */
3330
3456
  async getOne({ id }) {
3331
3457
  const streamPublicKey = new PublicKey(id);
@@ -3347,6 +3473,8 @@ var SolanaStreamClient = class extends BaseStreamClient {
3347
3473
  }
3348
3474
  /**
3349
3475
  * Fetch all aligned outgoing streams/contracts by the provided public key.
3476
+ * @param {string} sender - Sender public key
3477
+ * @returns Record of stream data
3350
3478
  */
3351
3479
  async getOutgoingAlignedStreams(sender) {
3352
3480
  const streams = {};
@@ -3392,6 +3520,8 @@ var SolanaStreamClient = class extends BaseStreamClient {
3392
3520
  /**
3393
3521
  * Fetch streams/contracts by providing direction.
3394
3522
  * Streams are sorted by start time in ascending order.
3523
+ * @param {IGetAllData} getData - Query parameters including address, stream type filter, and direction filter
3524
+ * @returns Record of stream data
3395
3525
  */
3396
3526
  async get({
3397
3527
  address,
@@ -3441,6 +3571,11 @@ var SolanaStreamClient = class extends BaseStreamClient {
3441
3571
  if (type === "all" /* All */) return sortedStreams;
3442
3572
  return sortedStreams.filter((stream) => stream[1].type === type);
3443
3573
  }
3574
+ /**
3575
+ * Searches for streams/contracts by providing filters.
3576
+ * @param {ISearchStreams} data - Search by mint, sender, recipient or closed status
3577
+ * @returns Record of stream data
3578
+ */
3444
3579
  async searchStreams(data) {
3445
3580
  const filters = Object.entries(data).filter(([_, value]) => value !== void 0).map(([key, value]) => ({
3446
3581
  memcmp: {
@@ -3459,6 +3594,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
3459
3594
  }
3460
3595
  /**
3461
3596
  * Attempts updating the stream auto withdrawal params and amount per period
3597
+ * @param {IUpdateData} data - Update parameters including stream ID and new settings
3598
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
3599
+ * @returns Transaction result
3462
3600
  */
3463
3601
  async update(data, extParams) {
3464
3602
  const ixs = await this.prepareUpdateInstructions(data, extParams);
@@ -3481,6 +3619,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
3481
3619
  }
3482
3620
  /**
3483
3621
  * Create Transaction instructions for update
3622
+ * @param {IUpdateData} data - Update parameters including stream ID and new settings
3623
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
3624
+ * @returns Transaction instructions
3484
3625
  */
3485
3626
  async prepareUpdateInstructions(data, { invoker, computePrice, computeLimit }) {
3486
3627
  if (!invoker.publicKey) {
@@ -3505,6 +3646,11 @@ var SolanaStreamClient = class extends BaseStreamClient {
3505
3646
  );
3506
3647
  return ixs;
3507
3648
  }
3649
+ /**
3650
+ * Gets fees for a given address
3651
+ * @param {IGetFeesData} getData - Query parameters containing the partner address to check for custom fees
3652
+ * @returns Fees
3653
+ */
3508
3654
  async getFees({ address }) {
3509
3655
  const [metadataPubKey] = PublicKey.findProgramAddressSync(
3510
3656
  [Buffer.from(FEES_METADATA_SEED)],
@@ -3524,9 +3670,18 @@ var SolanaStreamClient = class extends BaseStreamClient {
3524
3670
  partnerFee: Number(filteredPartners[0].partner_fee.toFixed(4))
3525
3671
  };
3526
3672
  }
3673
+ /**
3674
+ * Gets default streamflow fee
3675
+ * @returns Default streamflow fee
3676
+ */
3527
3677
  async getDefaultStreamflowFee() {
3528
3678
  return DEFAULT_STREAMFLOW_FEE;
3529
3679
  }
3680
+ /**
3681
+ * Extracts error code from an error
3682
+ * @param {Error} err - Error
3683
+ * @returns Error code
3684
+ */
3530
3685
  extractErrorCode(err) {
3531
3686
  const logs = "logs" in err && Array.isArray(err.logs) ? err.logs : void 0;
3532
3687
  return extractSolanaErrorCode(err.toString() ?? "Unknown error!", logs);