@solana/web3.js 1.5.0 → 1.5.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
 
@@ -20587,9 +20612,6 @@ var solanaWeb3 = (function (exports) {
20587
20612
  "minimalistic-assert": "^1.0.1",
20588
20613
  "minimalistic-crypto-utils": "^1.0.1"
20589
20614
  };
20590
- var _resolved = "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz";
20591
- var _integrity = "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==";
20592
- var _from = "elliptic@6.5.4";
20593
20615
  var require$$0 = {
20594
20616
  name: name,
20595
20617
  version: version,
@@ -20604,10 +20626,7 @@ var solanaWeb3 = (function (exports) {
20604
20626
  bugs: bugs,
20605
20627
  homepage: homepage,
20606
20628
  devDependencies: devDependencies,
20607
- dependencies: dependencies,
20608
- _resolved: _resolved,
20609
- _integrity: _integrity,
20610
- _from: _from
20629
+ dependencies: dependencies
20611
20630
  };
20612
20631
 
20613
20632
  var minimalisticAssert = assert$9;
@@ -27213,10 +27232,8 @@ var solanaWeb3 = (function (exports) {
27213
27232
  const configKeys = [];
27214
27233
 
27215
27234
  for (let i = 0; i < 2; i++) {
27216
- const publicKey = new PublicKey(byteArray.slice(0, PUBKEY_LENGTH));
27217
- byteArray = byteArray.slice(PUBKEY_LENGTH);
27218
- const isSigner = byteArray.slice(0, 1)[0] === 1;
27219
- byteArray = byteArray.slice(1);
27235
+ const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
27236
+ const isSigner = guardedShift(byteArray) === 1;
27220
27237
  configKeys.push({
27221
27238
  publicKey,
27222
27239
  isSigner