@solana/web3.js 1.40.1 → 1.40.2

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
@@ -13866,6 +13866,36 @@ var solanaWeb3 = (function (exports) {
13866
13866
  }
13867
13867
  }
13868
13868
 
13869
+ const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
13870
+ /**
13871
+ * Delegates to `Array#shift`, but throws if the array is zero-length.
13872
+ */
13873
+
13874
+ function guardedShift(byteArray) {
13875
+ if (byteArray.length === 0) {
13876
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
13877
+ }
13878
+
13879
+ return byteArray.shift();
13880
+ }
13881
+ /**
13882
+ * Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
13883
+ * the array.
13884
+ */
13885
+
13886
+ function guardedSplice(byteArray, ...args) {
13887
+ var _args$;
13888
+
13889
+ const [start] = args;
13890
+
13891
+ if (args.length === 2 // Implies that `deleteCount` was supplied
13892
+ ? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
13893
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
13894
+ }
13895
+
13896
+ return byteArray.splice(...args);
13897
+ }
13898
+
13869
13899
  /**
13870
13900
  * The message header, identifying signed and read-only account
13871
13901
  */
@@ -13964,32 +13994,28 @@ var solanaWeb3 = (function (exports) {
13964
13994
  static from(buffer$1) {
13965
13995
  // Slice up wire data
13966
13996
  let byteArray = [...buffer$1];
13967
- const numRequiredSignatures = byteArray.shift();
13968
- const numReadonlySignedAccounts = byteArray.shift();
13969
- const numReadonlyUnsignedAccounts = byteArray.shift();
13997
+ const numRequiredSignatures = guardedShift(byteArray);
13998
+ const numReadonlySignedAccounts = guardedShift(byteArray);
13999
+ const numReadonlyUnsignedAccounts = guardedShift(byteArray);
13970
14000
  const accountCount = decodeLength(byteArray);
13971
14001
  let accountKeys = [];
13972
14002
 
13973
14003
  for (let i = 0; i < accountCount; i++) {
13974
- const account = byteArray.slice(0, PUBKEY_LENGTH);
13975
- byteArray = byteArray.slice(PUBKEY_LENGTH);
14004
+ const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
13976
14005
  accountKeys.push(bs58$1.encode(buffer.Buffer.from(account)));
13977
14006
  }
13978
14007
 
13979
- const recentBlockhash = byteArray.slice(0, PUBKEY_LENGTH);
13980
- byteArray = byteArray.slice(PUBKEY_LENGTH);
14008
+ const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
13981
14009
  const instructionCount = decodeLength(byteArray);
13982
14010
  let instructions = [];
13983
14011
 
13984
14012
  for (let i = 0; i < instructionCount; i++) {
13985
- const programIdIndex = byteArray.shift();
14013
+ const programIdIndex = guardedShift(byteArray);
13986
14014
  const accountCount = decodeLength(byteArray);
13987
- const accounts = byteArray.slice(0, accountCount);
13988
- byteArray = byteArray.slice(accountCount);
14015
+ const accounts = guardedSplice(byteArray, 0, accountCount);
13989
14016
  const dataLength = decodeLength(byteArray);
13990
- const dataSlice = byteArray.slice(0, dataLength);
14017
+ const dataSlice = guardedSplice(byteArray, 0, dataLength);
13991
14018
  const data = bs58$1.encode(buffer.Buffer.from(dataSlice));
13992
- byteArray = byteArray.slice(dataLength);
13993
14019
  instructions.push({
13994
14020
  programIdIndex,
13995
14021
  accounts,
@@ -14018,6 +14044,10 @@ var solanaWeb3 = (function (exports) {
14018
14044
  }
14019
14045
  }
14020
14046
 
14047
+ /**
14048
+ * Transaction signature as base-58 encoded string
14049
+ */
14050
+
14021
14051
  /**
14022
14052
  * Default (empty) signature
14023
14053
  *
@@ -14663,8 +14693,7 @@ var solanaWeb3 = (function (exports) {
14663
14693
  let signatures = [];
14664
14694
 
14665
14695
  for (let i = 0; i < signatureCount; i++) {
14666
- const signature = byteArray.slice(0, SIGNATURE_LENGTH);
14667
- byteArray = byteArray.slice(SIGNATURE_LENGTH);
14696
+ const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH);
14668
14697
  signatures.push(bs58$1.encode(buffer.Buffer.from(signature)));
14669
14698
  }
14670
14699
 
@@ -29461,10 +29490,8 @@ var solanaWeb3 = (function (exports) {
29461
29490
  const configKeys = [];
29462
29491
 
29463
29492
  for (let i = 0; i < 2; i++) {
29464
- const publicKey = new PublicKey(byteArray.slice(0, PUBKEY_LENGTH));
29465
- byteArray = byteArray.slice(PUBKEY_LENGTH);
29466
- const isSigner = byteArray.slice(0, 1)[0] === 1;
29467
- byteArray = byteArray.slice(1);
29493
+ const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
29494
+ const isSigner = guardedShift(byteArray) === 1;
29468
29495
  configKeys.push({
29469
29496
  publicKey,
29470
29497
  isSigner