@solana/web3.js 1.41.10 → 1.41.11

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
@@ -13876,6 +13876,36 @@ var solanaWeb3 = (function (exports) {
13876
13876
  }
13877
13877
  }
13878
13878
 
13879
+ const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
13880
+ /**
13881
+ * Delegates to `Array#shift`, but throws if the array is zero-length.
13882
+ */
13883
+
13884
+ function guardedShift(byteArray) {
13885
+ if (byteArray.length === 0) {
13886
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
13887
+ }
13888
+
13889
+ return byteArray.shift();
13890
+ }
13891
+ /**
13892
+ * Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
13893
+ * the array.
13894
+ */
13895
+
13896
+ function guardedSplice(byteArray, ...args) {
13897
+ var _args$;
13898
+
13899
+ const [start] = args;
13900
+
13901
+ if (args.length === 2 // Implies that `deleteCount` was supplied
13902
+ ? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
13903
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
13904
+ }
13905
+
13906
+ return byteArray.splice(...args);
13907
+ }
13908
+
13879
13909
  /**
13880
13910
  * The message header, identifying signed and read-only account
13881
13911
  */
@@ -13974,32 +14004,28 @@ var solanaWeb3 = (function (exports) {
13974
14004
  static from(buffer$1) {
13975
14005
  // Slice up wire data
13976
14006
  let byteArray = [...buffer$1];
13977
- const numRequiredSignatures = byteArray.shift();
13978
- const numReadonlySignedAccounts = byteArray.shift();
13979
- const numReadonlyUnsignedAccounts = byteArray.shift();
14007
+ const numRequiredSignatures = guardedShift(byteArray);
14008
+ const numReadonlySignedAccounts = guardedShift(byteArray);
14009
+ const numReadonlyUnsignedAccounts = guardedShift(byteArray);
13980
14010
  const accountCount = decodeLength(byteArray);
13981
14011
  let accountKeys = [];
13982
14012
 
13983
14013
  for (let i = 0; i < accountCount; i++) {
13984
- const account = byteArray.slice(0, PUBKEY_LENGTH);
13985
- byteArray = byteArray.slice(PUBKEY_LENGTH);
14014
+ const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
13986
14015
  accountKeys.push(bs58$1.encode(buffer.Buffer.from(account)));
13987
14016
  }
13988
14017
 
13989
- const recentBlockhash = byteArray.slice(0, PUBKEY_LENGTH);
13990
- byteArray = byteArray.slice(PUBKEY_LENGTH);
14018
+ const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
13991
14019
  const instructionCount = decodeLength(byteArray);
13992
14020
  let instructions = [];
13993
14021
 
13994
14022
  for (let i = 0; i < instructionCount; i++) {
13995
- const programIdIndex = byteArray.shift();
14023
+ const programIdIndex = guardedShift(byteArray);
13996
14024
  const accountCount = decodeLength(byteArray);
13997
- const accounts = byteArray.slice(0, accountCount);
13998
- byteArray = byteArray.slice(accountCount);
14025
+ const accounts = guardedSplice(byteArray, 0, accountCount);
13999
14026
  const dataLength = decodeLength(byteArray);
14000
- const dataSlice = byteArray.slice(0, dataLength);
14027
+ const dataSlice = guardedSplice(byteArray, 0, dataLength);
14001
14028
  const data = bs58$1.encode(buffer.Buffer.from(dataSlice));
14002
- byteArray = byteArray.slice(dataLength);
14003
14029
  instructions.push({
14004
14030
  programIdIndex,
14005
14031
  accounts,
@@ -14028,6 +14054,10 @@ var solanaWeb3 = (function (exports) {
14028
14054
  }
14029
14055
  }
14030
14056
 
14057
+ /**
14058
+ * Transaction signature as base-58 encoded string
14059
+ */
14060
+
14031
14061
  exports.TransactionStatus = void 0;
14032
14062
  /**
14033
14063
  * Default (empty) signature
@@ -14678,8 +14708,7 @@ var solanaWeb3 = (function (exports) {
14678
14708
  let signatures = [];
14679
14709
 
14680
14710
  for (let i = 0; i < signatureCount; i++) {
14681
- const signature = byteArray.slice(0, SIGNATURE_LENGTH_IN_BYTES);
14682
- byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
14711
+ const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
14683
14712
  signatures.push(bs58$1.encode(buffer.Buffer.from(signature)));
14684
14713
  }
14685
14714
 
@@ -29688,10 +29717,8 @@ var solanaWeb3 = (function (exports) {
29688
29717
  const configKeys = [];
29689
29718
 
29690
29719
  for (let i = 0; i < 2; i++) {
29691
- const publicKey = new PublicKey(byteArray.slice(0, PUBKEY_LENGTH));
29692
- byteArray = byteArray.slice(PUBKEY_LENGTH);
29693
- const isSigner = byteArray.slice(0, 1)[0] === 1;
29694
- byteArray = byteArray.slice(1);
29720
+ const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
29721
+ const isSigner = guardedShift(byteArray) === 1;
29695
29722
  configKeys.push({
29696
29723
  publicKey,
29697
29724
  isSigner