@solana/web3.js 1.1.1 → 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.iife.js CHANGED
@@ -10766,6 +10766,36 @@ var solanaWeb3 = (function (exports) {
10766
10766
  }
10767
10767
  }
10768
10768
 
10769
+ const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
10770
+ /**
10771
+ * Delegates to `Array#shift`, but throws if the array is zero-length.
10772
+ */
10773
+
10774
+ function guardedShift(byteArray) {
10775
+ if (byteArray.length === 0) {
10776
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
10777
+ }
10778
+
10779
+ return byteArray.shift();
10780
+ }
10781
+ /**
10782
+ * Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
10783
+ * the array.
10784
+ */
10785
+
10786
+ function guardedSplice(byteArray, ...args) {
10787
+ var _args$;
10788
+
10789
+ const [start] = args;
10790
+
10791
+ if (args.length === 2 // Implies that `deleteCount` was supplied
10792
+ ? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
10793
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
10794
+ }
10795
+
10796
+ return byteArray.splice(...args);
10797
+ }
10798
+
10769
10799
  /**
10770
10800
  * The message header, identifying signed and read-only account
10771
10801
  *
@@ -10856,32 +10886,28 @@ var solanaWeb3 = (function (exports) {
10856
10886
  static from(buffer$1) {
10857
10887
  // Slice up wire data
10858
10888
  let byteArray = [...buffer$1];
10859
- const numRequiredSignatures = byteArray.shift();
10860
- const numReadonlySignedAccounts = byteArray.shift();
10861
- const numReadonlyUnsignedAccounts = byteArray.shift();
10889
+ const numRequiredSignatures = guardedShift(byteArray);
10890
+ const numReadonlySignedAccounts = guardedShift(byteArray);
10891
+ const numReadonlyUnsignedAccounts = guardedShift(byteArray);
10862
10892
  const accountCount = decodeLength(byteArray);
10863
10893
  let accountKeys = [];
10864
10894
 
10865
10895
  for (let i = 0; i < accountCount; i++) {
10866
- const account = byteArray.slice(0, PUBKEY_LENGTH);
10867
- byteArray = byteArray.slice(PUBKEY_LENGTH);
10896
+ const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
10868
10897
  accountKeys.push(bs58.encode(buffer.Buffer.from(account)));
10869
10898
  }
10870
10899
 
10871
- const recentBlockhash = byteArray.slice(0, PUBKEY_LENGTH);
10872
- byteArray = byteArray.slice(PUBKEY_LENGTH);
10900
+ const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
10873
10901
  const instructionCount = decodeLength(byteArray);
10874
10902
  let instructions = [];
10875
10903
 
10876
10904
  for (let i = 0; i < instructionCount; i++) {
10877
- const programIdIndex = byteArray.shift();
10905
+ const programIdIndex = guardedShift(byteArray);
10878
10906
  const accountCount = decodeLength(byteArray);
10879
- const accounts = byteArray.slice(0, accountCount);
10880
- byteArray = byteArray.slice(accountCount);
10907
+ const accounts = guardedSplice(byteArray, 0, accountCount);
10881
10908
  const dataLength = decodeLength(byteArray);
10882
- const dataSlice = byteArray.slice(0, dataLength);
10909
+ const dataSlice = guardedSplice(byteArray, 0, dataLength);
10883
10910
  const data = bs58.encode(buffer.Buffer.from(dataSlice));
10884
- byteArray = byteArray.slice(dataLength);
10885
10911
  instructions.push({
10886
10912
  programIdIndex,
10887
10913
  accounts,
@@ -11506,8 +11532,7 @@ var solanaWeb3 = (function (exports) {
11506
11532
  let signatures = [];
11507
11533
 
11508
11534
  for (let i = 0; i < signatureCount; i++) {
11509
- const signature = byteArray.slice(0, SIGNATURE_LENGTH);
11510
- byteArray = byteArray.slice(SIGNATURE_LENGTH);
11535
+ const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH);
11511
11536
  signatures.push(bs58.encode(buffer.Buffer.from(signature)));
11512
11537
  }
11513
11538
 
@@ -20521,9 +20546,6 @@ var solanaWeb3 = (function (exports) {
20521
20546
  "minimalistic-assert": "^1.0.1",
20522
20547
  "minimalistic-crypto-utils": "^1.0.1"
20523
20548
  };
20524
- var _resolved = "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz";
20525
- var _integrity = "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==";
20526
- var _from = "elliptic@6.5.4";
20527
20549
  var require$$0 = {
20528
20550
  name: name,
20529
20551
  version: version,
@@ -20538,10 +20560,7 @@ var solanaWeb3 = (function (exports) {
20538
20560
  bugs: bugs,
20539
20561
  homepage: homepage,
20540
20562
  devDependencies: devDependencies,
20541
- dependencies: dependencies,
20542
- _resolved: _resolved,
20543
- _integrity: _integrity,
20544
- _from: _from
20563
+ dependencies: dependencies
20545
20564
  };
20546
20565
 
20547
20566
  var minimalisticAssert = assert$9;
@@ -27161,10 +27180,8 @@ var solanaWeb3 = (function (exports) {
27161
27180
  const configKeys = [];
27162
27181
 
27163
27182
  for (let i = 0; i < 2; i++) {
27164
- const publicKey = new PublicKey(byteArray.slice(0, PUBKEY_LENGTH));
27165
- byteArray = byteArray.slice(PUBKEY_LENGTH);
27166
- const isSigner = byteArray.slice(0, 1)[0] === 1;
27167
- byteArray = byteArray.slice(1);
27183
+ const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
27184
+ const isSigner = guardedShift(byteArray) === 1;
27168
27185
  configKeys.push({
27169
27186
  publicKey,
27170
27187
  isSigner