@solana/web3.js 1.1.0 → 1.1.2
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 +41 -18
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +41 -18
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +2320 -0
- package/lib/index.esm.js +41 -18
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +483 -400
- 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/lib/types/index.d.ts.map +1 -1
- package/package.json +28 -28
- 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.browser.esm.js
CHANGED
|
@@ -4729,6 +4729,36 @@ function encodeLength(bytes, len) {
|
|
|
4729
4729
|
}
|
|
4730
4730
|
}
|
|
4731
4731
|
|
|
4732
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
4733
|
+
/**
|
|
4734
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
4735
|
+
*/
|
|
4736
|
+
|
|
4737
|
+
function guardedShift(byteArray) {
|
|
4738
|
+
if (byteArray.length === 0) {
|
|
4739
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
4740
|
+
}
|
|
4741
|
+
|
|
4742
|
+
return byteArray.shift();
|
|
4743
|
+
}
|
|
4744
|
+
/**
|
|
4745
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
4746
|
+
* the array.
|
|
4747
|
+
*/
|
|
4748
|
+
|
|
4749
|
+
function guardedSplice(byteArray, ...args) {
|
|
4750
|
+
var _args$;
|
|
4751
|
+
|
|
4752
|
+
const [start] = args;
|
|
4753
|
+
|
|
4754
|
+
if (args.length === 2 // Implies that `deleteCount` was supplied
|
|
4755
|
+
? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
|
|
4756
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
4757
|
+
}
|
|
4758
|
+
|
|
4759
|
+
return byteArray.splice(...args);
|
|
4760
|
+
}
|
|
4761
|
+
|
|
4732
4762
|
/**
|
|
4733
4763
|
* The message header, identifying signed and read-only account
|
|
4734
4764
|
*
|
|
@@ -4819,32 +4849,28 @@ class Message {
|
|
|
4819
4849
|
static from(buffer$1) {
|
|
4820
4850
|
// Slice up wire data
|
|
4821
4851
|
let byteArray = [...buffer$1];
|
|
4822
|
-
const numRequiredSignatures = byteArray
|
|
4823
|
-
const numReadonlySignedAccounts = byteArray
|
|
4824
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
4852
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
4853
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
4854
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
4825
4855
|
const accountCount = decodeLength(byteArray);
|
|
4826
4856
|
let accountKeys = [];
|
|
4827
4857
|
|
|
4828
4858
|
for (let i = 0; i < accountCount; i++) {
|
|
4829
|
-
const account = byteArray
|
|
4830
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
4859
|
+
const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
4831
4860
|
accountKeys.push(bs58.encode(buffer.Buffer.from(account)));
|
|
4832
4861
|
}
|
|
4833
4862
|
|
|
4834
|
-
const recentBlockhash = byteArray
|
|
4835
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
4863
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
4836
4864
|
const instructionCount = decodeLength(byteArray);
|
|
4837
4865
|
let instructions = [];
|
|
4838
4866
|
|
|
4839
4867
|
for (let i = 0; i < instructionCount; i++) {
|
|
4840
|
-
const programIdIndex = byteArray
|
|
4868
|
+
const programIdIndex = guardedShift(byteArray);
|
|
4841
4869
|
const accountCount = decodeLength(byteArray);
|
|
4842
|
-
const accounts = byteArray
|
|
4843
|
-
byteArray = byteArray.slice(accountCount);
|
|
4870
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
4844
4871
|
const dataLength = decodeLength(byteArray);
|
|
4845
|
-
const dataSlice = byteArray
|
|
4872
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
4846
4873
|
const data = bs58.encode(buffer.Buffer.from(dataSlice));
|
|
4847
|
-
byteArray = byteArray.slice(dataLength);
|
|
4848
4874
|
instructions.push({
|
|
4849
4875
|
programIdIndex,
|
|
4850
4876
|
accounts,
|
|
@@ -5469,8 +5495,7 @@ class Transaction {
|
|
|
5469
5495
|
let signatures = [];
|
|
5470
5496
|
|
|
5471
5497
|
for (let i = 0; i < signatureCount; i++) {
|
|
5472
|
-
const signature = byteArray
|
|
5473
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH);
|
|
5498
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH);
|
|
5474
5499
|
signatures.push(bs58.encode(buffer.Buffer.from(signature)));
|
|
5475
5500
|
}
|
|
5476
5501
|
|
|
@@ -11244,10 +11269,8 @@ class ValidatorInfo {
|
|
|
11244
11269
|
const configKeys = [];
|
|
11245
11270
|
|
|
11246
11271
|
for (let i = 0; i < 2; i++) {
|
|
11247
|
-
const publicKey = new PublicKey(byteArray
|
|
11248
|
-
|
|
11249
|
-
const isSigner = byteArray.slice(0, 1)[0] === 1;
|
|
11250
|
-
byteArray = byteArray.slice(1);
|
|
11272
|
+
const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
|
|
11273
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
11251
11274
|
configKeys.push({
|
|
11252
11275
|
publicKey,
|
|
11253
11276
|
isSigner
|