@streamflow/stream 8.8.0 → 8.9.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.
@@ -1,4 +1,4 @@
1
- export { Z as Account, a3 as AlignedContract, M as AlignedUnlocksContract, a6 as BatchItem, a8 as BatchItemError, a9 as BatchItemResult, a7 as BatchItemSuccess, U as ChangeOracleParams, y as ClientCreationOptions, a2 as Contract, R as CreateParams, V as CreateTestOracleParams, a4 as DecodedStream, $ as ICreateSolanaExt, a1 as ICreateStreamInstructions, I as ICreateStreamSolanaExt, a as IInteractStreamSolanaExt, Y as ISearchStreams, b as ITopUpStreamSolanaExt, a0 as ITransactionSolanaExtWithInstructions, aa as InstructionGenerator, a5 as MetadataRecipientHashMap, N as OracleType, S as SolanaStreamClient, Q as TestOracle, X as UpdateTestOracleParams, af as cancelStreamInstruction, x as constants, ab as createStreamInstruction, ac as createUncheckedStreamInstruction, z as decodeStream, J as deriveContractPDA, K as deriveEscrowPDA, L as deriveTestOraclePDA, H as extractSolanaErrorCode, G as sendAndConfirmStreamRawTransaction, B as signAllTransactionWithRecipients, _ as timelockIDL, ah as topupStreamInstruction, ag as transferStreamInstruction, ae as updateStreamInstruction, ad as withdrawStreamInstruction } from '../index-D-w3ZCyC.js';
1
+ export { Z as Account, a5 as AlignedContract, M as AlignedUnlocksContract, a8 as BatchItem, aa as BatchItemError, ab as BatchItemResult, a9 as BatchItemSuccess, U as ChangeOracleParams, y as ClientCreationOptions, a4 as Contract, R as CreateParams, V as CreateTestOracleParams, a6 as DecodedStream, $ as ICreateSolanaExt, a3 as ICreateStreamInstructions, I as ICreateStreamSolanaExt, a as IInteractStreamSolanaExt, a1 as IPrepareCreateStreamSolanaExt, a2 as IPrepareStreamSolanaExt, Y as ISearchStreams, b as ITopUpStreamSolanaExt, a0 as ITransactionSolanaExtWithInstructions, ac as InstructionGenerator, a7 as MetadataRecipientHashMap, N as OracleType, S as SolanaStreamClient, Q as TestOracle, X as UpdateTestOracleParams, ah as cancelStreamInstruction, x as constants, ad as createStreamInstruction, ae as createUncheckedStreamInstruction, z as decodeStream, J as deriveContractPDA, K as deriveEscrowPDA, L as deriveTestOraclePDA, H as extractSolanaErrorCode, G as sendAndConfirmStreamRawTransaction, B as signAllTransactionWithRecipients, _ as timelockIDL, aj as topupStreamInstruction, ai as transferStreamInstruction, ag as updateStreamInstruction, af as withdrawStreamInstruction } from '../index-BNQVJtIE.js';
2
2
  export { ContractError, IChain, ICluster } from '@streamflow/common';
3
3
  import 'p-queue';
4
4
  import '@solana/web3.js';
@@ -6,7 +6,7 @@ import { PublicKey, TransactionInstruction, Connection, Keypair, SYSVAR_RENT_PUB
6
6
  import { isSignerKeypair, isSignerWallet, executeTransaction, buildSendThrottler, prepareWrappedAccount, prepareTransaction, signAndExecuteTransaction, getMintAndProgram, prepareBaseInstructions, ata, createVersionedTransaction, executeMultipleTransactions, getMultipleAccountsInfoBatched, getProgramAccounts, checkOrCreateAtaBatch } from '@streamflow/common/solana';
7
7
  import * as borsh from 'borsh';
8
8
  import { Program } from '@coral-xyz/anchor';
9
- import { ICluster, getBN } from '@streamflow/common';
9
+ import { ICluster, assertHasPublicKey, invariant, getBN } from '@streamflow/common';
10
10
  export { ContractError, IChain, ICluster } from '@streamflow/common';
11
11
  import * as BufferLayout from '@solana/buffer-layout';
12
12
 
@@ -2441,14 +2441,14 @@ var SolanaStreamClient = class extends BaseStreamClient {
2441
2441
  */
2442
2442
  async buildCreateTransactionInstructions(data, extParams) {
2443
2443
  const { partner, amount, tokenProgramId } = data;
2444
- const { isNative, senderPublicKey, customInstructions } = extParams;
2444
+ const { isNative, sender, customInstructions } = extParams;
2445
+ assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
2445
2446
  const partnerPublicKey = partner ? new PublicKey(partner) : WITHDRAWOR_PUBLIC_KEY;
2446
2447
  const mintPublicKey = new PublicKey(data.tokenId);
2447
- const tempSender = { publicKey: senderPublicKey };
2448
2448
  const ixs = await this.getCreateATAInstructions(
2449
2449
  [partnerPublicKey],
2450
2450
  mintPublicKey,
2451
- tempSender,
2451
+ sender,
2452
2452
  true,
2453
2453
  tokenProgramId ? new PublicKey(tokenProgramId) : void 0
2454
2454
  );
@@ -2457,7 +2457,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
2457
2457
  address: partnerPublicKey.toString()
2458
2458
  });
2459
2459
  const totalAmount = calculateTotalAmountToDeposit(amount, totalFee);
2460
- ixs.push(...await prepareWrappedAccount(this.connection, tempSender.publicKey, totalAmount));
2460
+ ixs.push(...await prepareWrappedAccount(this.connection, sender.publicKey, totalAmount));
2461
2461
  }
2462
2462
  const {
2463
2463
  ixs: createIxs,
@@ -2465,7 +2465,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
2465
2465
  metadataPubKey
2466
2466
  } = await this.prepareCreateInstructions(data, {
2467
2467
  ...extParams,
2468
- sender: tempSender
2468
+ sender
2469
2469
  });
2470
2470
  ixs.push(...createIxs);
2471
2471
  await this.applyCustomAfterInstructions(ixs, customInstructions, metadataPubKey);
@@ -2487,9 +2487,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
2487
2487
  * @returns Transaction and metadata information
2488
2488
  */
2489
2489
  async buildCreateTransaction(data, extParams) {
2490
- const { senderPublicKey } = extParams;
2490
+ const { sender } = extParams;
2491
2491
  const { ixs, metadataId, metadata } = await this.buildCreateTransactionInstructions(data, extParams);
2492
- const { tx, hash, context } = await prepareTransaction(this.connection, ixs, senderPublicKey, void 0, [
2492
+ const { tx, hash, context } = await prepareTransaction(this.connection, ixs, sender.publicKey, void 0, [
2493
2493
  metadata
2494
2494
  ]);
2495
2495
  return {
@@ -2509,12 +2509,10 @@ var SolanaStreamClient = class extends BaseStreamClient {
2509
2509
  */
2510
2510
  async create(data, extParams) {
2511
2511
  const { sender } = extParams;
2512
- if (!sender.publicKey) {
2513
- throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
2514
- }
2512
+ assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
2515
2513
  const { ixs, metadataId, metadata } = await this.buildCreateTransactionInstructions(data, {
2516
2514
  ...extParams,
2517
- senderPublicKey: sender.publicKey
2515
+ sender
2518
2516
  });
2519
2517
  const { tx, hash, context } = await prepareTransaction(this.connection, ixs, sender.publicKey, void 0, [
2520
2518
  metadata
@@ -2567,19 +2565,13 @@ var SolanaStreamClient = class extends BaseStreamClient {
2567
2565
  floorPrice
2568
2566
  } = streamParams;
2569
2567
  const { isNative, sender, computeLimit, computePrice, metadataPubKeys } = extParams;
2570
- if (!sender.publicKey) {
2571
- throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
2572
- }
2573
- if (!priceOracle && oracleType && oracleType !== "none") {
2574
- throw new Error("Price oracle is required for the specified oracle type");
2575
- }
2568
+ invariant(!priceOracle && oracleType && oracleType !== "none", "Price oracle is required for the specified oracle type");
2569
+ assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
2576
2570
  const recipientPublicKey = new PublicKey(recipient);
2577
2571
  const mintPublicKey = isNative ? NATIVE_MINT : new PublicKey(mint);
2578
2572
  const metadata = !metadataPubKeys ? Keypair.generate() : void 0;
2579
2573
  const metadataPubKey = metadata ? metadata.publicKey : metadataPubKeys[0];
2580
- if (!metadataPubKey) {
2581
- throw new Error("Metadata public key is required");
2582
- }
2574
+ invariant(metadataPubKey, "Metadata public key is required");
2583
2575
  let tokenProgramId = streamTokenProgramId ? new PublicKey(streamTokenProgramId) : void 0;
2584
2576
  if (!tokenProgramId) {
2585
2577
  tokenProgramId = (await getMintAndProgram(this.connection, mintPublicKey)).tokenProgramId;
@@ -2592,9 +2584,11 @@ var SolanaStreamClient = class extends BaseStreamClient {
2592
2584
  computePrice,
2593
2585
  computeLimit: computeLimit ?? ALIGNED_COMPUTE_LIMIT
2594
2586
  });
2595
- ixs.push(
2596
- ...await this.getCreateATAInstructions([recipientPublicKey], mintPublicKey, sender, true, tokenProgramId)
2597
- );
2587
+ if (recipientPublicKey.toString() !== sender.toString() || !isNative) {
2588
+ ixs.push(
2589
+ ...await this.getCreateATAInstructions([recipientPublicKey], mintPublicKey, sender, true, tokenProgramId)
2590
+ );
2591
+ }
2598
2592
  const encodedUIntArray = new TextEncoder().encode(streamName);
2599
2593
  const streamNameArray = Array.from(encodedUIntArray);
2600
2594
  const createIx = await this.alignedProxyProgram.methods.create({
@@ -2641,7 +2635,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
2641
2635
  * Creates a new stream/vesting contract.
2642
2636
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
2643
2637
  * @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
2644
- * @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
2638
+ * @param {IPrepareCreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
2645
2639
  * @returns Create stream instructions
2646
2640
  */
2647
2641
  async prepareCreateStreamInstructions({
@@ -2666,9 +2660,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
2666
2660
  partner,
2667
2661
  tokenProgramId: streamTokenProgramId
2668
2662
  }, { sender, metadataPubKeys, isNative = false, computePrice, computeLimit }) {
2669
- if (!sender.publicKey) {
2670
- throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
2671
- }
2663
+ assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
2672
2664
  const ixs = prepareBaseInstructions(this.connection, {
2673
2665
  computePrice,
2674
2666
  computeLimit
@@ -2748,7 +2740,10 @@ var SolanaStreamClient = class extends BaseStreamClient {
2748
2740
  * @returns Create result
2749
2741
  */
2750
2742
  async createUnchecked(data, extParams) {
2751
- const { ixs, metadata, metadataPubKey } = await this.prepareCreateUncheckedInstructions(data, extParams);
2743
+ const { ixs, metadata, metadataPubKey } = await this.prepareCreateUncheckedInstructions(
2744
+ data,
2745
+ extParams
2746
+ );
2752
2747
  const { tx, hash, context } = await prepareTransaction(
2753
2748
  this.connection,
2754
2749
  ixs,
@@ -2793,9 +2788,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
2793
2788
  withdrawalFrequency = 0,
2794
2789
  partner
2795
2790
  }, { sender, metadataPubKeys, isNative = false, computePrice, computeLimit }) {
2796
- if (!sender.publicKey) {
2797
- throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
2798
- }
2791
+ assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
2799
2792
  const mintPublicKey = new PublicKey(mint);
2800
2793
  const recipientPublicKey = new PublicKey(recipient);
2801
2794
  const { metadata, metadataPubKey } = this.getOrCreateStreamMetadata(metadataPubKeys);
@@ -2804,7 +2797,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
2804
2797
  programId: this.programId,
2805
2798
  space: METADATA_ACC_SIZE,
2806
2799
  lamports: rentToExempt,
2807
- fromPubkey: sender?.publicKey,
2800
+ fromPubkey: sender.publicKey,
2808
2801
  newAccountPubkey: metadataPubKey
2809
2802
  });
2810
2803
  const [escrowTokens] = PublicKey.findProgramAddressSync(
@@ -2866,12 +2859,13 @@ var SolanaStreamClient = class extends BaseStreamClient {
2866
2859
  * Builds transaction instructions for creating multiple stream/vesting contracts without creating transactions.
2867
2860
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
2868
2861
  * @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
2869
- * @param {Omit<ICreateStreamSolanaExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
2862
+ * @param {IPrepareCreateStreamSolanaExt} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
2870
2863
  * @returns Create multiple transaction instructions
2871
2864
  */
2872
2865
  async buildCreateMultipleTransactionInstructions(data, extParams) {
2873
2866
  const { recipients, ...streamParams } = data;
2874
- const { senderPublicKey, metadataPubKeys: metadataPubKeysExt, isNative, customInstructions } = extParams;
2867
+ const { sender, metadataPubKeys: metadataPubKeysExt, isNative, customInstructions } = extParams;
2868
+ assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
2875
2869
  const metadatas = [];
2876
2870
  const metadataToRecipient = {};
2877
2871
  const instructionsBatch = [];
@@ -2881,12 +2875,10 @@ var SolanaStreamClient = class extends BaseStreamClient {
2881
2875
  if (recipients.length === 0) {
2882
2876
  throw new Error("Recipients array is empty!");
2883
2877
  }
2884
- const tempSender = { publicKey: senderPublicKey };
2885
2878
  for (let i = 0; i < recipients.length; i++) {
2886
2879
  const recipientData = recipients[i];
2887
2880
  const createStreamData = { ...streamParams, ...recipientData };
2888
2881
  const createStreamExtParams = {
2889
- sender: tempSender,
2890
2882
  metadataPubKeys: metadataPubKeys[i] ? [metadataPubKeys[i]] : void 0,
2891
2883
  ...extParams
2892
2884
  };
@@ -2906,14 +2898,14 @@ var SolanaStreamClient = class extends BaseStreamClient {
2906
2898
  const prepareInstructions = await this.getCreateATAInstructions(
2907
2899
  [partnerPublicKey],
2908
2900
  mintPublicKey,
2909
- tempSender,
2901
+ sender,
2910
2902
  true
2911
2903
  );
2912
2904
  if (isNative) {
2913
2905
  const totalDepositedAmount = recipients.reduce((acc, recipient) => recipient.amount.add(acc), new BN4(0));
2914
2906
  const nativeInstructions = await prepareWrappedAccount(
2915
2907
  this.connection,
2916
- tempSender.publicKey,
2908
+ sender.publicKey,
2917
2909
  totalDepositedAmount
2918
2910
  );
2919
2911
  prepareInstructions.push(...nativeInstructions);
@@ -2948,20 +2940,20 @@ var SolanaStreamClient = class extends BaseStreamClient {
2948
2940
  * ```
2949
2941
  *
2950
2942
  * @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
2951
- * @param {Omit<ICreateStreamSolanaExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
2943
+ * @param {IPrepareCreateStreamSolanaExt} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
2952
2944
  * @returns Multiple transaction information
2953
2945
  */
2954
2946
  async buildCreateMultipleTransactions(data, extParams) {
2955
- const { senderPublicKey } = extParams;
2947
+ const { sender } = extParams;
2956
2948
  const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, extParams);
2957
2949
  const { value: hash, context } = await this.connection.getLatestBlockhashAndContext();
2958
2950
  const batch = [];
2959
2951
  for (const { ixs, metadata, recipient } of instructionsBatch) {
2960
- batch.push({ tx: createVersionedTransaction(ixs, senderPublicKey, hash.blockhash, [metadata]), recipient });
2952
+ batch.push({ tx: createVersionedTransaction(ixs, sender.publicKey, hash.blockhash, [metadata]), recipient });
2961
2953
  }
2962
2954
  let prepareTx;
2963
2955
  if (prepareInstructions.length > 0) {
2964
- prepareTx = createVersionedTransaction(prepareInstructions, senderPublicKey, hash.blockhash);
2956
+ prepareTx = createVersionedTransaction(prepareInstructions, sender.publicKey, hash.blockhash);
2965
2957
  }
2966
2958
  return {
2967
2959
  transactions: batch,
@@ -2984,10 +2976,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
2984
2976
  if (!sender.publicKey) {
2985
2977
  throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
2986
2978
  }
2987
- const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, {
2988
- ...extParams,
2989
- senderPublicKey: sender.publicKey
2990
- });
2979
+ const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, extParams);
2991
2980
  const errors = [];
2992
2981
  const signatures = [];
2993
2982
  const metadataPubKeys = metadataPubKeysExt || [];
@@ -3052,10 +3041,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
3052
3041
  if (!sender.publicKey) {
3053
3042
  throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
3054
3043
  }
3055
- const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, {
3056
- ...extParams,
3057
- senderPublicKey: sender.publicKey
3058
- });
3044
+ const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, extParams);
3059
3045
  const errors = [];
3060
3046
  const signatures = [];
3061
3047
  const batch = [];
@@ -3118,10 +3104,11 @@ var SolanaStreamClient = class extends BaseStreamClient {
3118
3104
  */
3119
3105
  async withdraw({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, extParams) {
3120
3106
  const { invoker, customInstructions } = extParams;
3121
- if (!invoker.publicKey) {
3122
- throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
3123
- }
3124
- const ixs = await this.prepareWithdrawInstructions({ id, amount }, extParams);
3107
+ assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
3108
+ const ixs = await this.prepareWithdrawInstructions(
3109
+ { id, amount },
3110
+ extParams
3111
+ );
3125
3112
  const metadata = new PublicKey(id);
3126
3113
  await this.applyCustomAfterInstructions(ixs, customInstructions, metadata);
3127
3114
  const { tx, hash, context } = await prepareTransaction(this.connection, ixs, invoker.publicKey);
@@ -3141,22 +3128,18 @@ var SolanaStreamClient = class extends BaseStreamClient {
3141
3128
  /**
3142
3129
  * Creates Transaction Instructions for withdrawal
3143
3130
  * @param {IWithdrawData} withdrawData - Withdrawal parameters including stream ID and amount to withdraw
3144
- * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
3131
+ * @param {IPrepareStreamSolanaExt} extParams - Transaction configuration including invoker wallet address, token account validation, and compute settings
3145
3132
  * @returns Transaction instructions
3146
3133
  */
3147
3134
  async prepareWithdrawInstructions({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
3148
- if (!invoker.publicKey) {
3149
- throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
3150
- }
3135
+ assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
3151
3136
  const ixs = prepareBaseInstructions(this.connection, {
3152
3137
  computePrice,
3153
3138
  computeLimit
3154
3139
  });
3155
3140
  const streamPublicKey = new PublicKey(id);
3156
3141
  const escrow = await this.connection.getAccountInfo(streamPublicKey);
3157
- if (!escrow?.data) {
3158
- throw new Error("Couldn't get account info");
3159
- }
3142
+ invariant(escrow?.data, "Couldn't get account info");
3160
3143
  const data = decodeStream(escrow.data);
3161
3144
  const { sender, recipient, mint, streamflowTreasury, partner, recipientTokens, escrowTokens } = data;
3162
3145
  const { tokenProgramId } = await getMintAndProgram(this.connection, mint);
@@ -3212,7 +3195,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
3212
3195
  /**
3213
3196
  * Creates Transaction Instructions for cancel
3214
3197
  * @param {ICancelData} cancelData - Cancellation parameters including stream ID
3215
- * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
3198
+ * @param {IPrepareStreamSolanaExt} extParams - Transaction configuration including invoker wallet address, token account validation, and compute settings
3216
3199
  * @returns Transaction instructions
3217
3200
  */
3218
3201
  async prepareCancelInstructions(cancelData, extParams) {
@@ -3229,18 +3212,14 @@ var SolanaStreamClient = class extends BaseStreamClient {
3229
3212
  /**
3230
3213
  * Creates Transaction Instructions for cancel
3231
3214
  * @param {ICancelData} cancelData - Cancellation parameters including stream ID
3232
- * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
3215
+ * @param {IPrepareStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
3233
3216
  * @returns Transaction instructions
3234
3217
  */
3235
3218
  async prepareCancelAlignedUnlockInstructions({ id }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
3236
- if (!invoker.publicKey) {
3237
- throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
3238
- }
3219
+ assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
3239
3220
  const streamPublicKey = new PublicKey(id);
3240
3221
  const escrowAcc = await this.connection.getAccountInfo(streamPublicKey);
3241
- if (!escrowAcc?.data) {
3242
- throw new Error("Couldn't get account info");
3243
- }
3222
+ invariant(escrowAcc?.data, "Couldn't get account info");
3244
3223
  const streamData = decodeStream(escrowAcc.data);
3245
3224
  const { sender, recipient, mint, streamflowTreasury, partner, escrowTokens } = streamData;
3246
3225
  const { tokenProgramId } = await getMintAndProgram(this.connection, mint);
@@ -3272,18 +3251,14 @@ var SolanaStreamClient = class extends BaseStreamClient {
3272
3251
  /**
3273
3252
  * Creates Transaction Instructions for cancel
3274
3253
  * @param {ICancelData} cancelData - Cancellation parameters including stream ID
3275
- * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
3254
+ * @param {IPrepareStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
3276
3255
  * @returns Transaction instructions
3277
3256
  */
3278
3257
  async prepareCancelStreamInstructions({ id }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
3279
- if (!invoker.publicKey) {
3280
- throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
3281
- }
3258
+ assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
3282
3259
  const streamPublicKey = new PublicKey(id);
3283
3260
  const escrowAcc = await this.connection.getAccountInfo(streamPublicKey);
3284
- if (!escrowAcc?.data) {
3285
- throw new Error("Couldn't get account info");
3286
- }
3261
+ invariant(escrowAcc?.data, "Couldn't get account info");
3287
3262
  const data = decodeStream(escrowAcc.data);
3288
3263
  const { sender, recipient, partner, streamflowTreasury, mint, senderTokens, recipientTokens, escrowTokens } = data;
3289
3264
  const { tokenProgramId } = await getMintAndProgram(this.connection, mint);
@@ -3347,13 +3322,11 @@ var SolanaStreamClient = class extends BaseStreamClient {
3347
3322
  * Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
3348
3323
  * Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
3349
3324
  * @param {ITransferData} transferData - Transfer parameters including stream ID and new recipient address
3350
- * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
3325
+ * @param {IPrepareStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
3351
3326
  * @returns Transaction instructions
3352
3327
  */
3353
3328
  async prepareTransferInstructions({ id, newRecipient }, { invoker, computePrice, computeLimit = 100001 }) {
3354
- if (!invoker.publicKey) {
3355
- throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
3356
- }
3329
+ assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
3357
3330
  const ixs = prepareBaseInstructions(this.connection, {
3358
3331
  computePrice,
3359
3332
  computeLimit
@@ -3361,9 +3334,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
3361
3334
  const stream = new PublicKey(id);
3362
3335
  const newRecipientPublicKey = new PublicKey(newRecipient);
3363
3336
  const escrow = await this.connection.getAccountInfo(stream);
3364
- if (!escrow?.data) {
3365
- throw new Error("Couldn't get account info");
3366
- }
3337
+ invariant(escrow?.data, "Couldn't get account info");
3367
3338
  const { mint } = decodeStream(escrow?.data);
3368
3339
  const { tokenProgramId } = await getMintAndProgram(this.connection, mint);
3369
3340
  const newRecipientTokens = await ata(mint, newRecipientPublicKey, tokenProgramId);
@@ -3599,6 +3570,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
3599
3570
  * @returns Transaction result
3600
3571
  */
3601
3572
  async update(data, extParams) {
3573
+ if (!extParams.invoker.publicKey) {
3574
+ throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
3575
+ }
3602
3576
  const ixs = await this.prepareUpdateInstructions(data, extParams);
3603
3577
  const { tx, hash, context } = await prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
3604
3578
  const signature = await signAndExecuteTransaction(
@@ -3620,18 +3594,14 @@ var SolanaStreamClient = class extends BaseStreamClient {
3620
3594
  /**
3621
3595
  * Create Transaction instructions for update
3622
3596
  * @param {IUpdateData} data - Update parameters including stream ID and new settings
3623
- * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
3597
+ * @param {IPrepareStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
3624
3598
  * @returns Transaction instructions
3625
3599
  */
3626
3600
  async prepareUpdateInstructions(data, { invoker, computePrice, computeLimit }) {
3627
- if (!invoker.publicKey) {
3628
- throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
3629
- }
3601
+ assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
3630
3602
  const streamPublicKey = new PublicKey(data.id);
3631
3603
  const escrow = await this.connection.getAccountInfo(streamPublicKey);
3632
- if (!escrow) {
3633
- throw new Error("Couldn't get account info");
3634
- }
3604
+ invariant(escrow, "Couldn't get account info");
3635
3605
  const ixs = prepareBaseInstructions(this.connection, {
3636
3606
  computePrice,
3637
3607
  computeLimit