@streamflow/stream 10.0.0-alpha.p313.4046054 → 10.0.0-alpha.p313.85091cd

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.
@@ -553,7 +553,7 @@ declare class SolanaStreamClient {
553
553
  * @param {IPrepareCreateStreamExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
554
554
  * @returns Create stream instructions
555
555
  */
556
- prepareCreateStreamInstructions({ recipient, tokenId: mint, start, amount: depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canPause, canUpdateRate, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, tokenProgramId: streamTokenProgramId, }: ICreateStreamData, { sender, metadataPubKeys, isNative, computePrice, computeLimit }: IPrepareCreateStreamExt): Promise<ICreateStreamInstructions>;
556
+ prepareCreateLinearStreamInstructions({ recipient, tokenId: mint, start, amount: depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canPause, canUpdateRate, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, tokenProgramId: streamTokenProgramId, }: ICreateStreamData, { sender, metadataPubKeys, isNative, computePrice, computeLimit }: IPrepareCreateStreamExt): Promise<ICreateStreamInstructions>;
557
557
  /**
558
558
  * Creates a new stream/vesting contract using unchecked instruction.
559
559
  *
@@ -637,7 +637,7 @@ declare class SolanaStreamClient {
637
637
  * @param {ICreateStreamExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
638
638
  * @returns Multiple transaction information
639
639
  */
640
- createMultiple(data: ICreateMultipleStreamData, extParams: ICreateStreamExt): Promise<IMultiTransactionResult>;
640
+ createMultiple(data: ICreateMultipleStreamData[] | ICreateMultipleStreamData, extParams: ICreateStreamExt): Promise<IMultiTransactionResult>;
641
641
  /**
642
642
  * Creates multiple stream/vesting contracts, and send all transactions sequentially.
643
643
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
@@ -646,7 +646,7 @@ declare class SolanaStreamClient {
646
646
  * @param {ICreateStreamExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
647
647
  * @returns Multiple transaction information
648
648
  */
649
- createMultipleSequential(data: ICreateMultipleStreamData, extParams: ICreateStreamExt): Promise<IMultiTransactionResult>;
649
+ createMultipleSequential(data: ICreateMultipleStreamData[] | ICreateMultipleStreamData, extParams: ICreateStreamExt): Promise<IMultiTransactionResult>;
650
650
  /**
651
651
  * Attempts withdrawing from the specified stream.
652
652
  * @param {IWithdrawData} withdrawData - Withdrawal parameters including stream ID and amount to withdraw
@@ -688,7 +688,7 @@ declare class SolanaStreamClient {
688
688
  * @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
689
689
  * @returns Transaction instructions
690
690
  */
691
- prepareCancelStreamInstructions({ id }: ICancelData, { invoker, checkTokenAccounts, computePrice, computeLimit }: IPrepareStreamExt): Promise<TransactionInstruction[]>;
691
+ prepareCancelLinearStream({ id }: ICancelData, { invoker, checkTokenAccounts, computePrice, computeLimit }: IPrepareStreamExt): Promise<TransactionInstruction[]>;
692
692
  /**
693
693
  * Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
694
694
  * Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
@@ -771,11 +771,11 @@ declare class SolanaStreamClient {
771
771
  */
772
772
  getDefaultStreamflowFee(): Promise<number>;
773
773
  /**
774
- * Returns total fee percent, streamflow fees + partner fees
775
- * @param getFeesData structure with address for which we need to derive fee, either sender or partner usually
776
- * @param chainSpecificParams additional parameters required by chain client
777
- * @returns fee as floating number, so if fee is 0.99%, it will return 0.99
778
- */
774
+ * Returns total fee percent, streamflow fees + partner fees
775
+ * @param getFeesData structure with address for which we need to derive fee, either sender or partner usually
776
+ * @param chainSpecificParams additional parameters required by chain client
777
+ * @returns fee as floating number, so if fee is 0.99%, it will return 0.99
778
+ */
779
779
  getTotalFee(getFeesData: IGetFeesData): Promise<number>;
780
780
  /**
781
781
  * Extracts error code from an error
@@ -787,6 +787,7 @@ declare class SolanaStreamClient {
787
787
  * Utility function that checks whether the associated stream address is an aligned unlock contract, indicated by whether the sender/creator is a PDA
788
788
  */
789
789
  isAlignedUnlock(streamPublicKey: PublicKey, senderPublicKey: PublicKey): boolean;
790
+ private flatBuildCreateMultipleTransactionInstructions;
790
791
  /**
791
792
  * Utility function to generate metadata for a Contract or return existing Pubkey
792
793
  */
package/dist/esm/index.js CHANGED
@@ -2638,7 +2638,7 @@ var SolanaStreamClient = class {
2638
2638
  return { ixs, txId: signature, metadataId };
2639
2639
  }
2640
2640
  async prepareCreateInstructions(streamParams, extParams) {
2641
- const { ixs, metadata, metadataPubKey } = isCreateAlignedStreamData(streamParams) ? await this.prepareCreateAlignedUnlockInstructions(streamParams, extParams) : await this.prepareCreateStreamInstructions(streamParams, extParams);
2641
+ const { ixs, metadata, metadataPubKey } = isCreateAlignedStreamData(streamParams) ? await this.prepareCreateAlignedUnlockInstructions(streamParams, extParams) : await this.prepareCreateLinearStreamInstructions(streamParams, extParams);
2642
2642
  return { ixs, metadata, metadataPubKey };
2643
2643
  }
2644
2644
  async prepareCreateAlignedUnlockInstructions(streamParams, extParams) {
@@ -2748,7 +2748,7 @@ var SolanaStreamClient = class {
2748
2748
  * @param {IPrepareCreateStreamExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
2749
2749
  * @returns Create stream instructions
2750
2750
  */
2751
- async prepareCreateStreamInstructions({
2751
+ async prepareCreateLinearStreamInstructions({
2752
2752
  recipient,
2753
2753
  tokenId: mint,
2754
2754
  start,
@@ -3074,7 +3074,7 @@ var SolanaStreamClient = class {
3074
3074
  if (!sender.publicKey) {
3075
3075
  throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
3076
3076
  }
3077
- const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, extParams);
3077
+ const { instructionsBatch, metadatas, prepareInstructions, metadataToRecipient } = await this.flatBuildCreateMultipleTransactionInstructions(data, extParams);
3078
3078
  const errors = [];
3079
3079
  const signatures = [];
3080
3080
  const metadataPubKeys = metadataPubKeysExt || [];
@@ -3139,7 +3139,7 @@ var SolanaStreamClient = class {
3139
3139
  if (!sender.publicKey) {
3140
3140
  throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
3141
3141
  }
3142
- const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, extParams);
3142
+ const { instructionsBatch, metadatas, prepareInstructions, metadataToRecipient } = await this.flatBuildCreateMultipleTransactionInstructions(data, extParams);
3143
3143
  const errors = [];
3144
3144
  const signatures = [];
3145
3145
  const batch = [];
@@ -3301,7 +3301,7 @@ var SolanaStreamClient = class {
3301
3301
  }
3302
3302
  const { sender: senderPublicKey } = decodeStream(account.data);
3303
3303
  const isAlignedUnlock = this.isAlignedUnlock(streamPublicKey, senderPublicKey);
3304
- const ixs = isAlignedUnlock ? await this.prepareCancelAlignedUnlockInstructions(cancelData, extParams) : await this.prepareCancelStreamInstructions(cancelData, extParams);
3304
+ const ixs = isAlignedUnlock ? await this.prepareCancelAlignedUnlockInstructions(cancelData, extParams) : await this.prepareCancelLinearStream(cancelData, extParams);
3305
3305
  return ixs;
3306
3306
  }
3307
3307
  /**
@@ -3349,7 +3349,7 @@ var SolanaStreamClient = class {
3349
3349
  * @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
3350
3350
  * @returns Transaction instructions
3351
3351
  */
3352
- async prepareCancelStreamInstructions({ id }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
3352
+ async prepareCancelLinearStream({ id }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
3353
3353
  assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
3354
3354
  const streamPublicKey = new PublicKey(id);
3355
3355
  const escrowAcc = await this.connection.getAccountInfo(streamPublicKey);
@@ -3762,11 +3762,11 @@ var SolanaStreamClient = class {
3762
3762
  return DEFAULT_STREAMFLOW_FEE;
3763
3763
  }
3764
3764
  /**
3765
- * Returns total fee percent, streamflow fees + partner fees
3766
- * @param getFeesData structure with address for which we need to derive fee, either sender or partner usually
3767
- * @param chainSpecificParams additional parameters required by chain client
3768
- * @returns fee as floating number, so if fee is 0.99%, it will return 0.99
3769
- */
3765
+ * Returns total fee percent, streamflow fees + partner fees
3766
+ * @param getFeesData structure with address for which we need to derive fee, either sender or partner usually
3767
+ * @param chainSpecificParams additional parameters required by chain client
3768
+ * @returns fee as floating number, so if fee is 0.99%, it will return 0.99
3769
+ */
3770
3770
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
3771
3771
  async getTotalFee(getFeesData) {
3772
3772
  const fees = await this.getFees(getFeesData);
@@ -3791,6 +3791,21 @@ var SolanaStreamClient = class {
3791
3791
  const pda = deriveContractPDA(this.alignedProxyProgram.programId, streamPublicKey);
3792
3792
  return senderPublicKey.equals(pda);
3793
3793
  }
3794
+ async flatBuildCreateMultipleTransactionInstructions(data, extParams) {
3795
+ const dataArray = Array.isArray(data) ? data : [data];
3796
+ const results = await Promise.all(
3797
+ dataArray.map((item) => this.buildCreateMultipleTransactionInstructions(item, extParams))
3798
+ );
3799
+ return {
3800
+ instructionsBatch: results.flatMap((r) => r.instructionsBatch),
3801
+ metadatas: results.flatMap((r) => r.metadatas),
3802
+ prepareInstructions: results.flatMap((r) => r.prepareInstructions),
3803
+ metadataToRecipient: results.reduce(
3804
+ (acc, r) => Object.assign(acc, r.metadataToRecipient),
3805
+ {}
3806
+ )
3807
+ };
3808
+ }
3794
3809
  /**
3795
3810
  * Utility function to generate metadata for a Contract or return existing Pubkey
3796
3811
  */