@solana/web3.js 1.50.0 → 1.50.2
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 +51 -19
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +51 -19
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +51 -19
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.esm.js +51 -19
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +51 -19
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +3 -3
- package/lib/index.iife.min.js.map +1 -1
- package/lib/index.native.js +51 -19
- package/lib/index.native.js.map +1 -1
- package/package.json +22 -22
- package/src/connection.ts +4 -0
- package/src/message.ts +9 -12
- package/src/transaction.ts +2 -2
- package/src/util/guarded-array-utils.ts +34 -0
- package/src/validator-info.ts +5 -4
package/lib/index.browser.esm.js
CHANGED
|
@@ -2328,6 +2328,36 @@ function encodeLength(bytes, len) {
|
|
|
2328
2328
|
}
|
|
2329
2329
|
}
|
|
2330
2330
|
|
|
2331
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
2332
|
+
/**
|
|
2333
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
2334
|
+
*/
|
|
2335
|
+
|
|
2336
|
+
function guardedShift(byteArray) {
|
|
2337
|
+
if (byteArray.length === 0) {
|
|
2338
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
2339
|
+
}
|
|
2340
|
+
|
|
2341
|
+
return byteArray.shift();
|
|
2342
|
+
}
|
|
2343
|
+
/**
|
|
2344
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
2345
|
+
* the array.
|
|
2346
|
+
*/
|
|
2347
|
+
|
|
2348
|
+
function guardedSplice(byteArray, ...args) {
|
|
2349
|
+
var _args$;
|
|
2350
|
+
|
|
2351
|
+
const [start] = args;
|
|
2352
|
+
|
|
2353
|
+
if (args.length === 2 // Implies that `deleteCount` was supplied
|
|
2354
|
+
? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
|
|
2355
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
2356
|
+
}
|
|
2357
|
+
|
|
2358
|
+
return byteArray.splice(...args);
|
|
2359
|
+
}
|
|
2360
|
+
|
|
2331
2361
|
/**
|
|
2332
2362
|
* The message header, identifying signed and read-only account
|
|
2333
2363
|
*/
|
|
@@ -2426,32 +2456,28 @@ class Message {
|
|
|
2426
2456
|
static from(buffer) {
|
|
2427
2457
|
// Slice up wire data
|
|
2428
2458
|
let byteArray = [...buffer];
|
|
2429
|
-
const numRequiredSignatures = byteArray
|
|
2430
|
-
const numReadonlySignedAccounts = byteArray
|
|
2431
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
2459
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
2460
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
2461
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
2432
2462
|
const accountCount = decodeLength(byteArray);
|
|
2433
2463
|
let accountKeys = [];
|
|
2434
2464
|
|
|
2435
2465
|
for (let i = 0; i < accountCount; i++) {
|
|
2436
|
-
const account = byteArray
|
|
2437
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2466
|
+
const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
2438
2467
|
accountKeys.push(bs58.encode(Buffer.from(account)));
|
|
2439
2468
|
}
|
|
2440
2469
|
|
|
2441
|
-
const recentBlockhash = byteArray
|
|
2442
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2470
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
2443
2471
|
const instructionCount = decodeLength(byteArray);
|
|
2444
2472
|
let instructions = [];
|
|
2445
2473
|
|
|
2446
2474
|
for (let i = 0; i < instructionCount; i++) {
|
|
2447
|
-
const programIdIndex = byteArray
|
|
2475
|
+
const programIdIndex = guardedShift(byteArray);
|
|
2448
2476
|
const accountCount = decodeLength(byteArray);
|
|
2449
|
-
const accounts = byteArray
|
|
2450
|
-
byteArray = byteArray.slice(accountCount);
|
|
2477
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
2451
2478
|
const dataLength = decodeLength(byteArray);
|
|
2452
|
-
const dataSlice = byteArray
|
|
2479
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
2453
2480
|
const data = bs58.encode(Buffer.from(dataSlice));
|
|
2454
|
-
byteArray = byteArray.slice(dataLength);
|
|
2455
2481
|
instructions.push({
|
|
2456
2482
|
programIdIndex,
|
|
2457
2483
|
accounts,
|
|
@@ -2480,6 +2506,10 @@ function assert (condition, message) {
|
|
|
2480
2506
|
}
|
|
2481
2507
|
}
|
|
2482
2508
|
|
|
2509
|
+
/**
|
|
2510
|
+
* Transaction signature as base-58 encoded string
|
|
2511
|
+
*/
|
|
2512
|
+
|
|
2483
2513
|
let TransactionStatus;
|
|
2484
2514
|
/**
|
|
2485
2515
|
* Default (empty) signature
|
|
@@ -3159,8 +3189,7 @@ class Transaction {
|
|
|
3159
3189
|
let signatures = [];
|
|
3160
3190
|
|
|
3161
3191
|
for (let i = 0; i < signatureCount; i++) {
|
|
3162
|
-
const signature = byteArray
|
|
3163
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
|
|
3192
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
|
|
3164
3193
|
signatures.push(bs58.encode(Buffer.from(signature)));
|
|
3165
3194
|
}
|
|
3166
3195
|
|
|
@@ -5818,7 +5847,7 @@ const LogsNotificationResult = type({
|
|
|
5818
5847
|
|
|
5819
5848
|
/** @internal */
|
|
5820
5849
|
const COMMON_HTTP_HEADERS = {
|
|
5821
|
-
'solana-client': `js/${(_process$env$npm_pack = "
|
|
5850
|
+
'solana-client': `js/${(_process$env$npm_pack = "1.50.2") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
|
|
5822
5851
|
};
|
|
5823
5852
|
/**
|
|
5824
5853
|
* A connection to a fullnode JSON RPC endpoint
|
|
@@ -7860,6 +7889,11 @@ class Connection {
|
|
|
7860
7889
|
this._rpcWebSocketConnected = false;
|
|
7861
7890
|
this._rpcWebSocketGeneration++;
|
|
7862
7891
|
|
|
7892
|
+
if (this._rpcWebSocketIdleTimeout) {
|
|
7893
|
+
clearTimeout(this._rpcWebSocketIdleTimeout);
|
|
7894
|
+
this._rpcWebSocketIdleTimeout = null;
|
|
7895
|
+
}
|
|
7896
|
+
|
|
7863
7897
|
if (this._rpcWebSocketHeartbeat) {
|
|
7864
7898
|
clearInterval(this._rpcWebSocketHeartbeat);
|
|
7865
7899
|
this._rpcWebSocketHeartbeat = null;
|
|
@@ -9737,10 +9771,8 @@ class ValidatorInfo {
|
|
|
9737
9771
|
const configKeys = [];
|
|
9738
9772
|
|
|
9739
9773
|
for (let i = 0; i < 2; i++) {
|
|
9740
|
-
const publicKey = new PublicKey(byteArray
|
|
9741
|
-
|
|
9742
|
-
const isSigner = byteArray.slice(0, 1)[0] === 1;
|
|
9743
|
-
byteArray = byteArray.slice(1);
|
|
9774
|
+
const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
|
|
9775
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
9744
9776
|
configKeys.push({
|
|
9745
9777
|
publicKey,
|
|
9746
9778
|
isSigner
|