@solana/web3.js 1.45.0 → 1.45.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 +46 -19
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +46 -19
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +46 -19
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.esm.js +46 -19
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +46 -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/package.json +22 -22
- package/src/message.ts +9 -12
- package/src/transaction.ts +2 -2
- package/src/util/guarded-array-utils.ts +34 -0
- package/src/validator-info.ts +5 -4
package/lib/index.cjs.js
CHANGED
|
@@ -2245,6 +2245,36 @@ function encodeLength(bytes, len) {
|
|
|
2245
2245
|
}
|
|
2246
2246
|
}
|
|
2247
2247
|
|
|
2248
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
2249
|
+
/**
|
|
2250
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
2251
|
+
*/
|
|
2252
|
+
|
|
2253
|
+
function guardedShift(byteArray) {
|
|
2254
|
+
if (byteArray.length === 0) {
|
|
2255
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
2256
|
+
}
|
|
2257
|
+
|
|
2258
|
+
return byteArray.shift();
|
|
2259
|
+
}
|
|
2260
|
+
/**
|
|
2261
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
2262
|
+
* the array.
|
|
2263
|
+
*/
|
|
2264
|
+
|
|
2265
|
+
function guardedSplice(byteArray, ...args) {
|
|
2266
|
+
var _args$;
|
|
2267
|
+
|
|
2268
|
+
const [start] = args;
|
|
2269
|
+
|
|
2270
|
+
if (args.length === 2 // Implies that `deleteCount` was supplied
|
|
2271
|
+
? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
|
|
2272
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
2273
|
+
}
|
|
2274
|
+
|
|
2275
|
+
return byteArray.splice(...args);
|
|
2276
|
+
}
|
|
2277
|
+
|
|
2248
2278
|
/**
|
|
2249
2279
|
* The message header, identifying signed and read-only account
|
|
2250
2280
|
*/
|
|
@@ -2343,32 +2373,28 @@ class Message {
|
|
|
2343
2373
|
static from(buffer$1) {
|
|
2344
2374
|
// Slice up wire data
|
|
2345
2375
|
let byteArray = [...buffer$1];
|
|
2346
|
-
const numRequiredSignatures = byteArray
|
|
2347
|
-
const numReadonlySignedAccounts = byteArray
|
|
2348
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
2376
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
2377
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
2378
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
2349
2379
|
const accountCount = decodeLength(byteArray);
|
|
2350
2380
|
let accountKeys = [];
|
|
2351
2381
|
|
|
2352
2382
|
for (let i = 0; i < accountCount; i++) {
|
|
2353
|
-
const account = byteArray
|
|
2354
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2383
|
+
const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
2355
2384
|
accountKeys.push(bs58__default["default"].encode(buffer.Buffer.from(account)));
|
|
2356
2385
|
}
|
|
2357
2386
|
|
|
2358
|
-
const recentBlockhash = byteArray
|
|
2359
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2387
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
2360
2388
|
const instructionCount = decodeLength(byteArray);
|
|
2361
2389
|
let instructions = [];
|
|
2362
2390
|
|
|
2363
2391
|
for (let i = 0; i < instructionCount; i++) {
|
|
2364
|
-
const programIdIndex = byteArray
|
|
2392
|
+
const programIdIndex = guardedShift(byteArray);
|
|
2365
2393
|
const accountCount = decodeLength(byteArray);
|
|
2366
|
-
const accounts = byteArray
|
|
2367
|
-
byteArray = byteArray.slice(accountCount);
|
|
2394
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
2368
2395
|
const dataLength = decodeLength(byteArray);
|
|
2369
|
-
const dataSlice = byteArray
|
|
2396
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
2370
2397
|
const data = bs58__default["default"].encode(buffer.Buffer.from(dataSlice));
|
|
2371
|
-
byteArray = byteArray.slice(dataLength);
|
|
2372
2398
|
instructions.push({
|
|
2373
2399
|
programIdIndex,
|
|
2374
2400
|
accounts,
|
|
@@ -2397,6 +2423,10 @@ function assert (condition, message) {
|
|
|
2397
2423
|
}
|
|
2398
2424
|
}
|
|
2399
2425
|
|
|
2426
|
+
/**
|
|
2427
|
+
* Transaction signature as base-58 encoded string
|
|
2428
|
+
*/
|
|
2429
|
+
|
|
2400
2430
|
exports.TransactionStatus = void 0;
|
|
2401
2431
|
/**
|
|
2402
2432
|
* Default (empty) signature
|
|
@@ -3057,8 +3087,7 @@ class Transaction {
|
|
|
3057
3087
|
let signatures = [];
|
|
3058
3088
|
|
|
3059
3089
|
for (let i = 0; i < signatureCount; i++) {
|
|
3060
|
-
const signature = byteArray
|
|
3061
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
|
|
3090
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
|
|
3062
3091
|
signatures.push(bs58__default["default"].encode(buffer.Buffer.from(signature)));
|
|
3063
3092
|
}
|
|
3064
3093
|
|
|
@@ -5570,7 +5599,7 @@ const LogsNotificationResult = superstruct.type({
|
|
|
5570
5599
|
|
|
5571
5600
|
/** @internal */
|
|
5572
5601
|
const COMMON_HTTP_HEADERS = {
|
|
5573
|
-
'solana-client': `js/${(_process$env$npm_pack = "
|
|
5602
|
+
'solana-client': `js/${(_process$env$npm_pack = "1.45.1") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
|
|
5574
5603
|
};
|
|
5575
5604
|
/**
|
|
5576
5605
|
* A connection to a fullnode JSON RPC endpoint
|
|
@@ -9382,10 +9411,8 @@ class ValidatorInfo {
|
|
|
9382
9411
|
const configKeys = [];
|
|
9383
9412
|
|
|
9384
9413
|
for (let i = 0; i < 2; i++) {
|
|
9385
|
-
const publicKey = new PublicKey(byteArray
|
|
9386
|
-
|
|
9387
|
-
const isSigner = byteArray.slice(0, 1)[0] === 1;
|
|
9388
|
-
byteArray = byteArray.slice(1);
|
|
9414
|
+
const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
|
|
9415
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
9389
9416
|
configKeys.push({
|
|
9390
9417
|
publicKey,
|
|
9391
9418
|
isSigner
|