@solana/web3.js 1.38.0 → 1.39.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solana/web3.js",
3
- "version": "1.38.0",
3
+ "version": "1.39.0",
4
4
  "description": "Solana Javascript API",
5
5
  "keywords": [
6
6
  "api",
package/src/connection.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import bs58 from 'bs58';
2
2
  import {Buffer} from 'buffer';
3
- import fetch from 'cross-fetch';
3
+ import crossFetch from 'cross-fetch';
4
4
  import {
5
5
  type as pick,
6
6
  number,
@@ -814,9 +814,11 @@ function createRpcClient(
814
814
  url: string,
815
815
  useHttps: boolean,
816
816
  httpHeaders?: HttpHeaders,
817
+ customFetch?: typeof crossFetch,
817
818
  fetchMiddleware?: FetchMiddleware,
818
819
  disableRetryOnRateLimit?: boolean,
819
820
  ): RpcClient {
821
+ const fetch = customFetch ? customFetch : crossFetch;
820
822
  let agentManager: AgentManager | undefined;
821
823
  if (!process.env.BROWSER) {
822
824
  agentManager = new AgentManager(useHttps);
@@ -2108,6 +2110,8 @@ export type ConnectionConfig = {
2108
2110
  wsEndpoint?: string;
2109
2111
  /** Optional HTTP headers object */
2110
2112
  httpHeaders?: HttpHeaders;
2113
+ /** Optional custom fetch function */
2114
+ fetch?: typeof crossFetch;
2111
2115
  /** Optional fetch middleware callback */
2112
2116
  fetchMiddleware?: FetchMiddleware;
2113
2117
  /** Optional Disable retrying calls when server responds with HTTP 429 (Too Many Requests) */
@@ -2200,6 +2204,7 @@ export class Connection {
2200
2204
 
2201
2205
  let wsEndpoint;
2202
2206
  let httpHeaders;
2207
+ let fetch;
2203
2208
  let fetchMiddleware;
2204
2209
  let disableRetryOnRateLimit;
2205
2210
  if (commitmentOrConfig && typeof commitmentOrConfig === 'string') {
@@ -2210,6 +2215,7 @@ export class Connection {
2210
2215
  commitmentOrConfig.confirmTransactionInitialTimeout;
2211
2216
  wsEndpoint = commitmentOrConfig.wsEndpoint;
2212
2217
  httpHeaders = commitmentOrConfig.httpHeaders;
2218
+ fetch = commitmentOrConfig.fetch;
2213
2219
  fetchMiddleware = commitmentOrConfig.fetchMiddleware;
2214
2220
  disableRetryOnRateLimit = commitmentOrConfig.disableRetryOnRateLimit;
2215
2221
  }
@@ -2221,6 +2227,7 @@ export class Connection {
2221
2227
  url.toString(),
2222
2228
  useHttps,
2223
2229
  httpHeaders,
2230
+ fetch,
2224
2231
  fetchMiddleware,
2225
2232
  disableRetryOnRateLimit,
2226
2233
  );