@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/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
declare module '@solana/web3.js' {
|
|
3
3
|
import {Buffer} from 'buffer';
|
|
4
|
+
import {Agent} from 'http';
|
|
5
|
+
import {Agent as Agent$1} from 'https';
|
|
4
6
|
import * as nodeFetch from 'node-fetch';
|
|
5
7
|
|
|
6
8
|
export class Struct {
|
|
@@ -3272,6 +3274,12 @@ declare module '@solana/web3.js' {
|
|
|
3272
3274
|
* Configuration for instantiating a Connection
|
|
3273
3275
|
*/
|
|
3274
3276
|
type ConnectionConfig = {
|
|
3277
|
+
/**
|
|
3278
|
+
* An `http.Agent` that will be used to manage socket connections (eg. to implement connection
|
|
3279
|
+
* persistence). Set this to `false` to create a connection that uses no agent. This applies to
|
|
3280
|
+
* Node environments only.
|
|
3281
|
+
*/
|
|
3282
|
+
httpAgent?: Agent | Agent$1 | false;
|
|
3275
3283
|
/** Optional commitment level */
|
|
3276
3284
|
commitment?: Commitment;
|
|
3277
3285
|
/** Optional endpoint URL to the fullnode JSON RPC PubSub WebSocket Endpoint */
|
package/lib/index.esm.js
CHANGED
|
@@ -8,11 +8,11 @@ import { serialize, deserialize, deserializeUnchecked } from 'borsh';
|
|
|
8
8
|
import * as BufferLayout from '@solana/buffer-layout';
|
|
9
9
|
import { blob } from '@solana/buffer-layout';
|
|
10
10
|
import { toBigIntLE, toBufferLE } from 'bigint-buffer';
|
|
11
|
+
import https, { Agent } from 'https';
|
|
11
12
|
import { coerce, instance, string, tuple, literal, unknown, union, type, optional, any, number, array, nullable, create, boolean, record, assert as assert$1 } from 'superstruct';
|
|
12
13
|
import { Client } from 'rpc-websockets';
|
|
13
14
|
import RpcClient from 'jayson/lib/client/browser';
|
|
14
15
|
import http from 'http';
|
|
15
|
-
import https from 'https';
|
|
16
16
|
import * as nodeFetch from 'node-fetch';
|
|
17
17
|
import { keccak_256 } from '@noble/hashes/sha3';
|
|
18
18
|
import { hmac } from '@noble/hashes/hmac';
|
|
@@ -3916,14 +3916,34 @@ const BlockProductionResponseStruct = jsonRpcResultAndContext(type({
|
|
|
3916
3916
|
* A performance sample
|
|
3917
3917
|
*/
|
|
3918
3918
|
|
|
3919
|
-
function createRpcClient(url, httpHeaders, customFetch, fetchMiddleware, disableRetryOnRateLimit) {
|
|
3919
|
+
function createRpcClient(url, httpHeaders, customFetch, fetchMiddleware, disableRetryOnRateLimit, httpAgent) {
|
|
3920
3920
|
const fetch = customFetch ? customFetch : fetchImpl;
|
|
3921
3921
|
let agentManager;
|
|
3922
3922
|
|
|
3923
3923
|
{
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3924
|
+
if (httpAgent == null) {
|
|
3925
|
+
{
|
|
3926
|
+
agentManager = new AgentManager(url.startsWith('https:')
|
|
3927
|
+
/* useHttps */
|
|
3928
|
+
);
|
|
3929
|
+
}
|
|
3930
|
+
} else {
|
|
3931
|
+
if (httpAgent !== false) {
|
|
3932
|
+
const isHttps = url.startsWith('https:');
|
|
3933
|
+
|
|
3934
|
+
if (isHttps && !(httpAgent instanceof Agent)) {
|
|
3935
|
+
throw new Error('The endpoint `' + url + '` can only be paired with an `https.Agent`. You have, instead, supplied an ' + '`http.Agent` through `httpAgent`.');
|
|
3936
|
+
} else if (!isHttps && httpAgent instanceof Agent) {
|
|
3937
|
+
throw new Error('The endpoint `' + url + '` can only be paired with an `http.Agent`. You have, instead, supplied an ' + '`https.Agent` through `httpAgent`.');
|
|
3938
|
+
}
|
|
3939
|
+
|
|
3940
|
+
agentManager = {
|
|
3941
|
+
requestEnd() {},
|
|
3942
|
+
|
|
3943
|
+
requestStart: () => httpAgent
|
|
3944
|
+
};
|
|
3945
|
+
}
|
|
3946
|
+
}
|
|
3927
3947
|
}
|
|
3928
3948
|
|
|
3929
3949
|
let fetchWithMiddleware;
|
|
@@ -4833,6 +4853,7 @@ class Connection {
|
|
|
4833
4853
|
let fetch;
|
|
4834
4854
|
let fetchMiddleware;
|
|
4835
4855
|
let disableRetryOnRateLimit;
|
|
4856
|
+
let httpAgent;
|
|
4836
4857
|
|
|
4837
4858
|
if (commitmentOrConfig && typeof commitmentOrConfig === 'string') {
|
|
4838
4859
|
this._commitment = commitmentOrConfig;
|
|
@@ -4844,11 +4865,12 @@ class Connection {
|
|
|
4844
4865
|
fetch = commitmentOrConfig.fetch;
|
|
4845
4866
|
fetchMiddleware = commitmentOrConfig.fetchMiddleware;
|
|
4846
4867
|
disableRetryOnRateLimit = commitmentOrConfig.disableRetryOnRateLimit;
|
|
4868
|
+
httpAgent = commitmentOrConfig.httpAgent;
|
|
4847
4869
|
}
|
|
4848
4870
|
|
|
4849
4871
|
this._rpcEndpoint = assertEndpointUrl(endpoint);
|
|
4850
4872
|
this._rpcWsEndpoint = wsEndpoint || makeWebsocketUrl(endpoint);
|
|
4851
|
-
this._rpcClient = createRpcClient(endpoint, httpHeaders, fetch, fetchMiddleware, disableRetryOnRateLimit);
|
|
4873
|
+
this._rpcClient = createRpcClient(endpoint, httpHeaders, fetch, fetchMiddleware, disableRetryOnRateLimit, httpAgent);
|
|
4852
4874
|
this._rpcRequest = createRpcRequest(this._rpcClient);
|
|
4853
4875
|
this._rpcBatchRequest = createRpcBatchRequest(this._rpcClient);
|
|
4854
4876
|
this._rpcWebSocket = new Client(this._rpcWsEndpoint, {
|