@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.browser.cjs.js
CHANGED
|
@@ -2361,6 +2361,36 @@ function encodeLength(bytes, len) {
|
|
|
2361
2361
|
}
|
|
2362
2362
|
}
|
|
2363
2363
|
|
|
2364
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
2365
|
+
/**
|
|
2366
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
2367
|
+
*/
|
|
2368
|
+
|
|
2369
|
+
function guardedShift(byteArray) {
|
|
2370
|
+
if (byteArray.length === 0) {
|
|
2371
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
2372
|
+
}
|
|
2373
|
+
|
|
2374
|
+
return byteArray.shift();
|
|
2375
|
+
}
|
|
2376
|
+
/**
|
|
2377
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
2378
|
+
* the array.
|
|
2379
|
+
*/
|
|
2380
|
+
|
|
2381
|
+
function guardedSplice(byteArray, ...args) {
|
|
2382
|
+
var _args$;
|
|
2383
|
+
|
|
2384
|
+
const [start] = args;
|
|
2385
|
+
|
|
2386
|
+
if (args.length === 2 // Implies that `deleteCount` was supplied
|
|
2387
|
+
? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
|
|
2388
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
2389
|
+
}
|
|
2390
|
+
|
|
2391
|
+
return byteArray.splice(...args);
|
|
2392
|
+
}
|
|
2393
|
+
|
|
2364
2394
|
/**
|
|
2365
2395
|
* The message header, identifying signed and read-only account
|
|
2366
2396
|
*/
|
|
@@ -2459,32 +2489,28 @@ class Message {
|
|
|
2459
2489
|
static from(buffer$1) {
|
|
2460
2490
|
// Slice up wire data
|
|
2461
2491
|
let byteArray = [...buffer$1];
|
|
2462
|
-
const numRequiredSignatures = byteArray
|
|
2463
|
-
const numReadonlySignedAccounts = byteArray
|
|
2464
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
2492
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
2493
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
2494
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
2465
2495
|
const accountCount = decodeLength(byteArray);
|
|
2466
2496
|
let accountKeys = [];
|
|
2467
2497
|
|
|
2468
2498
|
for (let i = 0; i < accountCount; i++) {
|
|
2469
|
-
const account = byteArray
|
|
2470
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2499
|
+
const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
2471
2500
|
accountKeys.push(bs58__default["default"].encode(buffer.Buffer.from(account)));
|
|
2472
2501
|
}
|
|
2473
2502
|
|
|
2474
|
-
const recentBlockhash = byteArray
|
|
2475
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2503
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
2476
2504
|
const instructionCount = decodeLength(byteArray);
|
|
2477
2505
|
let instructions = [];
|
|
2478
2506
|
|
|
2479
2507
|
for (let i = 0; i < instructionCount; i++) {
|
|
2480
|
-
const programIdIndex = byteArray
|
|
2508
|
+
const programIdIndex = guardedShift(byteArray);
|
|
2481
2509
|
const accountCount = decodeLength(byteArray);
|
|
2482
|
-
const accounts = byteArray
|
|
2483
|
-
byteArray = byteArray.slice(accountCount);
|
|
2510
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
2484
2511
|
const dataLength = decodeLength(byteArray);
|
|
2485
|
-
const dataSlice = byteArray
|
|
2512
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
2486
2513
|
const data = bs58__default["default"].encode(buffer.Buffer.from(dataSlice));
|
|
2487
|
-
byteArray = byteArray.slice(dataLength);
|
|
2488
2514
|
instructions.push({
|
|
2489
2515
|
programIdIndex,
|
|
2490
2516
|
accounts,
|
|
@@ -2513,6 +2539,10 @@ function assert (condition, message) {
|
|
|
2513
2539
|
}
|
|
2514
2540
|
}
|
|
2515
2541
|
|
|
2542
|
+
/**
|
|
2543
|
+
* Transaction signature as base-58 encoded string
|
|
2544
|
+
*/
|
|
2545
|
+
|
|
2516
2546
|
exports.TransactionStatus = void 0;
|
|
2517
2547
|
/**
|
|
2518
2548
|
* Default (empty) signature
|
|
@@ -3192,8 +3222,7 @@ class Transaction {
|
|
|
3192
3222
|
let signatures = [];
|
|
3193
3223
|
|
|
3194
3224
|
for (let i = 0; i < signatureCount; i++) {
|
|
3195
|
-
const signature = byteArray
|
|
3196
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
|
|
3225
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
|
|
3197
3226
|
signatures.push(bs58__default["default"].encode(buffer.Buffer.from(signature)));
|
|
3198
3227
|
}
|
|
3199
3228
|
|
|
@@ -5857,7 +5886,7 @@ const LogsNotificationResult = superstruct.type({
|
|
|
5857
5886
|
|
|
5858
5887
|
/** @internal */
|
|
5859
5888
|
const COMMON_HTTP_HEADERS = {
|
|
5860
|
-
'solana-client': `js/${(_process$env$npm_pack = "
|
|
5889
|
+
'solana-client': `js/${(_process$env$npm_pack = "1.52.1") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
|
|
5861
5890
|
};
|
|
5862
5891
|
/**
|
|
5863
5892
|
* A connection to a fullnode JSON RPC endpoint
|
|
@@ -9786,10 +9815,8 @@ class ValidatorInfo {
|
|
|
9786
9815
|
const configKeys = [];
|
|
9787
9816
|
|
|
9788
9817
|
for (let i = 0; i < 2; i++) {
|
|
9789
|
-
const publicKey = new PublicKey(byteArray
|
|
9790
|
-
|
|
9791
|
-
const isSigner = byteArray.slice(0, 1)[0] === 1;
|
|
9792
|
-
byteArray = byteArray.slice(1);
|
|
9818
|
+
const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
|
|
9819
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
9793
9820
|
configKeys.push({
|
|
9794
9821
|
publicKey,
|
|
9795
9822
|
isSigner
|