@streamflow/stream 8.6.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.
@@ -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-Dl7EztUT.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-Dl7EztUT.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,91 @@ 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
+ * @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
2461
+ * @param {Omit<ICreateStreamSolanaExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
2462
+ * @returns Transaction instructions and metadata ID
2460
2463
  */
2461
- async create(data, extParams) {
2464
+ async buildCreateTransactionInstructions(data, extParams) {
2462
2465
  const { partner, amount, tokenProgramId } = data;
2463
- const { isNative, sender, customInstructions } = extParams;
2466
+ const { isNative, senderPublicKey, customInstructions } = extParams;
2464
2467
  const partnerPublicKey = partner ? new web3_js.PublicKey(partner) : WITHDRAWOR_PUBLIC_KEY;
2465
2468
  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
- }
2469
+ const tempSender = { publicKey: senderPublicKey };
2469
2470
  const ixs = await this.getCreateATAInstructions(
2470
2471
  [partnerPublicKey],
2471
2472
  mintPublicKey,
2472
- sender,
2473
+ tempSender,
2473
2474
  true,
2474
2475
  tokenProgramId ? new web3_js.PublicKey(tokenProgramId) : void 0
2475
2476
  );
2476
- const { ixs: createIxs, metadata, metadataPubKey } = await this.prepareCreateInstructions(data, extParams);
2477
+ const {
2478
+ ixs: createIxs,
2479
+ metadata,
2480
+ metadataPubKey
2481
+ } = await this.prepareCreateInstructions(data, {
2482
+ ...extParams,
2483
+ sender: tempSender
2484
+ });
2477
2485
  ixs.push(...createIxs);
2478
2486
  if (isNative) {
2479
2487
  const totalFee = await this.getTotalFee({
2480
2488
  address: partnerPublicKey.toString()
2481
2489
  });
2482
2490
  const totalAmount = calculateTotalAmountToDeposit(amount, totalFee);
2483
- ixs.push(...await solana.prepareWrappedAccount(this.connection, sender.publicKey, totalAmount));
2491
+ ixs.push(...await solana.prepareWrappedAccount(this.connection, tempSender.publicKey, totalAmount));
2484
2492
  }
2485
2493
  await this.applyCustomAfterInstructions(ixs, customInstructions, metadataPubKey);
2494
+ return {
2495
+ ixs,
2496
+ metadataId: metadataPubKey.toBase58(),
2497
+ metadata
2498
+ };
2499
+ }
2500
+ /**
2501
+ * Builds a transaction for creating a new stream/vesting contract without signing or executing it.
2502
+ * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
2503
+ * @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
2504
+ * @param {Omit<ICreateStreamSolanaExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
2505
+ * @returns Transaction and metadata information
2506
+ */
2507
+ async buildCreateTransaction(data, extParams) {
2508
+ const { senderPublicKey } = extParams;
2509
+ const { ixs, metadataId, metadata } = await this.buildCreateTransactionInstructions(data, extParams);
2510
+ const { tx, hash, context } = await solana.prepareTransaction(this.connection, ixs, senderPublicKey, void 0, [
2511
+ metadata
2512
+ ]);
2513
+ return {
2514
+ tx,
2515
+ metadataId,
2516
+ metadata,
2517
+ hash: hash.blockhash,
2518
+ context
2519
+ };
2520
+ }
2521
+ /**
2522
+ * Creates a new stream/vesting contract.
2523
+ * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
2524
+ * @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
2525
+ * @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, native token handling, and compute settings
2526
+ * @returns Create result
2527
+ */
2528
+ async create(data, extParams) {
2529
+ const { sender } = extParams;
2530
+ if (!sender.publicKey) {
2531
+ throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
2532
+ }
2533
+ const { ixs, metadataId, metadata } = await this.buildCreateTransactionInstructions(data, {
2534
+ ...extParams,
2535
+ senderPublicKey: sender.publicKey
2536
+ });
2486
2537
  const { tx, hash, context } = await solana.prepareTransaction(this.connection, ixs, sender.publicKey, void 0, [
2487
2538
  metadata
2488
2539
  ]);
2489
2540
  const signature = await solana.signAndExecuteTransaction(
2490
2541
  this.connection,
2491
- extParams.sender,
2542
+ sender,
2492
2543
  tx,
2493
2544
  {
2494
2545
  hash,
@@ -2497,7 +2548,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
2497
2548
  },
2498
2549
  this.schedulingParams
2499
2550
  );
2500
- return { ixs, txId: signature, metadataId: metadataPubKey.toBase58() };
2551
+ return { ixs, txId: signature, metadataId };
2501
2552
  }
2502
2553
  async prepareCreateInstructions(streamParams, extParams) {
2503
2554
  const { ixs, metadata, metadataPubKey } = isCreateAlignedStreamData(streamParams) ? await this.prepareCreateAlignedUnlockInstructions(streamParams, extParams) : await this.prepareCreateStreamInstructions(streamParams, extParams);
@@ -2607,6 +2658,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
2607
2658
  /**
2608
2659
  * Creates a new stream/vesting contract.
2609
2660
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
2661
+ * @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
2662
+ * @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
2663
+ * @returns Create stream instructions
2610
2664
  */
2611
2665
  async prepareCreateStreamInstructions({
2612
2666
  recipient,
@@ -2707,6 +2761,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
2707
2761
  * - initialized contract PDA off chain
2708
2762
  *
2709
2763
  * If you are not sure if you should use create or create_unchecked, go for create to be safer.
2764
+ * @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
2765
+ * @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
2766
+ * @returns Create result
2710
2767
  */
2711
2768
  async createUnchecked(data, extParams) {
2712
2769
  const { ixs, metadata, metadataPubKey } = await this.prepareCreateUncheckedInstructions(data, extParams);
@@ -2824,24 +2881,17 @@ var SolanaStreamClient = class extends BaseStreamClient {
2824
2881
  return { ixs, metadata, metadataPubKey };
2825
2882
  }
2826
2883
  /**
2827
- * Creates multiple stream/vesting contracts.
2884
+ * Builds transaction instructions for creating multiple stream/vesting contracts without creating transactions.
2828
2885
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
2886
+ * @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
2887
+ * @param {Omit<ICreateStreamSolanaExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
2888
+ * @returns Create multiple transaction instructions
2829
2889
  */
2830
- async createMultiple(data, extParams) {
2890
+ async buildCreateMultipleTransactionInstructions(data, extParams) {
2831
2891
  const { recipients, ...streamParams } = data;
2832
- const {
2833
- sender,
2834
- metadataPubKeys: metadataPubKeysExt,
2835
- isNative,
2836
- computePrice,
2837
- computeLimit,
2838
- customInstructions
2839
- } = extParams;
2892
+ const { senderPublicKey, metadataPubKeys: metadataPubKeysExt, isNative, customInstructions } = extParams;
2840
2893
  const metadatas = [];
2841
2894
  const metadataToRecipient = {};
2842
- const errors = [];
2843
- const signatures = [];
2844
- const batch = [];
2845
2895
  const instructionsBatch = [];
2846
2896
  const metadataPubKeys = metadataPubKeysExt || [];
2847
2897
  const partnerPublicKey = data.partner ? new web3_js.PublicKey(data.partner) : WITHDRAWOR_PUBLIC_KEY;
@@ -2849,18 +2899,14 @@ var SolanaStreamClient = class extends BaseStreamClient {
2849
2899
  if (recipients.length === 0) {
2850
2900
  throw new Error("Recipients array is empty!");
2851
2901
  }
2852
- if (!sender.publicKey) {
2853
- throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
2854
- }
2902
+ const tempSender = { publicKey: senderPublicKey };
2855
2903
  for (let i = 0; i < recipients.length; i++) {
2856
2904
  const recipientData = recipients[i];
2857
2905
  const createStreamData = { ...streamParams, ...recipientData };
2858
2906
  const createStreamExtParams = {
2859
- sender,
2907
+ sender: tempSender,
2860
2908
  metadataPubKeys: metadataPubKeys[i] ? [metadataPubKeys[i]] : void 0,
2861
- computePrice,
2862
- computeLimit,
2863
- customInstructions
2909
+ ...extParams
2864
2910
  };
2865
2911
  const { ixs, metadata, metadataPubKey } = await this.prepareCreateInstructions(
2866
2912
  createStreamData,
@@ -2875,21 +2921,80 @@ var SolanaStreamClient = class extends BaseStreamClient {
2875
2921
  recipient: recipientData.recipient
2876
2922
  });
2877
2923
  }
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
2924
  const prepareInstructions = await this.getCreateATAInstructions(
2883
2925
  [partnerPublicKey],
2884
2926
  mintPublicKey,
2885
- sender,
2927
+ tempSender,
2886
2928
  true
2887
2929
  );
2888
2930
  if (isNative) {
2889
2931
  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);
2932
+ const nativeInstructions = await solana.prepareWrappedAccount(
2933
+ this.connection,
2934
+ tempSender.publicKey,
2935
+ totalDepositedAmount
2936
+ );
2891
2937
  prepareInstructions.push(...nativeInstructions);
2892
2938
  }
2939
+ return {
2940
+ instructionsBatch,
2941
+ metadatas,
2942
+ metadataToRecipient,
2943
+ prepareInstructions
2944
+ };
2945
+ }
2946
+ /**
2947
+ * Builds multiple transactions for creating stream/vesting contracts without signing or executing them.
2948
+ * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
2949
+ * @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
2950
+ * @param {Omit<ICreateStreamSolanaExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
2951
+ * @returns Multiple transaction information
2952
+ */
2953
+ async buildCreateMultipleTransactions(data, extParams) {
2954
+ const { senderPublicKey } = extParams;
2955
+ const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, extParams);
2956
+ const { value: hash, context } = await this.connection.getLatestBlockhashAndContext();
2957
+ const batch = [];
2958
+ for (const { ixs, metadata, recipient } of instructionsBatch) {
2959
+ batch.push({ tx: solana.createVersionedTransaction(ixs, senderPublicKey, hash.blockhash, [metadata]), recipient });
2960
+ }
2961
+ let prepareTx;
2962
+ if (prepareInstructions.length > 0) {
2963
+ prepareTx = solana.createVersionedTransaction(prepareInstructions, senderPublicKey, hash.blockhash);
2964
+ }
2965
+ return {
2966
+ transactions: batch,
2967
+ metadatas,
2968
+ metadataToRecipient,
2969
+ hash,
2970
+ context,
2971
+ prepareTx
2972
+ };
2973
+ }
2974
+ /**
2975
+ * Creates multiple stream/vesting contracts.
2976
+ * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
2977
+ * @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
2978
+ * @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
2979
+ * @returns Multiple transaction information
2980
+ */
2981
+ async createMultiple(data, extParams) {
2982
+ const { sender, metadataPubKeys: metadataPubKeysExt } = extParams;
2983
+ if (!sender.publicKey) {
2984
+ throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
2985
+ }
2986
+ const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, {
2987
+ ...extParams,
2988
+ senderPublicKey: sender.publicKey
2989
+ });
2990
+ const errors = [];
2991
+ const signatures = [];
2992
+ const metadataPubKeys = metadataPubKeysExt || [];
2993
+ const batch = [];
2994
+ const { value: hash, context } = await this.connection.getLatestBlockhashAndContext();
2995
+ for (const { ixs, metadata, recipient } of instructionsBatch) {
2996
+ batch.push({ tx: solana.createVersionedTransaction(ixs, sender.publicKey, hash.blockhash, [metadata]), recipient });
2997
+ }
2893
2998
  if (prepareInstructions.length > 0) {
2894
2999
  batch.push({
2895
3000
  tx: solana.createVersionedTransaction(prepareInstructions, sender.publicKey, hash.blockhash),
@@ -2937,55 +3042,22 @@ var SolanaStreamClient = class extends BaseStreamClient {
2937
3042
  * Creates multiple stream/vesting contracts, and send all transactions sequentially.
2938
3043
  * 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
3044
  * In most cases, createMultiple should be used instead.
3045
+ * @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
3046
+ * @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
3047
+ * @returns Multiple transaction information
2940
3048
  */
2941
3049
  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
- }
3050
+ const { sender } = extParams;
2963
3051
  if (!sender.publicKey) {
2964
3052
  throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
2965
3053
  }
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
- }
3054
+ const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, {
3055
+ ...extParams,
3056
+ senderPublicKey: sender.publicKey
3057
+ });
3058
+ const errors = [];
3059
+ const signatures = [];
3060
+ const batch = [];
2989
3061
  const { value: hash, context } = await this.connection.getLatestBlockhashAndContext();
2990
3062
  for (const { ixs, metadata, recipient } of instructionsBatch) {
2991
3063
  const messageV0 = new web3_js.TransactionMessage({
@@ -2999,17 +3071,6 @@ var SolanaStreamClient = class extends BaseStreamClient {
2999
3071
  }
3000
3072
  batch.push({ tx, recipient });
3001
3073
  }
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
3074
  if (prepareInstructions.length > 0) {
3014
3075
  const messageV0 = new web3_js.TransactionMessage({
3015
3076
  payerKey: sender.publicKey,
@@ -3050,6 +3111,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
3050
3111
  }
3051
3112
  /**
3052
3113
  * Attempts withdrawing from the specified stream.
3114
+ * @param {IWithdrawData} withdrawData - Withdrawal parameters including stream ID and amount to withdraw
3115
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
3116
+ * @returns Transaction result
3053
3117
  */
3054
3118
  async withdraw({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, extParams) {
3055
3119
  const { invoker, customInstructions } = extParams;
@@ -3075,6 +3139,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
3075
3139
  }
3076
3140
  /**
3077
3141
  * Creates Transaction Instructions for withdrawal
3142
+ * @param {IWithdrawData} withdrawData - Withdrawal parameters including stream ID and amount to withdraw
3143
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
3144
+ * @returns Transaction instructions
3078
3145
  */
3079
3146
  async prepareWithdrawInstructions({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
3080
3147
  if (!invoker.publicKey) {
@@ -3121,6 +3188,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
3121
3188
  }
3122
3189
  /**
3123
3190
  * Attempts canceling the specified stream.
3191
+ * @param {ICancelData} cancelData - Cancellation parameters including stream ID
3192
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
3193
+ * @returns Transaction result
3124
3194
  */
3125
3195
  async cancel(cancelData, extParams) {
3126
3196
  const ixs = await this.prepareCancelInstructions(cancelData, extParams);
@@ -3138,6 +3208,12 @@ var SolanaStreamClient = class extends BaseStreamClient {
3138
3208
  );
3139
3209
  return { ixs, txId: signature };
3140
3210
  }
3211
+ /**
3212
+ * Creates Transaction Instructions for cancel
3213
+ * @param {ICancelData} cancelData - Cancellation parameters including stream ID
3214
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
3215
+ * @returns Transaction instructions
3216
+ */
3141
3217
  async prepareCancelInstructions(cancelData, extParams) {
3142
3218
  const streamPublicKey = new web3_js.PublicKey(cancelData.id);
3143
3219
  const account = await this.connection.getAccountInfo(streamPublicKey);
@@ -3149,6 +3225,12 @@ var SolanaStreamClient = class extends BaseStreamClient {
3149
3225
  const ixs = isAlignedUnlock ? await this.prepareCancelAlignedUnlockInstructions(cancelData, extParams) : await this.prepareCancelStreamInstructions(cancelData, extParams);
3150
3226
  return ixs;
3151
3227
  }
3228
+ /**
3229
+ * Creates Transaction Instructions for cancel
3230
+ * @param {ICancelData} cancelData - Cancellation parameters including stream ID
3231
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
3232
+ * @returns Transaction instructions
3233
+ */
3152
3234
  async prepareCancelAlignedUnlockInstructions({ id }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
3153
3235
  if (!invoker.publicKey) {
3154
3236
  throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
@@ -3188,6 +3270,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
3188
3270
  }
3189
3271
  /**
3190
3272
  * Creates Transaction Instructions for cancel
3273
+ * @param {ICancelData} cancelData - Cancellation parameters including stream ID
3274
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
3275
+ * @returns Transaction instructions
3191
3276
  */
3192
3277
  async prepareCancelStreamInstructions({ id }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
3193
3278
  if (!invoker.publicKey) {
@@ -3237,6 +3322,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
3237
3322
  /**
3238
3323
  * Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
3239
3324
  * Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
3325
+ * @param {ITransferData} transferData - Transfer parameters including stream ID and new recipient address
3326
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
3327
+ * @returns Transaction result
3240
3328
  */
3241
3329
  async transfer({ id, newRecipient }, extParams) {
3242
3330
  const ixs = await this.prepareTransferInstructions({ id, newRecipient }, extParams);
@@ -3257,6 +3345,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
3257
3345
  /**
3258
3346
  * Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
3259
3347
  * Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
3348
+ * @param {ITransferData} transferData - Transfer parameters including stream ID and new recipient address
3349
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
3350
+ * @returns Transaction instructions
3260
3351
  */
3261
3352
  async prepareTransferInstructions({ id, newRecipient }, { invoker, computePrice, computeLimit = 100001 }) {
3262
3353
  if (!invoker.publicKey) {
@@ -3292,6 +3383,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
3292
3383
  }
3293
3384
  /**
3294
3385
  * Tops up stream account with specified amount.
3386
+ * @param {ITopUpData} topupData - Top-up parameters including stream ID and amount to add
3387
+ * @param {ITopUpStreamSolanaExt} extParams - Transaction configuration including invoker wallet, native token handling, and compute settings
3388
+ * @returns Transaction result
3295
3389
  */
3296
3390
  async topup({ id, amount }, extParams) {
3297
3391
  const ixs = await this.prepareTopupInstructions({ id, amount }, extParams);
@@ -3311,6 +3405,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
3311
3405
  }
3312
3406
  /**
3313
3407
  * Create Transaction instructions for topup
3408
+ * @param {ITopUpData} topupData - Top-up parameters including stream ID and amount to add
3409
+ * @param {ITopUpStreamSolanaExt} extParams - Transaction configuration including invoker wallet, native token handling, and compute settings
3410
+ * @returns Transaction instructions
3314
3411
  */
3315
3412
  async prepareTopupInstructions({ id, amount }, { invoker, isNative, computePrice, computeLimit }) {
3316
3413
  if (!invoker.publicKey) {
@@ -3352,6 +3449,8 @@ var SolanaStreamClient = class extends BaseStreamClient {
3352
3449
  }
3353
3450
  /**
3354
3451
  * Fetch stream data by its id (address).
3452
+ * @param {IGetOneData} getData - Query parameters containing the stream ID to fetch
3453
+ * @returns Stream data
3355
3454
  */
3356
3455
  async getOne({ id }) {
3357
3456
  const streamPublicKey = new web3_js.PublicKey(id);
@@ -3373,6 +3472,8 @@ var SolanaStreamClient = class extends BaseStreamClient {
3373
3472
  }
3374
3473
  /**
3375
3474
  * Fetch all aligned outgoing streams/contracts by the provided public key.
3475
+ * @param {string} sender - Sender public key
3476
+ * @returns Record of stream data
3376
3477
  */
3377
3478
  async getOutgoingAlignedStreams(sender) {
3378
3479
  const streams = {};
@@ -3418,6 +3519,8 @@ var SolanaStreamClient = class extends BaseStreamClient {
3418
3519
  /**
3419
3520
  * Fetch streams/contracts by providing direction.
3420
3521
  * Streams are sorted by start time in ascending order.
3522
+ * @param {IGetAllData} getData - Query parameters including address, stream type filter, and direction filter
3523
+ * @returns Record of stream data
3421
3524
  */
3422
3525
  async get({
3423
3526
  address,
@@ -3467,6 +3570,11 @@ var SolanaStreamClient = class extends BaseStreamClient {
3467
3570
  if (type === "all" /* All */) return sortedStreams;
3468
3571
  return sortedStreams.filter((stream) => stream[1].type === type);
3469
3572
  }
3573
+ /**
3574
+ * Searches for streams/contracts by providing filters.
3575
+ * @param {ISearchStreams} data - Search by mint, sender, recipient or closed status
3576
+ * @returns Record of stream data
3577
+ */
3470
3578
  async searchStreams(data) {
3471
3579
  const filters = Object.entries(data).filter(([_, value]) => value !== void 0).map(([key, value]) => ({
3472
3580
  memcmp: {
@@ -3485,6 +3593,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
3485
3593
  }
3486
3594
  /**
3487
3595
  * Attempts updating the stream auto withdrawal params and amount per period
3596
+ * @param {IUpdateData} data - Update parameters including stream ID and new settings
3597
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
3598
+ * @returns Transaction result
3488
3599
  */
3489
3600
  async update(data, extParams) {
3490
3601
  const ixs = await this.prepareUpdateInstructions(data, extParams);
@@ -3507,6 +3618,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
3507
3618
  }
3508
3619
  /**
3509
3620
  * Create Transaction instructions for update
3621
+ * @param {IUpdateData} data - Update parameters including stream ID and new settings
3622
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
3623
+ * @returns Transaction instructions
3510
3624
  */
3511
3625
  async prepareUpdateInstructions(data, { invoker, computePrice, computeLimit }) {
3512
3626
  if (!invoker.publicKey) {
@@ -3531,6 +3645,11 @@ var SolanaStreamClient = class extends BaseStreamClient {
3531
3645
  );
3532
3646
  return ixs;
3533
3647
  }
3648
+ /**
3649
+ * Gets fees for a given address
3650
+ * @param {IGetFeesData} getData - Query parameters containing the partner address to check for custom fees
3651
+ * @returns Fees
3652
+ */
3534
3653
  async getFees({ address }) {
3535
3654
  const [metadataPubKey] = web3_js.PublicKey.findProgramAddressSync(
3536
3655
  [buffer.Buffer.from(FEES_METADATA_SEED)],
@@ -3550,9 +3669,18 @@ var SolanaStreamClient = class extends BaseStreamClient {
3550
3669
  partnerFee: Number(filteredPartners[0].partner_fee.toFixed(4))
3551
3670
  };
3552
3671
  }
3672
+ /**
3673
+ * Gets default streamflow fee
3674
+ * @returns Default streamflow fee
3675
+ */
3553
3676
  async getDefaultStreamflowFee() {
3554
3677
  return DEFAULT_STREAMFLOW_FEE;
3555
3678
  }
3679
+ /**
3680
+ * Extracts error code from an error
3681
+ * @param {Error} err - Error
3682
+ * @returns Error code
3683
+ */
3556
3684
  extractErrorCode(err) {
3557
3685
  const logs = "logs" in err && Array.isArray(err.logs) ? err.logs : void 0;
3558
3686
  return extractSolanaErrorCode(err.toString() ?? "Unknown error!", logs);