@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/README.md +0 -13
- package/lib/index.browser.cjs.js +10 -2
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +10 -2
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +29 -7
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +8 -0
- package/lib/index.esm.js +28 -6
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +10 -2
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +1 -1
- package/lib/index.iife.min.js.map +1 -1
- package/lib/index.native.js +10 -2
- package/lib/index.native.js.map +1 -1
- package/package.json +2 -2
- package/src/connection.ts +50 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solana/web3.js",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.70.0",
|
|
4
4
|
"description": "Solana Javascript API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"pretty": "prettier --check '{,{src,test}/**/}*.{j,t}s'",
|
|
52
52
|
"pretty:fix": "prettier --write '{,{src,test}/**/}*.{j,t}s'",
|
|
53
53
|
"re": "semantic-release --repository-url git@github.com:solana-labs/solana-web3.js.git",
|
|
54
|
-
"test": "cross-env TS_NODE_COMPILER_OPTIONS='{ \"module\": \"commonjs\", \"target\": \"es2019\" }' ts-mocha --require esm './test/**/*.test.ts'",
|
|
54
|
+
"test": "cross-env NODE_ENV=test TS_NODE_COMPILER_OPTIONS='{ \"module\": \"commonjs\", \"target\": \"es2019\" }' ts-mocha --require esm './test/**/*.test.ts'",
|
|
55
55
|
"test:cover": "nyc --reporter=lcov npm run test",
|
|
56
56
|
"test:live": "TEST_LIVE=1 npm run test",
|
|
57
57
|
"test:live-with-test-validator": "start-server-and-test 'solana-test-validator --reset --quiet' http://localhost:8899/health test:live"
|
package/src/connection.ts
CHANGED
|
@@ -2,6 +2,8 @@ import bs58 from 'bs58';
|
|
|
2
2
|
import {Buffer} from 'buffer';
|
|
3
3
|
// @ts-ignore
|
|
4
4
|
import fastStableStringify from 'fast-stable-stringify';
|
|
5
|
+
import type {Agent as HttpAgent} from 'http';
|
|
6
|
+
import {Agent as HttpsAgent} from 'https';
|
|
5
7
|
import {
|
|
6
8
|
type as pick,
|
|
7
9
|
number,
|
|
@@ -1450,11 +1452,47 @@ function createRpcClient(
|
|
|
1450
1452
|
customFetch?: FetchFn,
|
|
1451
1453
|
fetchMiddleware?: FetchMiddleware,
|
|
1452
1454
|
disableRetryOnRateLimit?: boolean,
|
|
1455
|
+
httpAgent?: HttpAgent | HttpsAgent | false,
|
|
1453
1456
|
): RpcClient {
|
|
1454
1457
|
const fetch = customFetch ? customFetch : fetchImpl;
|
|
1455
|
-
let agentManager:
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
+
let agentManager:
|
|
1459
|
+
| {requestEnd(): void; requestStart(): HttpAgent | HttpsAgent}
|
|
1460
|
+
| undefined;
|
|
1461
|
+
if (process.env.BROWSER) {
|
|
1462
|
+
if (httpAgent != null) {
|
|
1463
|
+
console.warn(
|
|
1464
|
+
'You have supplied an `httpAgent` when creating a `Connection` in a browser environment.' +
|
|
1465
|
+
'It has been ignored; `httpAgent` is only used in Node environments.',
|
|
1466
|
+
);
|
|
1467
|
+
}
|
|
1468
|
+
} else {
|
|
1469
|
+
if (httpAgent == null) {
|
|
1470
|
+
if (process.env.NODE_ENV !== 'test') {
|
|
1471
|
+
agentManager = new AgentManager(
|
|
1472
|
+
url.startsWith('https:') /* useHttps */,
|
|
1473
|
+
);
|
|
1474
|
+
}
|
|
1475
|
+
} else {
|
|
1476
|
+
if (httpAgent !== false) {
|
|
1477
|
+
const isHttps = url.startsWith('https:');
|
|
1478
|
+
if (isHttps && !(httpAgent instanceof HttpsAgent)) {
|
|
1479
|
+
throw new Error(
|
|
1480
|
+
'The endpoint `' +
|
|
1481
|
+
url +
|
|
1482
|
+
'` can only be paired with an `https.Agent`. You have, instead, supplied an ' +
|
|
1483
|
+
'`http.Agent` through `httpAgent`.',
|
|
1484
|
+
);
|
|
1485
|
+
} else if (!isHttps && httpAgent instanceof HttpsAgent) {
|
|
1486
|
+
throw new Error(
|
|
1487
|
+
'The endpoint `' +
|
|
1488
|
+
url +
|
|
1489
|
+
'` can only be paired with an `http.Agent`. You have, instead, supplied an ' +
|
|
1490
|
+
'`https.Agent` through `httpAgent`.',
|
|
1491
|
+
);
|
|
1492
|
+
}
|
|
1493
|
+
agentManager = {requestEnd() {}, requestStart: () => httpAgent};
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1458
1496
|
}
|
|
1459
1497
|
|
|
1460
1498
|
let fetchWithMiddleware: FetchFn | undefined;
|
|
@@ -2855,6 +2893,12 @@ export type FetchMiddleware = (
|
|
|
2855
2893
|
* Configuration for instantiating a Connection
|
|
2856
2894
|
*/
|
|
2857
2895
|
export type ConnectionConfig = {
|
|
2896
|
+
/**
|
|
2897
|
+
* An `http.Agent` that will be used to manage socket connections (eg. to implement connection
|
|
2898
|
+
* persistence). Set this to `false` to create a connection that uses no agent. This applies to
|
|
2899
|
+
* Node environments only.
|
|
2900
|
+
*/
|
|
2901
|
+
httpAgent?: HttpAgent | HttpsAgent | false;
|
|
2858
2902
|
/** Optional commitment level */
|
|
2859
2903
|
commitment?: Commitment;
|
|
2860
2904
|
/** Optional endpoint URL to the fullnode JSON RPC PubSub WebSocket Endpoint */
|
|
@@ -2972,6 +3016,7 @@ export class Connection {
|
|
|
2972
3016
|
let fetch;
|
|
2973
3017
|
let fetchMiddleware;
|
|
2974
3018
|
let disableRetryOnRateLimit;
|
|
3019
|
+
let httpAgent;
|
|
2975
3020
|
if (commitmentOrConfig && typeof commitmentOrConfig === 'string') {
|
|
2976
3021
|
this._commitment = commitmentOrConfig;
|
|
2977
3022
|
} else if (commitmentOrConfig) {
|
|
@@ -2983,6 +3028,7 @@ export class Connection {
|
|
|
2983
3028
|
fetch = commitmentOrConfig.fetch;
|
|
2984
3029
|
fetchMiddleware = commitmentOrConfig.fetchMiddleware;
|
|
2985
3030
|
disableRetryOnRateLimit = commitmentOrConfig.disableRetryOnRateLimit;
|
|
3031
|
+
httpAgent = commitmentOrConfig.httpAgent;
|
|
2986
3032
|
}
|
|
2987
3033
|
|
|
2988
3034
|
this._rpcEndpoint = assertEndpointUrl(endpoint);
|
|
@@ -2994,6 +3040,7 @@ export class Connection {
|
|
|
2994
3040
|
fetch,
|
|
2995
3041
|
fetchMiddleware,
|
|
2996
3042
|
disableRetryOnRateLimit,
|
|
3043
|
+
httpAgent,
|
|
2997
3044
|
);
|
|
2998
3045
|
this._rpcRequest = createRpcRequest(this._rpcClient);
|
|
2999
3046
|
this._rpcBatchRequest = createRpcBatchRequest(this._rpcClient);
|