@solana/web3.js 1.43.5 → 1.43.7
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.d.ts +1 -0
- 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 +7 -2
- package/src/util/guarded-array-utils.ts +34 -0
- package/src/validator-info.ts +5 -4
package/lib/index.browser.cjs.js
CHANGED
|
@@ -2218,6 +2218,36 @@ function encodeLength(bytes, len) {
|
|
|
2218
2218
|
}
|
|
2219
2219
|
}
|
|
2220
2220
|
|
|
2221
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
2222
|
+
/**
|
|
2223
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
2224
|
+
*/
|
|
2225
|
+
|
|
2226
|
+
function guardedShift(byteArray) {
|
|
2227
|
+
if (byteArray.length === 0) {
|
|
2228
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
2229
|
+
}
|
|
2230
|
+
|
|
2231
|
+
return byteArray.shift();
|
|
2232
|
+
}
|
|
2233
|
+
/**
|
|
2234
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
2235
|
+
* the array.
|
|
2236
|
+
*/
|
|
2237
|
+
|
|
2238
|
+
function guardedSplice(byteArray, ...args) {
|
|
2239
|
+
var _args$;
|
|
2240
|
+
|
|
2241
|
+
const [start] = args;
|
|
2242
|
+
|
|
2243
|
+
if (args.length === 2 // Implies that `deleteCount` was supplied
|
|
2244
|
+
? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
|
|
2245
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
2246
|
+
}
|
|
2247
|
+
|
|
2248
|
+
return byteArray.splice(...args);
|
|
2249
|
+
}
|
|
2250
|
+
|
|
2221
2251
|
/**
|
|
2222
2252
|
* The message header, identifying signed and read-only account
|
|
2223
2253
|
*/
|
|
@@ -2316,32 +2346,28 @@ class Message {
|
|
|
2316
2346
|
static from(buffer$1) {
|
|
2317
2347
|
// Slice up wire data
|
|
2318
2348
|
let byteArray = [...buffer$1];
|
|
2319
|
-
const numRequiredSignatures = byteArray
|
|
2320
|
-
const numReadonlySignedAccounts = byteArray
|
|
2321
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
2349
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
2350
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
2351
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
2322
2352
|
const accountCount = decodeLength(byteArray);
|
|
2323
2353
|
let accountKeys = [];
|
|
2324
2354
|
|
|
2325
2355
|
for (let i = 0; i < accountCount; i++) {
|
|
2326
|
-
const account = byteArray
|
|
2327
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2356
|
+
const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
2328
2357
|
accountKeys.push(bs58__default["default"].encode(buffer.Buffer.from(account)));
|
|
2329
2358
|
}
|
|
2330
2359
|
|
|
2331
|
-
const recentBlockhash = byteArray
|
|
2332
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2360
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
2333
2361
|
const instructionCount = decodeLength(byteArray);
|
|
2334
2362
|
let instructions = [];
|
|
2335
2363
|
|
|
2336
2364
|
for (let i = 0; i < instructionCount; i++) {
|
|
2337
|
-
const programIdIndex = byteArray
|
|
2365
|
+
const programIdIndex = guardedShift(byteArray);
|
|
2338
2366
|
const accountCount = decodeLength(byteArray);
|
|
2339
|
-
const accounts = byteArray
|
|
2340
|
-
byteArray = byteArray.slice(accountCount);
|
|
2367
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
2341
2368
|
const dataLength = decodeLength(byteArray);
|
|
2342
|
-
const dataSlice = byteArray
|
|
2369
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
2343
2370
|
const data = bs58__default["default"].encode(buffer.Buffer.from(dataSlice));
|
|
2344
|
-
byteArray = byteArray.slice(dataLength);
|
|
2345
2371
|
instructions.push({
|
|
2346
2372
|
programIdIndex,
|
|
2347
2373
|
accounts,
|
|
@@ -2370,6 +2396,10 @@ function assert (condition, message) {
|
|
|
2370
2396
|
}
|
|
2371
2397
|
}
|
|
2372
2398
|
|
|
2399
|
+
/**
|
|
2400
|
+
* Transaction signature as base-58 encoded string
|
|
2401
|
+
*/
|
|
2402
|
+
|
|
2373
2403
|
exports.TransactionStatus = void 0;
|
|
2374
2404
|
/**
|
|
2375
2405
|
* Default (empty) signature
|
|
@@ -3027,8 +3057,7 @@ class Transaction {
|
|
|
3027
3057
|
let signatures = [];
|
|
3028
3058
|
|
|
3029
3059
|
for (let i = 0; i < signatureCount; i++) {
|
|
3030
|
-
const signature = byteArray
|
|
3031
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
|
|
3060
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
|
|
3032
3061
|
signatures.push(bs58__default["default"].encode(buffer.Buffer.from(signature)));
|
|
3033
3062
|
}
|
|
3034
3063
|
|
|
@@ -9278,10 +9307,8 @@ class ValidatorInfo {
|
|
|
9278
9307
|
const configKeys = [];
|
|
9279
9308
|
|
|
9280
9309
|
for (let i = 0; i < 2; i++) {
|
|
9281
|
-
const publicKey = new PublicKey(byteArray
|
|
9282
|
-
|
|
9283
|
-
const isSigner = byteArray.slice(0, 1)[0] === 1;
|
|
9284
|
-
byteArray = byteArray.slice(1);
|
|
9310
|
+
const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
|
|
9311
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
9285
9312
|
configKeys.push({
|
|
9286
9313
|
publicKey,
|
|
9287
9314
|
isSigner
|