@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/cjs/index.cjs
CHANGED
|
@@ -5049,40 +5049,99 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5049
5049
|
return this.programId.toBase58();
|
|
5050
5050
|
}
|
|
5051
5051
|
/**
|
|
5052
|
-
*
|
|
5052
|
+
* Builds transaction instructions for creating a new stream/vesting contract without creating a transaction.
|
|
5053
5053
|
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
5054
|
+
*
|
|
5055
|
+
* For native SOL (isNative: true), SOL wrapping instructions are automatically included in the correct order
|
|
5056
|
+
* (before stream creation) to ensure the WSOL account exists when the stream creation instruction executes.
|
|
5057
|
+
*
|
|
5058
|
+
* @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
|
|
5059
|
+
* @param {Omit<ICreateStreamSolanaExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
|
|
5060
|
+
* @returns Transaction instructions and metadata ID
|
|
5054
5061
|
*/
|
|
5055
|
-
async
|
|
5062
|
+
async buildCreateTransactionInstructions(data, extParams) {
|
|
5056
5063
|
const { partner, amount, tokenProgramId } = data;
|
|
5057
|
-
const { isNative,
|
|
5064
|
+
const { isNative, senderPublicKey, customInstructions } = extParams;
|
|
5058
5065
|
const partnerPublicKey = partner ? new web3_js.PublicKey(partner) : WITHDRAWOR_PUBLIC_KEY;
|
|
5059
5066
|
const mintPublicKey = new web3_js.PublicKey(data.tokenId);
|
|
5060
|
-
|
|
5061
|
-
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
|
|
5062
|
-
}
|
|
5067
|
+
const tempSender = { publicKey: senderPublicKey };
|
|
5063
5068
|
const ixs = await this.getCreateATAInstructions(
|
|
5064
5069
|
[partnerPublicKey],
|
|
5065
5070
|
mintPublicKey,
|
|
5066
|
-
|
|
5071
|
+
tempSender,
|
|
5067
5072
|
true,
|
|
5068
5073
|
tokenProgramId ? new web3_js.PublicKey(tokenProgramId) : void 0
|
|
5069
5074
|
);
|
|
5070
|
-
const { ixs: createIxs, metadata, metadataPubKey } = await this.prepareCreateInstructions(data, extParams);
|
|
5071
|
-
ixs.push(...createIxs);
|
|
5072
5075
|
if (isNative) {
|
|
5073
5076
|
const totalFee = await this.getTotalFee({
|
|
5074
5077
|
address: partnerPublicKey.toString()
|
|
5075
5078
|
});
|
|
5076
5079
|
const totalAmount = calculateTotalAmountToDeposit(amount, totalFee);
|
|
5077
|
-
ixs.push(...await solana.prepareWrappedAccount(this.connection,
|
|
5080
|
+
ixs.push(...await solana.prepareWrappedAccount(this.connection, tempSender.publicKey, totalAmount));
|
|
5078
5081
|
}
|
|
5082
|
+
const {
|
|
5083
|
+
ixs: createIxs,
|
|
5084
|
+
metadata,
|
|
5085
|
+
metadataPubKey
|
|
5086
|
+
} = await this.prepareCreateInstructions(data, {
|
|
5087
|
+
...extParams,
|
|
5088
|
+
sender: tempSender
|
|
5089
|
+
});
|
|
5090
|
+
ixs.push(...createIxs);
|
|
5079
5091
|
await this.applyCustomAfterInstructions(ixs, customInstructions, metadataPubKey);
|
|
5092
|
+
return {
|
|
5093
|
+
ixs,
|
|
5094
|
+
metadataId: metadataPubKey.toBase58(),
|
|
5095
|
+
metadata
|
|
5096
|
+
};
|
|
5097
|
+
}
|
|
5098
|
+
/**
|
|
5099
|
+
* Builds a transaction for creating a new stream/vesting contract without signing or executing it.
|
|
5100
|
+
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
5101
|
+
*
|
|
5102
|
+
* For native SOL (isNative: true), SOL wrapping instructions are automatically included in the correct order
|
|
5103
|
+
* (before stream creation) to ensure the WSOL account exists when the stream creation instruction executes.
|
|
5104
|
+
*
|
|
5105
|
+
* @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
|
|
5106
|
+
* @param {Omit<ICreateStreamSolanaExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
|
|
5107
|
+
* @returns Transaction and metadata information
|
|
5108
|
+
*/
|
|
5109
|
+
async buildCreateTransaction(data, extParams) {
|
|
5110
|
+
const { senderPublicKey } = extParams;
|
|
5111
|
+
const { ixs, metadataId, metadata } = await this.buildCreateTransactionInstructions(data, extParams);
|
|
5112
|
+
const { tx, hash, context } = await solana.prepareTransaction(this.connection, ixs, senderPublicKey, void 0, [
|
|
5113
|
+
metadata
|
|
5114
|
+
]);
|
|
5115
|
+
return {
|
|
5116
|
+
tx,
|
|
5117
|
+
metadataId,
|
|
5118
|
+
metadata,
|
|
5119
|
+
hash: hash.blockhash,
|
|
5120
|
+
context
|
|
5121
|
+
};
|
|
5122
|
+
}
|
|
5123
|
+
/**
|
|
5124
|
+
* Creates a new stream/vesting contract.
|
|
5125
|
+
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
5126
|
+
* @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
|
|
5127
|
+
* @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, native token handling, and compute settings
|
|
5128
|
+
* @returns Create result
|
|
5129
|
+
*/
|
|
5130
|
+
async create(data, extParams) {
|
|
5131
|
+
const { sender } = extParams;
|
|
5132
|
+
if (!sender.publicKey) {
|
|
5133
|
+
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
|
|
5134
|
+
}
|
|
5135
|
+
const { ixs, metadataId, metadata } = await this.buildCreateTransactionInstructions(data, {
|
|
5136
|
+
...extParams,
|
|
5137
|
+
senderPublicKey: sender.publicKey
|
|
5138
|
+
});
|
|
5080
5139
|
const { tx, hash, context } = await solana.prepareTransaction(this.connection, ixs, sender.publicKey, void 0, [
|
|
5081
5140
|
metadata
|
|
5082
5141
|
]);
|
|
5083
5142
|
const signature = await solana.signAndExecuteTransaction(
|
|
5084
5143
|
this.connection,
|
|
5085
|
-
|
|
5144
|
+
sender,
|
|
5086
5145
|
tx,
|
|
5087
5146
|
{
|
|
5088
5147
|
hash,
|
|
@@ -5091,7 +5150,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5091
5150
|
},
|
|
5092
5151
|
this.schedulingParams
|
|
5093
5152
|
);
|
|
5094
|
-
return { ixs, txId: signature, metadataId
|
|
5153
|
+
return { ixs, txId: signature, metadataId };
|
|
5095
5154
|
}
|
|
5096
5155
|
async prepareCreateInstructions(streamParams, extParams) {
|
|
5097
5156
|
const { ixs, metadata, metadataPubKey } = isCreateAlignedStreamData(streamParams) ? await this.prepareCreateAlignedUnlockInstructions(streamParams, extParams) : await this.prepareCreateStreamInstructions(streamParams, extParams);
|
|
@@ -5201,6 +5260,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5201
5260
|
/**
|
|
5202
5261
|
* Creates a new stream/vesting contract.
|
|
5203
5262
|
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
5263
|
+
* @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
|
|
5264
|
+
* @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
|
|
5265
|
+
* @returns Create stream instructions
|
|
5204
5266
|
*/
|
|
5205
5267
|
async prepareCreateStreamInstructions({
|
|
5206
5268
|
recipient,
|
|
@@ -5301,6 +5363,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5301
5363
|
* - initialized contract PDA off chain
|
|
5302
5364
|
*
|
|
5303
5365
|
* If you are not sure if you should use create or create_unchecked, go for create to be safer.
|
|
5366
|
+
* @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
|
|
5367
|
+
* @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
|
|
5368
|
+
* @returns Create result
|
|
5304
5369
|
*/
|
|
5305
5370
|
async createUnchecked(data, extParams) {
|
|
5306
5371
|
const { ixs, metadata, metadataPubKey } = await this.prepareCreateUncheckedInstructions(data, extParams);
|
|
@@ -5418,24 +5483,17 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5418
5483
|
return { ixs, metadata, metadataPubKey };
|
|
5419
5484
|
}
|
|
5420
5485
|
/**
|
|
5421
|
-
*
|
|
5486
|
+
* Builds transaction instructions for creating multiple stream/vesting contracts without creating transactions.
|
|
5422
5487
|
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
5488
|
+
* @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
|
|
5489
|
+
* @param {Omit<ICreateStreamSolanaExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
|
|
5490
|
+
* @returns Create multiple transaction instructions
|
|
5423
5491
|
*/
|
|
5424
|
-
async
|
|
5492
|
+
async buildCreateMultipleTransactionInstructions(data, extParams) {
|
|
5425
5493
|
const { recipients, ...streamParams } = data;
|
|
5426
|
-
const {
|
|
5427
|
-
sender,
|
|
5428
|
-
metadataPubKeys: metadataPubKeysExt,
|
|
5429
|
-
isNative,
|
|
5430
|
-
computePrice,
|
|
5431
|
-
computeLimit,
|
|
5432
|
-
customInstructions
|
|
5433
|
-
} = extParams;
|
|
5494
|
+
const { senderPublicKey, metadataPubKeys: metadataPubKeysExt, isNative, customInstructions } = extParams;
|
|
5434
5495
|
const metadatas = [];
|
|
5435
5496
|
const metadataToRecipient = {};
|
|
5436
|
-
const errors = [];
|
|
5437
|
-
const signatures = [];
|
|
5438
|
-
const batch = [];
|
|
5439
5497
|
const instructionsBatch = [];
|
|
5440
5498
|
const metadataPubKeys = metadataPubKeysExt || [];
|
|
5441
5499
|
const partnerPublicKey = data.partner ? new web3_js.PublicKey(data.partner) : WITHDRAWOR_PUBLIC_KEY;
|
|
@@ -5443,18 +5501,14 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5443
5501
|
if (recipients.length === 0) {
|
|
5444
5502
|
throw new Error("Recipients array is empty!");
|
|
5445
5503
|
}
|
|
5446
|
-
|
|
5447
|
-
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
|
|
5448
|
-
}
|
|
5504
|
+
const tempSender = { publicKey: senderPublicKey };
|
|
5449
5505
|
for (let i = 0; i < recipients.length; i++) {
|
|
5450
5506
|
const recipientData = recipients[i];
|
|
5451
5507
|
const createStreamData = { ...streamParams, ...recipientData };
|
|
5452
5508
|
const createStreamExtParams = {
|
|
5453
|
-
sender,
|
|
5509
|
+
sender: tempSender,
|
|
5454
5510
|
metadataPubKeys: metadataPubKeys[i] ? [metadataPubKeys[i]] : void 0,
|
|
5455
|
-
|
|
5456
|
-
computeLimit,
|
|
5457
|
-
customInstructions
|
|
5511
|
+
...extParams
|
|
5458
5512
|
};
|
|
5459
5513
|
const { ixs, metadata, metadataPubKey } = await this.prepareCreateInstructions(
|
|
5460
5514
|
createStreamData,
|
|
@@ -5469,21 +5523,99 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5469
5523
|
recipient: recipientData.recipient
|
|
5470
5524
|
});
|
|
5471
5525
|
}
|
|
5472
|
-
const { value: hash, context } = await this.connection.getLatestBlockhashAndContext();
|
|
5473
|
-
for (const { ixs, metadata, recipient } of instructionsBatch) {
|
|
5474
|
-
batch.push({ tx: solana.createVersionedTransaction(ixs, sender.publicKey, hash.blockhash, [metadata]), recipient });
|
|
5475
|
-
}
|
|
5476
5526
|
const prepareInstructions = await this.getCreateATAInstructions(
|
|
5477
5527
|
[partnerPublicKey],
|
|
5478
5528
|
mintPublicKey,
|
|
5479
|
-
|
|
5529
|
+
tempSender,
|
|
5480
5530
|
true
|
|
5481
5531
|
);
|
|
5482
5532
|
if (isNative) {
|
|
5483
5533
|
const totalDepositedAmount = recipients.reduce((acc, recipient) => recipient.amount.add(acc), new BN7__default.default(0));
|
|
5484
|
-
const nativeInstructions = await solana.prepareWrappedAccount(
|
|
5534
|
+
const nativeInstructions = await solana.prepareWrappedAccount(
|
|
5535
|
+
this.connection,
|
|
5536
|
+
tempSender.publicKey,
|
|
5537
|
+
totalDepositedAmount
|
|
5538
|
+
);
|
|
5485
5539
|
prepareInstructions.push(...nativeInstructions);
|
|
5486
5540
|
}
|
|
5541
|
+
return {
|
|
5542
|
+
instructionsBatch,
|
|
5543
|
+
metadatas,
|
|
5544
|
+
metadataToRecipient,
|
|
5545
|
+
prepareInstructions
|
|
5546
|
+
};
|
|
5547
|
+
}
|
|
5548
|
+
/**
|
|
5549
|
+
* Builds multiple transactions for creating stream/vesting contracts without signing or executing them.
|
|
5550
|
+
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
5551
|
+
*
|
|
5552
|
+
* IMPORTANT: When using native SOL (isNative: true), you MUST execute the prepareTx FIRST and wait for confirmation
|
|
5553
|
+
* before executing the stream creation transactions. Otherwise, stream creation will fail with "InvalidAccountData".
|
|
5554
|
+
*
|
|
5555
|
+
* @example
|
|
5556
|
+
* ```typescript
|
|
5557
|
+
* const result = await streamClient.buildCreateMultipleTransactions(data, { isNative: true, senderPublicKey });
|
|
5558
|
+
*
|
|
5559
|
+
* // CRITICAL: Execute prepareTx first if it exists
|
|
5560
|
+
* if (result.prepareTx) {
|
|
5561
|
+
* await connection.sendAndConfirmTransaction(result.prepareTx, [signer]);
|
|
5562
|
+
* }
|
|
5563
|
+
*
|
|
5564
|
+
* // Only then execute stream creation transactions
|
|
5565
|
+
* for (const item of result.transactions) {
|
|
5566
|
+
* await connection.sendAndConfirmTransaction(item.tx, [signer]);
|
|
5567
|
+
* }
|
|
5568
|
+
* ```
|
|
5569
|
+
*
|
|
5570
|
+
* @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
|
|
5571
|
+
* @param {Omit<ICreateStreamSolanaExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
|
|
5572
|
+
* @returns Multiple transaction information
|
|
5573
|
+
*/
|
|
5574
|
+
async buildCreateMultipleTransactions(data, extParams) {
|
|
5575
|
+
const { senderPublicKey } = extParams;
|
|
5576
|
+
const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, extParams);
|
|
5577
|
+
const { value: hash, context } = await this.connection.getLatestBlockhashAndContext();
|
|
5578
|
+
const batch = [];
|
|
5579
|
+
for (const { ixs, metadata, recipient } of instructionsBatch) {
|
|
5580
|
+
batch.push({ tx: solana.createVersionedTransaction(ixs, senderPublicKey, hash.blockhash, [metadata]), recipient });
|
|
5581
|
+
}
|
|
5582
|
+
let prepareTx;
|
|
5583
|
+
if (prepareInstructions.length > 0) {
|
|
5584
|
+
prepareTx = solana.createVersionedTransaction(prepareInstructions, senderPublicKey, hash.blockhash);
|
|
5585
|
+
}
|
|
5586
|
+
return {
|
|
5587
|
+
transactions: batch,
|
|
5588
|
+
metadatas,
|
|
5589
|
+
metadataToRecipient,
|
|
5590
|
+
hash,
|
|
5591
|
+
context,
|
|
5592
|
+
prepareTx
|
|
5593
|
+
};
|
|
5594
|
+
}
|
|
5595
|
+
/**
|
|
5596
|
+
* Creates multiple stream/vesting contracts.
|
|
5597
|
+
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
5598
|
+
* @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
|
|
5599
|
+
* @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
|
|
5600
|
+
* @returns Multiple transaction information
|
|
5601
|
+
*/
|
|
5602
|
+
async createMultiple(data, extParams) {
|
|
5603
|
+
const { sender, metadataPubKeys: metadataPubKeysExt } = extParams;
|
|
5604
|
+
if (!sender.publicKey) {
|
|
5605
|
+
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
|
|
5606
|
+
}
|
|
5607
|
+
const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, {
|
|
5608
|
+
...extParams,
|
|
5609
|
+
senderPublicKey: sender.publicKey
|
|
5610
|
+
});
|
|
5611
|
+
const errors = [];
|
|
5612
|
+
const signatures = [];
|
|
5613
|
+
const metadataPubKeys = metadataPubKeysExt || [];
|
|
5614
|
+
const batch = [];
|
|
5615
|
+
const { value: hash, context } = await this.connection.getLatestBlockhashAndContext();
|
|
5616
|
+
for (const { ixs, metadata, recipient } of instructionsBatch) {
|
|
5617
|
+
batch.push({ tx: solana.createVersionedTransaction(ixs, sender.publicKey, hash.blockhash, [metadata]), recipient });
|
|
5618
|
+
}
|
|
5487
5619
|
if (prepareInstructions.length > 0) {
|
|
5488
5620
|
batch.push({
|
|
5489
5621
|
tx: solana.createVersionedTransaction(prepareInstructions, sender.publicKey, hash.blockhash),
|
|
@@ -5531,55 +5663,22 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5531
5663
|
* Creates multiple stream/vesting contracts, and send all transactions sequentially.
|
|
5532
5664
|
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
5533
5665
|
* In most cases, createMultiple should be used instead.
|
|
5666
|
+
* @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
|
|
5667
|
+
* @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
|
|
5668
|
+
* @returns Multiple transaction information
|
|
5534
5669
|
*/
|
|
5535
5670
|
async createMultipleSequential(data, extParams) {
|
|
5536
|
-
const {
|
|
5537
|
-
const {
|
|
5538
|
-
sender,
|
|
5539
|
-
metadataPubKeys: metadataPubKeysExt,
|
|
5540
|
-
isNative,
|
|
5541
|
-
computePrice,
|
|
5542
|
-
computeLimit,
|
|
5543
|
-
customInstructions
|
|
5544
|
-
} = extParams;
|
|
5545
|
-
const metadatas = [];
|
|
5546
|
-
const metadataToRecipient = {};
|
|
5547
|
-
const errors = [];
|
|
5548
|
-
const signatures = [];
|
|
5549
|
-
const batch = [];
|
|
5550
|
-
const instructionsBatch = [];
|
|
5551
|
-
const metadataPubKeys = metadataPubKeysExt || [];
|
|
5552
|
-
const partnerPublicKey = data.partner ? new web3_js.PublicKey(data.partner) : WITHDRAWOR_PUBLIC_KEY;
|
|
5553
|
-
const mintPublicKey = new web3_js.PublicKey(data.tokenId);
|
|
5554
|
-
if (recipients.length === 0) {
|
|
5555
|
-
throw new Error("Recipients array is empty!");
|
|
5556
|
-
}
|
|
5671
|
+
const { sender } = extParams;
|
|
5557
5672
|
if (!sender.publicKey) {
|
|
5558
5673
|
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
|
|
5559
5674
|
}
|
|
5560
|
-
|
|
5561
|
-
|
|
5562
|
-
|
|
5563
|
-
|
|
5564
|
-
|
|
5565
|
-
|
|
5566
|
-
|
|
5567
|
-
computeLimit,
|
|
5568
|
-
customInstructions
|
|
5569
|
-
};
|
|
5570
|
-
const { ixs, metadata, metadataPubKey } = await this.prepareCreateInstructions(
|
|
5571
|
-
createStreamData,
|
|
5572
|
-
createStreamExtParams
|
|
5573
|
-
);
|
|
5574
|
-
await this.applyCustomAfterInstructions(ixs, customInstructions, metadataPubKey);
|
|
5575
|
-
metadataToRecipient[metadataPubKey.toBase58()] = recipientData;
|
|
5576
|
-
metadatas.push(metadataPubKey.toBase58());
|
|
5577
|
-
instructionsBatch.push({
|
|
5578
|
-
ixs,
|
|
5579
|
-
metadata,
|
|
5580
|
-
recipient: recipientData.recipient
|
|
5581
|
-
});
|
|
5582
|
-
}
|
|
5675
|
+
const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, {
|
|
5676
|
+
...extParams,
|
|
5677
|
+
senderPublicKey: sender.publicKey
|
|
5678
|
+
});
|
|
5679
|
+
const errors = [];
|
|
5680
|
+
const signatures = [];
|
|
5681
|
+
const batch = [];
|
|
5583
5682
|
const { value: hash, context } = await this.connection.getLatestBlockhashAndContext();
|
|
5584
5683
|
for (const { ixs, metadata, recipient } of instructionsBatch) {
|
|
5585
5684
|
const messageV0 = new web3_js.TransactionMessage({
|
|
@@ -5593,17 +5692,6 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5593
5692
|
}
|
|
5594
5693
|
batch.push({ tx, recipient });
|
|
5595
5694
|
}
|
|
5596
|
-
const prepareInstructions = await this.getCreateATAInstructions(
|
|
5597
|
-
[partnerPublicKey],
|
|
5598
|
-
mintPublicKey,
|
|
5599
|
-
sender,
|
|
5600
|
-
true
|
|
5601
|
-
);
|
|
5602
|
-
if (isNative) {
|
|
5603
|
-
const totalDepositedAmount = recipients.reduce((acc, recipient) => recipient.amount.add(acc), new BN7__default.default(0));
|
|
5604
|
-
const nativeInstructions = await solana.prepareWrappedAccount(this.connection, sender.publicKey, totalDepositedAmount);
|
|
5605
|
-
prepareInstructions.push(...nativeInstructions);
|
|
5606
|
-
}
|
|
5607
5695
|
if (prepareInstructions.length > 0) {
|
|
5608
5696
|
const messageV0 = new web3_js.TransactionMessage({
|
|
5609
5697
|
payerKey: sender.publicKey,
|
|
@@ -5644,6 +5732,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5644
5732
|
}
|
|
5645
5733
|
/**
|
|
5646
5734
|
* Attempts withdrawing from the specified stream.
|
|
5735
|
+
* @param {IWithdrawData} withdrawData - Withdrawal parameters including stream ID and amount to withdraw
|
|
5736
|
+
* @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
|
|
5737
|
+
* @returns Transaction result
|
|
5647
5738
|
*/
|
|
5648
5739
|
async withdraw({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, extParams) {
|
|
5649
5740
|
const { invoker, customInstructions } = extParams;
|
|
@@ -5669,6 +5760,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5669
5760
|
}
|
|
5670
5761
|
/**
|
|
5671
5762
|
* Creates Transaction Instructions for withdrawal
|
|
5763
|
+
* @param {IWithdrawData} withdrawData - Withdrawal parameters including stream ID and amount to withdraw
|
|
5764
|
+
* @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
|
|
5765
|
+
* @returns Transaction instructions
|
|
5672
5766
|
*/
|
|
5673
5767
|
async prepareWithdrawInstructions({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
|
|
5674
5768
|
if (!invoker.publicKey) {
|
|
@@ -5715,6 +5809,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5715
5809
|
}
|
|
5716
5810
|
/**
|
|
5717
5811
|
* Attempts canceling the specified stream.
|
|
5812
|
+
* @param {ICancelData} cancelData - Cancellation parameters including stream ID
|
|
5813
|
+
* @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
|
|
5814
|
+
* @returns Transaction result
|
|
5718
5815
|
*/
|
|
5719
5816
|
async cancel(cancelData, extParams) {
|
|
5720
5817
|
const ixs = await this.prepareCancelInstructions(cancelData, extParams);
|
|
@@ -5732,6 +5829,12 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5732
5829
|
);
|
|
5733
5830
|
return { ixs, txId: signature };
|
|
5734
5831
|
}
|
|
5832
|
+
/**
|
|
5833
|
+
* Creates Transaction Instructions for cancel
|
|
5834
|
+
* @param {ICancelData} cancelData - Cancellation parameters including stream ID
|
|
5835
|
+
* @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
|
|
5836
|
+
* @returns Transaction instructions
|
|
5837
|
+
*/
|
|
5735
5838
|
async prepareCancelInstructions(cancelData, extParams) {
|
|
5736
5839
|
const streamPublicKey = new web3_js.PublicKey(cancelData.id);
|
|
5737
5840
|
const account = await this.connection.getAccountInfo(streamPublicKey);
|
|
@@ -5743,6 +5846,12 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5743
5846
|
const ixs = isAlignedUnlock ? await this.prepareCancelAlignedUnlockInstructions(cancelData, extParams) : await this.prepareCancelStreamInstructions(cancelData, extParams);
|
|
5744
5847
|
return ixs;
|
|
5745
5848
|
}
|
|
5849
|
+
/**
|
|
5850
|
+
* Creates Transaction Instructions for cancel
|
|
5851
|
+
* @param {ICancelData} cancelData - Cancellation parameters including stream ID
|
|
5852
|
+
* @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
|
|
5853
|
+
* @returns Transaction instructions
|
|
5854
|
+
*/
|
|
5746
5855
|
async prepareCancelAlignedUnlockInstructions({ id }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
|
|
5747
5856
|
if (!invoker.publicKey) {
|
|
5748
5857
|
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
@@ -5782,6 +5891,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5782
5891
|
}
|
|
5783
5892
|
/**
|
|
5784
5893
|
* Creates Transaction Instructions for cancel
|
|
5894
|
+
* @param {ICancelData} cancelData - Cancellation parameters including stream ID
|
|
5895
|
+
* @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
|
|
5896
|
+
* @returns Transaction instructions
|
|
5785
5897
|
*/
|
|
5786
5898
|
async prepareCancelStreamInstructions({ id }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
|
|
5787
5899
|
if (!invoker.publicKey) {
|
|
@@ -5831,6 +5943,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5831
5943
|
/**
|
|
5832
5944
|
* Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
|
|
5833
5945
|
* Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
|
|
5946
|
+
* @param {ITransferData} transferData - Transfer parameters including stream ID and new recipient address
|
|
5947
|
+
* @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
|
|
5948
|
+
* @returns Transaction result
|
|
5834
5949
|
*/
|
|
5835
5950
|
async transfer({ id, newRecipient }, extParams) {
|
|
5836
5951
|
const ixs = await this.prepareTransferInstructions({ id, newRecipient }, extParams);
|
|
@@ -5851,6 +5966,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5851
5966
|
/**
|
|
5852
5967
|
* Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
|
|
5853
5968
|
* Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
|
|
5969
|
+
* @param {ITransferData} transferData - Transfer parameters including stream ID and new recipient address
|
|
5970
|
+
* @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
|
|
5971
|
+
* @returns Transaction instructions
|
|
5854
5972
|
*/
|
|
5855
5973
|
async prepareTransferInstructions({ id, newRecipient }, { invoker, computePrice, computeLimit = 100001 }) {
|
|
5856
5974
|
if (!invoker.publicKey) {
|
|
@@ -5886,6 +6004,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5886
6004
|
}
|
|
5887
6005
|
/**
|
|
5888
6006
|
* Tops up stream account with specified amount.
|
|
6007
|
+
* @param {ITopUpData} topupData - Top-up parameters including stream ID and amount to add
|
|
6008
|
+
* @param {ITopUpStreamSolanaExt} extParams - Transaction configuration including invoker wallet, native token handling, and compute settings
|
|
6009
|
+
* @returns Transaction result
|
|
5889
6010
|
*/
|
|
5890
6011
|
async topup({ id, amount }, extParams) {
|
|
5891
6012
|
const ixs = await this.prepareTopupInstructions({ id, amount }, extParams);
|
|
@@ -5905,6 +6026,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5905
6026
|
}
|
|
5906
6027
|
/**
|
|
5907
6028
|
* Create Transaction instructions for topup
|
|
6029
|
+
* @param {ITopUpData} topupData - Top-up parameters including stream ID and amount to add
|
|
6030
|
+
* @param {ITopUpStreamSolanaExt} extParams - Transaction configuration including invoker wallet, native token handling, and compute settings
|
|
6031
|
+
* @returns Transaction instructions
|
|
5908
6032
|
*/
|
|
5909
6033
|
async prepareTopupInstructions({ id, amount }, { invoker, isNative, computePrice, computeLimit }) {
|
|
5910
6034
|
if (!invoker.publicKey) {
|
|
@@ -5946,6 +6070,8 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5946
6070
|
}
|
|
5947
6071
|
/**
|
|
5948
6072
|
* Fetch stream data by its id (address).
|
|
6073
|
+
* @param {IGetOneData} getData - Query parameters containing the stream ID to fetch
|
|
6074
|
+
* @returns Stream data
|
|
5949
6075
|
*/
|
|
5950
6076
|
async getOne({ id }) {
|
|
5951
6077
|
const streamPublicKey = new web3_js.PublicKey(id);
|
|
@@ -5967,6 +6093,8 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5967
6093
|
}
|
|
5968
6094
|
/**
|
|
5969
6095
|
* Fetch all aligned outgoing streams/contracts by the provided public key.
|
|
6096
|
+
* @param {string} sender - Sender public key
|
|
6097
|
+
* @returns Record of stream data
|
|
5970
6098
|
*/
|
|
5971
6099
|
async getOutgoingAlignedStreams(sender) {
|
|
5972
6100
|
const streams = {};
|
|
@@ -6012,6 +6140,8 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
6012
6140
|
/**
|
|
6013
6141
|
* Fetch streams/contracts by providing direction.
|
|
6014
6142
|
* Streams are sorted by start time in ascending order.
|
|
6143
|
+
* @param {IGetAllData} getData - Query parameters including address, stream type filter, and direction filter
|
|
6144
|
+
* @returns Record of stream data
|
|
6015
6145
|
*/
|
|
6016
6146
|
async get({
|
|
6017
6147
|
address,
|
|
@@ -6061,6 +6191,11 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
6061
6191
|
if (type === "all" /* All */) return sortedStreams;
|
|
6062
6192
|
return sortedStreams.filter((stream) => stream[1].type === type);
|
|
6063
6193
|
}
|
|
6194
|
+
/**
|
|
6195
|
+
* Searches for streams/contracts by providing filters.
|
|
6196
|
+
* @param {ISearchStreams} data - Search by mint, sender, recipient or closed status
|
|
6197
|
+
* @returns Record of stream data
|
|
6198
|
+
*/
|
|
6064
6199
|
async searchStreams(data) {
|
|
6065
6200
|
const filters = Object.entries(data).filter(([_, value]) => value !== void 0).map(([key, value]) => ({
|
|
6066
6201
|
memcmp: {
|
|
@@ -6079,6 +6214,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
6079
6214
|
}
|
|
6080
6215
|
/**
|
|
6081
6216
|
* Attempts updating the stream auto withdrawal params and amount per period
|
|
6217
|
+
* @param {IUpdateData} data - Update parameters including stream ID and new settings
|
|
6218
|
+
* @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
|
|
6219
|
+
* @returns Transaction result
|
|
6082
6220
|
*/
|
|
6083
6221
|
async update(data, extParams) {
|
|
6084
6222
|
const ixs = await this.prepareUpdateInstructions(data, extParams);
|
|
@@ -6101,6 +6239,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
6101
6239
|
}
|
|
6102
6240
|
/**
|
|
6103
6241
|
* Create Transaction instructions for update
|
|
6242
|
+
* @param {IUpdateData} data - Update parameters including stream ID and new settings
|
|
6243
|
+
* @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
|
|
6244
|
+
* @returns Transaction instructions
|
|
6104
6245
|
*/
|
|
6105
6246
|
async prepareUpdateInstructions(data, { invoker, computePrice, computeLimit }) {
|
|
6106
6247
|
if (!invoker.publicKey) {
|
|
@@ -6125,6 +6266,11 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
6125
6266
|
);
|
|
6126
6267
|
return ixs;
|
|
6127
6268
|
}
|
|
6269
|
+
/**
|
|
6270
|
+
* Gets fees for a given address
|
|
6271
|
+
* @param {IGetFeesData} getData - Query parameters containing the partner address to check for custom fees
|
|
6272
|
+
* @returns Fees
|
|
6273
|
+
*/
|
|
6128
6274
|
async getFees({ address }) {
|
|
6129
6275
|
const [metadataPubKey] = web3_js.PublicKey.findProgramAddressSync(
|
|
6130
6276
|
[buffer.Buffer.from(FEES_METADATA_SEED)],
|
|
@@ -6144,9 +6290,18 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
6144
6290
|
partnerFee: Number(filteredPartners[0].partner_fee.toFixed(4))
|
|
6145
6291
|
};
|
|
6146
6292
|
}
|
|
6293
|
+
/**
|
|
6294
|
+
* Gets default streamflow fee
|
|
6295
|
+
* @returns Default streamflow fee
|
|
6296
|
+
*/
|
|
6147
6297
|
async getDefaultStreamflowFee() {
|
|
6148
6298
|
return DEFAULT_STREAMFLOW_FEE;
|
|
6149
6299
|
}
|
|
6300
|
+
/**
|
|
6301
|
+
* Extracts error code from an error
|
|
6302
|
+
* @param {Error} err - Error
|
|
6303
|
+
* @returns Error code
|
|
6304
|
+
*/
|
|
6150
6305
|
extractErrorCode(err) {
|
|
6151
6306
|
const logs = "logs" in err && Array.isArray(err.logs) ? err.logs : void 0;
|
|
6152
6307
|
return extractSolanaErrorCode(err.toString() ?? "Unknown error!", logs);
|