@streamflow/stream 8.8.1 → 8.9.0-alpha.p308.94c0898
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.
- package/README.md +213 -175
- package/dist/cjs/{index-Bll7jg8V.d.cts → index-oCYfzJrc.d.cts} +37 -33
- package/dist/cjs/index.cjs +56 -88
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +2 -2
- package/dist/cjs/solana/index.cjs +56 -88
- package/dist/cjs/solana/index.cjs.map +1 -1
- package/dist/cjs/solana/index.d.cts +1 -1
- package/dist/esm/{index-D-w3ZCyC.d.ts → index-BNQVJtIE.d.ts} +37 -33
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +57 -89
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/solana/index.d.ts +1 -1
- package/dist/esm/solana/index.js +57 -89
- package/dist/esm/solana/index.js.map +1 -1
- package/package.json +4 -4
package/dist/cjs/index.d.cts
CHANGED
|
@@ -2,8 +2,8 @@ import { A as AptosStreamClient, I as ICreateStreamAptosExt, a as ITransactionAp
|
|
|
2
2
|
export { i as StreamflowAptos } from './index-DYIamO0j.cjs';
|
|
3
3
|
import { E as EvmStreamClient } from './index-BMZATAYa.cjs';
|
|
4
4
|
export { i as StreamflowEVM } from './index-BMZATAYa.cjs';
|
|
5
|
-
import { S as SolanaStreamClient, I as ICreateStreamSolanaExt, a as IInteractStreamSolanaExt, b as ITopUpStreamSolanaExt } from './index-
|
|
6
|
-
export { s as AIRDROP_AMOUNT, q as AIRDROP_TEST_TOKEN, j as ALIGNED_COMPUTE_LIMIT, A as ALIGNED_PRECISION_FACTOR_POW, h as ALIGNED_UNLOCKS_PROGRAM_ID, k as CONTRACT_DISCRIMINATOR, m as CONTRACT_SEED, C as CREATE_PARAMS_PADDING, D as DEFAULT_STREAMFLOW_FEE, E as ESCROW_SEED, r as FEES_METADATA_SEED, F as FEE_ORACLE_PUBLIC_KEY, O as ORIGINAL_CONTRACT_SENDER_OFFSET, u as PARTNERS_SCHEMA, o as PARTNER_ORACLE_PROGRAM_ID, t as PARTNER_SCHEMA, P as PROGRAM_ID, w as SOLANA_ERROR_MAP, v as SOLANA_ERROR_MATCH_REGEX, p as STREAMFLOW_TREASURY_PUBLIC_KEY, g as STREAM_STRUCT_OFFSETS, f as STREAM_STRUCT_OFFSET_CLOSED, e as STREAM_STRUCT_OFFSET_MINT, d as STREAM_STRUCT_OFFSET_RECIPIENT, c as STREAM_STRUCT_OFFSET_SENDER, i as StreamflowSolana, l as TEST_ORACLE_DISCRIMINATOR, n as TEST_ORACLE_SEED, T as TX_FINALITY_CONFIRMED, W as WITHDRAWOR_PUBLIC_KEY } from './index-
|
|
5
|
+
import { S as SolanaStreamClient, I as ICreateStreamSolanaExt, a as IInteractStreamSolanaExt, b as ITopUpStreamSolanaExt } from './index-oCYfzJrc.cjs';
|
|
6
|
+
export { s as AIRDROP_AMOUNT, q as AIRDROP_TEST_TOKEN, j as ALIGNED_COMPUTE_LIMIT, A as ALIGNED_PRECISION_FACTOR_POW, h as ALIGNED_UNLOCKS_PROGRAM_ID, k as CONTRACT_DISCRIMINATOR, m as CONTRACT_SEED, C as CREATE_PARAMS_PADDING, D as DEFAULT_STREAMFLOW_FEE, E as ESCROW_SEED, r as FEES_METADATA_SEED, F as FEE_ORACLE_PUBLIC_KEY, O as ORIGINAL_CONTRACT_SENDER_OFFSET, u as PARTNERS_SCHEMA, o as PARTNER_ORACLE_PROGRAM_ID, t as PARTNER_SCHEMA, P as PROGRAM_ID, w as SOLANA_ERROR_MAP, v as SOLANA_ERROR_MATCH_REGEX, p as STREAMFLOW_TREASURY_PUBLIC_KEY, g as STREAM_STRUCT_OFFSETS, f as STREAM_STRUCT_OFFSET_CLOSED, e as STREAM_STRUCT_OFFSET_MINT, d as STREAM_STRUCT_OFFSET_RECIPIENT, c as STREAM_STRUCT_OFFSET_SENDER, i as StreamflowSolana, l as TEST_ORACLE_DISCRIMINATOR, n as TEST_ORACLE_SEED, T as TX_FINALITY_CONFIRMED, W as WITHDRAWOR_PUBLIC_KEY } from './index-oCYfzJrc.cjs';
|
|
7
7
|
import { S as SuiStreamClient } from './index-Y0HH2ugY.cjs';
|
|
8
8
|
export { i as StreamflowSui } from './index-Y0HH2ugY.cjs';
|
|
9
9
|
import { S as Stream, A as AlignedStream, I as ICreateStreamData, a as ICreateAlignedStreamData, b as StreamType, B as BaseStreamClient, c as SolanaStreamClientOptions, d as AptosStreamClientOptions, e as SuiStreamClientOptions, E as EvmStreamClientOptions, f as ICreateStreamSuiExt, g as ICreateResult, h as ICreateMultipleStreamData, i as IMultiTransactionResult, j as IWithdrawData, k as ITransactionSuiExt, l as ITransactionResult, m as ICancelData, n as ITransferData, o as ITopUpData, p as IGetOneData, q as IGetAllData, r as IUpdateData, s as IGetFeesData, t as IFees } from './BaseStreamClient-DOyJqO7R.cjs';
|
|
@@ -2467,14 +2467,14 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2467
2467
|
*/
|
|
2468
2468
|
async buildCreateTransactionInstructions(data, extParams) {
|
|
2469
2469
|
const { partner, amount, tokenProgramId } = data;
|
|
2470
|
-
const { isNative,
|
|
2470
|
+
const { isNative, sender, customInstructions } = extParams;
|
|
2471
|
+
common.assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
|
|
2471
2472
|
const partnerPublicKey = partner ? new web3_js.PublicKey(partner) : WITHDRAWOR_PUBLIC_KEY;
|
|
2472
2473
|
const mintPublicKey = new web3_js.PublicKey(data.tokenId);
|
|
2473
|
-
const tempSender = { publicKey: senderPublicKey };
|
|
2474
2474
|
const ixs = await this.getCreateATAInstructions(
|
|
2475
2475
|
[partnerPublicKey],
|
|
2476
2476
|
mintPublicKey,
|
|
2477
|
-
|
|
2477
|
+
sender,
|
|
2478
2478
|
true,
|
|
2479
2479
|
tokenProgramId ? new web3_js.PublicKey(tokenProgramId) : void 0
|
|
2480
2480
|
);
|
|
@@ -2483,7 +2483,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2483
2483
|
address: partnerPublicKey.toString()
|
|
2484
2484
|
});
|
|
2485
2485
|
const totalAmount = calculateTotalAmountToDeposit(amount, totalFee);
|
|
2486
|
-
ixs.push(...await solana.prepareWrappedAccount(this.connection,
|
|
2486
|
+
ixs.push(...await solana.prepareWrappedAccount(this.connection, sender.publicKey, totalAmount));
|
|
2487
2487
|
}
|
|
2488
2488
|
const {
|
|
2489
2489
|
ixs: createIxs,
|
|
@@ -2491,7 +2491,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2491
2491
|
metadataPubKey
|
|
2492
2492
|
} = await this.prepareCreateInstructions(data, {
|
|
2493
2493
|
...extParams,
|
|
2494
|
-
sender
|
|
2494
|
+
sender
|
|
2495
2495
|
});
|
|
2496
2496
|
ixs.push(...createIxs);
|
|
2497
2497
|
await this.applyCustomAfterInstructions(ixs, customInstructions, metadataPubKey);
|
|
@@ -2513,9 +2513,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2513
2513
|
* @returns Transaction and metadata information
|
|
2514
2514
|
*/
|
|
2515
2515
|
async buildCreateTransaction(data, extParams) {
|
|
2516
|
-
const {
|
|
2516
|
+
const { sender } = extParams;
|
|
2517
2517
|
const { ixs, metadataId, metadata } = await this.buildCreateTransactionInstructions(data, extParams);
|
|
2518
|
-
const { tx, hash, context } = await solana.prepareTransaction(this.connection, ixs,
|
|
2518
|
+
const { tx, hash, context } = await solana.prepareTransaction(this.connection, ixs, sender.publicKey, void 0, [
|
|
2519
2519
|
metadata
|
|
2520
2520
|
]);
|
|
2521
2521
|
return {
|
|
@@ -2535,12 +2535,10 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2535
2535
|
*/
|
|
2536
2536
|
async create(data, extParams) {
|
|
2537
2537
|
const { sender } = extParams;
|
|
2538
|
-
|
|
2539
|
-
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
|
|
2540
|
-
}
|
|
2538
|
+
common.assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
|
|
2541
2539
|
const { ixs, metadataId, metadata } = await this.buildCreateTransactionInstructions(data, {
|
|
2542
2540
|
...extParams,
|
|
2543
|
-
|
|
2541
|
+
sender
|
|
2544
2542
|
});
|
|
2545
2543
|
const { tx, hash, context } = await solana.prepareTransaction(this.connection, ixs, sender.publicKey, void 0, [
|
|
2546
2544
|
metadata
|
|
@@ -2593,19 +2591,13 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2593
2591
|
floorPrice
|
|
2594
2592
|
} = streamParams;
|
|
2595
2593
|
const { isNative, sender, computeLimit, computePrice, metadataPubKeys } = extParams;
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
}
|
|
2599
|
-
if (!priceOracle && oracleType && oracleType !== "none") {
|
|
2600
|
-
throw new Error("Price oracle is required for the specified oracle type");
|
|
2601
|
-
}
|
|
2594
|
+
common.invariant(!priceOracle && oracleType && oracleType !== "none", "Price oracle is required for the specified oracle type");
|
|
2595
|
+
common.assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
|
|
2602
2596
|
const recipientPublicKey = new web3_js.PublicKey(recipient);
|
|
2603
2597
|
const mintPublicKey = isNative ? splToken.NATIVE_MINT : new web3_js.PublicKey(mint);
|
|
2604
2598
|
const metadata = !metadataPubKeys ? web3_js.Keypair.generate() : void 0;
|
|
2605
2599
|
const metadataPubKey = metadata ? metadata.publicKey : metadataPubKeys[0];
|
|
2606
|
-
|
|
2607
|
-
throw new Error("Metadata public key is required");
|
|
2608
|
-
}
|
|
2600
|
+
common.invariant(metadataPubKey, "Metadata public key is required");
|
|
2609
2601
|
let tokenProgramId = streamTokenProgramId ? new web3_js.PublicKey(streamTokenProgramId) : void 0;
|
|
2610
2602
|
if (!tokenProgramId) {
|
|
2611
2603
|
tokenProgramId = (await solana.getMintAndProgram(this.connection, mintPublicKey)).tokenProgramId;
|
|
@@ -2618,7 +2610,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2618
2610
|
computePrice,
|
|
2619
2611
|
computeLimit: computeLimit ?? ALIGNED_COMPUTE_LIMIT
|
|
2620
2612
|
});
|
|
2621
|
-
if (recipientPublicKey.toString() !== sender.
|
|
2613
|
+
if (recipientPublicKey.toString() !== sender.toString() || !isNative) {
|
|
2622
2614
|
ixs.push(
|
|
2623
2615
|
...await this.getCreateATAInstructions([recipientPublicKey], mintPublicKey, sender, true, tokenProgramId)
|
|
2624
2616
|
);
|
|
@@ -2669,7 +2661,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2669
2661
|
* Creates a new stream/vesting contract.
|
|
2670
2662
|
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
2671
2663
|
* @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
|
|
2672
|
-
* @param {
|
|
2664
|
+
* @param {IPrepareCreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
|
|
2673
2665
|
* @returns Create stream instructions
|
|
2674
2666
|
*/
|
|
2675
2667
|
async prepareCreateStreamInstructions({
|
|
@@ -2694,9 +2686,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2694
2686
|
partner,
|
|
2695
2687
|
tokenProgramId: streamTokenProgramId
|
|
2696
2688
|
}, { sender, metadataPubKeys, isNative = false, computePrice, computeLimit }) {
|
|
2697
|
-
|
|
2698
|
-
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
|
|
2699
|
-
}
|
|
2689
|
+
common.assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
|
|
2700
2690
|
const ixs = solana.prepareBaseInstructions(this.connection, {
|
|
2701
2691
|
computePrice,
|
|
2702
2692
|
computeLimit
|
|
@@ -2776,7 +2766,10 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2776
2766
|
* @returns Create result
|
|
2777
2767
|
*/
|
|
2778
2768
|
async createUnchecked(data, extParams) {
|
|
2779
|
-
const { ixs, metadata, metadataPubKey } = await this.prepareCreateUncheckedInstructions(
|
|
2769
|
+
const { ixs, metadata, metadataPubKey } = await this.prepareCreateUncheckedInstructions(
|
|
2770
|
+
data,
|
|
2771
|
+
extParams
|
|
2772
|
+
);
|
|
2780
2773
|
const { tx, hash, context } = await solana.prepareTransaction(
|
|
2781
2774
|
this.connection,
|
|
2782
2775
|
ixs,
|
|
@@ -2821,9 +2814,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2821
2814
|
withdrawalFrequency = 0,
|
|
2822
2815
|
partner
|
|
2823
2816
|
}, { sender, metadataPubKeys, isNative = false, computePrice, computeLimit }) {
|
|
2824
|
-
|
|
2825
|
-
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
|
|
2826
|
-
}
|
|
2817
|
+
common.assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
|
|
2827
2818
|
const mintPublicKey = new web3_js.PublicKey(mint);
|
|
2828
2819
|
const recipientPublicKey = new web3_js.PublicKey(recipient);
|
|
2829
2820
|
const { metadata, metadataPubKey } = this.getOrCreateStreamMetadata(metadataPubKeys);
|
|
@@ -2832,7 +2823,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2832
2823
|
programId: this.programId,
|
|
2833
2824
|
space: METADATA_ACC_SIZE,
|
|
2834
2825
|
lamports: rentToExempt,
|
|
2835
|
-
fromPubkey: sender
|
|
2826
|
+
fromPubkey: sender.publicKey,
|
|
2836
2827
|
newAccountPubkey: metadataPubKey
|
|
2837
2828
|
});
|
|
2838
2829
|
const [escrowTokens] = web3_js.PublicKey.findProgramAddressSync(
|
|
@@ -2894,12 +2885,13 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2894
2885
|
* Builds transaction instructions for creating multiple stream/vesting contracts without creating transactions.
|
|
2895
2886
|
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
2896
2887
|
* @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
|
|
2897
|
-
* @param {
|
|
2888
|
+
* @param {IPrepareCreateStreamSolanaExt} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
|
|
2898
2889
|
* @returns Create multiple transaction instructions
|
|
2899
2890
|
*/
|
|
2900
2891
|
async buildCreateMultipleTransactionInstructions(data, extParams) {
|
|
2901
2892
|
const { recipients, ...streamParams } = data;
|
|
2902
|
-
const {
|
|
2893
|
+
const { sender, metadataPubKeys: metadataPubKeysExt, isNative, customInstructions } = extParams;
|
|
2894
|
+
common.assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
|
|
2903
2895
|
const metadatas = [];
|
|
2904
2896
|
const metadataToRecipient = {};
|
|
2905
2897
|
const instructionsBatch = [];
|
|
@@ -2909,12 +2901,10 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2909
2901
|
if (recipients.length === 0) {
|
|
2910
2902
|
throw new Error("Recipients array is empty!");
|
|
2911
2903
|
}
|
|
2912
|
-
const tempSender = { publicKey: senderPublicKey };
|
|
2913
2904
|
for (let i = 0; i < recipients.length; i++) {
|
|
2914
2905
|
const recipientData = recipients[i];
|
|
2915
2906
|
const createStreamData = { ...streamParams, ...recipientData };
|
|
2916
2907
|
const createStreamExtParams = {
|
|
2917
|
-
sender: tempSender,
|
|
2918
2908
|
metadataPubKeys: metadataPubKeys[i] ? [metadataPubKeys[i]] : void 0,
|
|
2919
2909
|
...extParams
|
|
2920
2910
|
};
|
|
@@ -2934,14 +2924,14 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2934
2924
|
const prepareInstructions = await this.getCreateATAInstructions(
|
|
2935
2925
|
[partnerPublicKey],
|
|
2936
2926
|
mintPublicKey,
|
|
2937
|
-
|
|
2927
|
+
sender,
|
|
2938
2928
|
true
|
|
2939
2929
|
);
|
|
2940
2930
|
if (isNative) {
|
|
2941
2931
|
const totalDepositedAmount = recipients.reduce((acc, recipient) => recipient.amount.add(acc), new BN4__default.default(0));
|
|
2942
2932
|
const nativeInstructions = await solana.prepareWrappedAccount(
|
|
2943
2933
|
this.connection,
|
|
2944
|
-
|
|
2934
|
+
sender.publicKey,
|
|
2945
2935
|
totalDepositedAmount
|
|
2946
2936
|
);
|
|
2947
2937
|
prepareInstructions.push(...nativeInstructions);
|
|
@@ -2976,20 +2966,20 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2976
2966
|
* ```
|
|
2977
2967
|
*
|
|
2978
2968
|
* @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
|
|
2979
|
-
* @param {
|
|
2969
|
+
* @param {IPrepareCreateStreamSolanaExt} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
|
|
2980
2970
|
* @returns Multiple transaction information
|
|
2981
2971
|
*/
|
|
2982
2972
|
async buildCreateMultipleTransactions(data, extParams) {
|
|
2983
|
-
const {
|
|
2973
|
+
const { sender } = extParams;
|
|
2984
2974
|
const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, extParams);
|
|
2985
2975
|
const { value: hash, context } = await this.connection.getLatestBlockhashAndContext();
|
|
2986
2976
|
const batch = [];
|
|
2987
2977
|
for (const { ixs, metadata, recipient } of instructionsBatch) {
|
|
2988
|
-
batch.push({ tx: solana.createVersionedTransaction(ixs,
|
|
2978
|
+
batch.push({ tx: solana.createVersionedTransaction(ixs, sender.publicKey, hash.blockhash, [metadata]), recipient });
|
|
2989
2979
|
}
|
|
2990
2980
|
let prepareTx;
|
|
2991
2981
|
if (prepareInstructions.length > 0) {
|
|
2992
|
-
prepareTx = solana.createVersionedTransaction(prepareInstructions,
|
|
2982
|
+
prepareTx = solana.createVersionedTransaction(prepareInstructions, sender.publicKey, hash.blockhash);
|
|
2993
2983
|
}
|
|
2994
2984
|
return {
|
|
2995
2985
|
transactions: batch,
|
|
@@ -3012,10 +3002,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3012
3002
|
if (!sender.publicKey) {
|
|
3013
3003
|
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
|
|
3014
3004
|
}
|
|
3015
|
-
const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data,
|
|
3016
|
-
...extParams,
|
|
3017
|
-
senderPublicKey: sender.publicKey
|
|
3018
|
-
});
|
|
3005
|
+
const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, extParams);
|
|
3019
3006
|
const errors = [];
|
|
3020
3007
|
const signatures = [];
|
|
3021
3008
|
const metadataPubKeys = metadataPubKeysExt || [];
|
|
@@ -3080,10 +3067,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3080
3067
|
if (!sender.publicKey) {
|
|
3081
3068
|
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
|
|
3082
3069
|
}
|
|
3083
|
-
const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data,
|
|
3084
|
-
...extParams,
|
|
3085
|
-
senderPublicKey: sender.publicKey
|
|
3086
|
-
});
|
|
3070
|
+
const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, extParams);
|
|
3087
3071
|
const errors = [];
|
|
3088
3072
|
const signatures = [];
|
|
3089
3073
|
const batch = [];
|
|
@@ -3146,10 +3130,11 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3146
3130
|
*/
|
|
3147
3131
|
async withdraw({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, extParams) {
|
|
3148
3132
|
const { invoker, customInstructions } = extParams;
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3133
|
+
common.assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3134
|
+
const ixs = await this.prepareWithdrawInstructions(
|
|
3135
|
+
{ id, amount },
|
|
3136
|
+
extParams
|
|
3137
|
+
);
|
|
3153
3138
|
const metadata = new web3_js.PublicKey(id);
|
|
3154
3139
|
await this.applyCustomAfterInstructions(ixs, customInstructions, metadata);
|
|
3155
3140
|
const { tx, hash, context } = await solana.prepareTransaction(this.connection, ixs, invoker.publicKey);
|
|
@@ -3169,22 +3154,18 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3169
3154
|
/**
|
|
3170
3155
|
* Creates Transaction Instructions for withdrawal
|
|
3171
3156
|
* @param {IWithdrawData} withdrawData - Withdrawal parameters including stream ID and amount to withdraw
|
|
3172
|
-
* @param {
|
|
3157
|
+
* @param {IPrepareStreamSolanaExt} extParams - Transaction configuration including invoker wallet address, token account validation, and compute settings
|
|
3173
3158
|
* @returns Transaction instructions
|
|
3174
3159
|
*/
|
|
3175
3160
|
async prepareWithdrawInstructions({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
|
|
3176
|
-
|
|
3177
|
-
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3178
|
-
}
|
|
3161
|
+
common.assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3179
3162
|
const ixs = solana.prepareBaseInstructions(this.connection, {
|
|
3180
3163
|
computePrice,
|
|
3181
3164
|
computeLimit
|
|
3182
3165
|
});
|
|
3183
3166
|
const streamPublicKey = new web3_js.PublicKey(id);
|
|
3184
3167
|
const escrow = await this.connection.getAccountInfo(streamPublicKey);
|
|
3185
|
-
|
|
3186
|
-
throw new Error("Couldn't get account info");
|
|
3187
|
-
}
|
|
3168
|
+
common.invariant(escrow?.data, "Couldn't get account info");
|
|
3188
3169
|
const data = decodeStream(escrow.data);
|
|
3189
3170
|
const { sender, recipient, mint, streamflowTreasury, partner, recipientTokens, escrowTokens } = data;
|
|
3190
3171
|
const { tokenProgramId } = await solana.getMintAndProgram(this.connection, mint);
|
|
@@ -3240,7 +3221,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3240
3221
|
/**
|
|
3241
3222
|
* Creates Transaction Instructions for cancel
|
|
3242
3223
|
* @param {ICancelData} cancelData - Cancellation parameters including stream ID
|
|
3243
|
-
* @param {
|
|
3224
|
+
* @param {IPrepareStreamSolanaExt} extParams - Transaction configuration including invoker wallet address, token account validation, and compute settings
|
|
3244
3225
|
* @returns Transaction instructions
|
|
3245
3226
|
*/
|
|
3246
3227
|
async prepareCancelInstructions(cancelData, extParams) {
|
|
@@ -3257,18 +3238,14 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3257
3238
|
/**
|
|
3258
3239
|
* Creates Transaction Instructions for cancel
|
|
3259
3240
|
* @param {ICancelData} cancelData - Cancellation parameters including stream ID
|
|
3260
|
-
* @param {
|
|
3241
|
+
* @param {IPrepareStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
|
|
3261
3242
|
* @returns Transaction instructions
|
|
3262
3243
|
*/
|
|
3263
3244
|
async prepareCancelAlignedUnlockInstructions({ id }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
|
|
3264
|
-
|
|
3265
|
-
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3266
|
-
}
|
|
3245
|
+
common.assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3267
3246
|
const streamPublicKey = new web3_js.PublicKey(id);
|
|
3268
3247
|
const escrowAcc = await this.connection.getAccountInfo(streamPublicKey);
|
|
3269
|
-
|
|
3270
|
-
throw new Error("Couldn't get account info");
|
|
3271
|
-
}
|
|
3248
|
+
common.invariant(escrowAcc?.data, "Couldn't get account info");
|
|
3272
3249
|
const streamData = decodeStream(escrowAcc.data);
|
|
3273
3250
|
const { sender, recipient, mint, streamflowTreasury, partner, escrowTokens } = streamData;
|
|
3274
3251
|
const { tokenProgramId } = await solana.getMintAndProgram(this.connection, mint);
|
|
@@ -3300,18 +3277,14 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3300
3277
|
/**
|
|
3301
3278
|
* Creates Transaction Instructions for cancel
|
|
3302
3279
|
* @param {ICancelData} cancelData - Cancellation parameters including stream ID
|
|
3303
|
-
* @param {
|
|
3280
|
+
* @param {IPrepareStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
|
|
3304
3281
|
* @returns Transaction instructions
|
|
3305
3282
|
*/
|
|
3306
3283
|
async prepareCancelStreamInstructions({ id }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
|
|
3307
|
-
|
|
3308
|
-
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3309
|
-
}
|
|
3284
|
+
common.assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3310
3285
|
const streamPublicKey = new web3_js.PublicKey(id);
|
|
3311
3286
|
const escrowAcc = await this.connection.getAccountInfo(streamPublicKey);
|
|
3312
|
-
|
|
3313
|
-
throw new Error("Couldn't get account info");
|
|
3314
|
-
}
|
|
3287
|
+
common.invariant(escrowAcc?.data, "Couldn't get account info");
|
|
3315
3288
|
const data = decodeStream(escrowAcc.data);
|
|
3316
3289
|
const { sender, recipient, partner, streamflowTreasury, mint, senderTokens, recipientTokens, escrowTokens } = data;
|
|
3317
3290
|
const { tokenProgramId } = await solana.getMintAndProgram(this.connection, mint);
|
|
@@ -3375,13 +3348,11 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3375
3348
|
* Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
|
|
3376
3349
|
* Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
|
|
3377
3350
|
* @param {ITransferData} transferData - Transfer parameters including stream ID and new recipient address
|
|
3378
|
-
* @param {
|
|
3351
|
+
* @param {IPrepareStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
|
|
3379
3352
|
* @returns Transaction instructions
|
|
3380
3353
|
*/
|
|
3381
3354
|
async prepareTransferInstructions({ id, newRecipient }, { invoker, computePrice, computeLimit = 100001 }) {
|
|
3382
|
-
|
|
3383
|
-
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3384
|
-
}
|
|
3355
|
+
common.assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3385
3356
|
const ixs = solana.prepareBaseInstructions(this.connection, {
|
|
3386
3357
|
computePrice,
|
|
3387
3358
|
computeLimit
|
|
@@ -3389,9 +3360,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3389
3360
|
const stream = new web3_js.PublicKey(id);
|
|
3390
3361
|
const newRecipientPublicKey = new web3_js.PublicKey(newRecipient);
|
|
3391
3362
|
const escrow = await this.connection.getAccountInfo(stream);
|
|
3392
|
-
|
|
3393
|
-
throw new Error("Couldn't get account info");
|
|
3394
|
-
}
|
|
3363
|
+
common.invariant(escrow?.data, "Couldn't get account info");
|
|
3395
3364
|
const { mint } = decodeStream(escrow?.data);
|
|
3396
3365
|
const { tokenProgramId } = await solana.getMintAndProgram(this.connection, mint);
|
|
3397
3366
|
const newRecipientTokens = await solana.ata(mint, newRecipientPublicKey, tokenProgramId);
|
|
@@ -3627,6 +3596,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3627
3596
|
* @returns Transaction result
|
|
3628
3597
|
*/
|
|
3629
3598
|
async update(data, extParams) {
|
|
3599
|
+
if (!extParams.invoker.publicKey) {
|
|
3600
|
+
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3601
|
+
}
|
|
3630
3602
|
const ixs = await this.prepareUpdateInstructions(data, extParams);
|
|
3631
3603
|
const { tx, hash, context } = await solana.prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
|
|
3632
3604
|
const signature = await solana.signAndExecuteTransaction(
|
|
@@ -3648,18 +3620,14 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3648
3620
|
/**
|
|
3649
3621
|
* Create Transaction instructions for update
|
|
3650
3622
|
* @param {IUpdateData} data - Update parameters including stream ID and new settings
|
|
3651
|
-
* @param {
|
|
3623
|
+
* @param {IPrepareStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
|
|
3652
3624
|
* @returns Transaction instructions
|
|
3653
3625
|
*/
|
|
3654
3626
|
async prepareUpdateInstructions(data, { invoker, computePrice, computeLimit }) {
|
|
3655
|
-
|
|
3656
|
-
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3657
|
-
}
|
|
3627
|
+
common.assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3658
3628
|
const streamPublicKey = new web3_js.PublicKey(data.id);
|
|
3659
3629
|
const escrow = await this.connection.getAccountInfo(streamPublicKey);
|
|
3660
|
-
|
|
3661
|
-
throw new Error("Couldn't get account info");
|
|
3662
|
-
}
|
|
3630
|
+
common.invariant(escrow, "Couldn't get account info");
|
|
3663
3631
|
const ixs = solana.prepareBaseInstructions(this.connection, {
|
|
3664
3632
|
computePrice,
|
|
3665
3633
|
computeLimit
|