@streamflow/stream 8.8.0 → 8.9.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/README.md +213 -175
- package/dist/cjs/{index-Bll7jg8V.d.cts → index-oCYfzJrc.d.cts} +37 -33
- package/dist/cjs/index.cjs +60 -90
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +2 -2
- package/dist/cjs/solana/index.cjs +60 -90
- package/dist/cjs/solana/index.cjs.map +1 -1
- package/dist/cjs/solana/index.d.cts +1 -1
- package/dist/esm/{index-D-w3ZCyC.d.ts → index-BNQVJtIE.d.ts} +37 -33
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +61 -91
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/solana/index.d.ts +1 -1
- package/dist/esm/solana/index.js +61 -91
- package/dist/esm/solana/index.js.map +1 -1
- package/package.json +4 -4
package/dist/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AptosClient, AptosAccount, TransactionBuilderRemoteABI } from 'aptos';
|
|
2
|
-
import { ICluster, ContractError, IChain, getBN as getBN$1 } from '@streamflow/common';
|
|
2
|
+
import { ICluster, ContractError, IChain, assertHasPublicKey, invariant, getBN as getBN$1 } from '@streamflow/common';
|
|
3
3
|
export { ContractError, IChain, ICluster } from '@streamflow/common';
|
|
4
4
|
import BN7 from 'bn.js';
|
|
5
5
|
import { Buffer } from 'buffer';
|
|
@@ -5035,14 +5035,14 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5035
5035
|
*/
|
|
5036
5036
|
async buildCreateTransactionInstructions(data, extParams) {
|
|
5037
5037
|
const { partner, amount, tokenProgramId } = data;
|
|
5038
|
-
const { isNative,
|
|
5038
|
+
const { isNative, sender, customInstructions } = extParams;
|
|
5039
|
+
assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
|
|
5039
5040
|
const partnerPublicKey = partner ? new PublicKey(partner) : WITHDRAWOR_PUBLIC_KEY;
|
|
5040
5041
|
const mintPublicKey = new PublicKey(data.tokenId);
|
|
5041
|
-
const tempSender = { publicKey: senderPublicKey };
|
|
5042
5042
|
const ixs = await this.getCreateATAInstructions(
|
|
5043
5043
|
[partnerPublicKey],
|
|
5044
5044
|
mintPublicKey,
|
|
5045
|
-
|
|
5045
|
+
sender,
|
|
5046
5046
|
true,
|
|
5047
5047
|
tokenProgramId ? new PublicKey(tokenProgramId) : void 0
|
|
5048
5048
|
);
|
|
@@ -5051,7 +5051,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5051
5051
|
address: partnerPublicKey.toString()
|
|
5052
5052
|
});
|
|
5053
5053
|
const totalAmount = calculateTotalAmountToDeposit(amount, totalFee);
|
|
5054
|
-
ixs.push(...await prepareWrappedAccount(this.connection,
|
|
5054
|
+
ixs.push(...await prepareWrappedAccount(this.connection, sender.publicKey, totalAmount));
|
|
5055
5055
|
}
|
|
5056
5056
|
const {
|
|
5057
5057
|
ixs: createIxs,
|
|
@@ -5059,7 +5059,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5059
5059
|
metadataPubKey
|
|
5060
5060
|
} = await this.prepareCreateInstructions(data, {
|
|
5061
5061
|
...extParams,
|
|
5062
|
-
sender
|
|
5062
|
+
sender
|
|
5063
5063
|
});
|
|
5064
5064
|
ixs.push(...createIxs);
|
|
5065
5065
|
await this.applyCustomAfterInstructions(ixs, customInstructions, metadataPubKey);
|
|
@@ -5081,9 +5081,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5081
5081
|
* @returns Transaction and metadata information
|
|
5082
5082
|
*/
|
|
5083
5083
|
async buildCreateTransaction(data, extParams) {
|
|
5084
|
-
const {
|
|
5084
|
+
const { sender } = extParams;
|
|
5085
5085
|
const { ixs, metadataId, metadata } = await this.buildCreateTransactionInstructions(data, extParams);
|
|
5086
|
-
const { tx, hash, context } = await prepareTransaction(this.connection, ixs,
|
|
5086
|
+
const { tx, hash, context } = await prepareTransaction(this.connection, ixs, sender.publicKey, void 0, [
|
|
5087
5087
|
metadata
|
|
5088
5088
|
]);
|
|
5089
5089
|
return {
|
|
@@ -5103,12 +5103,10 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5103
5103
|
*/
|
|
5104
5104
|
async create(data, extParams) {
|
|
5105
5105
|
const { sender } = extParams;
|
|
5106
|
-
|
|
5107
|
-
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
|
|
5108
|
-
}
|
|
5106
|
+
assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
|
|
5109
5107
|
const { ixs, metadataId, metadata } = await this.buildCreateTransactionInstructions(data, {
|
|
5110
5108
|
...extParams,
|
|
5111
|
-
|
|
5109
|
+
sender
|
|
5112
5110
|
});
|
|
5113
5111
|
const { tx, hash, context } = await prepareTransaction(this.connection, ixs, sender.publicKey, void 0, [
|
|
5114
5112
|
metadata
|
|
@@ -5161,19 +5159,13 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5161
5159
|
floorPrice
|
|
5162
5160
|
} = streamParams;
|
|
5163
5161
|
const { isNative, sender, computeLimit, computePrice, metadataPubKeys } = extParams;
|
|
5164
|
-
|
|
5165
|
-
|
|
5166
|
-
}
|
|
5167
|
-
if (!priceOracle && oracleType && oracleType !== "none") {
|
|
5168
|
-
throw new Error("Price oracle is required for the specified oracle type");
|
|
5169
|
-
}
|
|
5162
|
+
invariant(!priceOracle && oracleType && oracleType !== "none", "Price oracle is required for the specified oracle type");
|
|
5163
|
+
assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
|
|
5170
5164
|
const recipientPublicKey = new PublicKey(recipient);
|
|
5171
5165
|
const mintPublicKey = isNative ? NATIVE_MINT : new PublicKey(mint);
|
|
5172
5166
|
const metadata = !metadataPubKeys ? Keypair.generate() : void 0;
|
|
5173
5167
|
const metadataPubKey = metadata ? metadata.publicKey : metadataPubKeys[0];
|
|
5174
|
-
|
|
5175
|
-
throw new Error("Metadata public key is required");
|
|
5176
|
-
}
|
|
5168
|
+
invariant(metadataPubKey, "Metadata public key is required");
|
|
5177
5169
|
let tokenProgramId = streamTokenProgramId ? new PublicKey(streamTokenProgramId) : void 0;
|
|
5178
5170
|
if (!tokenProgramId) {
|
|
5179
5171
|
tokenProgramId = (await getMintAndProgram(this.connection, mintPublicKey)).tokenProgramId;
|
|
@@ -5186,9 +5178,11 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5186
5178
|
computePrice,
|
|
5187
5179
|
computeLimit: computeLimit ?? ALIGNED_COMPUTE_LIMIT
|
|
5188
5180
|
});
|
|
5189
|
-
|
|
5190
|
-
|
|
5191
|
-
|
|
5181
|
+
if (recipientPublicKey.toString() !== sender.toString() || !isNative) {
|
|
5182
|
+
ixs.push(
|
|
5183
|
+
...await this.getCreateATAInstructions([recipientPublicKey], mintPublicKey, sender, true, tokenProgramId)
|
|
5184
|
+
);
|
|
5185
|
+
}
|
|
5192
5186
|
const encodedUIntArray = new TextEncoder().encode(streamName);
|
|
5193
5187
|
const streamNameArray = Array.from(encodedUIntArray);
|
|
5194
5188
|
const createIx = await this.alignedProxyProgram.methods.create({
|
|
@@ -5235,7 +5229,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5235
5229
|
* Creates a new stream/vesting contract.
|
|
5236
5230
|
* 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
5231
|
* @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
|
|
5238
|
-
* @param {
|
|
5232
|
+
* @param {IPrepareCreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
|
|
5239
5233
|
* @returns Create stream instructions
|
|
5240
5234
|
*/
|
|
5241
5235
|
async prepareCreateStreamInstructions({
|
|
@@ -5260,9 +5254,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5260
5254
|
partner,
|
|
5261
5255
|
tokenProgramId: streamTokenProgramId
|
|
5262
5256
|
}, { sender, metadataPubKeys, isNative = false, computePrice, computeLimit }) {
|
|
5263
|
-
|
|
5264
|
-
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
|
|
5265
|
-
}
|
|
5257
|
+
assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
|
|
5266
5258
|
const ixs = prepareBaseInstructions(this.connection, {
|
|
5267
5259
|
computePrice,
|
|
5268
5260
|
computeLimit
|
|
@@ -5342,7 +5334,10 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5342
5334
|
* @returns Create result
|
|
5343
5335
|
*/
|
|
5344
5336
|
async createUnchecked(data, extParams) {
|
|
5345
|
-
const { ixs, metadata, metadataPubKey } = await this.prepareCreateUncheckedInstructions(
|
|
5337
|
+
const { ixs, metadata, metadataPubKey } = await this.prepareCreateUncheckedInstructions(
|
|
5338
|
+
data,
|
|
5339
|
+
extParams
|
|
5340
|
+
);
|
|
5346
5341
|
const { tx, hash, context } = await prepareTransaction(
|
|
5347
5342
|
this.connection,
|
|
5348
5343
|
ixs,
|
|
@@ -5387,9 +5382,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5387
5382
|
withdrawalFrequency = 0,
|
|
5388
5383
|
partner
|
|
5389
5384
|
}, { sender, metadataPubKeys, isNative = false, computePrice, computeLimit }) {
|
|
5390
|
-
|
|
5391
|
-
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
|
|
5392
|
-
}
|
|
5385
|
+
assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
|
|
5393
5386
|
const mintPublicKey = new PublicKey(mint);
|
|
5394
5387
|
const recipientPublicKey = new PublicKey(recipient);
|
|
5395
5388
|
const { metadata, metadataPubKey } = this.getOrCreateStreamMetadata(metadataPubKeys);
|
|
@@ -5398,7 +5391,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5398
5391
|
programId: this.programId,
|
|
5399
5392
|
space: METADATA_ACC_SIZE,
|
|
5400
5393
|
lamports: rentToExempt,
|
|
5401
|
-
fromPubkey: sender
|
|
5394
|
+
fromPubkey: sender.publicKey,
|
|
5402
5395
|
newAccountPubkey: metadataPubKey
|
|
5403
5396
|
});
|
|
5404
5397
|
const [escrowTokens] = PublicKey.findProgramAddressSync(
|
|
@@ -5460,12 +5453,13 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5460
5453
|
* Builds transaction instructions for creating multiple stream/vesting contracts without creating transactions.
|
|
5461
5454
|
* 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
5455
|
* @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
|
|
5463
|
-
* @param {
|
|
5456
|
+
* @param {IPrepareCreateStreamSolanaExt} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
|
|
5464
5457
|
* @returns Create multiple transaction instructions
|
|
5465
5458
|
*/
|
|
5466
5459
|
async buildCreateMultipleTransactionInstructions(data, extParams) {
|
|
5467
5460
|
const { recipients, ...streamParams } = data;
|
|
5468
|
-
const {
|
|
5461
|
+
const { sender, metadataPubKeys: metadataPubKeysExt, isNative, customInstructions } = extParams;
|
|
5462
|
+
assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
|
|
5469
5463
|
const metadatas = [];
|
|
5470
5464
|
const metadataToRecipient = {};
|
|
5471
5465
|
const instructionsBatch = [];
|
|
@@ -5475,12 +5469,10 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5475
5469
|
if (recipients.length === 0) {
|
|
5476
5470
|
throw new Error("Recipients array is empty!");
|
|
5477
5471
|
}
|
|
5478
|
-
const tempSender = { publicKey: senderPublicKey };
|
|
5479
5472
|
for (let i = 0; i < recipients.length; i++) {
|
|
5480
5473
|
const recipientData = recipients[i];
|
|
5481
5474
|
const createStreamData = { ...streamParams, ...recipientData };
|
|
5482
5475
|
const createStreamExtParams = {
|
|
5483
|
-
sender: tempSender,
|
|
5484
5476
|
metadataPubKeys: metadataPubKeys[i] ? [metadataPubKeys[i]] : void 0,
|
|
5485
5477
|
...extParams
|
|
5486
5478
|
};
|
|
@@ -5500,14 +5492,14 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5500
5492
|
const prepareInstructions = await this.getCreateATAInstructions(
|
|
5501
5493
|
[partnerPublicKey],
|
|
5502
5494
|
mintPublicKey,
|
|
5503
|
-
|
|
5495
|
+
sender,
|
|
5504
5496
|
true
|
|
5505
5497
|
);
|
|
5506
5498
|
if (isNative) {
|
|
5507
5499
|
const totalDepositedAmount = recipients.reduce((acc, recipient) => recipient.amount.add(acc), new BN7(0));
|
|
5508
5500
|
const nativeInstructions = await prepareWrappedAccount(
|
|
5509
5501
|
this.connection,
|
|
5510
|
-
|
|
5502
|
+
sender.publicKey,
|
|
5511
5503
|
totalDepositedAmount
|
|
5512
5504
|
);
|
|
5513
5505
|
prepareInstructions.push(...nativeInstructions);
|
|
@@ -5542,20 +5534,20 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5542
5534
|
* ```
|
|
5543
5535
|
*
|
|
5544
5536
|
* @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
|
|
5545
|
-
* @param {
|
|
5537
|
+
* @param {IPrepareCreateStreamSolanaExt} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
|
|
5546
5538
|
* @returns Multiple transaction information
|
|
5547
5539
|
*/
|
|
5548
5540
|
async buildCreateMultipleTransactions(data, extParams) {
|
|
5549
|
-
const {
|
|
5541
|
+
const { sender } = extParams;
|
|
5550
5542
|
const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, extParams);
|
|
5551
5543
|
const { value: hash, context } = await this.connection.getLatestBlockhashAndContext();
|
|
5552
5544
|
const batch = [];
|
|
5553
5545
|
for (const { ixs, metadata, recipient } of instructionsBatch) {
|
|
5554
|
-
batch.push({ tx: createVersionedTransaction(ixs,
|
|
5546
|
+
batch.push({ tx: createVersionedTransaction(ixs, sender.publicKey, hash.blockhash, [metadata]), recipient });
|
|
5555
5547
|
}
|
|
5556
5548
|
let prepareTx;
|
|
5557
5549
|
if (prepareInstructions.length > 0) {
|
|
5558
|
-
prepareTx = createVersionedTransaction(prepareInstructions,
|
|
5550
|
+
prepareTx = createVersionedTransaction(prepareInstructions, sender.publicKey, hash.blockhash);
|
|
5559
5551
|
}
|
|
5560
5552
|
return {
|
|
5561
5553
|
transactions: batch,
|
|
@@ -5578,10 +5570,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5578
5570
|
if (!sender.publicKey) {
|
|
5579
5571
|
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
|
|
5580
5572
|
}
|
|
5581
|
-
const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data,
|
|
5582
|
-
...extParams,
|
|
5583
|
-
senderPublicKey: sender.publicKey
|
|
5584
|
-
});
|
|
5573
|
+
const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, extParams);
|
|
5585
5574
|
const errors = [];
|
|
5586
5575
|
const signatures = [];
|
|
5587
5576
|
const metadataPubKeys = metadataPubKeysExt || [];
|
|
@@ -5646,10 +5635,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5646
5635
|
if (!sender.publicKey) {
|
|
5647
5636
|
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
|
|
5648
5637
|
}
|
|
5649
|
-
const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data,
|
|
5650
|
-
...extParams,
|
|
5651
|
-
senderPublicKey: sender.publicKey
|
|
5652
|
-
});
|
|
5638
|
+
const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, extParams);
|
|
5653
5639
|
const errors = [];
|
|
5654
5640
|
const signatures = [];
|
|
5655
5641
|
const batch = [];
|
|
@@ -5712,10 +5698,11 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5712
5698
|
*/
|
|
5713
5699
|
async withdraw({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, extParams) {
|
|
5714
5700
|
const { invoker, customInstructions } = extParams;
|
|
5715
|
-
|
|
5716
|
-
|
|
5717
|
-
|
|
5718
|
-
|
|
5701
|
+
assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
5702
|
+
const ixs = await this.prepareWithdrawInstructions(
|
|
5703
|
+
{ id, amount },
|
|
5704
|
+
extParams
|
|
5705
|
+
);
|
|
5719
5706
|
const metadata = new PublicKey(id);
|
|
5720
5707
|
await this.applyCustomAfterInstructions(ixs, customInstructions, metadata);
|
|
5721
5708
|
const { tx, hash, context } = await prepareTransaction(this.connection, ixs, invoker.publicKey);
|
|
@@ -5735,22 +5722,18 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5735
5722
|
/**
|
|
5736
5723
|
* Creates Transaction Instructions for withdrawal
|
|
5737
5724
|
* @param {IWithdrawData} withdrawData - Withdrawal parameters including stream ID and amount to withdraw
|
|
5738
|
-
* @param {
|
|
5725
|
+
* @param {IPrepareStreamSolanaExt} extParams - Transaction configuration including invoker wallet address, token account validation, and compute settings
|
|
5739
5726
|
* @returns Transaction instructions
|
|
5740
5727
|
*/
|
|
5741
5728
|
async prepareWithdrawInstructions({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
|
|
5742
|
-
|
|
5743
|
-
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
5744
|
-
}
|
|
5729
|
+
assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
5745
5730
|
const ixs = prepareBaseInstructions(this.connection, {
|
|
5746
5731
|
computePrice,
|
|
5747
5732
|
computeLimit
|
|
5748
5733
|
});
|
|
5749
5734
|
const streamPublicKey = new PublicKey(id);
|
|
5750
5735
|
const escrow = await this.connection.getAccountInfo(streamPublicKey);
|
|
5751
|
-
|
|
5752
|
-
throw new Error("Couldn't get account info");
|
|
5753
|
-
}
|
|
5736
|
+
invariant(escrow?.data, "Couldn't get account info");
|
|
5754
5737
|
const data = decodeStream(escrow.data);
|
|
5755
5738
|
const { sender, recipient, mint, streamflowTreasury, partner, recipientTokens, escrowTokens } = data;
|
|
5756
5739
|
const { tokenProgramId } = await getMintAndProgram(this.connection, mint);
|
|
@@ -5806,7 +5789,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5806
5789
|
/**
|
|
5807
5790
|
* Creates Transaction Instructions for cancel
|
|
5808
5791
|
* @param {ICancelData} cancelData - Cancellation parameters including stream ID
|
|
5809
|
-
* @param {
|
|
5792
|
+
* @param {IPrepareStreamSolanaExt} extParams - Transaction configuration including invoker wallet address, token account validation, and compute settings
|
|
5810
5793
|
* @returns Transaction instructions
|
|
5811
5794
|
*/
|
|
5812
5795
|
async prepareCancelInstructions(cancelData, extParams) {
|
|
@@ -5823,18 +5806,14 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5823
5806
|
/**
|
|
5824
5807
|
* Creates Transaction Instructions for cancel
|
|
5825
5808
|
* @param {ICancelData} cancelData - Cancellation parameters including stream ID
|
|
5826
|
-
* @param {
|
|
5809
|
+
* @param {IPrepareStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
|
|
5827
5810
|
* @returns Transaction instructions
|
|
5828
5811
|
*/
|
|
5829
5812
|
async prepareCancelAlignedUnlockInstructions({ id }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
|
|
5830
|
-
|
|
5831
|
-
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
5832
|
-
}
|
|
5813
|
+
assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
5833
5814
|
const streamPublicKey = new PublicKey(id);
|
|
5834
5815
|
const escrowAcc = await this.connection.getAccountInfo(streamPublicKey);
|
|
5835
|
-
|
|
5836
|
-
throw new Error("Couldn't get account info");
|
|
5837
|
-
}
|
|
5816
|
+
invariant(escrowAcc?.data, "Couldn't get account info");
|
|
5838
5817
|
const streamData = decodeStream(escrowAcc.data);
|
|
5839
5818
|
const { sender, recipient, mint, streamflowTreasury, partner, escrowTokens } = streamData;
|
|
5840
5819
|
const { tokenProgramId } = await getMintAndProgram(this.connection, mint);
|
|
@@ -5866,18 +5845,14 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5866
5845
|
/**
|
|
5867
5846
|
* Creates Transaction Instructions for cancel
|
|
5868
5847
|
* @param {ICancelData} cancelData - Cancellation parameters including stream ID
|
|
5869
|
-
* @param {
|
|
5848
|
+
* @param {IPrepareStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
|
|
5870
5849
|
* @returns Transaction instructions
|
|
5871
5850
|
*/
|
|
5872
5851
|
async prepareCancelStreamInstructions({ id }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
|
|
5873
|
-
|
|
5874
|
-
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
5875
|
-
}
|
|
5852
|
+
assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
5876
5853
|
const streamPublicKey = new PublicKey(id);
|
|
5877
5854
|
const escrowAcc = await this.connection.getAccountInfo(streamPublicKey);
|
|
5878
|
-
|
|
5879
|
-
throw new Error("Couldn't get account info");
|
|
5880
|
-
}
|
|
5855
|
+
invariant(escrowAcc?.data, "Couldn't get account info");
|
|
5881
5856
|
const data = decodeStream(escrowAcc.data);
|
|
5882
5857
|
const { sender, recipient, partner, streamflowTreasury, mint, senderTokens, recipientTokens, escrowTokens } = data;
|
|
5883
5858
|
const { tokenProgramId } = await getMintAndProgram(this.connection, mint);
|
|
@@ -5941,13 +5916,11 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5941
5916
|
* Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
|
|
5942
5917
|
* Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
|
|
5943
5918
|
* @param {ITransferData} transferData - Transfer parameters including stream ID and new recipient address
|
|
5944
|
-
* @param {
|
|
5919
|
+
* @param {IPrepareStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
|
|
5945
5920
|
* @returns Transaction instructions
|
|
5946
5921
|
*/
|
|
5947
5922
|
async prepareTransferInstructions({ id, newRecipient }, { invoker, computePrice, computeLimit = 100001 }) {
|
|
5948
|
-
|
|
5949
|
-
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
5950
|
-
}
|
|
5923
|
+
assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
5951
5924
|
const ixs = prepareBaseInstructions(this.connection, {
|
|
5952
5925
|
computePrice,
|
|
5953
5926
|
computeLimit
|
|
@@ -5955,9 +5928,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5955
5928
|
const stream = new PublicKey(id);
|
|
5956
5929
|
const newRecipientPublicKey = new PublicKey(newRecipient);
|
|
5957
5930
|
const escrow = await this.connection.getAccountInfo(stream);
|
|
5958
|
-
|
|
5959
|
-
throw new Error("Couldn't get account info");
|
|
5960
|
-
}
|
|
5931
|
+
invariant(escrow?.data, "Couldn't get account info");
|
|
5961
5932
|
const { mint } = decodeStream(escrow?.data);
|
|
5962
5933
|
const { tokenProgramId } = await getMintAndProgram(this.connection, mint);
|
|
5963
5934
|
const newRecipientTokens = await ata(mint, newRecipientPublicKey, tokenProgramId);
|
|
@@ -6193,6 +6164,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
6193
6164
|
* @returns Transaction result
|
|
6194
6165
|
*/
|
|
6195
6166
|
async update(data, extParams) {
|
|
6167
|
+
if (!extParams.invoker.publicKey) {
|
|
6168
|
+
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
6169
|
+
}
|
|
6196
6170
|
const ixs = await this.prepareUpdateInstructions(data, extParams);
|
|
6197
6171
|
const { tx, hash, context } = await prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
|
|
6198
6172
|
const signature = await signAndExecuteTransaction(
|
|
@@ -6214,18 +6188,14 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
6214
6188
|
/**
|
|
6215
6189
|
* Create Transaction instructions for update
|
|
6216
6190
|
* @param {IUpdateData} data - Update parameters including stream ID and new settings
|
|
6217
|
-
* @param {
|
|
6191
|
+
* @param {IPrepareStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
|
|
6218
6192
|
* @returns Transaction instructions
|
|
6219
6193
|
*/
|
|
6220
6194
|
async prepareUpdateInstructions(data, { invoker, computePrice, computeLimit }) {
|
|
6221
|
-
|
|
6222
|
-
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
6223
|
-
}
|
|
6195
|
+
assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
6224
6196
|
const streamPublicKey = new PublicKey(data.id);
|
|
6225
6197
|
const escrow = await this.connection.getAccountInfo(streamPublicKey);
|
|
6226
|
-
|
|
6227
|
-
throw new Error("Couldn't get account info");
|
|
6228
|
-
}
|
|
6198
|
+
invariant(escrow, "Couldn't get account info");
|
|
6229
6199
|
const ixs = prepareBaseInstructions(this.connection, {
|
|
6230
6200
|
computePrice,
|
|
6231
6201
|
computeLimit
|