@solana/web3.js 1.61.0 → 1.61.2

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
@@ -11222,6 +11222,36 @@ var solanaWeb3 = (function (exports) {
11222
11222
 
11223
11223
  }
11224
11224
 
11225
+ const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
11226
+ /**
11227
+ * Delegates to `Array#shift`, but throws if the array is zero-length.
11228
+ */
11229
+
11230
+ function guardedShift(byteArray) {
11231
+ if (byteArray.length === 0) {
11232
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
11233
+ }
11234
+
11235
+ return byteArray.shift();
11236
+ }
11237
+ /**
11238
+ * Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
11239
+ * the array.
11240
+ */
11241
+
11242
+ function guardedSplice(byteArray, ...args) {
11243
+ var _args$;
11244
+
11245
+ const [start] = args;
11246
+
11247
+ if (args.length === 2 // Implies that `deleteCount` was supplied
11248
+ ? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
11249
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
11250
+ }
11251
+
11252
+ return byteArray.splice(...args);
11253
+ }
11254
+
11225
11255
  /**
11226
11256
  * An instruction to execute by a program
11227
11257
  *
@@ -11363,37 +11393,33 @@ var solanaWeb3 = (function (exports) {
11363
11393
  static from(buffer$1) {
11364
11394
  // Slice up wire data
11365
11395
  let byteArray = [...buffer$1];
11366
- const numRequiredSignatures = byteArray.shift();
11396
+ const numRequiredSignatures = guardedShift(byteArray);
11367
11397
 
11368
11398
  if (numRequiredSignatures !== (numRequiredSignatures & VERSION_PREFIX_MASK)) {
11369
11399
  throw new Error('Versioned messages must be deserialized with VersionedMessage.deserialize()');
11370
11400
  }
11371
11401
 
11372
- const numReadonlySignedAccounts = byteArray.shift();
11373
- const numReadonlyUnsignedAccounts = byteArray.shift();
11402
+ const numReadonlySignedAccounts = guardedShift(byteArray);
11403
+ const numReadonlyUnsignedAccounts = guardedShift(byteArray);
11374
11404
  const accountCount = decodeLength(byteArray);
11375
11405
  let accountKeys = [];
11376
11406
 
11377
11407
  for (let i = 0; i < accountCount; i++) {
11378
- const account = byteArray.slice(0, PUBLIC_KEY_LENGTH);
11379
- byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
11408
+ const account = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
11380
11409
  accountKeys.push(new PublicKey(buffer.Buffer.from(account)));
11381
11410
  }
11382
11411
 
11383
- const recentBlockhash = byteArray.slice(0, PUBLIC_KEY_LENGTH);
11384
- byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
11412
+ const recentBlockhash = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
11385
11413
  const instructionCount = decodeLength(byteArray);
11386
11414
  let instructions = [];
11387
11415
 
11388
11416
  for (let i = 0; i < instructionCount; i++) {
11389
- const programIdIndex = byteArray.shift();
11417
+ const programIdIndex = guardedShift(byteArray);
11390
11418
  const accountCount = decodeLength(byteArray);
11391
- const accounts = byteArray.slice(0, accountCount);
11392
- byteArray = byteArray.slice(accountCount);
11419
+ const accounts = guardedSplice(byteArray, 0, accountCount);
11393
11420
  const dataLength = decodeLength(byteArray);
11394
- const dataSlice = byteArray.slice(0, dataLength);
11421
+ const dataSlice = guardedSplice(byteArray, 0, dataLength);
11395
11422
  const data = bs58$1.encode(buffer.Buffer.from(dataSlice));
11396
- byteArray = byteArray.slice(dataLength);
11397
11423
  instructions.push({
11398
11424
  programIdIndex,
11399
11425
  accounts,
@@ -11606,33 +11632,33 @@ var solanaWeb3 = (function (exports) {
11606
11632
 
11607
11633
  static deserialize(serializedMessage) {
11608
11634
  let byteArray = [...serializedMessage];
11609
- const prefix = byteArray.shift();
11635
+ const prefix = guardedShift(byteArray);
11610
11636
  const maskedPrefix = prefix & VERSION_PREFIX_MASK;
11611
11637
  assert$1(prefix !== maskedPrefix, `Expected versioned message but received legacy message`);
11612
11638
  const version = maskedPrefix;
11613
11639
  assert$1(version === 0, `Expected versioned message with version 0 but found version ${version}`);
11614
11640
  const header = {
11615
- numRequiredSignatures: byteArray.shift(),
11616
- numReadonlySignedAccounts: byteArray.shift(),
11617
- numReadonlyUnsignedAccounts: byteArray.shift()
11641
+ numRequiredSignatures: guardedShift(byteArray),
11642
+ numReadonlySignedAccounts: guardedShift(byteArray),
11643
+ numReadonlyUnsignedAccounts: guardedShift(byteArray)
11618
11644
  };
11619
11645
  const staticAccountKeys = [];
11620
11646
  const staticAccountKeysLength = decodeLength(byteArray);
11621
11647
 
11622
11648
  for (let i = 0; i < staticAccountKeysLength; i++) {
11623
- staticAccountKeys.push(new PublicKey(byteArray.splice(0, PUBLIC_KEY_LENGTH)));
11649
+ staticAccountKeys.push(new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH)));
11624
11650
  }
11625
11651
 
11626
- const recentBlockhash = bs58$1.encode(byteArray.splice(0, PUBLIC_KEY_LENGTH));
11652
+ const recentBlockhash = bs58$1.encode(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
11627
11653
  const instructionCount = decodeLength(byteArray);
11628
11654
  const compiledInstructions = [];
11629
11655
 
11630
11656
  for (let i = 0; i < instructionCount; i++) {
11631
- const programIdIndex = byteArray.shift();
11657
+ const programIdIndex = guardedShift(byteArray);
11632
11658
  const accountKeyIndexesLength = decodeLength(byteArray);
11633
- const accountKeyIndexes = byteArray.splice(0, accountKeyIndexesLength);
11659
+ const accountKeyIndexes = guardedSplice(byteArray, 0, accountKeyIndexesLength);
11634
11660
  const dataLength = decodeLength(byteArray);
11635
- const data = new Uint8Array(byteArray.splice(0, dataLength));
11661
+ const data = new Uint8Array(guardedSplice(byteArray, 0, dataLength));
11636
11662
  compiledInstructions.push({
11637
11663
  programIdIndex,
11638
11664
  accountKeyIndexes,
@@ -11644,11 +11670,11 @@ var solanaWeb3 = (function (exports) {
11644
11670
  const addressTableLookups = [];
11645
11671
 
11646
11672
  for (let i = 0; i < addressTableLookupsCount; i++) {
11647
- const accountKey = new PublicKey(byteArray.splice(0, PUBLIC_KEY_LENGTH));
11673
+ const accountKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
11648
11674
  const writableIndexesLength = decodeLength(byteArray);
11649
- const writableIndexes = byteArray.splice(0, writableIndexesLength);
11675
+ const writableIndexes = guardedSplice(byteArray, 0, writableIndexesLength);
11650
11676
  const readonlyIndexesLength = decodeLength(byteArray);
11651
- const readonlyIndexes = byteArray.splice(0, readonlyIndexesLength);
11677
+ const readonlyIndexes = guardedSplice(byteArray, 0, readonlyIndexesLength);
11652
11678
  addressTableLookups.push({
11653
11679
  accountKey,
11654
11680
  writableIndexes,
@@ -12379,8 +12405,7 @@ var solanaWeb3 = (function (exports) {
12379
12405
  let signatures = [];
12380
12406
 
12381
12407
  for (let i = 0; i < signatureCount; i++) {
12382
- const signature = byteArray.slice(0, SIGNATURE_LENGTH_IN_BYTES);
12383
- byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
12408
+ const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
12384
12409
  signatures.push(bs58$1.encode(buffer.Buffer.from(signature)));
12385
12410
  }
12386
12411
 
@@ -12578,7 +12603,7 @@ var solanaWeb3 = (function (exports) {
12578
12603
  const signaturesLength = decodeLength(byteArray);
12579
12604
 
12580
12605
  for (let i = 0; i < signaturesLength; i++) {
12581
- signatures.push(new Uint8Array(byteArray.splice(0, SIGNATURE_LENGTH_IN_BYTES)));
12606
+ signatures.push(new Uint8Array(guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES)));
12582
12607
  }
12583
12608
 
12584
12609
  const message = VersionedMessage.deserialize(new Uint8Array(byteArray));
@@ -17127,7 +17152,7 @@ var solanaWeb3 = (function (exports) {
17127
17152
  }
17128
17153
 
17129
17154
  isActive() {
17130
- const U64_MAX = 2n ** 64n - 1n;
17155
+ const U64_MAX = 18446744073709551615n;
17131
17156
  return this.state.deactivationSlot === U64_MAX;
17132
17157
  }
17133
17158
 
@@ -18143,7 +18168,7 @@ var solanaWeb3 = (function (exports) {
18143
18168
 
18144
18169
  /** @internal */
18145
18170
  const COMMON_HTTP_HEADERS = {
18146
- 'solana-client': `js/${(_process$env$npm_pack = "0.0.0-development") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
18171
+ 'solana-client': `js/${(_process$env$npm_pack = "1.61.2") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
18147
18172
  };
18148
18173
  /**
18149
18174
  * A connection to a fullnode JSON RPC endpoint
@@ -24278,10 +24303,8 @@ var solanaWeb3 = (function (exports) {
24278
24303
  const configKeys = [];
24279
24304
 
24280
24305
  for (let i = 0; i < 2; i++) {
24281
- const publicKey = new PublicKey(byteArray.slice(0, PUBLIC_KEY_LENGTH));
24282
- byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
24283
- const isSigner = byteArray.slice(0, 1)[0] === 1;
24284
- byteArray = byteArray.slice(1);
24306
+ const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
24307
+ const isSigner = guardedShift(byteArray) === 1;
24285
24308
  configKeys.push({
24286
24309
  publicKey,
24287
24310
  isSigner