@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.
@@ -4460,7 +4460,7 @@ class Connection {
4460
4460
  * @param endpoint URL to the fullnode JSON RPC endpoint
4461
4461
  * @param commitmentOrConfig optional default commitment level or optional ConnectionConfig configuration object
4462
4462
  */
4463
- constructor(endpoint, commitmentOrConfig) {
4463
+ constructor(endpoint, _commitmentOrConfig) {
4464
4464
  this._commitment = void 0;
4465
4465
  this._confirmTransactionInitialTimeout = void 0;
4466
4466
  this._rpcEndpoint = void 0;
@@ -4488,23 +4488,47 @@ class Connection {
4488
4488
  this._subscriptionCallbacksByServerSubscriptionId = {};
4489
4489
  this._subscriptionsByHash = {};
4490
4490
  this._subscriptionsAutoDisposedByRpc = new Set();
4491
+ this.getBlockHeight = (() => {
4492
+ const requestPromises = {};
4493
+ return async commitmentOrConfig => {
4494
+ const {
4495
+ commitment,
4496
+ config
4497
+ } = extractCommitmentFromConfig(commitmentOrConfig);
4498
+ const args = this._buildArgs([], commitment, undefined /* encoding */, config);
4499
+ const requestHash = fastStableStringify$1(args);
4500
+ requestPromises[requestHash] = requestPromises[requestHash] ?? (async () => {
4501
+ try {
4502
+ const unsafeRes = await this._rpcRequest('getBlockHeight', args);
4503
+ const res = create(unsafeRes, jsonRpcResult(number()));
4504
+ if ('error' in res) {
4505
+ throw new SolanaJSONRPCError(res.error, 'failed to get block height information');
4506
+ }
4507
+ return res.result;
4508
+ } finally {
4509
+ delete requestPromises[requestHash];
4510
+ }
4511
+ })();
4512
+ return await requestPromises[requestHash];
4513
+ };
4514
+ })();
4491
4515
  let wsEndpoint;
4492
4516
  let httpHeaders;
4493
4517
  let fetch;
4494
4518
  let fetchMiddleware;
4495
4519
  let disableRetryOnRateLimit;
4496
4520
  let httpAgent;
4497
- if (commitmentOrConfig && typeof commitmentOrConfig === 'string') {
4498
- this._commitment = commitmentOrConfig;
4499
- } else if (commitmentOrConfig) {
4500
- this._commitment = commitmentOrConfig.commitment;
4501
- this._confirmTransactionInitialTimeout = commitmentOrConfig.confirmTransactionInitialTimeout;
4502
- wsEndpoint = commitmentOrConfig.wsEndpoint;
4503
- httpHeaders = commitmentOrConfig.httpHeaders;
4504
- fetch = commitmentOrConfig.fetch;
4505
- fetchMiddleware = commitmentOrConfig.fetchMiddleware;
4506
- disableRetryOnRateLimit = commitmentOrConfig.disableRetryOnRateLimit;
4507
- httpAgent = commitmentOrConfig.httpAgent;
4521
+ if (_commitmentOrConfig && typeof _commitmentOrConfig === 'string') {
4522
+ this._commitment = _commitmentOrConfig;
4523
+ } else if (_commitmentOrConfig) {
4524
+ this._commitment = _commitmentOrConfig.commitment;
4525
+ this._confirmTransactionInitialTimeout = _commitmentOrConfig.confirmTransactionInitialTimeout;
4526
+ wsEndpoint = _commitmentOrConfig.wsEndpoint;
4527
+ httpHeaders = _commitmentOrConfig.httpHeaders;
4528
+ fetch = _commitmentOrConfig.fetch;
4529
+ fetchMiddleware = _commitmentOrConfig.fetchMiddleware;
4530
+ disableRetryOnRateLimit = _commitmentOrConfig.disableRetryOnRateLimit;
4531
+ httpAgent = _commitmentOrConfig.httpAgent;
4508
4532
  }
4509
4533
  this._rpcEndpoint = assertEndpointUrl(endpoint);
4510
4534
  this._rpcWsEndpoint = wsEndpoint || makeWebsocketUrl(endpoint);
@@ -5762,19 +5786,6 @@ class Connection {
5762
5786
  /*
5763
5787
  * Returns the current block height of the node
5764
5788
  */
5765
- async getBlockHeight(commitmentOrConfig) {
5766
- const {
5767
- commitment,
5768
- config
5769
- } = extractCommitmentFromConfig(commitmentOrConfig);
5770
- const args = this._buildArgs([], commitment, undefined /* encoding */, config);
5771
- const unsafeRes = await this._rpcRequest('getBlockHeight', args);
5772
- const res = create(unsafeRes, jsonRpcResult(number()));
5773
- if ('error' in res) {
5774
- throw new SolanaJSONRPCError(res.error, 'failed to get block height information');
5775
- }
5776
- return res.result;
5777
- }
5778
5789
 
5779
5790
  /*
5780
5791
  * Returns recent block production information from the current or previous epoch