@solana/web3.js 1.6.0 → 1.6.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.iife.js CHANGED
@@ -10774,6 +10774,36 @@ var solanaWeb3 = (function (exports) {
10774
10774
  }
10775
10775
  }
10776
10776
 
10777
+ const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
10778
+ /**
10779
+ * Delegates to `Array#shift`, but throws if the array is zero-length.
10780
+ */
10781
+
10782
+ function guardedShift(byteArray) {
10783
+ if (byteArray.length === 0) {
10784
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
10785
+ }
10786
+
10787
+ return byteArray.shift();
10788
+ }
10789
+ /**
10790
+ * Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
10791
+ * the array.
10792
+ */
10793
+
10794
+ function guardedSplice(byteArray, ...args) {
10795
+ var _args$;
10796
+
10797
+ const [start] = args;
10798
+
10799
+ if (args.length === 2 // Implies that `deleteCount` was supplied
10800
+ ? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
10801
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
10802
+ }
10803
+
10804
+ return byteArray.splice(...args);
10805
+ }
10806
+
10777
10807
  /**
10778
10808
  * The message header, identifying signed and read-only account
10779
10809
  */
@@ -10858,32 +10888,28 @@ var solanaWeb3 = (function (exports) {
10858
10888
  static from(buffer$1) {
10859
10889
  // Slice up wire data
10860
10890
  let byteArray = [...buffer$1];
10861
- const numRequiredSignatures = byteArray.shift();
10862
- const numReadonlySignedAccounts = byteArray.shift();
10863
- const numReadonlyUnsignedAccounts = byteArray.shift();
10891
+ const numRequiredSignatures = guardedShift(byteArray);
10892
+ const numReadonlySignedAccounts = guardedShift(byteArray);
10893
+ const numReadonlyUnsignedAccounts = guardedShift(byteArray);
10864
10894
  const accountCount = decodeLength(byteArray);
10865
10895
  let accountKeys = [];
10866
10896
 
10867
10897
  for (let i = 0; i < accountCount; i++) {
10868
- const account = byteArray.slice(0, PUBKEY_LENGTH);
10869
- byteArray = byteArray.slice(PUBKEY_LENGTH);
10898
+ const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
10870
10899
  accountKeys.push(bs58.encode(buffer.Buffer.from(account)));
10871
10900
  }
10872
10901
 
10873
- const recentBlockhash = byteArray.slice(0, PUBKEY_LENGTH);
10874
- byteArray = byteArray.slice(PUBKEY_LENGTH);
10902
+ const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
10875
10903
  const instructionCount = decodeLength(byteArray);
10876
10904
  let instructions = [];
10877
10905
 
10878
10906
  for (let i = 0; i < instructionCount; i++) {
10879
- const programIdIndex = byteArray.shift();
10907
+ const programIdIndex = guardedShift(byteArray);
10880
10908
  const accountCount = decodeLength(byteArray);
10881
- const accounts = byteArray.slice(0, accountCount);
10882
- byteArray = byteArray.slice(accountCount);
10909
+ const accounts = guardedSplice(byteArray, 0, accountCount);
10883
10910
  const dataLength = decodeLength(byteArray);
10884
- const dataSlice = byteArray.slice(0, dataLength);
10911
+ const dataSlice = guardedSplice(byteArray, 0, dataLength);
10885
10912
  const data = bs58.encode(buffer.Buffer.from(dataSlice));
10886
- byteArray = byteArray.slice(dataLength);
10887
10913
  instructions.push({
10888
10914
  programIdIndex,
10889
10915
  accounts,
@@ -11503,8 +11529,7 @@ var solanaWeb3 = (function (exports) {
11503
11529
  let signatures = [];
11504
11530
 
11505
11531
  for (let i = 0; i < signatureCount; i++) {
11506
- const signature = byteArray.slice(0, SIGNATURE_LENGTH);
11507
- byteArray = byteArray.slice(SIGNATURE_LENGTH);
11532
+ const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH);
11508
11533
  signatures.push(bs58.encode(buffer.Buffer.from(signature)));
11509
11534
  }
11510
11535
 
@@ -20617,9 +20642,6 @@ var solanaWeb3 = (function (exports) {
20617
20642
  "minimalistic-assert": "^1.0.1",
20618
20643
  "minimalistic-crypto-utils": "^1.0.1"
20619
20644
  };
20620
- var _resolved = "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz";
20621
- var _integrity = "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==";
20622
- var _from = "elliptic@6.5.4";
20623
20645
  var require$$0 = {
20624
20646
  name: name,
20625
20647
  version: version,
@@ -20634,10 +20656,7 @@ var solanaWeb3 = (function (exports) {
20634
20656
  bugs: bugs,
20635
20657
  homepage: homepage,
20636
20658
  devDependencies: devDependencies,
20637
- dependencies: dependencies,
20638
- _resolved: _resolved,
20639
- _integrity: _integrity,
20640
- _from: _from
20659
+ dependencies: dependencies
20641
20660
  };
20642
20661
 
20643
20662
  var minimalisticAssert = assert$9;
@@ -27243,10 +27262,8 @@ var solanaWeb3 = (function (exports) {
27243
27262
  const configKeys = [];
27244
27263
 
27245
27264
  for (let i = 0; i < 2; i++) {
27246
- const publicKey = new PublicKey(byteArray.slice(0, PUBKEY_LENGTH));
27247
- byteArray = byteArray.slice(PUBKEY_LENGTH);
27248
- const isSigner = byteArray.slice(0, 1)[0] === 1;
27249
- byteArray = byteArray.slice(1);
27265
+ const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
27266
+ const isSigner = guardedShift(byteArray) === 1;
27250
27267
  configKeys.push({
27251
27268
  publicKey,
27252
27269
  isSigner