@solana/web3.js 1.48.0 → 1.50.1

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/lib/index.d.ts CHANGED
@@ -480,6 +480,22 @@ declare module '@solana/web3.js' {
480
480
  /** The minimum slot that the request can be evaluated at */
481
481
  minContextSlot?: number;
482
482
  };
483
+ /**
484
+ * Configuration object for changing `getBlock` query behavior
485
+ */
486
+ export type GetBlockConfig = {
487
+ /** The level of finality desired */
488
+ commitment?: Finality;
489
+ /** The max transaction version to return in responses. If the requested transaction is a higher version, an error will be returned */
490
+ maxSupportedTransactionVersion?: number;
491
+ };
492
+ /**
493
+ * Configuration object for changing `getStakeMinimumDelegation` query behavior
494
+ */
495
+ export type GetStakeMinimumDelegationConfig = {
496
+ /** The level of commitment desired */
497
+ commitment?: Commitment;
498
+ };
483
499
  /**
484
500
  * Configuration object for changing `getBlockHeight` query behavior
485
501
  */
@@ -536,6 +552,15 @@ declare module '@solana/web3.js' {
536
552
  /** The minimum slot that the request can be evaluated at */
537
553
  minContextSlot?: number;
538
554
  };
555
+ /**
556
+ * Configuration object for changing `getTransaction` query behavior
557
+ */
558
+ export type GetTransactionConfig = {
559
+ /** The level of finality desired */
560
+ commitment?: Finality;
561
+ /** The max transaction version to return in responses. If the requested transaction is a higher version, an error will be returned */
562
+ maxSupportedTransactionVersion?: number;
563
+ };
539
564
  /**
540
565
  * Configuration object for changing `getLargestAccounts` query behavior
541
566
  */
@@ -1738,9 +1763,7 @@ declare module '@solana/web3.js' {
1738
1763
  */
1739
1764
  getBlock(
1740
1765
  slot: number,
1741
- opts?: {
1742
- commitment?: Finality;
1743
- },
1766
+ rawConfig?: GetBlockConfig,
1744
1767
  ): Promise<BlockResponse | null>;
1745
1768
  getBlockHeight(
1746
1769
  commitmentOrConfig?: Commitment | GetBlockHeightConfig,
@@ -1753,23 +1776,21 @@ declare module '@solana/web3.js' {
1753
1776
  */
1754
1777
  getTransaction(
1755
1778
  signature: string,
1756
- opts?: {
1757
- commitment?: Finality;
1758
- },
1779
+ rawConfig?: GetTransactionConfig,
1759
1780
  ): Promise<TransactionResponse | null>;
1760
1781
  /**
1761
1782
  * Fetch parsed transaction details for a confirmed or finalized transaction
1762
1783
  */
1763
1784
  getParsedTransaction(
1764
1785
  signature: TransactionSignature,
1765
- commitment?: Finality,
1786
+ commitmentOrConfig?: GetTransactionConfig | Finality,
1766
1787
  ): Promise<ParsedConfirmedTransaction | null>;
1767
1788
  /**
1768
1789
  * Fetch parsed transaction details for a batch of confirmed transactions
1769
1790
  */
1770
1791
  getParsedTransactions(
1771
1792
  signatures: TransactionSignature[],
1772
- commitment?: Finality,
1793
+ commitmentOrConfig?: GetTransactionConfig | Finality,
1773
1794
  ): Promise<(ParsedConfirmedTransaction | null)[]>;
1774
1795
  /**
1775
1796
  * Fetch transaction details for a batch of confirmed transactions.
@@ -1777,7 +1798,7 @@ declare module '@solana/web3.js' {
1777
1798
  */
1778
1799
  getTransactions(
1779
1800
  signatures: TransactionSignature[],
1780
- commitment?: Finality,
1801
+ commitmentOrConfig?: GetTransactionConfig | Finality,
1781
1802
  ): Promise<(TransactionResponse | null)[]>;
1782
1803
  /**
1783
1804
  * Fetch a list of Transactions and transaction statuses from the cluster
@@ -1913,6 +1934,12 @@ declare module '@solana/web3.js' {
1913
1934
  to: PublicKey,
1914
1935
  lamports: number,
1915
1936
  ): Promise<TransactionSignature>;
1937
+ /**
1938
+ * get the stake minimum delegation
1939
+ */
1940
+ getStakeMinimumDelegation(
1941
+ config?: GetStakeMinimumDelegationConfig,
1942
+ ): Promise<RpcResponseAndContext<number>>;
1916
1943
  /**
1917
1944
  * Simulate a transaction
1918
1945
  */
package/lib/index.esm.js CHANGED
@@ -7062,8 +7062,15 @@ class Connection {
7062
7062
  */
7063
7063
 
7064
7064
 
7065
- async getBlock(slot, opts) {
7066
- const args = this._buildArgsAtLeastConfirmed([slot], opts && opts.commitment);
7065
+ async getBlock(slot, rawConfig) {
7066
+ const {
7067
+ commitment,
7068
+ config
7069
+ } = extractCommitmentFromConfig(rawConfig);
7070
+
7071
+ const args = this._buildArgsAtLeastConfirmed([slot], commitment, undefined
7072
+ /* encoding */
7073
+ , config);
7067
7074
 
7068
7075
  const unsafeRes = await this._rpcRequest('getBlock', args);
7069
7076
  const res = create(unsafeRes, GetBlockRpcResult);
@@ -7149,8 +7156,15 @@ class Connection {
7149
7156
  */
7150
7157
 
7151
7158
 
7152
- async getTransaction(signature, opts) {
7153
- const args = this._buildArgsAtLeastConfirmed([signature], opts && opts.commitment);
7159
+ async getTransaction(signature, rawConfig) {
7160
+ const {
7161
+ commitment,
7162
+ config
7163
+ } = extractCommitmentFromConfig(rawConfig);
7164
+
7165
+ const args = this._buildArgsAtLeastConfirmed([signature], commitment, undefined
7166
+ /* encoding */
7167
+ , config);
7154
7168
 
7155
7169
  const unsafeRes = await this._rpcRequest('getTransaction', args);
7156
7170
  const res = create(unsafeRes, GetTransactionRpcResult);
@@ -7172,8 +7186,13 @@ class Connection {
7172
7186
  */
7173
7187
 
7174
7188
 
7175
- async getParsedTransaction(signature, commitment) {
7176
- const args = this._buildArgsAtLeastConfirmed([signature], commitment, 'jsonParsed');
7189
+ async getParsedTransaction(signature, commitmentOrConfig) {
7190
+ const {
7191
+ commitment,
7192
+ config
7193
+ } = extractCommitmentFromConfig(commitmentOrConfig);
7194
+
7195
+ const args = this._buildArgsAtLeastConfirmed([signature], commitment, 'jsonParsed', config);
7177
7196
 
7178
7197
  const unsafeRes = await this._rpcRequest('getTransaction', args);
7179
7198
  const res = create(unsafeRes, GetParsedTransactionRpcResult);
@@ -7189,9 +7208,13 @@ class Connection {
7189
7208
  */
7190
7209
 
7191
7210
 
7192
- async getParsedTransactions(signatures, commitment) {
7211
+ async getParsedTransactions(signatures, commitmentOrConfig) {
7212
+ const {
7213
+ commitment,
7214
+ config
7215
+ } = extractCommitmentFromConfig(commitmentOrConfig);
7193
7216
  const batch = signatures.map(signature => {
7194
- const args = this._buildArgsAtLeastConfirmed([signature], commitment, 'jsonParsed');
7217
+ const args = this._buildArgsAtLeastConfirmed([signature], commitment, 'jsonParsed', config);
7195
7218
 
7196
7219
  return {
7197
7220
  methodName: 'getTransaction',
@@ -7216,9 +7239,15 @@ class Connection {
7216
7239
  */
7217
7240
 
7218
7241
 
7219
- async getTransactions(signatures, commitment) {
7242
+ async getTransactions(signatures, commitmentOrConfig) {
7243
+ const {
7244
+ commitment,
7245
+ config
7246
+ } = extractCommitmentFromConfig(commitmentOrConfig);
7220
7247
  const batch = signatures.map(signature => {
7221
- const args = this._buildArgsAtLeastConfirmed([signature], commitment);
7248
+ const args = this._buildArgsAtLeastConfirmed([signature], commitment, undefined
7249
+ /* encoding */
7250
+ , config);
7222
7251
 
7223
7252
  return {
7224
7253
  methodName: 'getTransaction',
@@ -7660,6 +7689,28 @@ class Connection {
7660
7689
  this._pollingBlockhash = false;
7661
7690
  }
7662
7691
  }
7692
+ /**
7693
+ * get the stake minimum delegation
7694
+ */
7695
+
7696
+
7697
+ async getStakeMinimumDelegation(config) {
7698
+ const {
7699
+ commitment,
7700
+ config: configArg
7701
+ } = extractCommitmentFromConfig(config);
7702
+
7703
+ const args = this._buildArgs([], commitment, 'base64', configArg);
7704
+
7705
+ const unsafeRes = await this._rpcRequest('getStakeMinimumDelegation', args);
7706
+ const res = create(unsafeRes, jsonRpcResultAndContext(number()));
7707
+
7708
+ if ('error' in res) {
7709
+ throw new SolanaJSONRPCError(res.error, `failed to get stake minimum delegation`);
7710
+ }
7711
+
7712
+ return res.result;
7713
+ }
7663
7714
  /**
7664
7715
  * Simulate a transaction
7665
7716
  */
@@ -7891,6 +7942,11 @@ class Connection {
7891
7942
  this._rpcWebSocketConnected = false;
7892
7943
  this._rpcWebSocketGeneration++;
7893
7944
 
7945
+ if (this._rpcWebSocketIdleTimeout) {
7946
+ clearTimeout(this._rpcWebSocketIdleTimeout);
7947
+ this._rpcWebSocketIdleTimeout = null;
7948
+ }
7949
+
7894
7950
  if (this._rpcWebSocketHeartbeat) {
7895
7951
  clearInterval(this._rpcWebSocketHeartbeat);
7896
7952
  this._rpcWebSocketHeartbeat = null;