@solana/web3.js 1.69.0 → 1.69.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
@@ -11238,6 +11238,36 @@ var solanaWeb3 = (function (exports) {
11238
11238
 
11239
11239
  }
11240
11240
 
11241
+ const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
11242
+ /**
11243
+ * Delegates to `Array#shift`, but throws if the array is zero-length.
11244
+ */
11245
+
11246
+ function guardedShift(byteArray) {
11247
+ if (byteArray.length === 0) {
11248
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
11249
+ }
11250
+
11251
+ return byteArray.shift();
11252
+ }
11253
+ /**
11254
+ * Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
11255
+ * the array.
11256
+ */
11257
+
11258
+ function guardedSplice(byteArray, ...args) {
11259
+ var _args$;
11260
+
11261
+ const [start] = args;
11262
+
11263
+ if (args.length === 2 // Implies that `deleteCount` was supplied
11264
+ ? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
11265
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
11266
+ }
11267
+
11268
+ return byteArray.splice(...args);
11269
+ }
11270
+
11241
11271
  /**
11242
11272
  * An instruction to execute by a program
11243
11273
  *
@@ -11389,37 +11419,33 @@ var solanaWeb3 = (function (exports) {
11389
11419
  static from(buffer$1) {
11390
11420
  // Slice up wire data
11391
11421
  let byteArray = [...buffer$1];
11392
- const numRequiredSignatures = byteArray.shift();
11422
+ const numRequiredSignatures = guardedShift(byteArray);
11393
11423
 
11394
11424
  if (numRequiredSignatures !== (numRequiredSignatures & VERSION_PREFIX_MASK)) {
11395
11425
  throw new Error('Versioned messages must be deserialized with VersionedMessage.deserialize()');
11396
11426
  }
11397
11427
 
11398
- const numReadonlySignedAccounts = byteArray.shift();
11399
- const numReadonlyUnsignedAccounts = byteArray.shift();
11428
+ const numReadonlySignedAccounts = guardedShift(byteArray);
11429
+ const numReadonlyUnsignedAccounts = guardedShift(byteArray);
11400
11430
  const accountCount = decodeLength(byteArray);
11401
11431
  let accountKeys = [];
11402
11432
 
11403
11433
  for (let i = 0; i < accountCount; i++) {
11404
- const account = byteArray.slice(0, PUBLIC_KEY_LENGTH);
11405
- byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
11434
+ const account = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
11406
11435
  accountKeys.push(new PublicKey(buffer.Buffer.from(account)));
11407
11436
  }
11408
11437
 
11409
- const recentBlockhash = byteArray.slice(0, PUBLIC_KEY_LENGTH);
11410
- byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
11438
+ const recentBlockhash = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
11411
11439
  const instructionCount = decodeLength(byteArray);
11412
11440
  let instructions = [];
11413
11441
 
11414
11442
  for (let i = 0; i < instructionCount; i++) {
11415
- const programIdIndex = byteArray.shift();
11443
+ const programIdIndex = guardedShift(byteArray);
11416
11444
  const accountCount = decodeLength(byteArray);
11417
- const accounts = byteArray.slice(0, accountCount);
11418
- byteArray = byteArray.slice(accountCount);
11445
+ const accounts = guardedSplice(byteArray, 0, accountCount);
11419
11446
  const dataLength = decodeLength(byteArray);
11420
- const dataSlice = byteArray.slice(0, dataLength);
11447
+ const dataSlice = guardedSplice(byteArray, 0, dataLength);
11421
11448
  const data = bs58$1.encode(buffer.Buffer.from(dataSlice));
11422
- byteArray = byteArray.slice(dataLength);
11423
11449
  instructions.push({
11424
11450
  programIdIndex,
11425
11451
  accounts,
@@ -11655,33 +11681,33 @@ var solanaWeb3 = (function (exports) {
11655
11681
 
11656
11682
  static deserialize(serializedMessage) {
11657
11683
  let byteArray = [...serializedMessage];
11658
- const prefix = byteArray.shift();
11684
+ const prefix = guardedShift(byteArray);
11659
11685
  const maskedPrefix = prefix & VERSION_PREFIX_MASK;
11660
11686
  assert$1(prefix !== maskedPrefix, `Expected versioned message but received legacy message`);
11661
11687
  const version = maskedPrefix;
11662
11688
  assert$1(version === 0, `Expected versioned message with version 0 but found version ${version}`);
11663
11689
  const header = {
11664
- numRequiredSignatures: byteArray.shift(),
11665
- numReadonlySignedAccounts: byteArray.shift(),
11666
- numReadonlyUnsignedAccounts: byteArray.shift()
11690
+ numRequiredSignatures: guardedShift(byteArray),
11691
+ numReadonlySignedAccounts: guardedShift(byteArray),
11692
+ numReadonlyUnsignedAccounts: guardedShift(byteArray)
11667
11693
  };
11668
11694
  const staticAccountKeys = [];
11669
11695
  const staticAccountKeysLength = decodeLength(byteArray);
11670
11696
 
11671
11697
  for (let i = 0; i < staticAccountKeysLength; i++) {
11672
- staticAccountKeys.push(new PublicKey(byteArray.splice(0, PUBLIC_KEY_LENGTH)));
11698
+ staticAccountKeys.push(new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH)));
11673
11699
  }
11674
11700
 
11675
- const recentBlockhash = bs58$1.encode(byteArray.splice(0, PUBLIC_KEY_LENGTH));
11701
+ const recentBlockhash = bs58$1.encode(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
11676
11702
  const instructionCount = decodeLength(byteArray);
11677
11703
  const compiledInstructions = [];
11678
11704
 
11679
11705
  for (let i = 0; i < instructionCount; i++) {
11680
- const programIdIndex = byteArray.shift();
11706
+ const programIdIndex = guardedShift(byteArray);
11681
11707
  const accountKeyIndexesLength = decodeLength(byteArray);
11682
- const accountKeyIndexes = byteArray.splice(0, accountKeyIndexesLength);
11708
+ const accountKeyIndexes = guardedSplice(byteArray, 0, accountKeyIndexesLength);
11683
11709
  const dataLength = decodeLength(byteArray);
11684
- const data = new Uint8Array(byteArray.splice(0, dataLength));
11710
+ const data = new Uint8Array(guardedSplice(byteArray, 0, dataLength));
11685
11711
  compiledInstructions.push({
11686
11712
  programIdIndex,
11687
11713
  accountKeyIndexes,
@@ -11693,11 +11719,11 @@ var solanaWeb3 = (function (exports) {
11693
11719
  const addressTableLookups = [];
11694
11720
 
11695
11721
  for (let i = 0; i < addressTableLookupsCount; i++) {
11696
- const accountKey = new PublicKey(byteArray.splice(0, PUBLIC_KEY_LENGTH));
11722
+ const accountKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
11697
11723
  const writableIndexesLength = decodeLength(byteArray);
11698
- const writableIndexes = byteArray.splice(0, writableIndexesLength);
11724
+ const writableIndexes = guardedSplice(byteArray, 0, writableIndexesLength);
11699
11725
  const readonlyIndexesLength = decodeLength(byteArray);
11700
- const readonlyIndexes = byteArray.splice(0, readonlyIndexesLength);
11726
+ const readonlyIndexes = guardedSplice(byteArray, 0, readonlyIndexesLength);
11701
11727
  addressTableLookups.push({
11702
11728
  accountKey,
11703
11729
  writableIndexes,
@@ -12437,8 +12463,7 @@ var solanaWeb3 = (function (exports) {
12437
12463
  let signatures = [];
12438
12464
 
12439
12465
  for (let i = 0; i < signatureCount; i++) {
12440
- const signature = byteArray.slice(0, SIGNATURE_LENGTH_IN_BYTES);
12441
- byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
12466
+ const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
12442
12467
  signatures.push(bs58$1.encode(buffer.Buffer.from(signature)));
12443
12468
  }
12444
12469
 
@@ -12636,7 +12661,7 @@ var solanaWeb3 = (function (exports) {
12636
12661
  const signaturesLength = decodeLength(byteArray);
12637
12662
 
12638
12663
  for (let i = 0; i < signaturesLength; i++) {
12639
- signatures.push(new Uint8Array(byteArray.splice(0, SIGNATURE_LENGTH_IN_BYTES)));
12664
+ signatures.push(new Uint8Array(guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES)));
12640
12665
  }
12641
12666
 
12642
12667
  const message = VersionedMessage.deserialize(new Uint8Array(byteArray));
@@ -18313,7 +18338,7 @@ var solanaWeb3 = (function (exports) {
18313
18338
 
18314
18339
  /** @internal */
18315
18340
  const COMMON_HTTP_HEADERS = {
18316
- 'solana-client': `js/${(_process$env$npm_pack = "0.0.0-development") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
18341
+ 'solana-client': `js/${(_process$env$npm_pack = "1.69.1") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
18317
18342
  };
18318
18343
  /**
18319
18344
  * A connection to a fullnode JSON RPC endpoint
@@ -24947,10 +24972,8 @@ var solanaWeb3 = (function (exports) {
24947
24972
  const configKeys = [];
24948
24973
 
24949
24974
  for (let i = 0; i < 2; i++) {
24950
- const publicKey = new PublicKey(byteArray.slice(0, PUBLIC_KEY_LENGTH));
24951
- byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
24952
- const isSigner = byteArray.slice(0, 1)[0] === 1;
24953
- byteArray = byteArray.slice(1);
24975
+ const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
24976
+ const isSigner = guardedShift(byteArray) === 1;
24954
24977
  configKeys.push({
24955
24978
  publicKey,
24956
24979
  isSigner