@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.esm.js
CHANGED
|
@@ -2247,6 +2247,40 @@ function encodeLength(bytes, len) {
|
|
|
2247
2247
|
}
|
|
2248
2248
|
}
|
|
2249
2249
|
|
|
2250
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
2251
|
+
/**
|
|
2252
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
2253
|
+
*/
|
|
2254
|
+
|
|
2255
|
+
function guardedShift(byteArray) {
|
|
2256
|
+
if (byteArray.length === 0) {
|
|
2257
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
2258
|
+
}
|
|
2259
|
+
|
|
2260
|
+
return byteArray.shift();
|
|
2261
|
+
}
|
|
2262
|
+
/**
|
|
2263
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
2264
|
+
* the array.
|
|
2265
|
+
*/
|
|
2266
|
+
|
|
2267
|
+
function guardedSplice(byteArray, ...args) {
|
|
2268
|
+
var _args$;
|
|
2269
|
+
|
|
2270
|
+
const [start] = args;
|
|
2271
|
+
|
|
2272
|
+
if (args.length === 2 // Implies that `deleteCount` was supplied
|
|
2273
|
+
? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
|
|
2274
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
2275
|
+
}
|
|
2276
|
+
|
|
2277
|
+
return byteArray.splice(...args);
|
|
2278
|
+
}
|
|
2279
|
+
|
|
2280
|
+
/**
|
|
2281
|
+
* Message constructor arguments
|
|
2282
|
+
*/
|
|
2283
|
+
|
|
2250
2284
|
const PUBKEY_LENGTH = 32;
|
|
2251
2285
|
/**
|
|
2252
2286
|
* List of instructions to be processed atomically
|
|
@@ -2341,32 +2375,28 @@ class Message {
|
|
|
2341
2375
|
static from(buffer) {
|
|
2342
2376
|
// Slice up wire data
|
|
2343
2377
|
let byteArray = [...buffer];
|
|
2344
|
-
const numRequiredSignatures = byteArray
|
|
2345
|
-
const numReadonlySignedAccounts = byteArray
|
|
2346
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
2378
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
2379
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
2380
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
2347
2381
|
const accountCount = decodeLength(byteArray);
|
|
2348
2382
|
let accountKeys = [];
|
|
2349
2383
|
|
|
2350
2384
|
for (let i = 0; i < accountCount; i++) {
|
|
2351
|
-
const account = byteArray
|
|
2352
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2385
|
+
const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
2353
2386
|
accountKeys.push(bs58.encode(Buffer.from(account)));
|
|
2354
2387
|
}
|
|
2355
2388
|
|
|
2356
|
-
const recentBlockhash = byteArray
|
|
2357
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2389
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
2358
2390
|
const instructionCount = decodeLength(byteArray);
|
|
2359
2391
|
let instructions = [];
|
|
2360
2392
|
|
|
2361
2393
|
for (let i = 0; i < instructionCount; i++) {
|
|
2362
|
-
const programIdIndex = byteArray
|
|
2394
|
+
const programIdIndex = guardedShift(byteArray);
|
|
2363
2395
|
const accountCount = decodeLength(byteArray);
|
|
2364
|
-
const accounts = byteArray
|
|
2365
|
-
byteArray = byteArray.slice(accountCount);
|
|
2396
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
2366
2397
|
const dataLength = decodeLength(byteArray);
|
|
2367
|
-
const dataSlice = byteArray
|
|
2398
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
2368
2399
|
const data = bs58.encode(Buffer.from(dataSlice));
|
|
2369
|
-
byteArray = byteArray.slice(dataLength);
|
|
2370
2400
|
instructions.push({
|
|
2371
2401
|
programIdIndex,
|
|
2372
2402
|
accounts,
|
|
@@ -2395,6 +2425,10 @@ function assert (condition, message) {
|
|
|
2395
2425
|
}
|
|
2396
2426
|
}
|
|
2397
2427
|
|
|
2428
|
+
/**
|
|
2429
|
+
* Transaction signature as base-58 encoded string
|
|
2430
|
+
*/
|
|
2431
|
+
|
|
2398
2432
|
let TransactionStatus;
|
|
2399
2433
|
/**
|
|
2400
2434
|
* Default (empty) signature
|
|
@@ -3074,8 +3108,7 @@ class Transaction {
|
|
|
3074
3108
|
let signatures = [];
|
|
3075
3109
|
|
|
3076
3110
|
for (let i = 0; i < signatureCount; i++) {
|
|
3077
|
-
const signature = byteArray
|
|
3078
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
|
|
3111
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
|
|
3079
3112
|
signatures.push(bs58.encode(Buffer.from(signature)));
|
|
3080
3113
|
}
|
|
3081
3114
|
|
|
@@ -5513,7 +5546,7 @@ const LogsNotificationResult = type({
|
|
|
5513
5546
|
|
|
5514
5547
|
/** @internal */
|
|
5515
5548
|
const COMMON_HTTP_HEADERS = {
|
|
5516
|
-
'solana-client': `js/${(_process$env$npm_pack = "
|
|
5549
|
+
'solana-client': `js/${(_process$env$npm_pack = "1.53.1") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
|
|
5517
5550
|
};
|
|
5518
5551
|
/**
|
|
5519
5552
|
* A connection to a fullnode JSON RPC endpoint
|
|
@@ -10233,10 +10266,8 @@ class ValidatorInfo {
|
|
|
10233
10266
|
const configKeys = [];
|
|
10234
10267
|
|
|
10235
10268
|
for (let i = 0; i < 2; i++) {
|
|
10236
|
-
const publicKey = new PublicKey(byteArray
|
|
10237
|
-
|
|
10238
|
-
const isSigner = byteArray.slice(0, 1)[0] === 1;
|
|
10239
|
-
byteArray = byteArray.slice(1);
|
|
10269
|
+
const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
|
|
10270
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
10240
10271
|
configKeys.push({
|
|
10241
10272
|
publicKey,
|
|
10242
10273
|
isSigner
|