@solana/web3.js 1.75.0 → 1.75.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
@@ -11296,8 +11296,8 @@ var solanaWeb3 = (function (exports) {
11296
11296
  getOrInsertDefault(ix.programId).isInvoked = true;
11297
11297
  for (const accountMeta of ix.keys) {
11298
11298
  const keyMeta = getOrInsertDefault(accountMeta.pubkey);
11299
- keyMeta.isSigner || (keyMeta.isSigner = accountMeta.isSigner);
11300
- keyMeta.isWritable || (keyMeta.isWritable = accountMeta.isWritable);
11299
+ keyMeta.isSigner ||= accountMeta.isSigner;
11300
+ keyMeta.isWritable ||= accountMeta.isWritable;
11301
11301
  }
11302
11302
  }
11303
11303
  return new CompiledKeys(payer, keyMetaMap);
@@ -11362,6 +11362,31 @@ var solanaWeb3 = (function (exports) {
11362
11362
  }
11363
11363
  }
11364
11364
 
11365
+ const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
11366
+
11367
+ /**
11368
+ * Delegates to `Array#shift`, but throws if the array is zero-length.
11369
+ */
11370
+ function guardedShift(byteArray) {
11371
+ if (byteArray.length === 0) {
11372
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
11373
+ }
11374
+ return byteArray.shift();
11375
+ }
11376
+
11377
+ /**
11378
+ * Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
11379
+ * the array.
11380
+ */
11381
+ function guardedSplice(byteArray, ...args) {
11382
+ const [start] = args;
11383
+ if (args.length === 2 // Implies that `deleteCount` was supplied
11384
+ ? start + (args[1] ?? 0) > byteArray.length : start >= byteArray.length) {
11385
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
11386
+ }
11387
+ return byteArray.splice(...args);
11388
+ }
11389
+
11365
11390
  /**
11366
11391
  * An instruction to execute by a program
11367
11392
  *
@@ -11499,32 +11524,28 @@ var solanaWeb3 = (function (exports) {
11499
11524
  static from(buffer$1) {
11500
11525
  // Slice up wire data
11501
11526
  let byteArray = [...buffer$1];
11502
- const numRequiredSignatures = byteArray.shift();
11527
+ const numRequiredSignatures = guardedShift(byteArray);
11503
11528
  if (numRequiredSignatures !== (numRequiredSignatures & VERSION_PREFIX_MASK)) {
11504
11529
  throw new Error('Versioned messages must be deserialized with VersionedMessage.deserialize()');
11505
11530
  }
11506
- const numReadonlySignedAccounts = byteArray.shift();
11507
- const numReadonlyUnsignedAccounts = byteArray.shift();
11531
+ const numReadonlySignedAccounts = guardedShift(byteArray);
11532
+ const numReadonlyUnsignedAccounts = guardedShift(byteArray);
11508
11533
  const accountCount = decodeLength(byteArray);
11509
11534
  let accountKeys = [];
11510
11535
  for (let i = 0; i < accountCount; i++) {
11511
- const account = byteArray.slice(0, PUBLIC_KEY_LENGTH);
11512
- byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
11536
+ const account = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
11513
11537
  accountKeys.push(new PublicKey(buffer.Buffer.from(account)));
11514
11538
  }
11515
- const recentBlockhash = byteArray.slice(0, PUBLIC_KEY_LENGTH);
11516
- byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
11539
+ const recentBlockhash = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
11517
11540
  const instructionCount = decodeLength(byteArray);
11518
11541
  let instructions = [];
11519
11542
  for (let i = 0; i < instructionCount; i++) {
11520
- const programIdIndex = byteArray.shift();
11543
+ const programIdIndex = guardedShift(byteArray);
11521
11544
  const accountCount = decodeLength(byteArray);
11522
- const accounts = byteArray.slice(0, accountCount);
11523
- byteArray = byteArray.slice(accountCount);
11545
+ const accounts = guardedSplice(byteArray, 0, accountCount);
11524
11546
  const dataLength = decodeLength(byteArray);
11525
- const dataSlice = byteArray.slice(0, dataLength);
11547
+ const dataSlice = guardedSplice(byteArray, 0, dataLength);
11526
11548
  const data = bs58$1.encode(buffer.Buffer.from(dataSlice));
11527
- byteArray = byteArray.slice(dataLength);
11528
11549
  instructions.push({
11529
11550
  programIdIndex,
11530
11551
  accounts,
@@ -11729,30 +11750,30 @@ var solanaWeb3 = (function (exports) {
11729
11750
  }
11730
11751
  static deserialize(serializedMessage) {
11731
11752
  let byteArray = [...serializedMessage];
11732
- const prefix = byteArray.shift();
11753
+ const prefix = guardedShift(byteArray);
11733
11754
  const maskedPrefix = prefix & VERSION_PREFIX_MASK;
11734
11755
  assert$1(prefix !== maskedPrefix, `Expected versioned message but received legacy message`);
11735
11756
  const version = maskedPrefix;
11736
11757
  assert$1(version === 0, `Expected versioned message with version 0 but found version ${version}`);
11737
11758
  const header = {
11738
- numRequiredSignatures: byteArray.shift(),
11739
- numReadonlySignedAccounts: byteArray.shift(),
11740
- numReadonlyUnsignedAccounts: byteArray.shift()
11759
+ numRequiredSignatures: guardedShift(byteArray),
11760
+ numReadonlySignedAccounts: guardedShift(byteArray),
11761
+ numReadonlyUnsignedAccounts: guardedShift(byteArray)
11741
11762
  };
11742
11763
  const staticAccountKeys = [];
11743
11764
  const staticAccountKeysLength = decodeLength(byteArray);
11744
11765
  for (let i = 0; i < staticAccountKeysLength; i++) {
11745
- staticAccountKeys.push(new PublicKey(byteArray.splice(0, PUBLIC_KEY_LENGTH)));
11766
+ staticAccountKeys.push(new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH)));
11746
11767
  }
11747
- const recentBlockhash = bs58$1.encode(byteArray.splice(0, PUBLIC_KEY_LENGTH));
11768
+ const recentBlockhash = bs58$1.encode(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
11748
11769
  const instructionCount = decodeLength(byteArray);
11749
11770
  const compiledInstructions = [];
11750
11771
  for (let i = 0; i < instructionCount; i++) {
11751
- const programIdIndex = byteArray.shift();
11772
+ const programIdIndex = guardedShift(byteArray);
11752
11773
  const accountKeyIndexesLength = decodeLength(byteArray);
11753
- const accountKeyIndexes = byteArray.splice(0, accountKeyIndexesLength);
11774
+ const accountKeyIndexes = guardedSplice(byteArray, 0, accountKeyIndexesLength);
11754
11775
  const dataLength = decodeLength(byteArray);
11755
- const data = new Uint8Array(byteArray.splice(0, dataLength));
11776
+ const data = new Uint8Array(guardedSplice(byteArray, 0, dataLength));
11756
11777
  compiledInstructions.push({
11757
11778
  programIdIndex,
11758
11779
  accountKeyIndexes,
@@ -11762,11 +11783,11 @@ var solanaWeb3 = (function (exports) {
11762
11783
  const addressTableLookupsCount = decodeLength(byteArray);
11763
11784
  const addressTableLookups = [];
11764
11785
  for (let i = 0; i < addressTableLookupsCount; i++) {
11765
- const accountKey = new PublicKey(byteArray.splice(0, PUBLIC_KEY_LENGTH));
11786
+ const accountKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
11766
11787
  const writableIndexesLength = decodeLength(byteArray);
11767
- const writableIndexes = byteArray.splice(0, writableIndexesLength);
11788
+ const writableIndexes = guardedSplice(byteArray, 0, writableIndexesLength);
11768
11789
  const readonlyIndexesLength = decodeLength(byteArray);
11769
- const readonlyIndexes = byteArray.splice(0, readonlyIndexesLength);
11790
+ const readonlyIndexes = guardedSplice(byteArray, 0, readonlyIndexesLength);
11770
11791
  addressTableLookups.push({
11771
11792
  accountKey,
11772
11793
  writableIndexes,
@@ -12441,8 +12462,7 @@ var solanaWeb3 = (function (exports) {
12441
12462
  const signatureCount = decodeLength(byteArray);
12442
12463
  let signatures = [];
12443
12464
  for (let i = 0; i < signatureCount; i++) {
12444
- const signature = byteArray.slice(0, SIGNATURE_LENGTH_IN_BYTES);
12445
- byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
12465
+ const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
12446
12466
  signatures.push(bs58$1.encode(buffer.Buffer.from(signature)));
12447
12467
  }
12448
12468
  return Transaction.populate(Message.from(byteArray), signatures);
@@ -12612,7 +12632,7 @@ var solanaWeb3 = (function (exports) {
12612
12632
  const signatures = [];
12613
12633
  const signaturesLength = decodeLength(byteArray);
12614
12634
  for (let i = 0; i < signaturesLength; i++) {
12615
- signatures.push(new Uint8Array(byteArray.splice(0, SIGNATURE_LENGTH_IN_BYTES)));
12635
+ signatures.push(new Uint8Array(guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES)));
12616
12636
  }
12617
12637
  const message = VersionedMessage.deserialize(new Uint8Array(byteArray));
12618
12638
  return new VersionedTransaction(message, signatures);
@@ -18241,7 +18261,7 @@ var solanaWeb3 = (function (exports) {
18241
18261
 
18242
18262
  /** @internal */
18243
18263
  const COMMON_HTTP_HEADERS = {
18244
- 'solana-client': `js/${"0.0.0-development" }`
18264
+ 'solana-client': `js/${"1.75.1" }`
18245
18265
  };
18246
18266
 
18247
18267
  /**
@@ -20470,12 +20490,11 @@ var solanaWeb3 = (function (exports) {
20470
20490
  * @internal
20471
20491
  */
20472
20492
  _onSubscriptionStateChange(clientSubscriptionId, callback) {
20473
- var _this$_subscriptionSt;
20474
20493
  const hash = this._subscriptionHashByClientSubscriptionId[clientSubscriptionId];
20475
20494
  if (hash == null) {
20476
20495
  return () => {};
20477
20496
  }
20478
- const stateChangeCallbacks = (_this$_subscriptionSt = this._subscriptionStateChangeCallbacksByHash)[hash] || (_this$_subscriptionSt[hash] = new Set());
20497
+ const stateChangeCallbacks = this._subscriptionStateChangeCallbacksByHash[hash] ||= new Set();
20479
20498
  stateChangeCallbacks.add(callback);
20480
20499
  return () => {
20481
20500
  stateChangeCallbacks.delete(callback);
@@ -24312,10 +24331,8 @@ var solanaWeb3 = (function (exports) {
24312
24331
  if (configKeyCount !== 2) return null;
24313
24332
  const configKeys = [];
24314
24333
  for (let i = 0; i < 2; i++) {
24315
- const publicKey = new PublicKey(byteArray.slice(0, PUBLIC_KEY_LENGTH));
24316
- byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
24317
- const isSigner = byteArray.slice(0, 1)[0] === 1;
24318
- byteArray = byteArray.slice(1);
24334
+ const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
24335
+ const isSigner = guardedShift(byteArray) === 1;
24319
24336
  configKeys.push({
24320
24337
  publicKey,
24321
24338
  isSigner