@solana/web3.js 1.73.4 → 1.74.0

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.
@@ -4492,7 +4492,7 @@ class Connection {
4492
4492
  * @param endpoint URL to the fullnode JSON RPC endpoint
4493
4493
  * @param commitmentOrConfig optional default commitment level or optional ConnectionConfig configuration object
4494
4494
  */
4495
- constructor(endpoint, commitmentOrConfig) {
4495
+ constructor(endpoint, _commitmentOrConfig) {
4496
4496
  this._commitment = void 0;
4497
4497
  this._confirmTransactionInitialTimeout = void 0;
4498
4498
  this._rpcEndpoint = void 0;
@@ -4520,23 +4520,47 @@ class Connection {
4520
4520
  this._subscriptionCallbacksByServerSubscriptionId = {};
4521
4521
  this._subscriptionsByHash = {};
4522
4522
  this._subscriptionsAutoDisposedByRpc = new Set();
4523
+ this.getBlockHeight = (() => {
4524
+ const requestPromises = {};
4525
+ return async commitmentOrConfig => {
4526
+ const {
4527
+ commitment,
4528
+ config
4529
+ } = extractCommitmentFromConfig(commitmentOrConfig);
4530
+ const args = this._buildArgs([], commitment, undefined /* encoding */, config);
4531
+ const requestHash = fastStableStringify$1(args);
4532
+ requestPromises[requestHash] = requestPromises[requestHash] ?? (async () => {
4533
+ try {
4534
+ const unsafeRes = await this._rpcRequest('getBlockHeight', args);
4535
+ const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.number()));
4536
+ if ('error' in res) {
4537
+ throw new SolanaJSONRPCError(res.error, 'failed to get block height information');
4538
+ }
4539
+ return res.result;
4540
+ } finally {
4541
+ delete requestPromises[requestHash];
4542
+ }
4543
+ })();
4544
+ return await requestPromises[requestHash];
4545
+ };
4546
+ })();
4523
4547
  let wsEndpoint;
4524
4548
  let httpHeaders;
4525
4549
  let fetch;
4526
4550
  let fetchMiddleware;
4527
4551
  let disableRetryOnRateLimit;
4528
4552
  let httpAgent;
4529
- if (commitmentOrConfig && typeof commitmentOrConfig === 'string') {
4530
- this._commitment = commitmentOrConfig;
4531
- } else if (commitmentOrConfig) {
4532
- this._commitment = commitmentOrConfig.commitment;
4533
- this._confirmTransactionInitialTimeout = commitmentOrConfig.confirmTransactionInitialTimeout;
4534
- wsEndpoint = commitmentOrConfig.wsEndpoint;
4535
- httpHeaders = commitmentOrConfig.httpHeaders;
4536
- fetch = commitmentOrConfig.fetch;
4537
- fetchMiddleware = commitmentOrConfig.fetchMiddleware;
4538
- disableRetryOnRateLimit = commitmentOrConfig.disableRetryOnRateLimit;
4539
- httpAgent = commitmentOrConfig.httpAgent;
4553
+ if (_commitmentOrConfig && typeof _commitmentOrConfig === 'string') {
4554
+ this._commitment = _commitmentOrConfig;
4555
+ } else if (_commitmentOrConfig) {
4556
+ this._commitment = _commitmentOrConfig.commitment;
4557
+ this._confirmTransactionInitialTimeout = _commitmentOrConfig.confirmTransactionInitialTimeout;
4558
+ wsEndpoint = _commitmentOrConfig.wsEndpoint;
4559
+ httpHeaders = _commitmentOrConfig.httpHeaders;
4560
+ fetch = _commitmentOrConfig.fetch;
4561
+ fetchMiddleware = _commitmentOrConfig.fetchMiddleware;
4562
+ disableRetryOnRateLimit = _commitmentOrConfig.disableRetryOnRateLimit;
4563
+ httpAgent = _commitmentOrConfig.httpAgent;
4540
4564
  }
4541
4565
  this._rpcEndpoint = assertEndpointUrl(endpoint);
4542
4566
  this._rpcWsEndpoint = wsEndpoint || makeWebsocketUrl(endpoint);
@@ -5794,19 +5818,6 @@ class Connection {
5794
5818
  /*
5795
5819
  * Returns the current block height of the node
5796
5820
  */
5797
- async getBlockHeight(commitmentOrConfig) {
5798
- const {
5799
- commitment,
5800
- config
5801
- } = extractCommitmentFromConfig(commitmentOrConfig);
5802
- const args = this._buildArgs([], commitment, undefined /* encoding */, config);
5803
- const unsafeRes = await this._rpcRequest('getBlockHeight', args);
5804
- const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.number()));
5805
- if ('error' in res) {
5806
- throw new SolanaJSONRPCError(res.error, 'failed to get block height information');
5807
- }
5808
- return res.result;
5809
- }
5810
5821
 
5811
5822
  /*
5812
5823
  * Returns recent block production information from the current or previous epoch