@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.
package/dist/esm/index.js CHANGED
@@ -5023,40 +5023,91 @@ var SolanaStreamClient = class extends BaseStreamClient {
5023
5023
  return this.programId.toBase58();
5024
5024
  }
5025
5025
  /**
5026
- * Creates a new stream/vesting contract.
5026
+ * Builds transaction instructions for creating a new stream/vesting contract without creating a transaction.
5027
5027
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
5028
+ * @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
5029
+ * @param {Omit<ICreateStreamSolanaExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
5030
+ * @returns Transaction instructions and metadata ID
5028
5031
  */
5029
- async create(data, extParams) {
5032
+ async buildCreateTransactionInstructions(data, extParams) {
5030
5033
  const { partner, amount, tokenProgramId } = data;
5031
- const { isNative, sender, customInstructions } = extParams;
5034
+ const { isNative, senderPublicKey, customInstructions } = extParams;
5032
5035
  const partnerPublicKey = partner ? new PublicKey(partner) : WITHDRAWOR_PUBLIC_KEY;
5033
5036
  const mintPublicKey = new PublicKey(data.tokenId);
5034
- if (!sender.publicKey) {
5035
- throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
5036
- }
5037
+ const tempSender = { publicKey: senderPublicKey };
5037
5038
  const ixs = await this.getCreateATAInstructions(
5038
5039
  [partnerPublicKey],
5039
5040
  mintPublicKey,
5040
- sender,
5041
+ tempSender,
5041
5042
  true,
5042
5043
  tokenProgramId ? new PublicKey(tokenProgramId) : void 0
5043
5044
  );
5044
- const { ixs: createIxs, metadata, metadataPubKey } = await this.prepareCreateInstructions(data, extParams);
5045
+ const {
5046
+ ixs: createIxs,
5047
+ metadata,
5048
+ metadataPubKey
5049
+ } = await this.prepareCreateInstructions(data, {
5050
+ ...extParams,
5051
+ sender: tempSender
5052
+ });
5045
5053
  ixs.push(...createIxs);
5046
5054
  if (isNative) {
5047
5055
  const totalFee = await this.getTotalFee({
5048
5056
  address: partnerPublicKey.toString()
5049
5057
  });
5050
5058
  const totalAmount = calculateTotalAmountToDeposit(amount, totalFee);
5051
- ixs.push(...await prepareWrappedAccount(this.connection, sender.publicKey, totalAmount));
5059
+ ixs.push(...await prepareWrappedAccount(this.connection, tempSender.publicKey, totalAmount));
5052
5060
  }
5053
5061
  await this.applyCustomAfterInstructions(ixs, customInstructions, metadataPubKey);
5062
+ return {
5063
+ ixs,
5064
+ metadataId: metadataPubKey.toBase58(),
5065
+ metadata
5066
+ };
5067
+ }
5068
+ /**
5069
+ * Builds a transaction for creating a new stream/vesting contract without signing or executing it.
5070
+ * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
5071
+ * @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
5072
+ * @param {Omit<ICreateStreamSolanaExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
5073
+ * @returns Transaction and metadata information
5074
+ */
5075
+ async buildCreateTransaction(data, extParams) {
5076
+ const { senderPublicKey } = extParams;
5077
+ const { ixs, metadataId, metadata } = await this.buildCreateTransactionInstructions(data, extParams);
5078
+ const { tx, hash, context } = await prepareTransaction(this.connection, ixs, senderPublicKey, void 0, [
5079
+ metadata
5080
+ ]);
5081
+ return {
5082
+ tx,
5083
+ metadataId,
5084
+ metadata,
5085
+ hash: hash.blockhash,
5086
+ context
5087
+ };
5088
+ }
5089
+ /**
5090
+ * Creates a new stream/vesting contract.
5091
+ * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
5092
+ * @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
5093
+ * @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, native token handling, and compute settings
5094
+ * @returns Create result
5095
+ */
5096
+ async create(data, extParams) {
5097
+ const { sender } = extParams;
5098
+ if (!sender.publicKey) {
5099
+ throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
5100
+ }
5101
+ const { ixs, metadataId, metadata } = await this.buildCreateTransactionInstructions(data, {
5102
+ ...extParams,
5103
+ senderPublicKey: sender.publicKey
5104
+ });
5054
5105
  const { tx, hash, context } = await prepareTransaction(this.connection, ixs, sender.publicKey, void 0, [
5055
5106
  metadata
5056
5107
  ]);
5057
5108
  const signature = await signAndExecuteTransaction(
5058
5109
  this.connection,
5059
- extParams.sender,
5110
+ sender,
5060
5111
  tx,
5061
5112
  {
5062
5113
  hash,
@@ -5065,7 +5116,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
5065
5116
  },
5066
5117
  this.schedulingParams
5067
5118
  );
5068
- return { ixs, txId: signature, metadataId: metadataPubKey.toBase58() };
5119
+ return { ixs, txId: signature, metadataId };
5069
5120
  }
5070
5121
  async prepareCreateInstructions(streamParams, extParams) {
5071
5122
  const { ixs, metadata, metadataPubKey } = isCreateAlignedStreamData(streamParams) ? await this.prepareCreateAlignedUnlockInstructions(streamParams, extParams) : await this.prepareCreateStreamInstructions(streamParams, extParams);
@@ -5175,6 +5226,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
5175
5226
  /**
5176
5227
  * Creates a new stream/vesting contract.
5177
5228
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
5229
+ * @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
5230
+ * @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
5231
+ * @returns Create stream instructions
5178
5232
  */
5179
5233
  async prepareCreateStreamInstructions({
5180
5234
  recipient,
@@ -5275,6 +5329,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
5275
5329
  * - initialized contract PDA off chain
5276
5330
  *
5277
5331
  * If you are not sure if you should use create or create_unchecked, go for create to be safer.
5332
+ * @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
5333
+ * @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
5334
+ * @returns Create result
5278
5335
  */
5279
5336
  async createUnchecked(data, extParams) {
5280
5337
  const { ixs, metadata, metadataPubKey } = await this.prepareCreateUncheckedInstructions(data, extParams);
@@ -5392,24 +5449,17 @@ var SolanaStreamClient = class extends BaseStreamClient {
5392
5449
  return { ixs, metadata, metadataPubKey };
5393
5450
  }
5394
5451
  /**
5395
- * Creates multiple stream/vesting contracts.
5452
+ * Builds transaction instructions for creating multiple stream/vesting contracts without creating transactions.
5396
5453
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
5454
+ * @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
5455
+ * @param {Omit<ICreateStreamSolanaExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
5456
+ * @returns Create multiple transaction instructions
5397
5457
  */
5398
- async createMultiple(data, extParams) {
5458
+ async buildCreateMultipleTransactionInstructions(data, extParams) {
5399
5459
  const { recipients, ...streamParams } = data;
5400
- const {
5401
- sender,
5402
- metadataPubKeys: metadataPubKeysExt,
5403
- isNative,
5404
- computePrice,
5405
- computeLimit,
5406
- customInstructions
5407
- } = extParams;
5460
+ const { senderPublicKey, metadataPubKeys: metadataPubKeysExt, isNative, customInstructions } = extParams;
5408
5461
  const metadatas = [];
5409
5462
  const metadataToRecipient = {};
5410
- const errors = [];
5411
- const signatures = [];
5412
- const batch = [];
5413
5463
  const instructionsBatch = [];
5414
5464
  const metadataPubKeys = metadataPubKeysExt || [];
5415
5465
  const partnerPublicKey = data.partner ? new PublicKey(data.partner) : WITHDRAWOR_PUBLIC_KEY;
@@ -5417,18 +5467,14 @@ var SolanaStreamClient = class extends BaseStreamClient {
5417
5467
  if (recipients.length === 0) {
5418
5468
  throw new Error("Recipients array is empty!");
5419
5469
  }
5420
- if (!sender.publicKey) {
5421
- throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
5422
- }
5470
+ const tempSender = { publicKey: senderPublicKey };
5423
5471
  for (let i = 0; i < recipients.length; i++) {
5424
5472
  const recipientData = recipients[i];
5425
5473
  const createStreamData = { ...streamParams, ...recipientData };
5426
5474
  const createStreamExtParams = {
5427
- sender,
5475
+ sender: tempSender,
5428
5476
  metadataPubKeys: metadataPubKeys[i] ? [metadataPubKeys[i]] : void 0,
5429
- computePrice,
5430
- computeLimit,
5431
- customInstructions
5477
+ ...extParams
5432
5478
  };
5433
5479
  const { ixs, metadata, metadataPubKey } = await this.prepareCreateInstructions(
5434
5480
  createStreamData,
@@ -5443,21 +5489,80 @@ var SolanaStreamClient = class extends BaseStreamClient {
5443
5489
  recipient: recipientData.recipient
5444
5490
  });
5445
5491
  }
5446
- const { value: hash, context } = await this.connection.getLatestBlockhashAndContext();
5447
- for (const { ixs, metadata, recipient } of instructionsBatch) {
5448
- batch.push({ tx: createVersionedTransaction(ixs, sender.publicKey, hash.blockhash, [metadata]), recipient });
5449
- }
5450
5492
  const prepareInstructions = await this.getCreateATAInstructions(
5451
5493
  [partnerPublicKey],
5452
5494
  mintPublicKey,
5453
- sender,
5495
+ tempSender,
5454
5496
  true
5455
5497
  );
5456
5498
  if (isNative) {
5457
5499
  const totalDepositedAmount = recipients.reduce((acc, recipient) => recipient.amount.add(acc), new BN7(0));
5458
- const nativeInstructions = await prepareWrappedAccount(this.connection, sender.publicKey, totalDepositedAmount);
5500
+ const nativeInstructions = await prepareWrappedAccount(
5501
+ this.connection,
5502
+ tempSender.publicKey,
5503
+ totalDepositedAmount
5504
+ );
5459
5505
  prepareInstructions.push(...nativeInstructions);
5460
5506
  }
5507
+ return {
5508
+ instructionsBatch,
5509
+ metadatas,
5510
+ metadataToRecipient,
5511
+ prepareInstructions
5512
+ };
5513
+ }
5514
+ /**
5515
+ * Builds multiple transactions for creating stream/vesting contracts without signing or executing them.
5516
+ * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
5517
+ * @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
5518
+ * @param {Omit<ICreateStreamSolanaExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
5519
+ * @returns Multiple transaction information
5520
+ */
5521
+ async buildCreateMultipleTransactions(data, extParams) {
5522
+ const { senderPublicKey } = extParams;
5523
+ const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, extParams);
5524
+ const { value: hash, context } = await this.connection.getLatestBlockhashAndContext();
5525
+ const batch = [];
5526
+ for (const { ixs, metadata, recipient } of instructionsBatch) {
5527
+ batch.push({ tx: createVersionedTransaction(ixs, senderPublicKey, hash.blockhash, [metadata]), recipient });
5528
+ }
5529
+ let prepareTx;
5530
+ if (prepareInstructions.length > 0) {
5531
+ prepareTx = createVersionedTransaction(prepareInstructions, senderPublicKey, hash.blockhash);
5532
+ }
5533
+ return {
5534
+ transactions: batch,
5535
+ metadatas,
5536
+ metadataToRecipient,
5537
+ hash,
5538
+ context,
5539
+ prepareTx
5540
+ };
5541
+ }
5542
+ /**
5543
+ * Creates multiple stream/vesting contracts.
5544
+ * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
5545
+ * @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
5546
+ * @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
5547
+ * @returns Multiple transaction information
5548
+ */
5549
+ async createMultiple(data, extParams) {
5550
+ const { sender, metadataPubKeys: metadataPubKeysExt } = extParams;
5551
+ if (!sender.publicKey) {
5552
+ throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
5553
+ }
5554
+ const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, {
5555
+ ...extParams,
5556
+ senderPublicKey: sender.publicKey
5557
+ });
5558
+ const errors = [];
5559
+ const signatures = [];
5560
+ const metadataPubKeys = metadataPubKeysExt || [];
5561
+ const batch = [];
5562
+ const { value: hash, context } = await this.connection.getLatestBlockhashAndContext();
5563
+ for (const { ixs, metadata, recipient } of instructionsBatch) {
5564
+ batch.push({ tx: createVersionedTransaction(ixs, sender.publicKey, hash.blockhash, [metadata]), recipient });
5565
+ }
5461
5566
  if (prepareInstructions.length > 0) {
5462
5567
  batch.push({
5463
5568
  tx: createVersionedTransaction(prepareInstructions, sender.publicKey, hash.blockhash),
@@ -5505,55 +5610,22 @@ var SolanaStreamClient = class extends BaseStreamClient {
5505
5610
  * Creates multiple stream/vesting contracts, and send all transactions sequentially.
5506
5611
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
5507
5612
  * In most cases, createMultiple should be used instead.
5613
+ * @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
5614
+ * @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
5615
+ * @returns Multiple transaction information
5508
5616
  */
5509
5617
  async createMultipleSequential(data, extParams) {
5510
- const { recipients, ...streamParams } = data;
5511
- const {
5512
- sender,
5513
- metadataPubKeys: metadataPubKeysExt,
5514
- isNative,
5515
- computePrice,
5516
- computeLimit,
5517
- customInstructions
5518
- } = extParams;
5519
- const metadatas = [];
5520
- const metadataToRecipient = {};
5521
- const errors = [];
5522
- const signatures = [];
5523
- const batch = [];
5524
- const instructionsBatch = [];
5525
- const metadataPubKeys = metadataPubKeysExt || [];
5526
- const partnerPublicKey = data.partner ? new PublicKey(data.partner) : WITHDRAWOR_PUBLIC_KEY;
5527
- const mintPublicKey = new PublicKey(data.tokenId);
5528
- if (recipients.length === 0) {
5529
- throw new Error("Recipients array is empty!");
5530
- }
5618
+ const { sender } = extParams;
5531
5619
  if (!sender.publicKey) {
5532
5620
  throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
5533
5621
  }
5534
- for (let i = 0; i < recipients.length; i++) {
5535
- const recipientData = recipients[i];
5536
- const createStreamData = { ...streamParams, ...recipientData };
5537
- const createStreamExtParams = {
5538
- sender,
5539
- metadataPubKeys: metadataPubKeys[i] ? [metadataPubKeys[i]] : void 0,
5540
- computePrice,
5541
- computeLimit,
5542
- customInstructions
5543
- };
5544
- const { ixs, metadata, metadataPubKey } = await this.prepareCreateInstructions(
5545
- createStreamData,
5546
- createStreamExtParams
5547
- );
5548
- await this.applyCustomAfterInstructions(ixs, customInstructions, metadataPubKey);
5549
- metadataToRecipient[metadataPubKey.toBase58()] = recipientData;
5550
- metadatas.push(metadataPubKey.toBase58());
5551
- instructionsBatch.push({
5552
- ixs,
5553
- metadata,
5554
- recipient: recipientData.recipient
5555
- });
5556
- }
5622
+ const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, {
5623
+ ...extParams,
5624
+ senderPublicKey: sender.publicKey
5625
+ });
5626
+ const errors = [];
5627
+ const signatures = [];
5628
+ const batch = [];
5557
5629
  const { value: hash, context } = await this.connection.getLatestBlockhashAndContext();
5558
5630
  for (const { ixs, metadata, recipient } of instructionsBatch) {
5559
5631
  const messageV0 = new TransactionMessage({
@@ -5567,17 +5639,6 @@ var SolanaStreamClient = class extends BaseStreamClient {
5567
5639
  }
5568
5640
  batch.push({ tx, recipient });
5569
5641
  }
5570
- const prepareInstructions = await this.getCreateATAInstructions(
5571
- [partnerPublicKey],
5572
- mintPublicKey,
5573
- sender,
5574
- true
5575
- );
5576
- if (isNative) {
5577
- const totalDepositedAmount = recipients.reduce((acc, recipient) => recipient.amount.add(acc), new BN7(0));
5578
- const nativeInstructions = await prepareWrappedAccount(this.connection, sender.publicKey, totalDepositedAmount);
5579
- prepareInstructions.push(...nativeInstructions);
5580
- }
5581
5642
  if (prepareInstructions.length > 0) {
5582
5643
  const messageV0 = new TransactionMessage({
5583
5644
  payerKey: sender.publicKey,
@@ -5618,6 +5679,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
5618
5679
  }
5619
5680
  /**
5620
5681
  * Attempts withdrawing from the specified stream.
5682
+ * @param {IWithdrawData} withdrawData - Withdrawal parameters including stream ID and amount to withdraw
5683
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
5684
+ * @returns Transaction result
5621
5685
  */
5622
5686
  async withdraw({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, extParams) {
5623
5687
  const { invoker, customInstructions } = extParams;
@@ -5643,6 +5707,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
5643
5707
  }
5644
5708
  /**
5645
5709
  * Creates Transaction Instructions for withdrawal
5710
+ * @param {IWithdrawData} withdrawData - Withdrawal parameters including stream ID and amount to withdraw
5711
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
5712
+ * @returns Transaction instructions
5646
5713
  */
5647
5714
  async prepareWithdrawInstructions({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
5648
5715
  if (!invoker.publicKey) {
@@ -5689,6 +5756,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
5689
5756
  }
5690
5757
  /**
5691
5758
  * Attempts canceling the specified stream.
5759
+ * @param {ICancelData} cancelData - Cancellation parameters including stream ID
5760
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
5761
+ * @returns Transaction result
5692
5762
  */
5693
5763
  async cancel(cancelData, extParams) {
5694
5764
  const ixs = await this.prepareCancelInstructions(cancelData, extParams);
@@ -5706,6 +5776,12 @@ var SolanaStreamClient = class extends BaseStreamClient {
5706
5776
  );
5707
5777
  return { ixs, txId: signature };
5708
5778
  }
5779
+ /**
5780
+ * Creates Transaction Instructions for cancel
5781
+ * @param {ICancelData} cancelData - Cancellation parameters including stream ID
5782
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
5783
+ * @returns Transaction instructions
5784
+ */
5709
5785
  async prepareCancelInstructions(cancelData, extParams) {
5710
5786
  const streamPublicKey = new PublicKey(cancelData.id);
5711
5787
  const account = await this.connection.getAccountInfo(streamPublicKey);
@@ -5717,6 +5793,12 @@ var SolanaStreamClient = class extends BaseStreamClient {
5717
5793
  const ixs = isAlignedUnlock ? await this.prepareCancelAlignedUnlockInstructions(cancelData, extParams) : await this.prepareCancelStreamInstructions(cancelData, extParams);
5718
5794
  return ixs;
5719
5795
  }
5796
+ /**
5797
+ * Creates Transaction Instructions for cancel
5798
+ * @param {ICancelData} cancelData - Cancellation parameters including stream ID
5799
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
5800
+ * @returns Transaction instructions
5801
+ */
5720
5802
  async prepareCancelAlignedUnlockInstructions({ id }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
5721
5803
  if (!invoker.publicKey) {
5722
5804
  throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
@@ -5756,6 +5838,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
5756
5838
  }
5757
5839
  /**
5758
5840
  * Creates Transaction Instructions for cancel
5841
+ * @param {ICancelData} cancelData - Cancellation parameters including stream ID
5842
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
5843
+ * @returns Transaction instructions
5759
5844
  */
5760
5845
  async prepareCancelStreamInstructions({ id }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
5761
5846
  if (!invoker.publicKey) {
@@ -5805,6 +5890,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
5805
5890
  /**
5806
5891
  * Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
5807
5892
  * Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
5893
+ * @param {ITransferData} transferData - Transfer parameters including stream ID and new recipient address
5894
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
5895
+ * @returns Transaction result
5808
5896
  */
5809
5897
  async transfer({ id, newRecipient }, extParams) {
5810
5898
  const ixs = await this.prepareTransferInstructions({ id, newRecipient }, extParams);
@@ -5825,6 +5913,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
5825
5913
  /**
5826
5914
  * Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
5827
5915
  * Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
5916
+ * @param {ITransferData} transferData - Transfer parameters including stream ID and new recipient address
5917
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
5918
+ * @returns Transaction instructions
5828
5919
  */
5829
5920
  async prepareTransferInstructions({ id, newRecipient }, { invoker, computePrice, computeLimit = 100001 }) {
5830
5921
  if (!invoker.publicKey) {
@@ -5860,6 +5951,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
5860
5951
  }
5861
5952
  /**
5862
5953
  * Tops up stream account with specified amount.
5954
+ * @param {ITopUpData} topupData - Top-up parameters including stream ID and amount to add
5955
+ * @param {ITopUpStreamSolanaExt} extParams - Transaction configuration including invoker wallet, native token handling, and compute settings
5956
+ * @returns Transaction result
5863
5957
  */
5864
5958
  async topup({ id, amount }, extParams) {
5865
5959
  const ixs = await this.prepareTopupInstructions({ id, amount }, extParams);
@@ -5879,6 +5973,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
5879
5973
  }
5880
5974
  /**
5881
5975
  * Create Transaction instructions for topup
5976
+ * @param {ITopUpData} topupData - Top-up parameters including stream ID and amount to add
5977
+ * @param {ITopUpStreamSolanaExt} extParams - Transaction configuration including invoker wallet, native token handling, and compute settings
5978
+ * @returns Transaction instructions
5882
5979
  */
5883
5980
  async prepareTopupInstructions({ id, amount }, { invoker, isNative, computePrice, computeLimit }) {
5884
5981
  if (!invoker.publicKey) {
@@ -5920,6 +6017,8 @@ var SolanaStreamClient = class extends BaseStreamClient {
5920
6017
  }
5921
6018
  /**
5922
6019
  * Fetch stream data by its id (address).
6020
+ * @param {IGetOneData} getData - Query parameters containing the stream ID to fetch
6021
+ * @returns Stream data
5923
6022
  */
5924
6023
  async getOne({ id }) {
5925
6024
  const streamPublicKey = new PublicKey(id);
@@ -5941,6 +6040,8 @@ var SolanaStreamClient = class extends BaseStreamClient {
5941
6040
  }
5942
6041
  /**
5943
6042
  * Fetch all aligned outgoing streams/contracts by the provided public key.
6043
+ * @param {string} sender - Sender public key
6044
+ * @returns Record of stream data
5944
6045
  */
5945
6046
  async getOutgoingAlignedStreams(sender) {
5946
6047
  const streams = {};
@@ -5986,6 +6087,8 @@ var SolanaStreamClient = class extends BaseStreamClient {
5986
6087
  /**
5987
6088
  * Fetch streams/contracts by providing direction.
5988
6089
  * Streams are sorted by start time in ascending order.
6090
+ * @param {IGetAllData} getData - Query parameters including address, stream type filter, and direction filter
6091
+ * @returns Record of stream data
5989
6092
  */
5990
6093
  async get({
5991
6094
  address,
@@ -6035,6 +6138,11 @@ var SolanaStreamClient = class extends BaseStreamClient {
6035
6138
  if (type === "all" /* All */) return sortedStreams;
6036
6139
  return sortedStreams.filter((stream) => stream[1].type === type);
6037
6140
  }
6141
+ /**
6142
+ * Searches for streams/contracts by providing filters.
6143
+ * @param {ISearchStreams} data - Search by mint, sender, recipient or closed status
6144
+ * @returns Record of stream data
6145
+ */
6038
6146
  async searchStreams(data) {
6039
6147
  const filters = Object.entries(data).filter(([_, value]) => value !== void 0).map(([key, value]) => ({
6040
6148
  memcmp: {
@@ -6053,6 +6161,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
6053
6161
  }
6054
6162
  /**
6055
6163
  * Attempts updating the stream auto withdrawal params and amount per period
6164
+ * @param {IUpdateData} data - Update parameters including stream ID and new settings
6165
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
6166
+ * @returns Transaction result
6056
6167
  */
6057
6168
  async update(data, extParams) {
6058
6169
  const ixs = await this.prepareUpdateInstructions(data, extParams);
@@ -6075,6 +6186,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
6075
6186
  }
6076
6187
  /**
6077
6188
  * Create Transaction instructions for update
6189
+ * @param {IUpdateData} data - Update parameters including stream ID and new settings
6190
+ * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
6191
+ * @returns Transaction instructions
6078
6192
  */
6079
6193
  async prepareUpdateInstructions(data, { invoker, computePrice, computeLimit }) {
6080
6194
  if (!invoker.publicKey) {
@@ -6099,6 +6213,11 @@ var SolanaStreamClient = class extends BaseStreamClient {
6099
6213
  );
6100
6214
  return ixs;
6101
6215
  }
6216
+ /**
6217
+ * Gets fees for a given address
6218
+ * @param {IGetFeesData} getData - Query parameters containing the partner address to check for custom fees
6219
+ * @returns Fees
6220
+ */
6102
6221
  async getFees({ address }) {
6103
6222
  const [metadataPubKey] = PublicKey.findProgramAddressSync(
6104
6223
  [Buffer.from(FEES_METADATA_SEED)],
@@ -6118,9 +6237,18 @@ var SolanaStreamClient = class extends BaseStreamClient {
6118
6237
  partnerFee: Number(filteredPartners[0].partner_fee.toFixed(4))
6119
6238
  };
6120
6239
  }
6240
+ /**
6241
+ * Gets default streamflow fee
6242
+ * @returns Default streamflow fee
6243
+ */
6121
6244
  async getDefaultStreamflowFee() {
6122
6245
  return DEFAULT_STREAMFLOW_FEE;
6123
6246
  }
6247
+ /**
6248
+ * Extracts error code from an error
6249
+ * @param {Error} err - Error
6250
+ * @returns Error code
6251
+ */
6124
6252
  extractErrorCode(err) {
6125
6253
  const logs = "logs" in err && Array.isArray(err.logs) ? err.logs : void 0;
6126
6254
  return extractSolanaErrorCode(err.toString() ?? "Unknown error!", logs);