@solana/web3.js 1.73.1-pr-29195.6 → 1.73.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.cjs.js +18 -88
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +18 -86
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +62 -136
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.esm.js +57 -129
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +2021 -2022
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +2 -2
- package/lib/index.iife.min.js.map +1 -1
- package/lib/index.native.js +18 -88
- package/lib/index.native.js.map +1 -1
- package/package.json +1 -1
- package/src/connection.ts +2 -7
- package/src/__forks__/browser/rpc-websocket-factory.ts +0 -1
- package/src/__forks__/react-native/rpc-websocket-factory.ts +0 -1
- package/src/rpc-websocket-factory.ts +0 -4
- package/src/rpc-websocket.ts +0 -79
package/lib/index.browser.cjs.js
CHANGED
|
@@ -12,9 +12,8 @@ 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');
|
|
15
16
|
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');
|
|
18
17
|
var sha3 = require('@noble/hashes/sha3');
|
|
19
18
|
var hmac = require('@noble/hashes/hmac');
|
|
20
19
|
var secp256k1 = require('@noble/secp256k1');
|
|
@@ -44,8 +43,6 @@ var BN__default = /*#__PURE__*/_interopDefaultLegacy(BN);
|
|
|
44
43
|
var bs58__default = /*#__PURE__*/_interopDefaultLegacy(bs58);
|
|
45
44
|
var BufferLayout__namespace = /*#__PURE__*/_interopNamespace(BufferLayout);
|
|
46
45
|
var RpcClient__default = /*#__PURE__*/_interopDefaultLegacy(RpcClient);
|
|
47
|
-
var RpcWebSocketCommonClient__default = /*#__PURE__*/_interopDefaultLegacy(RpcWebSocketCommonClient);
|
|
48
|
-
var createRpc__default = /*#__PURE__*/_interopDefaultLegacy(createRpc);
|
|
49
46
|
var secp256k1__namespace = /*#__PURE__*/_interopNamespace(secp256k1);
|
|
50
47
|
|
|
51
48
|
/**
|
|
@@ -2251,7 +2248,7 @@ async function sendAndConfirmTransaction(connection, transaction, signers, optio
|
|
|
2251
2248
|
|
|
2252
2249
|
if (transaction.recentBlockhash != null && transaction.lastValidBlockHeight != null) {
|
|
2253
2250
|
status = (await connection.confirmTransaction({
|
|
2254
|
-
abortSignal: options
|
|
2251
|
+
abortSignal: options?.abortSignal,
|
|
2255
2252
|
signature: signature,
|
|
2256
2253
|
blockhash: transaction.recentBlockhash,
|
|
2257
2254
|
lastValidBlockHeight: transaction.lastValidBlockHeight
|
|
@@ -2262,14 +2259,14 @@ async function sendAndConfirmTransaction(connection, transaction, signers, optio
|
|
|
2262
2259
|
} = transaction.nonceInfo;
|
|
2263
2260
|
const nonceAccountPubkey = nonceInstruction.keys[0].pubkey;
|
|
2264
2261
|
status = (await connection.confirmTransaction({
|
|
2265
|
-
abortSignal: options
|
|
2262
|
+
abortSignal: options?.abortSignal,
|
|
2266
2263
|
minContextSlot: transaction.minNonceContextSlot,
|
|
2267
2264
|
nonceAccountPubkey,
|
|
2268
2265
|
nonceValue: transaction.nonceInfo.nonce,
|
|
2269
2266
|
signature
|
|
2270
2267
|
}, options && options.commitment)).value;
|
|
2271
2268
|
} else {
|
|
2272
|
-
if (
|
|
2269
|
+
if (options?.abortSignal != null) {
|
|
2273
2270
|
console.warn('sendAndConfirmTransaction(): A transaction with a deprecated confirmation strategy was ' + 'supplied along with an `abortSignal`. Only transactions having `lastValidBlockHeight` ' + 'or a combination of `nonceInfo` and `minNonceContextSlot` are abortable.');
|
|
2274
2271
|
}
|
|
2275
2272
|
|
|
@@ -3550,60 +3547,6 @@ class SolanaJSONRPCError extends Error {
|
|
|
3550
3547
|
|
|
3551
3548
|
var fetchImpl = globalThis.fetch;
|
|
3552
3549
|
|
|
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
|
-
|
|
3607
3550
|
// TODO: These constants should be removed in favor of reading them out of a
|
|
3608
3551
|
// Syscall account
|
|
3609
3552
|
|
|
@@ -3713,7 +3656,6 @@ function makeWebsocketUrl(endpoint) {
|
|
|
3713
3656
|
return `${protocol}//${hostish}${websocketPort}${rest}`;
|
|
3714
3657
|
}
|
|
3715
3658
|
|
|
3716
|
-
var _process$env$npm_pack;
|
|
3717
3659
|
const PublicKeyFromString = superstruct.coerce(superstruct.instance(PublicKey), superstruct.string(), value => new PublicKey(value));
|
|
3718
3660
|
const RawAccountDataResult = superstruct.tuple([superstruct.string(), superstruct.literal('base64')]);
|
|
3719
3661
|
const BufferFromRawAccountData = superstruct.coerce(superstruct.instance(buffer.Buffer), RawAccountDataResult, value => buffer.Buffer.from(value[0], 'base64'));
|
|
@@ -4778,7 +4720,7 @@ const LogsNotificationResult = superstruct.type({
|
|
|
4778
4720
|
|
|
4779
4721
|
/** @internal */
|
|
4780
4722
|
const COMMON_HTTP_HEADERS = {
|
|
4781
|
-
'solana-client': `js/${
|
|
4723
|
+
'solana-client': `js/${"0.0.0-development" }`
|
|
4782
4724
|
};
|
|
4783
4725
|
/**
|
|
4784
4726
|
* A connection to a fullnode JSON RPC endpoint
|
|
@@ -4908,7 +4850,7 @@ class Connection {
|
|
|
4908
4850
|
this._rpcClient = createRpcClient(endpoint, httpHeaders, fetch, fetchMiddleware, disableRetryOnRateLimit, httpAgent);
|
|
4909
4851
|
this._rpcRequest = createRpcRequest(this._rpcClient);
|
|
4910
4852
|
this._rpcBatchRequest = createRpcBatchRequest(this._rpcClient);
|
|
4911
|
-
this._rpcWebSocket = new
|
|
4853
|
+
this._rpcWebSocket = new rpcWebsockets.Client(this._rpcWsEndpoint, {
|
|
4912
4854
|
autoconnect: false,
|
|
4913
4855
|
max_reconnects: Infinity
|
|
4914
4856
|
});
|
|
@@ -5324,7 +5266,7 @@ class Connection {
|
|
|
5324
5266
|
const args = this._buildArgs([publicKey.toBase58()], commitment, undefined
|
|
5325
5267
|
/* encoding */
|
|
5326
5268
|
, { ...config,
|
|
5327
|
-
epoch: epoch != null ? epoch : config
|
|
5269
|
+
epoch: epoch != null ? epoch : config?.epoch
|
|
5328
5270
|
});
|
|
5329
5271
|
|
|
5330
5272
|
const unsafeRes = await this._rpcRequest('getStakeActivation', args);
|
|
@@ -5396,11 +5338,9 @@ class Connection {
|
|
|
5396
5338
|
if (typeof strategy == 'string') {
|
|
5397
5339
|
rawSignature = strategy;
|
|
5398
5340
|
} else {
|
|
5399
|
-
var _config$abortSignal;
|
|
5400
|
-
|
|
5401
5341
|
const config = strategy;
|
|
5402
5342
|
|
|
5403
|
-
if (
|
|
5343
|
+
if (config.abortSignal?.aborted) {
|
|
5404
5344
|
return Promise.reject(config.abortSignal.reason);
|
|
5405
5345
|
}
|
|
5406
5346
|
|
|
@@ -5502,7 +5442,7 @@ class Connection {
|
|
|
5502
5442
|
return;
|
|
5503
5443
|
}
|
|
5504
5444
|
|
|
5505
|
-
if (value
|
|
5445
|
+
if (value?.err) {
|
|
5506
5446
|
reject(value.err);
|
|
5507
5447
|
} else {
|
|
5508
5448
|
switch (commitment) {
|
|
@@ -5652,7 +5592,7 @@ class Connection {
|
|
|
5652
5592
|
minContextSlot
|
|
5653
5593
|
});
|
|
5654
5594
|
lastCheckedSlot = context.slot;
|
|
5655
|
-
return nonceAccount
|
|
5595
|
+
return nonceAccount?.nonce;
|
|
5656
5596
|
} catch (e) {
|
|
5657
5597
|
// If for whatever reason we can't reach/read the nonce
|
|
5658
5598
|
// account, just keep using the last-known value.
|
|
@@ -5697,22 +5637,18 @@ class Connection {
|
|
|
5697
5637
|
if (outcome.__type === exports.TransactionStatus.PROCESSED) {
|
|
5698
5638
|
result = outcome.response;
|
|
5699
5639
|
} else {
|
|
5700
|
-
var _signatureStatus;
|
|
5701
|
-
|
|
5702
5640
|
// Double check that the transaction is indeed unconfirmed.
|
|
5703
5641
|
let signatureStatus;
|
|
5704
5642
|
|
|
5705
5643
|
while (true // eslint-disable-line no-constant-condition
|
|
5706
5644
|
) {
|
|
5707
|
-
var _outcome$slotInWhichN;
|
|
5708
|
-
|
|
5709
5645
|
const status = await this.getSignatureStatus(signature);
|
|
5710
5646
|
|
|
5711
5647
|
if (status == null) {
|
|
5712
5648
|
break;
|
|
5713
5649
|
}
|
|
5714
5650
|
|
|
5715
|
-
if (status.context.slot < (
|
|
5651
|
+
if (status.context.slot < (outcome.slotInWhichNonceDidAdvance ?? minContextSlot)) {
|
|
5716
5652
|
await sleep(400);
|
|
5717
5653
|
continue;
|
|
5718
5654
|
}
|
|
@@ -5721,7 +5657,7 @@ class Connection {
|
|
|
5721
5657
|
break;
|
|
5722
5658
|
}
|
|
5723
5659
|
|
|
5724
|
-
if (
|
|
5660
|
+
if (signatureStatus?.value) {
|
|
5725
5661
|
const commitmentForStatus = commitment || 'finalized';
|
|
5726
5662
|
const {
|
|
5727
5663
|
confirmationStatus
|
|
@@ -6034,7 +5970,7 @@ class Connection {
|
|
|
6034
5970
|
const args = this._buildArgs([addresses.map(pubkey => pubkey.toBase58())], commitment, undefined
|
|
6035
5971
|
/* encoding */
|
|
6036
5972
|
, { ...config,
|
|
6037
|
-
epoch: epoch != null ? epoch : config
|
|
5973
|
+
epoch: epoch != null ? epoch : config?.epoch
|
|
6038
5974
|
});
|
|
6039
5975
|
|
|
6040
5976
|
const unsafeRes = await this._rpcRequest('getInflationReward', args);
|
|
@@ -6331,7 +6267,7 @@ class Connection {
|
|
|
6331
6267
|
const unsafeRes = await this._rpcRequest('getBlock', args);
|
|
6332
6268
|
|
|
6333
6269
|
try {
|
|
6334
|
-
switch (config
|
|
6270
|
+
switch (config?.transactionDetails) {
|
|
6335
6271
|
case 'accounts':
|
|
6336
6272
|
{
|
|
6337
6273
|
const res = superstruct.create(unsafeRes, GetAccountsModeBlockRpcResult);
|
|
@@ -6401,7 +6337,7 @@ class Connection {
|
|
|
6401
6337
|
const unsafeRes = await this._rpcRequest('getBlock', args);
|
|
6402
6338
|
|
|
6403
6339
|
try {
|
|
6404
|
-
switch (config
|
|
6340
|
+
switch (config?.transactionDetails) {
|
|
6405
6341
|
case 'accounts':
|
|
6406
6342
|
{
|
|
6407
6343
|
const res = superstruct.create(unsafeRes, GetParsedAccountsModeBlockRpcResult);
|
|
@@ -7362,11 +7298,7 @@ class Connection {
|
|
|
7362
7298
|
this._rpcWebSocketConnected = true;
|
|
7363
7299
|
this._rpcWebSocketHeartbeat = setInterval(() => {
|
|
7364
7300
|
// Ping server every 5s to prevent idle timeouts
|
|
7365
|
-
(
|
|
7366
|
-
try {
|
|
7367
|
-
await this._rpcWebSocket.notify('ping'); // eslint-disable-next-line no-empty
|
|
7368
|
-
} catch {}
|
|
7369
|
-
})();
|
|
7301
|
+
this._rpcWebSocket.notify('ping').catch(() => {});
|
|
7370
7302
|
}, 5000);
|
|
7371
7303
|
|
|
7372
7304
|
this._updateSubscriptions();
|
|
@@ -7420,9 +7352,7 @@ class Connection {
|
|
|
7420
7352
|
|
|
7421
7353
|
|
|
7422
7354
|
_setSubscription(hash, nextSubscription) {
|
|
7423
|
-
|
|
7424
|
-
|
|
7425
|
-
const prevState = (_this$_subscriptionsB = this._subscriptionsByHash[hash]) === null || _this$_subscriptionsB === void 0 ? void 0 : _this$_subscriptionsB.state;
|
|
7355
|
+
const prevState = this._subscriptionsByHash[hash]?.state;
|
|
7426
7356
|
this._subscriptionsByHash[hash] = nextSubscription;
|
|
7427
7357
|
|
|
7428
7358
|
if (prevState !== nextSubscription.state) {
|
|
@@ -8180,7 +8110,7 @@ class Keypair {
|
|
|
8180
8110
|
*/
|
|
8181
8111
|
constructor(keypair) {
|
|
8182
8112
|
this._keypair = void 0;
|
|
8183
|
-
this._keypair = keypair
|
|
8113
|
+
this._keypair = keypair ?? generateKeypair();
|
|
8184
8114
|
}
|
|
8185
8115
|
/**
|
|
8186
8116
|
* Generate a new random keypair
|