@solana/web3.js 1.44.3 → 1.44.4

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
@@ -13878,6 +13878,36 @@ var solanaWeb3 = (function (exports) {
13878
13878
  }
13879
13879
  }
13880
13880
 
13881
+ const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
13882
+ /**
13883
+ * Delegates to `Array#shift`, but throws if the array is zero-length.
13884
+ */
13885
+
13886
+ function guardedShift(byteArray) {
13887
+ if (byteArray.length === 0) {
13888
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
13889
+ }
13890
+
13891
+ return byteArray.shift();
13892
+ }
13893
+ /**
13894
+ * Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
13895
+ * the array.
13896
+ */
13897
+
13898
+ function guardedSplice(byteArray, ...args) {
13899
+ var _args$;
13900
+
13901
+ const [start] = args;
13902
+
13903
+ if (args.length === 2 // Implies that `deleteCount` was supplied
13904
+ ? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
13905
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
13906
+ }
13907
+
13908
+ return byteArray.splice(...args);
13909
+ }
13910
+
13881
13911
  /**
13882
13912
  * The message header, identifying signed and read-only account
13883
13913
  */
@@ -13976,32 +14006,28 @@ var solanaWeb3 = (function (exports) {
13976
14006
  static from(buffer$1) {
13977
14007
  // Slice up wire data
13978
14008
  let byteArray = [...buffer$1];
13979
- const numRequiredSignatures = byteArray.shift();
13980
- const numReadonlySignedAccounts = byteArray.shift();
13981
- const numReadonlyUnsignedAccounts = byteArray.shift();
14009
+ const numRequiredSignatures = guardedShift(byteArray);
14010
+ const numReadonlySignedAccounts = guardedShift(byteArray);
14011
+ const numReadonlyUnsignedAccounts = guardedShift(byteArray);
13982
14012
  const accountCount = decodeLength(byteArray);
13983
14013
  let accountKeys = [];
13984
14014
 
13985
14015
  for (let i = 0; i < accountCount; i++) {
13986
- const account = byteArray.slice(0, PUBKEY_LENGTH);
13987
- byteArray = byteArray.slice(PUBKEY_LENGTH);
14016
+ const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
13988
14017
  accountKeys.push(bs58$1.encode(buffer.Buffer.from(account)));
13989
14018
  }
13990
14019
 
13991
- const recentBlockhash = byteArray.slice(0, PUBKEY_LENGTH);
13992
- byteArray = byteArray.slice(PUBKEY_LENGTH);
14020
+ const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
13993
14021
  const instructionCount = decodeLength(byteArray);
13994
14022
  let instructions = [];
13995
14023
 
13996
14024
  for (let i = 0; i < instructionCount; i++) {
13997
- const programIdIndex = byteArray.shift();
14025
+ const programIdIndex = guardedShift(byteArray);
13998
14026
  const accountCount = decodeLength(byteArray);
13999
- const accounts = byteArray.slice(0, accountCount);
14000
- byteArray = byteArray.slice(accountCount);
14027
+ const accounts = guardedSplice(byteArray, 0, accountCount);
14001
14028
  const dataLength = decodeLength(byteArray);
14002
- const dataSlice = byteArray.slice(0, dataLength);
14029
+ const dataSlice = guardedSplice(byteArray, 0, dataLength);
14003
14030
  const data = bs58$1.encode(buffer.Buffer.from(dataSlice));
14004
- byteArray = byteArray.slice(dataLength);
14005
14031
  instructions.push({
14006
14032
  programIdIndex,
14007
14033
  accounts,
@@ -14030,6 +14056,10 @@ var solanaWeb3 = (function (exports) {
14030
14056
  }
14031
14057
  }
14032
14058
 
14059
+ /**
14060
+ * Transaction signature as base-58 encoded string
14061
+ */
14062
+
14033
14063
  exports.TransactionStatus = void 0;
14034
14064
  /**
14035
14065
  * Default (empty) signature
@@ -14690,8 +14720,7 @@ var solanaWeb3 = (function (exports) {
14690
14720
  let signatures = [];
14691
14721
 
14692
14722
  for (let i = 0; i < signatureCount; i++) {
14693
- const signature = byteArray.slice(0, SIGNATURE_LENGTH_IN_BYTES);
14694
- byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
14723
+ const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
14695
14724
  signatures.push(bs58$1.encode(buffer.Buffer.from(signature)));
14696
14725
  }
14697
14726
 
@@ -29709,10 +29738,8 @@ var solanaWeb3 = (function (exports) {
29709
29738
  const configKeys = [];
29710
29739
 
29711
29740
  for (let i = 0; i < 2; i++) {
29712
- const publicKey = new PublicKey(byteArray.slice(0, PUBKEY_LENGTH));
29713
- byteArray = byteArray.slice(PUBKEY_LENGTH);
29714
- const isSigner = byteArray.slice(0, 1)[0] === 1;
29715
- byteArray = byteArray.slice(1);
29741
+ const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
29742
+ const isSigner = guardedShift(byteArray) === 1;
29716
29743
  configKeys.push({
29717
29744
  publicKey,
29718
29745
  isSigner