@solana/web3.js 1.70.1-pr-29195.5 → 1.70.2
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.browser.cjs.js +7 -69
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +7 -67
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +2452 -134
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.esm.js +2445 -130
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +1972 -1965
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +3 -3
- package/lib/index.iife.min.js.map +1 -1
- package/lib/index.native.js +7 -69
- package/lib/index.native.js.map +1 -1
- package/package.json +2 -1
- package/src/connection.ts +25 -24
- package/src/publickey.ts +2 -2
- package/src/__forks__/browser/rpc-websocket-factory.ts +0 -1
- package/src/__forks__/react-native/rpc-websocket-factory.ts +0 -1
- package/src/agent-manager.ts +0 -44
- package/src/rpc-websocket-factory.ts +0 -4
- package/src/rpc-websocket.ts +0 -79
package/lib/index.browser.cjs.js
CHANGED
|
@@ -12,9 +12,8 @@ var borsh = require('borsh');
|
|
|
12
12
|
var BufferLayout = require('@solana/buffer-layout');
|
|
13
13
|
var bigintBuffer = require('bigint-buffer');
|
|
14
14
|
var superstruct = require('superstruct');
|
|
15
|
+
var rpcWebsockets = require('rpc-websockets');
|
|
15
16
|
var RpcClient = require('jayson/lib/client/browser');
|
|
16
|
-
var RpcWebSocketCommonClient = require('rpc-websockets/dist/lib/client');
|
|
17
|
-
var createRpc = require('rpc-websockets/dist/lib/client/websocket.browser');
|
|
18
17
|
var sha3 = require('@noble/hashes/sha3');
|
|
19
18
|
var hmac = require('@noble/hashes/hmac');
|
|
20
19
|
var secp256k1 = require('@noble/secp256k1');
|
|
@@ -44,8 +43,6 @@ var BN__default = /*#__PURE__*/_interopDefaultLegacy(BN);
|
|
|
44
43
|
var bs58__default = /*#__PURE__*/_interopDefaultLegacy(bs58);
|
|
45
44
|
var BufferLayout__namespace = /*#__PURE__*/_interopNamespace(BufferLayout);
|
|
46
45
|
var RpcClient__default = /*#__PURE__*/_interopDefaultLegacy(RpcClient);
|
|
47
|
-
var RpcWebSocketCommonClient__default = /*#__PURE__*/_interopDefaultLegacy(RpcWebSocketCommonClient);
|
|
48
|
-
var createRpc__default = /*#__PURE__*/_interopDefaultLegacy(createRpc);
|
|
49
46
|
var secp256k1__namespace = /*#__PURE__*/_interopNamespace(secp256k1);
|
|
50
47
|
|
|
51
48
|
/**
|
|
@@ -222,7 +219,7 @@ class PublicKey extends Struct {
|
|
|
222
219
|
return this.toBase58();
|
|
223
220
|
}
|
|
224
221
|
/**
|
|
225
|
-
* Return the byte array representation of the public key
|
|
222
|
+
* Return the byte array representation of the public key in big endian
|
|
226
223
|
*/
|
|
227
224
|
|
|
228
225
|
|
|
@@ -230,7 +227,7 @@ class PublicKey extends Struct {
|
|
|
230
227
|
return this.toBuffer();
|
|
231
228
|
}
|
|
232
229
|
/**
|
|
233
|
-
* Return the Buffer representation of the public key
|
|
230
|
+
* Return the Buffer representation of the public key in big endian
|
|
234
231
|
*/
|
|
235
232
|
|
|
236
233
|
|
|
@@ -3547,60 +3544,6 @@ class SolanaJSONRPCError extends Error {
|
|
|
3547
3544
|
|
|
3548
3545
|
var fetchImpl = globalThis.fetch;
|
|
3549
3546
|
|
|
3550
|
-
class RpcWebSocketClient extends RpcWebSocketCommonClient__default["default"] {
|
|
3551
|
-
constructor(address, options, generate_request_id) {
|
|
3552
|
-
const webSocketFactory = url => {
|
|
3553
|
-
const rpc = createRpc__default["default"](url, {
|
|
3554
|
-
autoconnect: true,
|
|
3555
|
-
max_reconnects: 5,
|
|
3556
|
-
reconnect: true,
|
|
3557
|
-
reconnect_interval: 1000,
|
|
3558
|
-
...options
|
|
3559
|
-
});
|
|
3560
|
-
|
|
3561
|
-
if ('socket' in rpc) {
|
|
3562
|
-
this.underlyingSocket = rpc.socket;
|
|
3563
|
-
} else {
|
|
3564
|
-
this.underlyingSocket = rpc;
|
|
3565
|
-
}
|
|
3566
|
-
|
|
3567
|
-
return rpc;
|
|
3568
|
-
};
|
|
3569
|
-
|
|
3570
|
-
super(webSocketFactory, address, options, generate_request_id);
|
|
3571
|
-
this.underlyingSocket = void 0;
|
|
3572
|
-
}
|
|
3573
|
-
|
|
3574
|
-
call(...args) {
|
|
3575
|
-
var _this$underlyingSocke;
|
|
3576
|
-
|
|
3577
|
-
const readyState = (_this$underlyingSocke = this.underlyingSocket) === null || _this$underlyingSocke === void 0 ? void 0 : _this$underlyingSocke.readyState;
|
|
3578
|
-
|
|
3579
|
-
if (readyState === 1
|
|
3580
|
-
/* WebSocket.OPEN */
|
|
3581
|
-
) {
|
|
3582
|
-
return super.call(...args);
|
|
3583
|
-
}
|
|
3584
|
-
|
|
3585
|
-
return Promise.reject(new Error('Tried to call a JSON-RPC method `' + args[0] + '` but the socket was not `CONNECTING` or `OPEN` (`readyState` was ' + readyState + ')'));
|
|
3586
|
-
}
|
|
3587
|
-
|
|
3588
|
-
notify(...args) {
|
|
3589
|
-
var _this$underlyingSocke2;
|
|
3590
|
-
|
|
3591
|
-
const readyState = (_this$underlyingSocke2 = this.underlyingSocket) === null || _this$underlyingSocke2 === void 0 ? void 0 : _this$underlyingSocke2.readyState;
|
|
3592
|
-
|
|
3593
|
-
if (readyState === 1
|
|
3594
|
-
/* WebSocket.OPEN */
|
|
3595
|
-
) {
|
|
3596
|
-
return super.notify(...args);
|
|
3597
|
-
}
|
|
3598
|
-
|
|
3599
|
-
return Promise.reject(new Error('Tried to send a JSON-RPC notification `' + args[0] + '` but the socket was not `CONNECTING` or `OPEN` (`readyState` was ' + readyState + ')'));
|
|
3600
|
-
}
|
|
3601
|
-
|
|
3602
|
-
}
|
|
3603
|
-
|
|
3604
3547
|
// TODO: These constants should be removed in favor of reading them out of a
|
|
3605
3548
|
// Syscall account
|
|
3606
3549
|
|
|
@@ -3956,6 +3899,7 @@ const BlockProductionResponseStruct = jsonRpcResultAndContext(superstruct.type({
|
|
|
3956
3899
|
|
|
3957
3900
|
function createRpcClient(url, httpHeaders, customFetch, fetchMiddleware, disableRetryOnRateLimit, httpAgent) {
|
|
3958
3901
|
const fetch = customFetch ? customFetch : fetchImpl;
|
|
3902
|
+
let agent;
|
|
3959
3903
|
|
|
3960
3904
|
{
|
|
3961
3905
|
if (httpAgent != null) {
|
|
@@ -3979,7 +3923,6 @@ function createRpcClient(url, httpHeaders, customFetch, fetchMiddleware, disable
|
|
|
3979
3923
|
}
|
|
3980
3924
|
|
|
3981
3925
|
const clientBrowser = new RpcClient__default["default"](async (request, callback) => {
|
|
3982
|
-
const agent = undefined;
|
|
3983
3926
|
const options = {
|
|
3984
3927
|
method: 'POST',
|
|
3985
3928
|
body: request,
|
|
@@ -4031,7 +3974,6 @@ function createRpcClient(url, httpHeaders, customFetch, fetchMiddleware, disable
|
|
|
4031
3974
|
}
|
|
4032
3975
|
} catch (err) {
|
|
4033
3976
|
if (err instanceof Error) callback(err);
|
|
4034
|
-
} finally {
|
|
4035
3977
|
}
|
|
4036
3978
|
}, {});
|
|
4037
3979
|
return clientBrowser;
|
|
@@ -4759,7 +4701,7 @@ const LogsNotificationResult = superstruct.type({
|
|
|
4759
4701
|
|
|
4760
4702
|
/** @internal */
|
|
4761
4703
|
const COMMON_HTTP_HEADERS = {
|
|
4762
|
-
'solana-client': `js/${(_process$env$npm_pack = "
|
|
4704
|
+
'solana-client': `js/${(_process$env$npm_pack = "0.0.0-development") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
|
|
4763
4705
|
};
|
|
4764
4706
|
/**
|
|
4765
4707
|
* A connection to a fullnode JSON RPC endpoint
|
|
@@ -4889,7 +4831,7 @@ class Connection {
|
|
|
4889
4831
|
this._rpcClient = createRpcClient(endpoint, httpHeaders, fetch, fetchMiddleware, disableRetryOnRateLimit, httpAgent);
|
|
4890
4832
|
this._rpcRequest = createRpcRequest(this._rpcClient);
|
|
4891
4833
|
this._rpcBatchRequest = createRpcBatchRequest(this._rpcClient);
|
|
4892
|
-
this._rpcWebSocket = new
|
|
4834
|
+
this._rpcWebSocket = new rpcWebsockets.Client(this._rpcWsEndpoint, {
|
|
4893
4835
|
autoconnect: false,
|
|
4894
4836
|
max_reconnects: Infinity
|
|
4895
4837
|
});
|
|
@@ -7328,11 +7270,7 @@ class Connection {
|
|
|
7328
7270
|
this._rpcWebSocketConnected = true;
|
|
7329
7271
|
this._rpcWebSocketHeartbeat = setInterval(() => {
|
|
7330
7272
|
// Ping server every 5s to prevent idle timeouts
|
|
7331
|
-
(
|
|
7332
|
-
try {
|
|
7333
|
-
await this._rpcWebSocket.notify('ping'); // eslint-disable-next-line no-empty
|
|
7334
|
-
} catch {}
|
|
7335
|
-
})();
|
|
7273
|
+
this._rpcWebSocket.notify('ping').catch(() => {});
|
|
7336
7274
|
}, 5000);
|
|
7337
7275
|
|
|
7338
7276
|
this._updateSubscriptions();
|