@solana/web3.js 1.27.0 → 1.27.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
@@ -12423,6 +12423,36 @@ var solanaWeb3 = (function (exports) {
12423
12423
  }
12424
12424
  }
12425
12425
 
12426
+ const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
12427
+ /**
12428
+ * Delegates to `Array#shift`, but throws if the array is zero-length.
12429
+ */
12430
+
12431
+ function guardedShift(byteArray) {
12432
+ if (byteArray.length === 0) {
12433
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
12434
+ }
12435
+
12436
+ return byteArray.shift();
12437
+ }
12438
+ /**
12439
+ * Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
12440
+ * the array.
12441
+ */
12442
+
12443
+ function guardedSplice(byteArray, ...args) {
12444
+ var _args$;
12445
+
12446
+ const [start] = args;
12447
+
12448
+ if (args.length === 2 // Implies that `deleteCount` was supplied
12449
+ ? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
12450
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
12451
+ }
12452
+
12453
+ return byteArray.splice(...args);
12454
+ }
12455
+
12426
12456
  /**
12427
12457
  * The message header, identifying signed and read-only account
12428
12458
  */
@@ -12507,32 +12537,28 @@ var solanaWeb3 = (function (exports) {
12507
12537
  static from(buffer$1) {
12508
12538
  // Slice up wire data
12509
12539
  let byteArray = [...buffer$1];
12510
- const numRequiredSignatures = byteArray.shift();
12511
- const numReadonlySignedAccounts = byteArray.shift();
12512
- const numReadonlyUnsignedAccounts = byteArray.shift();
12540
+ const numRequiredSignatures = guardedShift(byteArray);
12541
+ const numReadonlySignedAccounts = guardedShift(byteArray);
12542
+ const numReadonlyUnsignedAccounts = guardedShift(byteArray);
12513
12543
  const accountCount = decodeLength(byteArray);
12514
12544
  let accountKeys = [];
12515
12545
 
12516
12546
  for (let i = 0; i < accountCount; i++) {
12517
- const account = byteArray.slice(0, PUBKEY_LENGTH);
12518
- byteArray = byteArray.slice(PUBKEY_LENGTH);
12547
+ const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
12519
12548
  accountKeys.push(bs58$1.encode(buffer.Buffer.from(account)));
12520
12549
  }
12521
12550
 
12522
- const recentBlockhash = byteArray.slice(0, PUBKEY_LENGTH);
12523
- byteArray = byteArray.slice(PUBKEY_LENGTH);
12551
+ const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
12524
12552
  const instructionCount = decodeLength(byteArray);
12525
12553
  let instructions = [];
12526
12554
 
12527
12555
  for (let i = 0; i < instructionCount; i++) {
12528
- const programIdIndex = byteArray.shift();
12556
+ const programIdIndex = guardedShift(byteArray);
12529
12557
  const accountCount = decodeLength(byteArray);
12530
- const accounts = byteArray.slice(0, accountCount);
12531
- byteArray = byteArray.slice(accountCount);
12558
+ const accounts = guardedSplice(byteArray, 0, accountCount);
12532
12559
  const dataLength = decodeLength(byteArray);
12533
- const dataSlice = byteArray.slice(0, dataLength);
12560
+ const dataSlice = guardedSplice(byteArray, 0, dataLength);
12534
12561
  const data = bs58$1.encode(buffer.Buffer.from(dataSlice));
12535
- byteArray = byteArray.slice(dataLength);
12536
12562
  instructions.push({
12537
12563
  programIdIndex,
12538
12564
  accounts,
@@ -12561,6 +12587,10 @@ var solanaWeb3 = (function (exports) {
12561
12587
  }
12562
12588
  }
12563
12589
 
12590
+ /**
12591
+ * Transaction signature as base-58 encoded string
12592
+ */
12593
+
12564
12594
  /**
12565
12595
  * Default (empty) signature
12566
12596
  *
@@ -13154,8 +13184,7 @@ var solanaWeb3 = (function (exports) {
13154
13184
  let signatures = [];
13155
13185
 
13156
13186
  for (let i = 0; i < signatureCount; i++) {
13157
- const signature = byteArray.slice(0, SIGNATURE_LENGTH);
13158
- byteArray = byteArray.slice(SIGNATURE_LENGTH);
13187
+ const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH);
13159
13188
  signatures.push(bs58$1.encode(buffer.Buffer.from(signature)));
13160
13189
  }
13161
13190
 
@@ -22465,9 +22494,6 @@ var solanaWeb3 = (function (exports) {
22465
22494
  "minimalistic-assert": "^1.0.1",
22466
22495
  "minimalistic-crypto-utils": "^1.0.1"
22467
22496
  };
22468
- var _resolved = "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz";
22469
- var _integrity = "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==";
22470
- var _from = "elliptic@6.5.4";
22471
22497
  var require$$0 = {
22472
22498
  name: name,
22473
22499
  version: version,
@@ -22482,10 +22508,7 @@ var solanaWeb3 = (function (exports) {
22482
22508
  bugs: bugs,
22483
22509
  homepage: homepage,
22484
22510
  devDependencies: devDependencies,
22485
- dependencies: dependencies,
22486
- _resolved: _resolved,
22487
- _integrity: _integrity,
22488
- _from: _from
22511
+ dependencies: dependencies
22489
22512
  };
22490
22513
 
22491
22514
  var utils$m = {};
@@ -29145,10 +29168,8 @@ var solanaWeb3 = (function (exports) {
29145
29168
  const configKeys = [];
29146
29169
 
29147
29170
  for (let i = 0; i < 2; i++) {
29148
- const publicKey = new PublicKey(byteArray.slice(0, PUBKEY_LENGTH));
29149
- byteArray = byteArray.slice(PUBKEY_LENGTH);
29150
- const isSigner = byteArray.slice(0, 1)[0] === 1;
29151
- byteArray = byteArray.slice(1);
29171
+ const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
29172
+ const isSigner = guardedShift(byteArray) === 1;
29152
29173
  configKeys.push({
29153
29174
  publicKey,
29154
29175
  isSigner