@streamflow/stream 12.5.0-alpha.p366.24de361 → 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,5 +1,5 @@
1
- export { f as Account, g as AlignedContract, h as AlignedProxyErrorCode, A as AlignedStream, i as AlignedStreamData, j as AlignedUnlocksContract, k as BatchCreationItem, l as BatchExecuteResult, m as BatchInstructionResult, B as BatchItem, n as BatchItemError, a as BatchItemResult, o as BatchItemSuccess, p as BuildTransactionFn, q as BuildTransactionOptions, r as BuiltTransaction, C as CancelFn, s as ChangeOracleParams, t as ClientCreationOptions, u as Contract, v as ContractErrorCode, w as CreateBatchFn, x as CreateFn, y as CreateInstructionResult, z as CreateParams, E as CreateTestOracleParams, D as DecodedStream, F as Env, G as ExecuteBatchFn, H as ExecuteBatchSequentialFn, J as ExecuteFn, K as ExecutionEnv, L as IAlignedStreamConfig, M as IBaseStreamConfig, N as ICancelData, d as ICreateAlignedStreamData, O as ICreateExt, P as ICreateLinearStreamData, Q as ICreateLockBatchParams, R as ICreateLockParams, T as ICreateMultiError, U as ICreateMultipleAlignedStreamData, V as ICreateMultipleLinearStreamData, W as ICreateMultipleStreamData, X as ICreateResult, c as ICreateStreamData, Y as ICreateStreamExt, Z as ICreateStreamInstructions, _ as ICreateVestingBatchParams, $ as ICreateVestingParams, a0 as IFees, a1 as IGetAllData, a2 as IGetFeesData, a3 as IGetOneData, a4 as IInteractData, a5 as IInteractStreamExt, a6 as ILockBatchRecipient, a7 as IMultiTransactionResult, a8 as IPrepareCreateStreamExt, a9 as IPrepareStreamExt, aa as IPrepareTopUpstreamExt, ab as IRecipient, ac as IRequestCancelData, e as ISearchStreams, ad as ITopUpData, ae as ITopUpStreamExt, af as ITransactionExtWithInstructions, ag as ITransactionResult, ah as ITransferData, I as IUpdateData, ai as IVestingBatchRecipient, aj as IWithdrawCancelRequestData, ak as IWithdrawData, al as InstructionGenerator, am as InstructionResult, an as Invoker, ao as LinearStream, ap as MetadataRecipientHashMap, aq as NativeOptions, ar as OracleType, as as OracleTypeName, at as SignFn, au as SolanaStreamClient, b as Stream, av as StreamClientOptions, aw as StreamClientOptionsWithConnection, ax as StreamDirection, S as StreamType, ay as TestOracle, az as TopupFn, aA as TransactionSchedulingOptions, aB as TransferFn, aC as UpdateFn, aD as UpdateTestOracleParams, 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';
2
- export { AIRDROP_AMOUNT, AIRDROP_TEST_TOKEN, ALIGNED_COMPUTE_LIMIT, ALIGNED_PRECISION_FACTOR_POW, ALIGNED_UNLOCKS_PROGRAM_ID, ApiClient, ApiClientOptions, CONTRACT_DISCRIMINATOR, CONTRACT_SEED, CREATE_PARAMS_PADDING, Chain, ContractSchema, ContractType, DEFAULT_AUTO_CLAIM_FEE_SOL, DEFAULT_CREATION_FEE_SOL, DEFAULT_STREAMFLOW_FEE, DynamicContractSchema, ESCROW_SEED, FEES_METADATA_SEED, FEE_ORACLE_PUBLIC_KEY, GetContractsOptions, MAX_SAFE_UNIX_TIME_VALUE, METADATA_SEED, ORIGINAL_CONTRACT_SENDER_OFFSET, PARTNERS_SCHEMA, PARTNER_ORACLE_PROGRAM_ID, PARTNER_SCHEMA, PROGRAM_ID, PriceOracleType, REPOPULATED_METADATA_SEED, SOLANA_ERROR_MAP, SOLANA_ERROR_MATCH_REGEX, STREAMFLOW_TREASURY_PUBLIC_KEY, STREAM_STRUCT_OFFSETS, STREAM_STRUCT_OFFSET_CLOSED, STREAM_STRUCT_OFFSET_MINT, STREAM_STRUCT_OFFSET_OLD_METADATA_KEY, STREAM_STRUCT_OFFSET_RECIPIENT, STREAM_STRUCT_OFFSET_SENDER, TEST_ORACLE_DISCRIMINATOR, TEST_ORACLE_SEED, TX_FINALITY_CONFIRMED, TabulariumContract, WITHDRAWOR, WITHDRAWOR_PUBLIC_KEY, WITHDRAW_AVAILABLE_AMOUNT, buildStreamType, calculateTotalAmountToDeposit, calculateUnlockedAmount, cancelStreamInstruction, createClient, createStreamInstruction, createStreamV2Instruction, createUncheckedStreamInstruction, createUncheckedStreamV2Instruction, decodeEndTime, decodeStream, deriveContractPDA, deriveEscrowPDA, deriveRepopulatedMetadataPDA, deriveStreamMetadataPDA, deriveTestOraclePDA, extractSolanaErrorCode, getMetadataKey, handleContractError, isAligned, isCliffCloseToDepositedAmount, isCreateAlignedStreamData, isDynamicLock, isTokenLock, isVesting, requestCancelStreamInstruction, sendAndConfirmStreamRawTransaction, signAllTransactionWithRecipients, timelockIDL, topupStreamInstruction, transferStreamInstruction, transformContract, updateStreamInstruction, withdrawCancelRequestInstruction, withdrawStreamInstruction } from './solana/index.cjs';
1
+ export { f as Account, g as AlignedContract, h as AlignedProxyErrorCode, A as AlignedStream, i as AlignedStreamData, j as AlignedUnlocksContract, k as BatchCreationItem, l as BatchExecuteResult, m as BatchInstructionResult, B as BatchItem, n as BatchItemError, a as BatchItemResult, o as BatchItemSuccess, p as BuildTransactionFn, q as BuildTransactionOptions, r as BuiltTransaction, C as CancelFn, s as ChangeOracleParams, t as ClientCreationOptions, u as Contract, v as ContractErrorCode, w as CreateBatchFn, x as CreateFn, y as CreateInstructionResult, z as CreateParams, E as CreateTestOracleParams, D as DecodedStream, F as Env, G as ExecuteBatchFn, H as ExecuteBatchSequentialFn, J as ExecuteFn, K as ExecutionEnv, L as IAlignedStreamConfig, M as IBaseStreamConfig, N as ICancelData, O as IClaimRoutedFeeData, d as ICreateAlignedStreamData, P as ICreateExt, Q as ICreateLinearStreamData, T as ICreateLockBatchParams, U as ICreateLockParams, V as ICreateMultiError, W as ICreateMultipleAlignedStreamData, X as ICreateMultipleLinearStreamData, Y as ICreateMultipleStreamData, Z as ICreateResult, c as ICreateStreamData, _ as ICreateStreamExt, $ as ICreateStreamInstructions, a0 as ICreateVestingBatchParams, a1 as ICreateVestingParams, a2 as IFees, a3 as IGetAllData, a4 as IGetFeesData, a5 as IGetOneData, a6 as IInteractData, a7 as IInteractStreamExt, a8 as ILockBatchRecipient, a9 as IMultiTransactionResult, aa as IPrepareCreateStreamExt, ab as IPrepareStreamExt, ac as IPrepareTopUpstreamExt, ad as IRecipient, e as ISearchStreams, ae as ITopUpData, af as ITopUpStreamExt, ag as ITransactionExtWithInstructions, ah as ITransactionResult, ai as ITransferData, I as IUpdateData, aj as IVestingBatchRecipient, ak as IWithdrawData, al as InstructionGenerator, am as InstructionResult, an as Invoker, ao as LinearStream, ap as MetadataRecipientHashMap, aq as NativeOptions, ar as OracleType, as as OracleTypeName, R as RoutedFeeDestination, at as SignFn, au as SolanaStreamClient, b as Stream, av as StreamClientOptions, aw as StreamClientOptionsWithConnection, ax as StreamDirection, S as StreamType, ay as TestOracle, az as TopupFn, aA as TransactionSchedulingOptions, aB as TransferFn, aC as UpdateFn, aD as UpdateTestOracleParams, 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
+ export { AIRDROP_AMOUNT, AIRDROP_TEST_TOKEN, ALIGNED_COMPUTE_LIMIT, ALIGNED_PRECISION_FACTOR_POW, ALIGNED_UNLOCKS_PROGRAM_ID, ApiClient, ApiClientOptions, CONTRACT_DISCRIMINATOR, CONTRACT_SEED, CREATE_PARAMS_PADDING, Chain, ContractSchema, ContractType, DEFAULT_AUTO_CLAIM_FEE_SOL, DEFAULT_CREATION_FEE_SOL, DEFAULT_STREAMFLOW_FEE, DynamicContractSchema, ESCROW_SEED, FEES_METADATA_SEED, FEE_ORACLE_PUBLIC_KEY, GetContractsOptions, MAX_SAFE_UNIX_TIME_VALUE, METADATA_SEED, ORIGINAL_CONTRACT_SENDER_OFFSET, PARTNERS_SCHEMA, PARTNER_ORACLE_PROGRAM_ID, PARTNER_SCHEMA, PROGRAM_ID, PriceOracleType, REPOPULATED_METADATA_SEED, SOLANA_ERROR_MAP, SOLANA_ERROR_MATCH_REGEX, STREAMFLOW_TREASURY_PUBLIC_KEY, STREAM_STRUCT_OFFSETS, STREAM_STRUCT_OFFSET_CLOSED, STREAM_STRUCT_OFFSET_MINT, STREAM_STRUCT_OFFSET_OLD_METADATA_KEY, STREAM_STRUCT_OFFSET_RECIPIENT, STREAM_STRUCT_OFFSET_SENDER, TEST_ORACLE_DISCRIMINATOR, TEST_ORACLE_SEED, TX_FINALITY_CONFIRMED, TabulariumContract, WITHDRAWOR, WITHDRAWOR_PUBLIC_KEY, WITHDRAW_AVAILABLE_AMOUNT, buildStreamType, calculateTotalAmountToDeposit, calculateUnlockedAmount, cancelStreamInstruction, claimRoutedFeeStreamInstruction, createClient, createStreamInstruction, createStreamV2Instruction, createUncheckedStreamInstruction, createUncheckedStreamV2Instruction, decodeEndTime, decodeStream, deriveContractPDA, deriveEscrowPDA, deriveRepopulatedMetadataPDA, deriveStreamMetadataPDA, deriveTestOraclePDA, extractSolanaErrorCode, getMetadataKey, handleContractError, isAligned, isCliffCloseToDepositedAmount, isCreateAlignedStreamData, isDynamicLock, isTokenLock, isVesting, sendAndConfirmStreamRawTransaction, signAllTransactionWithRecipients, timelockIDL, topupStreamInstruction, transferStreamInstruction, transformContract, updateStreamInstruction, withdrawStreamInstruction } from './solana/index.cjs';
3
3
  export { ContractError, ICluster, getBN, getNumberFromBN } from '@streamflow/common';
4
4
  import '@solana/wallet-adapter-base';
5
5
  import '@solana/web3.js';
@@ -1013,25 +1013,29 @@ var transferStreamInstruction = async (programId, {
1013
1013
  data
1014
1014
  });
1015
1015
  };
1016
- var requestCancelStreamInstruction = async (programId, { authority, metadata }) => {
1017
- const keys = [
1018
- { pubkey: authority, isSigner: true, isWritable: false },
1019
- { pubkey: metadata, isSigner: false, isWritable: true }
1020
- ];
1021
- const data = buffer.Buffer.concat([buffer.Buffer.from(await sha256.digest("global:request_cancel")).slice(0, 8), buffer.Buffer.alloc(10)]);
1022
- return new web3_js.TransactionInstruction({
1023
- keys,
1024
- programId,
1025
- data
1026
- });
1027
- };
1028
- var withdrawCancelRequestInstruction = async (programId, { authority, metadata }) => {
1016
+ var claimRoutedFeeStreamInstruction = async (destination, programId, {
1017
+ authority,
1018
+ metadata,
1019
+ escrowTokens,
1020
+ streamflowTreasury,
1021
+ streamflowTreasuryTokens,
1022
+ senderTokens,
1023
+ mint,
1024
+ tokenProgram
1025
+ }) => {
1029
1026
  const keys = [
1030
1027
  { pubkey: authority, isSigner: true, isWritable: false },
1031
- { pubkey: metadata, isSigner: false, isWritable: true }
1028
+ { pubkey: metadata, isSigner: false, isWritable: true },
1029
+ { pubkey: escrowTokens, isSigner: false, isWritable: true },
1030
+ { pubkey: streamflowTreasury, isSigner: false, isWritable: true },
1031
+ { pubkey: streamflowTreasuryTokens, isSigner: false, isWritable: true },
1032
+ { pubkey: senderTokens, isSigner: false, isWritable: true },
1033
+ { pubkey: mint, isSigner: false, isWritable: true },
1034
+ { pubkey: tokenProgram, isSigner: false, isWritable: false }
1032
1035
  ];
1033
1036
  const data = buffer.Buffer.concat([
1034
- buffer.Buffer.from(await sha256.digest("global:withdraw_cancel_request")).slice(0, 8),
1037
+ buffer.Buffer.from(await sha256.digest("global:claim_routed_fee")).slice(0, 8),
1038
+ buffer.Buffer.from([destination === "treasury" ? 0 : 1]),
1035
1039
  buffer.Buffer.alloc(10)
1036
1040
  ]);
1037
1041
  return new web3_js.TransactionInstruction({
@@ -4270,13 +4274,13 @@ var SolanaStreamClient = class {
4270
4274
  return ixs;
4271
4275
  }
4272
4276
  /**
4273
- * Requests cancellation of a stream by the fee partner authority.
4274
- * @param {IRequestCancelData} data - Request cancel parameters including stream ID
4277
+ * Claims routed fee from the stream and routes it to the requested destination.
4278
+ * @param {IClaimRoutedFeeData} data - Routed fee claim parameters including stream ID and destination
4275
4279
  * @param {IInteractStreamExt} extParams - Transaction configuration including invoker wallet and compute settings
4276
4280
  * @returns Transaction result
4277
4281
  */
4278
- async requestCancel(data, extParams) {
4279
- const ixs = await this.prepareRequestCancelInstructions(data, extParams);
4282
+ async claimRoutedFee(data, extParams) {
4283
+ const ixs = await this.prepareClaimRoutedFeeInstructions(data, extParams);
4280
4284
  const { tx, hash, context } = await common.prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
4281
4285
  const signature = await common.signAndExecuteTransaction(
4282
4286
  this.connection,
@@ -4292,65 +4296,51 @@ var SolanaStreamClient = class {
4292
4296
  return { ixs, txId: signature };
4293
4297
  }
4294
4298
  /**
4295
- * Creates Transaction Instructions for request_cancel
4296
- * @param {IRequestCancelData} data - Request cancel parameters including stream ID
4299
+ * Creates transaction instructions for claim_routed_fee.
4300
+ * @param {IClaimRoutedFeeData} data - Routed fee claim parameters including stream ID and destination
4297
4301
  * @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet and compute settings
4298
4302
  * @returns Transaction instructions
4299
4303
  */
4300
- async prepareRequestCancelInstructions({ id }, { invoker, computePrice, computeLimit }) {
4304
+ async prepareClaimRoutedFeeInstructions({ id, destination }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
4301
4305
  common.assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
4302
4306
  const ixs = common.prepareBaseInstructions(this.connection, {
4303
4307
  computePrice,
4304
4308
  computeLimit
4305
4309
  });
4306
- ixs.push(
4307
- await requestCancelStreamInstruction(this.programId, {
4308
- authority: invoker.publicKey,
4309
- metadata: new web3_js.PublicKey(id)
4310
- })
4311
- );
4312
- return ixs;
4313
- }
4314
- /**
4315
- * Withdraws a previously submitted cancel request.
4316
- * @param {IWithdrawCancelRequestData} data - Withdraw cancel request parameters including stream ID
4317
- * @param {IInteractStreamExt} extParams - Transaction configuration including invoker wallet and compute settings
4318
- * @returns Transaction result
4319
- */
4320
- async withdrawCancelRequest(data, extParams) {
4321
- const ixs = await this.prepareWithdrawCancelRequestInstructions(data, extParams);
4322
- const { tx, hash, context } = await common.prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
4323
- const signature = await common.signAndExecuteTransaction(
4324
- this.connection,
4325
- extParams.invoker,
4326
- tx,
4327
- {
4328
- hash,
4329
- context,
4330
- commitment: this.getCommitment()
4331
- },
4332
- this.schedulingParams
4310
+ const streamPublicKey = new web3_js.PublicKey(id);
4311
+ const streamAccount = await this.connection.getAccountInfo(streamPublicKey);
4312
+ common.invariant(streamAccount?.data, "Couldn't get account info");
4313
+ const { sender, mint, escrowTokens } = decodeStream(streamAccount.data);
4314
+ const { mint: mintAccount, tokenProgramId } = await common.getMintAndProgram(this.connection, mint);
4315
+ const streamflowTreasuryTokens = await common.ata(mint, STREAMFLOW_TREASURY_PUBLIC_KEY, tokenProgramId);
4316
+ const senderTokens = await common.ata(mint, sender, tokenProgramId);
4317
+ const ataIxs = await this.getCreateATAInstructions(
4318
+ [sender, STREAMFLOW_TREASURY_PUBLIC_KEY],
4319
+ mint,
4320
+ invoker,
4321
+ checkTokenAccounts,
4322
+ tokenProgramId
4333
4323
  );
4334
- return { ixs, txId: signature };
4335
- }
4336
- /**
4337
- * Creates Transaction Instructions for withdraw_cancel_request
4338
- * @param {IWithdrawCancelRequestData} data - Withdraw cancel request parameters including stream ID
4339
- * @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet and compute settings
4340
- * @returns Transaction instructions
4341
- */
4342
- async prepareWithdrawCancelRequestInstructions({ id }, { invoker, computePrice, computeLimit }) {
4343
- common.assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
4344
- const ixs = common.prepareBaseInstructions(this.connection, {
4345
- computePrice,
4346
- computeLimit
4324
+ const claimRoutedFeeIx = await claimRoutedFeeStreamInstruction(destination, this.programId, {
4325
+ authority: invoker.publicKey,
4326
+ metadata: streamPublicKey,
4327
+ escrowTokens,
4328
+ streamflowTreasury: STREAMFLOW_TREASURY_PUBLIC_KEY,
4329
+ streamflowTreasuryTokens,
4330
+ senderTokens,
4331
+ mint,
4332
+ tokenProgram: tokenProgramId
4347
4333
  });
4348
- ixs.push(
4349
- await withdrawCancelRequestInstruction(this.programId, {
4350
- authority: invoker.publicKey,
4351
- metadata: new web3_js.PublicKey(id)
4352
- })
4353
- );
4334
+ await this.addTransferHookAccounts(claimRoutedFeeIx, {
4335
+ mint,
4336
+ mintAccount,
4337
+ tokenProgramId,
4338
+ potentialTransfers: [
4339
+ { source: escrowTokens, destination: streamflowTreasuryTokens, owner: escrowTokens },
4340
+ { source: escrowTokens, destination: senderTokens, owner: escrowTokens }
4341
+ ]
4342
+ });
4343
+ ixs.push(...ataIxs, claimRoutedFeeIx);
4354
4344
  return ixs;
4355
4345
  }
4356
4346
  /**