@streamflow/stream 8.8.0 → 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 +60 -90
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +2 -2
- package/dist/cjs/solana/index.cjs +60 -90
- 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 +61 -91
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/solana/index.d.ts +1 -1
- package/dist/esm/solana/index.js +61 -91
- 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,9 +2610,11 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2618
2610
|
computePrice,
|
|
2619
2611
|
computeLimit: computeLimit ?? ALIGNED_COMPUTE_LIMIT
|
|
2620
2612
|
});
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2613
|
+
if (recipientPublicKey.toString() !== sender.toString() || !isNative) {
|
|
2614
|
+
ixs.push(
|
|
2615
|
+
...await this.getCreateATAInstructions([recipientPublicKey], mintPublicKey, sender, true, tokenProgramId)
|
|
2616
|
+
);
|
|
2617
|
+
}
|
|
2624
2618
|
const encodedUIntArray = new TextEncoder().encode(streamName);
|
|
2625
2619
|
const streamNameArray = Array.from(encodedUIntArray);
|
|
2626
2620
|
const createIx = await this.alignedProxyProgram.methods.create({
|
|
@@ -2667,7 +2661,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2667
2661
|
* Creates a new stream/vesting contract.
|
|
2668
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).
|
|
2669
2663
|
* @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
|
|
2670
|
-
* @param {
|
|
2664
|
+
* @param {IPrepareCreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
|
|
2671
2665
|
* @returns Create stream instructions
|
|
2672
2666
|
*/
|
|
2673
2667
|
async prepareCreateStreamInstructions({
|
|
@@ -2692,9 +2686,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2692
2686
|
partner,
|
|
2693
2687
|
tokenProgramId: streamTokenProgramId
|
|
2694
2688
|
}, { sender, metadataPubKeys, isNative = false, computePrice, computeLimit }) {
|
|
2695
|
-
|
|
2696
|
-
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
|
|
2697
|
-
}
|
|
2689
|
+
common.assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
|
|
2698
2690
|
const ixs = solana.prepareBaseInstructions(this.connection, {
|
|
2699
2691
|
computePrice,
|
|
2700
2692
|
computeLimit
|
|
@@ -2774,7 +2766,10 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2774
2766
|
* @returns Create result
|
|
2775
2767
|
*/
|
|
2776
2768
|
async createUnchecked(data, extParams) {
|
|
2777
|
-
const { ixs, metadata, metadataPubKey } = await this.prepareCreateUncheckedInstructions(
|
|
2769
|
+
const { ixs, metadata, metadataPubKey } = await this.prepareCreateUncheckedInstructions(
|
|
2770
|
+
data,
|
|
2771
|
+
extParams
|
|
2772
|
+
);
|
|
2778
2773
|
const { tx, hash, context } = await solana.prepareTransaction(
|
|
2779
2774
|
this.connection,
|
|
2780
2775
|
ixs,
|
|
@@ -2819,9 +2814,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2819
2814
|
withdrawalFrequency = 0,
|
|
2820
2815
|
partner
|
|
2821
2816
|
}, { sender, metadataPubKeys, isNative = false, computePrice, computeLimit }) {
|
|
2822
|
-
|
|
2823
|
-
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
|
|
2824
|
-
}
|
|
2817
|
+
common.assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
|
|
2825
2818
|
const mintPublicKey = new web3_js.PublicKey(mint);
|
|
2826
2819
|
const recipientPublicKey = new web3_js.PublicKey(recipient);
|
|
2827
2820
|
const { metadata, metadataPubKey } = this.getOrCreateStreamMetadata(metadataPubKeys);
|
|
@@ -2830,7 +2823,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2830
2823
|
programId: this.programId,
|
|
2831
2824
|
space: METADATA_ACC_SIZE,
|
|
2832
2825
|
lamports: rentToExempt,
|
|
2833
|
-
fromPubkey: sender
|
|
2826
|
+
fromPubkey: sender.publicKey,
|
|
2834
2827
|
newAccountPubkey: metadataPubKey
|
|
2835
2828
|
});
|
|
2836
2829
|
const [escrowTokens] = web3_js.PublicKey.findProgramAddressSync(
|
|
@@ -2892,12 +2885,13 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2892
2885
|
* Builds transaction instructions for creating multiple stream/vesting contracts without creating transactions.
|
|
2893
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).
|
|
2894
2887
|
* @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
|
|
2895
|
-
* @param {
|
|
2888
|
+
* @param {IPrepareCreateStreamSolanaExt} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
|
|
2896
2889
|
* @returns Create multiple transaction instructions
|
|
2897
2890
|
*/
|
|
2898
2891
|
async buildCreateMultipleTransactionInstructions(data, extParams) {
|
|
2899
2892
|
const { recipients, ...streamParams } = data;
|
|
2900
|
-
const {
|
|
2893
|
+
const { sender, metadataPubKeys: metadataPubKeysExt, isNative, customInstructions } = extParams;
|
|
2894
|
+
common.assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
|
|
2901
2895
|
const metadatas = [];
|
|
2902
2896
|
const metadataToRecipient = {};
|
|
2903
2897
|
const instructionsBatch = [];
|
|
@@ -2907,12 +2901,10 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2907
2901
|
if (recipients.length === 0) {
|
|
2908
2902
|
throw new Error("Recipients array is empty!");
|
|
2909
2903
|
}
|
|
2910
|
-
const tempSender = { publicKey: senderPublicKey };
|
|
2911
2904
|
for (let i = 0; i < recipients.length; i++) {
|
|
2912
2905
|
const recipientData = recipients[i];
|
|
2913
2906
|
const createStreamData = { ...streamParams, ...recipientData };
|
|
2914
2907
|
const createStreamExtParams = {
|
|
2915
|
-
sender: tempSender,
|
|
2916
2908
|
metadataPubKeys: metadataPubKeys[i] ? [metadataPubKeys[i]] : void 0,
|
|
2917
2909
|
...extParams
|
|
2918
2910
|
};
|
|
@@ -2932,14 +2924,14 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2932
2924
|
const prepareInstructions = await this.getCreateATAInstructions(
|
|
2933
2925
|
[partnerPublicKey],
|
|
2934
2926
|
mintPublicKey,
|
|
2935
|
-
|
|
2927
|
+
sender,
|
|
2936
2928
|
true
|
|
2937
2929
|
);
|
|
2938
2930
|
if (isNative) {
|
|
2939
2931
|
const totalDepositedAmount = recipients.reduce((acc, recipient) => recipient.amount.add(acc), new BN4__default.default(0));
|
|
2940
2932
|
const nativeInstructions = await solana.prepareWrappedAccount(
|
|
2941
2933
|
this.connection,
|
|
2942
|
-
|
|
2934
|
+
sender.publicKey,
|
|
2943
2935
|
totalDepositedAmount
|
|
2944
2936
|
);
|
|
2945
2937
|
prepareInstructions.push(...nativeInstructions);
|
|
@@ -2974,20 +2966,20 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2974
2966
|
* ```
|
|
2975
2967
|
*
|
|
2976
2968
|
* @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
|
|
2977
|
-
* @param {
|
|
2969
|
+
* @param {IPrepareCreateStreamSolanaExt} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
|
|
2978
2970
|
* @returns Multiple transaction information
|
|
2979
2971
|
*/
|
|
2980
2972
|
async buildCreateMultipleTransactions(data, extParams) {
|
|
2981
|
-
const {
|
|
2973
|
+
const { sender } = extParams;
|
|
2982
2974
|
const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, extParams);
|
|
2983
2975
|
const { value: hash, context } = await this.connection.getLatestBlockhashAndContext();
|
|
2984
2976
|
const batch = [];
|
|
2985
2977
|
for (const { ixs, metadata, recipient } of instructionsBatch) {
|
|
2986
|
-
batch.push({ tx: solana.createVersionedTransaction(ixs,
|
|
2978
|
+
batch.push({ tx: solana.createVersionedTransaction(ixs, sender.publicKey, hash.blockhash, [metadata]), recipient });
|
|
2987
2979
|
}
|
|
2988
2980
|
let prepareTx;
|
|
2989
2981
|
if (prepareInstructions.length > 0) {
|
|
2990
|
-
prepareTx = solana.createVersionedTransaction(prepareInstructions,
|
|
2982
|
+
prepareTx = solana.createVersionedTransaction(prepareInstructions, sender.publicKey, hash.blockhash);
|
|
2991
2983
|
}
|
|
2992
2984
|
return {
|
|
2993
2985
|
transactions: batch,
|
|
@@ -3010,10 +3002,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3010
3002
|
if (!sender.publicKey) {
|
|
3011
3003
|
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
|
|
3012
3004
|
}
|
|
3013
|
-
const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data,
|
|
3014
|
-
...extParams,
|
|
3015
|
-
senderPublicKey: sender.publicKey
|
|
3016
|
-
});
|
|
3005
|
+
const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, extParams);
|
|
3017
3006
|
const errors = [];
|
|
3018
3007
|
const signatures = [];
|
|
3019
3008
|
const metadataPubKeys = metadataPubKeysExt || [];
|
|
@@ -3078,10 +3067,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3078
3067
|
if (!sender.publicKey) {
|
|
3079
3068
|
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
|
|
3080
3069
|
}
|
|
3081
|
-
const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data,
|
|
3082
|
-
...extParams,
|
|
3083
|
-
senderPublicKey: sender.publicKey
|
|
3084
|
-
});
|
|
3070
|
+
const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, extParams);
|
|
3085
3071
|
const errors = [];
|
|
3086
3072
|
const signatures = [];
|
|
3087
3073
|
const batch = [];
|
|
@@ -3144,10 +3130,11 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3144
3130
|
*/
|
|
3145
3131
|
async withdraw({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, extParams) {
|
|
3146
3132
|
const { invoker, customInstructions } = extParams;
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
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
|
+
);
|
|
3151
3138
|
const metadata = new web3_js.PublicKey(id);
|
|
3152
3139
|
await this.applyCustomAfterInstructions(ixs, customInstructions, metadata);
|
|
3153
3140
|
const { tx, hash, context } = await solana.prepareTransaction(this.connection, ixs, invoker.publicKey);
|
|
@@ -3167,22 +3154,18 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3167
3154
|
/**
|
|
3168
3155
|
* Creates Transaction Instructions for withdrawal
|
|
3169
3156
|
* @param {IWithdrawData} withdrawData - Withdrawal parameters including stream ID and amount to withdraw
|
|
3170
|
-
* @param {
|
|
3157
|
+
* @param {IPrepareStreamSolanaExt} extParams - Transaction configuration including invoker wallet address, token account validation, and compute settings
|
|
3171
3158
|
* @returns Transaction instructions
|
|
3172
3159
|
*/
|
|
3173
3160
|
async prepareWithdrawInstructions({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
|
|
3174
|
-
|
|
3175
|
-
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3176
|
-
}
|
|
3161
|
+
common.assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3177
3162
|
const ixs = solana.prepareBaseInstructions(this.connection, {
|
|
3178
3163
|
computePrice,
|
|
3179
3164
|
computeLimit
|
|
3180
3165
|
});
|
|
3181
3166
|
const streamPublicKey = new web3_js.PublicKey(id);
|
|
3182
3167
|
const escrow = await this.connection.getAccountInfo(streamPublicKey);
|
|
3183
|
-
|
|
3184
|
-
throw new Error("Couldn't get account info");
|
|
3185
|
-
}
|
|
3168
|
+
common.invariant(escrow?.data, "Couldn't get account info");
|
|
3186
3169
|
const data = decodeStream(escrow.data);
|
|
3187
3170
|
const { sender, recipient, mint, streamflowTreasury, partner, recipientTokens, escrowTokens } = data;
|
|
3188
3171
|
const { tokenProgramId } = await solana.getMintAndProgram(this.connection, mint);
|
|
@@ -3238,7 +3221,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3238
3221
|
/**
|
|
3239
3222
|
* Creates Transaction Instructions for cancel
|
|
3240
3223
|
* @param {ICancelData} cancelData - Cancellation parameters including stream ID
|
|
3241
|
-
* @param {
|
|
3224
|
+
* @param {IPrepareStreamSolanaExt} extParams - Transaction configuration including invoker wallet address, token account validation, and compute settings
|
|
3242
3225
|
* @returns Transaction instructions
|
|
3243
3226
|
*/
|
|
3244
3227
|
async prepareCancelInstructions(cancelData, extParams) {
|
|
@@ -3255,18 +3238,14 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3255
3238
|
/**
|
|
3256
3239
|
* Creates Transaction Instructions for cancel
|
|
3257
3240
|
* @param {ICancelData} cancelData - Cancellation parameters including stream ID
|
|
3258
|
-
* @param {
|
|
3241
|
+
* @param {IPrepareStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
|
|
3259
3242
|
* @returns Transaction instructions
|
|
3260
3243
|
*/
|
|
3261
3244
|
async prepareCancelAlignedUnlockInstructions({ id }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
|
|
3262
|
-
|
|
3263
|
-
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3264
|
-
}
|
|
3245
|
+
common.assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3265
3246
|
const streamPublicKey = new web3_js.PublicKey(id);
|
|
3266
3247
|
const escrowAcc = await this.connection.getAccountInfo(streamPublicKey);
|
|
3267
|
-
|
|
3268
|
-
throw new Error("Couldn't get account info");
|
|
3269
|
-
}
|
|
3248
|
+
common.invariant(escrowAcc?.data, "Couldn't get account info");
|
|
3270
3249
|
const streamData = decodeStream(escrowAcc.data);
|
|
3271
3250
|
const { sender, recipient, mint, streamflowTreasury, partner, escrowTokens } = streamData;
|
|
3272
3251
|
const { tokenProgramId } = await solana.getMintAndProgram(this.connection, mint);
|
|
@@ -3298,18 +3277,14 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3298
3277
|
/**
|
|
3299
3278
|
* Creates Transaction Instructions for cancel
|
|
3300
3279
|
* @param {ICancelData} cancelData - Cancellation parameters including stream ID
|
|
3301
|
-
* @param {
|
|
3280
|
+
* @param {IPrepareStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
|
|
3302
3281
|
* @returns Transaction instructions
|
|
3303
3282
|
*/
|
|
3304
3283
|
async prepareCancelStreamInstructions({ id }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
|
|
3305
|
-
|
|
3306
|
-
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3307
|
-
}
|
|
3284
|
+
common.assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3308
3285
|
const streamPublicKey = new web3_js.PublicKey(id);
|
|
3309
3286
|
const escrowAcc = await this.connection.getAccountInfo(streamPublicKey);
|
|
3310
|
-
|
|
3311
|
-
throw new Error("Couldn't get account info");
|
|
3312
|
-
}
|
|
3287
|
+
common.invariant(escrowAcc?.data, "Couldn't get account info");
|
|
3313
3288
|
const data = decodeStream(escrowAcc.data);
|
|
3314
3289
|
const { sender, recipient, partner, streamflowTreasury, mint, senderTokens, recipientTokens, escrowTokens } = data;
|
|
3315
3290
|
const { tokenProgramId } = await solana.getMintAndProgram(this.connection, mint);
|
|
@@ -3373,13 +3348,11 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3373
3348
|
* Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
|
|
3374
3349
|
* Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
|
|
3375
3350
|
* @param {ITransferData} transferData - Transfer parameters including stream ID and new recipient address
|
|
3376
|
-
* @param {
|
|
3351
|
+
* @param {IPrepareStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
|
|
3377
3352
|
* @returns Transaction instructions
|
|
3378
3353
|
*/
|
|
3379
3354
|
async prepareTransferInstructions({ id, newRecipient }, { invoker, computePrice, computeLimit = 100001 }) {
|
|
3380
|
-
|
|
3381
|
-
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3382
|
-
}
|
|
3355
|
+
common.assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3383
3356
|
const ixs = solana.prepareBaseInstructions(this.connection, {
|
|
3384
3357
|
computePrice,
|
|
3385
3358
|
computeLimit
|
|
@@ -3387,9 +3360,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3387
3360
|
const stream = new web3_js.PublicKey(id);
|
|
3388
3361
|
const newRecipientPublicKey = new web3_js.PublicKey(newRecipient);
|
|
3389
3362
|
const escrow = await this.connection.getAccountInfo(stream);
|
|
3390
|
-
|
|
3391
|
-
throw new Error("Couldn't get account info");
|
|
3392
|
-
}
|
|
3363
|
+
common.invariant(escrow?.data, "Couldn't get account info");
|
|
3393
3364
|
const { mint } = decodeStream(escrow?.data);
|
|
3394
3365
|
const { tokenProgramId } = await solana.getMintAndProgram(this.connection, mint);
|
|
3395
3366
|
const newRecipientTokens = await solana.ata(mint, newRecipientPublicKey, tokenProgramId);
|
|
@@ -3625,6 +3596,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3625
3596
|
* @returns Transaction result
|
|
3626
3597
|
*/
|
|
3627
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
|
+
}
|
|
3628
3602
|
const ixs = await this.prepareUpdateInstructions(data, extParams);
|
|
3629
3603
|
const { tx, hash, context } = await solana.prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
|
|
3630
3604
|
const signature = await solana.signAndExecuteTransaction(
|
|
@@ -3646,18 +3620,14 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3646
3620
|
/**
|
|
3647
3621
|
* Create Transaction instructions for update
|
|
3648
3622
|
* @param {IUpdateData} data - Update parameters including stream ID and new settings
|
|
3649
|
-
* @param {
|
|
3623
|
+
* @param {IPrepareStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
|
|
3650
3624
|
* @returns Transaction instructions
|
|
3651
3625
|
*/
|
|
3652
3626
|
async prepareUpdateInstructions(data, { invoker, computePrice, computeLimit }) {
|
|
3653
|
-
|
|
3654
|
-
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3655
|
-
}
|
|
3627
|
+
common.assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3656
3628
|
const streamPublicKey = new web3_js.PublicKey(data.id);
|
|
3657
3629
|
const escrow = await this.connection.getAccountInfo(streamPublicKey);
|
|
3658
|
-
|
|
3659
|
-
throw new Error("Couldn't get account info");
|
|
3660
|
-
}
|
|
3630
|
+
common.invariant(escrow, "Couldn't get account info");
|
|
3661
3631
|
const ixs = solana.prepareBaseInstructions(this.connection, {
|
|
3662
3632
|
computePrice,
|
|
3663
3633
|
computeLimit
|