@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.
@@ -219,6 +219,7 @@ declare class SolanaStreamClient extends BaseStreamClient {
219
219
  getConnection(): Connection;
220
220
  getCommitment(): Commitment | undefined;
221
221
  getProgramId(): string;
222
+ getAlignedProxyProgramId(): string;
222
223
  /**
223
224
  * Builds transaction instructions for creating a new stream/vesting contract without creating a transaction.
224
225
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
@@ -493,14 +494,14 @@ declare class SolanaStreamClient extends BaseStreamClient {
493
494
  * @returns Error code
494
495
  */
495
496
  extractErrorCode(err: Error): string | null;
497
+ /**
498
+ * Utility function that checks whether the associated stream address is an aligned unlock contract, indicated by whether the sender/creator is a PDA
499
+ */
500
+ isAlignedUnlock(streamPublicKey: PublicKey, senderPublicKey: PublicKey): boolean;
496
501
  /**
497
502
  * Utility function to generate metadata for a Contract or return existing Pubkey
498
503
  */
499
504
  private getOrCreateStreamMetadata;
500
- /**
501
- * Utility function that checks whether the associated stream address is an aligned unlock contract, indicated by whether the sender/creator is a PDA
502
- */
503
- private isAlignedUnlock;
504
505
  /**
505
506
  * Returns insrtuctions for creating associated token accounts for the provided owners
506
507
  */
@@ -5048,6 +5048,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
5048
5048
  getProgramId() {
5049
5049
  return this.programId.toBase58();
5050
5050
  }
5051
+ getAlignedProxyProgramId() {
5052
+ return this.alignedProxyProgram.programId.toBase58();
5053
+ }
5051
5054
  /**
5052
5055
  * Builds transaction instructions for creating a new stream/vesting contract without creating a transaction.
5053
5056
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
@@ -6178,10 +6181,20 @@ var SolanaStreamClient = class extends BaseStreamClient {
6178
6181
  const accounts = await this.connection.getProgramAccounts(this.programId, {
6179
6182
  filters
6180
6183
  });
6181
- return accounts.map(({ pubkey, account }) => ({
6182
- publicKey: pubkey,
6183
- account: new Contract2(decodeStream(account.data))
6184
- }));
6184
+ const mapped = await Promise.all(
6185
+ accounts.map(async ({ pubkey, account }) => {
6186
+ const stream = decodeStream(account.data);
6187
+ if (this.isAlignedUnlock(pubkey, stream.sender)) {
6188
+ const alignedProxy = await this.alignedProxyProgram.account.contract.fetch(
6189
+ deriveContractPDA(this.alignedProxyProgram.programId, pubkey)
6190
+ );
6191
+ common.invariant(alignedProxy, "Couldn't get aligned proxy account info");
6192
+ return { publicKey: pubkey, account: new AlignedContract(stream, alignedProxy) };
6193
+ }
6194
+ return { publicKey: pubkey, account: new Contract2(stream) };
6195
+ })
6196
+ );
6197
+ return mapped;
6185
6198
  }
6186
6199
  /**
6187
6200
  * Attempts updating the stream auto withdrawal params and amount per period
@@ -6276,6 +6289,13 @@ var SolanaStreamClient = class extends BaseStreamClient {
6276
6289
  const logs = "logs" in err && Array.isArray(err.logs) ? err.logs : void 0;
6277
6290
  return extractSolanaErrorCode(err.toString() ?? "Unknown error!", logs);
6278
6291
  }
6292
+ /**
6293
+ * Utility function that checks whether the associated stream address is an aligned unlock contract, indicated by whether the sender/creator is a PDA
6294
+ */
6295
+ isAlignedUnlock(streamPublicKey, senderPublicKey) {
6296
+ const pda = deriveContractPDA(this.alignedProxyProgram.programId, streamPublicKey);
6297
+ return senderPublicKey.equals(pda);
6298
+ }
6279
6299
  /**
6280
6300
  * Utility function to generate metadata for a Contract or return existing Pubkey
6281
6301
  */
@@ -6290,13 +6310,6 @@ var SolanaStreamClient = class extends BaseStreamClient {
6290
6310
  }
6291
6311
  return { metadata, metadataPubKey };
6292
6312
  }
6293
- /**
6294
- * Utility function that checks whether the associated stream address is an aligned unlock contract, indicated by whether the sender/creator is a PDA
6295
- */
6296
- isAlignedUnlock(streamPublicKey, senderPublicKey) {
6297
- const pda = deriveContractPDA(this.alignedProxyProgram.programId, streamPublicKey);
6298
- return senderPublicKey.equals(pda);
6299
- }
6300
6313
  /**
6301
6314
  * Returns insrtuctions for creating associated token accounts for the provided owners
6302
6315
  */