@solana/web3.js 1.73.5 → 1.74.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.
@@ -4448,7 +4448,7 @@ const LogsNotificationResult = superstruct.type({
4448
4448
 
4449
4449
  /** @internal */
4450
4450
  const COMMON_HTTP_HEADERS = {
4451
- 'solana-client': `js/${"1.73.5" }`
4451
+ 'solana-client': `js/${"1.74.1" }`
4452
4452
  };
4453
4453
 
4454
4454
  /**
@@ -4512,7 +4512,7 @@ class Connection {
4512
4512
  * @param endpoint URL to the fullnode JSON RPC endpoint
4513
4513
  * @param commitmentOrConfig optional default commitment level or optional ConnectionConfig configuration object
4514
4514
  */
4515
- constructor(endpoint, commitmentOrConfig) {
4515
+ constructor(endpoint, _commitmentOrConfig) {
4516
4516
  this._commitment = void 0;
4517
4517
  this._confirmTransactionInitialTimeout = void 0;
4518
4518
  this._rpcEndpoint = void 0;
@@ -4540,23 +4540,47 @@ class Connection {
4540
4540
  this._subscriptionCallbacksByServerSubscriptionId = {};
4541
4541
  this._subscriptionsByHash = {};
4542
4542
  this._subscriptionsAutoDisposedByRpc = new Set();
4543
+ this.getBlockHeight = (() => {
4544
+ const requestPromises = {};
4545
+ return async commitmentOrConfig => {
4546
+ const {
4547
+ commitment,
4548
+ config
4549
+ } = extractCommitmentFromConfig(commitmentOrConfig);
4550
+ const args = this._buildArgs([], commitment, undefined /* encoding */, config);
4551
+ const requestHash = fastStableStringify$1(args);
4552
+ requestPromises[requestHash] = requestPromises[requestHash] ?? (async () => {
4553
+ try {
4554
+ const unsafeRes = await this._rpcRequest('getBlockHeight', args);
4555
+ const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.number()));
4556
+ if ('error' in res) {
4557
+ throw new SolanaJSONRPCError(res.error, 'failed to get block height information');
4558
+ }
4559
+ return res.result;
4560
+ } finally {
4561
+ delete requestPromises[requestHash];
4562
+ }
4563
+ })();
4564
+ return await requestPromises[requestHash];
4565
+ };
4566
+ })();
4543
4567
  let wsEndpoint;
4544
4568
  let httpHeaders;
4545
4569
  let fetch;
4546
4570
  let fetchMiddleware;
4547
4571
  let disableRetryOnRateLimit;
4548
4572
  let httpAgent;
4549
- if (commitmentOrConfig && typeof commitmentOrConfig === 'string') {
4550
- this._commitment = commitmentOrConfig;
4551
- } else if (commitmentOrConfig) {
4552
- this._commitment = commitmentOrConfig.commitment;
4553
- this._confirmTransactionInitialTimeout = commitmentOrConfig.confirmTransactionInitialTimeout;
4554
- wsEndpoint = commitmentOrConfig.wsEndpoint;
4555
- httpHeaders = commitmentOrConfig.httpHeaders;
4556
- fetch = commitmentOrConfig.fetch;
4557
- fetchMiddleware = commitmentOrConfig.fetchMiddleware;
4558
- disableRetryOnRateLimit = commitmentOrConfig.disableRetryOnRateLimit;
4559
- httpAgent = commitmentOrConfig.httpAgent;
4573
+ if (_commitmentOrConfig && typeof _commitmentOrConfig === 'string') {
4574
+ this._commitment = _commitmentOrConfig;
4575
+ } else if (_commitmentOrConfig) {
4576
+ this._commitment = _commitmentOrConfig.commitment;
4577
+ this._confirmTransactionInitialTimeout = _commitmentOrConfig.confirmTransactionInitialTimeout;
4578
+ wsEndpoint = _commitmentOrConfig.wsEndpoint;
4579
+ httpHeaders = _commitmentOrConfig.httpHeaders;
4580
+ fetch = _commitmentOrConfig.fetch;
4581
+ fetchMiddleware = _commitmentOrConfig.fetchMiddleware;
4582
+ disableRetryOnRateLimit = _commitmentOrConfig.disableRetryOnRateLimit;
4583
+ httpAgent = _commitmentOrConfig.httpAgent;
4560
4584
  }
4561
4585
  this._rpcEndpoint = assertEndpointUrl(endpoint);
4562
4586
  this._rpcWsEndpoint = wsEndpoint || makeWebsocketUrl(endpoint);
@@ -5814,19 +5838,6 @@ class Connection {
5814
5838
  /*
5815
5839
  * Returns the current block height of the node
5816
5840
  */
5817
- async getBlockHeight(commitmentOrConfig) {
5818
- const {
5819
- commitment,
5820
- config
5821
- } = extractCommitmentFromConfig(commitmentOrConfig);
5822
- const args = this._buildArgs([], commitment, undefined /* encoding */, config);
5823
- const unsafeRes = await this._rpcRequest('getBlockHeight', args);
5824
- const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.number()));
5825
- if ('error' in res) {
5826
- throw new SolanaJSONRPCError(res.error, 'failed to get block height information');
5827
- }
5828
- return res.result;
5829
- }
5830
5841
 
5831
5842
  /*
5832
5843
  * Returns recent block production information from the current or previous epoch