@solana/web3.js 1.29.3 → 1.29.4
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 +46 -25
- 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 +27 -27
- 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
|
@@ -2157,6 +2157,36 @@ function encodeLength(bytes, len) {
|
|
|
2157
2157
|
}
|
|
2158
2158
|
}
|
|
2159
2159
|
|
|
2160
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
2161
|
+
/**
|
|
2162
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
2163
|
+
*/
|
|
2164
|
+
|
|
2165
|
+
function guardedShift(byteArray) {
|
|
2166
|
+
if (byteArray.length === 0) {
|
|
2167
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
2168
|
+
}
|
|
2169
|
+
|
|
2170
|
+
return byteArray.shift();
|
|
2171
|
+
}
|
|
2172
|
+
/**
|
|
2173
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
2174
|
+
* the array.
|
|
2175
|
+
*/
|
|
2176
|
+
|
|
2177
|
+
function guardedSplice(byteArray, ...args) {
|
|
2178
|
+
var _args$;
|
|
2179
|
+
|
|
2180
|
+
const [start] = args;
|
|
2181
|
+
|
|
2182
|
+
if (args.length === 2 // Implies that `deleteCount` was supplied
|
|
2183
|
+
? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
|
|
2184
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
2185
|
+
}
|
|
2186
|
+
|
|
2187
|
+
return byteArray.splice(...args);
|
|
2188
|
+
}
|
|
2189
|
+
|
|
2160
2190
|
/**
|
|
2161
2191
|
* The message header, identifying signed and read-only account
|
|
2162
2192
|
*/
|
|
@@ -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
|
*
|
|
@@ -2907,8 +2937,7 @@ class Transaction {
|
|
|
2907
2937
|
let signatures = [];
|
|
2908
2938
|
|
|
2909
2939
|
for (let i = 0; i < signatureCount; i++) {
|
|
2910
|
-
const signature = byteArray
|
|
2911
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH);
|
|
2940
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH);
|
|
2912
2941
|
signatures.push(bs58__default["default"].encode(buffer.Buffer.from(signature)));
|
|
2913
2942
|
}
|
|
2914
2943
|
|
|
@@ -8464,10 +8493,8 @@ class ValidatorInfo {
|
|
|
8464
8493
|
const configKeys = [];
|
|
8465
8494
|
|
|
8466
8495
|
for (let i = 0; i < 2; i++) {
|
|
8467
|
-
const publicKey = new PublicKey(byteArray
|
|
8468
|
-
|
|
8469
|
-
const isSigner = byteArray.slice(0, 1)[0] === 1;
|
|
8470
|
-
byteArray = byteArray.slice(1);
|
|
8496
|
+
const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
|
|
8497
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
8471
8498
|
configKeys.push({
|
|
8472
8499
|
publicKey,
|
|
8473
8500
|
isSigner
|