@streamflow/stream 8.4.0 → 8.7.0-alpha.0

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-RvzYFo_L.js';
2
2
  export { ContractError, IChain, ICluster } from '@streamflow/common';
3
3
  import 'p-queue';
4
4
  import '@solana/web3.js';
@@ -2429,40 +2429,91 @@ 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
+ * @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
2435
+ * @param {Omit<ICreateStreamSolanaExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
2436
+ * @returns Transaction instructions and metadata ID
2434
2437
  */
2435
- async create(data, extParams) {
2438
+ async buildCreateTransactionInstructions(data, extParams) {
2436
2439
  const { partner, amount, tokenProgramId } = data;
2437
- const { isNative, sender, customInstructions } = extParams;
2440
+ const { isNative, senderPublicKey, customInstructions } = extParams;
2438
2441
  const partnerPublicKey = partner ? new PublicKey(partner) : WITHDRAWOR_PUBLIC_KEY;
2439
2442
  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
- }
2443
+ const tempSender = { publicKey: senderPublicKey };
2443
2444
  const ixs = await this.getCreateATAInstructions(
2444
2445
  [partnerPublicKey],
2445
2446
  mintPublicKey,
2446
- sender,
2447
+ tempSender,
2447
2448
  true,
2448
2449
  tokenProgramId ? new PublicKey(tokenProgramId) : void 0
2449
2450
  );
2450
- const { ixs: createIxs, metadata, metadataPubKey } = await this.prepareCreateInstructions(data, extParams);
2451
+ const {
2452
+ ixs: createIxs,
2453
+ metadata,
2454
+ metadataPubKey
2455
+ } = await this.prepareCreateInstructions(data, {
2456
+ ...extParams,
2457
+ sender: tempSender
2458
+ });
2451
2459
  ixs.push(...createIxs);
2452
2460
  if (isNative) {
2453
2461
  const totalFee = await this.getTotalFee({
2454
2462
  address: partnerPublicKey.toString()
2455
2463
  });
2456
2464
  const totalAmount = calculateTotalAmountToDeposit(amount, totalFee);
2457
- ixs.push(...await prepareWrappedAccount(this.connection, sender.publicKey, totalAmount));
2465
+ ixs.push(...await prepareWrappedAccount(this.connection, tempSender.publicKey, totalAmount));
2458
2466
  }
2459
2467
  await this.applyCustomAfterInstructions(ixs, customInstructions, metadataPubKey);
2468
+ return {
2469
+ ixs,
2470
+ metadataId: metadataPubKey.toBase58(),
2471
+ metadata
2472
+ };
2473
+ }
2474
+ /**
2475
+ * Builds a transaction for creating a new stream/vesting contract without signing or executing it.
2476
+ * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
2477
+ * @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
2478
+ * @param {Omit<ICreateStreamSolanaExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
2479
+ * @returns Transaction and metadata information
2480
+ */
2481
+ async buildCreateTransaction(data, extParams) {
2482
+ const { senderPublicKey } = extParams;
2483
+ const { ixs, metadataId, metadata } = await this.buildCreateTransactionInstructions(data, extParams);
2484
+ const { tx, hash, context } = await prepareTransaction(this.connection, ixs, senderPublicKey, void 0, [
2485
+ metadata
2486
+ ]);
2487
+ return {
2488
+ tx,
2489
+ metadataId,
2490
+ metadata,
2491
+ hash: hash.blockhash,
2492
+ context
2493
+ };
2494
+ }
2495
+ /**
2496
+ * Creates a new stream/vesting contract.
2497
+ * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
2498
+ * @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
2499
+ * @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, native token handling, and compute settings
2500
+ * @returns Create result
2501
+ */
2502
+ async create(data, extParams) {
2503
+ const { sender } = extParams;
2504
+ if (!sender.publicKey) {
2505
+ throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
2506
+ }
2507
+ const { ixs, metadataId, metadata } = await this.buildCreateTransactionInstructions(data, {
2508
+ ...extParams,
2509
+ senderPublicKey: sender.publicKey
2510
+ });
2460
2511
  const { tx, hash, context } = await prepareTransaction(this.connection, ixs, sender.publicKey, void 0, [
2461
2512
  metadata
2462
2513
  ]);
2463
2514
  const signature = await signAndExecuteTransaction(
2464
2515
  this.connection,
2465
- extParams.sender,
2516
+ sender,
2466
2517
  tx,
2467
2518
  {
2468
2519
  hash,
@@ -2471,7 +2522,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
2471
2522
  },
2472
2523
  this.schedulingParams
2473
2524
  );
2474
- return { ixs, txId: signature, metadataId: metadataPubKey.toBase58() };
2525
+ return { ixs, txId: signature, metadataId };
2475
2526
  }
2476
2527
  async prepareCreateInstructions(streamParams, extParams) {
2477
2528
  const { ixs, metadata, metadataPubKey } = isCreateAlignedStreamData(streamParams) ? await this.prepareCreateAlignedUnlockInstructions(streamParams, extParams) : await this.prepareCreateStreamInstructions(streamParams, extParams);
@@ -2581,6 +2632,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
2581
2632
  /**
2582
2633
  * Creates a new stream/vesting contract.
2583
2634
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
2635
+ * @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
2636
+ * @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
2637
+ * @returns Create stream instructions
2584
2638
  */
2585
2639
  async prepareCreateStreamInstructions({
2586
2640
  recipient,
@@ -2681,6 +2735,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
2681
2735
  * - initialized contract PDA off chain
2682
2736
  *
2683
2737
  * If you are not sure if you should use create or create_unchecked, go for create to be safer.
2738
+ * @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
2739
+ * @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
2740
+ * @returns Create result
2684
2741
  */
2685
2742
  async createUnchecked(data, extParams) {
2686
2743
  const { ixs, metadata, metadataPubKey } = await this.prepareCreateUncheckedInstructions(data, extParams);
@@ -2798,24 +2855,17 @@ var SolanaStreamClient = class extends BaseStreamClient {
2798
2855
  return { ixs, metadata, metadataPubKey };
2799
2856
  }
2800
2857
  /**
2801
- * Creates multiple stream/vesting contracts.
2858
+ * Builds transaction instructions for creating multiple stream/vesting contracts without creating transactions.
2802
2859
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
2860
+ * @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
2861
+ * @param {Omit<ICreateStreamSolanaExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
2862
+ * @returns Create multiple transaction instructions
2803
2863
  */
2804
- async createMultiple(data, extParams) {
2864
+ async buildCreateMultipleTransactionInstructions(data, extParams) {
2805
2865
  const { recipients, ...streamParams } = data;
2806
- const {
2807
- sender,
2808
- metadataPubKeys: metadataPubKeysExt,
2809
- isNative,
2810
- computePrice,
2811
- computeLimit,
2812
- customInstructions
2813
- } = extParams;
2866
+ const { senderPublicKey, metadataPubKeys: metadataPubKeysExt, isNative, customInstructions } = extParams;
2814
2867
  const metadatas = [];
2815
2868
  const metadataToRecipient = {};
2816
- const errors = [];
2817
- const signatures = [];
2818
- const batch = [];
2819
2869
  const instructionsBatch = [];
2820
2870
  const metadataPubKeys = metadataPubKeysExt || [];
2821
2871
  const partnerPublicKey = data.partner ? new PublicKey(data.partner) : WITHDRAWOR_PUBLIC_KEY;
@@ -2823,18 +2873,14 @@ var SolanaStreamClient = class extends BaseStreamClient {
2823
2873
  if (recipients.length === 0) {
2824
2874
  throw new Error("Recipients array is empty!");
2825
2875
  }
2826
- if (!sender.publicKey) {
2827
- throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
2828
- }
2876
+ const tempSender = { publicKey: senderPublicKey };
2829
2877
  for (let i = 0; i < recipients.length; i++) {
2830
2878
  const recipientData = recipients[i];
2831
2879
  const createStreamData = { ...streamParams, ...recipientData };
2832
2880
  const createStreamExtParams = {
2833
- sender,
2881
+ sender: tempSender,
2834
2882
  metadataPubKeys: metadataPubKeys[i] ? [metadataPubKeys[i]] : void 0,
2835
- computePrice,
2836
- computeLimit,
2837
- customInstructions
2883
+ ...extParams
2838
2884
  };
2839
2885
  const { ixs, metadata, metadataPubKey } = await this.prepareCreateInstructions(
2840
2886
  createStreamData,
@@ -2849,21 +2895,80 @@ var SolanaStreamClient = class extends BaseStreamClient {
2849
2895
  recipient: recipientData.recipient
2850
2896
  });
2851
2897
  }
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
2898
  const prepareInstructions = await this.getCreateATAInstructions(
2857
2899
  [partnerPublicKey],
2858
2900
  mintPublicKey,
2859
- sender,
2901
+ tempSender,
2860
2902
  true
2861
2903
  );
2862
2904
  if (isNative) {
2863
2905
  const totalDepositedAmount = recipients.reduce((acc, recipient) => recipient.amount.add(acc), new BN4(0));
2864
- const nativeInstructions = await prepareWrappedAccount(this.connection, sender.publicKey, totalDepositedAmount);
2906
+ const nativeInstructions = await prepareWrappedAccount(
2907
+ this.connection,
2908
+ tempSender.publicKey,
2909
+ totalDepositedAmount
2910
+ );
2865
2911
  prepareInstructions.push(...nativeInstructions);
2866
2912
  }
2913
+ return {
2914
+ instructionsBatch,
2915
+ metadatas,
2916
+ metadataToRecipient,
2917
+ prepareInstructions
2918
+ };
2919
+ }
2920
+ /**
2921
+ * Builds multiple transactions for creating stream/vesting contracts without signing or executing them.
2922
+ * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
2923
+ * @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
2924
+ * @param {Omit<ICreateStreamSolanaExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
2925
+ * @returns Multiple transaction information
2926
+ */
2927
+ async buildCreateMultipleTransactions(data, extParams) {
2928
+ const { senderPublicKey } = extParams;
2929
+ const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, extParams);
2930
+ const { value: hash, context } = await this.connection.getLatestBlockhashAndContext();
2931
+ const batch = [];
2932
+ for (const { ixs, metadata, recipient } of instructionsBatch) {
2933
+ batch.push({ tx: createVersionedTransaction(ixs, senderPublicKey, hash.blockhash, [metadata]), recipient });
2934
+ }
2935
+ let prepareTx;
2936
+ if (prepareInstructions.length > 0) {
2937
+ prepareTx = createVersionedTransaction(prepareInstructions, senderPublicKey, hash.blockhash);
2938
+ }
2939
+ return {
2940
+ transactions: batch,
2941
+ metadatas,
2942
+ metadataToRecipient,
2943
+ hash,
2944
+ context,
2945
+ prepareTx
2946
+ };
2947
+ }
2948
+ /**
2949
+ * Creates multiple stream/vesting contracts.
2950
+ * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
2951
+ * @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
2952
+ * @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
2953
+ * @returns Multiple transaction information
2954
+ */
2955
+ async createMultiple(data, extParams) {
2956
+ const { sender, metadataPubKeys: metadataPubKeysExt } = extParams;
2957
+ if (!sender.publicKey) {
2958
+ throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
2959
+ }
2960
+ const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, {
2961
+ ...extParams,
2962
+ senderPublicKey: sender.publicKey
2963
+ });
2964
+ const errors = [];
2965
+ const signatures = [];
2966
+ const metadataPubKeys = metadataPubKeysExt || [];
2967
+ const batch = [];
2968
+ const { value: hash, context } = await this.connection.getLatestBlockhashAndContext();
2969
+ for (const { ixs, metadata, recipient } of instructionsBatch) {
2970
+ batch.push({ tx: createVersionedTransaction(ixs, sender.publicKey, hash.blockhash, [metadata]), recipient });
2971
+ }
2867
2972
  if (prepareInstructions.length > 0) {
2868
2973
  batch.push({
2869
2974
  tx: createVersionedTransaction(prepareInstructions, sender.publicKey, hash.blockhash),
@@ -2911,55 +3016,22 @@ var SolanaStreamClient = class extends BaseStreamClient {
2911
3016
  * Creates multiple stream/vesting contracts, and send all transactions sequentially.
2912
3017
  * 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
3018
  * In most cases, createMultiple should be used instead.
3019
+ * @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
3020
+ * @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
3021
+ * @returns Multiple transaction information
2914
3022
  */
2915
3023
  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
- }
3024
+ const { sender } = extParams;
2937
3025
  if (!sender.publicKey) {
2938
3026
  throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
2939
3027
  }
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
- }
3028
+ const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, {
3029
+ ...extParams,
3030
+ senderPublicKey: sender.publicKey
3031
+ });
3032
+ const errors = [];
3033
+ const signatures = [];
3034
+ const batch = [];
2963
3035
  const { value: hash, context } = await this.connection.getLatestBlockhashAndContext();
2964
3036
  for (const { ixs, metadata, recipient } of instructionsBatch) {
2965
3037
  const messageV0 = new TransactionMessage({
@@ -2973,17 +3045,6 @@ var SolanaStreamClient = class extends BaseStreamClient {
2973
3045
  }
2974
3046
  batch.push({ tx, recipient });
2975
3047
  }
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
3048
  if (prepareInstructions.length > 0) {
2988
3049
  const messageV0 = new TransactionMessage({
2989
3050
  payerKey: sender.publicKey,
@@ -3024,6 +3085,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
3024
3085
  }
3025
3086
  /**
3026
3087
  * Attempts withdrawing from the specified stream.
3088
+ * @param {IWithdrawData} withdrawData - Withdrawal parameters including stream ID and amount to withdraw
3089
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
3090
+ * @returns Transaction result
3027
3091
  */
3028
3092
  async withdraw({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, extParams) {
3029
3093
  const { invoker, customInstructions } = extParams;
@@ -3049,6 +3113,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
3049
3113
  }
3050
3114
  /**
3051
3115
  * Creates Transaction Instructions for withdrawal
3116
+ * @param {IWithdrawData} withdrawData - Withdrawal parameters including stream ID and amount to withdraw
3117
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
3118
+ * @returns Transaction instructions
3052
3119
  */
3053
3120
  async prepareWithdrawInstructions({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
3054
3121
  if (!invoker.publicKey) {
@@ -3095,6 +3162,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
3095
3162
  }
3096
3163
  /**
3097
3164
  * Attempts canceling the specified stream.
3165
+ * @param {ICancelData} cancelData - Cancellation parameters including stream ID
3166
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
3167
+ * @returns Transaction result
3098
3168
  */
3099
3169
  async cancel(cancelData, extParams) {
3100
3170
  const ixs = await this.prepareCancelInstructions(cancelData, extParams);
@@ -3112,6 +3182,12 @@ var SolanaStreamClient = class extends BaseStreamClient {
3112
3182
  );
3113
3183
  return { ixs, txId: signature };
3114
3184
  }
3185
+ /**
3186
+ * Creates Transaction Instructions for cancel
3187
+ * @param {ICancelData} cancelData - Cancellation parameters including stream ID
3188
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
3189
+ * @returns Transaction instructions
3190
+ */
3115
3191
  async prepareCancelInstructions(cancelData, extParams) {
3116
3192
  const streamPublicKey = new PublicKey(cancelData.id);
3117
3193
  const account = await this.connection.getAccountInfo(streamPublicKey);
@@ -3123,6 +3199,12 @@ var SolanaStreamClient = class extends BaseStreamClient {
3123
3199
  const ixs = isAlignedUnlock ? await this.prepareCancelAlignedUnlockInstructions(cancelData, extParams) : await this.prepareCancelStreamInstructions(cancelData, extParams);
3124
3200
  return ixs;
3125
3201
  }
3202
+ /**
3203
+ * Creates Transaction Instructions for cancel
3204
+ * @param {ICancelData} cancelData - Cancellation parameters including stream ID
3205
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
3206
+ * @returns Transaction instructions
3207
+ */
3126
3208
  async prepareCancelAlignedUnlockInstructions({ id }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
3127
3209
  if (!invoker.publicKey) {
3128
3210
  throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
@@ -3162,6 +3244,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
3162
3244
  }
3163
3245
  /**
3164
3246
  * Creates Transaction Instructions for cancel
3247
+ * @param {ICancelData} cancelData - Cancellation parameters including stream ID
3248
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
3249
+ * @returns Transaction instructions
3165
3250
  */
3166
3251
  async prepareCancelStreamInstructions({ id }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
3167
3252
  if (!invoker.publicKey) {
@@ -3211,6 +3296,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
3211
3296
  /**
3212
3297
  * Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
3213
3298
  * Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
3299
+ * @param {ITransferData} transferData - Transfer parameters including stream ID and new recipient address
3300
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
3301
+ * @returns Transaction result
3214
3302
  */
3215
3303
  async transfer({ id, newRecipient }, extParams) {
3216
3304
  const ixs = await this.prepareTransferInstructions({ id, newRecipient }, extParams);
@@ -3231,6 +3319,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
3231
3319
  /**
3232
3320
  * Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
3233
3321
  * Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
3322
+ * @param {ITransferData} transferData - Transfer parameters including stream ID and new recipient address
3323
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
3324
+ * @returns Transaction instructions
3234
3325
  */
3235
3326
  async prepareTransferInstructions({ id, newRecipient }, { invoker, computePrice, computeLimit = 100001 }) {
3236
3327
  if (!invoker.publicKey) {
@@ -3266,6 +3357,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
3266
3357
  }
3267
3358
  /**
3268
3359
  * Tops up stream account with specified amount.
3360
+ * @param {ITopUpData} topupData - Top-up parameters including stream ID and amount to add
3361
+ * @param {ITopUpStreamSolanaExt} extParams - Transaction configuration including invoker wallet, native token handling, and compute settings
3362
+ * @returns Transaction result
3269
3363
  */
3270
3364
  async topup({ id, amount }, extParams) {
3271
3365
  const ixs = await this.prepareTopupInstructions({ id, amount }, extParams);
@@ -3285,6 +3379,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
3285
3379
  }
3286
3380
  /**
3287
3381
  * Create Transaction instructions for topup
3382
+ * @param {ITopUpData} topupData - Top-up parameters including stream ID and amount to add
3383
+ * @param {ITopUpStreamSolanaExt} extParams - Transaction configuration including invoker wallet, native token handling, and compute settings
3384
+ * @returns Transaction instructions
3288
3385
  */
3289
3386
  async prepareTopupInstructions({ id, amount }, { invoker, isNative, computePrice, computeLimit }) {
3290
3387
  if (!invoker.publicKey) {
@@ -3326,6 +3423,8 @@ var SolanaStreamClient = class extends BaseStreamClient {
3326
3423
  }
3327
3424
  /**
3328
3425
  * Fetch stream data by its id (address).
3426
+ * @param {IGetOneData} getData - Query parameters containing the stream ID to fetch
3427
+ * @returns Stream data
3329
3428
  */
3330
3429
  async getOne({ id }) {
3331
3430
  const streamPublicKey = new PublicKey(id);
@@ -3347,6 +3446,8 @@ var SolanaStreamClient = class extends BaseStreamClient {
3347
3446
  }
3348
3447
  /**
3349
3448
  * Fetch all aligned outgoing streams/contracts by the provided public key.
3449
+ * @param {string} sender - Sender public key
3450
+ * @returns Record of stream data
3350
3451
  */
3351
3452
  async getOutgoingAlignedStreams(sender) {
3352
3453
  const streams = {};
@@ -3392,6 +3493,8 @@ var SolanaStreamClient = class extends BaseStreamClient {
3392
3493
  /**
3393
3494
  * Fetch streams/contracts by providing direction.
3394
3495
  * Streams are sorted by start time in ascending order.
3496
+ * @param {IGetAllData} getData - Query parameters including address, stream type filter, and direction filter
3497
+ * @returns Record of stream data
3395
3498
  */
3396
3499
  async get({
3397
3500
  address,
@@ -3441,6 +3544,11 @@ var SolanaStreamClient = class extends BaseStreamClient {
3441
3544
  if (type === "all" /* All */) return sortedStreams;
3442
3545
  return sortedStreams.filter((stream) => stream[1].type === type);
3443
3546
  }
3547
+ /**
3548
+ * Searches for streams/contracts by providing filters.
3549
+ * @param {ISearchStreams} data - Search by mint, sender, recipient or closed status
3550
+ * @returns Record of stream data
3551
+ */
3444
3552
  async searchStreams(data) {
3445
3553
  const filters = Object.entries(data).filter(([_, value]) => value !== void 0).map(([key, value]) => ({
3446
3554
  memcmp: {
@@ -3459,6 +3567,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
3459
3567
  }
3460
3568
  /**
3461
3569
  * Attempts updating the stream auto withdrawal params and amount per period
3570
+ * @param {IUpdateData} data - Update parameters including stream ID and new settings
3571
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
3572
+ * @returns Transaction result
3462
3573
  */
3463
3574
  async update(data, extParams) {
3464
3575
  const ixs = await this.prepareUpdateInstructions(data, extParams);
@@ -3481,6 +3592,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
3481
3592
  }
3482
3593
  /**
3483
3594
  * Create Transaction instructions for update
3595
+ * @param {IUpdateData} data - Update parameters including stream ID and new settings
3596
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
3597
+ * @returns Transaction instructions
3484
3598
  */
3485
3599
  async prepareUpdateInstructions(data, { invoker, computePrice, computeLimit }) {
3486
3600
  if (!invoker.publicKey) {
@@ -3505,6 +3619,11 @@ var SolanaStreamClient = class extends BaseStreamClient {
3505
3619
  );
3506
3620
  return ixs;
3507
3621
  }
3622
+ /**
3623
+ * Gets fees for a given address
3624
+ * @param {IGetFeesData} getData - Query parameters containing the partner address to check for custom fees
3625
+ * @returns Fees
3626
+ */
3508
3627
  async getFees({ address }) {
3509
3628
  const [metadataPubKey] = PublicKey.findProgramAddressSync(
3510
3629
  [Buffer.from(FEES_METADATA_SEED)],
@@ -3524,9 +3643,18 @@ var SolanaStreamClient = class extends BaseStreamClient {
3524
3643
  partnerFee: Number(filteredPartners[0].partner_fee.toFixed(4))
3525
3644
  };
3526
3645
  }
3646
+ /**
3647
+ * Gets default streamflow fee
3648
+ * @returns Default streamflow fee
3649
+ */
3527
3650
  async getDefaultStreamflowFee() {
3528
3651
  return DEFAULT_STREAMFLOW_FEE;
3529
3652
  }
3653
+ /**
3654
+ * Extracts error code from an error
3655
+ * @param {Error} err - Error
3656
+ * @returns Error code
3657
+ */
3530
3658
  extractErrorCode(err) {
3531
3659
  const logs = "logs" in err && Array.isArray(err.logs) ? err.logs : void 0;
3532
3660
  return extractSolanaErrorCode(err.toString() ?? "Unknown error!", logs);