@streamflow/stream 8.8.1 → 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,7 +2584,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
2592
2584
  computePrice,
2593
2585
  computeLimit: computeLimit ?? ALIGNED_COMPUTE_LIMIT
2594
2586
  });
2595
- if (recipientPublicKey.toString() !== sender.publicKey.toString() || !isNative) {
2587
+ if (recipientPublicKey.toString() !== sender.toString() || !isNative) {
2596
2588
  ixs.push(
2597
2589
  ...await this.getCreateATAInstructions([recipientPublicKey], mintPublicKey, sender, true, tokenProgramId)
2598
2590
  );
@@ -2643,7 +2635,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
2643
2635
  * Creates a new stream/vesting contract.
2644
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).
2645
2637
  * @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
2646
- * @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
2647
2639
  * @returns Create stream instructions
2648
2640
  */
2649
2641
  async prepareCreateStreamInstructions({
@@ -2668,9 +2660,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
2668
2660
  partner,
2669
2661
  tokenProgramId: streamTokenProgramId
2670
2662
  }, { sender, metadataPubKeys, isNative = false, computePrice, computeLimit }) {
2671
- if (!sender.publicKey) {
2672
- throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
2673
- }
2663
+ assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
2674
2664
  const ixs = prepareBaseInstructions(this.connection, {
2675
2665
  computePrice,
2676
2666
  computeLimit
@@ -2750,7 +2740,10 @@ var SolanaStreamClient = class extends BaseStreamClient {
2750
2740
  * @returns Create result
2751
2741
  */
2752
2742
  async createUnchecked(data, extParams) {
2753
- const { ixs, metadata, metadataPubKey } = await this.prepareCreateUncheckedInstructions(data, extParams);
2743
+ const { ixs, metadata, metadataPubKey } = await this.prepareCreateUncheckedInstructions(
2744
+ data,
2745
+ extParams
2746
+ );
2754
2747
  const { tx, hash, context } = await prepareTransaction(
2755
2748
  this.connection,
2756
2749
  ixs,
@@ -2795,9 +2788,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
2795
2788
  withdrawalFrequency = 0,
2796
2789
  partner
2797
2790
  }, { sender, metadataPubKeys, isNative = false, computePrice, computeLimit }) {
2798
- if (!sender.publicKey) {
2799
- throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
2800
- }
2791
+ assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
2801
2792
  const mintPublicKey = new PublicKey(mint);
2802
2793
  const recipientPublicKey = new PublicKey(recipient);
2803
2794
  const { metadata, metadataPubKey } = this.getOrCreateStreamMetadata(metadataPubKeys);
@@ -2806,7 +2797,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
2806
2797
  programId: this.programId,
2807
2798
  space: METADATA_ACC_SIZE,
2808
2799
  lamports: rentToExempt,
2809
- fromPubkey: sender?.publicKey,
2800
+ fromPubkey: sender.publicKey,
2810
2801
  newAccountPubkey: metadataPubKey
2811
2802
  });
2812
2803
  const [escrowTokens] = PublicKey.findProgramAddressSync(
@@ -2868,12 +2859,13 @@ var SolanaStreamClient = class extends BaseStreamClient {
2868
2859
  * Builds transaction instructions for creating multiple stream/vesting contracts without creating transactions.
2869
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).
2870
2861
  * @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
2871
- * @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
2872
2863
  * @returns Create multiple transaction instructions
2873
2864
  */
2874
2865
  async buildCreateMultipleTransactionInstructions(data, extParams) {
2875
2866
  const { recipients, ...streamParams } = data;
2876
- 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!");
2877
2869
  const metadatas = [];
2878
2870
  const metadataToRecipient = {};
2879
2871
  const instructionsBatch = [];
@@ -2883,12 +2875,10 @@ var SolanaStreamClient = class extends BaseStreamClient {
2883
2875
  if (recipients.length === 0) {
2884
2876
  throw new Error("Recipients array is empty!");
2885
2877
  }
2886
- const tempSender = { publicKey: senderPublicKey };
2887
2878
  for (let i = 0; i < recipients.length; i++) {
2888
2879
  const recipientData = recipients[i];
2889
2880
  const createStreamData = { ...streamParams, ...recipientData };
2890
2881
  const createStreamExtParams = {
2891
- sender: tempSender,
2892
2882
  metadataPubKeys: metadataPubKeys[i] ? [metadataPubKeys[i]] : void 0,
2893
2883
  ...extParams
2894
2884
  };
@@ -2908,14 +2898,14 @@ var SolanaStreamClient = class extends BaseStreamClient {
2908
2898
  const prepareInstructions = await this.getCreateATAInstructions(
2909
2899
  [partnerPublicKey],
2910
2900
  mintPublicKey,
2911
- tempSender,
2901
+ sender,
2912
2902
  true
2913
2903
  );
2914
2904
  if (isNative) {
2915
2905
  const totalDepositedAmount = recipients.reduce((acc, recipient) => recipient.amount.add(acc), new BN4(0));
2916
2906
  const nativeInstructions = await prepareWrappedAccount(
2917
2907
  this.connection,
2918
- tempSender.publicKey,
2908
+ sender.publicKey,
2919
2909
  totalDepositedAmount
2920
2910
  );
2921
2911
  prepareInstructions.push(...nativeInstructions);
@@ -2950,20 +2940,20 @@ var SolanaStreamClient = class extends BaseStreamClient {
2950
2940
  * ```
2951
2941
  *
2952
2942
  * @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
2953
- * @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
2954
2944
  * @returns Multiple transaction information
2955
2945
  */
2956
2946
  async buildCreateMultipleTransactions(data, extParams) {
2957
- const { senderPublicKey } = extParams;
2947
+ const { sender } = extParams;
2958
2948
  const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, extParams);
2959
2949
  const { value: hash, context } = await this.connection.getLatestBlockhashAndContext();
2960
2950
  const batch = [];
2961
2951
  for (const { ixs, metadata, recipient } of instructionsBatch) {
2962
- batch.push({ tx: createVersionedTransaction(ixs, senderPublicKey, hash.blockhash, [metadata]), recipient });
2952
+ batch.push({ tx: createVersionedTransaction(ixs, sender.publicKey, hash.blockhash, [metadata]), recipient });
2963
2953
  }
2964
2954
  let prepareTx;
2965
2955
  if (prepareInstructions.length > 0) {
2966
- prepareTx = createVersionedTransaction(prepareInstructions, senderPublicKey, hash.blockhash);
2956
+ prepareTx = createVersionedTransaction(prepareInstructions, sender.publicKey, hash.blockhash);
2967
2957
  }
2968
2958
  return {
2969
2959
  transactions: batch,
@@ -2986,10 +2976,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
2986
2976
  if (!sender.publicKey) {
2987
2977
  throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
2988
2978
  }
2989
- const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, {
2990
- ...extParams,
2991
- senderPublicKey: sender.publicKey
2992
- });
2979
+ const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, extParams);
2993
2980
  const errors = [];
2994
2981
  const signatures = [];
2995
2982
  const metadataPubKeys = metadataPubKeysExt || [];
@@ -3054,10 +3041,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
3054
3041
  if (!sender.publicKey) {
3055
3042
  throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
3056
3043
  }
3057
- const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, {
3058
- ...extParams,
3059
- senderPublicKey: sender.publicKey
3060
- });
3044
+ const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, extParams);
3061
3045
  const errors = [];
3062
3046
  const signatures = [];
3063
3047
  const batch = [];
@@ -3120,10 +3104,11 @@ var SolanaStreamClient = class extends BaseStreamClient {
3120
3104
  */
3121
3105
  async withdraw({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, extParams) {
3122
3106
  const { invoker, customInstructions } = extParams;
3123
- if (!invoker.publicKey) {
3124
- throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
3125
- }
3126
- 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
+ );
3127
3112
  const metadata = new PublicKey(id);
3128
3113
  await this.applyCustomAfterInstructions(ixs, customInstructions, metadata);
3129
3114
  const { tx, hash, context } = await prepareTransaction(this.connection, ixs, invoker.publicKey);
@@ -3143,22 +3128,18 @@ var SolanaStreamClient = class extends BaseStreamClient {
3143
3128
  /**
3144
3129
  * Creates Transaction Instructions for withdrawal
3145
3130
  * @param {IWithdrawData} withdrawData - Withdrawal parameters including stream ID and amount to withdraw
3146
- * @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
3147
3132
  * @returns Transaction instructions
3148
3133
  */
3149
3134
  async prepareWithdrawInstructions({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
3150
- if (!invoker.publicKey) {
3151
- throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
3152
- }
3135
+ assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
3153
3136
  const ixs = prepareBaseInstructions(this.connection, {
3154
3137
  computePrice,
3155
3138
  computeLimit
3156
3139
  });
3157
3140
  const streamPublicKey = new PublicKey(id);
3158
3141
  const escrow = await this.connection.getAccountInfo(streamPublicKey);
3159
- if (!escrow?.data) {
3160
- throw new Error("Couldn't get account info");
3161
- }
3142
+ invariant(escrow?.data, "Couldn't get account info");
3162
3143
  const data = decodeStream(escrow.data);
3163
3144
  const { sender, recipient, mint, streamflowTreasury, partner, recipientTokens, escrowTokens } = data;
3164
3145
  const { tokenProgramId } = await getMintAndProgram(this.connection, mint);
@@ -3214,7 +3195,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
3214
3195
  /**
3215
3196
  * Creates Transaction Instructions for cancel
3216
3197
  * @param {ICancelData} cancelData - Cancellation parameters including stream ID
3217
- * @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
3218
3199
  * @returns Transaction instructions
3219
3200
  */
3220
3201
  async prepareCancelInstructions(cancelData, extParams) {
@@ -3231,18 +3212,14 @@ var SolanaStreamClient = class extends BaseStreamClient {
3231
3212
  /**
3232
3213
  * Creates Transaction Instructions for cancel
3233
3214
  * @param {ICancelData} cancelData - Cancellation parameters including stream ID
3234
- * @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
3235
3216
  * @returns Transaction instructions
3236
3217
  */
3237
3218
  async prepareCancelAlignedUnlockInstructions({ id }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
3238
- if (!invoker.publicKey) {
3239
- throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
3240
- }
3219
+ assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
3241
3220
  const streamPublicKey = new PublicKey(id);
3242
3221
  const escrowAcc = await this.connection.getAccountInfo(streamPublicKey);
3243
- if (!escrowAcc?.data) {
3244
- throw new Error("Couldn't get account info");
3245
- }
3222
+ invariant(escrowAcc?.data, "Couldn't get account info");
3246
3223
  const streamData = decodeStream(escrowAcc.data);
3247
3224
  const { sender, recipient, mint, streamflowTreasury, partner, escrowTokens } = streamData;
3248
3225
  const { tokenProgramId } = await getMintAndProgram(this.connection, mint);
@@ -3274,18 +3251,14 @@ var SolanaStreamClient = class extends BaseStreamClient {
3274
3251
  /**
3275
3252
  * Creates Transaction Instructions for cancel
3276
3253
  * @param {ICancelData} cancelData - Cancellation parameters including stream ID
3277
- * @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
3278
3255
  * @returns Transaction instructions
3279
3256
  */
3280
3257
  async prepareCancelStreamInstructions({ id }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
3281
- if (!invoker.publicKey) {
3282
- throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
3283
- }
3258
+ assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
3284
3259
  const streamPublicKey = new PublicKey(id);
3285
3260
  const escrowAcc = await this.connection.getAccountInfo(streamPublicKey);
3286
- if (!escrowAcc?.data) {
3287
- throw new Error("Couldn't get account info");
3288
- }
3261
+ invariant(escrowAcc?.data, "Couldn't get account info");
3289
3262
  const data = decodeStream(escrowAcc.data);
3290
3263
  const { sender, recipient, partner, streamflowTreasury, mint, senderTokens, recipientTokens, escrowTokens } = data;
3291
3264
  const { tokenProgramId } = await getMintAndProgram(this.connection, mint);
@@ -3349,13 +3322,11 @@ var SolanaStreamClient = class extends BaseStreamClient {
3349
3322
  * Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
3350
3323
  * Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
3351
3324
  * @param {ITransferData} transferData - Transfer parameters including stream ID and new recipient address
3352
- * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
3325
+ * @param {IPrepareStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
3353
3326
  * @returns Transaction instructions
3354
3327
  */
3355
3328
  async prepareTransferInstructions({ id, newRecipient }, { invoker, computePrice, computeLimit = 100001 }) {
3356
- if (!invoker.publicKey) {
3357
- throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
3358
- }
3329
+ assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
3359
3330
  const ixs = prepareBaseInstructions(this.connection, {
3360
3331
  computePrice,
3361
3332
  computeLimit
@@ -3363,9 +3334,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
3363
3334
  const stream = new PublicKey(id);
3364
3335
  const newRecipientPublicKey = new PublicKey(newRecipient);
3365
3336
  const escrow = await this.connection.getAccountInfo(stream);
3366
- if (!escrow?.data) {
3367
- throw new Error("Couldn't get account info");
3368
- }
3337
+ invariant(escrow?.data, "Couldn't get account info");
3369
3338
  const { mint } = decodeStream(escrow?.data);
3370
3339
  const { tokenProgramId } = await getMintAndProgram(this.connection, mint);
3371
3340
  const newRecipientTokens = await ata(mint, newRecipientPublicKey, tokenProgramId);
@@ -3601,6 +3570,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
3601
3570
  * @returns Transaction result
3602
3571
  */
3603
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
+ }
3604
3576
  const ixs = await this.prepareUpdateInstructions(data, extParams);
3605
3577
  const { tx, hash, context } = await prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
3606
3578
  const signature = await signAndExecuteTransaction(
@@ -3622,18 +3594,14 @@ var SolanaStreamClient = class extends BaseStreamClient {
3622
3594
  /**
3623
3595
  * Create Transaction instructions for update
3624
3596
  * @param {IUpdateData} data - Update parameters including stream ID and new settings
3625
- * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
3597
+ * @param {IPrepareStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
3626
3598
  * @returns Transaction instructions
3627
3599
  */
3628
3600
  async prepareUpdateInstructions(data, { invoker, computePrice, computeLimit }) {
3629
- if (!invoker.publicKey) {
3630
- throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
3631
- }
3601
+ assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
3632
3602
  const streamPublicKey = new PublicKey(data.id);
3633
3603
  const escrow = await this.connection.getAccountInfo(streamPublicKey);
3634
- if (!escrow) {
3635
- throw new Error("Couldn't get account info");
3636
- }
3604
+ invariant(escrow, "Couldn't get account info");
3637
3605
  const ixs = prepareBaseInstructions(this.connection, {
3638
3606
  computePrice,
3639
3607
  computeLimit