@solana/web3.js 1.90.0 → 1.90.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
@@ -2381,11 +2381,11 @@ var solanaWeb3 = (function (exports) {
2381
2381
  }
2382
2382
  } (buffer));
2383
2383
 
2384
- function number$1(n) {
2384
+ function number$2(n) {
2385
2385
  if (!Number.isSafeInteger(n) || n < 0)
2386
2386
  throw new Error(`Wrong positive integer: ${n}`);
2387
2387
  }
2388
- function bytes(b, ...lengths) {
2388
+ function bytes$1(b, ...lengths) {
2389
2389
  if (!(b instanceof Uint8Array))
2390
2390
  throw new Error('Expected Uint8Array');
2391
2391
  if (lengths.length > 0 && !lengths.includes(b.length))
@@ -2394,17 +2394,17 @@ var solanaWeb3 = (function (exports) {
2394
2394
  function hash(hash) {
2395
2395
  if (typeof hash !== 'function' || typeof hash.create !== 'function')
2396
2396
  throw new Error('Hash should be wrapped by utils.wrapConstructor');
2397
- number$1(hash.outputLen);
2398
- number$1(hash.blockLen);
2397
+ number$2(hash.outputLen);
2398
+ number$2(hash.blockLen);
2399
2399
  }
2400
- function exists(instance, checkFinished = true) {
2400
+ function exists$1(instance, checkFinished = true) {
2401
2401
  if (instance.destroyed)
2402
2402
  throw new Error('Hash instance has been destroyed');
2403
2403
  if (checkFinished && instance.finished)
2404
2404
  throw new Error('Hash#digest() has already been called');
2405
2405
  }
2406
- function output(out, instance) {
2407
- bytes(out);
2406
+ function output$1(out, instance) {
2407
+ bytes$1(out);
2408
2408
  const min = instance.outputLen;
2409
2409
  if (out.length < min) {
2410
2410
  throw new Error(`digestInto() expects output buffer of length at least ${min}`);
@@ -2421,20 +2421,19 @@ var solanaWeb3 = (function (exports) {
2421
2421
  // Makes the utils un-importable in browsers without a bundler.
2422
2422
  // Once node.js 18 is deprecated, we can just drop the import.
2423
2423
  const u8a$1 = (a) => a instanceof Uint8Array;
2424
- const u32$1 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
2425
2424
  // Cast array to view
2426
- const createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
2425
+ const createView$1 = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
2427
2426
  // The rotate right (circular right shift) operation for uint32
2428
- const rotr = (word, shift) => (word << (32 - shift)) | (word >>> shift);
2427
+ const rotr$1 = (word, shift) => (word << (32 - shift)) | (word >>> shift);
2429
2428
  // big-endian hardware is rare. Just in case someone still decides to run hashes:
2430
2429
  // early-throw an error because we don't support BE yet.
2431
- const isLE = new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44;
2432
- if (!isLE)
2430
+ const isLE$1 = new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44;
2431
+ if (!isLE$1)
2433
2432
  throw new Error('Non little-endian hardware is not supported');
2434
2433
  /**
2435
2434
  * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])
2436
2435
  */
2437
- function utf8ToBytes$1(str) {
2436
+ function utf8ToBytes$2(str) {
2438
2437
  if (typeof str !== 'string')
2439
2438
  throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
2440
2439
  return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
@@ -2444,9 +2443,9 @@ var solanaWeb3 = (function (exports) {
2444
2443
  * Warning: when Uint8Array is passed, it would NOT get copied.
2445
2444
  * Keep in mind for future mutable operations.
2446
2445
  */
2447
- function toBytes(data) {
2446
+ function toBytes$1(data) {
2448
2447
  if (typeof data === 'string')
2449
- data = utf8ToBytes$1(data);
2448
+ data = utf8ToBytes$2(data);
2450
2449
  if (!u8a$1(data))
2451
2450
  throw new Error(`expected Uint8Array, got ${typeof data}`);
2452
2451
  return data;
@@ -2466,14 +2465,14 @@ var solanaWeb3 = (function (exports) {
2466
2465
  return r;
2467
2466
  }
2468
2467
  // For runtime check if class implements interface
2469
- class Hash {
2468
+ let Hash$1 = class Hash {
2470
2469
  // Safe version that clones internal state
2471
2470
  clone() {
2472
2471
  return this._cloneInto();
2473
2472
  }
2474
- }
2475
- function wrapConstructor(hashCons) {
2476
- const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
2473
+ };
2474
+ function wrapConstructor$1(hashCons) {
2475
+ const hashC = (msg) => hashCons().update(toBytes$1(msg)).digest();
2477
2476
  const tmp = hashCons();
2478
2477
  hashC.outputLen = tmp.outputLen;
2479
2478
  hashC.blockLen = tmp.blockLen;
@@ -2491,7 +2490,7 @@ var solanaWeb3 = (function (exports) {
2491
2490
  }
2492
2491
 
2493
2492
  // Polyfill for Safari 14
2494
- function setBigUint64(view, byteOffset, value, isLE) {
2493
+ function setBigUint64$1(view, byteOffset, value, isLE) {
2495
2494
  if (typeof view.setBigUint64 === 'function')
2496
2495
  return view.setBigUint64(byteOffset, value, isLE);
2497
2496
  const _32n = BigInt(32);
@@ -2504,7 +2503,7 @@ var solanaWeb3 = (function (exports) {
2504
2503
  view.setUint32(byteOffset + l, wl, isLE);
2505
2504
  }
2506
2505
  // Base SHA2 class (RFC 6234)
2507
- class SHA2 extends Hash {
2506
+ let SHA2$1 = class SHA2 extends Hash$1 {
2508
2507
  constructor(blockLen, outputLen, padOffset, isLE) {
2509
2508
  super();
2510
2509
  this.blockLen = blockLen;
@@ -2516,18 +2515,18 @@ var solanaWeb3 = (function (exports) {
2516
2515
  this.pos = 0;
2517
2516
  this.destroyed = false;
2518
2517
  this.buffer = new Uint8Array(blockLen);
2519
- this.view = createView(this.buffer);
2518
+ this.view = createView$1(this.buffer);
2520
2519
  }
2521
2520
  update(data) {
2522
- exists(this);
2521
+ exists$1(this);
2523
2522
  const { view, buffer, blockLen } = this;
2524
- data = toBytes(data);
2523
+ data = toBytes$1(data);
2525
2524
  const len = data.length;
2526
2525
  for (let pos = 0; pos < len;) {
2527
2526
  const take = Math.min(blockLen - this.pos, len - pos);
2528
2527
  // Fast path: we have at least one block in input, cast it to view and process
2529
2528
  if (take === blockLen) {
2530
- const dataView = createView(data);
2529
+ const dataView = createView$1(data);
2531
2530
  for (; blockLen <= len - pos; pos += blockLen)
2532
2531
  this.process(dataView, pos);
2533
2532
  continue;
@@ -2545,8 +2544,8 @@ var solanaWeb3 = (function (exports) {
2545
2544
  return this;
2546
2545
  }
2547
2546
  digestInto(out) {
2548
- exists(this);
2549
- output(out, this);
2547
+ exists$1(this);
2548
+ output$1(out, this);
2550
2549
  this.finished = true;
2551
2550
  // Padding
2552
2551
  // We can avoid allocation of buffer for padding completely if it
@@ -2567,9 +2566,9 @@ var solanaWeb3 = (function (exports) {
2567
2566
  // Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that
2568
2567
  // You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen.
2569
2568
  // So we just write lowest 64 bits of that value.
2570
- setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);
2569
+ setBigUint64$1(view, blockLen - 8, BigInt(this.length * 8), isLE);
2571
2570
  this.process(view, 0);
2572
- const oview = createView(out);
2571
+ const oview = createView$1(out);
2573
2572
  const len = this.outputLen;
2574
2573
  // NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT
2575
2574
  if (len % 4)
@@ -2600,26 +2599,26 @@ var solanaWeb3 = (function (exports) {
2600
2599
  to.buffer.set(buffer);
2601
2600
  return to;
2602
2601
  }
2603
- }
2602
+ };
2604
2603
 
2605
- const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
2606
- const _32n = /* @__PURE__ */ BigInt(32);
2604
+ const U32_MASK64$1 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
2605
+ const _32n$1 = /* @__PURE__ */ BigInt(32);
2607
2606
  // We are not using BigUint64Array, because they are extremely slow as per 2022
2608
- function fromBig(n, le = false) {
2607
+ function fromBig$1(n, le = false) {
2609
2608
  if (le)
2610
- return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) };
2611
- return { h: Number((n >> _32n) & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
2609
+ return { h: Number(n & U32_MASK64$1), l: Number((n >> _32n$1) & U32_MASK64$1) };
2610
+ return { h: Number((n >> _32n$1) & U32_MASK64$1) | 0, l: Number(n & U32_MASK64$1) | 0 };
2612
2611
  }
2613
- function split(lst, le = false) {
2612
+ function split$1(lst, le = false) {
2614
2613
  let Ah = new Uint32Array(lst.length);
2615
2614
  let Al = new Uint32Array(lst.length);
2616
2615
  for (let i = 0; i < lst.length; i++) {
2617
- const { h, l } = fromBig(lst[i], le);
2616
+ const { h, l } = fromBig$1(lst[i], le);
2618
2617
  [Ah[i], Al[i]] = [h, l];
2619
2618
  }
2620
2619
  return [Ah, Al];
2621
2620
  }
2622
- const toBig = (h, l) => (BigInt(h >>> 0) << _32n) | BigInt(l >>> 0);
2621
+ const toBig = (h, l) => (BigInt(h >>> 0) << _32n$1) | BigInt(l >>> 0);
2623
2622
  // for Shift in [0, 32)
2624
2623
  const shrSH = (h, _l, s) => h >>> s;
2625
2624
  const shrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);
@@ -2633,11 +2632,11 @@ var solanaWeb3 = (function (exports) {
2633
2632
  const rotr32H = (_h, l) => l;
2634
2633
  const rotr32L = (h, _l) => h;
2635
2634
  // Left rotate for Shift in [1, 32)
2636
- const rotlSH = (h, l, s) => (h << s) | (l >>> (32 - s));
2637
- const rotlSL = (h, l, s) => (l << s) | (h >>> (32 - s));
2635
+ const rotlSH$1 = (h, l, s) => (h << s) | (l >>> (32 - s));
2636
+ const rotlSL$1 = (h, l, s) => (l << s) | (h >>> (32 - s));
2638
2637
  // Left rotate for Shift in (32, 64), NOTE: 32 is special case.
2639
- const rotlBH = (h, l, s) => (l << (s - 32)) | (h >>> (64 - s));
2640
- const rotlBL = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s));
2638
+ const rotlBH$1 = (h, l, s) => (l << (s - 32)) | (h >>> (64 - s));
2639
+ const rotlBL$1 = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s));
2641
2640
  // JS uses 32-bit signed integers for bitwise operations which means we cannot
2642
2641
  // simple take carry out of low bit sum by shift, we need to use division.
2643
2642
  function add(Ah, Al, Bh, Bl) {
@@ -2653,11 +2652,11 @@ var solanaWeb3 = (function (exports) {
2653
2652
  const add5H = (low, Ah, Bh, Ch, Dh, Eh) => (Ah + Bh + Ch + Dh + Eh + ((low / 2 ** 32) | 0)) | 0;
2654
2653
  // prettier-ignore
2655
2654
  const u64$1 = {
2656
- fromBig, split, toBig,
2655
+ fromBig: fromBig$1, split: split$1, toBig,
2657
2656
  shrSH, shrSL,
2658
2657
  rotrSH, rotrSL, rotrBH, rotrBL,
2659
2658
  rotr32H, rotr32L,
2660
- rotlSH, rotlSL, rotlBH, rotlBL,
2659
+ rotlSH: rotlSH$1, rotlSL: rotlSL$1, rotlBH: rotlBH$1, rotlBL: rotlBL$1,
2661
2660
  add, add3L, add3H, add4L, add4H, add5H, add5L,
2662
2661
  };
2663
2662
  var u64$2 = u64$1;
@@ -2689,7 +2688,7 @@ var solanaWeb3 = (function (exports) {
2689
2688
  // Temporary buffer, not used to store anything between runs
2690
2689
  const SHA512_W_H = /* @__PURE__ */ new Uint32Array(80);
2691
2690
  const SHA512_W_L = /* @__PURE__ */ new Uint32Array(80);
2692
- class SHA512 extends SHA2 {
2691
+ class SHA512 extends SHA2$1 {
2693
2692
  constructor() {
2694
2693
  super(128, 64, 16, false);
2695
2694
  // We cannot use array here since array allows indexing by variable which means optimizer/compiler cannot use registers.
@@ -2816,7 +2815,7 @@ var solanaWeb3 = (function (exports) {
2816
2815
  this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
2817
2816
  }
2818
2817
  }
2819
- const sha512 = /* @__PURE__ */ wrapConstructor(() => new SHA512());
2818
+ const sha512 = /* @__PURE__ */ wrapConstructor$1(() => new SHA512());
2820
2819
 
2821
2820
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
2822
2821
  // 100 lines of code in the file are duplicated from noble-hashes (utils).
@@ -2948,7 +2947,7 @@ var solanaWeb3 = (function (exports) {
2948
2947
  /**
2949
2948
  * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])
2950
2949
  */
2951
- function utf8ToBytes(str) {
2950
+ function utf8ToBytes$1(str) {
2952
2951
  if (typeof str !== 'string')
2953
2952
  throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
2954
2953
  return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
@@ -3103,7 +3102,7 @@ var solanaWeb3 = (function (exports) {
3103
3102
  numberToBytesLE: numberToBytesLE,
3104
3103
  numberToHexUnpadded: numberToHexUnpadded,
3105
3104
  numberToVarBytesBE: numberToVarBytesBE,
3106
- utf8ToBytes: utf8ToBytes,
3105
+ utf8ToBytes: utf8ToBytes$1,
3107
3106
  validateObject: validateObject
3108
3107
  });
3109
3108
 
@@ -4132,7 +4131,7 @@ var solanaWeb3 = (function (exports) {
4132
4131
  function ed25519_domain(data, ctx, phflag) {
4133
4132
  if (ctx.length > 255)
4134
4133
  throw new Error('Context is too big');
4135
- return concatBytes$1(utf8ToBytes$1('SigEd25519 no Ed25519 collisions'), new Uint8Array([phflag ? 1 : 0, ctx.length]), ctx, data);
4134
+ return concatBytes$1(utf8ToBytes$2('SigEd25519 no Ed25519 collisions'), new Uint8Array([phflag ? 1 : 0, ctx.length]), ctx, data);
4136
4135
  }
4137
4136
  /* @__PURE__ */ twistedEdwards({
4138
4137
  ...ed25519Defaults,
@@ -7772,16 +7771,216 @@ var solanaWeb3 = (function (exports) {
7772
7771
 
7773
7772
  var bs58$1 = /*@__PURE__*/getDefaultExportFromCjs(bs58);
7774
7773
 
7774
+ function number$1(n) {
7775
+ if (!Number.isSafeInteger(n) || n < 0)
7776
+ throw new Error(`Wrong positive integer: ${n}`);
7777
+ }
7778
+ // copied from utils
7779
+ function isBytes$1(a) {
7780
+ return (a instanceof Uint8Array ||
7781
+ (a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array'));
7782
+ }
7783
+ function bytes(b, ...lengths) {
7784
+ if (!isBytes$1(b))
7785
+ throw new Error('Expected Uint8Array');
7786
+ if (lengths.length > 0 && !lengths.includes(b.length))
7787
+ throw new Error(`Expected Uint8Array of length ${lengths}, not of length=${b.length}`);
7788
+ }
7789
+ function exists(instance, checkFinished = true) {
7790
+ if (instance.destroyed)
7791
+ throw new Error('Hash instance has been destroyed');
7792
+ if (checkFinished && instance.finished)
7793
+ throw new Error('Hash#digest() has already been called');
7794
+ }
7795
+ function output(out, instance) {
7796
+ bytes(out);
7797
+ const min = instance.outputLen;
7798
+ if (out.length < min) {
7799
+ throw new Error(`digestInto() expects output buffer of length at least ${min}`);
7800
+ }
7801
+ }
7802
+
7803
+ /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
7804
+ // We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.
7805
+ // node.js versions earlier than v19 don't declare it in global scope.
7806
+ // For node.js, package.json#exports field mapping rewrites import
7807
+ // from `crypto` to `cryptoNode`, which imports native module.
7808
+ // Makes the utils un-importable in browsers without a bundler.
7809
+ // Once node.js 18 is deprecated (2025-04-30), we can just drop the import.
7810
+ const u32$1 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
7811
+ function isBytes(a) {
7812
+ return (a instanceof Uint8Array ||
7813
+ (a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array'));
7814
+ }
7815
+ // Cast array to view
7816
+ const createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
7817
+ // The rotate right (circular right shift) operation for uint32
7818
+ const rotr = (word, shift) => (word << (32 - shift)) | (word >>> shift);
7819
+ // big-endian hardware is rare. Just in case someone still decides to run hashes:
7820
+ // early-throw an error because we don't support BE yet.
7821
+ // Other libraries would silently corrupt the data instead of throwing an error,
7822
+ // when they don't support it.
7823
+ const isLE = new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44;
7824
+ if (!isLE)
7825
+ throw new Error('Non little-endian hardware is not supported');
7826
+ /**
7827
+ * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])
7828
+ */
7829
+ function utf8ToBytes(str) {
7830
+ if (typeof str !== 'string')
7831
+ throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
7832
+ return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
7833
+ }
7834
+ /**
7835
+ * Normalizes (non-hex) string or Uint8Array to Uint8Array.
7836
+ * Warning: when Uint8Array is passed, it would NOT get copied.
7837
+ * Keep in mind for future mutable operations.
7838
+ */
7839
+ function toBytes(data) {
7840
+ if (typeof data === 'string')
7841
+ data = utf8ToBytes(data);
7842
+ if (!isBytes(data))
7843
+ throw new Error(`expected Uint8Array, got ${typeof data}`);
7844
+ return data;
7845
+ }
7846
+ // For runtime check if class implements interface
7847
+ class Hash {
7848
+ // Safe version that clones internal state
7849
+ clone() {
7850
+ return this._cloneInto();
7851
+ }
7852
+ }
7853
+ function wrapConstructor(hashCons) {
7854
+ const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
7855
+ const tmp = hashCons();
7856
+ hashC.outputLen = tmp.outputLen;
7857
+ hashC.blockLen = tmp.blockLen;
7858
+ hashC.create = () => hashCons();
7859
+ return hashC;
7860
+ }
7861
+
7862
+ // Polyfill for Safari 14
7863
+ function setBigUint64(view, byteOffset, value, isLE) {
7864
+ if (typeof view.setBigUint64 === 'function')
7865
+ return view.setBigUint64(byteOffset, value, isLE);
7866
+ const _32n = BigInt(32);
7867
+ const _u32_max = BigInt(0xffffffff);
7868
+ const wh = Number((value >> _32n) & _u32_max);
7869
+ const wl = Number(value & _u32_max);
7870
+ const h = isLE ? 4 : 0;
7871
+ const l = isLE ? 0 : 4;
7872
+ view.setUint32(byteOffset + h, wh, isLE);
7873
+ view.setUint32(byteOffset + l, wl, isLE);
7874
+ }
7875
+ // Base SHA2 class (RFC 6234)
7876
+ class SHA2 extends Hash {
7877
+ constructor(blockLen, outputLen, padOffset, isLE) {
7878
+ super();
7879
+ this.blockLen = blockLen;
7880
+ this.outputLen = outputLen;
7881
+ this.padOffset = padOffset;
7882
+ this.isLE = isLE;
7883
+ this.finished = false;
7884
+ this.length = 0;
7885
+ this.pos = 0;
7886
+ this.destroyed = false;
7887
+ this.buffer = new Uint8Array(blockLen);
7888
+ this.view = createView(this.buffer);
7889
+ }
7890
+ update(data) {
7891
+ exists(this);
7892
+ const { view, buffer, blockLen } = this;
7893
+ data = toBytes(data);
7894
+ const len = data.length;
7895
+ for (let pos = 0; pos < len;) {
7896
+ const take = Math.min(blockLen - this.pos, len - pos);
7897
+ // Fast path: we have at least one block in input, cast it to view and process
7898
+ if (take === blockLen) {
7899
+ const dataView = createView(data);
7900
+ for (; blockLen <= len - pos; pos += blockLen)
7901
+ this.process(dataView, pos);
7902
+ continue;
7903
+ }
7904
+ buffer.set(data.subarray(pos, pos + take), this.pos);
7905
+ this.pos += take;
7906
+ pos += take;
7907
+ if (this.pos === blockLen) {
7908
+ this.process(view, 0);
7909
+ this.pos = 0;
7910
+ }
7911
+ }
7912
+ this.length += data.length;
7913
+ this.roundClean();
7914
+ return this;
7915
+ }
7916
+ digestInto(out) {
7917
+ exists(this);
7918
+ output(out, this);
7919
+ this.finished = true;
7920
+ // Padding
7921
+ // We can avoid allocation of buffer for padding completely if it
7922
+ // was previously not allocated here. But it won't change performance.
7923
+ const { buffer, view, blockLen, isLE } = this;
7924
+ let { pos } = this;
7925
+ // append the bit '1' to the message
7926
+ buffer[pos++] = 0b10000000;
7927
+ this.buffer.subarray(pos).fill(0);
7928
+ // we have less than padOffset left in buffer, so we cannot put length in current block, need process it and pad again
7929
+ if (this.padOffset > blockLen - pos) {
7930
+ this.process(view, 0);
7931
+ pos = 0;
7932
+ }
7933
+ // Pad until full block byte with zeros
7934
+ for (let i = pos; i < blockLen; i++)
7935
+ buffer[i] = 0;
7936
+ // Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that
7937
+ // You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen.
7938
+ // So we just write lowest 64 bits of that value.
7939
+ setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);
7940
+ this.process(view, 0);
7941
+ const oview = createView(out);
7942
+ const len = this.outputLen;
7943
+ // NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT
7944
+ if (len % 4)
7945
+ throw new Error('_sha2: outputLen should be aligned to 32bit');
7946
+ const outLen = len / 4;
7947
+ const state = this.get();
7948
+ if (outLen > state.length)
7949
+ throw new Error('_sha2: outputLen bigger than state');
7950
+ for (let i = 0; i < outLen; i++)
7951
+ oview.setUint32(4 * i, state[i], isLE);
7952
+ }
7953
+ digest() {
7954
+ const { buffer, outputLen } = this;
7955
+ this.digestInto(buffer);
7956
+ const res = buffer.slice(0, outputLen);
7957
+ this.destroy();
7958
+ return res;
7959
+ }
7960
+ _cloneInto(to) {
7961
+ to || (to = new this.constructor());
7962
+ to.set(...this.get());
7963
+ const { blockLen, buffer, length, finished, destroyed, pos } = this;
7964
+ to.length = length;
7965
+ to.pos = pos;
7966
+ to.finished = finished;
7967
+ to.destroyed = destroyed;
7968
+ if (length % blockLen)
7969
+ to.buffer.set(buffer);
7970
+ return to;
7971
+ }
7972
+ }
7973
+
7775
7974
  // SHA2-256 need to try 2^128 hashes to execute birthday attack.
7776
7975
  // BTC network is doing 2^67 hashes/sec as per early 2023.
7777
7976
  // Choice: a ? b : c
7778
- const Chi = (a, b, c) => (a & b) ^ (~a & c);
7977
+ const Chi$1 = (a, b, c) => (a & b) ^ (~a & c);
7779
7978
  // Majority function, true if any two inpust is true
7780
- const Maj = (a, b, c) => (a & b) ^ (a & c) ^ (b & c);
7979
+ const Maj$1 = (a, b, c) => (a & b) ^ (a & c) ^ (b & c);
7781
7980
  // Round constants:
7782
7981
  // first 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311)
7783
7982
  // prettier-ignore
7784
- const SHA256_K = /* @__PURE__ */ new Uint32Array([
7983
+ const SHA256_K$1 = /* @__PURE__ */ new Uint32Array([
7785
7984
  0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
7786
7985
  0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
7787
7986
  0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
@@ -7793,25 +7992,25 @@ var solanaWeb3 = (function (exports) {
7793
7992
  ]);
7794
7993
  // Initial state (first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19):
7795
7994
  // prettier-ignore
7796
- const IV = /* @__PURE__ */ new Uint32Array([
7995
+ const IV$1 = /* @__PURE__ */ new Uint32Array([
7797
7996
  0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
7798
7997
  ]);
7799
7998
  // Temporary buffer, not used to store anything between runs
7800
7999
  // Named this way because it matches specification.
7801
- const SHA256_W = /* @__PURE__ */ new Uint32Array(64);
7802
- class SHA256 extends SHA2 {
8000
+ const SHA256_W$1 = /* @__PURE__ */ new Uint32Array(64);
8001
+ let SHA256$1 = class SHA256 extends SHA2 {
7803
8002
  constructor() {
7804
8003
  super(64, 32, 8, false);
7805
8004
  // We cannot use array here since array allows indexing by variable
7806
8005
  // which means optimizer/compiler cannot use registers.
7807
- this.A = IV[0] | 0;
7808
- this.B = IV[1] | 0;
7809
- this.C = IV[2] | 0;
7810
- this.D = IV[3] | 0;
7811
- this.E = IV[4] | 0;
7812
- this.F = IV[5] | 0;
7813
- this.G = IV[6] | 0;
7814
- this.H = IV[7] | 0;
8006
+ this.A = IV$1[0] | 0;
8007
+ this.B = IV$1[1] | 0;
8008
+ this.C = IV$1[2] | 0;
8009
+ this.D = IV$1[3] | 0;
8010
+ this.E = IV$1[4] | 0;
8011
+ this.F = IV$1[5] | 0;
8012
+ this.G = IV$1[6] | 0;
8013
+ this.H = IV$1[7] | 0;
7815
8014
  }
7816
8015
  get() {
7817
8016
  const { A, B, C, D, E, F, G, H } = this;
@@ -7831,21 +8030,21 @@ var solanaWeb3 = (function (exports) {
7831
8030
  process(view, offset) {
7832
8031
  // Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array
7833
8032
  for (let i = 0; i < 16; i++, offset += 4)
7834
- SHA256_W[i] = view.getUint32(offset, false);
8033
+ SHA256_W$1[i] = view.getUint32(offset, false);
7835
8034
  for (let i = 16; i < 64; i++) {
7836
- const W15 = SHA256_W[i - 15];
7837
- const W2 = SHA256_W[i - 2];
8035
+ const W15 = SHA256_W$1[i - 15];
8036
+ const W2 = SHA256_W$1[i - 2];
7838
8037
  const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ (W15 >>> 3);
7839
8038
  const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ (W2 >>> 10);
7840
- SHA256_W[i] = (s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16]) | 0;
8039
+ SHA256_W$1[i] = (s1 + SHA256_W$1[i - 7] + s0 + SHA256_W$1[i - 16]) | 0;
7841
8040
  }
7842
8041
  // Compression function main loop, 64 rounds
7843
8042
  let { A, B, C, D, E, F, G, H } = this;
7844
8043
  for (let i = 0; i < 64; i++) {
7845
8044
  const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
7846
- const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;
8045
+ const T1 = (H + sigma1 + Chi$1(E, F, G) + SHA256_K$1[i] + SHA256_W$1[i]) | 0;
7847
8046
  const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);
7848
- const T2 = (sigma0 + Maj(A, B, C)) | 0;
8047
+ const T2 = (sigma0 + Maj$1(A, B, C)) | 0;
7849
8048
  H = G;
7850
8049
  G = F;
7851
8050
  F = E;
@@ -7867,18 +8066,18 @@ var solanaWeb3 = (function (exports) {
7867
8066
  this.set(A, B, C, D, E, F, G, H);
7868
8067
  }
7869
8068
  roundClean() {
7870
- SHA256_W.fill(0);
8069
+ SHA256_W$1.fill(0);
7871
8070
  }
7872
8071
  destroy() {
7873
8072
  this.set(0, 0, 0, 0, 0, 0, 0, 0);
7874
8073
  this.buffer.fill(0);
7875
8074
  }
7876
- }
8075
+ };
7877
8076
  /**
7878
8077
  * SHA2-256 hash function
7879
8078
  * @param message - data that would be hashed
7880
8079
  */
7881
- const sha256 = /* @__PURE__ */ wrapConstructor(() => new SHA256());
8080
+ const sha256$1 = /* @__PURE__ */ wrapConstructor(() => new SHA256$1());
7882
8081
 
7883
8082
  var lib = {};
7884
8083
 
@@ -9127,7 +9326,7 @@ var solanaWeb3 = (function (exports) {
9127
9326
  /* eslint-disable require-await */
9128
9327
  static async createWithSeed(fromPublicKey, seed, programId) {
9129
9328
  const buffer$1 = buffer.Buffer.concat([fromPublicKey.toBuffer(), buffer.Buffer.from(seed), programId.toBuffer()]);
9130
- const publicKeyBytes = sha256(buffer$1);
9329
+ const publicKeyBytes = sha256$1(buffer$1);
9131
9330
  return new PublicKey(publicKeyBytes);
9132
9331
  }
9133
9332
 
@@ -9144,7 +9343,7 @@ var solanaWeb3 = (function (exports) {
9144
9343
  buffer$1 = buffer.Buffer.concat([buffer$1, toBuffer(seed)]);
9145
9344
  });
9146
9345
  buffer$1 = buffer.Buffer.concat([buffer$1, programId.toBuffer(), buffer.Buffer.from('ProgramDerivedAddress')]);
9147
- const publicKeyBytes = sha256(buffer$1);
9346
+ const publicKeyBytes = sha256$1(buffer$1);
9148
9347
  if (isOnCurve(publicKeyBytes)) {
9149
9348
  throw new Error(`Invalid seeds, address must fall off the curve`);
9150
9349
  }
@@ -11862,6 +12061,31 @@ var solanaWeb3 = (function (exports) {
11862
12061
  }
11863
12062
  }
11864
12063
 
12064
+ const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
12065
+
12066
+ /**
12067
+ * Delegates to `Array#shift`, but throws if the array is zero-length.
12068
+ */
12069
+ function guardedShift(byteArray) {
12070
+ if (byteArray.length === 0) {
12071
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
12072
+ }
12073
+ return byteArray.shift();
12074
+ }
12075
+
12076
+ /**
12077
+ * Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
12078
+ * the array.
12079
+ */
12080
+ function guardedSplice(byteArray, ...args) {
12081
+ const [start] = args;
12082
+ if (args.length === 2 // Implies that `deleteCount` was supplied
12083
+ ? start + (args[1] ?? 0) > byteArray.length : start >= byteArray.length) {
12084
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
12085
+ }
12086
+ return byteArray.splice(...args);
12087
+ }
12088
+
11865
12089
  /**
11866
12090
  * An instruction to execute by a program
11867
12091
  *
@@ -12003,32 +12227,28 @@ var solanaWeb3 = (function (exports) {
12003
12227
  static from(buffer$1) {
12004
12228
  // Slice up wire data
12005
12229
  let byteArray = [...buffer$1];
12006
- const numRequiredSignatures = byteArray.shift();
12230
+ const numRequiredSignatures = guardedShift(byteArray);
12007
12231
  if (numRequiredSignatures !== (numRequiredSignatures & VERSION_PREFIX_MASK)) {
12008
12232
  throw new Error('Versioned messages must be deserialized with VersionedMessage.deserialize()');
12009
12233
  }
12010
- const numReadonlySignedAccounts = byteArray.shift();
12011
- const numReadonlyUnsignedAccounts = byteArray.shift();
12234
+ const numReadonlySignedAccounts = guardedShift(byteArray);
12235
+ const numReadonlyUnsignedAccounts = guardedShift(byteArray);
12012
12236
  const accountCount = decodeLength(byteArray);
12013
12237
  let accountKeys = [];
12014
12238
  for (let i = 0; i < accountCount; i++) {
12015
- const account = byteArray.slice(0, PUBLIC_KEY_LENGTH);
12016
- byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
12239
+ const account = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
12017
12240
  accountKeys.push(new PublicKey(buffer.Buffer.from(account)));
12018
12241
  }
12019
- const recentBlockhash = byteArray.slice(0, PUBLIC_KEY_LENGTH);
12020
- byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
12242
+ const recentBlockhash = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
12021
12243
  const instructionCount = decodeLength(byteArray);
12022
12244
  let instructions = [];
12023
12245
  for (let i = 0; i < instructionCount; i++) {
12024
- const programIdIndex = byteArray.shift();
12246
+ const programIdIndex = guardedShift(byteArray);
12025
12247
  const accountCount = decodeLength(byteArray);
12026
- const accounts = byteArray.slice(0, accountCount);
12027
- byteArray = byteArray.slice(accountCount);
12248
+ const accounts = guardedSplice(byteArray, 0, accountCount);
12028
12249
  const dataLength = decodeLength(byteArray);
12029
- const dataSlice = byteArray.slice(0, dataLength);
12250
+ const dataSlice = guardedSplice(byteArray, 0, dataLength);
12030
12251
  const data = bs58$1.encode(buffer.Buffer.from(dataSlice));
12031
- byteArray = byteArray.slice(dataLength);
12032
12252
  instructions.push({
12033
12253
  programIdIndex,
12034
12254
  accounts,
@@ -12233,30 +12453,30 @@ var solanaWeb3 = (function (exports) {
12233
12453
  }
12234
12454
  static deserialize(serializedMessage) {
12235
12455
  let byteArray = [...serializedMessage];
12236
- const prefix = byteArray.shift();
12456
+ const prefix = guardedShift(byteArray);
12237
12457
  const maskedPrefix = prefix & VERSION_PREFIX_MASK;
12238
12458
  assert$1(prefix !== maskedPrefix, `Expected versioned message but received legacy message`);
12239
12459
  const version = maskedPrefix;
12240
12460
  assert$1(version === 0, `Expected versioned message with version 0 but found version ${version}`);
12241
12461
  const header = {
12242
- numRequiredSignatures: byteArray.shift(),
12243
- numReadonlySignedAccounts: byteArray.shift(),
12244
- numReadonlyUnsignedAccounts: byteArray.shift()
12462
+ numRequiredSignatures: guardedShift(byteArray),
12463
+ numReadonlySignedAccounts: guardedShift(byteArray),
12464
+ numReadonlyUnsignedAccounts: guardedShift(byteArray)
12245
12465
  };
12246
12466
  const staticAccountKeys = [];
12247
12467
  const staticAccountKeysLength = decodeLength(byteArray);
12248
12468
  for (let i = 0; i < staticAccountKeysLength; i++) {
12249
- staticAccountKeys.push(new PublicKey(byteArray.splice(0, PUBLIC_KEY_LENGTH)));
12469
+ staticAccountKeys.push(new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH)));
12250
12470
  }
12251
- const recentBlockhash = bs58$1.encode(byteArray.splice(0, PUBLIC_KEY_LENGTH));
12471
+ const recentBlockhash = bs58$1.encode(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
12252
12472
  const instructionCount = decodeLength(byteArray);
12253
12473
  const compiledInstructions = [];
12254
12474
  for (let i = 0; i < instructionCount; i++) {
12255
- const programIdIndex = byteArray.shift();
12475
+ const programIdIndex = guardedShift(byteArray);
12256
12476
  const accountKeyIndexesLength = decodeLength(byteArray);
12257
- const accountKeyIndexes = byteArray.splice(0, accountKeyIndexesLength);
12477
+ const accountKeyIndexes = guardedSplice(byteArray, 0, accountKeyIndexesLength);
12258
12478
  const dataLength = decodeLength(byteArray);
12259
- const data = new Uint8Array(byteArray.splice(0, dataLength));
12479
+ const data = new Uint8Array(guardedSplice(byteArray, 0, dataLength));
12260
12480
  compiledInstructions.push({
12261
12481
  programIdIndex,
12262
12482
  accountKeyIndexes,
@@ -12266,11 +12486,11 @@ var solanaWeb3 = (function (exports) {
12266
12486
  const addressTableLookupsCount = decodeLength(byteArray);
12267
12487
  const addressTableLookups = [];
12268
12488
  for (let i = 0; i < addressTableLookupsCount; i++) {
12269
- const accountKey = new PublicKey(byteArray.splice(0, PUBLIC_KEY_LENGTH));
12489
+ const accountKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
12270
12490
  const writableIndexesLength = decodeLength(byteArray);
12271
- const writableIndexes = byteArray.splice(0, writableIndexesLength);
12491
+ const writableIndexes = guardedSplice(byteArray, 0, writableIndexesLength);
12272
12492
  const readonlyIndexesLength = decodeLength(byteArray);
12273
- const readonlyIndexes = byteArray.splice(0, readonlyIndexesLength);
12493
+ const readonlyIndexes = guardedSplice(byteArray, 0, readonlyIndexesLength);
12274
12494
  addressTableLookups.push({
12275
12495
  accountKey,
12276
12496
  writableIndexes,
@@ -13061,8 +13281,7 @@ var solanaWeb3 = (function (exports) {
13061
13281
  const signatureCount = decodeLength(byteArray);
13062
13282
  let signatures = [];
13063
13283
  for (let i = 0; i < signatureCount; i++) {
13064
- const signature = byteArray.slice(0, SIGNATURE_LENGTH_IN_BYTES);
13065
- byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
13284
+ const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
13066
13285
  signatures.push(bs58$1.encode(buffer.Buffer.from(signature)));
13067
13286
  }
13068
13287
  return Transaction.populate(Message.from(byteArray), signatures);
@@ -13237,7 +13456,7 @@ var solanaWeb3 = (function (exports) {
13237
13456
  const signatures = [];
13238
13457
  const signaturesLength = decodeLength(byteArray);
13239
13458
  for (let i = 0; i < signaturesLength; i++) {
13240
- signatures.push(new Uint8Array(byteArray.splice(0, SIGNATURE_LENGTH_IN_BYTES)));
13459
+ signatures.push(new Uint8Array(guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES)));
13241
13460
  }
13242
13461
  const message = VersionedMessage.deserialize(new Uint8Array(byteArray));
13243
13462
  return new VersionedTransaction(message, signatures);
@@ -19369,7 +19588,7 @@ var solanaWeb3 = (function (exports) {
19369
19588
 
19370
19589
  /** @internal */
19371
19590
  const COMMON_HTTP_HEADERS = {
19372
- 'solana-client': `js/${"0.0.0-development" }`
19591
+ 'solana-client': `js/${"1.90.2" }`
19373
19592
  };
19374
19593
 
19375
19594
  /**
@@ -22917,6 +23136,30 @@ var solanaWeb3 = (function (exports) {
22917
23136
  }
22918
23137
  Ed25519Program.programId = new PublicKey('Ed25519SigVerify111111111111111111111111111');
22919
23138
 
23139
+ const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
23140
+ const _32n = /* @__PURE__ */ BigInt(32);
23141
+ // We are not using BigUint64Array, because they are extremely slow as per 2022
23142
+ function fromBig(n, le = false) {
23143
+ if (le)
23144
+ return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) };
23145
+ return { h: Number((n >> _32n) & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
23146
+ }
23147
+ function split(lst, le = false) {
23148
+ let Ah = new Uint32Array(lst.length);
23149
+ let Al = new Uint32Array(lst.length);
23150
+ for (let i = 0; i < lst.length; i++) {
23151
+ const { h, l } = fromBig(lst[i], le);
23152
+ [Ah[i], Al[i]] = [h, l];
23153
+ }
23154
+ return [Ah, Al];
23155
+ }
23156
+ // Left rotate for Shift in [1, 32)
23157
+ const rotlSH = (h, l, s) => (h << s) | (l >>> (32 - s));
23158
+ const rotlSL = (h, l, s) => (l << s) | (h >>> (32 - s));
23159
+ // Left rotate for Shift in (32, 64), NOTE: 32 is special case.
23160
+ const rotlBH = (h, l, s) => (l << (s - 32)) | (h >>> (64 - s));
23161
+ const rotlBL = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s));
23162
+
22920
23163
  // SHA3 (keccak) is based on a new design: basically, the internal state is bigger than output size.
22921
23164
  // It's called a sponge function.
22922
23165
  // Various per round constants calculations
@@ -23108,6 +23351,114 @@ var solanaWeb3 = (function (exports) {
23108
23351
  */
23109
23352
  const keccak_256 = /* @__PURE__ */ gen(0x01, 136, 256 / 8);
23110
23353
 
23354
+ // SHA2-256 need to try 2^128 hashes to execute birthday attack.
23355
+ // BTC network is doing 2^67 hashes/sec as per early 2023.
23356
+ // Choice: a ? b : c
23357
+ const Chi = (a, b, c) => (a & b) ^ (~a & c);
23358
+ // Majority function, true if any two inpust is true
23359
+ const Maj = (a, b, c) => (a & b) ^ (a & c) ^ (b & c);
23360
+ // Round constants:
23361
+ // first 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311)
23362
+ // prettier-ignore
23363
+ const SHA256_K = /* @__PURE__ */ new Uint32Array([
23364
+ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
23365
+ 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
23366
+ 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
23367
+ 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
23368
+ 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
23369
+ 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
23370
+ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
23371
+ 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
23372
+ ]);
23373
+ // Initial state (first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19):
23374
+ // prettier-ignore
23375
+ const IV = /* @__PURE__ */ new Uint32Array([
23376
+ 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
23377
+ ]);
23378
+ // Temporary buffer, not used to store anything between runs
23379
+ // Named this way because it matches specification.
23380
+ const SHA256_W = /* @__PURE__ */ new Uint32Array(64);
23381
+ class SHA256 extends SHA2$1 {
23382
+ constructor() {
23383
+ super(64, 32, 8, false);
23384
+ // We cannot use array here since array allows indexing by variable
23385
+ // which means optimizer/compiler cannot use registers.
23386
+ this.A = IV[0] | 0;
23387
+ this.B = IV[1] | 0;
23388
+ this.C = IV[2] | 0;
23389
+ this.D = IV[3] | 0;
23390
+ this.E = IV[4] | 0;
23391
+ this.F = IV[5] | 0;
23392
+ this.G = IV[6] | 0;
23393
+ this.H = IV[7] | 0;
23394
+ }
23395
+ get() {
23396
+ const { A, B, C, D, E, F, G, H } = this;
23397
+ return [A, B, C, D, E, F, G, H];
23398
+ }
23399
+ // prettier-ignore
23400
+ set(A, B, C, D, E, F, G, H) {
23401
+ this.A = A | 0;
23402
+ this.B = B | 0;
23403
+ this.C = C | 0;
23404
+ this.D = D | 0;
23405
+ this.E = E | 0;
23406
+ this.F = F | 0;
23407
+ this.G = G | 0;
23408
+ this.H = H | 0;
23409
+ }
23410
+ process(view, offset) {
23411
+ // Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array
23412
+ for (let i = 0; i < 16; i++, offset += 4)
23413
+ SHA256_W[i] = view.getUint32(offset, false);
23414
+ for (let i = 16; i < 64; i++) {
23415
+ const W15 = SHA256_W[i - 15];
23416
+ const W2 = SHA256_W[i - 2];
23417
+ const s0 = rotr$1(W15, 7) ^ rotr$1(W15, 18) ^ (W15 >>> 3);
23418
+ const s1 = rotr$1(W2, 17) ^ rotr$1(W2, 19) ^ (W2 >>> 10);
23419
+ SHA256_W[i] = (s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16]) | 0;
23420
+ }
23421
+ // Compression function main loop, 64 rounds
23422
+ let { A, B, C, D, E, F, G, H } = this;
23423
+ for (let i = 0; i < 64; i++) {
23424
+ const sigma1 = rotr$1(E, 6) ^ rotr$1(E, 11) ^ rotr$1(E, 25);
23425
+ const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;
23426
+ const sigma0 = rotr$1(A, 2) ^ rotr$1(A, 13) ^ rotr$1(A, 22);
23427
+ const T2 = (sigma0 + Maj(A, B, C)) | 0;
23428
+ H = G;
23429
+ G = F;
23430
+ F = E;
23431
+ E = (D + T1) | 0;
23432
+ D = C;
23433
+ C = B;
23434
+ B = A;
23435
+ A = (T1 + T2) | 0;
23436
+ }
23437
+ // Add the compressed chunk to the current hash value
23438
+ A = (A + this.A) | 0;
23439
+ B = (B + this.B) | 0;
23440
+ C = (C + this.C) | 0;
23441
+ D = (D + this.D) | 0;
23442
+ E = (E + this.E) | 0;
23443
+ F = (F + this.F) | 0;
23444
+ G = (G + this.G) | 0;
23445
+ H = (H + this.H) | 0;
23446
+ this.set(A, B, C, D, E, F, G, H);
23447
+ }
23448
+ roundClean() {
23449
+ SHA256_W.fill(0);
23450
+ }
23451
+ destroy() {
23452
+ this.set(0, 0, 0, 0, 0, 0, 0, 0);
23453
+ this.buffer.fill(0);
23454
+ }
23455
+ }
23456
+ /**
23457
+ * SHA2-256 hash function
23458
+ * @param message - data that would be hashed
23459
+ */
23460
+ const sha256 = /* @__PURE__ */ wrapConstructor$1(() => new SHA256());
23461
+
23111
23462
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
23112
23463
  // Short Weierstrass curve. The formula is: y² = x³ + ax + b
23113
23464
  function validatePointOpts(curve) {
@@ -24039,13 +24390,13 @@ var solanaWeb3 = (function (exports) {
24039
24390
  }
24040
24391
 
24041
24392
  // HMAC (RFC 2104)
24042
- class HMAC extends Hash {
24393
+ class HMAC extends Hash$1 {
24043
24394
  constructor(hash$1, _key) {
24044
24395
  super();
24045
24396
  this.finished = false;
24046
24397
  this.destroyed = false;
24047
24398
  hash(hash$1);
24048
- const key = toBytes(_key);
24399
+ const key = toBytes$1(_key);
24049
24400
  this.iHash = hash$1.create();
24050
24401
  if (typeof this.iHash.update !== 'function')
24051
24402
  throw new Error('Expected instance of class which extends utils.Hash');
@@ -24067,13 +24418,13 @@ var solanaWeb3 = (function (exports) {
24067
24418
  pad.fill(0);
24068
24419
  }
24069
24420
  update(buf) {
24070
- exists(this);
24421
+ exists$1(this);
24071
24422
  this.iHash.update(buf);
24072
24423
  return this;
24073
24424
  }
24074
24425
  digestInto(out) {
24075
- exists(this);
24076
- bytes(out, this.outputLen);
24426
+ exists$1(this);
24427
+ bytes$1(out, this.outputLen);
24077
24428
  this.finished = true;
24078
24429
  this.iHash.digestInto(out);
24079
24430
  this.oHash.update(out);
@@ -24971,12 +25322,14 @@ var solanaWeb3 = (function (exports) {
24971
25322
  /**
24972
25323
  * Generate a Transaction that splits Stake tokens into another stake account
24973
25324
  */
24974
- static split(params) {
25325
+ static split(params,
25326
+ // Compute the cost of allocating the new stake account in lamports
25327
+ rentExemptReserve) {
24975
25328
  const transaction = new Transaction();
24976
25329
  transaction.add(SystemProgram.createAccount({
24977
25330
  fromPubkey: params.authorizedPubkey,
24978
25331
  newAccountPubkey: params.splitStakePubkey,
24979
- lamports: 0,
25332
+ lamports: rentExemptReserve,
24980
25333
  space: this.space,
24981
25334
  programId: this.programId
24982
25335
  }));
@@ -24987,7 +25340,9 @@ var solanaWeb3 = (function (exports) {
24987
25340
  * Generate a Transaction that splits Stake tokens into another account
24988
25341
  * derived from a base public key and seed
24989
25342
  */
24990
- static splitWithSeed(params) {
25343
+ static splitWithSeed(params,
25344
+ // If this stake account is new, compute the cost of allocating it in lamports
25345
+ rentExemptReserve) {
24991
25346
  const {
24992
25347
  stakePubkey,
24993
25348
  authorizedPubkey,
@@ -25004,6 +25359,13 @@ var solanaWeb3 = (function (exports) {
25004
25359
  space: this.space,
25005
25360
  programId: this.programId
25006
25361
  }));
25362
+ if (rentExemptReserve && rentExemptReserve > 0) {
25363
+ transaction.add(SystemProgram.transfer({
25364
+ fromPubkey: params.authorizedPubkey,
25365
+ toPubkey: splitStakePubkey,
25366
+ lamports: rentExemptReserve
25367
+ }));
25368
+ }
25007
25369
  return transaction.add(this.splitInstruction({
25008
25370
  stakePubkey,
25009
25371
  authorizedPubkey,
@@ -25134,8 +25496,8 @@ var solanaWeb3 = (function (exports) {
25134
25496
  * Max space of a Stake account
25135
25497
  *
25136
25498
  * This is generated from the solana-stake-program StakeState struct as
25137
- * `StakeState::size_of()`:
25138
- * https://docs.rs/solana-stake-program/latest/solana_stake_program/stake_state/enum.StakeState.html
25499
+ * `StakeStateV2::size_of()`:
25500
+ * https://docs.rs/solana-stake-program/latest/solana_stake_program/stake_state/enum.StakeStateV2.html
25139
25501
  */
25140
25502
  StakeProgram.space = 200;
25141
25503
 
@@ -25610,10 +25972,8 @@ var solanaWeb3 = (function (exports) {
25610
25972
  if (configKeyCount !== 2) return null;
25611
25973
  const configKeys = [];
25612
25974
  for (let i = 0; i < 2; i++) {
25613
- const publicKey = new PublicKey(byteArray.slice(0, PUBLIC_KEY_LENGTH));
25614
- byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
25615
- const isSigner = byteArray.slice(0, 1)[0] === 1;
25616
- byteArray = byteArray.slice(1);
25975
+ const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
25976
+ const isSigner = guardedShift(byteArray) === 1;
25617
25977
  configKeys.push({
25618
25978
  publicKey,
25619
25979
  isSigner