@streamflow/stream 12.5.0 → 13.0.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.
@@ -1,4 +1,4 @@
1
- export { k as BatchCreationItem, l as BatchExecuteResult, m as BatchInstructionResult, p as BuildTransactionFn, q as BuildTransactionOptions, r as BuiltTransaction, C as CancelFn, w as CreateBatchFn, x as CreateFn, y as CreateInstructionResult, F as Env, G as ExecuteBatchFn, H as ExecuteBatchSequentialFn, J as ExecuteFn, K as ExecutionEnv, Q as ICreateLockBatchParams, R as ICreateLockParams, _ as ICreateVestingBatchParams, $ as ICreateVestingParams, a6 as ILockBatchRecipient, ai as IVestingBatchRecipient, am as InstructionResult, an as Invoker, aq as NativeOptions, at as SignFn, az as TopupFn, aB as TransferFn, aC as UpdateFn, aE as WithdrawFn, aF as buildLockBatchParams, aG as buildLockParams, aH as buildTransaction, aI as buildVestingBatchParams, aJ as buildVestingParams, aK as cancel, aL as computeAmountPerPeriod, aM as create, aN as createBatch, aO as createClientFromEnv, aP as createLock, aQ as createLockBatch, aR as createVesting, aS as createVestingBatch, aT as execute, aU as executeBatch, aV as executeBatchSequential, aW as resolveConnection, aX as resolveDuration, aY as sign, aZ as topup, a_ as transfer, a$ as update, b0 as withdraw } from '../../index-CjMTLhxa.cjs';
1
+ export { k as BatchCreationItem, l as BatchExecuteResult, m as BatchInstructionResult, p as BuildTransactionFn, q as BuildTransactionOptions, r as BuiltTransaction, C as CancelFn, w as CreateBatchFn, x as CreateFn, y as CreateInstructionResult, F as Env, G as ExecuteBatchFn, H as ExecuteBatchSequentialFn, J as ExecuteFn, K as ExecutionEnv, T as ICreateLockBatchParams, U as ICreateLockParams, a0 as ICreateVestingBatchParams, a1 as ICreateVestingParams, a8 as ILockBatchRecipient, aj as IVestingBatchRecipient, am as InstructionResult, an as Invoker, aq as NativeOptions, at as SignFn, az as TopupFn, aB as TransferFn, aC as UpdateFn, aE as WithdrawFn, aF as buildLockBatchParams, aG as buildLockParams, aH as buildTransaction, aI as buildVestingBatchParams, aJ as buildVestingParams, aK as cancel, aL as computeAmountPerPeriod, aM as create, aN as createBatch, aO as createClientFromEnv, aP as createLock, aQ as createLockBatch, aR as createVesting, aS as createVestingBatch, aT as execute, aU as executeBatch, aV as executeBatchSequential, aW as resolveConnection, aX as resolveDuration, aY as sign, aZ as topup, a_ as transfer, a$ as update, b0 as withdraw } from '../../index-80Zw9SxQ.cjs';
2
2
  import '@solana/wallet-adapter-base';
3
3
  import '@solana/web3.js';
4
4
  import '@streamflow/common';
@@ -1097,25 +1097,29 @@ var transferStreamInstruction = async (programId, {
1097
1097
  data
1098
1098
  });
1099
1099
  };
1100
- var requestCancelStreamInstruction = async (programId, { authority, metadata }) => {
1101
- const keys = [
1102
- { pubkey: authority, isSigner: true, isWritable: false },
1103
- { pubkey: metadata, isSigner: false, isWritable: true }
1104
- ];
1105
- const data = buffer.Buffer.concat([buffer.Buffer.from(await sha256.digest("global:request_cancel")).slice(0, 8), buffer.Buffer.alloc(10)]);
1106
- return new web3_js.TransactionInstruction({
1107
- keys,
1108
- programId,
1109
- data
1110
- });
1111
- };
1112
- var withdrawCancelRequestInstruction = async (programId, { authority, metadata }) => {
1100
+ var claimRoutedFeeStreamInstruction = async (destination, programId, {
1101
+ authority,
1102
+ metadata,
1103
+ escrowTokens,
1104
+ streamflowTreasury,
1105
+ streamflowTreasuryTokens,
1106
+ senderTokens,
1107
+ mint,
1108
+ tokenProgram
1109
+ }) => {
1113
1110
  const keys = [
1114
1111
  { pubkey: authority, isSigner: true, isWritable: false },
1115
- { pubkey: metadata, isSigner: false, isWritable: true }
1112
+ { pubkey: metadata, isSigner: false, isWritable: true },
1113
+ { pubkey: escrowTokens, isSigner: false, isWritable: true },
1114
+ { pubkey: streamflowTreasury, isSigner: false, isWritable: true },
1115
+ { pubkey: streamflowTreasuryTokens, isSigner: false, isWritable: true },
1116
+ { pubkey: senderTokens, isSigner: false, isWritable: true },
1117
+ { pubkey: mint, isSigner: false, isWritable: true },
1118
+ { pubkey: tokenProgram, isSigner: false, isWritable: false }
1116
1119
  ];
1117
1120
  const data = buffer.Buffer.concat([
1118
- buffer.Buffer.from(await sha256.digest("global:withdraw_cancel_request")).slice(0, 8),
1121
+ buffer.Buffer.from(await sha256.digest("global:claim_routed_fee")).slice(0, 8),
1122
+ buffer.Buffer.from([destination === "treasury" ? 0 : 1]),
1119
1123
  buffer.Buffer.alloc(10)
1120
1124
  ]);
1121
1125
  return new web3_js.TransactionInstruction({
@@ -4357,13 +4361,13 @@ var SolanaStreamClient = class {
4357
4361
  return ixs;
4358
4362
  }
4359
4363
  /**
4360
- * Requests cancellation of a stream by the fee partner authority.
4361
- * @param {IRequestCancelData} data - Request cancel parameters including stream ID
4364
+ * Claims routed fee from the stream and routes it to the requested destination.
4365
+ * @param {IClaimRoutedFeeData} data - Routed fee claim parameters including stream ID and destination
4362
4366
  * @param {IInteractStreamExt} extParams - Transaction configuration including invoker wallet and compute settings
4363
4367
  * @returns Transaction result
4364
4368
  */
4365
- async requestCancel(data, extParams) {
4366
- const ixs = await this.prepareRequestCancelInstructions(data, extParams);
4369
+ async claimRoutedFee(data, extParams) {
4370
+ const ixs = await this.prepareClaimRoutedFeeInstructions(data, extParams);
4367
4371
  const { tx, hash, context } = await common.prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
4368
4372
  const signature = await common.signAndExecuteTransaction(
4369
4373
  this.connection,
@@ -4379,65 +4383,51 @@ var SolanaStreamClient = class {
4379
4383
  return { ixs, txId: signature };
4380
4384
  }
4381
4385
  /**
4382
- * Creates Transaction Instructions for request_cancel
4383
- * @param {IRequestCancelData} data - Request cancel parameters including stream ID
4386
+ * Creates transaction instructions for claim_routed_fee.
4387
+ * @param {IClaimRoutedFeeData} data - Routed fee claim parameters including stream ID and destination
4384
4388
  * @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet and compute settings
4385
4389
  * @returns Transaction instructions
4386
4390
  */
4387
- async prepareRequestCancelInstructions({ id }, { invoker, computePrice, computeLimit }) {
4391
+ async prepareClaimRoutedFeeInstructions({ id, destination }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
4388
4392
  common.assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
4389
4393
  const ixs = common.prepareBaseInstructions(this.connection, {
4390
4394
  computePrice,
4391
4395
  computeLimit
4392
4396
  });
4393
- ixs.push(
4394
- await requestCancelStreamInstruction(this.programId, {
4395
- authority: invoker.publicKey,
4396
- metadata: new web3_js.PublicKey(id)
4397
- })
4398
- );
4399
- return ixs;
4400
- }
4401
- /**
4402
- * Withdraws a previously submitted cancel request.
4403
- * @param {IWithdrawCancelRequestData} data - Withdraw cancel request parameters including stream ID
4404
- * @param {IInteractStreamExt} extParams - Transaction configuration including invoker wallet and compute settings
4405
- * @returns Transaction result
4406
- */
4407
- async withdrawCancelRequest(data, extParams) {
4408
- const ixs = await this.prepareWithdrawCancelRequestInstructions(data, extParams);
4409
- const { tx, hash, context } = await common.prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
4410
- const signature = await common.signAndExecuteTransaction(
4411
- this.connection,
4412
- extParams.invoker,
4413
- tx,
4414
- {
4415
- hash,
4416
- context,
4417
- commitment: this.getCommitment()
4418
- },
4419
- this.schedulingParams
4397
+ const streamPublicKey = new web3_js.PublicKey(id);
4398
+ const streamAccount = await this.connection.getAccountInfo(streamPublicKey);
4399
+ common.invariant(streamAccount?.data, "Couldn't get account info");
4400
+ const { sender, mint, escrowTokens } = decodeStream(streamAccount.data);
4401
+ const { mint: mintAccount, tokenProgramId } = await common.getMintAndProgram(this.connection, mint);
4402
+ const streamflowTreasuryTokens = await common.ata(mint, STREAMFLOW_TREASURY_PUBLIC_KEY, tokenProgramId);
4403
+ const senderTokens = await common.ata(mint, sender, tokenProgramId);
4404
+ const ataIxs = await this.getCreateATAInstructions(
4405
+ [sender, STREAMFLOW_TREASURY_PUBLIC_KEY],
4406
+ mint,
4407
+ invoker,
4408
+ checkTokenAccounts,
4409
+ tokenProgramId
4420
4410
  );
4421
- return { ixs, txId: signature };
4422
- }
4423
- /**
4424
- * Creates Transaction Instructions for withdraw_cancel_request
4425
- * @param {IWithdrawCancelRequestData} data - Withdraw cancel request parameters including stream ID
4426
- * @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet and compute settings
4427
- * @returns Transaction instructions
4428
- */
4429
- async prepareWithdrawCancelRequestInstructions({ id }, { invoker, computePrice, computeLimit }) {
4430
- common.assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
4431
- const ixs = common.prepareBaseInstructions(this.connection, {
4432
- computePrice,
4433
- computeLimit
4411
+ const claimRoutedFeeIx = await claimRoutedFeeStreamInstruction(destination, this.programId, {
4412
+ authority: invoker.publicKey,
4413
+ metadata: streamPublicKey,
4414
+ escrowTokens,
4415
+ streamflowTreasury: STREAMFLOW_TREASURY_PUBLIC_KEY,
4416
+ streamflowTreasuryTokens,
4417
+ senderTokens,
4418
+ mint,
4419
+ tokenProgram: tokenProgramId
4434
4420
  });
4435
- ixs.push(
4436
- await withdrawCancelRequestInstruction(this.programId, {
4437
- authority: invoker.publicKey,
4438
- metadata: new web3_js.PublicKey(id)
4439
- })
4440
- );
4421
+ await this.addTransferHookAccounts(claimRoutedFeeIx, {
4422
+ mint,
4423
+ mintAccount,
4424
+ tokenProgramId,
4425
+ potentialTransfers: [
4426
+ { source: escrowTokens, destination: streamflowTreasuryTokens, owner: escrowTokens },
4427
+ { source: escrowTokens, destination: senderTokens, owner: escrowTokens }
4428
+ ]
4429
+ });
4430
+ ixs.push(...ataIxs, claimRoutedFeeIx);
4441
4431
  return ixs;
4442
4432
  }
4443
4433
  /**
@@ -5951,6 +5941,7 @@ exports.calculateTotalAmountToDeposit = calculateTotalAmountToDeposit;
5951
5941
  exports.calculateUnlockedAmount = calculateUnlockedAmount;
5952
5942
  exports.cancel = cancel;
5953
5943
  exports.cancelStreamInstruction = cancelStreamInstruction;
5944
+ exports.claimRoutedFeeStreamInstruction = claimRoutedFeeStreamInstruction;
5954
5945
  exports.computeAmountPerPeriod = computeAmountPerPeriod;
5955
5946
  exports.create = create;
5956
5947
  exports.createBatch = createBatch;
@@ -5983,7 +5974,6 @@ exports.isCreateAlignedStreamData = isCreateAlignedStreamData;
5983
5974
  exports.isDynamicLock = isDynamicLock;
5984
5975
  exports.isTokenLock = isTokenLock;
5985
5976
  exports.isVesting = isVesting;
5986
- exports.requestCancelStreamInstruction = requestCancelStreamInstruction;
5987
5977
  exports.resolveConnection = resolveConnection;
5988
5978
  exports.resolveDuration = resolveDuration;
5989
5979
  exports.sendAndConfirmStreamRawTransaction = sendAndConfirmStreamRawTransaction;
@@ -5998,7 +5988,6 @@ exports.transformContract = transformContract;
5998
5988
  exports.update = update;
5999
5989
  exports.updateStreamInstruction = updateStreamInstruction;
6000
5990
  exports.withdraw = withdraw;
6001
- exports.withdrawCancelRequestInstruction = withdrawCancelRequestInstruction;
6002
5991
  exports.withdrawStreamInstruction = withdrawStreamInstruction;
6003
5992
  //# sourceMappingURL=index.cjs.map
6004
5993
  //# sourceMappingURL=index.cjs.map