@solana/web3.js 1.73.0 → 1.73.1-pr-29195.6
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 +64 -3
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +62 -3
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +112 -47
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.esm.js +105 -42
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +2244 -2266
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +3 -5
- package/lib/index.iife.min.js.map +1 -1
- package/lib/index.native.js +64 -3
- package/lib/index.native.js.map +1 -1
- package/package.json +2 -2
- package/src/__forks__/browser/rpc-websocket-factory.ts +1 -0
- package/src/__forks__/react-native/rpc-websocket-factory.ts +1 -0
- package/src/connection.ts +9 -4
- package/src/rpc-websocket-factory.ts +4 -0
- package/src/rpc-websocket.ts +79 -0
- package/src/transaction/legacy.ts +1 -1
package/lib/index.browser.cjs.js
CHANGED
|
@@ -12,8 +12,9 @@ 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');
|
|
16
15
|
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');
|
|
17
18
|
var sha3 = require('@noble/hashes/sha3');
|
|
18
19
|
var hmac = require('@noble/hashes/hmac');
|
|
19
20
|
var secp256k1 = require('@noble/secp256k1');
|
|
@@ -43,6 +44,8 @@ var BN__default = /*#__PURE__*/_interopDefaultLegacy(BN);
|
|
|
43
44
|
var bs58__default = /*#__PURE__*/_interopDefaultLegacy(bs58);
|
|
44
45
|
var BufferLayout__namespace = /*#__PURE__*/_interopNamespace(BufferLayout);
|
|
45
46
|
var RpcClient__default = /*#__PURE__*/_interopDefaultLegacy(RpcClient);
|
|
47
|
+
var RpcWebSocketCommonClient__default = /*#__PURE__*/_interopDefaultLegacy(RpcWebSocketCommonClient);
|
|
48
|
+
var createRpc__default = /*#__PURE__*/_interopDefaultLegacy(createRpc);
|
|
46
49
|
var secp256k1__namespace = /*#__PURE__*/_interopNamespace(secp256k1);
|
|
47
50
|
|
|
48
51
|
/**
|
|
@@ -3547,6 +3550,60 @@ class SolanaJSONRPCError extends Error {
|
|
|
3547
3550
|
|
|
3548
3551
|
var fetchImpl = globalThis.fetch;
|
|
3549
3552
|
|
|
3553
|
+
class RpcWebSocketClient extends RpcWebSocketCommonClient__default["default"] {
|
|
3554
|
+
constructor(address, options, generate_request_id) {
|
|
3555
|
+
const webSocketFactory = url => {
|
|
3556
|
+
const rpc = createRpc__default["default"](url, {
|
|
3557
|
+
autoconnect: true,
|
|
3558
|
+
max_reconnects: 5,
|
|
3559
|
+
reconnect: true,
|
|
3560
|
+
reconnect_interval: 1000,
|
|
3561
|
+
...options
|
|
3562
|
+
});
|
|
3563
|
+
|
|
3564
|
+
if ('socket' in rpc) {
|
|
3565
|
+
this.underlyingSocket = rpc.socket;
|
|
3566
|
+
} else {
|
|
3567
|
+
this.underlyingSocket = rpc;
|
|
3568
|
+
}
|
|
3569
|
+
|
|
3570
|
+
return rpc;
|
|
3571
|
+
};
|
|
3572
|
+
|
|
3573
|
+
super(webSocketFactory, address, options, generate_request_id);
|
|
3574
|
+
this.underlyingSocket = void 0;
|
|
3575
|
+
}
|
|
3576
|
+
|
|
3577
|
+
call(...args) {
|
|
3578
|
+
var _this$underlyingSocke;
|
|
3579
|
+
|
|
3580
|
+
const readyState = (_this$underlyingSocke = this.underlyingSocket) === null || _this$underlyingSocke === void 0 ? void 0 : _this$underlyingSocke.readyState;
|
|
3581
|
+
|
|
3582
|
+
if (readyState === 1
|
|
3583
|
+
/* WebSocket.OPEN */
|
|
3584
|
+
) {
|
|
3585
|
+
return super.call(...args);
|
|
3586
|
+
}
|
|
3587
|
+
|
|
3588
|
+
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 + ')'));
|
|
3589
|
+
}
|
|
3590
|
+
|
|
3591
|
+
notify(...args) {
|
|
3592
|
+
var _this$underlyingSocke2;
|
|
3593
|
+
|
|
3594
|
+
const readyState = (_this$underlyingSocke2 = this.underlyingSocket) === null || _this$underlyingSocke2 === void 0 ? void 0 : _this$underlyingSocke2.readyState;
|
|
3595
|
+
|
|
3596
|
+
if (readyState === 1
|
|
3597
|
+
/* WebSocket.OPEN */
|
|
3598
|
+
) {
|
|
3599
|
+
return super.notify(...args);
|
|
3600
|
+
}
|
|
3601
|
+
|
|
3602
|
+
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 + ')'));
|
|
3603
|
+
}
|
|
3604
|
+
|
|
3605
|
+
}
|
|
3606
|
+
|
|
3550
3607
|
// TODO: These constants should be removed in favor of reading them out of a
|
|
3551
3608
|
// Syscall account
|
|
3552
3609
|
|
|
@@ -4851,7 +4908,7 @@ class Connection {
|
|
|
4851
4908
|
this._rpcClient = createRpcClient(endpoint, httpHeaders, fetch, fetchMiddleware, disableRetryOnRateLimit, httpAgent);
|
|
4852
4909
|
this._rpcRequest = createRpcRequest(this._rpcClient);
|
|
4853
4910
|
this._rpcBatchRequest = createRpcBatchRequest(this._rpcClient);
|
|
4854
|
-
this._rpcWebSocket = new
|
|
4911
|
+
this._rpcWebSocket = new RpcWebSocketClient(this._rpcWsEndpoint, {
|
|
4855
4912
|
autoconnect: false,
|
|
4856
4913
|
max_reconnects: Infinity
|
|
4857
4914
|
});
|
|
@@ -7305,7 +7362,11 @@ class Connection {
|
|
|
7305
7362
|
this._rpcWebSocketConnected = true;
|
|
7306
7363
|
this._rpcWebSocketHeartbeat = setInterval(() => {
|
|
7307
7364
|
// Ping server every 5s to prevent idle timeouts
|
|
7308
|
-
|
|
7365
|
+
(async () => {
|
|
7366
|
+
try {
|
|
7367
|
+
await this._rpcWebSocket.notify('ping'); // eslint-disable-next-line no-empty
|
|
7368
|
+
} catch {}
|
|
7369
|
+
})();
|
|
7309
7370
|
}, 5000);
|
|
7310
7371
|
|
|
7311
7372
|
this._updateSubscriptions();
|