@solana/web3.js 1.45.0 → 1.45.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 +46 -19
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +46 -19
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +46 -19
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.esm.js +46 -19
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +46 -19
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +3 -3
- 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 +34 -0
- package/src/validator-info.ts +5 -4
package/lib/index.browser.esm.js
CHANGED
|
@@ -2187,6 +2187,36 @@ function encodeLength(bytes, len) {
|
|
|
2187
2187
|
}
|
|
2188
2188
|
}
|
|
2189
2189
|
|
|
2190
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
2191
|
+
/**
|
|
2192
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
2193
|
+
*/
|
|
2194
|
+
|
|
2195
|
+
function guardedShift(byteArray) {
|
|
2196
|
+
if (byteArray.length === 0) {
|
|
2197
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
2198
|
+
}
|
|
2199
|
+
|
|
2200
|
+
return byteArray.shift();
|
|
2201
|
+
}
|
|
2202
|
+
/**
|
|
2203
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
2204
|
+
* the array.
|
|
2205
|
+
*/
|
|
2206
|
+
|
|
2207
|
+
function guardedSplice(byteArray, ...args) {
|
|
2208
|
+
var _args$;
|
|
2209
|
+
|
|
2210
|
+
const [start] = args;
|
|
2211
|
+
|
|
2212
|
+
if (args.length === 2 // Implies that `deleteCount` was supplied
|
|
2213
|
+
? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
|
|
2214
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
2215
|
+
}
|
|
2216
|
+
|
|
2217
|
+
return byteArray.splice(...args);
|
|
2218
|
+
}
|
|
2219
|
+
|
|
2190
2220
|
/**
|
|
2191
2221
|
* The message header, identifying signed and read-only account
|
|
2192
2222
|
*/
|
|
@@ -2285,32 +2315,28 @@ class Message {
|
|
|
2285
2315
|
static from(buffer) {
|
|
2286
2316
|
// Slice up wire data
|
|
2287
2317
|
let byteArray = [...buffer];
|
|
2288
|
-
const numRequiredSignatures = byteArray
|
|
2289
|
-
const numReadonlySignedAccounts = byteArray
|
|
2290
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
2318
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
2319
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
2320
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
2291
2321
|
const accountCount = decodeLength(byteArray);
|
|
2292
2322
|
let accountKeys = [];
|
|
2293
2323
|
|
|
2294
2324
|
for (let i = 0; i < accountCount; i++) {
|
|
2295
|
-
const account = byteArray
|
|
2296
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2325
|
+
const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
2297
2326
|
accountKeys.push(bs58.encode(Buffer.from(account)));
|
|
2298
2327
|
}
|
|
2299
2328
|
|
|
2300
|
-
const recentBlockhash = byteArray
|
|
2301
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2329
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
2302
2330
|
const instructionCount = decodeLength(byteArray);
|
|
2303
2331
|
let instructions = [];
|
|
2304
2332
|
|
|
2305
2333
|
for (let i = 0; i < instructionCount; i++) {
|
|
2306
|
-
const programIdIndex = byteArray
|
|
2334
|
+
const programIdIndex = guardedShift(byteArray);
|
|
2307
2335
|
const accountCount = decodeLength(byteArray);
|
|
2308
|
-
const accounts = byteArray
|
|
2309
|
-
byteArray = byteArray.slice(accountCount);
|
|
2336
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
2310
2337
|
const dataLength = decodeLength(byteArray);
|
|
2311
|
-
const dataSlice = byteArray
|
|
2338
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
2312
2339
|
const data = bs58.encode(Buffer.from(dataSlice));
|
|
2313
|
-
byteArray = byteArray.slice(dataLength);
|
|
2314
2340
|
instructions.push({
|
|
2315
2341
|
programIdIndex,
|
|
2316
2342
|
accounts,
|
|
@@ -2339,6 +2365,10 @@ function assert (condition, message) {
|
|
|
2339
2365
|
}
|
|
2340
2366
|
}
|
|
2341
2367
|
|
|
2368
|
+
/**
|
|
2369
|
+
* Transaction signature as base-58 encoded string
|
|
2370
|
+
*/
|
|
2371
|
+
|
|
2342
2372
|
let TransactionStatus;
|
|
2343
2373
|
/**
|
|
2344
2374
|
* Default (empty) signature
|
|
@@ -2999,8 +3029,7 @@ class Transaction {
|
|
|
2999
3029
|
let signatures = [];
|
|
3000
3030
|
|
|
3001
3031
|
for (let i = 0; i < signatureCount; i++) {
|
|
3002
|
-
const signature = byteArray
|
|
3003
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
|
|
3032
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
|
|
3004
3033
|
signatures.push(bs58.encode(Buffer.from(signature)));
|
|
3005
3034
|
}
|
|
3006
3035
|
|
|
@@ -5454,7 +5483,7 @@ const LogsNotificationResult = type({
|
|
|
5454
5483
|
|
|
5455
5484
|
/** @internal */
|
|
5456
5485
|
const COMMON_HTTP_HEADERS = {
|
|
5457
|
-
'solana-client': `js/${(_process$env$npm_pack = "
|
|
5486
|
+
'solana-client': `js/${(_process$env$npm_pack = "1.45.1") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
|
|
5458
5487
|
};
|
|
5459
5488
|
/**
|
|
5460
5489
|
* A connection to a fullnode JSON RPC endpoint
|
|
@@ -9266,10 +9295,8 @@ class ValidatorInfo {
|
|
|
9266
9295
|
const configKeys = [];
|
|
9267
9296
|
|
|
9268
9297
|
for (let i = 0; i < 2; i++) {
|
|
9269
|
-
const publicKey = new PublicKey(byteArray
|
|
9270
|
-
|
|
9271
|
-
const isSigner = byteArray.slice(0, 1)[0] === 1;
|
|
9272
|
-
byteArray = byteArray.slice(1);
|
|
9298
|
+
const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
|
|
9299
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
9273
9300
|
configKeys.push({
|
|
9274
9301
|
publicKey,
|
|
9275
9302
|
isSigner
|