@solana/web3.js 1.52.0 → 1.52.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 +46 -19
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +46 -19
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +46 -19
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.esm.js +46 -19
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +46 -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 +46 -19
- package/lib/index.native.js.map +1 -1
- package/package.json +22 -22
- 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.esm.js
CHANGED
|
@@ -2354,6 +2354,36 @@ function encodeLength(bytes, len) {
|
|
|
2354
2354
|
}
|
|
2355
2355
|
}
|
|
2356
2356
|
|
|
2357
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
2358
|
+
/**
|
|
2359
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
2360
|
+
*/
|
|
2361
|
+
|
|
2362
|
+
function guardedShift(byteArray) {
|
|
2363
|
+
if (byteArray.length === 0) {
|
|
2364
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
2365
|
+
}
|
|
2366
|
+
|
|
2367
|
+
return byteArray.shift();
|
|
2368
|
+
}
|
|
2369
|
+
/**
|
|
2370
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
2371
|
+
* the array.
|
|
2372
|
+
*/
|
|
2373
|
+
|
|
2374
|
+
function guardedSplice(byteArray, ...args) {
|
|
2375
|
+
var _args$;
|
|
2376
|
+
|
|
2377
|
+
const [start] = args;
|
|
2378
|
+
|
|
2379
|
+
if (args.length === 2 // Implies that `deleteCount` was supplied
|
|
2380
|
+
? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
|
|
2381
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
2382
|
+
}
|
|
2383
|
+
|
|
2384
|
+
return byteArray.splice(...args);
|
|
2385
|
+
}
|
|
2386
|
+
|
|
2357
2387
|
/**
|
|
2358
2388
|
* The message header, identifying signed and read-only account
|
|
2359
2389
|
*/
|
|
@@ -2452,32 +2482,28 @@ class Message {
|
|
|
2452
2482
|
static from(buffer) {
|
|
2453
2483
|
// Slice up wire data
|
|
2454
2484
|
let byteArray = [...buffer];
|
|
2455
|
-
const numRequiredSignatures = byteArray
|
|
2456
|
-
const numReadonlySignedAccounts = byteArray
|
|
2457
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
2485
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
2486
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
2487
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
2458
2488
|
const accountCount = decodeLength(byteArray);
|
|
2459
2489
|
let accountKeys = [];
|
|
2460
2490
|
|
|
2461
2491
|
for (let i = 0; i < accountCount; i++) {
|
|
2462
|
-
const account = byteArray
|
|
2463
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2492
|
+
const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
2464
2493
|
accountKeys.push(bs58.encode(Buffer.from(account)));
|
|
2465
2494
|
}
|
|
2466
2495
|
|
|
2467
|
-
const recentBlockhash = byteArray
|
|
2468
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2496
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
2469
2497
|
const instructionCount = decodeLength(byteArray);
|
|
2470
2498
|
let instructions = [];
|
|
2471
2499
|
|
|
2472
2500
|
for (let i = 0; i < instructionCount; i++) {
|
|
2473
|
-
const programIdIndex = byteArray
|
|
2501
|
+
const programIdIndex = guardedShift(byteArray);
|
|
2474
2502
|
const accountCount = decodeLength(byteArray);
|
|
2475
|
-
const accounts = byteArray
|
|
2476
|
-
byteArray = byteArray.slice(accountCount);
|
|
2503
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
2477
2504
|
const dataLength = decodeLength(byteArray);
|
|
2478
|
-
const dataSlice = byteArray
|
|
2505
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
2479
2506
|
const data = bs58.encode(Buffer.from(dataSlice));
|
|
2480
|
-
byteArray = byteArray.slice(dataLength);
|
|
2481
2507
|
instructions.push({
|
|
2482
2508
|
programIdIndex,
|
|
2483
2509
|
accounts,
|
|
@@ -2506,6 +2532,10 @@ function assert (condition, message) {
|
|
|
2506
2532
|
}
|
|
2507
2533
|
}
|
|
2508
2534
|
|
|
2535
|
+
/**
|
|
2536
|
+
* Transaction signature as base-58 encoded string
|
|
2537
|
+
*/
|
|
2538
|
+
|
|
2509
2539
|
let TransactionStatus;
|
|
2510
2540
|
/**
|
|
2511
2541
|
* Default (empty) signature
|
|
@@ -3185,8 +3215,7 @@ class Transaction {
|
|
|
3185
3215
|
let signatures = [];
|
|
3186
3216
|
|
|
3187
3217
|
for (let i = 0; i < signatureCount; i++) {
|
|
3188
|
-
const signature = byteArray
|
|
3189
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
|
|
3218
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
|
|
3190
3219
|
signatures.push(bs58.encode(Buffer.from(signature)));
|
|
3191
3220
|
}
|
|
3192
3221
|
|
|
@@ -5908,7 +5937,7 @@ const LogsNotificationResult = type({
|
|
|
5908
5937
|
|
|
5909
5938
|
/** @internal */
|
|
5910
5939
|
const COMMON_HTTP_HEADERS = {
|
|
5911
|
-
'solana-client': `js/${(_process$env$npm_pack = "
|
|
5940
|
+
'solana-client': `js/${(_process$env$npm_pack = "1.52.1") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
|
|
5912
5941
|
};
|
|
5913
5942
|
/**
|
|
5914
5943
|
* A connection to a fullnode JSON RPC endpoint
|
|
@@ -9837,10 +9866,8 @@ class ValidatorInfo {
|
|
|
9837
9866
|
const configKeys = [];
|
|
9838
9867
|
|
|
9839
9868
|
for (let i = 0; i < 2; i++) {
|
|
9840
|
-
const publicKey = new PublicKey(byteArray
|
|
9841
|
-
|
|
9842
|
-
const isSigner = byteArray.slice(0, 1)[0] === 1;
|
|
9843
|
-
byteArray = byteArray.slice(1);
|
|
9869
|
+
const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
|
|
9870
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
9844
9871
|
configKeys.push({
|
|
9845
9872
|
publicKey,
|
|
9846
9873
|
isSigner
|