@solana/web3.js 1.39.1 → 1.39.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
@@ -13845,6 +13845,36 @@ var solanaWeb3 = (function (exports) {
13845
13845
  }
13846
13846
  }
13847
13847
 
13848
+ const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
13849
+ /**
13850
+ * Delegates to `Array#shift`, but throws if the array is zero-length.
13851
+ */
13852
+
13853
+ function guardedShift(byteArray) {
13854
+ if (byteArray.length === 0) {
13855
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
13856
+ }
13857
+
13858
+ return byteArray.shift();
13859
+ }
13860
+ /**
13861
+ * Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
13862
+ * the array.
13863
+ */
13864
+
13865
+ function guardedSplice(byteArray, ...args) {
13866
+ var _args$;
13867
+
13868
+ const [start] = args;
13869
+
13870
+ if (args.length === 2 // Implies that `deleteCount` was supplied
13871
+ ? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
13872
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
13873
+ }
13874
+
13875
+ return byteArray.splice(...args);
13876
+ }
13877
+
13848
13878
  /**
13849
13879
  * The message header, identifying signed and read-only account
13850
13880
  */
@@ -13943,32 +13973,28 @@ var solanaWeb3 = (function (exports) {
13943
13973
  static from(buffer$1) {
13944
13974
  // Slice up wire data
13945
13975
  let byteArray = [...buffer$1];
13946
- const numRequiredSignatures = byteArray.shift();
13947
- const numReadonlySignedAccounts = byteArray.shift();
13948
- const numReadonlyUnsignedAccounts = byteArray.shift();
13976
+ const numRequiredSignatures = guardedShift(byteArray);
13977
+ const numReadonlySignedAccounts = guardedShift(byteArray);
13978
+ const numReadonlyUnsignedAccounts = guardedShift(byteArray);
13949
13979
  const accountCount = decodeLength(byteArray);
13950
13980
  let accountKeys = [];
13951
13981
 
13952
13982
  for (let i = 0; i < accountCount; i++) {
13953
- const account = byteArray.slice(0, PUBKEY_LENGTH);
13954
- byteArray = byteArray.slice(PUBKEY_LENGTH);
13983
+ const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
13955
13984
  accountKeys.push(bs58$1.encode(buffer.Buffer.from(account)));
13956
13985
  }
13957
13986
 
13958
- const recentBlockhash = byteArray.slice(0, PUBKEY_LENGTH);
13959
- byteArray = byteArray.slice(PUBKEY_LENGTH);
13987
+ const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
13960
13988
  const instructionCount = decodeLength(byteArray);
13961
13989
  let instructions = [];
13962
13990
 
13963
13991
  for (let i = 0; i < instructionCount; i++) {
13964
- const programIdIndex = byteArray.shift();
13992
+ const programIdIndex = guardedShift(byteArray);
13965
13993
  const accountCount = decodeLength(byteArray);
13966
- const accounts = byteArray.slice(0, accountCount);
13967
- byteArray = byteArray.slice(accountCount);
13994
+ const accounts = guardedSplice(byteArray, 0, accountCount);
13968
13995
  const dataLength = decodeLength(byteArray);
13969
- const dataSlice = byteArray.slice(0, dataLength);
13996
+ const dataSlice = guardedSplice(byteArray, 0, dataLength);
13970
13997
  const data = bs58$1.encode(buffer.Buffer.from(dataSlice));
13971
- byteArray = byteArray.slice(dataLength);
13972
13998
  instructions.push({
13973
13999
  programIdIndex,
13974
14000
  accounts,
@@ -13997,6 +14023,10 @@ var solanaWeb3 = (function (exports) {
13997
14023
  }
13998
14024
  }
13999
14025
 
14026
+ /**
14027
+ * Transaction signature as base-58 encoded string
14028
+ */
14029
+
14000
14030
  /**
14001
14031
  * Default (empty) signature
14002
14032
  *
@@ -14644,8 +14674,7 @@ var solanaWeb3 = (function (exports) {
14644
14674
  let signatures = [];
14645
14675
 
14646
14676
  for (let i = 0; i < signatureCount; i++) {
14647
- const signature = byteArray.slice(0, SIGNATURE_LENGTH);
14648
- byteArray = byteArray.slice(SIGNATURE_LENGTH);
14677
+ const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH);
14649
14678
  signatures.push(bs58$1.encode(buffer.Buffer.from(signature)));
14650
14679
  }
14651
14680
 
@@ -29410,10 +29439,8 @@ var solanaWeb3 = (function (exports) {
29410
29439
  const configKeys = [];
29411
29440
 
29412
29441
  for (let i = 0; i < 2; i++) {
29413
- const publicKey = new PublicKey(byteArray.slice(0, PUBKEY_LENGTH));
29414
- byteArray = byteArray.slice(PUBKEY_LENGTH);
29415
- const isSigner = byteArray.slice(0, 1)[0] === 1;
29416
- byteArray = byteArray.slice(1);
29442
+ const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
29443
+ const isSigner = guardedShift(byteArray) === 1;
29417
29444
  configKeys.push({
29418
29445
  publicKey,
29419
29446
  isSigner