@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.browser.cjs.js
CHANGED
|
@@ -2254,6 +2254,40 @@ function encodeLength(bytes, len) {
|
|
|
2254
2254
|
}
|
|
2255
2255
|
}
|
|
2256
2256
|
|
|
2257
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
2258
|
+
/**
|
|
2259
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
2260
|
+
*/
|
|
2261
|
+
|
|
2262
|
+
function guardedShift(byteArray) {
|
|
2263
|
+
if (byteArray.length === 0) {
|
|
2264
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
2265
|
+
}
|
|
2266
|
+
|
|
2267
|
+
return byteArray.shift();
|
|
2268
|
+
}
|
|
2269
|
+
/**
|
|
2270
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
2271
|
+
* the array.
|
|
2272
|
+
*/
|
|
2273
|
+
|
|
2274
|
+
function guardedSplice(byteArray, ...args) {
|
|
2275
|
+
var _args$;
|
|
2276
|
+
|
|
2277
|
+
const [start] = args;
|
|
2278
|
+
|
|
2279
|
+
if (args.length === 2 // Implies that `deleteCount` was supplied
|
|
2280
|
+
? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
|
|
2281
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
2282
|
+
}
|
|
2283
|
+
|
|
2284
|
+
return byteArray.splice(...args);
|
|
2285
|
+
}
|
|
2286
|
+
|
|
2287
|
+
/**
|
|
2288
|
+
* Message constructor arguments
|
|
2289
|
+
*/
|
|
2290
|
+
|
|
2257
2291
|
const PUBKEY_LENGTH = 32;
|
|
2258
2292
|
/**
|
|
2259
2293
|
* List of instructions to be processed atomically
|
|
@@ -2348,32 +2382,28 @@ class Message {
|
|
|
2348
2382
|
static from(buffer$1) {
|
|
2349
2383
|
// Slice up wire data
|
|
2350
2384
|
let byteArray = [...buffer$1];
|
|
2351
|
-
const numRequiredSignatures = byteArray
|
|
2352
|
-
const numReadonlySignedAccounts = byteArray
|
|
2353
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
2385
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
2386
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
2387
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
2354
2388
|
const accountCount = decodeLength(byteArray);
|
|
2355
2389
|
let accountKeys = [];
|
|
2356
2390
|
|
|
2357
2391
|
for (let i = 0; i < accountCount; i++) {
|
|
2358
|
-
const account = byteArray
|
|
2359
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2392
|
+
const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
2360
2393
|
accountKeys.push(bs58__default["default"].encode(buffer.Buffer.from(account)));
|
|
2361
2394
|
}
|
|
2362
2395
|
|
|
2363
|
-
const recentBlockhash = byteArray
|
|
2364
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2396
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
2365
2397
|
const instructionCount = decodeLength(byteArray);
|
|
2366
2398
|
let instructions = [];
|
|
2367
2399
|
|
|
2368
2400
|
for (let i = 0; i < instructionCount; i++) {
|
|
2369
|
-
const programIdIndex = byteArray
|
|
2401
|
+
const programIdIndex = guardedShift(byteArray);
|
|
2370
2402
|
const accountCount = decodeLength(byteArray);
|
|
2371
|
-
const accounts = byteArray
|
|
2372
|
-
byteArray = byteArray.slice(accountCount);
|
|
2403
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
2373
2404
|
const dataLength = decodeLength(byteArray);
|
|
2374
|
-
const dataSlice = byteArray
|
|
2405
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
2375
2406
|
const data = bs58__default["default"].encode(buffer.Buffer.from(dataSlice));
|
|
2376
|
-
byteArray = byteArray.slice(dataLength);
|
|
2377
2407
|
instructions.push({
|
|
2378
2408
|
programIdIndex,
|
|
2379
2409
|
accounts,
|
|
@@ -2402,6 +2432,10 @@ function assert (condition, message) {
|
|
|
2402
2432
|
}
|
|
2403
2433
|
}
|
|
2404
2434
|
|
|
2435
|
+
/**
|
|
2436
|
+
* Transaction signature as base-58 encoded string
|
|
2437
|
+
*/
|
|
2438
|
+
|
|
2405
2439
|
exports.TransactionStatus = void 0;
|
|
2406
2440
|
/**
|
|
2407
2441
|
* Default (empty) signature
|
|
@@ -3081,8 +3115,7 @@ class Transaction {
|
|
|
3081
3115
|
let signatures = [];
|
|
3082
3116
|
|
|
3083
3117
|
for (let i = 0; i < signatureCount; i++) {
|
|
3084
|
-
const signature = byteArray
|
|
3085
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
|
|
3118
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
|
|
3086
3119
|
signatures.push(bs58__default["default"].encode(buffer.Buffer.from(signature)));
|
|
3087
3120
|
}
|
|
3088
3121
|
|
|
@@ -5462,7 +5495,7 @@ const LogsNotificationResult = superstruct.type({
|
|
|
5462
5495
|
|
|
5463
5496
|
/** @internal */
|
|
5464
5497
|
const COMMON_HTTP_HEADERS = {
|
|
5465
|
-
'solana-client': `js/${(_process$env$npm_pack = "
|
|
5498
|
+
'solana-client': `js/${(_process$env$npm_pack = "1.53.1") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
|
|
5466
5499
|
};
|
|
5467
5500
|
/**
|
|
5468
5501
|
* A connection to a fullnode JSON RPC endpoint
|
|
@@ -10182,10 +10215,8 @@ class ValidatorInfo {
|
|
|
10182
10215
|
const configKeys = [];
|
|
10183
10216
|
|
|
10184
10217
|
for (let i = 0; i < 2; i++) {
|
|
10185
|
-
const publicKey = new PublicKey(byteArray
|
|
10186
|
-
|
|
10187
|
-
const isSigner = byteArray.slice(0, 1)[0] === 1;
|
|
10188
|
-
byteArray = byteArray.slice(1);
|
|
10218
|
+
const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
|
|
10219
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
10189
10220
|
configKeys.push({
|
|
10190
10221
|
publicKey,
|
|
10191
10222
|
isSigner
|