@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.cjs.js
CHANGED
|
@@ -2388,6 +2388,36 @@ function encodeLength(bytes, len) {
|
|
|
2388
2388
|
}
|
|
2389
2389
|
}
|
|
2390
2390
|
|
|
2391
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
2392
|
+
/**
|
|
2393
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
2394
|
+
*/
|
|
2395
|
+
|
|
2396
|
+
function guardedShift(byteArray) {
|
|
2397
|
+
if (byteArray.length === 0) {
|
|
2398
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
2399
|
+
}
|
|
2400
|
+
|
|
2401
|
+
return byteArray.shift();
|
|
2402
|
+
}
|
|
2403
|
+
/**
|
|
2404
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
2405
|
+
* the array.
|
|
2406
|
+
*/
|
|
2407
|
+
|
|
2408
|
+
function guardedSplice(byteArray, ...args) {
|
|
2409
|
+
var _args$;
|
|
2410
|
+
|
|
2411
|
+
const [start] = args;
|
|
2412
|
+
|
|
2413
|
+
if (args.length === 2 // Implies that `deleteCount` was supplied
|
|
2414
|
+
? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
|
|
2415
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
2416
|
+
}
|
|
2417
|
+
|
|
2418
|
+
return byteArray.splice(...args);
|
|
2419
|
+
}
|
|
2420
|
+
|
|
2391
2421
|
/**
|
|
2392
2422
|
* The message header, identifying signed and read-only account
|
|
2393
2423
|
*/
|
|
@@ -2486,32 +2516,28 @@ class Message {
|
|
|
2486
2516
|
static from(buffer$1) {
|
|
2487
2517
|
// Slice up wire data
|
|
2488
2518
|
let byteArray = [...buffer$1];
|
|
2489
|
-
const numRequiredSignatures = byteArray
|
|
2490
|
-
const numReadonlySignedAccounts = byteArray
|
|
2491
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
2519
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
2520
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
2521
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
2492
2522
|
const accountCount = decodeLength(byteArray);
|
|
2493
2523
|
let accountKeys = [];
|
|
2494
2524
|
|
|
2495
2525
|
for (let i = 0; i < accountCount; i++) {
|
|
2496
|
-
const account = byteArray
|
|
2497
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2526
|
+
const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
2498
2527
|
accountKeys.push(bs58__default["default"].encode(buffer.Buffer.from(account)));
|
|
2499
2528
|
}
|
|
2500
2529
|
|
|
2501
|
-
const recentBlockhash = byteArray
|
|
2502
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2530
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
2503
2531
|
const instructionCount = decodeLength(byteArray);
|
|
2504
2532
|
let instructions = [];
|
|
2505
2533
|
|
|
2506
2534
|
for (let i = 0; i < instructionCount; i++) {
|
|
2507
|
-
const programIdIndex = byteArray
|
|
2535
|
+
const programIdIndex = guardedShift(byteArray);
|
|
2508
2536
|
const accountCount = decodeLength(byteArray);
|
|
2509
|
-
const accounts = byteArray
|
|
2510
|
-
byteArray = byteArray.slice(accountCount);
|
|
2537
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
2511
2538
|
const dataLength = decodeLength(byteArray);
|
|
2512
|
-
const dataSlice = byteArray
|
|
2539
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
2513
2540
|
const data = bs58__default["default"].encode(buffer.Buffer.from(dataSlice));
|
|
2514
|
-
byteArray = byteArray.slice(dataLength);
|
|
2515
2541
|
instructions.push({
|
|
2516
2542
|
programIdIndex,
|
|
2517
2543
|
accounts,
|
|
@@ -2540,6 +2566,10 @@ function assert (condition, message) {
|
|
|
2540
2566
|
}
|
|
2541
2567
|
}
|
|
2542
2568
|
|
|
2569
|
+
/**
|
|
2570
|
+
* Transaction signature as base-58 encoded string
|
|
2571
|
+
*/
|
|
2572
|
+
|
|
2543
2573
|
exports.TransactionStatus = void 0;
|
|
2544
2574
|
/**
|
|
2545
2575
|
* Default (empty) signature
|
|
@@ -3219,8 +3249,7 @@ class Transaction {
|
|
|
3219
3249
|
let signatures = [];
|
|
3220
3250
|
|
|
3221
3251
|
for (let i = 0; i < signatureCount; i++) {
|
|
3222
|
-
const signature = byteArray
|
|
3223
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
|
|
3252
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
|
|
3224
3253
|
signatures.push(bs58__default["default"].encode(buffer.Buffer.from(signature)));
|
|
3225
3254
|
}
|
|
3226
3255
|
|
|
@@ -5942,7 +5971,7 @@ const LogsNotificationResult = superstruct.type({
|
|
|
5942
5971
|
|
|
5943
5972
|
/** @internal */
|
|
5944
5973
|
const COMMON_HTTP_HEADERS = {
|
|
5945
|
-
'solana-client': `js/${(_process$env$npm_pack = "
|
|
5974
|
+
'solana-client': `js/${(_process$env$npm_pack = "1.52.1") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
|
|
5946
5975
|
};
|
|
5947
5976
|
/**
|
|
5948
5977
|
* A connection to a fullnode JSON RPC endpoint
|
|
@@ -9871,10 +9900,8 @@ class ValidatorInfo {
|
|
|
9871
9900
|
const configKeys = [];
|
|
9872
9901
|
|
|
9873
9902
|
for (let i = 0; i < 2; i++) {
|
|
9874
|
-
const publicKey = new PublicKey(byteArray
|
|
9875
|
-
|
|
9876
|
-
const isSigner = byteArray.slice(0, 1)[0] === 1;
|
|
9877
|
-
byteArray = byteArray.slice(1);
|
|
9903
|
+
const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
|
|
9904
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
9878
9905
|
configKeys.push({
|
|
9879
9906
|
publicKey,
|
|
9880
9907
|
isSigner
|