@solana/web3.js 1.2.7 → 1.2.8

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
 
@@ -20450,9 +20475,6 @@ var solanaWeb3 = (function (exports) {
20450
20475
  "minimalistic-assert": "^1.0.1",
20451
20476
  "minimalistic-crypto-utils": "^1.0.1"
20452
20477
  };
20453
- var _resolved = "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz";
20454
- var _integrity = "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==";
20455
- var _from = "elliptic@6.5.4";
20456
20478
  var require$$0 = {
20457
20479
  name: name,
20458
20480
  version: version,
@@ -20467,10 +20489,7 @@ var solanaWeb3 = (function (exports) {
20467
20489
  bugs: bugs,
20468
20490
  homepage: homepage,
20469
20491
  devDependencies: devDependencies,
20470
- dependencies: dependencies,
20471
- _resolved: _resolved,
20472
- _integrity: _integrity,
20473
- _from: _from
20492
+ dependencies: dependencies
20474
20493
  };
20475
20494
 
20476
20495
  var minimalisticAssert = assert$9;
@@ -27076,10 +27095,8 @@ var solanaWeb3 = (function (exports) {
27076
27095
  const configKeys = [];
27077
27096
 
27078
27097
  for (let i = 0; i < 2; i++) {
27079
- const publicKey = new PublicKey(byteArray.slice(0, PUBKEY_LENGTH));
27080
- byteArray = byteArray.slice(PUBKEY_LENGTH);
27081
- const isSigner = byteArray.slice(0, 1)[0] === 1;
27082
- byteArray = byteArray.slice(1);
27098
+ const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
27099
+ const isSigner = guardedShift(byteArray) === 1;
27083
27100
  configKeys.push({
27084
27101
  publicKey,
27085
27102
  isSigner