@solana/web3.js 1.93.2 → 1.93.3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solana/web3.js",
3
- "version": "1.93.2",
3
+ "version": "1.93.3",
4
4
  "description": "Solana Javascript API",
5
5
  "keywords": [
6
6
  "api",
package/src/connection.ts CHANGED
@@ -2787,6 +2787,39 @@ export type GetNonceAndContextConfig = {
2787
2787
  minContextSlot?: number;
2788
2788
  };
2789
2789
 
2790
+ export type AccountSubscriptionConfig = Readonly<{
2791
+ /** Optional commitment level */
2792
+ commitment?: Commitment;
2793
+ /**
2794
+ * Encoding format for Account data
2795
+ * - `base58` is slow.
2796
+ * - `jsonParsed` encoding attempts to use program-specific state parsers to return more
2797
+ * human-readable and explicit account state data
2798
+ * - If `jsonParsed` is requested but a parser cannot be found, the field falls back to `base64`
2799
+ * encoding, detectable when the `data` field is type `string`.
2800
+ */
2801
+ encoding?: 'base58' | 'base64' | 'base64+zstd' | 'jsonParsed';
2802
+ }>;
2803
+
2804
+ export type ProgramAccountSubscriptionConfig = Readonly<{
2805
+ /** Optional commitment level */
2806
+ commitment?: Commitment;
2807
+ /**
2808
+ * Encoding format for Account data
2809
+ * - `base58` is slow.
2810
+ * - `jsonParsed` encoding attempts to use program-specific state parsers to return more
2811
+ * human-readable and explicit account state data
2812
+ * - If `jsonParsed` is requested but a parser cannot be found, the field falls back to `base64`
2813
+ * encoding, detectable when the `data` field is type `string`.
2814
+ */
2815
+ encoding?: 'base58' | 'base64' | 'base64+zstd' | 'jsonParsed';
2816
+ /**
2817
+ * Filter results using various filter objects
2818
+ * The resultant account must meet ALL filter criteria to be included in the returned results
2819
+ */
2820
+ filters?: GetProgramAccountsFilter[];
2821
+ }>;
2822
+
2790
2823
  /**
2791
2824
  * Information describing an account
2792
2825
  */
@@ -6334,18 +6367,34 @@ export class Connection {
6334
6367
  *
6335
6368
  * @param publicKey Public key of the account to monitor
6336
6369
  * @param callback Function to invoke whenever the account is changed
6337
- * @param commitment Specify the commitment level account changes must reach before notification
6370
+ * @param config
6338
6371
  * @return subscription id
6339
6372
  */
6373
+ onAccountChange(
6374
+ publicKey: PublicKey,
6375
+ callback: AccountChangeCallback,
6376
+ config?: AccountSubscriptionConfig,
6377
+ ): ClientSubscriptionId;
6378
+ /** @deprecated Instead, pass in an {@link AccountSubscriptionConfig} */
6379
+ // eslint-disable-next-line no-dupe-class-members
6340
6380
  onAccountChange(
6341
6381
  publicKey: PublicKey,
6342
6382
  callback: AccountChangeCallback,
6343
6383
  commitment?: Commitment,
6384
+ ): ClientSubscriptionId;
6385
+ // eslint-disable-next-line no-dupe-class-members
6386
+ onAccountChange(
6387
+ publicKey: PublicKey,
6388
+ callback: AccountChangeCallback,
6389
+ commitmentOrConfig?: Commitment | AccountSubscriptionConfig,
6344
6390
  ): ClientSubscriptionId {
6391
+ const {commitment, config} =
6392
+ extractCommitmentFromConfig(commitmentOrConfig);
6345
6393
  const args = this._buildArgs(
6346
6394
  [publicKey.toBase58()],
6347
6395
  commitment || this._commitment || 'finalized', // Apply connection/server default.
6348
6396
  'base64',
6397
+ config,
6349
6398
  );
6350
6399
  return this._makeSubscription(
6351
6400
  {
@@ -6394,21 +6443,40 @@ export class Connection {
6394
6443
  *
6395
6444
  * @param programId Public key of the program to monitor
6396
6445
  * @param callback Function to invoke whenever the account is changed
6397
- * @param commitment Specify the commitment level account changes must reach before notification
6398
- * @param filters The program account filters to pass into the RPC method
6446
+ * @param config
6399
6447
  * @return subscription id
6400
6448
  */
6449
+ onProgramAccountChange(
6450
+ programId: PublicKey,
6451
+ callback: ProgramAccountChangeCallback,
6452
+ config?: ProgramAccountSubscriptionConfig,
6453
+ ): ClientSubscriptionId;
6454
+ /** @deprecated Instead, pass in a {@link ProgramAccountSubscriptionConfig} */
6455
+ // eslint-disable-next-line no-dupe-class-members
6401
6456
  onProgramAccountChange(
6402
6457
  programId: PublicKey,
6403
6458
  callback: ProgramAccountChangeCallback,
6404
6459
  commitment?: Commitment,
6405
6460
  filters?: GetProgramAccountsFilter[],
6461
+ ): ClientSubscriptionId;
6462
+ // eslint-disable-next-line no-dupe-class-members
6463
+ onProgramAccountChange(
6464
+ programId: PublicKey,
6465
+ callback: ProgramAccountChangeCallback,
6466
+ commitmentOrConfig?: Commitment | ProgramAccountSubscriptionConfig,
6467
+ maybeFilters?: GetProgramAccountsFilter[],
6406
6468
  ): ClientSubscriptionId {
6469
+ const {commitment, config} =
6470
+ extractCommitmentFromConfig(commitmentOrConfig);
6407
6471
  const args = this._buildArgs(
6408
6472
  [programId.toBase58()],
6409
6473
  commitment || this._commitment || 'finalized', // Apply connection/server default.
6410
6474
  'base64' /* encoding */,
6411
- filters ? {filters: filters} : undefined /* extra */,
6475
+ config
6476
+ ? config
6477
+ : maybeFilters
6478
+ ? {filters: maybeFilters}
6479
+ : undefined /* extra */,
6412
6480
  );
6413
6481
  return this._makeSubscription(
6414
6482
  {