@solana/web3.js 1.66.5 → 1.66.6

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
@@ -11223,6 +11223,36 @@ var solanaWeb3 = (function (exports) {
11223
11223
 
11224
11224
  }
11225
11225
 
11226
+ const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
11227
+ /**
11228
+ * Delegates to `Array#shift`, but throws if the array is zero-length.
11229
+ */
11230
+
11231
+ function guardedShift(byteArray) {
11232
+ if (byteArray.length === 0) {
11233
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
11234
+ }
11235
+
11236
+ return byteArray.shift();
11237
+ }
11238
+ /**
11239
+ * Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
11240
+ * the array.
11241
+ */
11242
+
11243
+ function guardedSplice(byteArray, ...args) {
11244
+ var _args$;
11245
+
11246
+ const [start] = args;
11247
+
11248
+ if (args.length === 2 // Implies that `deleteCount` was supplied
11249
+ ? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
11250
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
11251
+ }
11252
+
11253
+ return byteArray.splice(...args);
11254
+ }
11255
+
11226
11256
  /**
11227
11257
  * An instruction to execute by a program
11228
11258
  *
@@ -11374,37 +11404,33 @@ var solanaWeb3 = (function (exports) {
11374
11404
  static from(buffer$1) {
11375
11405
  // Slice up wire data
11376
11406
  let byteArray = [...buffer$1];
11377
- const numRequiredSignatures = byteArray.shift();
11407
+ const numRequiredSignatures = guardedShift(byteArray);
11378
11408
 
11379
11409
  if (numRequiredSignatures !== (numRequiredSignatures & VERSION_PREFIX_MASK)) {
11380
11410
  throw new Error('Versioned messages must be deserialized with VersionedMessage.deserialize()');
11381
11411
  }
11382
11412
 
11383
- const numReadonlySignedAccounts = byteArray.shift();
11384
- const numReadonlyUnsignedAccounts = byteArray.shift();
11413
+ const numReadonlySignedAccounts = guardedShift(byteArray);
11414
+ const numReadonlyUnsignedAccounts = guardedShift(byteArray);
11385
11415
  const accountCount = decodeLength(byteArray);
11386
11416
  let accountKeys = [];
11387
11417
 
11388
11418
  for (let i = 0; i < accountCount; i++) {
11389
- const account = byteArray.slice(0, PUBLIC_KEY_LENGTH);
11390
- byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
11419
+ const account = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
11391
11420
  accountKeys.push(new PublicKey(buffer.Buffer.from(account)));
11392
11421
  }
11393
11422
 
11394
- const recentBlockhash = byteArray.slice(0, PUBLIC_KEY_LENGTH);
11395
- byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
11423
+ const recentBlockhash = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
11396
11424
  const instructionCount = decodeLength(byteArray);
11397
11425
  let instructions = [];
11398
11426
 
11399
11427
  for (let i = 0; i < instructionCount; i++) {
11400
- const programIdIndex = byteArray.shift();
11428
+ const programIdIndex = guardedShift(byteArray);
11401
11429
  const accountCount = decodeLength(byteArray);
11402
- const accounts = byteArray.slice(0, accountCount);
11403
- byteArray = byteArray.slice(accountCount);
11430
+ const accounts = guardedSplice(byteArray, 0, accountCount);
11404
11431
  const dataLength = decodeLength(byteArray);
11405
- const dataSlice = byteArray.slice(0, dataLength);
11432
+ const dataSlice = guardedSplice(byteArray, 0, dataLength);
11406
11433
  const data = bs58$1.encode(buffer.Buffer.from(dataSlice));
11407
- byteArray = byteArray.slice(dataLength);
11408
11434
  instructions.push({
11409
11435
  programIdIndex,
11410
11436
  accounts,
@@ -11640,33 +11666,33 @@ var solanaWeb3 = (function (exports) {
11640
11666
 
11641
11667
  static deserialize(serializedMessage) {
11642
11668
  let byteArray = [...serializedMessage];
11643
- const prefix = byteArray.shift();
11669
+ const prefix = guardedShift(byteArray);
11644
11670
  const maskedPrefix = prefix & VERSION_PREFIX_MASK;
11645
11671
  assert$1(prefix !== maskedPrefix, `Expected versioned message but received legacy message`);
11646
11672
  const version = maskedPrefix;
11647
11673
  assert$1(version === 0, `Expected versioned message with version 0 but found version ${version}`);
11648
11674
  const header = {
11649
- numRequiredSignatures: byteArray.shift(),
11650
- numReadonlySignedAccounts: byteArray.shift(),
11651
- numReadonlyUnsignedAccounts: byteArray.shift()
11675
+ numRequiredSignatures: guardedShift(byteArray),
11676
+ numReadonlySignedAccounts: guardedShift(byteArray),
11677
+ numReadonlyUnsignedAccounts: guardedShift(byteArray)
11652
11678
  };
11653
11679
  const staticAccountKeys = [];
11654
11680
  const staticAccountKeysLength = decodeLength(byteArray);
11655
11681
 
11656
11682
  for (let i = 0; i < staticAccountKeysLength; i++) {
11657
- staticAccountKeys.push(new PublicKey(byteArray.splice(0, PUBLIC_KEY_LENGTH)));
11683
+ staticAccountKeys.push(new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH)));
11658
11684
  }
11659
11685
 
11660
- const recentBlockhash = bs58$1.encode(byteArray.splice(0, PUBLIC_KEY_LENGTH));
11686
+ const recentBlockhash = bs58$1.encode(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
11661
11687
  const instructionCount = decodeLength(byteArray);
11662
11688
  const compiledInstructions = [];
11663
11689
 
11664
11690
  for (let i = 0; i < instructionCount; i++) {
11665
- const programIdIndex = byteArray.shift();
11691
+ const programIdIndex = guardedShift(byteArray);
11666
11692
  const accountKeyIndexesLength = decodeLength(byteArray);
11667
- const accountKeyIndexes = byteArray.splice(0, accountKeyIndexesLength);
11693
+ const accountKeyIndexes = guardedSplice(byteArray, 0, accountKeyIndexesLength);
11668
11694
  const dataLength = decodeLength(byteArray);
11669
- const data = new Uint8Array(byteArray.splice(0, dataLength));
11695
+ const data = new Uint8Array(guardedSplice(byteArray, 0, dataLength));
11670
11696
  compiledInstructions.push({
11671
11697
  programIdIndex,
11672
11698
  accountKeyIndexes,
@@ -11678,11 +11704,11 @@ var solanaWeb3 = (function (exports) {
11678
11704
  const addressTableLookups = [];
11679
11705
 
11680
11706
  for (let i = 0; i < addressTableLookupsCount; i++) {
11681
- const accountKey = new PublicKey(byteArray.splice(0, PUBLIC_KEY_LENGTH));
11707
+ const accountKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
11682
11708
  const writableIndexesLength = decodeLength(byteArray);
11683
- const writableIndexes = byteArray.splice(0, writableIndexesLength);
11709
+ const writableIndexes = guardedSplice(byteArray, 0, writableIndexesLength);
11684
11710
  const readonlyIndexesLength = decodeLength(byteArray);
11685
- const readonlyIndexes = byteArray.splice(0, readonlyIndexesLength);
11711
+ const readonlyIndexes = guardedSplice(byteArray, 0, readonlyIndexesLength);
11686
11712
  addressTableLookups.push({
11687
11713
  accountKey,
11688
11714
  writableIndexes,
@@ -12413,8 +12439,7 @@ var solanaWeb3 = (function (exports) {
12413
12439
  let signatures = [];
12414
12440
 
12415
12441
  for (let i = 0; i < signatureCount; i++) {
12416
- const signature = byteArray.slice(0, SIGNATURE_LENGTH_IN_BYTES);
12417
- byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
12442
+ const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
12418
12443
  signatures.push(bs58$1.encode(buffer.Buffer.from(signature)));
12419
12444
  }
12420
12445
 
@@ -12612,7 +12637,7 @@ var solanaWeb3 = (function (exports) {
12612
12637
  const signaturesLength = decodeLength(byteArray);
12613
12638
 
12614
12639
  for (let i = 0; i < signaturesLength; i++) {
12615
- signatures.push(new Uint8Array(byteArray.splice(0, SIGNATURE_LENGTH_IN_BYTES)));
12640
+ signatures.push(new Uint8Array(guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES)));
12616
12641
  }
12617
12642
 
12618
12643
  const message = VersionedMessage.deserialize(new Uint8Array(byteArray));
@@ -18207,7 +18232,7 @@ var solanaWeb3 = (function (exports) {
18207
18232
 
18208
18233
  /** @internal */
18209
18234
  const COMMON_HTTP_HEADERS = {
18210
- 'solana-client': `js/${(_process$env$npm_pack = "0.0.0-development") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
18235
+ 'solana-client': `js/${(_process$env$npm_pack = "1.66.6") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
18211
18236
  };
18212
18237
  /**
18213
18238
  * A connection to a fullnode JSON RPC endpoint
@@ -24530,10 +24555,8 @@ var solanaWeb3 = (function (exports) {
24530
24555
  const configKeys = [];
24531
24556
 
24532
24557
  for (let i = 0; i < 2; i++) {
24533
- const publicKey = new PublicKey(byteArray.slice(0, PUBLIC_KEY_LENGTH));
24534
- byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
24535
- const isSigner = byteArray.slice(0, 1)[0] === 1;
24536
- byteArray = byteArray.slice(1);
24558
+ const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
24559
+ const isSigner = guardedShift(byteArray) === 1;
24537
24560
  configKeys.push({
24538
24561
  publicKey,
24539
24562
  isSigner