@streamflow/stream 8.7.0-alpha.0 → 8.7.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.
@@ -212,6 +212,10 @@ declare class SolanaStreamClient extends BaseStreamClient {
212
212
  /**
213
213
  * Builds transaction instructions for creating a new stream/vesting contract without creating a transaction.
214
214
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
215
+ *
216
+ * For native SOL (isNative: true), SOL wrapping instructions are automatically included in the correct order
217
+ * (before stream creation) to ensure the WSOL account exists when the stream creation instruction executes.
218
+ *
215
219
  * @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
216
220
  * @param {Omit<ICreateStreamSolanaExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
217
221
  * @returns Transaction instructions and metadata ID
@@ -226,6 +230,10 @@ declare class SolanaStreamClient extends BaseStreamClient {
226
230
  /**
227
231
  * Builds a transaction for creating a new stream/vesting contract without signing or executing it.
228
232
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
233
+ *
234
+ * For native SOL (isNative: true), SOL wrapping instructions are automatically included in the correct order
235
+ * (before stream creation) to ensure the WSOL account exists when the stream creation instruction executes.
236
+ *
229
237
  * @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
230
238
  * @param {Omit<ICreateStreamSolanaExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
231
239
  * @returns Transaction and metadata information
@@ -301,6 +309,25 @@ declare class SolanaStreamClient extends BaseStreamClient {
301
309
  /**
302
310
  * Builds multiple transactions for creating stream/vesting contracts without signing or executing them.
303
311
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
312
+ *
313
+ * IMPORTANT: When using native SOL (isNative: true), you MUST execute the prepareTx FIRST and wait for confirmation
314
+ * before executing the stream creation transactions. Otherwise, stream creation will fail with "InvalidAccountData".
315
+ *
316
+ * @example
317
+ * ```typescript
318
+ * const result = await streamClient.buildCreateMultipleTransactions(data, { isNative: true, senderPublicKey });
319
+ *
320
+ * // CRITICAL: Execute prepareTx first if it exists
321
+ * if (result.prepareTx) {
322
+ * await connection.sendAndConfirmTransaction(result.prepareTx, [signer]);
323
+ * }
324
+ *
325
+ * // Only then execute stream creation transactions
326
+ * for (const item of result.transactions) {
327
+ * await connection.sendAndConfirmTransaction(item.tx, [signer]);
328
+ * }
329
+ * ```
330
+ *
304
331
  * @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
305
332
  * @param {Omit<ICreateStreamSolanaExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
306
333
  * @returns Multiple transaction information
@@ -5051,6 +5051,10 @@ var SolanaStreamClient = class extends BaseStreamClient {
5051
5051
  /**
5052
5052
  * Builds transaction instructions for creating a new stream/vesting contract without creating a transaction.
5053
5053
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
5054
+ *
5055
+ * For native SOL (isNative: true), SOL wrapping instructions are automatically included in the correct order
5056
+ * (before stream creation) to ensure the WSOL account exists when the stream creation instruction executes.
5057
+ *
5054
5058
  * @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
5055
5059
  * @param {Omit<ICreateStreamSolanaExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
5056
5060
  * @returns Transaction instructions and metadata ID
@@ -5068,6 +5072,13 @@ var SolanaStreamClient = class extends BaseStreamClient {
5068
5072
  true,
5069
5073
  tokenProgramId ? new web3_js.PublicKey(tokenProgramId) : void 0
5070
5074
  );
5075
+ if (isNative) {
5076
+ const totalFee = await this.getTotalFee({
5077
+ address: partnerPublicKey.toString()
5078
+ });
5079
+ const totalAmount = calculateTotalAmountToDeposit(amount, totalFee);
5080
+ ixs.push(...await solana.prepareWrappedAccount(this.connection, tempSender.publicKey, totalAmount));
5081
+ }
5071
5082
  const {
5072
5083
  ixs: createIxs,
5073
5084
  metadata,
@@ -5077,13 +5088,6 @@ var SolanaStreamClient = class extends BaseStreamClient {
5077
5088
  sender: tempSender
5078
5089
  });
5079
5090
  ixs.push(...createIxs);
5080
- if (isNative) {
5081
- const totalFee = await this.getTotalFee({
5082
- address: partnerPublicKey.toString()
5083
- });
5084
- const totalAmount = calculateTotalAmountToDeposit(amount, totalFee);
5085
- ixs.push(...await solana.prepareWrappedAccount(this.connection, tempSender.publicKey, totalAmount));
5086
- }
5087
5091
  await this.applyCustomAfterInstructions(ixs, customInstructions, metadataPubKey);
5088
5092
  return {
5089
5093
  ixs,
@@ -5094,6 +5098,10 @@ var SolanaStreamClient = class extends BaseStreamClient {
5094
5098
  /**
5095
5099
  * Builds a transaction for creating a new stream/vesting contract without signing or executing it.
5096
5100
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
5101
+ *
5102
+ * For native SOL (isNative: true), SOL wrapping instructions are automatically included in the correct order
5103
+ * (before stream creation) to ensure the WSOL account exists when the stream creation instruction executes.
5104
+ *
5097
5105
  * @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
5098
5106
  * @param {Omit<ICreateStreamSolanaExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
5099
5107
  * @returns Transaction and metadata information
@@ -5540,6 +5548,25 @@ var SolanaStreamClient = class extends BaseStreamClient {
5540
5548
  /**
5541
5549
  * Builds multiple transactions for creating stream/vesting contracts without signing or executing them.
5542
5550
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
5551
+ *
5552
+ * IMPORTANT: When using native SOL (isNative: true), you MUST execute the prepareTx FIRST and wait for confirmation
5553
+ * before executing the stream creation transactions. Otherwise, stream creation will fail with "InvalidAccountData".
5554
+ *
5555
+ * @example
5556
+ * ```typescript
5557
+ * const result = await streamClient.buildCreateMultipleTransactions(data, { isNative: true, senderPublicKey });
5558
+ *
5559
+ * // CRITICAL: Execute prepareTx first if it exists
5560
+ * if (result.prepareTx) {
5561
+ * await connection.sendAndConfirmTransaction(result.prepareTx, [signer]);
5562
+ * }
5563
+ *
5564
+ * // Only then execute stream creation transactions
5565
+ * for (const item of result.transactions) {
5566
+ * await connection.sendAndConfirmTransaction(item.tx, [signer]);
5567
+ * }
5568
+ * ```
5569
+ *
5543
5570
  * @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
5544
5571
  * @param {Omit<ICreateStreamSolanaExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
5545
5572
  * @returns Multiple transaction information