@solana/web3.js 1.14.1 → 1.15.1
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.esm.js +34 -20
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +34 -20
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.esm.js +35 -21
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +34 -20
- 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/module.flow.js +5 -0
- package/package.json +3 -3
- package/src/connection.ts +16 -23
- package/src/util/url.ts +20 -0
package/lib/index.browser.esm.js
CHANGED
|
@@ -4286,6 +4286,24 @@ function promiseTimeout(promise, timeoutMs) {
|
|
|
4286
4286
|
});
|
|
4287
4287
|
}
|
|
4288
4288
|
|
|
4289
|
+
function makeWebsocketUrl(endpoint) {
|
|
4290
|
+
let url = urlParse(endpoint);
|
|
4291
|
+
const useHttps = url.protocol === 'https:';
|
|
4292
|
+
url.protocol = useHttps ? 'wss:' : 'ws:';
|
|
4293
|
+
url.host = ''; // Only shift the port by +1 as a convention for ws(s) only if given endpoint
|
|
4294
|
+
// is explictly specifying the endpoint port (HTTP-based RPC), assuming
|
|
4295
|
+
// we're directly trying to connect to solana-validator's ws listening port.
|
|
4296
|
+
// When the endpoint omits the port, we're connecting to the protocol
|
|
4297
|
+
// default ports: http(80) or https(443) and it's assumed we're behind a reverse
|
|
4298
|
+
// proxy which manages WebSocket upgrade and backend port redirection.
|
|
4299
|
+
|
|
4300
|
+
if (url.port !== null) {
|
|
4301
|
+
url.port = String(Number(url.port) + 1);
|
|
4302
|
+
}
|
|
4303
|
+
|
|
4304
|
+
return urlFormat(url);
|
|
4305
|
+
}
|
|
4306
|
+
|
|
4289
4307
|
const PublicKeyFromString = coerce(instance(PublicKey), string(), value => new PublicKey(value));
|
|
4290
4308
|
const RawAccountDataResult = tuple([string(), literal('base64')]);
|
|
4291
4309
|
const BufferFromRawAccountData = coerce(instance(Buffer), RawAccountDataResult, value => Buffer.from(value[0], 'base64'));
|
|
@@ -5151,6 +5169,10 @@ class Connection {
|
|
|
5151
5169
|
|
|
5152
5170
|
/** @internal */
|
|
5153
5171
|
|
|
5172
|
+
/** @internal */
|
|
5173
|
+
|
|
5174
|
+
/** @internal */
|
|
5175
|
+
|
|
5154
5176
|
/**
|
|
5155
5177
|
* Establish a JSON RPC connection
|
|
5156
5178
|
*
|
|
@@ -5168,6 +5190,13 @@ class Connection {
|
|
|
5168
5190
|
|
|
5169
5191
|
_defineProperty(this, "_pollingBlockhash", false);
|
|
5170
5192
|
|
|
5193
|
+
_defineProperty(this, "_blockhashInfo", {
|
|
5194
|
+
recentBlockhash: null,
|
|
5195
|
+
lastFetch: 0,
|
|
5196
|
+
transactionSignatures: [],
|
|
5197
|
+
simulatedSignatures: []
|
|
5198
|
+
});
|
|
5199
|
+
|
|
5171
5200
|
_defineProperty(this, "_accountChangeSubscriptionCounter", 0);
|
|
5172
5201
|
|
|
5173
5202
|
_defineProperty(this, "_accountChangeSubscriptions", {});
|
|
@@ -5196,9 +5225,9 @@ class Connection {
|
|
|
5196
5225
|
|
|
5197
5226
|
_defineProperty(this, "_slotUpdateSubscriptions", {});
|
|
5198
5227
|
|
|
5199
|
-
this._rpcEndpoint = endpoint;
|
|
5200
5228
|
let url = urlParse(endpoint);
|
|
5201
5229
|
const useHttps = url.protocol === 'https:';
|
|
5230
|
+
let wsEndpoint;
|
|
5202
5231
|
let httpHeaders;
|
|
5203
5232
|
let fetchMiddleware;
|
|
5204
5233
|
|
|
@@ -5206,32 +5235,17 @@ class Connection {
|
|
|
5206
5235
|
this._commitment = commitmentOrConfig;
|
|
5207
5236
|
} else if (commitmentOrConfig) {
|
|
5208
5237
|
this._commitment = commitmentOrConfig.commitment;
|
|
5238
|
+
wsEndpoint = commitmentOrConfig.wsEndpoint;
|
|
5209
5239
|
httpHeaders = commitmentOrConfig.httpHeaders;
|
|
5210
5240
|
fetchMiddleware = commitmentOrConfig.fetchMiddleware;
|
|
5211
5241
|
}
|
|
5212
5242
|
|
|
5243
|
+
this._rpcEndpoint = endpoint;
|
|
5244
|
+
this._rpcWsEndpoint = wsEndpoint || makeWebsocketUrl(endpoint);
|
|
5213
5245
|
this._rpcClient = createRpcClient(url.href, useHttps, httpHeaders, fetchMiddleware);
|
|
5214
5246
|
this._rpcRequest = createRpcRequest(this._rpcClient);
|
|
5215
5247
|
this._rpcBatchRequest = createRpcBatchRequest(this._rpcClient);
|
|
5216
|
-
this.
|
|
5217
|
-
recentBlockhash: null,
|
|
5218
|
-
lastFetch: 0,
|
|
5219
|
-
transactionSignatures: [],
|
|
5220
|
-
simulatedSignatures: []
|
|
5221
|
-
};
|
|
5222
|
-
url.protocol = useHttps ? 'wss:' : 'ws:';
|
|
5223
|
-
url.host = ''; // Only shift the port by +1 as a convention for ws(s) only if given endpoint
|
|
5224
|
-
// is explictly specifying the endpoint port (HTTP-based RPC), assuming
|
|
5225
|
-
// we're directly trying to connect to solana-validator's ws listening port.
|
|
5226
|
-
// When the endpoint omits the port, we're connecting to the protocol
|
|
5227
|
-
// default ports: http(80) or https(443) and it's assumed we're behind a reverse
|
|
5228
|
-
// proxy which manages WebSocket upgrade and backend port redirection.
|
|
5229
|
-
|
|
5230
|
-
if (url.port !== null) {
|
|
5231
|
-
url.port = String(Number(url.port) + 1);
|
|
5232
|
-
}
|
|
5233
|
-
|
|
5234
|
-
this._rpcWebSocket = new Client(urlFormat(url), {
|
|
5248
|
+
this._rpcWebSocket = new Client(this._rpcWsEndpoint, {
|
|
5235
5249
|
autoconnect: false,
|
|
5236
5250
|
max_reconnects: Infinity
|
|
5237
5251
|
});
|