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