@solana/web3.js 1.24.1 → 1.24.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 +46 -19
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +46 -18
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +5 -0
- package/lib/index.esm.js +46 -19
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +86 -43
- 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/module.flow.js +4 -0
- package/package.json +31 -31
- package/src/index.ts +1 -0
- 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
|
@@ -476,6 +476,36 @@ function encodeLength(bytes, len) {
|
|
|
476
476
|
}
|
|
477
477
|
}
|
|
478
478
|
|
|
479
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
480
|
+
/**
|
|
481
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
482
|
+
*/
|
|
483
|
+
|
|
484
|
+
function guardedShift(byteArray) {
|
|
485
|
+
if (byteArray.length === 0) {
|
|
486
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
return byteArray.shift();
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
493
|
+
* the array.
|
|
494
|
+
*/
|
|
495
|
+
|
|
496
|
+
function guardedSplice(byteArray, ...args) {
|
|
497
|
+
var _args$;
|
|
498
|
+
|
|
499
|
+
const [start] = args;
|
|
500
|
+
|
|
501
|
+
if (args.length === 2 // Implies that `deleteCount` was supplied
|
|
502
|
+
? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
|
|
503
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
return byteArray.splice(...args);
|
|
507
|
+
}
|
|
508
|
+
|
|
479
509
|
/**
|
|
480
510
|
* The message header, identifying signed and read-only account
|
|
481
511
|
*/
|
|
@@ -560,32 +590,28 @@ class Message {
|
|
|
560
590
|
static from(buffer$1) {
|
|
561
591
|
// Slice up wire data
|
|
562
592
|
let byteArray = [...buffer$1];
|
|
563
|
-
const numRequiredSignatures = byteArray
|
|
564
|
-
const numReadonlySignedAccounts = byteArray
|
|
565
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
593
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
594
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
595
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
566
596
|
const accountCount = decodeLength(byteArray);
|
|
567
597
|
let accountKeys = [];
|
|
568
598
|
|
|
569
599
|
for (let i = 0; i < accountCount; i++) {
|
|
570
|
-
const account = byteArray
|
|
571
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
600
|
+
const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
572
601
|
accountKeys.push(bs58__default['default'].encode(buffer.Buffer.from(account)));
|
|
573
602
|
}
|
|
574
603
|
|
|
575
|
-
const recentBlockhash = byteArray
|
|
576
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
604
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
577
605
|
const instructionCount = decodeLength(byteArray);
|
|
578
606
|
let instructions = [];
|
|
579
607
|
|
|
580
608
|
for (let i = 0; i < instructionCount; i++) {
|
|
581
|
-
const programIdIndex = byteArray
|
|
609
|
+
const programIdIndex = guardedShift(byteArray);
|
|
582
610
|
const accountCount = decodeLength(byteArray);
|
|
583
|
-
const accounts = byteArray
|
|
584
|
-
byteArray = byteArray.slice(accountCount);
|
|
611
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
585
612
|
const dataLength = decodeLength(byteArray);
|
|
586
|
-
const dataSlice = byteArray
|
|
613
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
587
614
|
const data = bs58__default['default'].encode(buffer.Buffer.from(dataSlice));
|
|
588
|
-
byteArray = byteArray.slice(dataLength);
|
|
589
615
|
instructions.push({
|
|
590
616
|
programIdIndex,
|
|
591
617
|
accounts,
|
|
@@ -614,6 +640,10 @@ function assert (condition, message) {
|
|
|
614
640
|
}
|
|
615
641
|
}
|
|
616
642
|
|
|
643
|
+
/**
|
|
644
|
+
* Transaction signature as base-58 encoded string
|
|
645
|
+
*/
|
|
646
|
+
|
|
617
647
|
/**
|
|
618
648
|
* Default (empty) signature
|
|
619
649
|
*
|
|
@@ -1207,8 +1237,7 @@ class Transaction {
|
|
|
1207
1237
|
let signatures = [];
|
|
1208
1238
|
|
|
1209
1239
|
for (let i = 0; i < signatureCount; i++) {
|
|
1210
|
-
const signature = byteArray
|
|
1211
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH);
|
|
1240
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH);
|
|
1212
1241
|
signatures.push(bs58__default['default'].encode(buffer.Buffer.from(signature)));
|
|
1213
1242
|
}
|
|
1214
1243
|
|
|
@@ -6606,10 +6635,8 @@ class ValidatorInfo {
|
|
|
6606
6635
|
const configKeys = [];
|
|
6607
6636
|
|
|
6608
6637
|
for (let i = 0; i < 2; i++) {
|
|
6609
|
-
const publicKey = new PublicKey(byteArray
|
|
6610
|
-
|
|
6611
|
-
const isSigner = byteArray.slice(0, 1)[0] === 1;
|
|
6612
|
-
byteArray = byteArray.slice(1);
|
|
6638
|
+
const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
|
|
6639
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
6613
6640
|
configKeys.push({
|
|
6614
6641
|
publicKey,
|
|
6615
6642
|
isSigner
|
|
@@ -6806,6 +6833,7 @@ exports.SYSVAR_RENT_PUBKEY = SYSVAR_RENT_PUBKEY;
|
|
|
6806
6833
|
exports.SYSVAR_REWARDS_PUBKEY = SYSVAR_REWARDS_PUBKEY;
|
|
6807
6834
|
exports.SYSVAR_STAKE_HISTORY_PUBKEY = SYSVAR_STAKE_HISTORY_PUBKEY;
|
|
6808
6835
|
exports.Secp256k1Program = Secp256k1Program;
|
|
6836
|
+
exports.SendTransactionError = SendTransactionError;
|
|
6809
6837
|
exports.StakeAuthorizationLayout = StakeAuthorizationLayout;
|
|
6810
6838
|
exports.StakeInstruction = StakeInstruction;
|
|
6811
6839
|
exports.StakeProgram = StakeProgram;
|