@solana/web3.js 1.50.1 → 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 +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
|
@@ -2386,6 +2386,36 @@ function encodeLength(bytes, len) {
|
|
|
2386
2386
|
}
|
|
2387
2387
|
}
|
|
2388
2388
|
|
|
2389
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
2390
|
+
/**
|
|
2391
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
2392
|
+
*/
|
|
2393
|
+
|
|
2394
|
+
function guardedShift(byteArray) {
|
|
2395
|
+
if (byteArray.length === 0) {
|
|
2396
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
2397
|
+
}
|
|
2398
|
+
|
|
2399
|
+
return byteArray.shift();
|
|
2400
|
+
}
|
|
2401
|
+
/**
|
|
2402
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
2403
|
+
* the array.
|
|
2404
|
+
*/
|
|
2405
|
+
|
|
2406
|
+
function guardedSplice(byteArray, ...args) {
|
|
2407
|
+
var _args$;
|
|
2408
|
+
|
|
2409
|
+
const [start] = args;
|
|
2410
|
+
|
|
2411
|
+
if (args.length === 2 // Implies that `deleteCount` was supplied
|
|
2412
|
+
? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
|
|
2413
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
2414
|
+
}
|
|
2415
|
+
|
|
2416
|
+
return byteArray.splice(...args);
|
|
2417
|
+
}
|
|
2418
|
+
|
|
2389
2419
|
/**
|
|
2390
2420
|
* The message header, identifying signed and read-only account
|
|
2391
2421
|
*/
|
|
@@ -2484,32 +2514,28 @@ class Message {
|
|
|
2484
2514
|
static from(buffer$1) {
|
|
2485
2515
|
// Slice up wire data
|
|
2486
2516
|
let byteArray = [...buffer$1];
|
|
2487
|
-
const numRequiredSignatures = byteArray
|
|
2488
|
-
const numReadonlySignedAccounts = byteArray
|
|
2489
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
2517
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
2518
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
2519
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
2490
2520
|
const accountCount = decodeLength(byteArray);
|
|
2491
2521
|
let accountKeys = [];
|
|
2492
2522
|
|
|
2493
2523
|
for (let i = 0; i < accountCount; i++) {
|
|
2494
|
-
const account = byteArray
|
|
2495
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2524
|
+
const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
2496
2525
|
accountKeys.push(bs58__default["default"].encode(buffer.Buffer.from(account)));
|
|
2497
2526
|
}
|
|
2498
2527
|
|
|
2499
|
-
const recentBlockhash = byteArray
|
|
2500
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2528
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
2501
2529
|
const instructionCount = decodeLength(byteArray);
|
|
2502
2530
|
let instructions = [];
|
|
2503
2531
|
|
|
2504
2532
|
for (let i = 0; i < instructionCount; i++) {
|
|
2505
|
-
const programIdIndex = byteArray
|
|
2533
|
+
const programIdIndex = guardedShift(byteArray);
|
|
2506
2534
|
const accountCount = decodeLength(byteArray);
|
|
2507
|
-
const accounts = byteArray
|
|
2508
|
-
byteArray = byteArray.slice(accountCount);
|
|
2535
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
2509
2536
|
const dataLength = decodeLength(byteArray);
|
|
2510
|
-
const dataSlice = byteArray
|
|
2537
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
2511
2538
|
const data = bs58__default["default"].encode(buffer.Buffer.from(dataSlice));
|
|
2512
|
-
byteArray = byteArray.slice(dataLength);
|
|
2513
2539
|
instructions.push({
|
|
2514
2540
|
programIdIndex,
|
|
2515
2541
|
accounts,
|
|
@@ -2538,6 +2564,10 @@ function assert (condition, message) {
|
|
|
2538
2564
|
}
|
|
2539
2565
|
}
|
|
2540
2566
|
|
|
2567
|
+
/**
|
|
2568
|
+
* Transaction signature as base-58 encoded string
|
|
2569
|
+
*/
|
|
2570
|
+
|
|
2541
2571
|
exports.TransactionStatus = void 0;
|
|
2542
2572
|
/**
|
|
2543
2573
|
* Default (empty) signature
|
|
@@ -3217,8 +3247,7 @@ class Transaction {
|
|
|
3217
3247
|
let signatures = [];
|
|
3218
3248
|
|
|
3219
3249
|
for (let i = 0; i < signatureCount; i++) {
|
|
3220
|
-
const signature = byteArray
|
|
3221
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
|
|
3250
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
|
|
3222
3251
|
signatures.push(bs58__default["default"].encode(buffer.Buffer.from(signature)));
|
|
3223
3252
|
}
|
|
3224
3253
|
|
|
@@ -5934,7 +5963,7 @@ const LogsNotificationResult = superstruct.type({
|
|
|
5934
5963
|
|
|
5935
5964
|
/** @internal */
|
|
5936
5965
|
const COMMON_HTTP_HEADERS = {
|
|
5937
|
-
'solana-client': `js/${(_process$env$npm_pack = "
|
|
5966
|
+
'solana-client': `js/${(_process$env$npm_pack = "1.50.2") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
|
|
5938
5967
|
};
|
|
5939
5968
|
/**
|
|
5940
5969
|
* A connection to a fullnode JSON RPC endpoint
|
|
@@ -9858,10 +9887,8 @@ class ValidatorInfo {
|
|
|
9858
9887
|
const configKeys = [];
|
|
9859
9888
|
|
|
9860
9889
|
for (let i = 0; i < 2; i++) {
|
|
9861
|
-
const publicKey = new PublicKey(byteArray
|
|
9862
|
-
|
|
9863
|
-
const isSigner = byteArray.slice(0, 1)[0] === 1;
|
|
9864
|
-
byteArray = byteArray.slice(1);
|
|
9890
|
+
const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
|
|
9891
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
9865
9892
|
configKeys.push({
|
|
9866
9893
|
publicKey,
|
|
9867
9894
|
isSigner
|