@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.esm.js
CHANGED
|
@@ -2352,6 +2352,36 @@ function encodeLength(bytes, len) {
|
|
|
2352
2352
|
}
|
|
2353
2353
|
}
|
|
2354
2354
|
|
|
2355
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
2356
|
+
/**
|
|
2357
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
2358
|
+
*/
|
|
2359
|
+
|
|
2360
|
+
function guardedShift(byteArray) {
|
|
2361
|
+
if (byteArray.length === 0) {
|
|
2362
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
2363
|
+
}
|
|
2364
|
+
|
|
2365
|
+
return byteArray.shift();
|
|
2366
|
+
}
|
|
2367
|
+
/**
|
|
2368
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
2369
|
+
* the array.
|
|
2370
|
+
*/
|
|
2371
|
+
|
|
2372
|
+
function guardedSplice(byteArray, ...args) {
|
|
2373
|
+
var _args$;
|
|
2374
|
+
|
|
2375
|
+
const [start] = args;
|
|
2376
|
+
|
|
2377
|
+
if (args.length === 2 // Implies that `deleteCount` was supplied
|
|
2378
|
+
? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
|
|
2379
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
2380
|
+
}
|
|
2381
|
+
|
|
2382
|
+
return byteArray.splice(...args);
|
|
2383
|
+
}
|
|
2384
|
+
|
|
2355
2385
|
/**
|
|
2356
2386
|
* The message header, identifying signed and read-only account
|
|
2357
2387
|
*/
|
|
@@ -2450,32 +2480,28 @@ class Message {
|
|
|
2450
2480
|
static from(buffer) {
|
|
2451
2481
|
// Slice up wire data
|
|
2452
2482
|
let byteArray = [...buffer];
|
|
2453
|
-
const numRequiredSignatures = byteArray
|
|
2454
|
-
const numReadonlySignedAccounts = byteArray
|
|
2455
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
2483
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
2484
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
2485
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
2456
2486
|
const accountCount = decodeLength(byteArray);
|
|
2457
2487
|
let accountKeys = [];
|
|
2458
2488
|
|
|
2459
2489
|
for (let i = 0; i < accountCount; i++) {
|
|
2460
|
-
const account = byteArray
|
|
2461
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2490
|
+
const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
2462
2491
|
accountKeys.push(bs58.encode(Buffer.from(account)));
|
|
2463
2492
|
}
|
|
2464
2493
|
|
|
2465
|
-
const recentBlockhash = byteArray
|
|
2466
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2494
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
2467
2495
|
const instructionCount = decodeLength(byteArray);
|
|
2468
2496
|
let instructions = [];
|
|
2469
2497
|
|
|
2470
2498
|
for (let i = 0; i < instructionCount; i++) {
|
|
2471
|
-
const programIdIndex = byteArray
|
|
2499
|
+
const programIdIndex = guardedShift(byteArray);
|
|
2472
2500
|
const accountCount = decodeLength(byteArray);
|
|
2473
|
-
const accounts = byteArray
|
|
2474
|
-
byteArray = byteArray.slice(accountCount);
|
|
2501
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
2475
2502
|
const dataLength = decodeLength(byteArray);
|
|
2476
|
-
const dataSlice = byteArray
|
|
2503
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
2477
2504
|
const data = bs58.encode(Buffer.from(dataSlice));
|
|
2478
|
-
byteArray = byteArray.slice(dataLength);
|
|
2479
2505
|
instructions.push({
|
|
2480
2506
|
programIdIndex,
|
|
2481
2507
|
accounts,
|
|
@@ -2504,6 +2530,10 @@ function assert (condition, message) {
|
|
|
2504
2530
|
}
|
|
2505
2531
|
}
|
|
2506
2532
|
|
|
2533
|
+
/**
|
|
2534
|
+
* Transaction signature as base-58 encoded string
|
|
2535
|
+
*/
|
|
2536
|
+
|
|
2507
2537
|
let TransactionStatus;
|
|
2508
2538
|
/**
|
|
2509
2539
|
* Default (empty) signature
|
|
@@ -3183,8 +3213,7 @@ class Transaction {
|
|
|
3183
3213
|
let signatures = [];
|
|
3184
3214
|
|
|
3185
3215
|
for (let i = 0; i < signatureCount; i++) {
|
|
3186
|
-
const signature = byteArray
|
|
3187
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
|
|
3216
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
|
|
3188
3217
|
signatures.push(bs58.encode(Buffer.from(signature)));
|
|
3189
3218
|
}
|
|
3190
3219
|
|
|
@@ -5900,7 +5929,7 @@ const LogsNotificationResult = type({
|
|
|
5900
5929
|
|
|
5901
5930
|
/** @internal */
|
|
5902
5931
|
const COMMON_HTTP_HEADERS = {
|
|
5903
|
-
'solana-client': `js/${(_process$env$npm_pack = "
|
|
5932
|
+
'solana-client': `js/${(_process$env$npm_pack = "1.50.2") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
|
|
5904
5933
|
};
|
|
5905
5934
|
/**
|
|
5906
5935
|
* A connection to a fullnode JSON RPC endpoint
|
|
@@ -9824,10 +9853,8 @@ class ValidatorInfo {
|
|
|
9824
9853
|
const configKeys = [];
|
|
9825
9854
|
|
|
9826
9855
|
for (let i = 0; i < 2; i++) {
|
|
9827
|
-
const publicKey = new PublicKey(byteArray
|
|
9828
|
-
|
|
9829
|
-
const isSigner = byteArray.slice(0, 1)[0] === 1;
|
|
9830
|
-
byteArray = byteArray.slice(1);
|
|
9856
|
+
const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
|
|
9857
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
9831
9858
|
configKeys.push({
|
|
9832
9859
|
publicKey,
|
|
9833
9860
|
isSigner
|