@solana/web3.js 1.49.0 → 1.49.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
|
@@ -2359,6 +2359,36 @@ function encodeLength(bytes, len) {
|
|
|
2359
2359
|
}
|
|
2360
2360
|
}
|
|
2361
2361
|
|
|
2362
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
2363
|
+
/**
|
|
2364
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
2365
|
+
*/
|
|
2366
|
+
|
|
2367
|
+
function guardedShift(byteArray) {
|
|
2368
|
+
if (byteArray.length === 0) {
|
|
2369
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
2370
|
+
}
|
|
2371
|
+
|
|
2372
|
+
return byteArray.shift();
|
|
2373
|
+
}
|
|
2374
|
+
/**
|
|
2375
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
2376
|
+
* the array.
|
|
2377
|
+
*/
|
|
2378
|
+
|
|
2379
|
+
function guardedSplice(byteArray, ...args) {
|
|
2380
|
+
var _args$;
|
|
2381
|
+
|
|
2382
|
+
const [start] = args;
|
|
2383
|
+
|
|
2384
|
+
if (args.length === 2 // Implies that `deleteCount` was supplied
|
|
2385
|
+
? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
|
|
2386
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
2387
|
+
}
|
|
2388
|
+
|
|
2389
|
+
return byteArray.splice(...args);
|
|
2390
|
+
}
|
|
2391
|
+
|
|
2362
2392
|
/**
|
|
2363
2393
|
* The message header, identifying signed and read-only account
|
|
2364
2394
|
*/
|
|
@@ -2457,32 +2487,28 @@ class Message {
|
|
|
2457
2487
|
static from(buffer$1) {
|
|
2458
2488
|
// Slice up wire data
|
|
2459
2489
|
let byteArray = [...buffer$1];
|
|
2460
|
-
const numRequiredSignatures = byteArray
|
|
2461
|
-
const numReadonlySignedAccounts = byteArray
|
|
2462
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
2490
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
2491
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
2492
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
2463
2493
|
const accountCount = decodeLength(byteArray);
|
|
2464
2494
|
let accountKeys = [];
|
|
2465
2495
|
|
|
2466
2496
|
for (let i = 0; i < accountCount; i++) {
|
|
2467
|
-
const account = byteArray
|
|
2468
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2497
|
+
const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
2469
2498
|
accountKeys.push(bs58__default["default"].encode(buffer.Buffer.from(account)));
|
|
2470
2499
|
}
|
|
2471
2500
|
|
|
2472
|
-
const recentBlockhash = byteArray
|
|
2473
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2501
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
2474
2502
|
const instructionCount = decodeLength(byteArray);
|
|
2475
2503
|
let instructions = [];
|
|
2476
2504
|
|
|
2477
2505
|
for (let i = 0; i < instructionCount; i++) {
|
|
2478
|
-
const programIdIndex = byteArray
|
|
2506
|
+
const programIdIndex = guardedShift(byteArray);
|
|
2479
2507
|
const accountCount = decodeLength(byteArray);
|
|
2480
|
-
const accounts = byteArray
|
|
2481
|
-
byteArray = byteArray.slice(accountCount);
|
|
2508
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
2482
2509
|
const dataLength = decodeLength(byteArray);
|
|
2483
|
-
const dataSlice = byteArray
|
|
2510
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
2484
2511
|
const data = bs58__default["default"].encode(buffer.Buffer.from(dataSlice));
|
|
2485
|
-
byteArray = byteArray.slice(dataLength);
|
|
2486
2512
|
instructions.push({
|
|
2487
2513
|
programIdIndex,
|
|
2488
2514
|
accounts,
|
|
@@ -2511,6 +2537,10 @@ function assert (condition, message) {
|
|
|
2511
2537
|
}
|
|
2512
2538
|
}
|
|
2513
2539
|
|
|
2540
|
+
/**
|
|
2541
|
+
* Transaction signature as base-58 encoded string
|
|
2542
|
+
*/
|
|
2543
|
+
|
|
2514
2544
|
exports.TransactionStatus = void 0;
|
|
2515
2545
|
/**
|
|
2516
2546
|
* Default (empty) signature
|
|
@@ -3190,8 +3220,7 @@ class Transaction {
|
|
|
3190
3220
|
let signatures = [];
|
|
3191
3221
|
|
|
3192
3222
|
for (let i = 0; i < signatureCount; i++) {
|
|
3193
|
-
const signature = byteArray
|
|
3194
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
|
|
3223
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
|
|
3195
3224
|
signatures.push(bs58__default["default"].encode(buffer.Buffer.from(signature)));
|
|
3196
3225
|
}
|
|
3197
3226
|
|
|
@@ -5849,7 +5878,7 @@ const LogsNotificationResult = superstruct.type({
|
|
|
5849
5878
|
|
|
5850
5879
|
/** @internal */
|
|
5851
5880
|
const COMMON_HTTP_HEADERS = {
|
|
5852
|
-
'solana-client': `js/${(_process$env$npm_pack = "
|
|
5881
|
+
'solana-client': `js/${(_process$env$npm_pack = "1.49.1") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
|
|
5853
5882
|
};
|
|
5854
5883
|
/**
|
|
5855
5884
|
* A connection to a fullnode JSON RPC endpoint
|
|
@@ -9731,10 +9760,8 @@ class ValidatorInfo {
|
|
|
9731
9760
|
const configKeys = [];
|
|
9732
9761
|
|
|
9733
9762
|
for (let i = 0; i < 2; i++) {
|
|
9734
|
-
const publicKey = new PublicKey(byteArray
|
|
9735
|
-
|
|
9736
|
-
const isSigner = byteArray.slice(0, 1)[0] === 1;
|
|
9737
|
-
byteArray = byteArray.slice(1);
|
|
9763
|
+
const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
|
|
9764
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
9738
9765
|
configKeys.push({
|
|
9739
9766
|
publicKey,
|
|
9740
9767
|
isSigner
|