@streamflow/stream 8.6.0 → 8.7.0-alpha.0
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-Dl7EztUT.d.cts} +152 -1
- package/dist/cjs/index.cjs +220 -92
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +2 -2
- package/dist/cjs/solana/index.cjs +220 -92
- 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-RvzYFo_L.d.ts} +152 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +220 -92
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/solana/index.d.ts +1 -1
- package/dist/esm/solana/index.js +220 -92
- package/dist/esm/solana/index.js.map +1 -1
- package/package.json +4 -4
package/dist/cjs/index.cjs
CHANGED
|
@@ -5049,40 +5049,91 @@ 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
|
+
* @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
|
|
5055
|
+
* @param {Omit<ICreateStreamSolanaExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
|
|
5056
|
+
* @returns Transaction instructions and metadata ID
|
|
5054
5057
|
*/
|
|
5055
|
-
async
|
|
5058
|
+
async buildCreateTransactionInstructions(data, extParams) {
|
|
5056
5059
|
const { partner, amount, tokenProgramId } = data;
|
|
5057
|
-
const { isNative,
|
|
5060
|
+
const { isNative, senderPublicKey, customInstructions } = extParams;
|
|
5058
5061
|
const partnerPublicKey = partner ? new web3_js.PublicKey(partner) : WITHDRAWOR_PUBLIC_KEY;
|
|
5059
5062
|
const mintPublicKey = new web3_js.PublicKey(data.tokenId);
|
|
5060
|
-
|
|
5061
|
-
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
|
|
5062
|
-
}
|
|
5063
|
+
const tempSender = { publicKey: senderPublicKey };
|
|
5063
5064
|
const ixs = await this.getCreateATAInstructions(
|
|
5064
5065
|
[partnerPublicKey],
|
|
5065
5066
|
mintPublicKey,
|
|
5066
|
-
|
|
5067
|
+
tempSender,
|
|
5067
5068
|
true,
|
|
5068
5069
|
tokenProgramId ? new web3_js.PublicKey(tokenProgramId) : void 0
|
|
5069
5070
|
);
|
|
5070
|
-
const {
|
|
5071
|
+
const {
|
|
5072
|
+
ixs: createIxs,
|
|
5073
|
+
metadata,
|
|
5074
|
+
metadataPubKey
|
|
5075
|
+
} = await this.prepareCreateInstructions(data, {
|
|
5076
|
+
...extParams,
|
|
5077
|
+
sender: tempSender
|
|
5078
|
+
});
|
|
5071
5079
|
ixs.push(...createIxs);
|
|
5072
5080
|
if (isNative) {
|
|
5073
5081
|
const totalFee = await this.getTotalFee({
|
|
5074
5082
|
address: partnerPublicKey.toString()
|
|
5075
5083
|
});
|
|
5076
5084
|
const totalAmount = calculateTotalAmountToDeposit(amount, totalFee);
|
|
5077
|
-
ixs.push(...await solana.prepareWrappedAccount(this.connection,
|
|
5085
|
+
ixs.push(...await solana.prepareWrappedAccount(this.connection, tempSender.publicKey, totalAmount));
|
|
5078
5086
|
}
|
|
5079
5087
|
await this.applyCustomAfterInstructions(ixs, customInstructions, metadataPubKey);
|
|
5088
|
+
return {
|
|
5089
|
+
ixs,
|
|
5090
|
+
metadataId: metadataPubKey.toBase58(),
|
|
5091
|
+
metadata
|
|
5092
|
+
};
|
|
5093
|
+
}
|
|
5094
|
+
/**
|
|
5095
|
+
* Builds a transaction for creating a new stream/vesting contract without signing or executing it.
|
|
5096
|
+
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
5097
|
+
* @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
|
|
5098
|
+
* @param {Omit<ICreateStreamSolanaExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
|
|
5099
|
+
* @returns Transaction and metadata information
|
|
5100
|
+
*/
|
|
5101
|
+
async buildCreateTransaction(data, extParams) {
|
|
5102
|
+
const { senderPublicKey } = extParams;
|
|
5103
|
+
const { ixs, metadataId, metadata } = await this.buildCreateTransactionInstructions(data, extParams);
|
|
5104
|
+
const { tx, hash, context } = await solana.prepareTransaction(this.connection, ixs, senderPublicKey, void 0, [
|
|
5105
|
+
metadata
|
|
5106
|
+
]);
|
|
5107
|
+
return {
|
|
5108
|
+
tx,
|
|
5109
|
+
metadataId,
|
|
5110
|
+
metadata,
|
|
5111
|
+
hash: hash.blockhash,
|
|
5112
|
+
context
|
|
5113
|
+
};
|
|
5114
|
+
}
|
|
5115
|
+
/**
|
|
5116
|
+
* Creates a new stream/vesting contract.
|
|
5117
|
+
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
5118
|
+
* @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
|
|
5119
|
+
* @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, native token handling, and compute settings
|
|
5120
|
+
* @returns Create result
|
|
5121
|
+
*/
|
|
5122
|
+
async create(data, extParams) {
|
|
5123
|
+
const { sender } = extParams;
|
|
5124
|
+
if (!sender.publicKey) {
|
|
5125
|
+
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
|
|
5126
|
+
}
|
|
5127
|
+
const { ixs, metadataId, metadata } = await this.buildCreateTransactionInstructions(data, {
|
|
5128
|
+
...extParams,
|
|
5129
|
+
senderPublicKey: sender.publicKey
|
|
5130
|
+
});
|
|
5080
5131
|
const { tx, hash, context } = await solana.prepareTransaction(this.connection, ixs, sender.publicKey, void 0, [
|
|
5081
5132
|
metadata
|
|
5082
5133
|
]);
|
|
5083
5134
|
const signature = await solana.signAndExecuteTransaction(
|
|
5084
5135
|
this.connection,
|
|
5085
|
-
|
|
5136
|
+
sender,
|
|
5086
5137
|
tx,
|
|
5087
5138
|
{
|
|
5088
5139
|
hash,
|
|
@@ -5091,7 +5142,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5091
5142
|
},
|
|
5092
5143
|
this.schedulingParams
|
|
5093
5144
|
);
|
|
5094
|
-
return { ixs, txId: signature, metadataId
|
|
5145
|
+
return { ixs, txId: signature, metadataId };
|
|
5095
5146
|
}
|
|
5096
5147
|
async prepareCreateInstructions(streamParams, extParams) {
|
|
5097
5148
|
const { ixs, metadata, metadataPubKey } = isCreateAlignedStreamData(streamParams) ? await this.prepareCreateAlignedUnlockInstructions(streamParams, extParams) : await this.prepareCreateStreamInstructions(streamParams, extParams);
|
|
@@ -5201,6 +5252,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5201
5252
|
/**
|
|
5202
5253
|
* Creates a new stream/vesting contract.
|
|
5203
5254
|
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
5255
|
+
* @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
|
|
5256
|
+
* @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
|
|
5257
|
+
* @returns Create stream instructions
|
|
5204
5258
|
*/
|
|
5205
5259
|
async prepareCreateStreamInstructions({
|
|
5206
5260
|
recipient,
|
|
@@ -5301,6 +5355,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5301
5355
|
* - initialized contract PDA off chain
|
|
5302
5356
|
*
|
|
5303
5357
|
* If you are not sure if you should use create or create_unchecked, go for create to be safer.
|
|
5358
|
+
* @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
|
|
5359
|
+
* @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
|
|
5360
|
+
* @returns Create result
|
|
5304
5361
|
*/
|
|
5305
5362
|
async createUnchecked(data, extParams) {
|
|
5306
5363
|
const { ixs, metadata, metadataPubKey } = await this.prepareCreateUncheckedInstructions(data, extParams);
|
|
@@ -5418,24 +5475,17 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5418
5475
|
return { ixs, metadata, metadataPubKey };
|
|
5419
5476
|
}
|
|
5420
5477
|
/**
|
|
5421
|
-
*
|
|
5478
|
+
* Builds transaction instructions for creating multiple stream/vesting contracts without creating transactions.
|
|
5422
5479
|
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
5480
|
+
* @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
|
|
5481
|
+
* @param {Omit<ICreateStreamSolanaExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
|
|
5482
|
+
* @returns Create multiple transaction instructions
|
|
5423
5483
|
*/
|
|
5424
|
-
async
|
|
5484
|
+
async buildCreateMultipleTransactionInstructions(data, extParams) {
|
|
5425
5485
|
const { recipients, ...streamParams } = data;
|
|
5426
|
-
const {
|
|
5427
|
-
sender,
|
|
5428
|
-
metadataPubKeys: metadataPubKeysExt,
|
|
5429
|
-
isNative,
|
|
5430
|
-
computePrice,
|
|
5431
|
-
computeLimit,
|
|
5432
|
-
customInstructions
|
|
5433
|
-
} = extParams;
|
|
5486
|
+
const { senderPublicKey, metadataPubKeys: metadataPubKeysExt, isNative, customInstructions } = extParams;
|
|
5434
5487
|
const metadatas = [];
|
|
5435
5488
|
const metadataToRecipient = {};
|
|
5436
|
-
const errors = [];
|
|
5437
|
-
const signatures = [];
|
|
5438
|
-
const batch = [];
|
|
5439
5489
|
const instructionsBatch = [];
|
|
5440
5490
|
const metadataPubKeys = metadataPubKeysExt || [];
|
|
5441
5491
|
const partnerPublicKey = data.partner ? new web3_js.PublicKey(data.partner) : WITHDRAWOR_PUBLIC_KEY;
|
|
@@ -5443,18 +5493,14 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5443
5493
|
if (recipients.length === 0) {
|
|
5444
5494
|
throw new Error("Recipients array is empty!");
|
|
5445
5495
|
}
|
|
5446
|
-
|
|
5447
|
-
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
|
|
5448
|
-
}
|
|
5496
|
+
const tempSender = { publicKey: senderPublicKey };
|
|
5449
5497
|
for (let i = 0; i < recipients.length; i++) {
|
|
5450
5498
|
const recipientData = recipients[i];
|
|
5451
5499
|
const createStreamData = { ...streamParams, ...recipientData };
|
|
5452
5500
|
const createStreamExtParams = {
|
|
5453
|
-
sender,
|
|
5501
|
+
sender: tempSender,
|
|
5454
5502
|
metadataPubKeys: metadataPubKeys[i] ? [metadataPubKeys[i]] : void 0,
|
|
5455
|
-
|
|
5456
|
-
computeLimit,
|
|
5457
|
-
customInstructions
|
|
5503
|
+
...extParams
|
|
5458
5504
|
};
|
|
5459
5505
|
const { ixs, metadata, metadataPubKey } = await this.prepareCreateInstructions(
|
|
5460
5506
|
createStreamData,
|
|
@@ -5469,21 +5515,80 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5469
5515
|
recipient: recipientData.recipient
|
|
5470
5516
|
});
|
|
5471
5517
|
}
|
|
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
5518
|
const prepareInstructions = await this.getCreateATAInstructions(
|
|
5477
5519
|
[partnerPublicKey],
|
|
5478
5520
|
mintPublicKey,
|
|
5479
|
-
|
|
5521
|
+
tempSender,
|
|
5480
5522
|
true
|
|
5481
5523
|
);
|
|
5482
5524
|
if (isNative) {
|
|
5483
5525
|
const totalDepositedAmount = recipients.reduce((acc, recipient) => recipient.amount.add(acc), new BN7__default.default(0));
|
|
5484
|
-
const nativeInstructions = await solana.prepareWrappedAccount(
|
|
5526
|
+
const nativeInstructions = await solana.prepareWrappedAccount(
|
|
5527
|
+
this.connection,
|
|
5528
|
+
tempSender.publicKey,
|
|
5529
|
+
totalDepositedAmount
|
|
5530
|
+
);
|
|
5485
5531
|
prepareInstructions.push(...nativeInstructions);
|
|
5486
5532
|
}
|
|
5533
|
+
return {
|
|
5534
|
+
instructionsBatch,
|
|
5535
|
+
metadatas,
|
|
5536
|
+
metadataToRecipient,
|
|
5537
|
+
prepareInstructions
|
|
5538
|
+
};
|
|
5539
|
+
}
|
|
5540
|
+
/**
|
|
5541
|
+
* Builds multiple transactions for creating stream/vesting contracts without signing or executing them.
|
|
5542
|
+
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
5543
|
+
* @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
|
|
5544
|
+
* @param {Omit<ICreateStreamSolanaExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
|
|
5545
|
+
* @returns Multiple transaction information
|
|
5546
|
+
*/
|
|
5547
|
+
async buildCreateMultipleTransactions(data, extParams) {
|
|
5548
|
+
const { senderPublicKey } = extParams;
|
|
5549
|
+
const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, extParams);
|
|
5550
|
+
const { value: hash, context } = await this.connection.getLatestBlockhashAndContext();
|
|
5551
|
+
const batch = [];
|
|
5552
|
+
for (const { ixs, metadata, recipient } of instructionsBatch) {
|
|
5553
|
+
batch.push({ tx: solana.createVersionedTransaction(ixs, senderPublicKey, hash.blockhash, [metadata]), recipient });
|
|
5554
|
+
}
|
|
5555
|
+
let prepareTx;
|
|
5556
|
+
if (prepareInstructions.length > 0) {
|
|
5557
|
+
prepareTx = solana.createVersionedTransaction(prepareInstructions, senderPublicKey, hash.blockhash);
|
|
5558
|
+
}
|
|
5559
|
+
return {
|
|
5560
|
+
transactions: batch,
|
|
5561
|
+
metadatas,
|
|
5562
|
+
metadataToRecipient,
|
|
5563
|
+
hash,
|
|
5564
|
+
context,
|
|
5565
|
+
prepareTx
|
|
5566
|
+
};
|
|
5567
|
+
}
|
|
5568
|
+
/**
|
|
5569
|
+
* Creates multiple stream/vesting contracts.
|
|
5570
|
+
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
5571
|
+
* @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
|
|
5572
|
+
* @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
|
|
5573
|
+
* @returns Multiple transaction information
|
|
5574
|
+
*/
|
|
5575
|
+
async createMultiple(data, extParams) {
|
|
5576
|
+
const { sender, metadataPubKeys: metadataPubKeysExt } = extParams;
|
|
5577
|
+
if (!sender.publicKey) {
|
|
5578
|
+
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
|
|
5579
|
+
}
|
|
5580
|
+
const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, {
|
|
5581
|
+
...extParams,
|
|
5582
|
+
senderPublicKey: sender.publicKey
|
|
5583
|
+
});
|
|
5584
|
+
const errors = [];
|
|
5585
|
+
const signatures = [];
|
|
5586
|
+
const metadataPubKeys = metadataPubKeysExt || [];
|
|
5587
|
+
const batch = [];
|
|
5588
|
+
const { value: hash, context } = await this.connection.getLatestBlockhashAndContext();
|
|
5589
|
+
for (const { ixs, metadata, recipient } of instructionsBatch) {
|
|
5590
|
+
batch.push({ tx: solana.createVersionedTransaction(ixs, sender.publicKey, hash.blockhash, [metadata]), recipient });
|
|
5591
|
+
}
|
|
5487
5592
|
if (prepareInstructions.length > 0) {
|
|
5488
5593
|
batch.push({
|
|
5489
5594
|
tx: solana.createVersionedTransaction(prepareInstructions, sender.publicKey, hash.blockhash),
|
|
@@ -5531,55 +5636,22 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5531
5636
|
* Creates multiple stream/vesting contracts, and send all transactions sequentially.
|
|
5532
5637
|
* 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
5638
|
* In most cases, createMultiple should be used instead.
|
|
5639
|
+
* @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
|
|
5640
|
+
* @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
|
|
5641
|
+
* @returns Multiple transaction information
|
|
5534
5642
|
*/
|
|
5535
5643
|
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
|
-
}
|
|
5644
|
+
const { sender } = extParams;
|
|
5557
5645
|
if (!sender.publicKey) {
|
|
5558
5646
|
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
|
|
5559
5647
|
}
|
|
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
|
-
}
|
|
5648
|
+
const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, {
|
|
5649
|
+
...extParams,
|
|
5650
|
+
senderPublicKey: sender.publicKey
|
|
5651
|
+
});
|
|
5652
|
+
const errors = [];
|
|
5653
|
+
const signatures = [];
|
|
5654
|
+
const batch = [];
|
|
5583
5655
|
const { value: hash, context } = await this.connection.getLatestBlockhashAndContext();
|
|
5584
5656
|
for (const { ixs, metadata, recipient } of instructionsBatch) {
|
|
5585
5657
|
const messageV0 = new web3_js.TransactionMessage({
|
|
@@ -5593,17 +5665,6 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5593
5665
|
}
|
|
5594
5666
|
batch.push({ tx, recipient });
|
|
5595
5667
|
}
|
|
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
5668
|
if (prepareInstructions.length > 0) {
|
|
5608
5669
|
const messageV0 = new web3_js.TransactionMessage({
|
|
5609
5670
|
payerKey: sender.publicKey,
|
|
@@ -5644,6 +5705,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5644
5705
|
}
|
|
5645
5706
|
/**
|
|
5646
5707
|
* Attempts withdrawing from the specified stream.
|
|
5708
|
+
* @param {IWithdrawData} withdrawData - Withdrawal parameters including stream ID and amount to withdraw
|
|
5709
|
+
* @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
|
|
5710
|
+
* @returns Transaction result
|
|
5647
5711
|
*/
|
|
5648
5712
|
async withdraw({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, extParams) {
|
|
5649
5713
|
const { invoker, customInstructions } = extParams;
|
|
@@ -5669,6 +5733,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5669
5733
|
}
|
|
5670
5734
|
/**
|
|
5671
5735
|
* Creates Transaction Instructions for withdrawal
|
|
5736
|
+
* @param {IWithdrawData} withdrawData - Withdrawal parameters including stream ID and amount to withdraw
|
|
5737
|
+
* @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
|
|
5738
|
+
* @returns Transaction instructions
|
|
5672
5739
|
*/
|
|
5673
5740
|
async prepareWithdrawInstructions({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
|
|
5674
5741
|
if (!invoker.publicKey) {
|
|
@@ -5715,6 +5782,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5715
5782
|
}
|
|
5716
5783
|
/**
|
|
5717
5784
|
* Attempts canceling the specified stream.
|
|
5785
|
+
* @param {ICancelData} cancelData - Cancellation parameters including stream ID
|
|
5786
|
+
* @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
|
|
5787
|
+
* @returns Transaction result
|
|
5718
5788
|
*/
|
|
5719
5789
|
async cancel(cancelData, extParams) {
|
|
5720
5790
|
const ixs = await this.prepareCancelInstructions(cancelData, extParams);
|
|
@@ -5732,6 +5802,12 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5732
5802
|
);
|
|
5733
5803
|
return { ixs, txId: signature };
|
|
5734
5804
|
}
|
|
5805
|
+
/**
|
|
5806
|
+
* Creates Transaction Instructions for cancel
|
|
5807
|
+
* @param {ICancelData} cancelData - Cancellation parameters including stream ID
|
|
5808
|
+
* @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
|
|
5809
|
+
* @returns Transaction instructions
|
|
5810
|
+
*/
|
|
5735
5811
|
async prepareCancelInstructions(cancelData, extParams) {
|
|
5736
5812
|
const streamPublicKey = new web3_js.PublicKey(cancelData.id);
|
|
5737
5813
|
const account = await this.connection.getAccountInfo(streamPublicKey);
|
|
@@ -5743,6 +5819,12 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5743
5819
|
const ixs = isAlignedUnlock ? await this.prepareCancelAlignedUnlockInstructions(cancelData, extParams) : await this.prepareCancelStreamInstructions(cancelData, extParams);
|
|
5744
5820
|
return ixs;
|
|
5745
5821
|
}
|
|
5822
|
+
/**
|
|
5823
|
+
* Creates Transaction Instructions for cancel
|
|
5824
|
+
* @param {ICancelData} cancelData - Cancellation parameters including stream ID
|
|
5825
|
+
* @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
|
|
5826
|
+
* @returns Transaction instructions
|
|
5827
|
+
*/
|
|
5746
5828
|
async prepareCancelAlignedUnlockInstructions({ id }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
|
|
5747
5829
|
if (!invoker.publicKey) {
|
|
5748
5830
|
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
@@ -5782,6 +5864,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5782
5864
|
}
|
|
5783
5865
|
/**
|
|
5784
5866
|
* Creates Transaction Instructions for cancel
|
|
5867
|
+
* @param {ICancelData} cancelData - Cancellation parameters including stream ID
|
|
5868
|
+
* @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
|
|
5869
|
+
* @returns Transaction instructions
|
|
5785
5870
|
*/
|
|
5786
5871
|
async prepareCancelStreamInstructions({ id }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
|
|
5787
5872
|
if (!invoker.publicKey) {
|
|
@@ -5831,6 +5916,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5831
5916
|
/**
|
|
5832
5917
|
* Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
|
|
5833
5918
|
* Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
|
|
5919
|
+
* @param {ITransferData} transferData - Transfer parameters including stream ID and new recipient address
|
|
5920
|
+
* @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
|
|
5921
|
+
* @returns Transaction result
|
|
5834
5922
|
*/
|
|
5835
5923
|
async transfer({ id, newRecipient }, extParams) {
|
|
5836
5924
|
const ixs = await this.prepareTransferInstructions({ id, newRecipient }, extParams);
|
|
@@ -5851,6 +5939,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5851
5939
|
/**
|
|
5852
5940
|
* Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
|
|
5853
5941
|
* Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
|
|
5942
|
+
* @param {ITransferData} transferData - Transfer parameters including stream ID and new recipient address
|
|
5943
|
+
* @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
|
|
5944
|
+
* @returns Transaction instructions
|
|
5854
5945
|
*/
|
|
5855
5946
|
async prepareTransferInstructions({ id, newRecipient }, { invoker, computePrice, computeLimit = 100001 }) {
|
|
5856
5947
|
if (!invoker.publicKey) {
|
|
@@ -5886,6 +5977,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5886
5977
|
}
|
|
5887
5978
|
/**
|
|
5888
5979
|
* Tops up stream account with specified amount.
|
|
5980
|
+
* @param {ITopUpData} topupData - Top-up parameters including stream ID and amount to add
|
|
5981
|
+
* @param {ITopUpStreamSolanaExt} extParams - Transaction configuration including invoker wallet, native token handling, and compute settings
|
|
5982
|
+
* @returns Transaction result
|
|
5889
5983
|
*/
|
|
5890
5984
|
async topup({ id, amount }, extParams) {
|
|
5891
5985
|
const ixs = await this.prepareTopupInstructions({ id, amount }, extParams);
|
|
@@ -5905,6 +5999,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5905
5999
|
}
|
|
5906
6000
|
/**
|
|
5907
6001
|
* Create Transaction instructions for topup
|
|
6002
|
+
* @param {ITopUpData} topupData - Top-up parameters including stream ID and amount to add
|
|
6003
|
+
* @param {ITopUpStreamSolanaExt} extParams - Transaction configuration including invoker wallet, native token handling, and compute settings
|
|
6004
|
+
* @returns Transaction instructions
|
|
5908
6005
|
*/
|
|
5909
6006
|
async prepareTopupInstructions({ id, amount }, { invoker, isNative, computePrice, computeLimit }) {
|
|
5910
6007
|
if (!invoker.publicKey) {
|
|
@@ -5946,6 +6043,8 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5946
6043
|
}
|
|
5947
6044
|
/**
|
|
5948
6045
|
* Fetch stream data by its id (address).
|
|
6046
|
+
* @param {IGetOneData} getData - Query parameters containing the stream ID to fetch
|
|
6047
|
+
* @returns Stream data
|
|
5949
6048
|
*/
|
|
5950
6049
|
async getOne({ id }) {
|
|
5951
6050
|
const streamPublicKey = new web3_js.PublicKey(id);
|
|
@@ -5967,6 +6066,8 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5967
6066
|
}
|
|
5968
6067
|
/**
|
|
5969
6068
|
* Fetch all aligned outgoing streams/contracts by the provided public key.
|
|
6069
|
+
* @param {string} sender - Sender public key
|
|
6070
|
+
* @returns Record of stream data
|
|
5970
6071
|
*/
|
|
5971
6072
|
async getOutgoingAlignedStreams(sender) {
|
|
5972
6073
|
const streams = {};
|
|
@@ -6012,6 +6113,8 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
6012
6113
|
/**
|
|
6013
6114
|
* Fetch streams/contracts by providing direction.
|
|
6014
6115
|
* Streams are sorted by start time in ascending order.
|
|
6116
|
+
* @param {IGetAllData} getData - Query parameters including address, stream type filter, and direction filter
|
|
6117
|
+
* @returns Record of stream data
|
|
6015
6118
|
*/
|
|
6016
6119
|
async get({
|
|
6017
6120
|
address,
|
|
@@ -6061,6 +6164,11 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
6061
6164
|
if (type === "all" /* All */) return sortedStreams;
|
|
6062
6165
|
return sortedStreams.filter((stream) => stream[1].type === type);
|
|
6063
6166
|
}
|
|
6167
|
+
/**
|
|
6168
|
+
* Searches for streams/contracts by providing filters.
|
|
6169
|
+
* @param {ISearchStreams} data - Search by mint, sender, recipient or closed status
|
|
6170
|
+
* @returns Record of stream data
|
|
6171
|
+
*/
|
|
6064
6172
|
async searchStreams(data) {
|
|
6065
6173
|
const filters = Object.entries(data).filter(([_, value]) => value !== void 0).map(([key, value]) => ({
|
|
6066
6174
|
memcmp: {
|
|
@@ -6079,6 +6187,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
6079
6187
|
}
|
|
6080
6188
|
/**
|
|
6081
6189
|
* Attempts updating the stream auto withdrawal params and amount per period
|
|
6190
|
+
* @param {IUpdateData} data - Update parameters including stream ID and new settings
|
|
6191
|
+
* @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
|
|
6192
|
+
* @returns Transaction result
|
|
6082
6193
|
*/
|
|
6083
6194
|
async update(data, extParams) {
|
|
6084
6195
|
const ixs = await this.prepareUpdateInstructions(data, extParams);
|
|
@@ -6101,6 +6212,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
6101
6212
|
}
|
|
6102
6213
|
/**
|
|
6103
6214
|
* Create Transaction instructions for update
|
|
6215
|
+
* @param {IUpdateData} data - Update parameters including stream ID and new settings
|
|
6216
|
+
* @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
|
|
6217
|
+
* @returns Transaction instructions
|
|
6104
6218
|
*/
|
|
6105
6219
|
async prepareUpdateInstructions(data, { invoker, computePrice, computeLimit }) {
|
|
6106
6220
|
if (!invoker.publicKey) {
|
|
@@ -6125,6 +6239,11 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
6125
6239
|
);
|
|
6126
6240
|
return ixs;
|
|
6127
6241
|
}
|
|
6242
|
+
/**
|
|
6243
|
+
* Gets fees for a given address
|
|
6244
|
+
* @param {IGetFeesData} getData - Query parameters containing the partner address to check for custom fees
|
|
6245
|
+
* @returns Fees
|
|
6246
|
+
*/
|
|
6128
6247
|
async getFees({ address }) {
|
|
6129
6248
|
const [metadataPubKey] = web3_js.PublicKey.findProgramAddressSync(
|
|
6130
6249
|
[buffer.Buffer.from(FEES_METADATA_SEED)],
|
|
@@ -6144,9 +6263,18 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
6144
6263
|
partnerFee: Number(filteredPartners[0].partner_fee.toFixed(4))
|
|
6145
6264
|
};
|
|
6146
6265
|
}
|
|
6266
|
+
/**
|
|
6267
|
+
* Gets default streamflow fee
|
|
6268
|
+
* @returns Default streamflow fee
|
|
6269
|
+
*/
|
|
6147
6270
|
async getDefaultStreamflowFee() {
|
|
6148
6271
|
return DEFAULT_STREAMFLOW_FEE;
|
|
6149
6272
|
}
|
|
6273
|
+
/**
|
|
6274
|
+
* Extracts error code from an error
|
|
6275
|
+
* @param {Error} err - Error
|
|
6276
|
+
* @returns Error code
|
|
6277
|
+
*/
|
|
6150
6278
|
extractErrorCode(err) {
|
|
6151
6279
|
const logs = "logs" in err && Array.isArray(err.logs) ? err.logs : void 0;
|
|
6152
6280
|
return extractSolanaErrorCode(err.toString() ?? "Unknown error!", logs);
|