@streamflow/stream 10.0.0-alpha.p313.fe3720a → 10.0.0-alpha.p317.e143b57

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.
@@ -2995,14 +2995,13 @@ var SolanaStreamClient = class {
2995
2995
  * @param {IPrepareCreateStreamExt} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
2996
2996
  * @returns Create multiple transaction instructions
2997
2997
  */
2998
- async buildCreateMultipleTransactionInstructions(data, extParams) {
2998
+ async buildCreateMultipleTransactionInstructions(data, extParams, applyCustomAfterInstructions = true) {
2999
2999
  const { recipients, ...streamParams } = data;
3000
3000
  const { sender, metadataPubKeys: metadataPubKeysExt, isNative, customInstructions } = extParams;
3001
3001
  common.assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
3002
3002
  const metadatas = [];
3003
3003
  const metadataToRecipient = {};
3004
3004
  const instructionsBatch = [];
3005
- const metadataPubKeys = metadataPubKeysExt || [];
3006
3005
  const partnerPublicKey = data.partner ? new web3_js.PublicKey(data.partner) : WITHDRAWOR_PUBLIC_KEY;
3007
3006
  const mintPublicKey = new web3_js.PublicKey(data.tokenId);
3008
3007
  if (recipients.length === 0) {
@@ -3012,14 +3011,16 @@ var SolanaStreamClient = class {
3012
3011
  const recipientData = recipients[i];
3013
3012
  const createStreamData = { ...streamParams, ...recipientData };
3014
3013
  const createStreamExtParams = {
3015
- metadataPubKeys: metadataPubKeys[i] ? [metadataPubKeys[i]] : void 0,
3016
- ...extParams
3014
+ ...extParams,
3015
+ metadataPubKeys: metadataPubKeysExt?.[i] ? [metadataPubKeysExt[i]] : void 0
3017
3016
  };
3018
3017
  const { ixs, metadata, metadataPubKey } = await this.prepareCreateInstructions(
3019
3018
  createStreamData,
3020
3019
  createStreamExtParams
3021
3020
  );
3022
- await this.applyCustomAfterInstructions(ixs, customInstructions, metadataPubKey);
3021
+ if (applyCustomAfterInstructions) {
3022
+ await this.applyCustomAfterInstructions(ixs, customInstructions, metadataPubKey);
3023
+ }
3023
3024
  metadataToRecipient[metadataPubKey.toBase58()] = recipientData;
3024
3025
  metadatas.push(metadataPubKey.toBase58());
3025
3026
  instructionsBatch.push({
@@ -3067,9 +3068,9 @@ var SolanaStreamClient = class {
3067
3068
  * @param {IPrepareCreateStreamExt} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
3068
3069
  * @returns Multiple transaction information
3069
3070
  */
3070
- async buildCreateMultipleTransactions(data, extParams) {
3071
+ async buildCreateMultipleTransactions(data, extParams, applyCustomAfterInstructions = true) {
3071
3072
  const { sender } = extParams;
3072
- const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, extParams);
3073
+ const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, extParams, applyCustomAfterInstructions);
3073
3074
  const { value: hash, context } = await this.connection.getLatestBlockhashAndContext();
3074
3075
  const batch = [];
3075
3076
  for (const { ixs, metadata, recipient } of instructionsBatch) {
@@ -3100,7 +3101,7 @@ var SolanaStreamClient = class {
3100
3101
  if (!sender.publicKey) {
3101
3102
  throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
3102
3103
  }
3103
- const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, extParams);
3104
+ const { instructionsBatch, metadatas, prepareInstructions, metadataToRecipient } = await this.flatBuildCreateMultipleTransactionInstructions(data, extParams);
3104
3105
  const errors = [];
3105
3106
  const signatures = [];
3106
3107
  const metadataPubKeys = metadataPubKeysExt || [];
@@ -3165,7 +3166,7 @@ var SolanaStreamClient = class {
3165
3166
  if (!sender.publicKey) {
3166
3167
  throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
3167
3168
  }
3168
- const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, extParams);
3169
+ const { instructionsBatch, metadatas, prepareInstructions, metadataToRecipient } = await this.flatBuildCreateMultipleTransactionInstructions(data, extParams);
3169
3170
  const errors = [];
3170
3171
  const signatures = [];
3171
3172
  const batch = [];
@@ -3788,11 +3789,11 @@ var SolanaStreamClient = class {
3788
3789
  return DEFAULT_STREAMFLOW_FEE;
3789
3790
  }
3790
3791
  /**
3791
- * Returns total fee percent, streamflow fees + partner fees
3792
- * @param getFeesData structure with address for which we need to derive fee, either sender or partner usually
3793
- * @param chainSpecificParams additional parameters required by chain client
3794
- * @returns fee as floating number, so if fee is 0.99%, it will return 0.99
3795
- */
3792
+ * Returns total fee percent, streamflow fees + partner fees
3793
+ * @param getFeesData structure with address for which we need to derive fee, either sender or partner usually
3794
+ * @param chainSpecificParams additional parameters required by chain client
3795
+ * @returns fee as floating number, so if fee is 0.99%, it will return 0.99
3796
+ */
3796
3797
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
3797
3798
  async getTotalFee(getFeesData) {
3798
3799
  const fees = await this.getFees(getFeesData);
@@ -3817,6 +3818,21 @@ var SolanaStreamClient = class {
3817
3818
  const pda = deriveContractPDA(this.alignedProxyProgram.programId, streamPublicKey);
3818
3819
  return senderPublicKey.equals(pda);
3819
3820
  }
3821
+ async flatBuildCreateMultipleTransactionInstructions(data, extParams) {
3822
+ const dataArray = Array.isArray(data) ? data : [data];
3823
+ const results = await Promise.all(
3824
+ dataArray.map((item, index) => this.buildCreateMultipleTransactionInstructions(item, extParams, index === 0))
3825
+ );
3826
+ return {
3827
+ instructionsBatch: results.flatMap((r) => r.instructionsBatch),
3828
+ metadatas: results.flatMap((r) => r.metadatas),
3829
+ prepareInstructions: results.flatMap((r) => r.prepareInstructions),
3830
+ metadataToRecipient: results.reduce(
3831
+ (acc, r) => Object.assign(acc, r.metadataToRecipient),
3832
+ {}
3833
+ )
3834
+ };
3835
+ }
3820
3836
  /**
3821
3837
  * Utility function to generate metadata for a Contract or return existing Pubkey
3822
3838
  */