@streamflow/stream 9.2.0-alpha.p0.5034440 → 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-DsFyl13W.js';
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-DLVKn7Ae.js';
2
2
  export { ContractError, IChain, ICluster } from '@streamflow/common';
3
3
  import 'p-queue';
4
4
  import '@solana/web3.js';
@@ -2972,6 +2972,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
2972
2972
  const metadatas = [];
2973
2973
  const metadataToRecipient = {};
2974
2974
  const instructionsBatch = [];
2975
+ const metadataPubKeys = metadataPubKeysExt || [];
2975
2976
  const partnerPublicKey = data.partner ? new PublicKey(data.partner) : WITHDRAWOR_PUBLIC_KEY;
2976
2977
  const mintPublicKey = new PublicKey(data.tokenId);
2977
2978
  if (recipients.length === 0) {
@@ -2981,8 +2982,8 @@ var SolanaStreamClient = class extends BaseStreamClient {
2981
2982
  const recipientData = recipients[i];
2982
2983
  const createStreamData = { ...streamParams, ...recipientData };
2983
2984
  const createStreamExtParams = {
2984
- ...extParams,
2985
- metadataPubKeys: metadataPubKeysExt?.[i] ? [metadataPubKeysExt[i]] : void 0
2985
+ metadataPubKeys: metadataPubKeys[i] ? [metadataPubKeys[i]] : void 0,
2986
+ ...extParams
2986
2987
  };
2987
2988
  const { ixs, metadata, metadataPubKey } = await this.prepareCreateInstructions(
2988
2989
  createStreamData,
@@ -3648,20 +3649,41 @@ var SolanaStreamClient = class extends BaseStreamClient {
3648
3649
  const accounts = await this.connection.getProgramAccounts(this.programId, {
3649
3650
  filters
3650
3651
  });
3651
- const mapped = await Promise.all(
3652
- accounts.map(async ({ pubkey, account }) => {
3653
- const stream = decodeStream(account.data);
3654
- if (this.isAlignedUnlock(pubkey, stream.sender)) {
3655
- const alignedProxy = await this.alignedProxyProgram.account.contract.fetch(
3656
- deriveContractPDA(this.alignedProxyProgram.programId, pubkey)
3657
- );
3658
- invariant(alignedProxy, "Couldn't get aligned proxy account info");
3659
- return { publicKey: pubkey, account: new AlignedContract(stream, alignedProxy) };
3660
- }
3661
- return { publicKey: pubkey, account: new Contract(stream) };
3662
- })
3663
- );
3664
- return mapped;
3652
+ const decoded = this.decodeStreamsFromAccounts(accounts);
3653
+ const alignedEntries = this.collectAlignedEntries(decoded);
3654
+ const alignedProxies = await this.fetchAlignedProxiesByEntries(alignedEntries);
3655
+ return this.mapDecodedToProgramAccounts(decoded, alignedEntries, alignedProxies);
3656
+ }
3657
+ decodeStreamsFromAccounts(accounts) {
3658
+ return accounts.map(({ pubkey, account }) => ({
3659
+ pubkey,
3660
+ stream: decodeStream(account.data)
3661
+ }));
3662
+ }
3663
+ collectAlignedEntries(decoded) {
3664
+ const entries = [];
3665
+ decoded.forEach(({ pubkey, stream }, index) => {
3666
+ if (this.isAlignedUnlock(pubkey, stream.sender)) {
3667
+ entries.push({ index, pda: deriveContractPDA(this.alignedProxyProgram.programId, pubkey) });
3668
+ }
3669
+ });
3670
+ return entries;
3671
+ }
3672
+ async fetchAlignedProxiesByEntries(aligned) {
3673
+ if (aligned.length === 0) return [];
3674
+ const res = await this.alignedProxyProgram.account.contract.fetchMultiple(aligned.map((a) => a.pda));
3675
+ return res;
3676
+ }
3677
+ mapDecodedToProgramAccounts(decoded, alignedEntries, alignedProxies) {
3678
+ return decoded.map(({ pubkey, stream }, idx) => {
3679
+ const alignedIdx = alignedEntries.findIndex((a) => a.index === idx);
3680
+ if (alignedIdx !== -1) {
3681
+ const alignedProxy = alignedProxies[alignedIdx];
3682
+ invariant(alignedProxy, "Couldn't get aligned proxy account info");
3683
+ return { publicKey: pubkey, account: new AlignedContract(stream, alignedProxy) };
3684
+ }
3685
+ return { publicKey: pubkey, account: new Contract(stream) };
3686
+ });
3665
3687
  }
3666
3688
  /**
3667
3689
  * Attempts updating the stream auto withdrawal params and amount per period