@solana/web3.js 1.53.0 → 1.53.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 +50 -19
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +50 -19
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +50 -19
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.esm.js +50 -19
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +50 -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 +50 -19
- package/lib/index.native.js.map +1 -1
- package/package.json +22 -22
- package/src/message/legacy.ts +9 -12
- package/src/transaction/legacy.ts +2 -2
- package/src/utils/guarded-array-utils.ts +34 -0
- package/src/validator-info.ts +5 -4
package/lib/index.cjs.js
CHANGED
|
@@ -2281,6 +2281,40 @@ function encodeLength(bytes, len) {
|
|
|
2281
2281
|
}
|
|
2282
2282
|
}
|
|
2283
2283
|
|
|
2284
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
2285
|
+
/**
|
|
2286
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
2287
|
+
*/
|
|
2288
|
+
|
|
2289
|
+
function guardedShift(byteArray) {
|
|
2290
|
+
if (byteArray.length === 0) {
|
|
2291
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
2292
|
+
}
|
|
2293
|
+
|
|
2294
|
+
return byteArray.shift();
|
|
2295
|
+
}
|
|
2296
|
+
/**
|
|
2297
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
2298
|
+
* the array.
|
|
2299
|
+
*/
|
|
2300
|
+
|
|
2301
|
+
function guardedSplice(byteArray, ...args) {
|
|
2302
|
+
var _args$;
|
|
2303
|
+
|
|
2304
|
+
const [start] = args;
|
|
2305
|
+
|
|
2306
|
+
if (args.length === 2 // Implies that `deleteCount` was supplied
|
|
2307
|
+
? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
|
|
2308
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
2309
|
+
}
|
|
2310
|
+
|
|
2311
|
+
return byteArray.splice(...args);
|
|
2312
|
+
}
|
|
2313
|
+
|
|
2314
|
+
/**
|
|
2315
|
+
* Message constructor arguments
|
|
2316
|
+
*/
|
|
2317
|
+
|
|
2284
2318
|
const PUBKEY_LENGTH = 32;
|
|
2285
2319
|
/**
|
|
2286
2320
|
* List of instructions to be processed atomically
|
|
@@ -2375,32 +2409,28 @@ class Message {
|
|
|
2375
2409
|
static from(buffer$1) {
|
|
2376
2410
|
// Slice up wire data
|
|
2377
2411
|
let byteArray = [...buffer$1];
|
|
2378
|
-
const numRequiredSignatures = byteArray
|
|
2379
|
-
const numReadonlySignedAccounts = byteArray
|
|
2380
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
2412
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
2413
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
2414
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
2381
2415
|
const accountCount = decodeLength(byteArray);
|
|
2382
2416
|
let accountKeys = [];
|
|
2383
2417
|
|
|
2384
2418
|
for (let i = 0; i < accountCount; i++) {
|
|
2385
|
-
const account = byteArray
|
|
2386
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2419
|
+
const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
2387
2420
|
accountKeys.push(bs58__default["default"].encode(buffer.Buffer.from(account)));
|
|
2388
2421
|
}
|
|
2389
2422
|
|
|
2390
|
-
const recentBlockhash = byteArray
|
|
2391
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2423
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
2392
2424
|
const instructionCount = decodeLength(byteArray);
|
|
2393
2425
|
let instructions = [];
|
|
2394
2426
|
|
|
2395
2427
|
for (let i = 0; i < instructionCount; i++) {
|
|
2396
|
-
const programIdIndex = byteArray
|
|
2428
|
+
const programIdIndex = guardedShift(byteArray);
|
|
2397
2429
|
const accountCount = decodeLength(byteArray);
|
|
2398
|
-
const accounts = byteArray
|
|
2399
|
-
byteArray = byteArray.slice(accountCount);
|
|
2430
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
2400
2431
|
const dataLength = decodeLength(byteArray);
|
|
2401
|
-
const dataSlice = byteArray
|
|
2432
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
2402
2433
|
const data = bs58__default["default"].encode(buffer.Buffer.from(dataSlice));
|
|
2403
|
-
byteArray = byteArray.slice(dataLength);
|
|
2404
2434
|
instructions.push({
|
|
2405
2435
|
programIdIndex,
|
|
2406
2436
|
accounts,
|
|
@@ -2429,6 +2459,10 @@ function assert (condition, message) {
|
|
|
2429
2459
|
}
|
|
2430
2460
|
}
|
|
2431
2461
|
|
|
2462
|
+
/**
|
|
2463
|
+
* Transaction signature as base-58 encoded string
|
|
2464
|
+
*/
|
|
2465
|
+
|
|
2432
2466
|
exports.TransactionStatus = void 0;
|
|
2433
2467
|
/**
|
|
2434
2468
|
* Default (empty) signature
|
|
@@ -3108,8 +3142,7 @@ class Transaction {
|
|
|
3108
3142
|
let signatures = [];
|
|
3109
3143
|
|
|
3110
3144
|
for (let i = 0; i < signatureCount; i++) {
|
|
3111
|
-
const signature = byteArray
|
|
3112
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
|
|
3145
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
|
|
3113
3146
|
signatures.push(bs58__default["default"].encode(buffer.Buffer.from(signature)));
|
|
3114
3147
|
}
|
|
3115
3148
|
|
|
@@ -5547,7 +5580,7 @@ const LogsNotificationResult = superstruct.type({
|
|
|
5547
5580
|
|
|
5548
5581
|
/** @internal */
|
|
5549
5582
|
const COMMON_HTTP_HEADERS = {
|
|
5550
|
-
'solana-client': `js/${(_process$env$npm_pack = "
|
|
5583
|
+
'solana-client': `js/${(_process$env$npm_pack = "1.53.1") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
|
|
5551
5584
|
};
|
|
5552
5585
|
/**
|
|
5553
5586
|
* A connection to a fullnode JSON RPC endpoint
|
|
@@ -10267,10 +10300,8 @@ class ValidatorInfo {
|
|
|
10267
10300
|
const configKeys = [];
|
|
10268
10301
|
|
|
10269
10302
|
for (let i = 0; i < 2; i++) {
|
|
10270
|
-
const publicKey = new PublicKey(byteArray
|
|
10271
|
-
|
|
10272
|
-
const isSigner = byteArray.slice(0, 1)[0] === 1;
|
|
10273
|
-
byteArray = byteArray.slice(1);
|
|
10303
|
+
const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
|
|
10304
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
10274
10305
|
configKeys.push({
|
|
10275
10306
|
publicKey,
|
|
10276
10307
|
isSigner
|