@solana/web3.js 1.38.0 → 1.38.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 +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 +37 -0
- package/src/validator-info.ts +5 -4
package/lib/index.browser.cjs.js
CHANGED
|
@@ -2192,6 +2192,36 @@ function encodeLength(bytes, len) {
|
|
|
2192
2192
|
}
|
|
2193
2193
|
}
|
|
2194
2194
|
|
|
2195
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
2196
|
+
/**
|
|
2197
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
2198
|
+
*/
|
|
2199
|
+
|
|
2200
|
+
function guardedShift(byteArray) {
|
|
2201
|
+
if (byteArray.length === 0) {
|
|
2202
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
2203
|
+
}
|
|
2204
|
+
|
|
2205
|
+
return byteArray.shift();
|
|
2206
|
+
}
|
|
2207
|
+
/**
|
|
2208
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
2209
|
+
* the array.
|
|
2210
|
+
*/
|
|
2211
|
+
|
|
2212
|
+
function guardedSplice(byteArray, ...args) {
|
|
2213
|
+
var _args$;
|
|
2214
|
+
|
|
2215
|
+
const [start] = args;
|
|
2216
|
+
|
|
2217
|
+
if (args.length === 2 // Implies that `deleteCount` was supplied
|
|
2218
|
+
? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
|
|
2219
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
2220
|
+
}
|
|
2221
|
+
|
|
2222
|
+
return byteArray.splice(...args);
|
|
2223
|
+
}
|
|
2224
|
+
|
|
2195
2225
|
/**
|
|
2196
2226
|
* The message header, identifying signed and read-only account
|
|
2197
2227
|
*/
|
|
@@ -2290,32 +2320,28 @@ class Message {
|
|
|
2290
2320
|
static from(buffer$1) {
|
|
2291
2321
|
// Slice up wire data
|
|
2292
2322
|
let byteArray = [...buffer$1];
|
|
2293
|
-
const numRequiredSignatures = byteArray
|
|
2294
|
-
const numReadonlySignedAccounts = byteArray
|
|
2295
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
2323
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
2324
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
2325
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
2296
2326
|
const accountCount = decodeLength(byteArray);
|
|
2297
2327
|
let accountKeys = [];
|
|
2298
2328
|
|
|
2299
2329
|
for (let i = 0; i < accountCount; i++) {
|
|
2300
|
-
const account = byteArray
|
|
2301
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2330
|
+
const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
2302
2331
|
accountKeys.push(bs58__default["default"].encode(buffer.Buffer.from(account)));
|
|
2303
2332
|
}
|
|
2304
2333
|
|
|
2305
|
-
const recentBlockhash = byteArray
|
|
2306
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2334
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
2307
2335
|
const instructionCount = decodeLength(byteArray);
|
|
2308
2336
|
let instructions = [];
|
|
2309
2337
|
|
|
2310
2338
|
for (let i = 0; i < instructionCount; i++) {
|
|
2311
|
-
const programIdIndex = byteArray
|
|
2339
|
+
const programIdIndex = guardedShift(byteArray);
|
|
2312
2340
|
const accountCount = decodeLength(byteArray);
|
|
2313
|
-
const accounts = byteArray
|
|
2314
|
-
byteArray = byteArray.slice(accountCount);
|
|
2341
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
2315
2342
|
const dataLength = decodeLength(byteArray);
|
|
2316
|
-
const dataSlice = byteArray
|
|
2343
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
2317
2344
|
const data = bs58__default["default"].encode(buffer.Buffer.from(dataSlice));
|
|
2318
|
-
byteArray = byteArray.slice(dataLength);
|
|
2319
2345
|
instructions.push({
|
|
2320
2346
|
programIdIndex,
|
|
2321
2347
|
accounts,
|
|
@@ -2344,6 +2370,10 @@ function assert (condition, message) {
|
|
|
2344
2370
|
}
|
|
2345
2371
|
}
|
|
2346
2372
|
|
|
2373
|
+
/**
|
|
2374
|
+
* Transaction signature as base-58 encoded string
|
|
2375
|
+
*/
|
|
2376
|
+
|
|
2347
2377
|
/**
|
|
2348
2378
|
* Default (empty) signature
|
|
2349
2379
|
*
|
|
@@ -2938,8 +2968,7 @@ class Transaction {
|
|
|
2938
2968
|
let signatures = [];
|
|
2939
2969
|
|
|
2940
2970
|
for (let i = 0; i < signatureCount; i++) {
|
|
2941
|
-
const signature = byteArray
|
|
2942
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH);
|
|
2971
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH);
|
|
2943
2972
|
signatures.push(bs58__default["default"].encode(buffer.Buffer.from(signature)));
|
|
2944
2973
|
}
|
|
2945
2974
|
|
|
@@ -9282,10 +9311,8 @@ class ValidatorInfo {
|
|
|
9282
9311
|
const configKeys = [];
|
|
9283
9312
|
|
|
9284
9313
|
for (let i = 0; i < 2; i++) {
|
|
9285
|
-
const publicKey = new PublicKey(byteArray
|
|
9286
|
-
|
|
9287
|
-
const isSigner = byteArray.slice(0, 1)[0] === 1;
|
|
9288
|
-
byteArray = byteArray.slice(1);
|
|
9314
|
+
const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
|
|
9315
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
9289
9316
|
configKeys.push({
|
|
9290
9317
|
publicKey,
|
|
9291
9318
|
isSigner
|