@solana/web3.js 1.41.10 → 1.41.11
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 +45 -18
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +45 -18
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +45 -18
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.esm.js +45 -18
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +45 -18
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +2 -2
- 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.browser.cjs.js
CHANGED
|
@@ -2224,6 +2224,36 @@ function encodeLength(bytes, len) {
|
|
|
2224
2224
|
}
|
|
2225
2225
|
}
|
|
2226
2226
|
|
|
2227
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
2228
|
+
/**
|
|
2229
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
2230
|
+
*/
|
|
2231
|
+
|
|
2232
|
+
function guardedShift(byteArray) {
|
|
2233
|
+
if (byteArray.length === 0) {
|
|
2234
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
2235
|
+
}
|
|
2236
|
+
|
|
2237
|
+
return byteArray.shift();
|
|
2238
|
+
}
|
|
2239
|
+
/**
|
|
2240
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
2241
|
+
* the array.
|
|
2242
|
+
*/
|
|
2243
|
+
|
|
2244
|
+
function guardedSplice(byteArray, ...args) {
|
|
2245
|
+
var _args$;
|
|
2246
|
+
|
|
2247
|
+
const [start] = args;
|
|
2248
|
+
|
|
2249
|
+
if (args.length === 2 // Implies that `deleteCount` was supplied
|
|
2250
|
+
? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
|
|
2251
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
2252
|
+
}
|
|
2253
|
+
|
|
2254
|
+
return byteArray.splice(...args);
|
|
2255
|
+
}
|
|
2256
|
+
|
|
2227
2257
|
/**
|
|
2228
2258
|
* The message header, identifying signed and read-only account
|
|
2229
2259
|
*/
|
|
@@ -2322,32 +2352,28 @@ class Message {
|
|
|
2322
2352
|
static from(buffer$1) {
|
|
2323
2353
|
// Slice up wire data
|
|
2324
2354
|
let byteArray = [...buffer$1];
|
|
2325
|
-
const numRequiredSignatures = byteArray
|
|
2326
|
-
const numReadonlySignedAccounts = byteArray
|
|
2327
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
2355
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
2356
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
2357
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
2328
2358
|
const accountCount = decodeLength(byteArray);
|
|
2329
2359
|
let accountKeys = [];
|
|
2330
2360
|
|
|
2331
2361
|
for (let i = 0; i < accountCount; i++) {
|
|
2332
|
-
const account = byteArray
|
|
2333
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2362
|
+
const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
2334
2363
|
accountKeys.push(bs58__default["default"].encode(buffer.Buffer.from(account)));
|
|
2335
2364
|
}
|
|
2336
2365
|
|
|
2337
|
-
const recentBlockhash = byteArray
|
|
2338
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2366
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
2339
2367
|
const instructionCount = decodeLength(byteArray);
|
|
2340
2368
|
let instructions = [];
|
|
2341
2369
|
|
|
2342
2370
|
for (let i = 0; i < instructionCount; i++) {
|
|
2343
|
-
const programIdIndex = byteArray
|
|
2371
|
+
const programIdIndex = guardedShift(byteArray);
|
|
2344
2372
|
const accountCount = decodeLength(byteArray);
|
|
2345
|
-
const accounts = byteArray
|
|
2346
|
-
byteArray = byteArray.slice(accountCount);
|
|
2373
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
2347
2374
|
const dataLength = decodeLength(byteArray);
|
|
2348
|
-
const dataSlice = byteArray
|
|
2375
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
2349
2376
|
const data = bs58__default["default"].encode(buffer.Buffer.from(dataSlice));
|
|
2350
|
-
byteArray = byteArray.slice(dataLength);
|
|
2351
2377
|
instructions.push({
|
|
2352
2378
|
programIdIndex,
|
|
2353
2379
|
accounts,
|
|
@@ -2376,6 +2402,10 @@ function assert (condition, message) {
|
|
|
2376
2402
|
}
|
|
2377
2403
|
}
|
|
2378
2404
|
|
|
2405
|
+
/**
|
|
2406
|
+
* Transaction signature as base-58 encoded string
|
|
2407
|
+
*/
|
|
2408
|
+
|
|
2379
2409
|
exports.TransactionStatus = void 0;
|
|
2380
2410
|
/**
|
|
2381
2411
|
* Default (empty) signature
|
|
@@ -3026,8 +3056,7 @@ class Transaction {
|
|
|
3026
3056
|
let signatures = [];
|
|
3027
3057
|
|
|
3028
3058
|
for (let i = 0; i < signatureCount; i++) {
|
|
3029
|
-
const signature = byteArray
|
|
3030
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
|
|
3059
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
|
|
3031
3060
|
signatures.push(bs58__default["default"].encode(buffer.Buffer.from(signature)));
|
|
3032
3061
|
}
|
|
3033
3062
|
|
|
@@ -9744,10 +9773,8 @@ class ValidatorInfo {
|
|
|
9744
9773
|
const configKeys = [];
|
|
9745
9774
|
|
|
9746
9775
|
for (let i = 0; i < 2; i++) {
|
|
9747
|
-
const publicKey = new PublicKey(byteArray
|
|
9748
|
-
|
|
9749
|
-
const isSigner = byteArray.slice(0, 1)[0] === 1;
|
|
9750
|
-
byteArray = byteArray.slice(1);
|
|
9776
|
+
const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
|
|
9777
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
9751
9778
|
configKeys.push({
|
|
9752
9779
|
publicKey,
|
|
9753
9780
|
isSigner
|