@solana/web3.js 1.69.0 → 1.70.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.
package/lib/index.cjs.js CHANGED
@@ -11,11 +11,11 @@ var sha256 = require('@noble/hashes/sha256');
11
11
  var borsh = require('borsh');
12
12
  var BufferLayout = require('@solana/buffer-layout');
13
13
  var bigintBuffer = require('bigint-buffer');
14
+ var https = require('https');
14
15
  var superstruct = require('superstruct');
15
16
  var rpcWebsockets = require('rpc-websockets');
16
17
  var RpcClient = require('jayson/lib/client/browser');
17
18
  var http = require('http');
18
- var https = require('https');
19
19
  var nodeFetch = require('node-fetch');
20
20
  var sha3 = require('@noble/hashes/sha3');
21
21
  var hmac = require('@noble/hashes/hmac');
@@ -45,9 +45,9 @@ var ed25519__namespace = /*#__PURE__*/_interopNamespace(ed25519);
45
45
  var BN__default = /*#__PURE__*/_interopDefaultLegacy(BN);
46
46
  var bs58__default = /*#__PURE__*/_interopDefaultLegacy(bs58);
47
47
  var BufferLayout__namespace = /*#__PURE__*/_interopNamespace(BufferLayout);
48
+ var https__default = /*#__PURE__*/_interopDefaultLegacy(https);
48
49
  var RpcClient__default = /*#__PURE__*/_interopDefaultLegacy(RpcClient);
49
50
  var http__default = /*#__PURE__*/_interopDefaultLegacy(http);
50
- var https__default = /*#__PURE__*/_interopDefaultLegacy(https);
51
51
  var nodeFetch__namespace = /*#__PURE__*/_interopNamespace(nodeFetch);
52
52
  var secp256k1__namespace = /*#__PURE__*/_interopNamespace(secp256k1);
53
53
 
@@ -3949,14 +3949,34 @@ const BlockProductionResponseStruct = jsonRpcResultAndContext(superstruct.type({
3949
3949
  * A performance sample
3950
3950
  */
3951
3951
 
3952
- function createRpcClient(url, httpHeaders, customFetch, fetchMiddleware, disableRetryOnRateLimit) {
3952
+ function createRpcClient(url, httpHeaders, customFetch, fetchMiddleware, disableRetryOnRateLimit, httpAgent) {
3953
3953
  const fetch = customFetch ? customFetch : fetchImpl;
3954
3954
  let agentManager;
3955
3955
 
3956
3956
  {
3957
- agentManager = new AgentManager(url.startsWith('https:')
3958
- /* useHttps */
3959
- );
3957
+ if (httpAgent == null) {
3958
+ {
3959
+ agentManager = new AgentManager(url.startsWith('https:')
3960
+ /* useHttps */
3961
+ );
3962
+ }
3963
+ } else {
3964
+ if (httpAgent !== false) {
3965
+ const isHttps = url.startsWith('https:');
3966
+
3967
+ if (isHttps && !(httpAgent instanceof https.Agent)) {
3968
+ throw new Error('The endpoint `' + url + '` can only be paired with an `https.Agent`. You have, instead, supplied an ' + '`http.Agent` through `httpAgent`.');
3969
+ } else if (!isHttps && httpAgent instanceof https.Agent) {
3970
+ throw new Error('The endpoint `' + url + '` can only be paired with an `http.Agent`. You have, instead, supplied an ' + '`https.Agent` through `httpAgent`.');
3971
+ }
3972
+
3973
+ agentManager = {
3974
+ requestEnd() {},
3975
+
3976
+ requestStart: () => httpAgent
3977
+ };
3978
+ }
3979
+ }
3960
3980
  }
3961
3981
 
3962
3982
  let fetchWithMiddleware;
@@ -4866,6 +4886,7 @@ class Connection {
4866
4886
  let fetch;
4867
4887
  let fetchMiddleware;
4868
4888
  let disableRetryOnRateLimit;
4889
+ let httpAgent;
4869
4890
 
4870
4891
  if (commitmentOrConfig && typeof commitmentOrConfig === 'string') {
4871
4892
  this._commitment = commitmentOrConfig;
@@ -4877,11 +4898,12 @@ class Connection {
4877
4898
  fetch = commitmentOrConfig.fetch;
4878
4899
  fetchMiddleware = commitmentOrConfig.fetchMiddleware;
4879
4900
  disableRetryOnRateLimit = commitmentOrConfig.disableRetryOnRateLimit;
4901
+ httpAgent = commitmentOrConfig.httpAgent;
4880
4902
  }
4881
4903
 
4882
4904
  this._rpcEndpoint = assertEndpointUrl(endpoint);
4883
4905
  this._rpcWsEndpoint = wsEndpoint || makeWebsocketUrl(endpoint);
4884
- this._rpcClient = createRpcClient(endpoint, httpHeaders, fetch, fetchMiddleware, disableRetryOnRateLimit);
4906
+ this._rpcClient = createRpcClient(endpoint, httpHeaders, fetch, fetchMiddleware, disableRetryOnRateLimit, httpAgent);
4885
4907
  this._rpcRequest = createRpcRequest(this._rpcClient);
4886
4908
  this._rpcBatchRequest = createRpcBatchRequest(this._rpcClient);
4887
4909
  this._rpcWebSocket = new rpcWebsockets.Client(this._rpcWsEndpoint, {