@solana/web3.js 1.70.0 → 1.70.1-pr-29195

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.
@@ -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 WebsocketFactory = 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 WebsocketFactory__default = /*#__PURE__*/_interopDefaultLegacy(WebsocketFactory);
46
49
  var secp256k1__namespace = /*#__PURE__*/_interopNamespace(secp256k1);
47
50
 
48
51
  /**
@@ -126,6 +129,7 @@ class Enum extends Struct {
126
129
  }
127
130
  const SOLANA_SCHEMA = new Map();
128
131
 
132
+ let _Symbol$toStringTag;
129
133
  /**
130
134
  * Maximum length of derived pubkey seed
131
135
  */
@@ -150,6 +154,7 @@ let uniquePublicKeyCounter = 1;
150
154
  * A public key
151
155
  */
152
156
 
157
+ _Symbol$toStringTag = Symbol.toStringTag;
153
158
  class PublicKey extends Struct {
154
159
  /** @internal */
155
160
 
@@ -240,6 +245,10 @@ class PublicKey extends Struct {
240
245
  b.copy(zeroPad, 32 - b.length);
241
246
  return zeroPad;
242
247
  }
248
+
249
+ get [_Symbol$toStringTag]() {
250
+ return `PublicKey(${this.toString()})`;
251
+ }
243
252
  /**
244
253
  * Return the base-58 representation of the public key
245
254
  */
@@ -3538,6 +3547,56 @@ class SolanaJSONRPCError extends Error {
3538
3547
 
3539
3548
  var fetchImpl = globalThis.fetch;
3540
3549
 
3550
+ class RpcWebSocketClient extends RpcWebSocketCommonClient__default["default"] {
3551
+ constructor(address, options, generate_request_id) {
3552
+ const webSocketFactory = url => {
3553
+ const rpc = WebsocketFactory__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 === WebSocket.OPEN) {
3580
+ return super.call(...args);
3581
+ }
3582
+
3583
+ throw new Error('Tried to call a JSON-RPC method `' + args[0] + '` but the socket was not `CONNECTING` or `OPEN` (`readyState` was ' + readyState + ')');
3584
+ }
3585
+
3586
+ notify(...args) {
3587
+ var _this$underlyingSocke2;
3588
+
3589
+ const readyState = (_this$underlyingSocke2 = this.underlyingSocket) === null || _this$underlyingSocke2 === void 0 ? void 0 : _this$underlyingSocke2.readyState;
3590
+
3591
+ if (readyState === WebSocket.OPEN) {
3592
+ return super.notify(...args);
3593
+ }
3594
+
3595
+ throw new Error('Tried to send a JSON-RPC notification `' + args[0] + '` but the socket was not `CONNECTING` or `OPEN` (`readyState` was ' + readyState + ')');
3596
+ }
3597
+
3598
+ }
3599
+
3541
3600
  // TODO: These constants should be removed in favor of reading them out of a
3542
3601
  // Syscall account
3543
3602
 
@@ -4696,7 +4755,7 @@ const LogsNotificationResult = superstruct.type({
4696
4755
 
4697
4756
  /** @internal */
4698
4757
  const COMMON_HTTP_HEADERS = {
4699
- 'solana-client': `js/${(_process$env$npm_pack = "0.0.0-development") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
4758
+ 'solana-client': `js/${(_process$env$npm_pack = "1.70.1-pr-29195") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
4700
4759
  };
4701
4760
  /**
4702
4761
  * A connection to a fullnode JSON RPC endpoint
@@ -4826,7 +4885,7 @@ class Connection {
4826
4885
  this._rpcClient = createRpcClient(endpoint, httpHeaders, fetch, fetchMiddleware, disableRetryOnRateLimit, httpAgent);
4827
4886
  this._rpcRequest = createRpcRequest(this._rpcClient);
4828
4887
  this._rpcBatchRequest = createRpcBatchRequest(this._rpcClient);
4829
- this._rpcWebSocket = new rpcWebsockets.Client(this._rpcWsEndpoint, {
4888
+ this._rpcWebSocket = new RpcWebSocketClient(this._rpcWsEndpoint, {
4830
4889
  autoconnect: false,
4831
4890
  max_reconnects: Infinity
4832
4891
  });