@streamflow/stream 9.2.0 → 9.2.1-alpha.p321.02efd07

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 { Z as Account, a5 as AlignedContract, M as AlignedUnlocksContract, a8 as BatchItem, aa as BatchItemError, ab as BatchItemResult, a9 as BatchItemSuccess, U as ChangeOracleParams, y as ClientCreationOptions, a4 as Contract, R as CreateParams, V as CreateTestOracleParams, a6 as DecodedStream, $ as ICreateSolanaExt, a3 as ICreateStreamInstructions, I as ICreateStreamSolanaExt, a as IInteractStreamSolanaExt, a1 as IPrepareCreateStreamSolanaExt, a2 as IPrepareStreamSolanaExt, Y as ISearchStreams, b as ITopUpStreamSolanaExt, a0 as ITransactionSolanaExtWithInstructions, ac as InstructionGenerator, a7 as MetadataRecipientHashMap, N as OracleType, S as SolanaStreamClient, Q as TestOracle, X as UpdateTestOracleParams, ah as cancelStreamInstruction, x as constants, ad as createStreamInstruction, ae as createUncheckedStreamInstruction, z as decodeStream, J as deriveContractPDA, K as deriveEscrowPDA, L as deriveTestOraclePDA, H as extractSolanaErrorCode, G as sendAndConfirmStreamRawTransaction, B as signAllTransactionWithRecipients, _ as timelockIDL, aj as topupStreamInstruction, ai as transferStreamInstruction, ag as updateStreamInstruction, af as withdrawStreamInstruction } from '../index-ByMlPIUq.cjs';
1
+ export { Z as Account, a5 as AlignedContract, M as AlignedUnlocksContract, a8 as BatchItem, aa as BatchItemError, ab as BatchItemResult, a9 as BatchItemSuccess, U as ChangeOracleParams, y as ClientCreationOptions, a4 as Contract, R as CreateParams, V as CreateTestOracleParams, a6 as DecodedStream, $ as ICreateSolanaExt, a3 as ICreateStreamInstructions, I as ICreateStreamSolanaExt, a as IInteractStreamSolanaExt, a1 as IPrepareCreateStreamSolanaExt, a2 as IPrepareStreamSolanaExt, Y as ISearchStreams, b as ITopUpStreamSolanaExt, a0 as ITransactionSolanaExtWithInstructions, ac as InstructionGenerator, a7 as MetadataRecipientHashMap, N as OracleType, S as SolanaStreamClient, Q as TestOracle, X as UpdateTestOracleParams, ah as cancelStreamInstruction, x as constants, ad as createStreamInstruction, ae as createUncheckedStreamInstruction, z as decodeStream, J as deriveContractPDA, K as deriveEscrowPDA, L as deriveTestOraclePDA, H as extractSolanaErrorCode, G as sendAndConfirmStreamRawTransaction, B as signAllTransactionWithRecipients, _ as timelockIDL, aj as topupStreamInstruction, ai as transferStreamInstruction, ag as updateStreamInstruction, af as withdrawStreamInstruction } from '../index-CPUhIwK2.cjs';
2
2
  export { ContractError, IChain, ICluster } from '@streamflow/common';
3
3
  import 'p-queue';
4
4
  import '@solana/web3.js';
@@ -463,6 +463,10 @@ declare class SolanaStreamClient extends BaseStreamClient {
463
463
  * @returns Record of stream data
464
464
  */
465
465
  searchStreams(data: ISearchStreams): Promise<IProgramAccount<Stream>[]>;
466
+ private decodeStreamsFromAccounts;
467
+ private collectAlignedEntries;
468
+ private fetchAlignedProxiesByEntries;
469
+ private mapDecodedToProgramAccounts;
466
470
  /**
467
471
  * Attempts updating the stream auto withdrawal params and amount per period
468
472
  * @param {IUpdateData} data - Update parameters including stream ID and new settings
@@ -2,8 +2,8 @@ import { A as AptosStreamClient, I as ICreateStreamAptosExt, a as ITransactionAp
2
2
  export { i as StreamflowAptos } from './index-D54wSYym.js';
3
3
  import { E as EvmStreamClient } from './index-elpYUBph.js';
4
4
  export { i as StreamflowEVM } from './index-elpYUBph.js';
5
- import { S as SolanaStreamClient, I as ICreateStreamSolanaExt, a as IInteractStreamSolanaExt, b as ITopUpStreamSolanaExt } from './index-DsFyl13W.js';
6
- export { s as AIRDROP_AMOUNT, q as AIRDROP_TEST_TOKEN, j as ALIGNED_COMPUTE_LIMIT, A as ALIGNED_PRECISION_FACTOR_POW, h as ALIGNED_UNLOCKS_PROGRAM_ID, k as CONTRACT_DISCRIMINATOR, m as CONTRACT_SEED, C as CREATE_PARAMS_PADDING, D as DEFAULT_STREAMFLOW_FEE, E as ESCROW_SEED, r as FEES_METADATA_SEED, F as FEE_ORACLE_PUBLIC_KEY, O as ORIGINAL_CONTRACT_SENDER_OFFSET, u as PARTNERS_SCHEMA, o as PARTNER_ORACLE_PROGRAM_ID, t as PARTNER_SCHEMA, P as PROGRAM_ID, w as SOLANA_ERROR_MAP, v as SOLANA_ERROR_MATCH_REGEX, p as STREAMFLOW_TREASURY_PUBLIC_KEY, g as STREAM_STRUCT_OFFSETS, f as STREAM_STRUCT_OFFSET_CLOSED, e as STREAM_STRUCT_OFFSET_MINT, d as STREAM_STRUCT_OFFSET_RECIPIENT, c as STREAM_STRUCT_OFFSET_SENDER, i as StreamflowSolana, l as TEST_ORACLE_DISCRIMINATOR, n as TEST_ORACLE_SEED, T as TX_FINALITY_CONFIRMED, W as WITHDRAWOR_PUBLIC_KEY } from './index-DsFyl13W.js';
5
+ import { S as SolanaStreamClient, I as ICreateStreamSolanaExt, a as IInteractStreamSolanaExt, b as ITopUpStreamSolanaExt } from './index-DLVKn7Ae.js';
6
+ export { s as AIRDROP_AMOUNT, q as AIRDROP_TEST_TOKEN, j as ALIGNED_COMPUTE_LIMIT, A as ALIGNED_PRECISION_FACTOR_POW, h as ALIGNED_UNLOCKS_PROGRAM_ID, k as CONTRACT_DISCRIMINATOR, m as CONTRACT_SEED, C as CREATE_PARAMS_PADDING, D as DEFAULT_STREAMFLOW_FEE, E as ESCROW_SEED, r as FEES_METADATA_SEED, F as FEE_ORACLE_PUBLIC_KEY, O as ORIGINAL_CONTRACT_SENDER_OFFSET, u as PARTNERS_SCHEMA, o as PARTNER_ORACLE_PROGRAM_ID, t as PARTNER_SCHEMA, P as PROGRAM_ID, w as SOLANA_ERROR_MAP, v as SOLANA_ERROR_MATCH_REGEX, p as STREAMFLOW_TREASURY_PUBLIC_KEY, g as STREAM_STRUCT_OFFSETS, f as STREAM_STRUCT_OFFSET_CLOSED, e as STREAM_STRUCT_OFFSET_MINT, d as STREAM_STRUCT_OFFSET_RECIPIENT, c as STREAM_STRUCT_OFFSET_SENDER, i as StreamflowSolana, l as TEST_ORACLE_DISCRIMINATOR, n as TEST_ORACLE_SEED, T as TX_FINALITY_CONFIRMED, W as WITHDRAWOR_PUBLIC_KEY } from './index-DLVKn7Ae.js';
7
7
  import { S as SuiStreamClient } from './index-DrzqsoIB.js';
8
8
  export { i as StreamflowSui } from './index-DrzqsoIB.js';
9
9
  import { S as Stream, A as AlignedStream, I as ICreateStreamData, a as ICreateAlignedStreamData, b as StreamType, B as BaseStreamClient, c as SolanaStreamClientOptions, d as AptosStreamClientOptions, e as SuiStreamClientOptions, E as EvmStreamClientOptions, f as ICreateStreamSuiExt, g as ICreateResult, h as ICreateMultipleStreamData, i as IMultiTransactionResult, j as IWithdrawData, k as ITransactionSuiExt, l as ITransactionResult, m as ICancelData, n as ITransferData, o as ITopUpData, p as IGetOneData, q as IGetAllData, r as IUpdateData, s as IGetFeesData, t as IFees } from './BaseStreamClient-DOyJqO7R.js';
package/dist/esm/index.js CHANGED
@@ -6243,20 +6243,41 @@ var SolanaStreamClient = class extends BaseStreamClient {
6243
6243
  const accounts = await this.connection.getProgramAccounts(this.programId, {
6244
6244
  filters
6245
6245
  });
6246
- const mapped = await Promise.all(
6247
- accounts.map(async ({ pubkey, account }) => {
6248
- const stream = decodeStream(account.data);
6249
- if (this.isAlignedUnlock(pubkey, stream.sender)) {
6250
- const alignedProxy = await this.alignedProxyProgram.account.contract.fetch(
6251
- deriveContractPDA(this.alignedProxyProgram.programId, pubkey)
6252
- );
6253
- invariant(alignedProxy, "Couldn't get aligned proxy account info");
6254
- return { publicKey: pubkey, account: new AlignedContract(stream, alignedProxy) };
6255
- }
6256
- return { publicKey: pubkey, account: new Contract2(stream) };
6257
- })
6258
- );
6259
- return mapped;
6246
+ const decoded = this.decodeStreamsFromAccounts(accounts);
6247
+ const alignedEntries = this.collectAlignedEntries(decoded);
6248
+ const alignedProxies = await this.fetchAlignedProxiesByEntries(alignedEntries);
6249
+ return this.mapDecodedToProgramAccounts(decoded, alignedEntries, alignedProxies);
6250
+ }
6251
+ decodeStreamsFromAccounts(accounts) {
6252
+ return accounts.map(({ pubkey, account }) => ({
6253
+ pubkey,
6254
+ stream: decodeStream(account.data)
6255
+ }));
6256
+ }
6257
+ collectAlignedEntries(decoded) {
6258
+ const entries = [];
6259
+ decoded.forEach(({ pubkey, stream }, index) => {
6260
+ if (this.isAlignedUnlock(pubkey, stream.sender)) {
6261
+ entries.push({ index, pda: deriveContractPDA(this.alignedProxyProgram.programId, pubkey) });
6262
+ }
6263
+ });
6264
+ return entries;
6265
+ }
6266
+ async fetchAlignedProxiesByEntries(aligned) {
6267
+ if (aligned.length === 0) return [];
6268
+ const res = await this.alignedProxyProgram.account.contract.fetchMultiple(aligned.map((a) => a.pda));
6269
+ return res;
6270
+ }
6271
+ mapDecodedToProgramAccounts(decoded, alignedEntries, alignedProxies) {
6272
+ return decoded.map(({ pubkey, stream }, idx) => {
6273
+ const alignedIdx = alignedEntries.findIndex((a) => a.index === idx);
6274
+ if (alignedIdx !== -1) {
6275
+ const alignedProxy = alignedProxies[alignedIdx];
6276
+ invariant(alignedProxy, "Couldn't get aligned proxy account info");
6277
+ return { publicKey: pubkey, account: new AlignedContract(stream, alignedProxy) };
6278
+ }
6279
+ return { publicKey: pubkey, account: new Contract2(stream) };
6280
+ });
6260
6281
  }
6261
6282
  /**
6262
6283
  * Attempts updating the stream auto withdrawal params and amount per period