@solana/web3.js 1.21.0 → 1.21.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
@@ -12414,6 +12414,36 @@ var solanaWeb3 = (function (exports) {
12414
12414
  }
12415
12415
  }
12416
12416
 
12417
+ const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
12418
+ /**
12419
+ * Delegates to `Array#shift`, but throws if the array is zero-length.
12420
+ */
12421
+
12422
+ function guardedShift(byteArray) {
12423
+ if (byteArray.length === 0) {
12424
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
12425
+ }
12426
+
12427
+ return byteArray.shift();
12428
+ }
12429
+ /**
12430
+ * Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
12431
+ * the array.
12432
+ */
12433
+
12434
+ function guardedSplice(byteArray, ...args) {
12435
+ var _args$;
12436
+
12437
+ const [start] = args;
12438
+
12439
+ if (args.length === 2 // Implies that `deleteCount` was supplied
12440
+ ? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
12441
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
12442
+ }
12443
+
12444
+ return byteArray.splice(...args);
12445
+ }
12446
+
12417
12447
  /**
12418
12448
  * The message header, identifying signed and read-only account
12419
12449
  */
@@ -12498,32 +12528,28 @@ var solanaWeb3 = (function (exports) {
12498
12528
  static from(buffer$1) {
12499
12529
  // Slice up wire data
12500
12530
  let byteArray = [...buffer$1];
12501
- const numRequiredSignatures = byteArray.shift();
12502
- const numReadonlySignedAccounts = byteArray.shift();
12503
- const numReadonlyUnsignedAccounts = byteArray.shift();
12531
+ const numRequiredSignatures = guardedShift(byteArray);
12532
+ const numReadonlySignedAccounts = guardedShift(byteArray);
12533
+ const numReadonlyUnsignedAccounts = guardedShift(byteArray);
12504
12534
  const accountCount = decodeLength(byteArray);
12505
12535
  let accountKeys = [];
12506
12536
 
12507
12537
  for (let i = 0; i < accountCount; i++) {
12508
- const account = byteArray.slice(0, PUBKEY_LENGTH);
12509
- byteArray = byteArray.slice(PUBKEY_LENGTH);
12538
+ const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
12510
12539
  accountKeys.push(bs58.encode(buffer.Buffer.from(account)));
12511
12540
  }
12512
12541
 
12513
- const recentBlockhash = byteArray.slice(0, PUBKEY_LENGTH);
12514
- byteArray = byteArray.slice(PUBKEY_LENGTH);
12542
+ const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
12515
12543
  const instructionCount = decodeLength(byteArray);
12516
12544
  let instructions = [];
12517
12545
 
12518
12546
  for (let i = 0; i < instructionCount; i++) {
12519
- const programIdIndex = byteArray.shift();
12547
+ const programIdIndex = guardedShift(byteArray);
12520
12548
  const accountCount = decodeLength(byteArray);
12521
- const accounts = byteArray.slice(0, accountCount);
12522
- byteArray = byteArray.slice(accountCount);
12549
+ const accounts = guardedSplice(byteArray, 0, accountCount);
12523
12550
  const dataLength = decodeLength(byteArray);
12524
- const dataSlice = byteArray.slice(0, dataLength);
12551
+ const dataSlice = guardedSplice(byteArray, 0, dataLength);
12525
12552
  const data = bs58.encode(buffer.Buffer.from(dataSlice));
12526
- byteArray = byteArray.slice(dataLength);
12527
12553
  instructions.push({
12528
12554
  programIdIndex,
12529
12555
  accounts,
@@ -12552,6 +12578,10 @@ var solanaWeb3 = (function (exports) {
12552
12578
  }
12553
12579
  }
12554
12580
 
12581
+ /**
12582
+ * Transaction signature as base-58 encoded string
12583
+ */
12584
+
12555
12585
  /**
12556
12586
  * Default (empty) signature
12557
12587
  *
@@ -13145,8 +13175,7 @@ var solanaWeb3 = (function (exports) {
13145
13175
  let signatures = [];
13146
13176
 
13147
13177
  for (let i = 0; i < signatureCount; i++) {
13148
- const signature = byteArray.slice(0, SIGNATURE_LENGTH);
13149
- byteArray = byteArray.slice(SIGNATURE_LENGTH);
13178
+ const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH);
13150
13179
  signatures.push(bs58.encode(buffer.Buffer.from(signature)));
13151
13180
  }
13152
13181
 
@@ -21720,9 +21749,6 @@ var solanaWeb3 = (function (exports) {
21720
21749
  "minimalistic-assert": "^1.0.1",
21721
21750
  "minimalistic-crypto-utils": "^1.0.1"
21722
21751
  };
21723
- var _resolved = "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz";
21724
- var _integrity = "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==";
21725
- var _from = "elliptic@6.5.4";
21726
21752
  var require$$0 = {
21727
21753
  name: name,
21728
21754
  version: version,
@@ -21737,10 +21763,7 @@ var solanaWeb3 = (function (exports) {
21737
21763
  bugs: bugs,
21738
21764
  homepage: homepage,
21739
21765
  devDependencies: devDependencies,
21740
- dependencies: dependencies,
21741
- _resolved: _resolved,
21742
- _integrity: _integrity,
21743
- _from: _from
21766
+ dependencies: dependencies
21744
21767
  };
21745
21768
 
21746
21769
  var utils$m = {};
@@ -28393,10 +28416,8 @@ var solanaWeb3 = (function (exports) {
28393
28416
  const configKeys = [];
28394
28417
 
28395
28418
  for (let i = 0; i < 2; i++) {
28396
- const publicKey = new PublicKey(byteArray.slice(0, PUBKEY_LENGTH));
28397
- byteArray = byteArray.slice(PUBKEY_LENGTH);
28398
- const isSigner = byteArray.slice(0, 1)[0] === 1;
28399
- byteArray = byteArray.slice(1);
28419
+ const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
28420
+ const isSigner = guardedShift(byteArray) === 1;
28400
28421
  configKeys.push({
28401
28422
  publicKey,
28402
28423
  isSigner