@streamflow/stream 9.0.2 → 9.0.4

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-BNQVJtIE.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-Dp5DXxr-.js';
2
2
  export { ContractError, IChain, ICluster } from '@streamflow/common';
3
3
  import 'p-queue';
4
4
  import '@solana/web3.js';
@@ -2428,6 +2428,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
2428
2428
  getProgramId() {
2429
2429
  return this.programId.toBase58();
2430
2430
  }
2431
+ getAlignedProxyProgramId() {
2432
+ return this.alignedProxyProgram.programId.toBase58();
2433
+ }
2431
2434
  /**
2432
2435
  * Builds transaction instructions for creating a new stream/vesting contract without creating a transaction.
2433
2436
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
@@ -3558,10 +3561,20 @@ var SolanaStreamClient = class extends BaseStreamClient {
3558
3561
  const accounts = await this.connection.getProgramAccounts(this.programId, {
3559
3562
  filters
3560
3563
  });
3561
- return accounts.map(({ pubkey, account }) => ({
3562
- publicKey: pubkey,
3563
- account: new Contract(decodeStream(account.data))
3564
- }));
3564
+ const mapped = await Promise.all(
3565
+ accounts.map(async ({ pubkey, account }) => {
3566
+ const stream = decodeStream(account.data);
3567
+ if (this.isAlignedUnlock(pubkey, stream.sender)) {
3568
+ const alignedProxy = await this.alignedProxyProgram.account.contract.fetch(
3569
+ deriveContractPDA(this.alignedProxyProgram.programId, pubkey)
3570
+ );
3571
+ invariant(alignedProxy, "Couldn't get aligned proxy account info");
3572
+ return { publicKey: pubkey, account: new AlignedContract(stream, alignedProxy) };
3573
+ }
3574
+ return { publicKey: pubkey, account: new Contract(stream) };
3575
+ })
3576
+ );
3577
+ return mapped;
3565
3578
  }
3566
3579
  /**
3567
3580
  * Attempts updating the stream auto withdrawal params and amount per period
@@ -3656,6 +3669,13 @@ var SolanaStreamClient = class extends BaseStreamClient {
3656
3669
  const logs = "logs" in err && Array.isArray(err.logs) ? err.logs : void 0;
3657
3670
  return extractSolanaErrorCode(err.toString() ?? "Unknown error!", logs);
3658
3671
  }
3672
+ /**
3673
+ * Utility function that checks whether the associated stream address is an aligned unlock contract, indicated by whether the sender/creator is a PDA
3674
+ */
3675
+ isAlignedUnlock(streamPublicKey, senderPublicKey) {
3676
+ const pda = deriveContractPDA(this.alignedProxyProgram.programId, streamPublicKey);
3677
+ return senderPublicKey.equals(pda);
3678
+ }
3659
3679
  /**
3660
3680
  * Utility function to generate metadata for a Contract or return existing Pubkey
3661
3681
  */
@@ -3670,13 +3690,6 @@ var SolanaStreamClient = class extends BaseStreamClient {
3670
3690
  }
3671
3691
  return { metadata, metadataPubKey };
3672
3692
  }
3673
- /**
3674
- * Utility function that checks whether the associated stream address is an aligned unlock contract, indicated by whether the sender/creator is a PDA
3675
- */
3676
- isAlignedUnlock(streamPublicKey, senderPublicKey) {
3677
- const pda = deriveContractPDA(this.alignedProxyProgram.programId, streamPublicKey);
3678
- return senderPublicKey.equals(pda);
3679
- }
3680
3693
  /**
3681
3694
  * Returns insrtuctions for creating associated token accounts for the provided owners
3682
3695
  */