@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.
@@ -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-Cu0If4Dd.js';
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-CroMeFk7.js';
2
2
  import '@solana/wallet-adapter-base';
3
3
  import '@solana/web3.js';
4
4
  import '@streamflow/common';
@@ -986,25 +986,29 @@ var transferStreamInstruction = async (programId, {
986
986
  data
987
987
  });
988
988
  };
989
- var requestCancelStreamInstruction = async (programId, { authority, metadata }) => {
990
- const keys = [
991
- { pubkey: authority, isSigner: true, isWritable: false },
992
- { pubkey: metadata, isSigner: false, isWritable: true }
993
- ];
994
- const data = Buffer.concat([Buffer.from(await sha256.digest("global:request_cancel")).slice(0, 8), Buffer.alloc(10)]);
995
- return new TransactionInstruction({
996
- keys,
997
- programId,
998
- data
999
- });
1000
- };
1001
- var withdrawCancelRequestInstruction = async (programId, { authority, metadata }) => {
989
+ var claimRoutedFeeStreamInstruction = async (destination, programId, {
990
+ authority,
991
+ metadata,
992
+ escrowTokens,
993
+ streamflowTreasury,
994
+ streamflowTreasuryTokens,
995
+ senderTokens,
996
+ mint,
997
+ tokenProgram
998
+ }) => {
1002
999
  const keys = [
1003
1000
  { pubkey: authority, isSigner: true, isWritable: false },
1004
- { pubkey: metadata, isSigner: false, isWritable: true }
1001
+ { pubkey: metadata, isSigner: false, isWritable: true },
1002
+ { pubkey: escrowTokens, isSigner: false, isWritable: true },
1003
+ { pubkey: streamflowTreasury, isSigner: false, isWritable: true },
1004
+ { pubkey: streamflowTreasuryTokens, isSigner: false, isWritable: true },
1005
+ { pubkey: senderTokens, isSigner: false, isWritable: true },
1006
+ { pubkey: mint, isSigner: false, isWritable: true },
1007
+ { pubkey: tokenProgram, isSigner: false, isWritable: false }
1005
1008
  ];
1006
1009
  const data = Buffer.concat([
1007
- Buffer.from(await sha256.digest("global:withdraw_cancel_request")).slice(0, 8),
1010
+ Buffer.from(await sha256.digest("global:claim_routed_fee")).slice(0, 8),
1011
+ Buffer.from([destination === "treasury" ? 0 : 1]),
1008
1012
  Buffer.alloc(10)
1009
1013
  ]);
1010
1014
  return new TransactionInstruction({
@@ -4243,13 +4247,13 @@ var SolanaStreamClient = class {
4243
4247
  return ixs;
4244
4248
  }
4245
4249
  /**
4246
- * Requests cancellation of a stream by the fee partner authority.
4247
- * @param {IRequestCancelData} data - Request cancel parameters including stream ID
4250
+ * Claims routed fee from the stream and routes it to the requested destination.
4251
+ * @param {IClaimRoutedFeeData} data - Routed fee claim parameters including stream ID and destination
4248
4252
  * @param {IInteractStreamExt} extParams - Transaction configuration including invoker wallet and compute settings
4249
4253
  * @returns Transaction result
4250
4254
  */
4251
- async requestCancel(data, extParams) {
4252
- const ixs = await this.prepareRequestCancelInstructions(data, extParams);
4255
+ async claimRoutedFee(data, extParams) {
4256
+ const ixs = await this.prepareClaimRoutedFeeInstructions(data, extParams);
4253
4257
  const { tx, hash, context } = await prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
4254
4258
  const signature = await signAndExecuteTransaction(
4255
4259
  this.connection,
@@ -4265,65 +4269,51 @@ var SolanaStreamClient = class {
4265
4269
  return { ixs, txId: signature };
4266
4270
  }
4267
4271
  /**
4268
- * Creates Transaction Instructions for request_cancel
4269
- * @param {IRequestCancelData} data - Request cancel parameters including stream ID
4272
+ * Creates transaction instructions for claim_routed_fee.
4273
+ * @param {IClaimRoutedFeeData} data - Routed fee claim parameters including stream ID and destination
4270
4274
  * @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet and compute settings
4271
4275
  * @returns Transaction instructions
4272
4276
  */
4273
- async prepareRequestCancelInstructions({ id }, { invoker, computePrice, computeLimit }) {
4277
+ async prepareClaimRoutedFeeInstructions({ id, destination }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
4274
4278
  assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
4275
4279
  const ixs = prepareBaseInstructions(this.connection, {
4276
4280
  computePrice,
4277
4281
  computeLimit
4278
4282
  });
4279
- ixs.push(
4280
- await requestCancelStreamInstruction(this.programId, {
4281
- authority: invoker.publicKey,
4282
- metadata: new PublicKey(id)
4283
- })
4284
- );
4285
- return ixs;
4286
- }
4287
- /**
4288
- * Withdraws a previously submitted cancel request.
4289
- * @param {IWithdrawCancelRequestData} data - Withdraw cancel request parameters including stream ID
4290
- * @param {IInteractStreamExt} extParams - Transaction configuration including invoker wallet and compute settings
4291
- * @returns Transaction result
4292
- */
4293
- async withdrawCancelRequest(data, extParams) {
4294
- const ixs = await this.prepareWithdrawCancelRequestInstructions(data, extParams);
4295
- const { tx, hash, context } = await prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
4296
- const signature = await signAndExecuteTransaction(
4297
- this.connection,
4298
- extParams.invoker,
4299
- tx,
4300
- {
4301
- hash,
4302
- context,
4303
- commitment: this.getCommitment()
4304
- },
4305
- this.schedulingParams
4283
+ const streamPublicKey = new PublicKey(id);
4284
+ const streamAccount = await this.connection.getAccountInfo(streamPublicKey);
4285
+ invariant(streamAccount?.data, "Couldn't get account info");
4286
+ const { sender, mint, escrowTokens } = decodeStream(streamAccount.data);
4287
+ const { mint: mintAccount, tokenProgramId } = await getMintAndProgram(this.connection, mint);
4288
+ const streamflowTreasuryTokens = await ata(mint, STREAMFLOW_TREASURY_PUBLIC_KEY, tokenProgramId);
4289
+ const senderTokens = await ata(mint, sender, tokenProgramId);
4290
+ const ataIxs = await this.getCreateATAInstructions(
4291
+ [sender, STREAMFLOW_TREASURY_PUBLIC_KEY],
4292
+ mint,
4293
+ invoker,
4294
+ checkTokenAccounts,
4295
+ tokenProgramId
4306
4296
  );
4307
- return { ixs, txId: signature };
4308
- }
4309
- /**
4310
- * Creates Transaction Instructions for withdraw_cancel_request
4311
- * @param {IWithdrawCancelRequestData} data - Withdraw cancel request parameters including stream ID
4312
- * @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet and compute settings
4313
- * @returns Transaction instructions
4314
- */
4315
- async prepareWithdrawCancelRequestInstructions({ id }, { invoker, computePrice, computeLimit }) {
4316
- assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
4317
- const ixs = prepareBaseInstructions(this.connection, {
4318
- computePrice,
4319
- computeLimit
4297
+ const claimRoutedFeeIx = await claimRoutedFeeStreamInstruction(destination, this.programId, {
4298
+ authority: invoker.publicKey,
4299
+ metadata: streamPublicKey,
4300
+ escrowTokens,
4301
+ streamflowTreasury: STREAMFLOW_TREASURY_PUBLIC_KEY,
4302
+ streamflowTreasuryTokens,
4303
+ senderTokens,
4304
+ mint,
4305
+ tokenProgram: tokenProgramId
4320
4306
  });
4321
- ixs.push(
4322
- await withdrawCancelRequestInstruction(this.programId, {
4323
- authority: invoker.publicKey,
4324
- metadata: new PublicKey(id)
4325
- })
4326
- );
4307
+ await this.addTransferHookAccounts(claimRoutedFeeIx, {
4308
+ mint,
4309
+ mintAccount,
4310
+ tokenProgramId,
4311
+ potentialTransfers: [
4312
+ { source: escrowTokens, destination: streamflowTreasuryTokens, owner: escrowTokens },
4313
+ { source: escrowTokens, destination: senderTokens, owner: escrowTokens }
4314
+ ]
4315
+ });
4316
+ ixs.push(...ataIxs, claimRoutedFeeIx);
4327
4317
  return ixs;
4328
4318
  }
4329
4319
  /**