@streamflow/stream 10.0.0-alpha.p313.4046054 → 10.0.0-alpha.p313.77ad1fe
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/dist/cjs/index.cjs +34 -18
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/solana/index.cjs +34 -18
- package/dist/cjs/solana/index.cjs.map +1 -1
- package/dist/cjs/solana/index.d.cts +12 -11
- package/dist/esm/index.js +34 -18
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/solana/index.d.ts +12 -11
- package/dist/esm/solana/index.js +34 -18
- package/dist/esm/solana/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -553,7 +553,7 @@ declare class SolanaStreamClient {
|
|
|
553
553
|
* @param {IPrepareCreateStreamExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
|
|
554
554
|
* @returns Create stream instructions
|
|
555
555
|
*/
|
|
556
|
-
|
|
556
|
+
prepareCreateLinearStreamInstructions({ recipient, tokenId: mint, start, amount: depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canPause, canUpdateRate, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, tokenProgramId: streamTokenProgramId, }: ICreateStreamData, { sender, metadataPubKeys, isNative, computePrice, computeLimit }: IPrepareCreateStreamExt): Promise<ICreateStreamInstructions>;
|
|
557
557
|
/**
|
|
558
558
|
* Creates a new stream/vesting contract using unchecked instruction.
|
|
559
559
|
*
|
|
@@ -583,7 +583,7 @@ declare class SolanaStreamClient {
|
|
|
583
583
|
* @param {IPrepareCreateStreamExt} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
|
|
584
584
|
* @returns Create multiple transaction instructions
|
|
585
585
|
*/
|
|
586
|
-
buildCreateMultipleTransactionInstructions(data: ICreateMultipleStreamData, extParams: IPrepareCreateStreamExt): Promise<{
|
|
586
|
+
buildCreateMultipleTransactionInstructions(data: ICreateMultipleStreamData, extParams: IPrepareCreateStreamExt, applyCustomAfterInstructions?: boolean): Promise<{
|
|
587
587
|
instructionsBatch: {
|
|
588
588
|
ixs: TransactionInstruction[];
|
|
589
589
|
metadata: Keypair | undefined;
|
|
@@ -619,7 +619,7 @@ declare class SolanaStreamClient {
|
|
|
619
619
|
* @param {IPrepareCreateStreamExt} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
|
|
620
620
|
* @returns Multiple transaction information
|
|
621
621
|
*/
|
|
622
|
-
buildCreateMultipleTransactions(data: ICreateMultipleStreamData, extParams: IPrepareCreateStreamExt): Promise<{
|
|
622
|
+
buildCreateMultipleTransactions(data: ICreateMultipleStreamData, extParams: IPrepareCreateStreamExt, applyCustomAfterInstructions?: boolean): Promise<{
|
|
623
623
|
transactions: BatchItem[];
|
|
624
624
|
metadatas: string[];
|
|
625
625
|
metadataToRecipient: MetadataRecipientHashMap;
|
|
@@ -637,7 +637,7 @@ declare class SolanaStreamClient {
|
|
|
637
637
|
* @param {ICreateStreamExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
|
|
638
638
|
* @returns Multiple transaction information
|
|
639
639
|
*/
|
|
640
|
-
createMultiple(data: ICreateMultipleStreamData, extParams: ICreateStreamExt): Promise<IMultiTransactionResult>;
|
|
640
|
+
createMultiple(data: ICreateMultipleStreamData[] | ICreateMultipleStreamData, extParams: ICreateStreamExt): Promise<IMultiTransactionResult>;
|
|
641
641
|
/**
|
|
642
642
|
* Creates multiple stream/vesting contracts, and send all transactions sequentially.
|
|
643
643
|
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
@@ -646,7 +646,7 @@ declare class SolanaStreamClient {
|
|
|
646
646
|
* @param {ICreateStreamExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
|
|
647
647
|
* @returns Multiple transaction information
|
|
648
648
|
*/
|
|
649
|
-
createMultipleSequential(data: ICreateMultipleStreamData, extParams: ICreateStreamExt): Promise<IMultiTransactionResult>;
|
|
649
|
+
createMultipleSequential(data: ICreateMultipleStreamData[] | ICreateMultipleStreamData, extParams: ICreateStreamExt): Promise<IMultiTransactionResult>;
|
|
650
650
|
/**
|
|
651
651
|
* Attempts withdrawing from the specified stream.
|
|
652
652
|
* @param {IWithdrawData} withdrawData - Withdrawal parameters including stream ID and amount to withdraw
|
|
@@ -688,7 +688,7 @@ declare class SolanaStreamClient {
|
|
|
688
688
|
* @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
|
|
689
689
|
* @returns Transaction instructions
|
|
690
690
|
*/
|
|
691
|
-
|
|
691
|
+
prepareCancelLinearStream({ id }: ICancelData, { invoker, checkTokenAccounts, computePrice, computeLimit }: IPrepareStreamExt): Promise<TransactionInstruction[]>;
|
|
692
692
|
/**
|
|
693
693
|
* Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
|
|
694
694
|
* Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
|
|
@@ -771,11 +771,11 @@ declare class SolanaStreamClient {
|
|
|
771
771
|
*/
|
|
772
772
|
getDefaultStreamflowFee(): Promise<number>;
|
|
773
773
|
/**
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
774
|
+
* Returns total fee percent, streamflow fees + partner fees
|
|
775
|
+
* @param getFeesData structure with address for which we need to derive fee, either sender or partner usually
|
|
776
|
+
* @param chainSpecificParams additional parameters required by chain client
|
|
777
|
+
* @returns fee as floating number, so if fee is 0.99%, it will return 0.99
|
|
778
|
+
*/
|
|
779
779
|
getTotalFee(getFeesData: IGetFeesData): Promise<number>;
|
|
780
780
|
/**
|
|
781
781
|
* Extracts error code from an error
|
|
@@ -787,6 +787,7 @@ declare class SolanaStreamClient {
|
|
|
787
787
|
* Utility function that checks whether the associated stream address is an aligned unlock contract, indicated by whether the sender/creator is a PDA
|
|
788
788
|
*/
|
|
789
789
|
isAlignedUnlock(streamPublicKey: PublicKey, senderPublicKey: PublicKey): boolean;
|
|
790
|
+
private flatBuildCreateMultipleTransactionInstructions;
|
|
790
791
|
/**
|
|
791
792
|
* Utility function to generate metadata for a Contract or return existing Pubkey
|
|
792
793
|
*/
|
package/dist/esm/solana/index.js
CHANGED
|
@@ -2638,7 +2638,7 @@ var SolanaStreamClient = class {
|
|
|
2638
2638
|
return { ixs, txId: signature, metadataId };
|
|
2639
2639
|
}
|
|
2640
2640
|
async prepareCreateInstructions(streamParams, extParams) {
|
|
2641
|
-
const { ixs, metadata, metadataPubKey } = isCreateAlignedStreamData(streamParams) ? await this.prepareCreateAlignedUnlockInstructions(streamParams, extParams) : await this.
|
|
2641
|
+
const { ixs, metadata, metadataPubKey } = isCreateAlignedStreamData(streamParams) ? await this.prepareCreateAlignedUnlockInstructions(streamParams, extParams) : await this.prepareCreateLinearStreamInstructions(streamParams, extParams);
|
|
2642
2642
|
return { ixs, metadata, metadataPubKey };
|
|
2643
2643
|
}
|
|
2644
2644
|
async prepareCreateAlignedUnlockInstructions(streamParams, extParams) {
|
|
@@ -2748,7 +2748,7 @@ var SolanaStreamClient = class {
|
|
|
2748
2748
|
* @param {IPrepareCreateStreamExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
|
|
2749
2749
|
* @returns Create stream instructions
|
|
2750
2750
|
*/
|
|
2751
|
-
async
|
|
2751
|
+
async prepareCreateLinearStreamInstructions({
|
|
2752
2752
|
recipient,
|
|
2753
2753
|
tokenId: mint,
|
|
2754
2754
|
start,
|
|
@@ -2969,14 +2969,13 @@ var SolanaStreamClient = class {
|
|
|
2969
2969
|
* @param {IPrepareCreateStreamExt} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
|
|
2970
2970
|
* @returns Create multiple transaction instructions
|
|
2971
2971
|
*/
|
|
2972
|
-
async buildCreateMultipleTransactionInstructions(data, extParams) {
|
|
2972
|
+
async buildCreateMultipleTransactionInstructions(data, extParams, applyCustomAfterInstructions = true) {
|
|
2973
2973
|
const { recipients, ...streamParams } = data;
|
|
2974
2974
|
const { sender, metadataPubKeys: metadataPubKeysExt, isNative, customInstructions } = extParams;
|
|
2975
2975
|
assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
|
|
2976
2976
|
const metadatas = [];
|
|
2977
2977
|
const metadataToRecipient = {};
|
|
2978
2978
|
const instructionsBatch = [];
|
|
2979
|
-
const metadataPubKeys = metadataPubKeysExt || [];
|
|
2980
2979
|
const partnerPublicKey = data.partner ? new PublicKey(data.partner) : WITHDRAWOR_PUBLIC_KEY;
|
|
2981
2980
|
const mintPublicKey = new PublicKey(data.tokenId);
|
|
2982
2981
|
if (recipients.length === 0) {
|
|
@@ -2986,14 +2985,16 @@ var SolanaStreamClient = class {
|
|
|
2986
2985
|
const recipientData = recipients[i];
|
|
2987
2986
|
const createStreamData = { ...streamParams, ...recipientData };
|
|
2988
2987
|
const createStreamExtParams = {
|
|
2989
|
-
|
|
2990
|
-
|
|
2988
|
+
...extParams,
|
|
2989
|
+
metadataPubKeys: metadataPubKeysExt?.[i] ? [metadataPubKeysExt[i]] : void 0
|
|
2991
2990
|
};
|
|
2992
2991
|
const { ixs, metadata, metadataPubKey } = await this.prepareCreateInstructions(
|
|
2993
2992
|
createStreamData,
|
|
2994
2993
|
createStreamExtParams
|
|
2995
2994
|
);
|
|
2996
|
-
|
|
2995
|
+
if (applyCustomAfterInstructions) {
|
|
2996
|
+
await this.applyCustomAfterInstructions(ixs, customInstructions, metadataPubKey);
|
|
2997
|
+
}
|
|
2997
2998
|
metadataToRecipient[metadataPubKey.toBase58()] = recipientData;
|
|
2998
2999
|
metadatas.push(metadataPubKey.toBase58());
|
|
2999
3000
|
instructionsBatch.push({
|
|
@@ -3041,9 +3042,9 @@ var SolanaStreamClient = class {
|
|
|
3041
3042
|
* @param {IPrepareCreateStreamExt} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
|
|
3042
3043
|
* @returns Multiple transaction information
|
|
3043
3044
|
*/
|
|
3044
|
-
async buildCreateMultipleTransactions(data, extParams) {
|
|
3045
|
+
async buildCreateMultipleTransactions(data, extParams, applyCustomAfterInstructions = true) {
|
|
3045
3046
|
const { sender } = extParams;
|
|
3046
|
-
const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, extParams);
|
|
3047
|
+
const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, extParams, applyCustomAfterInstructions);
|
|
3047
3048
|
const { value: hash, context } = await this.connection.getLatestBlockhashAndContext();
|
|
3048
3049
|
const batch = [];
|
|
3049
3050
|
for (const { ixs, metadata, recipient } of instructionsBatch) {
|
|
@@ -3074,7 +3075,7 @@ var SolanaStreamClient = class {
|
|
|
3074
3075
|
if (!sender.publicKey) {
|
|
3075
3076
|
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
|
|
3076
3077
|
}
|
|
3077
|
-
const { instructionsBatch, metadatas,
|
|
3078
|
+
const { instructionsBatch, metadatas, prepareInstructions, metadataToRecipient } = await this.flatBuildCreateMultipleTransactionInstructions(data, extParams);
|
|
3078
3079
|
const errors = [];
|
|
3079
3080
|
const signatures = [];
|
|
3080
3081
|
const metadataPubKeys = metadataPubKeysExt || [];
|
|
@@ -3139,7 +3140,7 @@ var SolanaStreamClient = class {
|
|
|
3139
3140
|
if (!sender.publicKey) {
|
|
3140
3141
|
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
|
|
3141
3142
|
}
|
|
3142
|
-
const { instructionsBatch, metadatas,
|
|
3143
|
+
const { instructionsBatch, metadatas, prepareInstructions, metadataToRecipient } = await this.flatBuildCreateMultipleTransactionInstructions(data, extParams);
|
|
3143
3144
|
const errors = [];
|
|
3144
3145
|
const signatures = [];
|
|
3145
3146
|
const batch = [];
|
|
@@ -3301,7 +3302,7 @@ var SolanaStreamClient = class {
|
|
|
3301
3302
|
}
|
|
3302
3303
|
const { sender: senderPublicKey } = decodeStream(account.data);
|
|
3303
3304
|
const isAlignedUnlock = this.isAlignedUnlock(streamPublicKey, senderPublicKey);
|
|
3304
|
-
const ixs = isAlignedUnlock ? await this.prepareCancelAlignedUnlockInstructions(cancelData, extParams) : await this.
|
|
3305
|
+
const ixs = isAlignedUnlock ? await this.prepareCancelAlignedUnlockInstructions(cancelData, extParams) : await this.prepareCancelLinearStream(cancelData, extParams);
|
|
3305
3306
|
return ixs;
|
|
3306
3307
|
}
|
|
3307
3308
|
/**
|
|
@@ -3349,7 +3350,7 @@ var SolanaStreamClient = class {
|
|
|
3349
3350
|
* @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
|
|
3350
3351
|
* @returns Transaction instructions
|
|
3351
3352
|
*/
|
|
3352
|
-
async
|
|
3353
|
+
async prepareCancelLinearStream({ id }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
|
|
3353
3354
|
assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3354
3355
|
const streamPublicKey = new PublicKey(id);
|
|
3355
3356
|
const escrowAcc = await this.connection.getAccountInfo(streamPublicKey);
|
|
@@ -3762,11 +3763,11 @@ var SolanaStreamClient = class {
|
|
|
3762
3763
|
return DEFAULT_STREAMFLOW_FEE;
|
|
3763
3764
|
}
|
|
3764
3765
|
/**
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3766
|
+
* Returns total fee percent, streamflow fees + partner fees
|
|
3767
|
+
* @param getFeesData structure with address for which we need to derive fee, either sender or partner usually
|
|
3768
|
+
* @param chainSpecificParams additional parameters required by chain client
|
|
3769
|
+
* @returns fee as floating number, so if fee is 0.99%, it will return 0.99
|
|
3770
|
+
*/
|
|
3770
3771
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3771
3772
|
async getTotalFee(getFeesData) {
|
|
3772
3773
|
const fees = await this.getFees(getFeesData);
|
|
@@ -3791,6 +3792,21 @@ var SolanaStreamClient = class {
|
|
|
3791
3792
|
const pda = deriveContractPDA(this.alignedProxyProgram.programId, streamPublicKey);
|
|
3792
3793
|
return senderPublicKey.equals(pda);
|
|
3793
3794
|
}
|
|
3795
|
+
async flatBuildCreateMultipleTransactionInstructions(data, extParams) {
|
|
3796
|
+
const dataArray = Array.isArray(data) ? data : [data];
|
|
3797
|
+
const results = await Promise.all(
|
|
3798
|
+
dataArray.map((item, index) => this.buildCreateMultipleTransactionInstructions(item, extParams, index === 0))
|
|
3799
|
+
);
|
|
3800
|
+
return {
|
|
3801
|
+
instructionsBatch: results.flatMap((r) => r.instructionsBatch),
|
|
3802
|
+
metadatas: results.flatMap((r) => r.metadatas),
|
|
3803
|
+
prepareInstructions: results.flatMap((r) => r.prepareInstructions),
|
|
3804
|
+
metadataToRecipient: results.reduce(
|
|
3805
|
+
(acc, r) => Object.assign(acc, r.metadataToRecipient),
|
|
3806
|
+
{}
|
|
3807
|
+
)
|
|
3808
|
+
};
|
|
3809
|
+
}
|
|
3794
3810
|
/**
|
|
3795
3811
|
* Utility function to generate metadata for a Contract or return existing Pubkey
|
|
3796
3812
|
*/
|