@streamflow/stream 8.6.0 → 8.7.0-alpha.p304.6732440
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-BAZFUaQL.d.cts → index-Bll7jg8V.d.cts} +179 -1
- package/dist/cjs/index.cjs +248 -93
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +2 -2
- package/dist/cjs/solana/index.cjs +248 -93
- package/dist/cjs/solana/index.cjs.map +1 -1
- package/dist/cjs/solana/index.d.cts +1 -1
- package/dist/esm/{index-DKkJbavt.d.ts → index-D-w3ZCyC.d.ts} +179 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +248 -93
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/solana/index.d.ts +1 -1
- package/dist/esm/solana/index.js +248 -93
- package/dist/esm/solana/index.js.map +1 -1
- package/package.json +4 -4
package/dist/esm/index.js
CHANGED
|
@@ -5023,40 +5023,99 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5023
5023
|
return this.programId.toBase58();
|
|
5024
5024
|
}
|
|
5025
5025
|
/**
|
|
5026
|
-
*
|
|
5026
|
+
* Builds transaction instructions for creating a new stream/vesting contract without creating a transaction.
|
|
5027
5027
|
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
5028
|
+
*
|
|
5029
|
+
* For native SOL (isNative: true), SOL wrapping instructions are automatically included in the correct order
|
|
5030
|
+
* (before stream creation) to ensure the WSOL account exists when the stream creation instruction executes.
|
|
5031
|
+
*
|
|
5032
|
+
* @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
|
|
5033
|
+
* @param {Omit<ICreateStreamSolanaExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
|
|
5034
|
+
* @returns Transaction instructions and metadata ID
|
|
5028
5035
|
*/
|
|
5029
|
-
async
|
|
5036
|
+
async buildCreateTransactionInstructions(data, extParams) {
|
|
5030
5037
|
const { partner, amount, tokenProgramId } = data;
|
|
5031
|
-
const { isNative,
|
|
5038
|
+
const { isNative, senderPublicKey, customInstructions } = extParams;
|
|
5032
5039
|
const partnerPublicKey = partner ? new PublicKey(partner) : WITHDRAWOR_PUBLIC_KEY;
|
|
5033
5040
|
const mintPublicKey = new PublicKey(data.tokenId);
|
|
5034
|
-
|
|
5035
|
-
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
|
|
5036
|
-
}
|
|
5041
|
+
const tempSender = { publicKey: senderPublicKey };
|
|
5037
5042
|
const ixs = await this.getCreateATAInstructions(
|
|
5038
5043
|
[partnerPublicKey],
|
|
5039
5044
|
mintPublicKey,
|
|
5040
|
-
|
|
5045
|
+
tempSender,
|
|
5041
5046
|
true,
|
|
5042
5047
|
tokenProgramId ? new PublicKey(tokenProgramId) : void 0
|
|
5043
5048
|
);
|
|
5044
|
-
const { ixs: createIxs, metadata, metadataPubKey } = await this.prepareCreateInstructions(data, extParams);
|
|
5045
|
-
ixs.push(...createIxs);
|
|
5046
5049
|
if (isNative) {
|
|
5047
5050
|
const totalFee = await this.getTotalFee({
|
|
5048
5051
|
address: partnerPublicKey.toString()
|
|
5049
5052
|
});
|
|
5050
5053
|
const totalAmount = calculateTotalAmountToDeposit(amount, totalFee);
|
|
5051
|
-
ixs.push(...await prepareWrappedAccount(this.connection,
|
|
5054
|
+
ixs.push(...await prepareWrappedAccount(this.connection, tempSender.publicKey, totalAmount));
|
|
5052
5055
|
}
|
|
5056
|
+
const {
|
|
5057
|
+
ixs: createIxs,
|
|
5058
|
+
metadata,
|
|
5059
|
+
metadataPubKey
|
|
5060
|
+
} = await this.prepareCreateInstructions(data, {
|
|
5061
|
+
...extParams,
|
|
5062
|
+
sender: tempSender
|
|
5063
|
+
});
|
|
5064
|
+
ixs.push(...createIxs);
|
|
5053
5065
|
await this.applyCustomAfterInstructions(ixs, customInstructions, metadataPubKey);
|
|
5066
|
+
return {
|
|
5067
|
+
ixs,
|
|
5068
|
+
metadataId: metadataPubKey.toBase58(),
|
|
5069
|
+
metadata
|
|
5070
|
+
};
|
|
5071
|
+
}
|
|
5072
|
+
/**
|
|
5073
|
+
* Builds a transaction for creating a new stream/vesting contract without signing or executing it.
|
|
5074
|
+
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
5075
|
+
*
|
|
5076
|
+
* For native SOL (isNative: true), SOL wrapping instructions are automatically included in the correct order
|
|
5077
|
+
* (before stream creation) to ensure the WSOL account exists when the stream creation instruction executes.
|
|
5078
|
+
*
|
|
5079
|
+
* @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
|
|
5080
|
+
* @param {Omit<ICreateStreamSolanaExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
|
|
5081
|
+
* @returns Transaction and metadata information
|
|
5082
|
+
*/
|
|
5083
|
+
async buildCreateTransaction(data, extParams) {
|
|
5084
|
+
const { senderPublicKey } = extParams;
|
|
5085
|
+
const { ixs, metadataId, metadata } = await this.buildCreateTransactionInstructions(data, extParams);
|
|
5086
|
+
const { tx, hash, context } = await prepareTransaction(this.connection, ixs, senderPublicKey, void 0, [
|
|
5087
|
+
metadata
|
|
5088
|
+
]);
|
|
5089
|
+
return {
|
|
5090
|
+
tx,
|
|
5091
|
+
metadataId,
|
|
5092
|
+
metadata,
|
|
5093
|
+
hash: hash.blockhash,
|
|
5094
|
+
context
|
|
5095
|
+
};
|
|
5096
|
+
}
|
|
5097
|
+
/**
|
|
5098
|
+
* Creates a new stream/vesting contract.
|
|
5099
|
+
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
5100
|
+
* @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
|
|
5101
|
+
* @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, native token handling, and compute settings
|
|
5102
|
+
* @returns Create result
|
|
5103
|
+
*/
|
|
5104
|
+
async create(data, extParams) {
|
|
5105
|
+
const { sender } = extParams;
|
|
5106
|
+
if (!sender.publicKey) {
|
|
5107
|
+
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
|
|
5108
|
+
}
|
|
5109
|
+
const { ixs, metadataId, metadata } = await this.buildCreateTransactionInstructions(data, {
|
|
5110
|
+
...extParams,
|
|
5111
|
+
senderPublicKey: sender.publicKey
|
|
5112
|
+
});
|
|
5054
5113
|
const { tx, hash, context } = await prepareTransaction(this.connection, ixs, sender.publicKey, void 0, [
|
|
5055
5114
|
metadata
|
|
5056
5115
|
]);
|
|
5057
5116
|
const signature = await signAndExecuteTransaction(
|
|
5058
5117
|
this.connection,
|
|
5059
|
-
|
|
5118
|
+
sender,
|
|
5060
5119
|
tx,
|
|
5061
5120
|
{
|
|
5062
5121
|
hash,
|
|
@@ -5065,7 +5124,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5065
5124
|
},
|
|
5066
5125
|
this.schedulingParams
|
|
5067
5126
|
);
|
|
5068
|
-
return { ixs, txId: signature, metadataId
|
|
5127
|
+
return { ixs, txId: signature, metadataId };
|
|
5069
5128
|
}
|
|
5070
5129
|
async prepareCreateInstructions(streamParams, extParams) {
|
|
5071
5130
|
const { ixs, metadata, metadataPubKey } = isCreateAlignedStreamData(streamParams) ? await this.prepareCreateAlignedUnlockInstructions(streamParams, extParams) : await this.prepareCreateStreamInstructions(streamParams, extParams);
|
|
@@ -5175,6 +5234,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5175
5234
|
/**
|
|
5176
5235
|
* Creates a new stream/vesting contract.
|
|
5177
5236
|
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
5237
|
+
* @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
|
|
5238
|
+
* @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
|
|
5239
|
+
* @returns Create stream instructions
|
|
5178
5240
|
*/
|
|
5179
5241
|
async prepareCreateStreamInstructions({
|
|
5180
5242
|
recipient,
|
|
@@ -5275,6 +5337,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5275
5337
|
* - initialized contract PDA off chain
|
|
5276
5338
|
*
|
|
5277
5339
|
* If you are not sure if you should use create or create_unchecked, go for create to be safer.
|
|
5340
|
+
* @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
|
|
5341
|
+
* @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
|
|
5342
|
+
* @returns Create result
|
|
5278
5343
|
*/
|
|
5279
5344
|
async createUnchecked(data, extParams) {
|
|
5280
5345
|
const { ixs, metadata, metadataPubKey } = await this.prepareCreateUncheckedInstructions(data, extParams);
|
|
@@ -5392,24 +5457,17 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5392
5457
|
return { ixs, metadata, metadataPubKey };
|
|
5393
5458
|
}
|
|
5394
5459
|
/**
|
|
5395
|
-
*
|
|
5460
|
+
* Builds transaction instructions for creating multiple stream/vesting contracts without creating transactions.
|
|
5396
5461
|
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
5462
|
+
* @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
|
|
5463
|
+
* @param {Omit<ICreateStreamSolanaExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
|
|
5464
|
+
* @returns Create multiple transaction instructions
|
|
5397
5465
|
*/
|
|
5398
|
-
async
|
|
5466
|
+
async buildCreateMultipleTransactionInstructions(data, extParams) {
|
|
5399
5467
|
const { recipients, ...streamParams } = data;
|
|
5400
|
-
const {
|
|
5401
|
-
sender,
|
|
5402
|
-
metadataPubKeys: metadataPubKeysExt,
|
|
5403
|
-
isNative,
|
|
5404
|
-
computePrice,
|
|
5405
|
-
computeLimit,
|
|
5406
|
-
customInstructions
|
|
5407
|
-
} = extParams;
|
|
5468
|
+
const { senderPublicKey, metadataPubKeys: metadataPubKeysExt, isNative, customInstructions } = extParams;
|
|
5408
5469
|
const metadatas = [];
|
|
5409
5470
|
const metadataToRecipient = {};
|
|
5410
|
-
const errors = [];
|
|
5411
|
-
const signatures = [];
|
|
5412
|
-
const batch = [];
|
|
5413
5471
|
const instructionsBatch = [];
|
|
5414
5472
|
const metadataPubKeys = metadataPubKeysExt || [];
|
|
5415
5473
|
const partnerPublicKey = data.partner ? new PublicKey(data.partner) : WITHDRAWOR_PUBLIC_KEY;
|
|
@@ -5417,18 +5475,14 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5417
5475
|
if (recipients.length === 0) {
|
|
5418
5476
|
throw new Error("Recipients array is empty!");
|
|
5419
5477
|
}
|
|
5420
|
-
|
|
5421
|
-
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
|
|
5422
|
-
}
|
|
5478
|
+
const tempSender = { publicKey: senderPublicKey };
|
|
5423
5479
|
for (let i = 0; i < recipients.length; i++) {
|
|
5424
5480
|
const recipientData = recipients[i];
|
|
5425
5481
|
const createStreamData = { ...streamParams, ...recipientData };
|
|
5426
5482
|
const createStreamExtParams = {
|
|
5427
|
-
sender,
|
|
5483
|
+
sender: tempSender,
|
|
5428
5484
|
metadataPubKeys: metadataPubKeys[i] ? [metadataPubKeys[i]] : void 0,
|
|
5429
|
-
|
|
5430
|
-
computeLimit,
|
|
5431
|
-
customInstructions
|
|
5485
|
+
...extParams
|
|
5432
5486
|
};
|
|
5433
5487
|
const { ixs, metadata, metadataPubKey } = await this.prepareCreateInstructions(
|
|
5434
5488
|
createStreamData,
|
|
@@ -5443,21 +5497,99 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5443
5497
|
recipient: recipientData.recipient
|
|
5444
5498
|
});
|
|
5445
5499
|
}
|
|
5446
|
-
const { value: hash, context } = await this.connection.getLatestBlockhashAndContext();
|
|
5447
|
-
for (const { ixs, metadata, recipient } of instructionsBatch) {
|
|
5448
|
-
batch.push({ tx: createVersionedTransaction(ixs, sender.publicKey, hash.blockhash, [metadata]), recipient });
|
|
5449
|
-
}
|
|
5450
5500
|
const prepareInstructions = await this.getCreateATAInstructions(
|
|
5451
5501
|
[partnerPublicKey],
|
|
5452
5502
|
mintPublicKey,
|
|
5453
|
-
|
|
5503
|
+
tempSender,
|
|
5454
5504
|
true
|
|
5455
5505
|
);
|
|
5456
5506
|
if (isNative) {
|
|
5457
5507
|
const totalDepositedAmount = recipients.reduce((acc, recipient) => recipient.amount.add(acc), new BN7(0));
|
|
5458
|
-
const nativeInstructions = await prepareWrappedAccount(
|
|
5508
|
+
const nativeInstructions = await prepareWrappedAccount(
|
|
5509
|
+
this.connection,
|
|
5510
|
+
tempSender.publicKey,
|
|
5511
|
+
totalDepositedAmount
|
|
5512
|
+
);
|
|
5459
5513
|
prepareInstructions.push(...nativeInstructions);
|
|
5460
5514
|
}
|
|
5515
|
+
return {
|
|
5516
|
+
instructionsBatch,
|
|
5517
|
+
metadatas,
|
|
5518
|
+
metadataToRecipient,
|
|
5519
|
+
prepareInstructions
|
|
5520
|
+
};
|
|
5521
|
+
}
|
|
5522
|
+
/**
|
|
5523
|
+
* Builds multiple transactions for creating stream/vesting contracts without signing or executing them.
|
|
5524
|
+
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
5525
|
+
*
|
|
5526
|
+
* IMPORTANT: When using native SOL (isNative: true), you MUST execute the prepareTx FIRST and wait for confirmation
|
|
5527
|
+
* before executing the stream creation transactions. Otherwise, stream creation will fail with "InvalidAccountData".
|
|
5528
|
+
*
|
|
5529
|
+
* @example
|
|
5530
|
+
* ```typescript
|
|
5531
|
+
* const result = await streamClient.buildCreateMultipleTransactions(data, { isNative: true, senderPublicKey });
|
|
5532
|
+
*
|
|
5533
|
+
* // CRITICAL: Execute prepareTx first if it exists
|
|
5534
|
+
* if (result.prepareTx) {
|
|
5535
|
+
* await connection.sendAndConfirmTransaction(result.prepareTx, [signer]);
|
|
5536
|
+
* }
|
|
5537
|
+
*
|
|
5538
|
+
* // Only then execute stream creation transactions
|
|
5539
|
+
* for (const item of result.transactions) {
|
|
5540
|
+
* await connection.sendAndConfirmTransaction(item.tx, [signer]);
|
|
5541
|
+
* }
|
|
5542
|
+
* ```
|
|
5543
|
+
*
|
|
5544
|
+
* @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
|
|
5545
|
+
* @param {Omit<ICreateStreamSolanaExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
|
|
5546
|
+
* @returns Multiple transaction information
|
|
5547
|
+
*/
|
|
5548
|
+
async buildCreateMultipleTransactions(data, extParams) {
|
|
5549
|
+
const { senderPublicKey } = extParams;
|
|
5550
|
+
const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, extParams);
|
|
5551
|
+
const { value: hash, context } = await this.connection.getLatestBlockhashAndContext();
|
|
5552
|
+
const batch = [];
|
|
5553
|
+
for (const { ixs, metadata, recipient } of instructionsBatch) {
|
|
5554
|
+
batch.push({ tx: createVersionedTransaction(ixs, senderPublicKey, hash.blockhash, [metadata]), recipient });
|
|
5555
|
+
}
|
|
5556
|
+
let prepareTx;
|
|
5557
|
+
if (prepareInstructions.length > 0) {
|
|
5558
|
+
prepareTx = createVersionedTransaction(prepareInstructions, senderPublicKey, hash.blockhash);
|
|
5559
|
+
}
|
|
5560
|
+
return {
|
|
5561
|
+
transactions: batch,
|
|
5562
|
+
metadatas,
|
|
5563
|
+
metadataToRecipient,
|
|
5564
|
+
hash,
|
|
5565
|
+
context,
|
|
5566
|
+
prepareTx
|
|
5567
|
+
};
|
|
5568
|
+
}
|
|
5569
|
+
/**
|
|
5570
|
+
* Creates multiple stream/vesting contracts.
|
|
5571
|
+
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
5572
|
+
* @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
|
|
5573
|
+
* @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
|
|
5574
|
+
* @returns Multiple transaction information
|
|
5575
|
+
*/
|
|
5576
|
+
async createMultiple(data, extParams) {
|
|
5577
|
+
const { sender, metadataPubKeys: metadataPubKeysExt } = extParams;
|
|
5578
|
+
if (!sender.publicKey) {
|
|
5579
|
+
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
|
|
5580
|
+
}
|
|
5581
|
+
const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, {
|
|
5582
|
+
...extParams,
|
|
5583
|
+
senderPublicKey: sender.publicKey
|
|
5584
|
+
});
|
|
5585
|
+
const errors = [];
|
|
5586
|
+
const signatures = [];
|
|
5587
|
+
const metadataPubKeys = metadataPubKeysExt || [];
|
|
5588
|
+
const batch = [];
|
|
5589
|
+
const { value: hash, context } = await this.connection.getLatestBlockhashAndContext();
|
|
5590
|
+
for (const { ixs, metadata, recipient } of instructionsBatch) {
|
|
5591
|
+
batch.push({ tx: createVersionedTransaction(ixs, sender.publicKey, hash.blockhash, [metadata]), recipient });
|
|
5592
|
+
}
|
|
5461
5593
|
if (prepareInstructions.length > 0) {
|
|
5462
5594
|
batch.push({
|
|
5463
5595
|
tx: createVersionedTransaction(prepareInstructions, sender.publicKey, hash.blockhash),
|
|
@@ -5505,55 +5637,22 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5505
5637
|
* Creates multiple stream/vesting contracts, and send all transactions sequentially.
|
|
5506
5638
|
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
5507
5639
|
* In most cases, createMultiple should be used instead.
|
|
5640
|
+
* @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
|
|
5641
|
+
* @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
|
|
5642
|
+
* @returns Multiple transaction information
|
|
5508
5643
|
*/
|
|
5509
5644
|
async createMultipleSequential(data, extParams) {
|
|
5510
|
-
const {
|
|
5511
|
-
const {
|
|
5512
|
-
sender,
|
|
5513
|
-
metadataPubKeys: metadataPubKeysExt,
|
|
5514
|
-
isNative,
|
|
5515
|
-
computePrice,
|
|
5516
|
-
computeLimit,
|
|
5517
|
-
customInstructions
|
|
5518
|
-
} = extParams;
|
|
5519
|
-
const metadatas = [];
|
|
5520
|
-
const metadataToRecipient = {};
|
|
5521
|
-
const errors = [];
|
|
5522
|
-
const signatures = [];
|
|
5523
|
-
const batch = [];
|
|
5524
|
-
const instructionsBatch = [];
|
|
5525
|
-
const metadataPubKeys = metadataPubKeysExt || [];
|
|
5526
|
-
const partnerPublicKey = data.partner ? new PublicKey(data.partner) : WITHDRAWOR_PUBLIC_KEY;
|
|
5527
|
-
const mintPublicKey = new PublicKey(data.tokenId);
|
|
5528
|
-
if (recipients.length === 0) {
|
|
5529
|
-
throw new Error("Recipients array is empty!");
|
|
5530
|
-
}
|
|
5645
|
+
const { sender } = extParams;
|
|
5531
5646
|
if (!sender.publicKey) {
|
|
5532
5647
|
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
|
|
5533
5648
|
}
|
|
5534
|
-
|
|
5535
|
-
|
|
5536
|
-
|
|
5537
|
-
|
|
5538
|
-
|
|
5539
|
-
|
|
5540
|
-
|
|
5541
|
-
computeLimit,
|
|
5542
|
-
customInstructions
|
|
5543
|
-
};
|
|
5544
|
-
const { ixs, metadata, metadataPubKey } = await this.prepareCreateInstructions(
|
|
5545
|
-
createStreamData,
|
|
5546
|
-
createStreamExtParams
|
|
5547
|
-
);
|
|
5548
|
-
await this.applyCustomAfterInstructions(ixs, customInstructions, metadataPubKey);
|
|
5549
|
-
metadataToRecipient[metadataPubKey.toBase58()] = recipientData;
|
|
5550
|
-
metadatas.push(metadataPubKey.toBase58());
|
|
5551
|
-
instructionsBatch.push({
|
|
5552
|
-
ixs,
|
|
5553
|
-
metadata,
|
|
5554
|
-
recipient: recipientData.recipient
|
|
5555
|
-
});
|
|
5556
|
-
}
|
|
5649
|
+
const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, {
|
|
5650
|
+
...extParams,
|
|
5651
|
+
senderPublicKey: sender.publicKey
|
|
5652
|
+
});
|
|
5653
|
+
const errors = [];
|
|
5654
|
+
const signatures = [];
|
|
5655
|
+
const batch = [];
|
|
5557
5656
|
const { value: hash, context } = await this.connection.getLatestBlockhashAndContext();
|
|
5558
5657
|
for (const { ixs, metadata, recipient } of instructionsBatch) {
|
|
5559
5658
|
const messageV0 = new TransactionMessage({
|
|
@@ -5567,17 +5666,6 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5567
5666
|
}
|
|
5568
5667
|
batch.push({ tx, recipient });
|
|
5569
5668
|
}
|
|
5570
|
-
const prepareInstructions = await this.getCreateATAInstructions(
|
|
5571
|
-
[partnerPublicKey],
|
|
5572
|
-
mintPublicKey,
|
|
5573
|
-
sender,
|
|
5574
|
-
true
|
|
5575
|
-
);
|
|
5576
|
-
if (isNative) {
|
|
5577
|
-
const totalDepositedAmount = recipients.reduce((acc, recipient) => recipient.amount.add(acc), new BN7(0));
|
|
5578
|
-
const nativeInstructions = await prepareWrappedAccount(this.connection, sender.publicKey, totalDepositedAmount);
|
|
5579
|
-
prepareInstructions.push(...nativeInstructions);
|
|
5580
|
-
}
|
|
5581
5669
|
if (prepareInstructions.length > 0) {
|
|
5582
5670
|
const messageV0 = new TransactionMessage({
|
|
5583
5671
|
payerKey: sender.publicKey,
|
|
@@ -5618,6 +5706,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5618
5706
|
}
|
|
5619
5707
|
/**
|
|
5620
5708
|
* Attempts withdrawing from the specified stream.
|
|
5709
|
+
* @param {IWithdrawData} withdrawData - Withdrawal parameters including stream ID and amount to withdraw
|
|
5710
|
+
* @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
|
|
5711
|
+
* @returns Transaction result
|
|
5621
5712
|
*/
|
|
5622
5713
|
async withdraw({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, extParams) {
|
|
5623
5714
|
const { invoker, customInstructions } = extParams;
|
|
@@ -5643,6 +5734,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5643
5734
|
}
|
|
5644
5735
|
/**
|
|
5645
5736
|
* Creates Transaction Instructions for withdrawal
|
|
5737
|
+
* @param {IWithdrawData} withdrawData - Withdrawal parameters including stream ID and amount to withdraw
|
|
5738
|
+
* @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
|
|
5739
|
+
* @returns Transaction instructions
|
|
5646
5740
|
*/
|
|
5647
5741
|
async prepareWithdrawInstructions({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
|
|
5648
5742
|
if (!invoker.publicKey) {
|
|
@@ -5689,6 +5783,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5689
5783
|
}
|
|
5690
5784
|
/**
|
|
5691
5785
|
* Attempts canceling the specified stream.
|
|
5786
|
+
* @param {ICancelData} cancelData - Cancellation parameters including stream ID
|
|
5787
|
+
* @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
|
|
5788
|
+
* @returns Transaction result
|
|
5692
5789
|
*/
|
|
5693
5790
|
async cancel(cancelData, extParams) {
|
|
5694
5791
|
const ixs = await this.prepareCancelInstructions(cancelData, extParams);
|
|
@@ -5706,6 +5803,12 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5706
5803
|
);
|
|
5707
5804
|
return { ixs, txId: signature };
|
|
5708
5805
|
}
|
|
5806
|
+
/**
|
|
5807
|
+
* Creates Transaction Instructions for cancel
|
|
5808
|
+
* @param {ICancelData} cancelData - Cancellation parameters including stream ID
|
|
5809
|
+
* @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
|
|
5810
|
+
* @returns Transaction instructions
|
|
5811
|
+
*/
|
|
5709
5812
|
async prepareCancelInstructions(cancelData, extParams) {
|
|
5710
5813
|
const streamPublicKey = new PublicKey(cancelData.id);
|
|
5711
5814
|
const account = await this.connection.getAccountInfo(streamPublicKey);
|
|
@@ -5717,6 +5820,12 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5717
5820
|
const ixs = isAlignedUnlock ? await this.prepareCancelAlignedUnlockInstructions(cancelData, extParams) : await this.prepareCancelStreamInstructions(cancelData, extParams);
|
|
5718
5821
|
return ixs;
|
|
5719
5822
|
}
|
|
5823
|
+
/**
|
|
5824
|
+
* Creates Transaction Instructions for cancel
|
|
5825
|
+
* @param {ICancelData} cancelData - Cancellation parameters including stream ID
|
|
5826
|
+
* @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
|
|
5827
|
+
* @returns Transaction instructions
|
|
5828
|
+
*/
|
|
5720
5829
|
async prepareCancelAlignedUnlockInstructions({ id }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
|
|
5721
5830
|
if (!invoker.publicKey) {
|
|
5722
5831
|
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
@@ -5756,6 +5865,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5756
5865
|
}
|
|
5757
5866
|
/**
|
|
5758
5867
|
* Creates Transaction Instructions for cancel
|
|
5868
|
+
* @param {ICancelData} cancelData - Cancellation parameters including stream ID
|
|
5869
|
+
* @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
|
|
5870
|
+
* @returns Transaction instructions
|
|
5759
5871
|
*/
|
|
5760
5872
|
async prepareCancelStreamInstructions({ id }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
|
|
5761
5873
|
if (!invoker.publicKey) {
|
|
@@ -5805,6 +5917,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5805
5917
|
/**
|
|
5806
5918
|
* Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
|
|
5807
5919
|
* Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
|
|
5920
|
+
* @param {ITransferData} transferData - Transfer parameters including stream ID and new recipient address
|
|
5921
|
+
* @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
|
|
5922
|
+
* @returns Transaction result
|
|
5808
5923
|
*/
|
|
5809
5924
|
async transfer({ id, newRecipient }, extParams) {
|
|
5810
5925
|
const ixs = await this.prepareTransferInstructions({ id, newRecipient }, extParams);
|
|
@@ -5825,6 +5940,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5825
5940
|
/**
|
|
5826
5941
|
* Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
|
|
5827
5942
|
* Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
|
|
5943
|
+
* @param {ITransferData} transferData - Transfer parameters including stream ID and new recipient address
|
|
5944
|
+
* @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
|
|
5945
|
+
* @returns Transaction instructions
|
|
5828
5946
|
*/
|
|
5829
5947
|
async prepareTransferInstructions({ id, newRecipient }, { invoker, computePrice, computeLimit = 100001 }) {
|
|
5830
5948
|
if (!invoker.publicKey) {
|
|
@@ -5860,6 +5978,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5860
5978
|
}
|
|
5861
5979
|
/**
|
|
5862
5980
|
* Tops up stream account with specified amount.
|
|
5981
|
+
* @param {ITopUpData} topupData - Top-up parameters including stream ID and amount to add
|
|
5982
|
+
* @param {ITopUpStreamSolanaExt} extParams - Transaction configuration including invoker wallet, native token handling, and compute settings
|
|
5983
|
+
* @returns Transaction result
|
|
5863
5984
|
*/
|
|
5864
5985
|
async topup({ id, amount }, extParams) {
|
|
5865
5986
|
const ixs = await this.prepareTopupInstructions({ id, amount }, extParams);
|
|
@@ -5879,6 +6000,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5879
6000
|
}
|
|
5880
6001
|
/**
|
|
5881
6002
|
* Create Transaction instructions for topup
|
|
6003
|
+
* @param {ITopUpData} topupData - Top-up parameters including stream ID and amount to add
|
|
6004
|
+
* @param {ITopUpStreamSolanaExt} extParams - Transaction configuration including invoker wallet, native token handling, and compute settings
|
|
6005
|
+
* @returns Transaction instructions
|
|
5882
6006
|
*/
|
|
5883
6007
|
async prepareTopupInstructions({ id, amount }, { invoker, isNative, computePrice, computeLimit }) {
|
|
5884
6008
|
if (!invoker.publicKey) {
|
|
@@ -5920,6 +6044,8 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5920
6044
|
}
|
|
5921
6045
|
/**
|
|
5922
6046
|
* Fetch stream data by its id (address).
|
|
6047
|
+
* @param {IGetOneData} getData - Query parameters containing the stream ID to fetch
|
|
6048
|
+
* @returns Stream data
|
|
5923
6049
|
*/
|
|
5924
6050
|
async getOne({ id }) {
|
|
5925
6051
|
const streamPublicKey = new PublicKey(id);
|
|
@@ -5941,6 +6067,8 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5941
6067
|
}
|
|
5942
6068
|
/**
|
|
5943
6069
|
* Fetch all aligned outgoing streams/contracts by the provided public key.
|
|
6070
|
+
* @param {string} sender - Sender public key
|
|
6071
|
+
* @returns Record of stream data
|
|
5944
6072
|
*/
|
|
5945
6073
|
async getOutgoingAlignedStreams(sender) {
|
|
5946
6074
|
const streams = {};
|
|
@@ -5986,6 +6114,8 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5986
6114
|
/**
|
|
5987
6115
|
* Fetch streams/contracts by providing direction.
|
|
5988
6116
|
* Streams are sorted by start time in ascending order.
|
|
6117
|
+
* @param {IGetAllData} getData - Query parameters including address, stream type filter, and direction filter
|
|
6118
|
+
* @returns Record of stream data
|
|
5989
6119
|
*/
|
|
5990
6120
|
async get({
|
|
5991
6121
|
address,
|
|
@@ -6035,6 +6165,11 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
6035
6165
|
if (type === "all" /* All */) return sortedStreams;
|
|
6036
6166
|
return sortedStreams.filter((stream) => stream[1].type === type);
|
|
6037
6167
|
}
|
|
6168
|
+
/**
|
|
6169
|
+
* Searches for streams/contracts by providing filters.
|
|
6170
|
+
* @param {ISearchStreams} data - Search by mint, sender, recipient or closed status
|
|
6171
|
+
* @returns Record of stream data
|
|
6172
|
+
*/
|
|
6038
6173
|
async searchStreams(data) {
|
|
6039
6174
|
const filters = Object.entries(data).filter(([_, value]) => value !== void 0).map(([key, value]) => ({
|
|
6040
6175
|
memcmp: {
|
|
@@ -6053,6 +6188,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
6053
6188
|
}
|
|
6054
6189
|
/**
|
|
6055
6190
|
* Attempts updating the stream auto withdrawal params and amount per period
|
|
6191
|
+
* @param {IUpdateData} data - Update parameters including stream ID and new settings
|
|
6192
|
+
* @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
|
|
6193
|
+
* @returns Transaction result
|
|
6056
6194
|
*/
|
|
6057
6195
|
async update(data, extParams) {
|
|
6058
6196
|
const ixs = await this.prepareUpdateInstructions(data, extParams);
|
|
@@ -6075,6 +6213,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
6075
6213
|
}
|
|
6076
6214
|
/**
|
|
6077
6215
|
* Create Transaction instructions for update
|
|
6216
|
+
* @param {IUpdateData} data - Update parameters including stream ID and new settings
|
|
6217
|
+
* @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
|
|
6218
|
+
* @returns Transaction instructions
|
|
6078
6219
|
*/
|
|
6079
6220
|
async prepareUpdateInstructions(data, { invoker, computePrice, computeLimit }) {
|
|
6080
6221
|
if (!invoker.publicKey) {
|
|
@@ -6099,6 +6240,11 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
6099
6240
|
);
|
|
6100
6241
|
return ixs;
|
|
6101
6242
|
}
|
|
6243
|
+
/**
|
|
6244
|
+
* Gets fees for a given address
|
|
6245
|
+
* @param {IGetFeesData} getData - Query parameters containing the partner address to check for custom fees
|
|
6246
|
+
* @returns Fees
|
|
6247
|
+
*/
|
|
6102
6248
|
async getFees({ address }) {
|
|
6103
6249
|
const [metadataPubKey] = PublicKey.findProgramAddressSync(
|
|
6104
6250
|
[Buffer.from(FEES_METADATA_SEED)],
|
|
@@ -6118,9 +6264,18 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
6118
6264
|
partnerFee: Number(filteredPartners[0].partner_fee.toFixed(4))
|
|
6119
6265
|
};
|
|
6120
6266
|
}
|
|
6267
|
+
/**
|
|
6268
|
+
* Gets default streamflow fee
|
|
6269
|
+
* @returns Default streamflow fee
|
|
6270
|
+
*/
|
|
6121
6271
|
async getDefaultStreamflowFee() {
|
|
6122
6272
|
return DEFAULT_STREAMFLOW_FEE;
|
|
6123
6273
|
}
|
|
6274
|
+
/**
|
|
6275
|
+
* Extracts error code from an error
|
|
6276
|
+
* @param {Error} err - Error
|
|
6277
|
+
* @returns Error code
|
|
6278
|
+
*/
|
|
6124
6279
|
extractErrorCode(err) {
|
|
6125
6280
|
const logs = "logs" in err && Array.isArray(err.logs) ? err.logs : void 0;
|
|
6126
6281
|
return extractSolanaErrorCode(err.toString() ?? "Unknown error!", logs);
|