@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
package/dist/cjs/index.cjs
CHANGED
|
@@ -2664,7 +2664,7 @@ var SolanaStreamClient = class {
|
|
|
2664
2664
|
return { ixs, txId: signature, metadataId };
|
|
2665
2665
|
}
|
|
2666
2666
|
async prepareCreateInstructions(streamParams, extParams) {
|
|
2667
|
-
const { ixs, metadata, metadataPubKey } = isCreateAlignedStreamData(streamParams) ? await this.prepareCreateAlignedUnlockInstructions(streamParams, extParams) : await this.
|
|
2667
|
+
const { ixs, metadata, metadataPubKey } = isCreateAlignedStreamData(streamParams) ? await this.prepareCreateAlignedUnlockInstructions(streamParams, extParams) : await this.prepareCreateLinearStreamInstructions(streamParams, extParams);
|
|
2668
2668
|
return { ixs, metadata, metadataPubKey };
|
|
2669
2669
|
}
|
|
2670
2670
|
async prepareCreateAlignedUnlockInstructions(streamParams, extParams) {
|
|
@@ -2774,7 +2774,7 @@ var SolanaStreamClient = class {
|
|
|
2774
2774
|
* @param {IPrepareCreateStreamExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
|
|
2775
2775
|
* @returns Create stream instructions
|
|
2776
2776
|
*/
|
|
2777
|
-
async
|
|
2777
|
+
async prepareCreateLinearStreamInstructions({
|
|
2778
2778
|
recipient,
|
|
2779
2779
|
tokenId: mint,
|
|
2780
2780
|
start,
|
|
@@ -2995,14 +2995,13 @@ var SolanaStreamClient = class {
|
|
|
2995
2995
|
* @param {IPrepareCreateStreamExt} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
|
|
2996
2996
|
* @returns Create multiple transaction instructions
|
|
2997
2997
|
*/
|
|
2998
|
-
async buildCreateMultipleTransactionInstructions(data, extParams) {
|
|
2998
|
+
async buildCreateMultipleTransactionInstructions(data, extParams, applyCustomAfterInstructions = true) {
|
|
2999
2999
|
const { recipients, ...streamParams } = data;
|
|
3000
3000
|
const { sender, metadataPubKeys: metadataPubKeysExt, isNative, customInstructions } = extParams;
|
|
3001
3001
|
common.assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
|
|
3002
3002
|
const metadatas = [];
|
|
3003
3003
|
const metadataToRecipient = {};
|
|
3004
3004
|
const instructionsBatch = [];
|
|
3005
|
-
const metadataPubKeys = metadataPubKeysExt || [];
|
|
3006
3005
|
const partnerPublicKey = data.partner ? new web3_js.PublicKey(data.partner) : WITHDRAWOR_PUBLIC_KEY;
|
|
3007
3006
|
const mintPublicKey = new web3_js.PublicKey(data.tokenId);
|
|
3008
3007
|
if (recipients.length === 0) {
|
|
@@ -3012,14 +3011,16 @@ var SolanaStreamClient = class {
|
|
|
3012
3011
|
const recipientData = recipients[i];
|
|
3013
3012
|
const createStreamData = { ...streamParams, ...recipientData };
|
|
3014
3013
|
const createStreamExtParams = {
|
|
3015
|
-
|
|
3016
|
-
|
|
3014
|
+
...extParams,
|
|
3015
|
+
metadataPubKeys: metadataPubKeysExt?.[i] ? [metadataPubKeysExt[i]] : void 0
|
|
3017
3016
|
};
|
|
3018
3017
|
const { ixs, metadata, metadataPubKey } = await this.prepareCreateInstructions(
|
|
3019
3018
|
createStreamData,
|
|
3020
3019
|
createStreamExtParams
|
|
3021
3020
|
);
|
|
3022
|
-
|
|
3021
|
+
if (applyCustomAfterInstructions) {
|
|
3022
|
+
await this.applyCustomAfterInstructions(ixs, customInstructions, metadataPubKey);
|
|
3023
|
+
}
|
|
3023
3024
|
metadataToRecipient[metadataPubKey.toBase58()] = recipientData;
|
|
3024
3025
|
metadatas.push(metadataPubKey.toBase58());
|
|
3025
3026
|
instructionsBatch.push({
|
|
@@ -3067,9 +3068,9 @@ var SolanaStreamClient = class {
|
|
|
3067
3068
|
* @param {IPrepareCreateStreamExt} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
|
|
3068
3069
|
* @returns Multiple transaction information
|
|
3069
3070
|
*/
|
|
3070
|
-
async buildCreateMultipleTransactions(data, extParams) {
|
|
3071
|
+
async buildCreateMultipleTransactions(data, extParams, applyCustomAfterInstructions = true) {
|
|
3071
3072
|
const { sender } = extParams;
|
|
3072
|
-
const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, extParams);
|
|
3073
|
+
const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, extParams, applyCustomAfterInstructions);
|
|
3073
3074
|
const { value: hash, context } = await this.connection.getLatestBlockhashAndContext();
|
|
3074
3075
|
const batch = [];
|
|
3075
3076
|
for (const { ixs, metadata, recipient } of instructionsBatch) {
|
|
@@ -3100,7 +3101,7 @@ var SolanaStreamClient = class {
|
|
|
3100
3101
|
if (!sender.publicKey) {
|
|
3101
3102
|
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
|
|
3102
3103
|
}
|
|
3103
|
-
const { instructionsBatch, metadatas,
|
|
3104
|
+
const { instructionsBatch, metadatas, prepareInstructions, metadataToRecipient } = await this.flatBuildCreateMultipleTransactionInstructions(data, extParams);
|
|
3104
3105
|
const errors = [];
|
|
3105
3106
|
const signatures = [];
|
|
3106
3107
|
const metadataPubKeys = metadataPubKeysExt || [];
|
|
@@ -3165,7 +3166,7 @@ var SolanaStreamClient = class {
|
|
|
3165
3166
|
if (!sender.publicKey) {
|
|
3166
3167
|
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
|
|
3167
3168
|
}
|
|
3168
|
-
const { instructionsBatch, metadatas,
|
|
3169
|
+
const { instructionsBatch, metadatas, prepareInstructions, metadataToRecipient } = await this.flatBuildCreateMultipleTransactionInstructions(data, extParams);
|
|
3169
3170
|
const errors = [];
|
|
3170
3171
|
const signatures = [];
|
|
3171
3172
|
const batch = [];
|
|
@@ -3327,7 +3328,7 @@ var SolanaStreamClient = class {
|
|
|
3327
3328
|
}
|
|
3328
3329
|
const { sender: senderPublicKey } = decodeStream(account.data);
|
|
3329
3330
|
const isAlignedUnlock = this.isAlignedUnlock(streamPublicKey, senderPublicKey);
|
|
3330
|
-
const ixs = isAlignedUnlock ? await this.prepareCancelAlignedUnlockInstructions(cancelData, extParams) : await this.
|
|
3331
|
+
const ixs = isAlignedUnlock ? await this.prepareCancelAlignedUnlockInstructions(cancelData, extParams) : await this.prepareCancelLinearStream(cancelData, extParams);
|
|
3331
3332
|
return ixs;
|
|
3332
3333
|
}
|
|
3333
3334
|
/**
|
|
@@ -3375,7 +3376,7 @@ var SolanaStreamClient = class {
|
|
|
3375
3376
|
* @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
|
|
3376
3377
|
* @returns Transaction instructions
|
|
3377
3378
|
*/
|
|
3378
|
-
async
|
|
3379
|
+
async prepareCancelLinearStream({ id }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
|
|
3379
3380
|
common.assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3380
3381
|
const streamPublicKey = new web3_js.PublicKey(id);
|
|
3381
3382
|
const escrowAcc = await this.connection.getAccountInfo(streamPublicKey);
|
|
@@ -3788,11 +3789,11 @@ var SolanaStreamClient = class {
|
|
|
3788
3789
|
return DEFAULT_STREAMFLOW_FEE;
|
|
3789
3790
|
}
|
|
3790
3791
|
/**
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3792
|
+
* Returns total fee percent, streamflow fees + partner fees
|
|
3793
|
+
* @param getFeesData structure with address for which we need to derive fee, either sender or partner usually
|
|
3794
|
+
* @param chainSpecificParams additional parameters required by chain client
|
|
3795
|
+
* @returns fee as floating number, so if fee is 0.99%, it will return 0.99
|
|
3796
|
+
*/
|
|
3796
3797
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3797
3798
|
async getTotalFee(getFeesData) {
|
|
3798
3799
|
const fees = await this.getFees(getFeesData);
|
|
@@ -3817,6 +3818,21 @@ var SolanaStreamClient = class {
|
|
|
3817
3818
|
const pda = deriveContractPDA(this.alignedProxyProgram.programId, streamPublicKey);
|
|
3818
3819
|
return senderPublicKey.equals(pda);
|
|
3819
3820
|
}
|
|
3821
|
+
async flatBuildCreateMultipleTransactionInstructions(data, extParams) {
|
|
3822
|
+
const dataArray = Array.isArray(data) ? data : [data];
|
|
3823
|
+
const results = await Promise.all(
|
|
3824
|
+
dataArray.map((item, index) => this.buildCreateMultipleTransactionInstructions(item, extParams, index === 0))
|
|
3825
|
+
);
|
|
3826
|
+
return {
|
|
3827
|
+
instructionsBatch: results.flatMap((r) => r.instructionsBatch),
|
|
3828
|
+
metadatas: results.flatMap((r) => r.metadatas),
|
|
3829
|
+
prepareInstructions: results.flatMap((r) => r.prepareInstructions),
|
|
3830
|
+
metadataToRecipient: results.reduce(
|
|
3831
|
+
(acc, r) => Object.assign(acc, r.metadataToRecipient),
|
|
3832
|
+
{}
|
|
3833
|
+
)
|
|
3834
|
+
};
|
|
3835
|
+
}
|
|
3820
3836
|
/**
|
|
3821
3837
|
* Utility function to generate metadata for a Contract or return existing Pubkey
|
|
3822
3838
|
*/
|