@solana/web3.js 1.32.2 → 1.32.3
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
|
@@ -2155,6 +2155,36 @@ function encodeLength(bytes, len) {
|
|
|
2155
2155
|
}
|
|
2156
2156
|
}
|
|
2157
2157
|
|
|
2158
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
2159
|
+
/**
|
|
2160
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
2161
|
+
*/
|
|
2162
|
+
|
|
2163
|
+
function guardedShift(byteArray) {
|
|
2164
|
+
if (byteArray.length === 0) {
|
|
2165
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
2166
|
+
}
|
|
2167
|
+
|
|
2168
|
+
return byteArray.shift();
|
|
2169
|
+
}
|
|
2170
|
+
/**
|
|
2171
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
2172
|
+
* the array.
|
|
2173
|
+
*/
|
|
2174
|
+
|
|
2175
|
+
function guardedSplice(byteArray, ...args) {
|
|
2176
|
+
var _args$;
|
|
2177
|
+
|
|
2178
|
+
const [start] = args;
|
|
2179
|
+
|
|
2180
|
+
if (args.length === 2 // Implies that `deleteCount` was supplied
|
|
2181
|
+
? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
|
|
2182
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
2183
|
+
}
|
|
2184
|
+
|
|
2185
|
+
return byteArray.splice(...args);
|
|
2186
|
+
}
|
|
2187
|
+
|
|
2158
2188
|
/**
|
|
2159
2189
|
* The message header, identifying signed and read-only account
|
|
2160
2190
|
*/
|
|
@@ -2253,32 +2283,28 @@ class Message {
|
|
|
2253
2283
|
static from(buffer$1) {
|
|
2254
2284
|
// Slice up wire data
|
|
2255
2285
|
let byteArray = [...buffer$1];
|
|
2256
|
-
const numRequiredSignatures = byteArray
|
|
2257
|
-
const numReadonlySignedAccounts = byteArray
|
|
2258
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
2286
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
2287
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
2288
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
2259
2289
|
const accountCount = decodeLength(byteArray);
|
|
2260
2290
|
let accountKeys = [];
|
|
2261
2291
|
|
|
2262
2292
|
for (let i = 0; i < accountCount; i++) {
|
|
2263
|
-
const account = byteArray
|
|
2264
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2293
|
+
const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
2265
2294
|
accountKeys.push(bs58__default["default"].encode(buffer.Buffer.from(account)));
|
|
2266
2295
|
}
|
|
2267
2296
|
|
|
2268
|
-
const recentBlockhash = byteArray
|
|
2269
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2297
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
2270
2298
|
const instructionCount = decodeLength(byteArray);
|
|
2271
2299
|
let instructions = [];
|
|
2272
2300
|
|
|
2273
2301
|
for (let i = 0; i < instructionCount; i++) {
|
|
2274
|
-
const programIdIndex = byteArray
|
|
2302
|
+
const programIdIndex = guardedShift(byteArray);
|
|
2275
2303
|
const accountCount = decodeLength(byteArray);
|
|
2276
|
-
const accounts = byteArray
|
|
2277
|
-
byteArray = byteArray.slice(accountCount);
|
|
2304
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
2278
2305
|
const dataLength = decodeLength(byteArray);
|
|
2279
|
-
const dataSlice = byteArray
|
|
2306
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
2280
2307
|
const data = bs58__default["default"].encode(buffer.Buffer.from(dataSlice));
|
|
2281
|
-
byteArray = byteArray.slice(dataLength);
|
|
2282
2308
|
instructions.push({
|
|
2283
2309
|
programIdIndex,
|
|
2284
2310
|
accounts,
|
|
@@ -2307,6 +2333,10 @@ function assert (condition, message) {
|
|
|
2307
2333
|
}
|
|
2308
2334
|
}
|
|
2309
2335
|
|
|
2336
|
+
/**
|
|
2337
|
+
* Transaction signature as base-58 encoded string
|
|
2338
|
+
*/
|
|
2339
|
+
|
|
2310
2340
|
/**
|
|
2311
2341
|
* Default (empty) signature
|
|
2312
2342
|
*
|
|
@@ -2893,8 +2923,7 @@ class Transaction {
|
|
|
2893
2923
|
let signatures = [];
|
|
2894
2924
|
|
|
2895
2925
|
for (let i = 0; i < signatureCount; i++) {
|
|
2896
|
-
const signature = byteArray
|
|
2897
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH);
|
|
2926
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH);
|
|
2898
2927
|
signatures.push(bs58__default["default"].encode(buffer.Buffer.from(signature)));
|
|
2899
2928
|
}
|
|
2900
2929
|
|
|
@@ -8628,10 +8657,8 @@ class ValidatorInfo {
|
|
|
8628
8657
|
const configKeys = [];
|
|
8629
8658
|
|
|
8630
8659
|
for (let i = 0; i < 2; i++) {
|
|
8631
|
-
const publicKey = new PublicKey(byteArray
|
|
8632
|
-
|
|
8633
|
-
const isSigner = byteArray.slice(0, 1)[0] === 1;
|
|
8634
|
-
byteArray = byteArray.slice(1);
|
|
8660
|
+
const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
|
|
8661
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
8635
8662
|
configKeys.push({
|
|
8636
8663
|
publicKey,
|
|
8637
8664
|
isSigner
|