@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.
package/lib/index.cjs.js CHANGED
@@ -13,10 +13,11 @@ var BufferLayout = require('@solana/buffer-layout');
13
13
  var bigintBuffer = require('bigint-buffer');
14
14
  var https = require('https');
15
15
  var superstruct = require('superstruct');
16
- var rpcWebsockets = require('rpc-websockets');
17
16
  var RpcClient = require('jayson/lib/client/browser');
18
17
  var http = require('http');
19
18
  var nodeFetch = require('node-fetch');
19
+ var RpcWebSocketCommonClient = require('rpc-websockets/dist/lib/client');
20
+ var createRpc = require('rpc-websockets/dist/lib/client/websocket');
20
21
  var sha3 = require('@noble/hashes/sha3');
21
22
  var hmac = require('@noble/hashes/hmac');
22
23
  var secp256k1 = require('@noble/secp256k1');
@@ -49,6 +50,8 @@ var https__default = /*#__PURE__*/_interopDefaultLegacy(https);
49
50
  var RpcClient__default = /*#__PURE__*/_interopDefaultLegacy(RpcClient);
50
51
  var http__default = /*#__PURE__*/_interopDefaultLegacy(http);
51
52
  var nodeFetch__namespace = /*#__PURE__*/_interopNamespace(nodeFetch);
53
+ var RpcWebSocketCommonClient__default = /*#__PURE__*/_interopDefaultLegacy(RpcWebSocketCommonClient);
54
+ var createRpc__default = /*#__PURE__*/_interopDefaultLegacy(createRpc);
52
55
  var secp256k1__namespace = /*#__PURE__*/_interopNamespace(secp256k1);
53
56
 
54
57
  /**
@@ -132,6 +135,7 @@ class Enum extends Struct {
132
135
  }
133
136
  const SOLANA_SCHEMA = new Map();
134
137
 
138
+ let _Symbol$toStringTag;
135
139
  /**
136
140
  * Maximum length of derived pubkey seed
137
141
  */
@@ -156,6 +160,7 @@ let uniquePublicKeyCounter = 1;
156
160
  * A public key
157
161
  */
158
162
 
163
+ _Symbol$toStringTag = Symbol.toStringTag;
159
164
  class PublicKey extends Struct {
160
165
  /** @internal */
161
166
 
@@ -246,6 +251,10 @@ class PublicKey extends Struct {
246
251
  b.copy(zeroPad, 32 - b.length);
247
252
  return zeroPad;
248
253
  }
254
+
255
+ get [_Symbol$toStringTag]() {
256
+ return `PublicKey(${this.toString()})`;
257
+ }
249
258
  /**
250
259
  * Return the base-58 representation of the public key
251
260
  */
@@ -3596,6 +3605,56 @@ async function fetchImpl (input, init) {
3596
3605
  return await nodeFetch__namespace.default(processedInput, init);
3597
3606
  }
3598
3607
 
3608
+ class RpcWebSocketClient extends RpcWebSocketCommonClient__default["default"] {
3609
+ constructor(address, options, generate_request_id) {
3610
+ const webSocketFactory = url => {
3611
+ const rpc = createRpc__default["default"](url, {
3612
+ autoconnect: true,
3613
+ max_reconnects: 5,
3614
+ reconnect: true,
3615
+ reconnect_interval: 1000,
3616
+ ...options
3617
+ });
3618
+
3619
+ if ('socket' in rpc) {
3620
+ this.underlyingSocket = rpc.socket;
3621
+ } else {
3622
+ this.underlyingSocket = rpc;
3623
+ }
3624
+
3625
+ return rpc;
3626
+ };
3627
+
3628
+ super(webSocketFactory, address, options, generate_request_id);
3629
+ this.underlyingSocket = void 0;
3630
+ }
3631
+
3632
+ call(...args) {
3633
+ var _this$underlyingSocke;
3634
+
3635
+ const readyState = (_this$underlyingSocke = this.underlyingSocket) === null || _this$underlyingSocke === void 0 ? void 0 : _this$underlyingSocke.readyState;
3636
+
3637
+ if (readyState === WebSocket.OPEN) {
3638
+ return super.call(...args);
3639
+ }
3640
+
3641
+ throw new Error('Tried to call a JSON-RPC method `' + args[0] + '` but the socket was not `CONNECTING` or `OPEN` (`readyState` was ' + readyState + ')');
3642
+ }
3643
+
3644
+ notify(...args) {
3645
+ var _this$underlyingSocke2;
3646
+
3647
+ const readyState = (_this$underlyingSocke2 = this.underlyingSocket) === null || _this$underlyingSocke2 === void 0 ? void 0 : _this$underlyingSocke2.readyState;
3648
+
3649
+ if (readyState === WebSocket.OPEN) {
3650
+ return super.notify(...args);
3651
+ }
3652
+
3653
+ throw new Error('Tried to send a JSON-RPC notification `' + args[0] + '` but the socket was not `CONNECTING` or `OPEN` (`readyState` was ' + readyState + ')');
3654
+ }
3655
+
3656
+ }
3657
+
3599
3658
  // TODO: These constants should be removed in favor of reading them out of a
3600
3659
  // Syscall account
3601
3660
 
@@ -4776,7 +4835,7 @@ const LogsNotificationResult = superstruct.type({
4776
4835
 
4777
4836
  /** @internal */
4778
4837
  const COMMON_HTTP_HEADERS = {
4779
- 'solana-client': `js/${(_process$env$npm_pack = "0.0.0-development") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
4838
+ 'solana-client': `js/${(_process$env$npm_pack = "1.70.1-pr-29195") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
4780
4839
  };
4781
4840
  /**
4782
4841
  * A connection to a fullnode JSON RPC endpoint
@@ -4906,7 +4965,7 @@ class Connection {
4906
4965
  this._rpcClient = createRpcClient(endpoint, httpHeaders, fetch, fetchMiddleware, disableRetryOnRateLimit, httpAgent);
4907
4966
  this._rpcRequest = createRpcRequest(this._rpcClient);
4908
4967
  this._rpcBatchRequest = createRpcBatchRequest(this._rpcClient);
4909
- this._rpcWebSocket = new rpcWebsockets.Client(this._rpcWsEndpoint, {
4968
+ this._rpcWebSocket = new RpcWebSocketClient(this._rpcWsEndpoint, {
4910
4969
  autoconnect: false,
4911
4970
  max_reconnects: Infinity
4912
4971
  });