@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.cjs.js
CHANGED
|
@@ -2378,6 +2378,24 @@ function promiseTimeout(promise, timeoutMs) {
|
|
|
2378
2378
|
});
|
|
2379
2379
|
}
|
|
2380
2380
|
|
|
2381
|
+
function makeWebsocketUrl(endpoint) {
|
|
2382
|
+
let url$1 = url.parse(endpoint);
|
|
2383
|
+
const useHttps = url$1.protocol === 'https:';
|
|
2384
|
+
url$1.protocol = useHttps ? 'wss:' : 'ws:';
|
|
2385
|
+
url$1.host = ''; // Only shift the port by +1 as a convention for ws(s) only if given endpoint
|
|
2386
|
+
// is explictly specifying the endpoint port (HTTP-based RPC), assuming
|
|
2387
|
+
// we're directly trying to connect to solana-validator's ws listening port.
|
|
2388
|
+
// When the endpoint omits the port, we're connecting to the protocol
|
|
2389
|
+
// default ports: http(80) or https(443) and it's assumed we're behind a reverse
|
|
2390
|
+
// proxy which manages WebSocket upgrade and backend port redirection.
|
|
2391
|
+
|
|
2392
|
+
if (url$1.port !== null) {
|
|
2393
|
+
url$1.port = String(Number(url$1.port) + 1);
|
|
2394
|
+
}
|
|
2395
|
+
|
|
2396
|
+
return url.format(url$1);
|
|
2397
|
+
}
|
|
2398
|
+
|
|
2381
2399
|
const PublicKeyFromString = superstruct.coerce(superstruct.instance(PublicKey), superstruct.string(), value => new PublicKey(value));
|
|
2382
2400
|
const RawAccountDataResult = superstruct.tuple([superstruct.string(), superstruct.literal('base64')]);
|
|
2383
2401
|
const BufferFromRawAccountData = superstruct.coerce(superstruct.instance(buffer.Buffer), RawAccountDataResult, value => buffer.Buffer.from(value[0], 'base64'));
|
|
@@ -3249,6 +3267,10 @@ class Connection {
|
|
|
3249
3267
|
|
|
3250
3268
|
/** @internal */
|
|
3251
3269
|
|
|
3270
|
+
/** @internal */
|
|
3271
|
+
|
|
3272
|
+
/** @internal */
|
|
3273
|
+
|
|
3252
3274
|
/**
|
|
3253
3275
|
* Establish a JSON RPC connection
|
|
3254
3276
|
*
|
|
@@ -3266,6 +3288,13 @@ class Connection {
|
|
|
3266
3288
|
|
|
3267
3289
|
_defineProperty__default['default'](this, "_pollingBlockhash", false);
|
|
3268
3290
|
|
|
3291
|
+
_defineProperty__default['default'](this, "_blockhashInfo", {
|
|
3292
|
+
recentBlockhash: null,
|
|
3293
|
+
lastFetch: 0,
|
|
3294
|
+
transactionSignatures: [],
|
|
3295
|
+
simulatedSignatures: []
|
|
3296
|
+
});
|
|
3297
|
+
|
|
3269
3298
|
_defineProperty__default['default'](this, "_accountChangeSubscriptionCounter", 0);
|
|
3270
3299
|
|
|
3271
3300
|
_defineProperty__default['default'](this, "_accountChangeSubscriptions", {});
|
|
@@ -3294,9 +3323,9 @@ class Connection {
|
|
|
3294
3323
|
|
|
3295
3324
|
_defineProperty__default['default'](this, "_slotUpdateSubscriptions", {});
|
|
3296
3325
|
|
|
3297
|
-
this._rpcEndpoint = endpoint;
|
|
3298
3326
|
let url$1 = url.parse(endpoint);
|
|
3299
3327
|
const useHttps = url$1.protocol === 'https:';
|
|
3328
|
+
let wsEndpoint;
|
|
3300
3329
|
let httpHeaders;
|
|
3301
3330
|
let fetchMiddleware;
|
|
3302
3331
|
|
|
@@ -3304,32 +3333,17 @@ class Connection {
|
|
|
3304
3333
|
this._commitment = commitmentOrConfig;
|
|
3305
3334
|
} else if (commitmentOrConfig) {
|
|
3306
3335
|
this._commitment = commitmentOrConfig.commitment;
|
|
3336
|
+
wsEndpoint = commitmentOrConfig.wsEndpoint;
|
|
3307
3337
|
httpHeaders = commitmentOrConfig.httpHeaders;
|
|
3308
3338
|
fetchMiddleware = commitmentOrConfig.fetchMiddleware;
|
|
3309
3339
|
}
|
|
3310
3340
|
|
|
3341
|
+
this._rpcEndpoint = endpoint;
|
|
3342
|
+
this._rpcWsEndpoint = wsEndpoint || makeWebsocketUrl(endpoint);
|
|
3311
3343
|
this._rpcClient = createRpcClient(url$1.href, useHttps, httpHeaders, fetchMiddleware);
|
|
3312
3344
|
this._rpcRequest = createRpcRequest(this._rpcClient);
|
|
3313
3345
|
this._rpcBatchRequest = createRpcBatchRequest(this._rpcClient);
|
|
3314
|
-
this.
|
|
3315
|
-
recentBlockhash: null,
|
|
3316
|
-
lastFetch: 0,
|
|
3317
|
-
transactionSignatures: [],
|
|
3318
|
-
simulatedSignatures: []
|
|
3319
|
-
};
|
|
3320
|
-
url$1.protocol = useHttps ? 'wss:' : 'ws:';
|
|
3321
|
-
url$1.host = ''; // Only shift the port by +1 as a convention for ws(s) only if given endpoint
|
|
3322
|
-
// is explictly specifying the endpoint port (HTTP-based RPC), assuming
|
|
3323
|
-
// we're directly trying to connect to solana-validator's ws listening port.
|
|
3324
|
-
// When the endpoint omits the port, we're connecting to the protocol
|
|
3325
|
-
// default ports: http(80) or https(443) and it's assumed we're behind a reverse
|
|
3326
|
-
// proxy which manages WebSocket upgrade and backend port redirection.
|
|
3327
|
-
|
|
3328
|
-
if (url$1.port !== null) {
|
|
3329
|
-
url$1.port = String(Number(url$1.port) + 1);
|
|
3330
|
-
}
|
|
3331
|
-
|
|
3332
|
-
this._rpcWebSocket = new rpcWebsockets.Client(url.format(url$1), {
|
|
3346
|
+
this._rpcWebSocket = new rpcWebsockets.Client(this._rpcWsEndpoint, {
|
|
3333
3347
|
autoconnect: false,
|
|
3334
3348
|
max_reconnects: Infinity
|
|
3335
3349
|
});
|