@solana/web3.js 1.7.1 → 1.7.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.iife.js CHANGED
@@ -10787,6 +10787,36 @@ var solanaWeb3 = (function (exports) {
10787
10787
  }
10788
10788
  }
10789
10789
 
10790
+ const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
10791
+ /**
10792
+ * Delegates to `Array#shift`, but throws if the array is zero-length.
10793
+ */
10794
+
10795
+ function guardedShift(byteArray) {
10796
+ if (byteArray.length === 0) {
10797
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
10798
+ }
10799
+
10800
+ return byteArray.shift();
10801
+ }
10802
+ /**
10803
+ * Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
10804
+ * the array.
10805
+ */
10806
+
10807
+ function guardedSplice(byteArray, ...args) {
10808
+ var _args$;
10809
+
10810
+ const [start] = args;
10811
+
10812
+ if (args.length === 2 // Implies that `deleteCount` was supplied
10813
+ ? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
10814
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
10815
+ }
10816
+
10817
+ return byteArray.splice(...args);
10818
+ }
10819
+
10790
10820
  /**
10791
10821
  * The message header, identifying signed and read-only account
10792
10822
  */
@@ -10871,32 +10901,28 @@ var solanaWeb3 = (function (exports) {
10871
10901
  static from(buffer$1) {
10872
10902
  // Slice up wire data
10873
10903
  let byteArray = [...buffer$1];
10874
- const numRequiredSignatures = byteArray.shift();
10875
- const numReadonlySignedAccounts = byteArray.shift();
10876
- const numReadonlyUnsignedAccounts = byteArray.shift();
10904
+ const numRequiredSignatures = guardedShift(byteArray);
10905
+ const numReadonlySignedAccounts = guardedShift(byteArray);
10906
+ const numReadonlyUnsignedAccounts = guardedShift(byteArray);
10877
10907
  const accountCount = decodeLength(byteArray);
10878
10908
  let accountKeys = [];
10879
10909
 
10880
10910
  for (let i = 0; i < accountCount; i++) {
10881
- const account = byteArray.slice(0, PUBKEY_LENGTH);
10882
- byteArray = byteArray.slice(PUBKEY_LENGTH);
10911
+ const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
10883
10912
  accountKeys.push(bs58.encode(buffer.Buffer.from(account)));
10884
10913
  }
10885
10914
 
10886
- const recentBlockhash = byteArray.slice(0, PUBKEY_LENGTH);
10887
- byteArray = byteArray.slice(PUBKEY_LENGTH);
10915
+ const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
10888
10916
  const instructionCount = decodeLength(byteArray);
10889
10917
  let instructions = [];
10890
10918
 
10891
10919
  for (let i = 0; i < instructionCount; i++) {
10892
- const programIdIndex = byteArray.shift();
10920
+ const programIdIndex = guardedShift(byteArray);
10893
10921
  const accountCount = decodeLength(byteArray);
10894
- const accounts = byteArray.slice(0, accountCount);
10895
- byteArray = byteArray.slice(accountCount);
10922
+ const accounts = guardedSplice(byteArray, 0, accountCount);
10896
10923
  const dataLength = decodeLength(byteArray);
10897
- const dataSlice = byteArray.slice(0, dataLength);
10924
+ const dataSlice = guardedSplice(byteArray, 0, dataLength);
10898
10925
  const data = bs58.encode(buffer.Buffer.from(dataSlice));
10899
- byteArray = byteArray.slice(dataLength);
10900
10926
  instructions.push({
10901
10927
  programIdIndex,
10902
10928
  accounts,
@@ -11516,8 +11542,7 @@ var solanaWeb3 = (function (exports) {
11516
11542
  let signatures = [];
11517
11543
 
11518
11544
  for (let i = 0; i < signatureCount; i++) {
11519
- const signature = byteArray.slice(0, SIGNATURE_LENGTH);
11520
- byteArray = byteArray.slice(SIGNATURE_LENGTH);
11545
+ const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH);
11521
11546
  signatures.push(bs58.encode(buffer.Buffer.from(signature)));
11522
11547
  }
11523
11548
 
@@ -20677,9 +20702,6 @@ var solanaWeb3 = (function (exports) {
20677
20702
  "minimalistic-assert": "^1.0.1",
20678
20703
  "minimalistic-crypto-utils": "^1.0.1"
20679
20704
  };
20680
- var _resolved = "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz";
20681
- var _integrity = "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==";
20682
- var _from = "elliptic@6.5.4";
20683
20705
  var require$$0 = {
20684
20706
  name: name,
20685
20707
  version: version,
@@ -20694,10 +20716,7 @@ var solanaWeb3 = (function (exports) {
20694
20716
  bugs: bugs,
20695
20717
  homepage: homepage,
20696
20718
  devDependencies: devDependencies,
20697
- dependencies: dependencies,
20698
- _resolved: _resolved,
20699
- _integrity: _integrity,
20700
- _from: _from
20719
+ dependencies: dependencies
20701
20720
  };
20702
20721
 
20703
20722
  var minimalisticAssert = assert$9;
@@ -27303,10 +27322,8 @@ var solanaWeb3 = (function (exports) {
27303
27322
  const configKeys = [];
27304
27323
 
27305
27324
  for (let i = 0; i < 2; i++) {
27306
- const publicKey = new PublicKey(byteArray.slice(0, PUBKEY_LENGTH));
27307
- byteArray = byteArray.slice(PUBKEY_LENGTH);
27308
- const isSigner = byteArray.slice(0, 1)[0] === 1;
27309
- byteArray = byteArray.slice(1);
27325
+ const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
27326
+ const isSigner = guardedShift(byteArray) === 1;
27310
27327
  configKeys.push({
27311
27328
  publicKey,
27312
27329
  isSigner