@solana/web3.js 1.4.0 → 1.4.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
 
@@ -20561,9 +20586,6 @@ var solanaWeb3 = (function (exports) {
20561
20586
  "minimalistic-assert": "^1.0.1",
20562
20587
  "minimalistic-crypto-utils": "^1.0.1"
20563
20588
  };
20564
- var _resolved = "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz";
20565
- var _integrity = "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==";
20566
- var _from = "elliptic@6.5.4";
20567
20589
  var require$$0 = {
20568
20590
  name: name,
20569
20591
  version: version,
@@ -20578,10 +20600,7 @@ var solanaWeb3 = (function (exports) {
20578
20600
  bugs: bugs,
20579
20601
  homepage: homepage,
20580
20602
  devDependencies: devDependencies,
20581
- dependencies: dependencies,
20582
- _resolved: _resolved,
20583
- _integrity: _integrity,
20584
- _from: _from
20603
+ dependencies: dependencies
20585
20604
  };
20586
20605
 
20587
20606
  var minimalisticAssert = assert$9;
@@ -27187,10 +27206,8 @@ var solanaWeb3 = (function (exports) {
27187
27206
  const configKeys = [];
27188
27207
 
27189
27208
  for (let i = 0; i < 2; i++) {
27190
- const publicKey = new PublicKey(byteArray.slice(0, PUBKEY_LENGTH));
27191
- byteArray = byteArray.slice(PUBKEY_LENGTH);
27192
- const isSigner = byteArray.slice(0, 1)[0] === 1;
27193
- byteArray = byteArray.slice(1);
27209
+ const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
27210
+ const isSigner = guardedShift(byteArray) === 1;
27194
27211
  configKeys.push({
27195
27212
  publicKey,
27196
27213
  isSigner