@solana/web3.js 1.35.1 → 1.35.2
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.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 +23 -23
- 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.cjs.js
CHANGED
|
@@ -2162,6 +2162,36 @@ function encodeLength(bytes, len) {
|
|
|
2162
2162
|
}
|
|
2163
2163
|
}
|
|
2164
2164
|
|
|
2165
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
2166
|
+
/**
|
|
2167
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
2168
|
+
*/
|
|
2169
|
+
|
|
2170
|
+
function guardedShift(byteArray) {
|
|
2171
|
+
if (byteArray.length === 0) {
|
|
2172
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
2173
|
+
}
|
|
2174
|
+
|
|
2175
|
+
return byteArray.shift();
|
|
2176
|
+
}
|
|
2177
|
+
/**
|
|
2178
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
2179
|
+
* the array.
|
|
2180
|
+
*/
|
|
2181
|
+
|
|
2182
|
+
function guardedSplice(byteArray, ...args) {
|
|
2183
|
+
var _args$;
|
|
2184
|
+
|
|
2185
|
+
const [start] = args;
|
|
2186
|
+
|
|
2187
|
+
if (args.length === 2 // Implies that `deleteCount` was supplied
|
|
2188
|
+
? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
|
|
2189
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
2190
|
+
}
|
|
2191
|
+
|
|
2192
|
+
return byteArray.splice(...args);
|
|
2193
|
+
}
|
|
2194
|
+
|
|
2165
2195
|
/**
|
|
2166
2196
|
* The message header, identifying signed and read-only account
|
|
2167
2197
|
*/
|
|
@@ -2260,32 +2290,28 @@ class Message {
|
|
|
2260
2290
|
static from(buffer$1) {
|
|
2261
2291
|
// Slice up wire data
|
|
2262
2292
|
let byteArray = [...buffer$1];
|
|
2263
|
-
const numRequiredSignatures = byteArray
|
|
2264
|
-
const numReadonlySignedAccounts = byteArray
|
|
2265
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
2293
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
2294
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
2295
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
2266
2296
|
const accountCount = decodeLength(byteArray);
|
|
2267
2297
|
let accountKeys = [];
|
|
2268
2298
|
|
|
2269
2299
|
for (let i = 0; i < accountCount; i++) {
|
|
2270
|
-
const account = byteArray
|
|
2271
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2300
|
+
const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
2272
2301
|
accountKeys.push(bs58__default["default"].encode(buffer.Buffer.from(account)));
|
|
2273
2302
|
}
|
|
2274
2303
|
|
|
2275
|
-
const recentBlockhash = byteArray
|
|
2276
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2304
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
2277
2305
|
const instructionCount = decodeLength(byteArray);
|
|
2278
2306
|
let instructions = [];
|
|
2279
2307
|
|
|
2280
2308
|
for (let i = 0; i < instructionCount; i++) {
|
|
2281
|
-
const programIdIndex = byteArray
|
|
2309
|
+
const programIdIndex = guardedShift(byteArray);
|
|
2282
2310
|
const accountCount = decodeLength(byteArray);
|
|
2283
|
-
const accounts = byteArray
|
|
2284
|
-
byteArray = byteArray.slice(accountCount);
|
|
2311
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
2285
2312
|
const dataLength = decodeLength(byteArray);
|
|
2286
|
-
const dataSlice = byteArray
|
|
2313
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
2287
2314
|
const data = bs58__default["default"].encode(buffer.Buffer.from(dataSlice));
|
|
2288
|
-
byteArray = byteArray.slice(dataLength);
|
|
2289
2315
|
instructions.push({
|
|
2290
2316
|
programIdIndex,
|
|
2291
2317
|
accounts,
|
|
@@ -2314,6 +2340,10 @@ function assert (condition, message) {
|
|
|
2314
2340
|
}
|
|
2315
2341
|
}
|
|
2316
2342
|
|
|
2343
|
+
/**
|
|
2344
|
+
* Transaction signature as base-58 encoded string
|
|
2345
|
+
*/
|
|
2346
|
+
|
|
2317
2347
|
/**
|
|
2318
2348
|
* Default (empty) signature
|
|
2319
2349
|
*
|
|
@@ -2900,8 +2930,7 @@ class Transaction {
|
|
|
2900
2930
|
let signatures = [];
|
|
2901
2931
|
|
|
2902
2932
|
for (let i = 0; i < signatureCount; i++) {
|
|
2903
|
-
const signature = byteArray
|
|
2904
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH);
|
|
2933
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH);
|
|
2905
2934
|
signatures.push(bs58__default["default"].encode(buffer.Buffer.from(signature)));
|
|
2906
2935
|
}
|
|
2907
2936
|
|
|
@@ -8673,10 +8702,8 @@ class ValidatorInfo {
|
|
|
8673
8702
|
const configKeys = [];
|
|
8674
8703
|
|
|
8675
8704
|
for (let i = 0; i < 2; i++) {
|
|
8676
|
-
const publicKey = new PublicKey(byteArray
|
|
8677
|
-
|
|
8678
|
-
const isSigner = byteArray.slice(0, 1)[0] === 1;
|
|
8679
|
-
byteArray = byteArray.slice(1);
|
|
8705
|
+
const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
|
|
8706
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
8680
8707
|
configKeys.push({
|
|
8681
8708
|
publicKey,
|
|
8682
8709
|
isSigner
|