@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.esm.js
CHANGED
|
@@ -2223,6 +2223,40 @@ function encodeLength(bytes, len) {
|
|
|
2223
2223
|
}
|
|
2224
2224
|
}
|
|
2225
2225
|
|
|
2226
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
2227
|
+
/**
|
|
2228
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
2229
|
+
*/
|
|
2230
|
+
|
|
2231
|
+
function guardedShift(byteArray) {
|
|
2232
|
+
if (byteArray.length === 0) {
|
|
2233
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
2234
|
+
}
|
|
2235
|
+
|
|
2236
|
+
return byteArray.shift();
|
|
2237
|
+
}
|
|
2238
|
+
/**
|
|
2239
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
2240
|
+
* the array.
|
|
2241
|
+
*/
|
|
2242
|
+
|
|
2243
|
+
function guardedSplice(byteArray, ...args) {
|
|
2244
|
+
var _args$;
|
|
2245
|
+
|
|
2246
|
+
const [start] = args;
|
|
2247
|
+
|
|
2248
|
+
if (args.length === 2 // Implies that `deleteCount` was supplied
|
|
2249
|
+
? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
|
|
2250
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
2251
|
+
}
|
|
2252
|
+
|
|
2253
|
+
return byteArray.splice(...args);
|
|
2254
|
+
}
|
|
2255
|
+
|
|
2256
|
+
/**
|
|
2257
|
+
* Message constructor arguments
|
|
2258
|
+
*/
|
|
2259
|
+
|
|
2226
2260
|
const PUBKEY_LENGTH = 32;
|
|
2227
2261
|
/**
|
|
2228
2262
|
* List of instructions to be processed atomically
|
|
@@ -2317,32 +2351,28 @@ class Message {
|
|
|
2317
2351
|
static from(buffer) {
|
|
2318
2352
|
// Slice up wire data
|
|
2319
2353
|
let byteArray = [...buffer];
|
|
2320
|
-
const numRequiredSignatures = byteArray
|
|
2321
|
-
const numReadonlySignedAccounts = byteArray
|
|
2322
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
2354
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
2355
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
2356
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
2323
2357
|
const accountCount = decodeLength(byteArray);
|
|
2324
2358
|
let accountKeys = [];
|
|
2325
2359
|
|
|
2326
2360
|
for (let i = 0; i < accountCount; i++) {
|
|
2327
|
-
const account = byteArray
|
|
2328
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2361
|
+
const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
2329
2362
|
accountKeys.push(bs58.encode(Buffer.from(account)));
|
|
2330
2363
|
}
|
|
2331
2364
|
|
|
2332
|
-
const recentBlockhash = byteArray
|
|
2333
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2365
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
2334
2366
|
const instructionCount = decodeLength(byteArray);
|
|
2335
2367
|
let instructions = [];
|
|
2336
2368
|
|
|
2337
2369
|
for (let i = 0; i < instructionCount; i++) {
|
|
2338
|
-
const programIdIndex = byteArray
|
|
2370
|
+
const programIdIndex = guardedShift(byteArray);
|
|
2339
2371
|
const accountCount = decodeLength(byteArray);
|
|
2340
|
-
const accounts = byteArray
|
|
2341
|
-
byteArray = byteArray.slice(accountCount);
|
|
2372
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
2342
2373
|
const dataLength = decodeLength(byteArray);
|
|
2343
|
-
const dataSlice = byteArray
|
|
2374
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
2344
2375
|
const data = bs58.encode(Buffer.from(dataSlice));
|
|
2345
|
-
byteArray = byteArray.slice(dataLength);
|
|
2346
2376
|
instructions.push({
|
|
2347
2377
|
programIdIndex,
|
|
2348
2378
|
accounts,
|
|
@@ -2371,6 +2401,10 @@ function assert (condition, message) {
|
|
|
2371
2401
|
}
|
|
2372
2402
|
}
|
|
2373
2403
|
|
|
2404
|
+
/**
|
|
2405
|
+
* Transaction signature as base-58 encoded string
|
|
2406
|
+
*/
|
|
2407
|
+
|
|
2374
2408
|
let TransactionStatus;
|
|
2375
2409
|
/**
|
|
2376
2410
|
* Default (empty) signature
|
|
@@ -3050,8 +3084,7 @@ class Transaction {
|
|
|
3050
3084
|
let signatures = [];
|
|
3051
3085
|
|
|
3052
3086
|
for (let i = 0; i < signatureCount; i++) {
|
|
3053
|
-
const signature = byteArray
|
|
3054
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
|
|
3087
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
|
|
3055
3088
|
signatures.push(bs58.encode(Buffer.from(signature)));
|
|
3056
3089
|
}
|
|
3057
3090
|
|
|
@@ -5431,7 +5464,7 @@ const LogsNotificationResult = type({
|
|
|
5431
5464
|
|
|
5432
5465
|
/** @internal */
|
|
5433
5466
|
const COMMON_HTTP_HEADERS = {
|
|
5434
|
-
'solana-client': `js/${(_process$env$npm_pack = "
|
|
5467
|
+
'solana-client': `js/${(_process$env$npm_pack = "1.53.1") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
|
|
5435
5468
|
};
|
|
5436
5469
|
/**
|
|
5437
5470
|
* A connection to a fullnode JSON RPC endpoint
|
|
@@ -10151,10 +10184,8 @@ class ValidatorInfo {
|
|
|
10151
10184
|
const configKeys = [];
|
|
10152
10185
|
|
|
10153
10186
|
for (let i = 0; i < 2; i++) {
|
|
10154
|
-
const publicKey = new PublicKey(byteArray
|
|
10155
|
-
|
|
10156
|
-
const isSigner = byteArray.slice(0, 1)[0] === 1;
|
|
10157
|
-
byteArray = byteArray.slice(1);
|
|
10187
|
+
const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
|
|
10188
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
10158
10189
|
configKeys.push({
|
|
10159
10190
|
publicKey,
|
|
10160
10191
|
isSigner
|