@solana/web3.js 1.70.2 → 1.70.4

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
@@ -8399,7 +8399,8 @@ var solanaWeb3 = (function (exports) {
8399
8399
 
8400
8400
 
8401
8401
  toBytes() {
8402
- return this.toBuffer();
8402
+ const buf = this.toBuffer();
8403
+ return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
8403
8404
  }
8404
8405
  /**
8405
8406
  * Return the Buffer representation of the public key in big endian
@@ -11244,6 +11245,36 @@ var solanaWeb3 = (function (exports) {
11244
11245
 
11245
11246
  }
11246
11247
 
11248
+ const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
11249
+ /**
11250
+ * Delegates to `Array#shift`, but throws if the array is zero-length.
11251
+ */
11252
+
11253
+ function guardedShift(byteArray) {
11254
+ if (byteArray.length === 0) {
11255
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
11256
+ }
11257
+
11258
+ return byteArray.shift();
11259
+ }
11260
+ /**
11261
+ * Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
11262
+ * the array.
11263
+ */
11264
+
11265
+ function guardedSplice(byteArray, ...args) {
11266
+ var _args$;
11267
+
11268
+ const [start] = args;
11269
+
11270
+ if (args.length === 2 // Implies that `deleteCount` was supplied
11271
+ ? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
11272
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
11273
+ }
11274
+
11275
+ return byteArray.splice(...args);
11276
+ }
11277
+
11247
11278
  /**
11248
11279
  * An instruction to execute by a program
11249
11280
  *
@@ -11395,37 +11426,33 @@ var solanaWeb3 = (function (exports) {
11395
11426
  static from(buffer$1) {
11396
11427
  // Slice up wire data
11397
11428
  let byteArray = [...buffer$1];
11398
- const numRequiredSignatures = byteArray.shift();
11429
+ const numRequiredSignatures = guardedShift(byteArray);
11399
11430
 
11400
11431
  if (numRequiredSignatures !== (numRequiredSignatures & VERSION_PREFIX_MASK)) {
11401
11432
  throw new Error('Versioned messages must be deserialized with VersionedMessage.deserialize()');
11402
11433
  }
11403
11434
 
11404
- const numReadonlySignedAccounts = byteArray.shift();
11405
- const numReadonlyUnsignedAccounts = byteArray.shift();
11435
+ const numReadonlySignedAccounts = guardedShift(byteArray);
11436
+ const numReadonlyUnsignedAccounts = guardedShift(byteArray);
11406
11437
  const accountCount = decodeLength(byteArray);
11407
11438
  let accountKeys = [];
11408
11439
 
11409
11440
  for (let i = 0; i < accountCount; i++) {
11410
- const account = byteArray.slice(0, PUBLIC_KEY_LENGTH);
11411
- byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
11441
+ const account = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
11412
11442
  accountKeys.push(new PublicKey(buffer.Buffer.from(account)));
11413
11443
  }
11414
11444
 
11415
- const recentBlockhash = byteArray.slice(0, PUBLIC_KEY_LENGTH);
11416
- byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
11445
+ const recentBlockhash = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
11417
11446
  const instructionCount = decodeLength(byteArray);
11418
11447
  let instructions = [];
11419
11448
 
11420
11449
  for (let i = 0; i < instructionCount; i++) {
11421
- const programIdIndex = byteArray.shift();
11450
+ const programIdIndex = guardedShift(byteArray);
11422
11451
  const accountCount = decodeLength(byteArray);
11423
- const accounts = byteArray.slice(0, accountCount);
11424
- byteArray = byteArray.slice(accountCount);
11452
+ const accounts = guardedSplice(byteArray, 0, accountCount);
11425
11453
  const dataLength = decodeLength(byteArray);
11426
- const dataSlice = byteArray.slice(0, dataLength);
11454
+ const dataSlice = guardedSplice(byteArray, 0, dataLength);
11427
11455
  const data = bs58$1.encode(buffer.Buffer.from(dataSlice));
11428
- byteArray = byteArray.slice(dataLength);
11429
11456
  instructions.push({
11430
11457
  programIdIndex,
11431
11458
  accounts,
@@ -11661,33 +11688,33 @@ var solanaWeb3 = (function (exports) {
11661
11688
 
11662
11689
  static deserialize(serializedMessage) {
11663
11690
  let byteArray = [...serializedMessage];
11664
- const prefix = byteArray.shift();
11691
+ const prefix = guardedShift(byteArray);
11665
11692
  const maskedPrefix = prefix & VERSION_PREFIX_MASK;
11666
11693
  assert$1(prefix !== maskedPrefix, `Expected versioned message but received legacy message`);
11667
11694
  const version = maskedPrefix;
11668
11695
  assert$1(version === 0, `Expected versioned message with version 0 but found version ${version}`);
11669
11696
  const header = {
11670
- numRequiredSignatures: byteArray.shift(),
11671
- numReadonlySignedAccounts: byteArray.shift(),
11672
- numReadonlyUnsignedAccounts: byteArray.shift()
11697
+ numRequiredSignatures: guardedShift(byteArray),
11698
+ numReadonlySignedAccounts: guardedShift(byteArray),
11699
+ numReadonlyUnsignedAccounts: guardedShift(byteArray)
11673
11700
  };
11674
11701
  const staticAccountKeys = [];
11675
11702
  const staticAccountKeysLength = decodeLength(byteArray);
11676
11703
 
11677
11704
  for (let i = 0; i < staticAccountKeysLength; i++) {
11678
- staticAccountKeys.push(new PublicKey(byteArray.splice(0, PUBLIC_KEY_LENGTH)));
11705
+ staticAccountKeys.push(new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH)));
11679
11706
  }
11680
11707
 
11681
- const recentBlockhash = bs58$1.encode(byteArray.splice(0, PUBLIC_KEY_LENGTH));
11708
+ const recentBlockhash = bs58$1.encode(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
11682
11709
  const instructionCount = decodeLength(byteArray);
11683
11710
  const compiledInstructions = [];
11684
11711
 
11685
11712
  for (let i = 0; i < instructionCount; i++) {
11686
- const programIdIndex = byteArray.shift();
11713
+ const programIdIndex = guardedShift(byteArray);
11687
11714
  const accountKeyIndexesLength = decodeLength(byteArray);
11688
- const accountKeyIndexes = byteArray.splice(0, accountKeyIndexesLength);
11715
+ const accountKeyIndexes = guardedSplice(byteArray, 0, accountKeyIndexesLength);
11689
11716
  const dataLength = decodeLength(byteArray);
11690
- const data = new Uint8Array(byteArray.splice(0, dataLength));
11717
+ const data = new Uint8Array(guardedSplice(byteArray, 0, dataLength));
11691
11718
  compiledInstructions.push({
11692
11719
  programIdIndex,
11693
11720
  accountKeyIndexes,
@@ -11699,11 +11726,11 @@ var solanaWeb3 = (function (exports) {
11699
11726
  const addressTableLookups = [];
11700
11727
 
11701
11728
  for (let i = 0; i < addressTableLookupsCount; i++) {
11702
- const accountKey = new PublicKey(byteArray.splice(0, PUBLIC_KEY_LENGTH));
11729
+ const accountKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
11703
11730
  const writableIndexesLength = decodeLength(byteArray);
11704
- const writableIndexes = byteArray.splice(0, writableIndexesLength);
11731
+ const writableIndexes = guardedSplice(byteArray, 0, writableIndexesLength);
11705
11732
  const readonlyIndexesLength = decodeLength(byteArray);
11706
- const readonlyIndexes = byteArray.splice(0, readonlyIndexesLength);
11733
+ const readonlyIndexes = guardedSplice(byteArray, 0, readonlyIndexesLength);
11707
11734
  addressTableLookups.push({
11708
11735
  accountKey,
11709
11736
  writableIndexes,
@@ -12443,8 +12470,7 @@ var solanaWeb3 = (function (exports) {
12443
12470
  let signatures = [];
12444
12471
 
12445
12472
  for (let i = 0; i < signatureCount; i++) {
12446
- const signature = byteArray.slice(0, SIGNATURE_LENGTH_IN_BYTES);
12447
- byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
12473
+ const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
12448
12474
  signatures.push(bs58$1.encode(buffer.Buffer.from(signature)));
12449
12475
  }
12450
12476
 
@@ -12642,7 +12668,7 @@ var solanaWeb3 = (function (exports) {
12642
12668
  const signaturesLength = decodeLength(byteArray);
12643
12669
 
12644
12670
  for (let i = 0; i < signaturesLength; i++) {
12645
- signatures.push(new Uint8Array(byteArray.splice(0, SIGNATURE_LENGTH_IN_BYTES)));
12671
+ signatures.push(new Uint8Array(guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES)));
12646
12672
  }
12647
12673
 
12648
12674
  const message = VersionedMessage.deserialize(new Uint8Array(byteArray));
@@ -18324,7 +18350,7 @@ var solanaWeb3 = (function (exports) {
18324
18350
 
18325
18351
  /** @internal */
18326
18352
  const COMMON_HTTP_HEADERS = {
18327
- 'solana-client': `js/${(_process$env$npm_pack = "0.0.0-development") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
18353
+ 'solana-client': `js/${(_process$env$npm_pack = "1.70.4") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
18328
18354
  };
18329
18355
  /**
18330
18356
  * A connection to a fullnode JSON RPC endpoint
@@ -24960,10 +24986,8 @@ var solanaWeb3 = (function (exports) {
24960
24986
  const configKeys = [];
24961
24987
 
24962
24988
  for (let i = 0; i < 2; i++) {
24963
- const publicKey = new PublicKey(byteArray.slice(0, PUBLIC_KEY_LENGTH));
24964
- byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
24965
- const isSigner = byteArray.slice(0, 1)[0] === 1;
24966
- byteArray = byteArray.slice(1);
24989
+ const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
24990
+ const isSigner = guardedShift(byteArray) === 1;
24967
24991
  configKeys.push({
24968
24992
  publicKey,
24969
24993
  isSigner
@@ -25128,7 +25152,7 @@ var solanaWeb3 = (function (exports) {
25128
25152
  *
25129
25153
  * @param {Connection} connection
25130
25154
  * @param {Buffer} rawTransaction
25131
- * @param {BlockheightBasedTransactionConfirmationStrategy} confirmationStrategy
25155
+ * @param {TransactionConfirmationStrategy} confirmationStrategy
25132
25156
  * @param {ConfirmOptions} [options]
25133
25157
  * @returns {Promise<TransactionSignature>}
25134
25158
  */