@streamflow/stream 12.5.0 → 13.1.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.
@@ -71,8 +71,10 @@ interface IUpdateData extends IInteractData {
71
71
  cancelableBySender?: boolean;
72
72
  }
73
73
  type ICancelData = IInteractData;
74
- type IRequestCancelData = IInteractData;
75
- type IWithdrawCancelRequestData = IInteractData;
74
+ type RoutedFeeDestination = "treasury" | "sender";
75
+ interface IClaimRoutedFeeData extends IInteractData {
76
+ destination: RoutedFeeDestination;
77
+ }
76
78
  interface ITransferData extends IInteractData {
77
79
  newRecipient: string;
78
80
  }
@@ -749,33 +751,19 @@ declare class SolanaStreamClient {
749
751
  */
750
752
  prepareCancelLinearStream({ id }: ICancelData, { invoker, checkTokenAccounts, computePrice, computeLimit }: IPrepareStreamExt): Promise<TransactionInstruction[]>;
751
753
  /**
752
- * Requests cancellation of a stream by the fee partner authority.
753
- * @param {IRequestCancelData} data - Request cancel parameters including stream ID
754
- * @param {IInteractStreamExt} extParams - Transaction configuration including invoker wallet and compute settings
755
- * @returns Transaction result
756
- */
757
- requestCancel(data: IRequestCancelData, extParams: IInteractStreamExt): Promise<ITransactionResult>;
758
- /**
759
- * Creates Transaction Instructions for request_cancel
760
- * @param {IRequestCancelData} data - Request cancel parameters including stream ID
761
- * @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet and compute settings
762
- * @returns Transaction instructions
763
- */
764
- prepareRequestCancelInstructions({ id }: IRequestCancelData, { invoker, computePrice, computeLimit }: IPrepareStreamExt): Promise<TransactionInstruction[]>;
765
- /**
766
- * Withdraws a previously submitted cancel request.
767
- * @param {IWithdrawCancelRequestData} data - Withdraw cancel request parameters including stream ID
754
+ * Claims routed fee from the stream and routes it to the requested destination.
755
+ * @param {IClaimRoutedFeeData} data - Routed fee claim parameters including stream ID and destination
768
756
  * @param {IInteractStreamExt} extParams - Transaction configuration including invoker wallet and compute settings
769
757
  * @returns Transaction result
770
758
  */
771
- withdrawCancelRequest(data: IWithdrawCancelRequestData, extParams: IInteractStreamExt): Promise<ITransactionResult>;
759
+ claimRoutedFee(data: IClaimRoutedFeeData, extParams: IInteractStreamExt): Promise<ITransactionResult>;
772
760
  /**
773
- * Creates Transaction Instructions for withdraw_cancel_request
774
- * @param {IWithdrawCancelRequestData} data - Withdraw cancel request parameters including stream ID
761
+ * Creates transaction instructions for claim_routed_fee.
762
+ * @param {IClaimRoutedFeeData} data - Routed fee claim parameters including stream ID and destination
775
763
  * @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet and compute settings
776
764
  * @returns Transaction instructions
777
765
  */
778
- prepareWithdrawCancelRequestInstructions({ id }: IWithdrawCancelRequestData, { invoker, computePrice, computeLimit }: IPrepareStreamExt): Promise<TransactionInstruction[]>;
766
+ prepareClaimRoutedFeeInstructions({ id, destination }: IClaimRoutedFeeData, { invoker, checkTokenAccounts, computePrice, computeLimit }: IPrepareStreamExt): Promise<TransactionInstruction[]>;
779
767
  /**
780
768
  * Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
781
769
  * Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
@@ -1111,4 +1099,4 @@ declare function execute(builtTx: BuiltTransaction, env: ExecutionEnv): Promise<
1111
1099
  declare function executeBatch(builtTransactions: BuiltTransaction[], env: ExecutionEnv): Promise<BatchExecuteResult>;
1112
1100
  declare function executeBatchSequential(builtTransactions: BuiltTransaction[], env: ExecutionEnv): Promise<BatchExecuteResult>;
1113
1101
 
1114
- export { type ICreateVestingParams as $, type AlignedStream as A, type BatchItem as B, type CancelFn as C, type DecodedStream as D, type CreateTestOracleParams as E, type Env as F, type ExecuteBatchFn as G, type ExecuteBatchSequentialFn as H, type IUpdateData as I, type ExecuteFn as J, type ExecutionEnv as K, type IAlignedStreamConfig as L, type IBaseStreamConfig as M, type ICancelData as N, type ICreateExt as O, type ICreateLinearStreamData as P, type ICreateLockBatchParams as Q, type ICreateLockParams as R, StreamType as S, type ICreateMultiError as T, type ICreateMultipleAlignedStreamData as U, type ICreateMultipleLinearStreamData as V, type ICreateMultipleStreamData as W, type ICreateResult as X, type ICreateStreamExt as Y, type ICreateStreamInstructions as Z, type ICreateVestingBatchParams as _, type BatchItemResult as a, update as a$, type IFees as a0, type IGetAllData as a1, type IGetFeesData as a2, type IGetOneData as a3, type IInteractData as a4, type IInteractStreamExt as a5, type ILockBatchRecipient as a6, type IMultiTransactionResult as a7, type IPrepareCreateStreamExt as a8, type IPrepareStreamExt as a9, type TransactionSchedulingOptions as aA, type TransferFn as aB, type UpdateFn as aC, type UpdateTestOracleParams as aD, type WithdrawFn as aE, buildLockBatchParams as aF, buildLockParams as aG, buildTransaction as aH, buildVestingBatchParams as aI, buildVestingParams as aJ, cancel as aK, computeAmountPerPeriod as aL, create as aM, createBatch as aN, createClientFromEnv as aO, createLock as aP, createLockBatch as aQ, createVesting as aR, createVestingBatch as aS, execute as aT, executeBatch as aU, executeBatchSequential as aV, resolveConnection as aW, resolveDuration as aX, sign as aY, topup as aZ, transfer as a_, type IPrepareTopUpstreamExt as aa, type IRecipient as ab, type IRequestCancelData as ac, type ITopUpData as ad, type ITopUpStreamExt as ae, type ITransactionExtWithInstructions as af, type ITransactionResult as ag, type ITransferData as ah, type IVestingBatchRecipient as ai, type IWithdrawCancelRequestData as aj, type IWithdrawData as ak, type InstructionGenerator as al, type InstructionResult as am, type Invoker as an, type LinearStream as ao, type MetadataRecipientHashMap as ap, type NativeOptions as aq, type OracleType as ar, type OracleTypeName as as, type SignFn as at, SolanaStreamClient as au, type StreamClientOptions as av, type StreamClientOptionsWithConnection as aw, StreamDirection as ax, type TestOracle as ay, type TopupFn as az, type Stream as b, withdraw as b0, type ICreateStreamData as c, type ICreateAlignedStreamData as d, type ISearchStreams as e, type Account as f, AlignedContract as g, AlignedProxyErrorCode as h, type AlignedStreamData as i, type AlignedUnlocksContract as j, type BatchCreationItem as k, type BatchExecuteResult as l, type BatchInstructionResult as m, type BatchItemError as n, type BatchItemSuccess as o, type BuildTransactionFn as p, type BuildTransactionOptions as q, type BuiltTransaction as r, type ChangeOracleParams as s, type ClientCreationOptions as t, Contract as u, ContractErrorCode as v, type CreateBatchFn as w, type CreateFn as x, type CreateInstructionResult as y, type CreateParams as z };
1102
+ export { type ICreateStreamInstructions as $, type AlignedStream as A, type BatchItem as B, type CancelFn as C, type DecodedStream as D, type CreateTestOracleParams as E, type Env as F, type ExecuteBatchFn as G, type ExecuteBatchSequentialFn as H, type IUpdateData as I, type ExecuteFn as J, type ExecutionEnv as K, type IAlignedStreamConfig as L, type IBaseStreamConfig as M, type ICancelData as N, type IClaimRoutedFeeData as O, type ICreateExt as P, type ICreateLinearStreamData as Q, type RoutedFeeDestination as R, StreamType as S, type ICreateLockBatchParams as T, type ICreateLockParams as U, type ICreateMultiError as V, type ICreateMultipleAlignedStreamData as W, type ICreateMultipleLinearStreamData as X, type ICreateMultipleStreamData as Y, type ICreateResult as Z, type ICreateStreamExt as _, type BatchItemResult as a, update as a$, type ICreateVestingBatchParams as a0, type ICreateVestingParams as a1, type IFees as a2, type IGetAllData as a3, type IGetFeesData as a4, type IGetOneData as a5, type IInteractData as a6, type IInteractStreamExt as a7, type ILockBatchRecipient as a8, type IMultiTransactionResult as a9, type TransactionSchedulingOptions as aA, type TransferFn as aB, type UpdateFn as aC, type UpdateTestOracleParams as aD, type WithdrawFn as aE, buildLockBatchParams as aF, buildLockParams as aG, buildTransaction as aH, buildVestingBatchParams as aI, buildVestingParams as aJ, cancel as aK, computeAmountPerPeriod as aL, create as aM, createBatch as aN, createClientFromEnv as aO, createLock as aP, createLockBatch as aQ, createVesting as aR, createVestingBatch as aS, execute as aT, executeBatch as aU, executeBatchSequential as aV, resolveConnection as aW, resolveDuration as aX, sign as aY, topup as aZ, transfer as a_, type IPrepareCreateStreamExt as aa, type IPrepareStreamExt as ab, type IPrepareTopUpstreamExt as ac, type IRecipient as ad, type ITopUpData as ae, type ITopUpStreamExt as af, type ITransactionExtWithInstructions as ag, type ITransactionResult as ah, type ITransferData as ai, type IVestingBatchRecipient as aj, type IWithdrawData as ak, type InstructionGenerator as al, type InstructionResult as am, type Invoker as an, type LinearStream as ao, type MetadataRecipientHashMap as ap, type NativeOptions as aq, type OracleType as ar, type OracleTypeName as as, type SignFn as at, SolanaStreamClient as au, type StreamClientOptions as av, type StreamClientOptionsWithConnection as aw, StreamDirection as ax, type TestOracle as ay, type TopupFn as az, type Stream as b, withdraw as b0, type ICreateStreamData as c, type ICreateAlignedStreamData as d, type ISearchStreams as e, type Account as f, AlignedContract as g, AlignedProxyErrorCode as h, type AlignedStreamData as i, type AlignedUnlocksContract as j, type BatchCreationItem as k, type BatchExecuteResult as l, type BatchInstructionResult as m, type BatchItemError as n, type BatchItemSuccess as o, type BuildTransactionFn as p, type BuildTransactionOptions as q, type BuiltTransaction as r, type ChangeOracleParams as s, type ClientCreationOptions as t, Contract as u, ContractErrorCode as v, type CreateBatchFn as w, type CreateFn as x, type CreateInstructionResult as y, type CreateParams as z };
@@ -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