@pooflabs/web 0.0.19 → 0.0.21

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/dist/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import globalAxios from 'axios';
2
- import { ComputeBudgetProgram, VersionedTransaction, TransactionMessage, PublicKey, SystemProgram, TransactionInstruction, Keypair, Transaction as Transaction$1, Connection } from '@solana/web3.js';
2
+ import { PublicKey, SystemProgram, TransactionInstruction, ComputeBudgetProgram, VersionedTransaction, TransactionMessage, Keypair, Transaction as Transaction$1, Connection } from '@solana/web3.js';
3
3
  import * as anchor from '@coral-xyz/anchor';
4
4
  import { Program } from '@coral-xyz/anchor';
5
5
  import * as React$1 from 'react';
@@ -4831,176 +4831,6 @@ function requireNaclFast () {
4831
4831
  var naclFastExports = requireNaclFast();
4832
4832
  var nacl = /*@__PURE__*/getDefaultExportFromCjs$1(naclFastExports);
4833
4833
 
4834
- // base-x encoding / decoding
4835
- // Copyright (c) 2018 base-x contributors
4836
- // Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
4837
- // Distributed under the MIT software license, see the accompanying
4838
- // file LICENSE or http://www.opensource.org/licenses/mit-license.php.
4839
- function base$1 (ALPHABET) {
4840
- if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }
4841
- const BASE_MAP = new Uint8Array(256);
4842
- for (let j = 0; j < BASE_MAP.length; j++) {
4843
- BASE_MAP[j] = 255;
4844
- }
4845
- for (let i = 0; i < ALPHABET.length; i++) {
4846
- const x = ALPHABET.charAt(i);
4847
- const xc = x.charCodeAt(0);
4848
- if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }
4849
- BASE_MAP[xc] = i;
4850
- }
4851
- const BASE = ALPHABET.length;
4852
- const LEADER = ALPHABET.charAt(0);
4853
- const FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up
4854
- const iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up
4855
- function encode (source) {
4856
- // eslint-disable-next-line no-empty
4857
- if (source instanceof Uint8Array) ; else if (ArrayBuffer.isView(source)) {
4858
- source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
4859
- } else if (Array.isArray(source)) {
4860
- source = Uint8Array.from(source);
4861
- }
4862
- if (!(source instanceof Uint8Array)) { throw new TypeError('Expected Uint8Array') }
4863
- if (source.length === 0) { return '' }
4864
- // Skip & count leading zeroes.
4865
- let zeroes = 0;
4866
- let length = 0;
4867
- let pbegin = 0;
4868
- const pend = source.length;
4869
- while (pbegin !== pend && source[pbegin] === 0) {
4870
- pbegin++;
4871
- zeroes++;
4872
- }
4873
- // Allocate enough space in big-endian base58 representation.
4874
- const size = ((pend - pbegin) * iFACTOR + 1) >>> 0;
4875
- const b58 = new Uint8Array(size);
4876
- // Process the bytes.
4877
- while (pbegin !== pend) {
4878
- let carry = source[pbegin];
4879
- // Apply "b58 = b58 * 256 + ch".
4880
- let i = 0;
4881
- for (let it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
4882
- carry += (256 * b58[it1]) >>> 0;
4883
- b58[it1] = (carry % BASE) >>> 0;
4884
- carry = (carry / BASE) >>> 0;
4885
- }
4886
- if (carry !== 0) { throw new Error('Non-zero carry') }
4887
- length = i;
4888
- pbegin++;
4889
- }
4890
- // Skip leading zeroes in base58 result.
4891
- let it2 = size - length;
4892
- while (it2 !== size && b58[it2] === 0) {
4893
- it2++;
4894
- }
4895
- // Translate the result into a string.
4896
- let str = LEADER.repeat(zeroes);
4897
- for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]); }
4898
- return str
4899
- }
4900
- function decodeUnsafe (source) {
4901
- if (typeof source !== 'string') { throw new TypeError('Expected String') }
4902
- if (source.length === 0) { return new Uint8Array() }
4903
- let psz = 0;
4904
- // Skip and count leading '1's.
4905
- let zeroes = 0;
4906
- let length = 0;
4907
- while (source[psz] === LEADER) {
4908
- zeroes++;
4909
- psz++;
4910
- }
4911
- // Allocate enough space in big-endian base256 representation.
4912
- const size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.
4913
- const b256 = new Uint8Array(size);
4914
- // Process the characters.
4915
- while (psz < source.length) {
4916
- // Find code of next character
4917
- const charCode = source.charCodeAt(psz);
4918
- // Base map can not be indexed using char code
4919
- if (charCode > 255) { return }
4920
- // Decode character
4921
- let carry = BASE_MAP[charCode];
4922
- // Invalid character
4923
- if (carry === 255) { return }
4924
- let i = 0;
4925
- for (let it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
4926
- carry += (BASE * b256[it3]) >>> 0;
4927
- b256[it3] = (carry % 256) >>> 0;
4928
- carry = (carry / 256) >>> 0;
4929
- }
4930
- if (carry !== 0) { throw new Error('Non-zero carry') }
4931
- length = i;
4932
- psz++;
4933
- }
4934
- // Skip leading zeroes in b256.
4935
- let it4 = size - length;
4936
- while (it4 !== size && b256[it4] === 0) {
4937
- it4++;
4938
- }
4939
- const vch = new Uint8Array(zeroes + (size - it4));
4940
- let j = zeroes;
4941
- while (it4 !== size) {
4942
- vch[j++] = b256[it4++];
4943
- }
4944
- return vch
4945
- }
4946
- function decode (string) {
4947
- const buffer = decodeUnsafe(string);
4948
- if (buffer) { return buffer }
4949
- throw new Error('Non-base' + BASE + ' character')
4950
- }
4951
- return {
4952
- encode,
4953
- decodeUnsafe,
4954
- decode
4955
- }
4956
- }
4957
-
4958
- var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
4959
- var ue$3 = base$1(ALPHABET);
4960
-
4961
- /**
4962
- * Check if a given instruction is a SetComputeUnitLimit instruction
4963
- * See https://github.com/solana-program/compute-budget/blob/main/clients/js/src/generated/programs/computeBudget.ts#L29
4964
- */
4965
- function isSetComputeLimitInstruction(ix) {
4966
- return (ix.programId.equals(ComputeBudgetProgram.programId) && ix.data[0] === 2 // opcode for setComputeUnitLimit is 2
4967
- );
4968
- }
4969
- // Was getSimulationUnits
4970
- // Credit https://twitter.com/stegabob, originally from
4971
- // https://x.com/stegaBOB/status/1766662289392889920
4972
- const getSimulationComputeUnits = async (connection, instructions, payer, lookupTables, commitment = "confirmed") => {
4973
- const simulationInstructions = [...instructions];
4974
- // Replace or add compute limit instruction
4975
- const computeLimitIndex = simulationInstructions.findIndex(isSetComputeLimitInstruction);
4976
- const simulationLimitIx = ComputeBudgetProgram.setComputeUnitLimit({
4977
- units: 1_400_000,
4978
- });
4979
- if (computeLimitIndex >= 0) {
4980
- simulationInstructions[computeLimitIndex] = simulationLimitIx;
4981
- }
4982
- else {
4983
- simulationInstructions.unshift(simulationLimitIx);
4984
- }
4985
- const testTransaction = new VersionedTransaction(new TransactionMessage({
4986
- instructions: simulationInstructions,
4987
- payerKey: payer,
4988
- // RecentBlockhash can by any public key during simulation
4989
- // since 'replaceRecentBlockhash' is set to 'true' below
4990
- recentBlockhash: PublicKey.default.toString(),
4991
- }).compileToV0Message(lookupTables));
4992
- const rpcResponse = await connection.simulateTransaction(testTransaction, {
4993
- replaceRecentBlockhash: true,
4994
- sigVerify: false,
4995
- commitment,
4996
- });
4997
- if (rpcResponse?.value?.err) {
4998
- const logs = rpcResponse.value.logs?.join("\n • ") || "No logs available";
4999
- throw new Error(`Transaction simulation failed:\n •${logs}` + JSON.stringify(rpcResponse?.value?.err));
5000
- }
5001
- return rpcResponse.value.unitsConsumed || null;
5002
- };
5003
-
5004
4834
  var bn$3 = {exports: {}};
5005
4835
 
5006
4836
  var bn$2 = bn$3.exports;
@@ -8367,431 +8197,6 @@ function requireBn () {
8367
8197
  var bnExports = requireBn();
8368
8198
  var BN = /*@__PURE__*/getDefaultExportFromCjs$1(bnExports);
8369
8199
 
8370
- const crypto$3 = typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis.crypto : undefined;
8371
-
8372
- /**
8373
- * Utilities for hex, bytes, CSPRNG.
8374
- * @module
8375
- */
8376
- /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
8377
- // We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.
8378
- // node.js versions earlier than v19 don't declare it in global scope.
8379
- // For node.js, package.json#exports field mapping rewrites import
8380
- // from `crypto` to `cryptoNode`, which imports native module.
8381
- // Makes the utils un-importable in browsers without a bundler.
8382
- // Once node.js 18 is deprecated (2025-04-30), we can just drop the import.
8383
- /** Checks if something is Uint8Array. Be careful: nodejs Buffer will return true. */
8384
- function isBytes$2(a) {
8385
- return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');
8386
- }
8387
- /** Asserts something is positive integer. */
8388
- function anumber$1(n) {
8389
- if (!Number.isSafeInteger(n) || n < 0)
8390
- throw new Error('positive integer expected, got ' + n);
8391
- }
8392
- /** Asserts something is Uint8Array. */
8393
- function abytes$2(b, ...lengths) {
8394
- if (!isBytes$2(b))
8395
- throw new Error('Uint8Array expected');
8396
- if (lengths.length > 0 && !lengths.includes(b.length))
8397
- throw new Error('Uint8Array expected of length ' + lengths + ', got length=' + b.length);
8398
- }
8399
- /** Asserts something is hash */
8400
- function ahash(h) {
8401
- if (typeof h !== 'function' || typeof h.create !== 'function')
8402
- throw new Error('Hash should be wrapped by utils.createHasher');
8403
- anumber$1(h.outputLen);
8404
- anumber$1(h.blockLen);
8405
- }
8406
- /** Asserts a hash instance has not been destroyed / finished */
8407
- function aexists(instance, checkFinished = true) {
8408
- if (instance.destroyed)
8409
- throw new Error('Hash instance has been destroyed');
8410
- if (checkFinished && instance.finished)
8411
- throw new Error('Hash#digest() has already been called');
8412
- }
8413
- /** Asserts output is properly-sized byte array */
8414
- function aoutput(out, instance) {
8415
- abytes$2(out);
8416
- const min = instance.outputLen;
8417
- if (out.length < min) {
8418
- throw new Error('digestInto() expects output buffer of length at least ' + min);
8419
- }
8420
- }
8421
- /** Cast u8 / u16 / u32 to u32. */
8422
- function u32$1(arr) {
8423
- return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
8424
- }
8425
- /** Zeroize a byte array. Warning: JS provides no guarantees. */
8426
- function clean(...arrays) {
8427
- for (let i = 0; i < arrays.length; i++) {
8428
- arrays[i].fill(0);
8429
- }
8430
- }
8431
- /** Create DataView of an array for easy byte-level manipulation. */
8432
- function createView$1(arr) {
8433
- return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
8434
- }
8435
- /** The rotate right (circular right shift) operation for uint32 */
8436
- function rotr$1(word, shift) {
8437
- return (word << (32 - shift)) | (word >>> shift);
8438
- }
8439
- /** Is current platform little-endian? Most are. Big-Endian platform: IBM */
8440
- const isLE$1 = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44)();
8441
- /** The byte swap operation for uint32 */
8442
- function byteSwap(word) {
8443
- return (((word << 24) & 0xff000000) |
8444
- ((word << 8) & 0xff0000) |
8445
- ((word >>> 8) & 0xff00) |
8446
- ((word >>> 24) & 0xff));
8447
- }
8448
- /** In place byte swap for Uint32Array */
8449
- function byteSwap32(arr) {
8450
- for (let i = 0; i < arr.length; i++) {
8451
- arr[i] = byteSwap(arr[i]);
8452
- }
8453
- return arr;
8454
- }
8455
- const swap32IfBE = isLE$1
8456
- ? (u) => u
8457
- : byteSwap32;
8458
- /**
8459
- * Converts string to bytes using UTF8 encoding.
8460
- * @example utf8ToBytes('abc') // Uint8Array.from([97, 98, 99])
8461
- */
8462
- function utf8ToBytes$2(str) {
8463
- if (typeof str !== 'string')
8464
- throw new Error('string expected');
8465
- return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
8466
- }
8467
- /**
8468
- * Normalizes (non-hex) string or Uint8Array to Uint8Array.
8469
- * Warning: when Uint8Array is passed, it would NOT get copied.
8470
- * Keep in mind for future mutable operations.
8471
- */
8472
- function toBytes$1(data) {
8473
- if (typeof data === 'string')
8474
- data = utf8ToBytes$2(data);
8475
- abytes$2(data);
8476
- return data;
8477
- }
8478
- /** Copies several Uint8Arrays into one. */
8479
- function concatBytes$3(...arrays) {
8480
- let sum = 0;
8481
- for (let i = 0; i < arrays.length; i++) {
8482
- const a = arrays[i];
8483
- abytes$2(a);
8484
- sum += a.length;
8485
- }
8486
- const res = new Uint8Array(sum);
8487
- for (let i = 0, pad = 0; i < arrays.length; i++) {
8488
- const a = arrays[i];
8489
- res.set(a, pad);
8490
- pad += a.length;
8491
- }
8492
- return res;
8493
- }
8494
- /** For runtime check if class implements interface */
8495
- let Hash$1 = class Hash {
8496
- };
8497
- /** Wraps hash function, creating an interface on top of it */
8498
- function createHasher(hashCons) {
8499
- const hashC = (msg) => hashCons().update(toBytes$1(msg)).digest();
8500
- const tmp = hashCons();
8501
- hashC.outputLen = tmp.outputLen;
8502
- hashC.blockLen = tmp.blockLen;
8503
- hashC.create = () => hashCons();
8504
- return hashC;
8505
- }
8506
- /** Cryptographically secure PRNG. Uses internal OS-level `crypto.getRandomValues`. */
8507
- function randomBytes$1(bytesLength = 32) {
8508
- if (crypto$3 && typeof crypto$3.getRandomValues === 'function') {
8509
- return crypto$3.getRandomValues(new Uint8Array(bytesLength));
8510
- }
8511
- // Legacy Node.js compatibility
8512
- if (crypto$3 && typeof crypto$3.randomBytes === 'function') {
8513
- return Uint8Array.from(crypto$3.randomBytes(bytesLength));
8514
- }
8515
- throw new Error('crypto.getRandomValues must be defined');
8516
- }
8517
-
8518
- /**
8519
- * Internal Merkle-Damgard hash utils.
8520
- * @module
8521
- */
8522
- /** Polyfill for Safari 14. https://caniuse.com/mdn-javascript_builtins_dataview_setbiguint64 */
8523
- function setBigUint64$1(view, byteOffset, value, isLE) {
8524
- if (typeof view.setBigUint64 === 'function')
8525
- return view.setBigUint64(byteOffset, value, isLE);
8526
- const _32n = BigInt(32);
8527
- const _u32_max = BigInt(0xffffffff);
8528
- const wh = Number((value >> _32n) & _u32_max);
8529
- const wl = Number(value & _u32_max);
8530
- const h = isLE ? 4 : 0;
8531
- const l = isLE ? 0 : 4;
8532
- view.setUint32(byteOffset + h, wh, isLE);
8533
- view.setUint32(byteOffset + l, wl, isLE);
8534
- }
8535
- /** Choice: a ? b : c */
8536
- function Chi$1(a, b, c) {
8537
- return (a & b) ^ (~a & c);
8538
- }
8539
- /** Majority function, true if any two inputs is true. */
8540
- function Maj$1(a, b, c) {
8541
- return (a & b) ^ (a & c) ^ (b & c);
8542
- }
8543
- /**
8544
- * Merkle-Damgard hash construction base class.
8545
- * Could be used to create MD5, RIPEMD, SHA1, SHA2.
8546
- */
8547
- class HashMD extends Hash$1 {
8548
- constructor(blockLen, outputLen, padOffset, isLE) {
8549
- super();
8550
- this.finished = false;
8551
- this.length = 0;
8552
- this.pos = 0;
8553
- this.destroyed = false;
8554
- this.blockLen = blockLen;
8555
- this.outputLen = outputLen;
8556
- this.padOffset = padOffset;
8557
- this.isLE = isLE;
8558
- this.buffer = new Uint8Array(blockLen);
8559
- this.view = createView$1(this.buffer);
8560
- }
8561
- update(data) {
8562
- aexists(this);
8563
- data = toBytes$1(data);
8564
- abytes$2(data);
8565
- const { view, buffer, blockLen } = this;
8566
- const len = data.length;
8567
- for (let pos = 0; pos < len;) {
8568
- const take = Math.min(blockLen - this.pos, len - pos);
8569
- // Fast path: we have at least one block in input, cast it to view and process
8570
- if (take === blockLen) {
8571
- const dataView = createView$1(data);
8572
- for (; blockLen <= len - pos; pos += blockLen)
8573
- this.process(dataView, pos);
8574
- continue;
8575
- }
8576
- buffer.set(data.subarray(pos, pos + take), this.pos);
8577
- this.pos += take;
8578
- pos += take;
8579
- if (this.pos === blockLen) {
8580
- this.process(view, 0);
8581
- this.pos = 0;
8582
- }
8583
- }
8584
- this.length += data.length;
8585
- this.roundClean();
8586
- return this;
8587
- }
8588
- digestInto(out) {
8589
- aexists(this);
8590
- aoutput(out, this);
8591
- this.finished = true;
8592
- // Padding
8593
- // We can avoid allocation of buffer for padding completely if it
8594
- // was previously not allocated here. But it won't change performance.
8595
- const { buffer, view, blockLen, isLE } = this;
8596
- let { pos } = this;
8597
- // append the bit '1' to the message
8598
- buffer[pos++] = 0b10000000;
8599
- clean(this.buffer.subarray(pos));
8600
- // we have less than padOffset left in buffer, so we cannot put length in
8601
- // current block, need process it and pad again
8602
- if (this.padOffset > blockLen - pos) {
8603
- this.process(view, 0);
8604
- pos = 0;
8605
- }
8606
- // Pad until full block byte with zeros
8607
- for (let i = pos; i < blockLen; i++)
8608
- buffer[i] = 0;
8609
- // Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that
8610
- // You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen.
8611
- // So we just write lowest 64 bits of that value.
8612
- setBigUint64$1(view, blockLen - 8, BigInt(this.length * 8), isLE);
8613
- this.process(view, 0);
8614
- const oview = createView$1(out);
8615
- const len = this.outputLen;
8616
- // NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT
8617
- if (len % 4)
8618
- throw new Error('_sha2: outputLen should be aligned to 32bit');
8619
- const outLen = len / 4;
8620
- const state = this.get();
8621
- if (outLen > state.length)
8622
- throw new Error('_sha2: outputLen bigger than state');
8623
- for (let i = 0; i < outLen; i++)
8624
- oview.setUint32(4 * i, state[i], isLE);
8625
- }
8626
- digest() {
8627
- const { buffer, outputLen } = this;
8628
- this.digestInto(buffer);
8629
- const res = buffer.slice(0, outputLen);
8630
- this.destroy();
8631
- return res;
8632
- }
8633
- _cloneInto(to) {
8634
- to || (to = new this.constructor());
8635
- to.set(...this.get());
8636
- const { blockLen, buffer, length, finished, destroyed, pos } = this;
8637
- to.destroyed = destroyed;
8638
- to.finished = finished;
8639
- to.length = length;
8640
- to.pos = pos;
8641
- if (length % blockLen)
8642
- to.buffer.set(buffer);
8643
- return to;
8644
- }
8645
- clone() {
8646
- return this._cloneInto();
8647
- }
8648
- }
8649
- /**
8650
- * Initial SHA-2 state: fractional parts of square roots of first 16 primes 2..53.
8651
- * Check out `test/misc/sha2-gen-iv.js` for recomputation guide.
8652
- */
8653
- /** Initial SHA256 state. Bits 0..32 of frac part of sqrt of primes 2..19 */
8654
- const SHA256_IV = /* @__PURE__ */ Uint32Array.from([
8655
- 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,
8656
- ]);
8657
-
8658
- /**
8659
- * Internal helpers for u64. BigUint64Array is too slow as per 2025, so we implement it using Uint32Array.
8660
- * @todo re-check https://issues.chromium.org/issues/42212588
8661
- * @module
8662
- */
8663
- const U32_MASK64$1 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
8664
- const _32n$1 = /* @__PURE__ */ BigInt(32);
8665
- function fromBig$1(n, le = false) {
8666
- if (le)
8667
- return { h: Number(n & U32_MASK64$1), l: Number((n >> _32n$1) & U32_MASK64$1) };
8668
- return { h: Number((n >> _32n$1) & U32_MASK64$1) | 0, l: Number(n & U32_MASK64$1) | 0 };
8669
- }
8670
- function split$1(lst, le = false) {
8671
- const len = lst.length;
8672
- let Ah = new Uint32Array(len);
8673
- let Al = new Uint32Array(len);
8674
- for (let i = 0; i < len; i++) {
8675
- const { h, l } = fromBig$1(lst[i], le);
8676
- [Ah[i], Al[i]] = [h, l];
8677
- }
8678
- return [Ah, Al];
8679
- }
8680
- // Left rotate for Shift in [1, 32)
8681
- const rotlSH$1 = (h, l, s) => (h << s) | (l >>> (32 - s));
8682
- const rotlSL$1 = (h, l, s) => (l << s) | (h >>> (32 - s));
8683
- // Left rotate for Shift in (32, 64), NOTE: 32 is special case.
8684
- const rotlBH$1 = (h, l, s) => (l << (s - 32)) | (h >>> (64 - s));
8685
- const rotlBL$1 = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s));
8686
-
8687
- /**
8688
- * SHA2 hash function. A.k.a. sha256, sha384, sha512, sha512_224, sha512_256.
8689
- * SHA256 is the fastest hash implementable in JS, even faster than Blake3.
8690
- * Check out [RFC 4634](https://datatracker.ietf.org/doc/html/rfc4634) and
8691
- * [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf).
8692
- * @module
8693
- */
8694
- /**
8695
- * Round constants:
8696
- * First 32 bits of fractional parts of the cube roots of the first 64 primes 2..311)
8697
- */
8698
- // prettier-ignore
8699
- const SHA256_K$1 = /* @__PURE__ */ Uint32Array.from([
8700
- 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
8701
- 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
8702
- 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
8703
- 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
8704
- 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
8705
- 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
8706
- 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
8707
- 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
8708
- ]);
8709
- /** Reusable temporary buffer. "W" comes straight from spec. */
8710
- const SHA256_W$1 = /* @__PURE__ */ new Uint32Array(64);
8711
- let SHA256$1 = class SHA256 extends HashMD {
8712
- constructor(outputLen = 32) {
8713
- super(64, outputLen, 8, false);
8714
- // We cannot use array here since array allows indexing by variable
8715
- // which means optimizer/compiler cannot use registers.
8716
- this.A = SHA256_IV[0] | 0;
8717
- this.B = SHA256_IV[1] | 0;
8718
- this.C = SHA256_IV[2] | 0;
8719
- this.D = SHA256_IV[3] | 0;
8720
- this.E = SHA256_IV[4] | 0;
8721
- this.F = SHA256_IV[5] | 0;
8722
- this.G = SHA256_IV[6] | 0;
8723
- this.H = SHA256_IV[7] | 0;
8724
- }
8725
- get() {
8726
- const { A, B, C, D, E, F, G, H } = this;
8727
- return [A, B, C, D, E, F, G, H];
8728
- }
8729
- // prettier-ignore
8730
- set(A, B, C, D, E, F, G, H) {
8731
- this.A = A | 0;
8732
- this.B = B | 0;
8733
- this.C = C | 0;
8734
- this.D = D | 0;
8735
- this.E = E | 0;
8736
- this.F = F | 0;
8737
- this.G = G | 0;
8738
- this.H = H | 0;
8739
- }
8740
- process(view, offset) {
8741
- // Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array
8742
- for (let i = 0; i < 16; i++, offset += 4)
8743
- SHA256_W$1[i] = view.getUint32(offset, false);
8744
- for (let i = 16; i < 64; i++) {
8745
- const W15 = SHA256_W$1[i - 15];
8746
- const W2 = SHA256_W$1[i - 2];
8747
- const s0 = rotr$1(W15, 7) ^ rotr$1(W15, 18) ^ (W15 >>> 3);
8748
- const s1 = rotr$1(W2, 17) ^ rotr$1(W2, 19) ^ (W2 >>> 10);
8749
- SHA256_W$1[i] = (s1 + SHA256_W$1[i - 7] + s0 + SHA256_W$1[i - 16]) | 0;
8750
- }
8751
- // Compression function main loop, 64 rounds
8752
- let { A, B, C, D, E, F, G, H } = this;
8753
- for (let i = 0; i < 64; i++) {
8754
- const sigma1 = rotr$1(E, 6) ^ rotr$1(E, 11) ^ rotr$1(E, 25);
8755
- const T1 = (H + sigma1 + Chi$1(E, F, G) + SHA256_K$1[i] + SHA256_W$1[i]) | 0;
8756
- const sigma0 = rotr$1(A, 2) ^ rotr$1(A, 13) ^ rotr$1(A, 22);
8757
- const T2 = (sigma0 + Maj$1(A, B, C)) | 0;
8758
- H = G;
8759
- G = F;
8760
- F = E;
8761
- E = (D + T1) | 0;
8762
- D = C;
8763
- C = B;
8764
- B = A;
8765
- A = (T1 + T2) | 0;
8766
- }
8767
- // Add the compressed chunk to the current hash value
8768
- A = (A + this.A) | 0;
8769
- B = (B + this.B) | 0;
8770
- C = (C + this.C) | 0;
8771
- D = (D + this.D) | 0;
8772
- E = (E + this.E) | 0;
8773
- F = (F + this.F) | 0;
8774
- G = (G + this.G) | 0;
8775
- H = (H + this.H) | 0;
8776
- this.set(A, B, C, D, E, F, G, H);
8777
- }
8778
- roundClean() {
8779
- clean(SHA256_W$1);
8780
- }
8781
- destroy() {
8782
- this.set(0, 0, 0, 0, 0, 0, 0, 0);
8783
- clean(this.buffer);
8784
- }
8785
- };
8786
- /**
8787
- * SHA2-256 hash function from RFC 4634.
8788
- *
8789
- * It is the fastest JS hash, even faster than Blake3.
8790
- * To break sha256 using birthday attack, attackers need to try 2^128 hashes.
8791
- * BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025.
8792
- */
8793
- const sha256$2 = /* @__PURE__ */ createHasher(() => new SHA256$1());
8794
-
8795
8200
  /*! *****************************************************************************
8796
8201
  Copyright (c) Microsoft Corporation. All rights reserved.
8797
8202
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use
@@ -12153,6 +11558,57 @@ function requireBs58$1 () {
12153
11558
  var bs58Exports = requireBs58$1();
12154
11559
  var bs58$2 = /*@__PURE__*/getDefaultExportFromCjs(bs58Exports);
12155
11560
 
11561
+ // ─────────────────────────────────────────────────────────────
11562
+ // Local implementation of getSimulationComputeUnits
11563
+ // (Replaces @solana-developers/helpers to avoid Wallet import issue in browser/ESM builds)
11564
+ // Source: https://github.com/solana-developers/helpers/blob/main/src/lib/transaction.ts
11565
+ // ─────────────────────────────────────────────────────────────
11566
+ /**
11567
+ * Check if a given instruction is a SetComputeUnitLimit instruction
11568
+ * See https://github.com/solana-program/compute-budget/blob/main/clients/js/src/generated/programs/computeBudget.ts#L29
11569
+ */
11570
+ function isSetComputeLimitInstruction(ix) {
11571
+ return (ix.programId.equals(ComputeBudgetProgram.programId) &&
11572
+ ix.data[0] === 2 // opcode for setComputeUnitLimit is 2
11573
+ );
11574
+ }
11575
+ /**
11576
+ * Get the compute units required for a set of instructions via simulation.
11577
+ * Credit https://twitter.com/stegabob, originally from https://x.com/stegaBOB/status/1766662289392889920
11578
+ */
11579
+ async function getSimulationComputeUnits(connection, instructions, payer, lookupTables, commitment = "confirmed") {
11580
+ var _a, _b, _c;
11581
+ const simulationInstructions = [...instructions];
11582
+ // Replace or add compute limit instruction
11583
+ const computeLimitIndex = simulationInstructions.findIndex(isSetComputeLimitInstruction);
11584
+ const simulationLimitIx = ComputeBudgetProgram.setComputeUnitLimit({
11585
+ units: 1400000,
11586
+ });
11587
+ if (computeLimitIndex >= 0) {
11588
+ simulationInstructions[computeLimitIndex] = simulationLimitIx;
11589
+ }
11590
+ else {
11591
+ simulationInstructions.unshift(simulationLimitIx);
11592
+ }
11593
+ const testTransaction = new VersionedTransaction(new TransactionMessage({
11594
+ instructions: simulationInstructions,
11595
+ payerKey: payer,
11596
+ // RecentBlockhash can by any public key during simulation
11597
+ // since 'replaceRecentBlockhash' is set to 'true' below
11598
+ recentBlockhash: PublicKey.default.toString(),
11599
+ }).compileToV0Message(lookupTables));
11600
+ const rpcResponse = await connection.simulateTransaction(testTransaction, {
11601
+ replaceRecentBlockhash: true,
11602
+ sigVerify: false,
11603
+ commitment,
11604
+ });
11605
+ if ((_a = rpcResponse === null || rpcResponse === void 0 ? void 0 : rpcResponse.value) === null || _a === void 0 ? void 0 : _a.err) {
11606
+ const logs = ((_b = rpcResponse.value.logs) === null || _b === void 0 ? void 0 : _b.join("\n • ")) || "No logs available";
11607
+ throw new Error(`Transaction simulation failed:\n •${logs}` +
11608
+ JSON.stringify((_c = rpcResponse === null || rpcResponse === void 0 ? void 0 : rpcResponse.value) === null || _c === void 0 ? void 0 : _c.err));
11609
+ }
11610
+ return rpcResponse.value.unitsConsumed || null;
11611
+ }
12156
11612
  /* ------------------------------------------------------------------ */
12157
11613
  /* RFC-4501 message */
12158
11614
  /* ------------------------------------------------------------------ */
@@ -12468,7 +11924,6 @@ async function makeApiRequest(method, urlPath, data, _overrides) {
12468
11924
  // Signal to backend that client supports offchain transaction signing
12469
11925
  if (typeof window !== "undefined" &&
12470
11926
  window.TAROBASE_SUPPORTS_OFFCHAIN_SIGNING) {
12471
- console.log("X-Supports-Offchain-Signing", "true");
12472
11927
  headers["X-Supports-Offchain-Signing"] = "true";
12473
11928
  }
12474
11929
  const requestConfig = {
@@ -16862,7 +16317,7 @@ function output(out, instance) {
16862
16317
  }
16863
16318
  }
16864
16319
 
16865
- const crypto$2 = typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis.crypto : undefined;
16320
+ const crypto$3 = typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis.crypto : undefined;
16866
16321
 
16867
16322
  /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
16868
16323
  // We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.
@@ -16872,20 +16327,20 @@ const crypto$2 = typeof globalThis === 'object' && 'crypto' in globalThis ? glob
16872
16327
  // Makes the utils un-importable in browsers without a bundler.
16873
16328
  // Once node.js 18 is deprecated, we can just drop the import.
16874
16329
  const u8a$1 = (a) => a instanceof Uint8Array;
16875
- const u32 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
16330
+ const u32$1 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
16876
16331
  // Cast array to view
16877
- const createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
16332
+ const createView$1 = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
16878
16333
  // The rotate right (circular right shift) operation for uint32
16879
- const rotr = (word, shift) => (word << (32 - shift)) | (word >>> shift);
16334
+ const rotr$1 = (word, shift) => (word << (32 - shift)) | (word >>> shift);
16880
16335
  // big-endian hardware is rare. Just in case someone still decides to run hashes:
16881
16336
  // early-throw an error because we don't support BE yet.
16882
- const isLE = new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44;
16883
- if (!isLE)
16337
+ const isLE$1 = new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44;
16338
+ if (!isLE$1)
16884
16339
  throw new Error('Non little-endian hardware is not supported');
16885
16340
  /**
16886
16341
  * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])
16887
16342
  */
16888
- function utf8ToBytes$1(str) {
16343
+ function utf8ToBytes$2(str) {
16889
16344
  if (typeof str !== 'string')
16890
16345
  throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
16891
16346
  return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
@@ -16895,9 +16350,9 @@ function utf8ToBytes$1(str) {
16895
16350
  * Warning: when Uint8Array is passed, it would NOT get copied.
16896
16351
  * Keep in mind for future mutable operations.
16897
16352
  */
16898
- function toBytes(data) {
16353
+ function toBytes$1(data) {
16899
16354
  if (typeof data === 'string')
16900
- data = utf8ToBytes$1(data);
16355
+ data = utf8ToBytes$2(data);
16901
16356
  if (!u8a$1(data))
16902
16357
  throw new Error(`expected Uint8Array, got ${typeof data}`);
16903
16358
  return data;
@@ -16905,7 +16360,7 @@ function toBytes(data) {
16905
16360
  /**
16906
16361
  * Copies several Uint8Arrays into one.
16907
16362
  */
16908
- function concatBytes$2(...arrays) {
16363
+ function concatBytes$3(...arrays) {
16909
16364
  const r = new Uint8Array(arrays.reduce((sum, a) => sum + a.length, 0));
16910
16365
  let pad = 0; // walk through each item, ensure they have proper type
16911
16366
  arrays.forEach((a) => {
@@ -16917,14 +16372,14 @@ function concatBytes$2(...arrays) {
16917
16372
  return r;
16918
16373
  }
16919
16374
  // For runtime check if class implements interface
16920
- class Hash {
16375
+ let Hash$1 = class Hash {
16921
16376
  // Safe version that clones internal state
16922
16377
  clone() {
16923
16378
  return this._cloneInto();
16924
16379
  }
16925
- }
16380
+ };
16926
16381
  function wrapConstructor(hashCons) {
16927
- const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
16382
+ const hashC = (msg) => hashCons().update(toBytes$1(msg)).digest();
16928
16383
  const tmp = hashCons();
16929
16384
  hashC.outputLen = tmp.outputLen;
16930
16385
  hashC.blockLen = tmp.blockLen;
@@ -16934,21 +16389,21 @@ function wrapConstructor(hashCons) {
16934
16389
  /**
16935
16390
  * Secure PRNG. Uses `crypto.getRandomValues`, which defers to OS.
16936
16391
  */
16937
- function randomBytes(bytesLength = 32) {
16938
- if (crypto$2 && typeof crypto$2.getRandomValues === 'function') {
16939
- return crypto$2.getRandomValues(new Uint8Array(bytesLength));
16392
+ function randomBytes$1(bytesLength = 32) {
16393
+ if (crypto$3 && typeof crypto$3.getRandomValues === 'function') {
16394
+ return crypto$3.getRandomValues(new Uint8Array(bytesLength));
16940
16395
  }
16941
16396
  throw new Error('crypto.getRandomValues must be defined');
16942
16397
  }
16943
16398
 
16944
16399
  // HMAC (RFC 2104)
16945
- let HMAC$1 = class HMAC extends Hash {
16400
+ let HMAC$1 = class HMAC extends Hash$1 {
16946
16401
  constructor(hash$1, _key) {
16947
16402
  super();
16948
16403
  this.finished = false;
16949
16404
  this.destroyed = false;
16950
16405
  hash(hash$1);
16951
- const key = toBytes(_key);
16406
+ const key = toBytes$1(_key);
16952
16407
  this.iHash = hash$1.create();
16953
16408
  if (typeof this.iHash.update !== 'function')
16954
16409
  throw new Error('Expected instance of class which extends utils.Hash');
@@ -17017,7 +16472,7 @@ const hmac$1 = (hash, key, message) => new HMAC$1(hash, key).update(message).dig
17017
16472
  hmac$1.create = (hash, key) => new HMAC$1(hash, key);
17018
16473
 
17019
16474
  // Polyfill for Safari 14
17020
- function setBigUint64(view, byteOffset, value, isLE) {
16475
+ function setBigUint64$1(view, byteOffset, value, isLE) {
17021
16476
  if (typeof view.setBigUint64 === 'function')
17022
16477
  return view.setBigUint64(byteOffset, value, isLE);
17023
16478
  const _32n = BigInt(32);
@@ -17030,7 +16485,7 @@ function setBigUint64(view, byteOffset, value, isLE) {
17030
16485
  view.setUint32(byteOffset + l, wl, isLE);
17031
16486
  }
17032
16487
  // Base SHA2 class (RFC 6234)
17033
- class SHA2 extends Hash {
16488
+ class SHA2 extends Hash$1 {
17034
16489
  constructor(blockLen, outputLen, padOffset, isLE) {
17035
16490
  super();
17036
16491
  this.blockLen = blockLen;
@@ -17042,18 +16497,18 @@ class SHA2 extends Hash {
17042
16497
  this.pos = 0;
17043
16498
  this.destroyed = false;
17044
16499
  this.buffer = new Uint8Array(blockLen);
17045
- this.view = createView(this.buffer);
16500
+ this.view = createView$1(this.buffer);
17046
16501
  }
17047
16502
  update(data) {
17048
16503
  exists(this);
17049
16504
  const { view, buffer, blockLen } = this;
17050
- data = toBytes(data);
16505
+ data = toBytes$1(data);
17051
16506
  const len = data.length;
17052
16507
  for (let pos = 0; pos < len;) {
17053
16508
  const take = Math.min(blockLen - this.pos, len - pos);
17054
16509
  // Fast path: we have at least one block in input, cast it to view and process
17055
16510
  if (take === blockLen) {
17056
- const dataView = createView(data);
16511
+ const dataView = createView$1(data);
17057
16512
  for (; blockLen <= len - pos; pos += blockLen)
17058
16513
  this.process(dataView, pos);
17059
16514
  continue;
@@ -17093,9 +16548,9 @@ class SHA2 extends Hash {
17093
16548
  // Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that
17094
16549
  // You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen.
17095
16550
  // So we just write lowest 64 bits of that value.
17096
- setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);
16551
+ setBigUint64$1(view, blockLen - 8, BigInt(this.length * 8), isLE);
17097
16552
  this.process(view, 0);
17098
- const oview = createView(out);
16553
+ const oview = createView$1(out);
17099
16554
  const len = this.outputLen;
17100
16555
  // NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT
17101
16556
  if (len % 4)
@@ -17131,13 +16586,13 @@ class SHA2 extends Hash {
17131
16586
  // SHA2-256 need to try 2^128 hashes to execute birthday attack.
17132
16587
  // BTC network is doing 2^67 hashes/sec as per early 2023.
17133
16588
  // Choice: a ? b : c
17134
- const Chi = (a, b, c) => (a & b) ^ (~a & c);
16589
+ const Chi$1 = (a, b, c) => (a & b) ^ (~a & c);
17135
16590
  // Majority function, true if any two inpust is true
17136
- const Maj = (a, b, c) => (a & b) ^ (a & c) ^ (b & c);
16591
+ const Maj$1 = (a, b, c) => (a & b) ^ (a & c) ^ (b & c);
17137
16592
  // Round constants:
17138
16593
  // first 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311)
17139
16594
  // prettier-ignore
17140
- const SHA256_K = /* @__PURE__ */ new Uint32Array([
16595
+ const SHA256_K$1 = /* @__PURE__ */ new Uint32Array([
17141
16596
  0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
17142
16597
  0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
17143
16598
  0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
@@ -17154,8 +16609,8 @@ const IV = /* @__PURE__ */ new Uint32Array([
17154
16609
  ]);
17155
16610
  // Temporary buffer, not used to store anything between runs
17156
16611
  // Named this way because it matches specification.
17157
- const SHA256_W = /* @__PURE__ */ new Uint32Array(64);
17158
- class SHA256 extends SHA2 {
16612
+ const SHA256_W$1 = /* @__PURE__ */ new Uint32Array(64);
16613
+ let SHA256$1 = class SHA256 extends SHA2 {
17159
16614
  constructor() {
17160
16615
  super(64, 32, 8, false);
17161
16616
  // We cannot use array here since array allows indexing by variable
@@ -17187,21 +16642,21 @@ class SHA256 extends SHA2 {
17187
16642
  process(view, offset) {
17188
16643
  // Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array
17189
16644
  for (let i = 0; i < 16; i++, offset += 4)
17190
- SHA256_W[i] = view.getUint32(offset, false);
16645
+ SHA256_W$1[i] = view.getUint32(offset, false);
17191
16646
  for (let i = 16; i < 64; i++) {
17192
- const W15 = SHA256_W[i - 15];
17193
- const W2 = SHA256_W[i - 2];
17194
- const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ (W15 >>> 3);
17195
- const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ (W2 >>> 10);
17196
- SHA256_W[i] = (s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16]) | 0;
16647
+ const W15 = SHA256_W$1[i - 15];
16648
+ const W2 = SHA256_W$1[i - 2];
16649
+ const s0 = rotr$1(W15, 7) ^ rotr$1(W15, 18) ^ (W15 >>> 3);
16650
+ const s1 = rotr$1(W2, 17) ^ rotr$1(W2, 19) ^ (W2 >>> 10);
16651
+ SHA256_W$1[i] = (s1 + SHA256_W$1[i - 7] + s0 + SHA256_W$1[i - 16]) | 0;
17197
16652
  }
17198
16653
  // Compression function main loop, 64 rounds
17199
16654
  let { A, B, C, D, E, F, G, H } = this;
17200
16655
  for (let i = 0; i < 64; i++) {
17201
- const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
17202
- const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;
17203
- const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);
17204
- const T2 = (sigma0 + Maj(A, B, C)) | 0;
16656
+ const sigma1 = rotr$1(E, 6) ^ rotr$1(E, 11) ^ rotr$1(E, 25);
16657
+ const T1 = (H + sigma1 + Chi$1(E, F, G) + SHA256_K$1[i] + SHA256_W$1[i]) | 0;
16658
+ const sigma0 = rotr$1(A, 2) ^ rotr$1(A, 13) ^ rotr$1(A, 22);
16659
+ const T2 = (sigma0 + Maj$1(A, B, C)) | 0;
17205
16660
  H = G;
17206
16661
  G = F;
17207
16662
  F = E;
@@ -17223,37 +16678,37 @@ class SHA256 extends SHA2 {
17223
16678
  this.set(A, B, C, D, E, F, G, H);
17224
16679
  }
17225
16680
  roundClean() {
17226
- SHA256_W.fill(0);
16681
+ SHA256_W$1.fill(0);
17227
16682
  }
17228
16683
  destroy() {
17229
16684
  this.set(0, 0, 0, 0, 0, 0, 0, 0);
17230
16685
  this.buffer.fill(0);
17231
16686
  }
17232
- }
16687
+ };
17233
16688
  /**
17234
16689
  * SHA2-256 hash function
17235
16690
  * @param message - data that would be hashed
17236
16691
  */
17237
- const sha256$1 = /* @__PURE__ */ wrapConstructor(() => new SHA256());
16692
+ const sha256$2 = /* @__PURE__ */ wrapConstructor(() => new SHA256$1());
17238
16693
 
17239
- const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
17240
- const _32n = /* @__PURE__ */ BigInt(32);
16694
+ const U32_MASK64$1 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
16695
+ const _32n$1 = /* @__PURE__ */ BigInt(32);
17241
16696
  // We are not using BigUint64Array, because they are extremely slow as per 2022
17242
- function fromBig(n, le = false) {
16697
+ function fromBig$1(n, le = false) {
17243
16698
  if (le)
17244
- return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) };
17245
- return { h: Number((n >> _32n) & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
16699
+ return { h: Number(n & U32_MASK64$1), l: Number((n >> _32n$1) & U32_MASK64$1) };
16700
+ return { h: Number((n >> _32n$1) & U32_MASK64$1) | 0, l: Number(n & U32_MASK64$1) | 0 };
17246
16701
  }
17247
- function split(lst, le = false) {
16702
+ function split$1(lst, le = false) {
17248
16703
  let Ah = new Uint32Array(lst.length);
17249
16704
  let Al = new Uint32Array(lst.length);
17250
16705
  for (let i = 0; i < lst.length; i++) {
17251
- const { h, l } = fromBig(lst[i], le);
16706
+ const { h, l } = fromBig$1(lst[i], le);
17252
16707
  [Ah[i], Al[i]] = [h, l];
17253
16708
  }
17254
16709
  return [Ah, Al];
17255
16710
  }
17256
- const toBig = (h, l) => (BigInt(h >>> 0) << _32n) | BigInt(l >>> 0);
16711
+ const toBig = (h, l) => (BigInt(h >>> 0) << _32n$1) | BigInt(l >>> 0);
17257
16712
  // for Shift in [0, 32)
17258
16713
  const shrSH = (h, _l, s) => h >>> s;
17259
16714
  const shrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);
@@ -17267,11 +16722,11 @@ const rotrBL = (h, l, s) => (h >>> (s - 32)) | (l << (64 - s));
17267
16722
  const rotr32H = (_h, l) => l;
17268
16723
  const rotr32L = (h, _l) => h;
17269
16724
  // Left rotate for Shift in [1, 32)
17270
- const rotlSH = (h, l, s) => (h << s) | (l >>> (32 - s));
17271
- const rotlSL = (h, l, s) => (l << s) | (h >>> (32 - s));
16725
+ const rotlSH$1 = (h, l, s) => (h << s) | (l >>> (32 - s));
16726
+ const rotlSL$1 = (h, l, s) => (l << s) | (h >>> (32 - s));
17272
16727
  // Left rotate for Shift in (32, 64), NOTE: 32 is special case.
17273
- const rotlBH = (h, l, s) => (l << (s - 32)) | (h >>> (64 - s));
17274
- const rotlBL = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s));
16728
+ const rotlBH$1 = (h, l, s) => (l << (s - 32)) | (h >>> (64 - s));
16729
+ const rotlBL$1 = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s));
17275
16730
  // JS uses 32-bit signed integers for bitwise operations which means we cannot
17276
16731
  // simple take carry out of low bit sum by shift, we need to use division.
17277
16732
  function add(Ah, Al, Bh, Bl) {
@@ -17287,11 +16742,11 @@ const add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl
17287
16742
  const add5H = (low, Ah, Bh, Ch, Dh, Eh) => (Ah + Bh + Ch + Dh + Eh + ((low / 2 ** 32) | 0)) | 0;
17288
16743
  // prettier-ignore
17289
16744
  const u64 = {
17290
- fromBig, split, toBig,
16745
+ fromBig: fromBig$1, split: split$1, toBig,
17291
16746
  shrSH, shrSL,
17292
16747
  rotrSH, rotrSL, rotrBH, rotrBL,
17293
16748
  rotr32H, rotr32L,
17294
- rotlSH, rotlSL, rotlBH, rotlBL,
16749
+ rotlSH: rotlSH$1, rotlSL: rotlSL$1, rotlBH: rotlBH$1, rotlBL: rotlBL$1,
17295
16750
  add, add3L, add3H, add4L, add4H, add5H, add5L,
17296
16751
  };
17297
16752
 
@@ -17468,7 +16923,7 @@ const anyGlobal = getGlobal();
17468
16923
  anyGlobal.crypto || anyGlobal.msCrypto;
17469
16924
  function createHash(algo) {
17470
16925
  switch (algo) {
17471
- case "sha256": return sha256$1.create();
16926
+ case "sha256": return sha256$2.create();
17472
16927
  case "sha512": return sha512.create();
17473
16928
  }
17474
16929
  assertArgument(false, "invalid hashing algorithm name", "algorithm", algo);
@@ -17499,10 +16954,10 @@ for (let round = 0, R = _1n$b, x = 1, y = 0; round < 24; round++) {
17499
16954
  }
17500
16955
  _SHA3_IOTA$1.push(t);
17501
16956
  }
17502
- const [SHA3_IOTA_H$1, SHA3_IOTA_L$1] = /* @__PURE__ */ split(_SHA3_IOTA$1, true);
16957
+ const [SHA3_IOTA_H$1, SHA3_IOTA_L$1] = /* @__PURE__ */ split$1(_SHA3_IOTA$1, true);
17503
16958
  // Left rotation (without 0, 32, 64)
17504
- const rotlH$1 = (h, l, s) => (s > 32 ? rotlBH(h, l, s) : rotlSH(h, l, s));
17505
- const rotlL$1 = (h, l, s) => (s > 32 ? rotlBL(h, l, s) : rotlSL(h, l, s));
16959
+ const rotlH$1 = (h, l, s) => (s > 32 ? rotlBH$1(h, l, s) : rotlSH$1(h, l, s));
16960
+ const rotlL$1 = (h, l, s) => (s > 32 ? rotlBL$1(h, l, s) : rotlSL$1(h, l, s));
17506
16961
  // Same as keccakf1600, but allows to skip some rounds
17507
16962
  function keccakP$1(s, rounds = 24) {
17508
16963
  const B = new Uint32Array(5 * 2);
@@ -17549,7 +17004,7 @@ function keccakP$1(s, rounds = 24) {
17549
17004
  }
17550
17005
  B.fill(0);
17551
17006
  }
17552
- let Keccak$1 = class Keccak extends Hash {
17007
+ let Keccak$1 = class Keccak extends Hash$1 {
17553
17008
  // NOTE: we accept arguments in bytes instead of bits here.
17554
17009
  constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) {
17555
17010
  super();
@@ -17568,7 +17023,7 @@ let Keccak$1 = class Keccak extends Hash {
17568
17023
  if (0 >= this.blockLen || this.blockLen >= 200)
17569
17024
  throw new Error('Sha3 supports only keccak-f1600 function');
17570
17025
  this.state = new Uint8Array(200);
17571
- this.state32 = u32(this.state);
17026
+ this.state32 = u32$1(this.state);
17572
17027
  }
17573
17028
  keccak() {
17574
17029
  keccakP$1(this.state32, this.rounds);
@@ -17578,7 +17033,7 @@ let Keccak$1 = class Keccak extends Hash {
17578
17033
  update(data) {
17579
17034
  exists(this);
17580
17035
  const { blockLen, state } = this;
17581
- data = toBytes(data);
17036
+ data = toBytes$1(data);
17582
17037
  const len = data.length;
17583
17038
  for (let pos = 0; pos < len;) {
17584
17039
  const take = Math.min(blockLen - this.pos, len - pos);
@@ -17733,20 +17188,20 @@ let locked256 = false;
17733
17188
  * //_result:
17734
17189
  *
17735
17190
  */
17736
- function sha256(_data) {
17191
+ function sha256$1(_data) {
17737
17192
  const data = getBytes(_data, "data");
17738
17193
  return hexlify(__sha256(data));
17739
17194
  }
17740
- sha256._ = _sha256;
17741
- sha256.lock = function () { locked256 = true; };
17742
- sha256.register = function (func) {
17195
+ sha256$1._ = _sha256;
17196
+ sha256$1.lock = function () { locked256 = true; };
17197
+ sha256$1.register = function (func) {
17743
17198
  if (locked256) {
17744
17199
  throw new Error("sha256 is locked");
17745
17200
  }
17746
17201
  __sha256 = func;
17747
17202
  };
17748
- Object.freeze(sha256);
17749
- Object.freeze(sha256);
17203
+ Object.freeze(sha256$1);
17204
+ Object.freeze(sha256$1);
17750
17205
 
17751
17206
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
17752
17207
  // 100 lines of code in the file are duplicated from noble-hashes (utils).
@@ -17855,7 +17310,7 @@ function ensureBytes$1(title, hex, expectedLength) {
17855
17310
  /**
17856
17311
  * Copies several Uint8Arrays into one.
17857
17312
  */
17858
- function concatBytes$1(...arrays) {
17313
+ function concatBytes$2(...arrays) {
17859
17314
  const r = new Uint8Array(arrays.reduce((sum, a) => sum + a.length, 0));
17860
17315
  let pad = 0; // walk through each item, ensure they have proper type
17861
17316
  arrays.forEach((a) => {
@@ -17878,7 +17333,7 @@ function equalBytes(b1, b2) {
17878
17333
  /**
17879
17334
  * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])
17880
17335
  */
17881
- function utf8ToBytes(str) {
17336
+ function utf8ToBytes$1(str) {
17882
17337
  if (typeof str !== 'string')
17883
17338
  throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
17884
17339
  return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
@@ -17961,7 +17416,7 @@ function createHmacDrbg$1(hashLen, qByteLen, hmacFn) {
17961
17416
  out.push(sl);
17962
17417
  len += v.length;
17963
17418
  }
17964
- return concatBytes$1(...out);
17419
+ return concatBytes$2(...out);
17965
17420
  };
17966
17421
  const genUntil = (seed, pred) => {
17967
17422
  reset();
@@ -18023,7 +17478,7 @@ var ut$4 = /*#__PURE__*/Object.freeze({
18023
17478
  bytesToHex: bytesToHex$1,
18024
17479
  bytesToNumberBE: bytesToNumberBE$1,
18025
17480
  bytesToNumberLE: bytesToNumberLE$1,
18026
- concatBytes: concatBytes$1,
17481
+ concatBytes: concatBytes$2,
18027
17482
  createHmacDrbg: createHmacDrbg$1,
18028
17483
  ensureBytes: ensureBytes$1,
18029
17484
  equalBytes: equalBytes,
@@ -18033,7 +17488,7 @@ var ut$4 = /*#__PURE__*/Object.freeze({
18033
17488
  numberToBytesLE: numberToBytesLE$1,
18034
17489
  numberToHexUnpadded: numberToHexUnpadded$1,
18035
17490
  numberToVarBytesBE: numberToVarBytesBE,
18036
- utf8ToBytes: utf8ToBytes,
17491
+ utf8ToBytes: utf8ToBytes$1,
18037
17492
  validateObject: validateObject$1
18038
17493
  });
18039
17494
 
@@ -18641,7 +18096,7 @@ function weierstrassPoints$1(opts) {
18641
18096
  const toBytes = CURVE.toBytes ||
18642
18097
  ((_c, point, _isCompressed) => {
18643
18098
  const a = point.toAffine();
18644
- return concatBytes$1(Uint8Array.from([0x04]), Fp.toBytes(a.x), Fp.toBytes(a.y));
18099
+ return concatBytes$2(Uint8Array.from([0x04]), Fp.toBytes(a.x), Fp.toBytes(a.y));
18645
18100
  });
18646
18101
  const fromBytes = CURVE.fromBytes ||
18647
18102
  ((bytes) => {
@@ -19094,7 +18549,7 @@ function weierstrass$1(curveDef) {
19094
18549
  toBytes(_c, point, isCompressed) {
19095
18550
  const a = point.toAffine();
19096
18551
  const x = Fp.toBytes(a.x);
19097
- const cat = concatBytes$1;
18552
+ const cat = concatBytes$2;
19098
18553
  if (isCompressed) {
19099
18554
  return cat(Uint8Array.from([point.hasEvenY() ? 0x02 : 0x03]), x);
19100
18555
  }
@@ -19344,7 +18799,7 @@ function weierstrass$1(curveDef) {
19344
18799
  const e = ent === true ? randomBytes(Fp.BYTES) : ent; // generate random bytes OR pass as-is
19345
18800
  seedArgs.push(ensureBytes$1('extraEntropy', e)); // check for being bytes
19346
18801
  }
19347
- const seed = concatBytes$1(...seedArgs); // Step D of RFC6979 3.2
18802
+ const seed = concatBytes$2(...seedArgs); // Step D of RFC6979 3.2
19348
18803
  const m = h1int; // NOTE: no need to call bits2int second time here, it is inside truncateHash!
19349
18804
  // Converts signature params into point w r/s, checks result for validity.
19350
18805
  function k2sig(kBytes) {
@@ -19478,8 +18933,8 @@ function weierstrass$1(curveDef) {
19478
18933
  function getHash$1(hash) {
19479
18934
  return {
19480
18935
  hash,
19481
- hmac: (key, ...msgs) => hmac$1(hash, key, concatBytes$2(...msgs)),
19482
- randomBytes,
18936
+ hmac: (key, ...msgs) => hmac$1(hash, key, concatBytes$3(...msgs)),
18937
+ randomBytes: randomBytes$1,
19483
18938
  };
19484
18939
  }
19485
18940
  function createCurve$1(curveDef, defHash) {
@@ -19563,7 +19018,7 @@ const secp256k1$1 = createCurve$1({
19563
19018
  return { k1neg, k1, k2neg, k2 };
19564
19019
  },
19565
19020
  },
19566
- }, sha256$1);
19021
+ }, sha256$2);
19567
19022
  // Schnorr signatures are superior to ECDSA from above. Below is Schnorr-specific BIP0340 code.
19568
19023
  // https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki
19569
19024
  BigInt(0);
@@ -20299,7 +19754,7 @@ function getVersionedHash(version, hash) {
20299
19754
  while (versioned.length < 2) {
20300
19755
  versioned = "0" + versioned;
20301
19756
  }
20302
- versioned += sha256(hash).substring(4);
19757
+ versioned += sha256$1(hash).substring(4);
20303
19758
  return "0x" + versioned;
20304
19759
  }
20305
19760
  function handleAddress(value) {
@@ -21388,6 +20843,133 @@ class Transaction {
21388
20843
  }
21389
20844
  }
21390
20845
 
20846
+ // base-x encoding / decoding
20847
+ // Copyright (c) 2018 base-x contributors
20848
+ // Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
20849
+ // Distributed under the MIT software license, see the accompanying
20850
+ // file LICENSE or http://www.opensource.org/licenses/mit-license.php.
20851
+ function base$1 (ALPHABET) {
20852
+ if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }
20853
+ const BASE_MAP = new Uint8Array(256);
20854
+ for (let j = 0; j < BASE_MAP.length; j++) {
20855
+ BASE_MAP[j] = 255;
20856
+ }
20857
+ for (let i = 0; i < ALPHABET.length; i++) {
20858
+ const x = ALPHABET.charAt(i);
20859
+ const xc = x.charCodeAt(0);
20860
+ if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }
20861
+ BASE_MAP[xc] = i;
20862
+ }
20863
+ const BASE = ALPHABET.length;
20864
+ const LEADER = ALPHABET.charAt(0);
20865
+ const FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up
20866
+ const iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up
20867
+ function encode (source) {
20868
+ // eslint-disable-next-line no-empty
20869
+ if (source instanceof Uint8Array) ; else if (ArrayBuffer.isView(source)) {
20870
+ source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
20871
+ } else if (Array.isArray(source)) {
20872
+ source = Uint8Array.from(source);
20873
+ }
20874
+ if (!(source instanceof Uint8Array)) { throw new TypeError('Expected Uint8Array') }
20875
+ if (source.length === 0) { return '' }
20876
+ // Skip & count leading zeroes.
20877
+ let zeroes = 0;
20878
+ let length = 0;
20879
+ let pbegin = 0;
20880
+ const pend = source.length;
20881
+ while (pbegin !== pend && source[pbegin] === 0) {
20882
+ pbegin++;
20883
+ zeroes++;
20884
+ }
20885
+ // Allocate enough space in big-endian base58 representation.
20886
+ const size = ((pend - pbegin) * iFACTOR + 1) >>> 0;
20887
+ const b58 = new Uint8Array(size);
20888
+ // Process the bytes.
20889
+ while (pbegin !== pend) {
20890
+ let carry = source[pbegin];
20891
+ // Apply "b58 = b58 * 256 + ch".
20892
+ let i = 0;
20893
+ for (let it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
20894
+ carry += (256 * b58[it1]) >>> 0;
20895
+ b58[it1] = (carry % BASE) >>> 0;
20896
+ carry = (carry / BASE) >>> 0;
20897
+ }
20898
+ if (carry !== 0) { throw new Error('Non-zero carry') }
20899
+ length = i;
20900
+ pbegin++;
20901
+ }
20902
+ // Skip leading zeroes in base58 result.
20903
+ let it2 = size - length;
20904
+ while (it2 !== size && b58[it2] === 0) {
20905
+ it2++;
20906
+ }
20907
+ // Translate the result into a string.
20908
+ let str = LEADER.repeat(zeroes);
20909
+ for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]); }
20910
+ return str
20911
+ }
20912
+ function decodeUnsafe (source) {
20913
+ if (typeof source !== 'string') { throw new TypeError('Expected String') }
20914
+ if (source.length === 0) { return new Uint8Array() }
20915
+ let psz = 0;
20916
+ // Skip and count leading '1's.
20917
+ let zeroes = 0;
20918
+ let length = 0;
20919
+ while (source[psz] === LEADER) {
20920
+ zeroes++;
20921
+ psz++;
20922
+ }
20923
+ // Allocate enough space in big-endian base256 representation.
20924
+ const size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.
20925
+ const b256 = new Uint8Array(size);
20926
+ // Process the characters.
20927
+ while (psz < source.length) {
20928
+ // Find code of next character
20929
+ const charCode = source.charCodeAt(psz);
20930
+ // Base map can not be indexed using char code
20931
+ if (charCode > 255) { return }
20932
+ // Decode character
20933
+ let carry = BASE_MAP[charCode];
20934
+ // Invalid character
20935
+ if (carry === 255) { return }
20936
+ let i = 0;
20937
+ for (let it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
20938
+ carry += (BASE * b256[it3]) >>> 0;
20939
+ b256[it3] = (carry % 256) >>> 0;
20940
+ carry = (carry / 256) >>> 0;
20941
+ }
20942
+ if (carry !== 0) { throw new Error('Non-zero carry') }
20943
+ length = i;
20944
+ psz++;
20945
+ }
20946
+ // Skip leading zeroes in b256.
20947
+ let it4 = size - length;
20948
+ while (it4 !== size && b256[it4] === 0) {
20949
+ it4++;
20950
+ }
20951
+ const vch = new Uint8Array(zeroes + (size - it4));
20952
+ let j = zeroes;
20953
+ while (it4 !== size) {
20954
+ vch[j++] = b256[it4++];
20955
+ }
20956
+ return vch
20957
+ }
20958
+ function decode (string) {
20959
+ const buffer = decodeUnsafe(string);
20960
+ if (buffer) { return buffer }
20961
+ throw new Error('Non-base' + BASE + ' character')
20962
+ }
20963
+ return {
20964
+ encode,
20965
+ decodeUnsafe,
20966
+ decode
20967
+ }
20968
+ }
20969
+
20970
+ var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
20971
+ var ue$3 = base$1(ALPHABET);
20972
+
21391
20973
  // src/index.ts
21392
20974
  function parseSignMessageResponse(base64Response, networkId) {
21393
20975
  const networkPrefix = networkId.split(":")[0].toLowerCase();
@@ -25682,6 +25264,183 @@ class PhantomWalletProvider {
25682
25264
  }
25683
25265
  }
25684
25266
 
25267
+ /**
25268
+ * Internal helpers for u64. BigUint64Array is too slow as per 2025, so we implement it using Uint32Array.
25269
+ * @todo re-check https://issues.chromium.org/issues/42212588
25270
+ * @module
25271
+ */
25272
+ const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
25273
+ const _32n = /* @__PURE__ */ BigInt(32);
25274
+ function fromBig(n, le = false) {
25275
+ if (le)
25276
+ return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) };
25277
+ return { h: Number((n >> _32n) & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
25278
+ }
25279
+ function split(lst, le = false) {
25280
+ const len = lst.length;
25281
+ let Ah = new Uint32Array(len);
25282
+ let Al = new Uint32Array(len);
25283
+ for (let i = 0; i < len; i++) {
25284
+ const { h, l } = fromBig(lst[i], le);
25285
+ [Ah[i], Al[i]] = [h, l];
25286
+ }
25287
+ return [Ah, Al];
25288
+ }
25289
+ // Left rotate for Shift in [1, 32)
25290
+ const rotlSH = (h, l, s) => (h << s) | (l >>> (32 - s));
25291
+ const rotlSL = (h, l, s) => (l << s) | (h >>> (32 - s));
25292
+ // Left rotate for Shift in (32, 64), NOTE: 32 is special case.
25293
+ const rotlBH = (h, l, s) => (l << (s - 32)) | (h >>> (64 - s));
25294
+ const rotlBL = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s));
25295
+
25296
+ const crypto$2 = typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis.crypto : undefined;
25297
+
25298
+ /**
25299
+ * Utilities for hex, bytes, CSPRNG.
25300
+ * @module
25301
+ */
25302
+ /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
25303
+ // We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.
25304
+ // node.js versions earlier than v19 don't declare it in global scope.
25305
+ // For node.js, package.json#exports field mapping rewrites import
25306
+ // from `crypto` to `cryptoNode`, which imports native module.
25307
+ // Makes the utils un-importable in browsers without a bundler.
25308
+ // Once node.js 18 is deprecated (2025-04-30), we can just drop the import.
25309
+ /** Checks if something is Uint8Array. Be careful: nodejs Buffer will return true. */
25310
+ function isBytes$2(a) {
25311
+ return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');
25312
+ }
25313
+ /** Asserts something is positive integer. */
25314
+ function anumber$1(n) {
25315
+ if (!Number.isSafeInteger(n) || n < 0)
25316
+ throw new Error('positive integer expected, got ' + n);
25317
+ }
25318
+ /** Asserts something is Uint8Array. */
25319
+ function abytes$2(b, ...lengths) {
25320
+ if (!isBytes$2(b))
25321
+ throw new Error('Uint8Array expected');
25322
+ if (lengths.length > 0 && !lengths.includes(b.length))
25323
+ throw new Error('Uint8Array expected of length ' + lengths + ', got length=' + b.length);
25324
+ }
25325
+ /** Asserts something is hash */
25326
+ function ahash(h) {
25327
+ if (typeof h !== 'function' || typeof h.create !== 'function')
25328
+ throw new Error('Hash should be wrapped by utils.createHasher');
25329
+ anumber$1(h.outputLen);
25330
+ anumber$1(h.blockLen);
25331
+ }
25332
+ /** Asserts a hash instance has not been destroyed / finished */
25333
+ function aexists(instance, checkFinished = true) {
25334
+ if (instance.destroyed)
25335
+ throw new Error('Hash instance has been destroyed');
25336
+ if (checkFinished && instance.finished)
25337
+ throw new Error('Hash#digest() has already been called');
25338
+ }
25339
+ /** Asserts output is properly-sized byte array */
25340
+ function aoutput(out, instance) {
25341
+ abytes$2(out);
25342
+ const min = instance.outputLen;
25343
+ if (out.length < min) {
25344
+ throw new Error('digestInto() expects output buffer of length at least ' + min);
25345
+ }
25346
+ }
25347
+ /** Cast u8 / u16 / u32 to u32. */
25348
+ function u32(arr) {
25349
+ return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
25350
+ }
25351
+ /** Zeroize a byte array. Warning: JS provides no guarantees. */
25352
+ function clean(...arrays) {
25353
+ for (let i = 0; i < arrays.length; i++) {
25354
+ arrays[i].fill(0);
25355
+ }
25356
+ }
25357
+ /** Create DataView of an array for easy byte-level manipulation. */
25358
+ function createView(arr) {
25359
+ return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
25360
+ }
25361
+ /** The rotate right (circular right shift) operation for uint32 */
25362
+ function rotr(word, shift) {
25363
+ return (word << (32 - shift)) | (word >>> shift);
25364
+ }
25365
+ /** Is current platform little-endian? Most are. Big-Endian platform: IBM */
25366
+ const isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44)();
25367
+ /** The byte swap operation for uint32 */
25368
+ function byteSwap(word) {
25369
+ return (((word << 24) & 0xff000000) |
25370
+ ((word << 8) & 0xff0000) |
25371
+ ((word >>> 8) & 0xff00) |
25372
+ ((word >>> 24) & 0xff));
25373
+ }
25374
+ /** In place byte swap for Uint32Array */
25375
+ function byteSwap32(arr) {
25376
+ for (let i = 0; i < arr.length; i++) {
25377
+ arr[i] = byteSwap(arr[i]);
25378
+ }
25379
+ return arr;
25380
+ }
25381
+ const swap32IfBE = isLE
25382
+ ? (u) => u
25383
+ : byteSwap32;
25384
+ /**
25385
+ * Converts string to bytes using UTF8 encoding.
25386
+ * @example utf8ToBytes('abc') // Uint8Array.from([97, 98, 99])
25387
+ */
25388
+ function utf8ToBytes(str) {
25389
+ if (typeof str !== 'string')
25390
+ throw new Error('string expected');
25391
+ return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
25392
+ }
25393
+ /**
25394
+ * Normalizes (non-hex) string or Uint8Array to Uint8Array.
25395
+ * Warning: when Uint8Array is passed, it would NOT get copied.
25396
+ * Keep in mind for future mutable operations.
25397
+ */
25398
+ function toBytes(data) {
25399
+ if (typeof data === 'string')
25400
+ data = utf8ToBytes(data);
25401
+ abytes$2(data);
25402
+ return data;
25403
+ }
25404
+ /** Copies several Uint8Arrays into one. */
25405
+ function concatBytes$1(...arrays) {
25406
+ let sum = 0;
25407
+ for (let i = 0; i < arrays.length; i++) {
25408
+ const a = arrays[i];
25409
+ abytes$2(a);
25410
+ sum += a.length;
25411
+ }
25412
+ const res = new Uint8Array(sum);
25413
+ for (let i = 0, pad = 0; i < arrays.length; i++) {
25414
+ const a = arrays[i];
25415
+ res.set(a, pad);
25416
+ pad += a.length;
25417
+ }
25418
+ return res;
25419
+ }
25420
+ /** For runtime check if class implements interface */
25421
+ class Hash {
25422
+ }
25423
+ /** Wraps hash function, creating an interface on top of it */
25424
+ function createHasher(hashCons) {
25425
+ const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
25426
+ const tmp = hashCons();
25427
+ hashC.outputLen = tmp.outputLen;
25428
+ hashC.blockLen = tmp.blockLen;
25429
+ hashC.create = () => hashCons();
25430
+ return hashC;
25431
+ }
25432
+ /** Cryptographically secure PRNG. Uses internal OS-level `crypto.getRandomValues`. */
25433
+ function randomBytes(bytesLength = 32) {
25434
+ if (crypto$2 && typeof crypto$2.getRandomValues === 'function') {
25435
+ return crypto$2.getRandomValues(new Uint8Array(bytesLength));
25436
+ }
25437
+ // Legacy Node.js compatibility
25438
+ if (crypto$2 && typeof crypto$2.randomBytes === 'function') {
25439
+ return Uint8Array.from(crypto$2.randomBytes(bytesLength));
25440
+ }
25441
+ throw new Error('crypto.getRandomValues must be defined');
25442
+ }
25443
+
25685
25444
  /**
25686
25445
  * SHA3 (keccak) hash function, based on a new "Sponge function" design.
25687
25446
  * Different from older hashes, the internal state is bigger than output size.
@@ -25720,12 +25479,12 @@ for (let round = 0, R = _1n$5, x = 1, y = 0; round < 24; round++) {
25720
25479
  }
25721
25480
  _SHA3_IOTA.push(t);
25722
25481
  }
25723
- const IOTAS = split$1(_SHA3_IOTA, true);
25482
+ const IOTAS = split(_SHA3_IOTA, true);
25724
25483
  const SHA3_IOTA_H = IOTAS[0];
25725
25484
  const SHA3_IOTA_L = IOTAS[1];
25726
25485
  // Left rotation (without 0, 32, 64)
25727
- const rotlH = (h, l, s) => (s > 32 ? rotlBH$1(h, l, s) : rotlSH$1(h, l, s));
25728
- const rotlL = (h, l, s) => (s > 32 ? rotlBL$1(h, l, s) : rotlSL$1(h, l, s));
25486
+ const rotlH = (h, l, s) => (s > 32 ? rotlBH(h, l, s) : rotlSH(h, l, s));
25487
+ const rotlL = (h, l, s) => (s > 32 ? rotlBL(h, l, s) : rotlSL(h, l, s));
25729
25488
  /** `keccakf1600` internal function, additionally allows to adjust round count. */
25730
25489
  function keccakP(s, rounds = 24) {
25731
25490
  const B = new Uint32Array(5 * 2);
@@ -25773,7 +25532,7 @@ function keccakP(s, rounds = 24) {
25773
25532
  clean(B);
25774
25533
  }
25775
25534
  /** Keccak sponge function. */
25776
- class Keccak extends Hash$1 {
25535
+ class Keccak extends Hash {
25777
25536
  // NOTE: we accept arguments in bytes instead of bits here.
25778
25537
  constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) {
25779
25538
  super();
@@ -25794,7 +25553,7 @@ class Keccak extends Hash$1 {
25794
25553
  if (!(0 < blockLen && blockLen < 200))
25795
25554
  throw new Error('only keccak-f1600 function is supported');
25796
25555
  this.state = new Uint8Array(200);
25797
- this.state32 = u32$1(this.state);
25556
+ this.state32 = u32(this.state);
25798
25557
  }
25799
25558
  clone() {
25800
25559
  return this._cloneInto();
@@ -25808,7 +25567,7 @@ class Keccak extends Hash$1 {
25808
25567
  }
25809
25568
  update(data) {
25810
25569
  aexists(this);
25811
- data = toBytes$1(data);
25570
+ data = toBytes(data);
25812
25571
  abytes$2(data);
25813
25572
  const { blockLen, state } = this;
25814
25573
  const len = data.length;
@@ -25894,17 +25653,265 @@ const gen = (suffix, blockLen, outputLen) => createHasher(() => new Keccak(block
25894
25653
  /** keccak-256 hash function. Different from SHA3-256. */
25895
25654
  const keccak_256 = /* @__PURE__ */ (() => gen(0x01, 136, 256 / 8))();
25896
25655
 
25656
+ /**
25657
+ * Internal Merkle-Damgard hash utils.
25658
+ * @module
25659
+ */
25660
+ /** Polyfill for Safari 14. https://caniuse.com/mdn-javascript_builtins_dataview_setbiguint64 */
25661
+ function setBigUint64(view, byteOffset, value, isLE) {
25662
+ if (typeof view.setBigUint64 === 'function')
25663
+ return view.setBigUint64(byteOffset, value, isLE);
25664
+ const _32n = BigInt(32);
25665
+ const _u32_max = BigInt(0xffffffff);
25666
+ const wh = Number((value >> _32n) & _u32_max);
25667
+ const wl = Number(value & _u32_max);
25668
+ const h = isLE ? 4 : 0;
25669
+ const l = isLE ? 0 : 4;
25670
+ view.setUint32(byteOffset + h, wh, isLE);
25671
+ view.setUint32(byteOffset + l, wl, isLE);
25672
+ }
25673
+ /** Choice: a ? b : c */
25674
+ function Chi(a, b, c) {
25675
+ return (a & b) ^ (~a & c);
25676
+ }
25677
+ /** Majority function, true if any two inputs is true. */
25678
+ function Maj(a, b, c) {
25679
+ return (a & b) ^ (a & c) ^ (b & c);
25680
+ }
25681
+ /**
25682
+ * Merkle-Damgard hash construction base class.
25683
+ * Could be used to create MD5, RIPEMD, SHA1, SHA2.
25684
+ */
25685
+ class HashMD extends Hash {
25686
+ constructor(blockLen, outputLen, padOffset, isLE) {
25687
+ super();
25688
+ this.finished = false;
25689
+ this.length = 0;
25690
+ this.pos = 0;
25691
+ this.destroyed = false;
25692
+ this.blockLen = blockLen;
25693
+ this.outputLen = outputLen;
25694
+ this.padOffset = padOffset;
25695
+ this.isLE = isLE;
25696
+ this.buffer = new Uint8Array(blockLen);
25697
+ this.view = createView(this.buffer);
25698
+ }
25699
+ update(data) {
25700
+ aexists(this);
25701
+ data = toBytes(data);
25702
+ abytes$2(data);
25703
+ const { view, buffer, blockLen } = this;
25704
+ const len = data.length;
25705
+ for (let pos = 0; pos < len;) {
25706
+ const take = Math.min(blockLen - this.pos, len - pos);
25707
+ // Fast path: we have at least one block in input, cast it to view and process
25708
+ if (take === blockLen) {
25709
+ const dataView = createView(data);
25710
+ for (; blockLen <= len - pos; pos += blockLen)
25711
+ this.process(dataView, pos);
25712
+ continue;
25713
+ }
25714
+ buffer.set(data.subarray(pos, pos + take), this.pos);
25715
+ this.pos += take;
25716
+ pos += take;
25717
+ if (this.pos === blockLen) {
25718
+ this.process(view, 0);
25719
+ this.pos = 0;
25720
+ }
25721
+ }
25722
+ this.length += data.length;
25723
+ this.roundClean();
25724
+ return this;
25725
+ }
25726
+ digestInto(out) {
25727
+ aexists(this);
25728
+ aoutput(out, this);
25729
+ this.finished = true;
25730
+ // Padding
25731
+ // We can avoid allocation of buffer for padding completely if it
25732
+ // was previously not allocated here. But it won't change performance.
25733
+ const { buffer, view, blockLen, isLE } = this;
25734
+ let { pos } = this;
25735
+ // append the bit '1' to the message
25736
+ buffer[pos++] = 0b10000000;
25737
+ clean(this.buffer.subarray(pos));
25738
+ // we have less than padOffset left in buffer, so we cannot put length in
25739
+ // current block, need process it and pad again
25740
+ if (this.padOffset > blockLen - pos) {
25741
+ this.process(view, 0);
25742
+ pos = 0;
25743
+ }
25744
+ // Pad until full block byte with zeros
25745
+ for (let i = pos; i < blockLen; i++)
25746
+ buffer[i] = 0;
25747
+ // Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that
25748
+ // You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen.
25749
+ // So we just write lowest 64 bits of that value.
25750
+ setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);
25751
+ this.process(view, 0);
25752
+ const oview = createView(out);
25753
+ const len = this.outputLen;
25754
+ // NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT
25755
+ if (len % 4)
25756
+ throw new Error('_sha2: outputLen should be aligned to 32bit');
25757
+ const outLen = len / 4;
25758
+ const state = this.get();
25759
+ if (outLen > state.length)
25760
+ throw new Error('_sha2: outputLen bigger than state');
25761
+ for (let i = 0; i < outLen; i++)
25762
+ oview.setUint32(4 * i, state[i], isLE);
25763
+ }
25764
+ digest() {
25765
+ const { buffer, outputLen } = this;
25766
+ this.digestInto(buffer);
25767
+ const res = buffer.slice(0, outputLen);
25768
+ this.destroy();
25769
+ return res;
25770
+ }
25771
+ _cloneInto(to) {
25772
+ to || (to = new this.constructor());
25773
+ to.set(...this.get());
25774
+ const { blockLen, buffer, length, finished, destroyed, pos } = this;
25775
+ to.destroyed = destroyed;
25776
+ to.finished = finished;
25777
+ to.length = length;
25778
+ to.pos = pos;
25779
+ if (length % blockLen)
25780
+ to.buffer.set(buffer);
25781
+ return to;
25782
+ }
25783
+ clone() {
25784
+ return this._cloneInto();
25785
+ }
25786
+ }
25787
+ /**
25788
+ * Initial SHA-2 state: fractional parts of square roots of first 16 primes 2..53.
25789
+ * Check out `test/misc/sha2-gen-iv.js` for recomputation guide.
25790
+ */
25791
+ /** Initial SHA256 state. Bits 0..32 of frac part of sqrt of primes 2..19 */
25792
+ const SHA256_IV = /* @__PURE__ */ Uint32Array.from([
25793
+ 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,
25794
+ ]);
25795
+
25796
+ /**
25797
+ * SHA2 hash function. A.k.a. sha256, sha384, sha512, sha512_224, sha512_256.
25798
+ * SHA256 is the fastest hash implementable in JS, even faster than Blake3.
25799
+ * Check out [RFC 4634](https://datatracker.ietf.org/doc/html/rfc4634) and
25800
+ * [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf).
25801
+ * @module
25802
+ */
25803
+ /**
25804
+ * Round constants:
25805
+ * First 32 bits of fractional parts of the cube roots of the first 64 primes 2..311)
25806
+ */
25807
+ // prettier-ignore
25808
+ const SHA256_K = /* @__PURE__ */ Uint32Array.from([
25809
+ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
25810
+ 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
25811
+ 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
25812
+ 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
25813
+ 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
25814
+ 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
25815
+ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
25816
+ 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
25817
+ ]);
25818
+ /** Reusable temporary buffer. "W" comes straight from spec. */
25819
+ const SHA256_W = /* @__PURE__ */ new Uint32Array(64);
25820
+ class SHA256 extends HashMD {
25821
+ constructor(outputLen = 32) {
25822
+ super(64, outputLen, 8, false);
25823
+ // We cannot use array here since array allows indexing by variable
25824
+ // which means optimizer/compiler cannot use registers.
25825
+ this.A = SHA256_IV[0] | 0;
25826
+ this.B = SHA256_IV[1] | 0;
25827
+ this.C = SHA256_IV[2] | 0;
25828
+ this.D = SHA256_IV[3] | 0;
25829
+ this.E = SHA256_IV[4] | 0;
25830
+ this.F = SHA256_IV[5] | 0;
25831
+ this.G = SHA256_IV[6] | 0;
25832
+ this.H = SHA256_IV[7] | 0;
25833
+ }
25834
+ get() {
25835
+ const { A, B, C, D, E, F, G, H } = this;
25836
+ return [A, B, C, D, E, F, G, H];
25837
+ }
25838
+ // prettier-ignore
25839
+ set(A, B, C, D, E, F, G, H) {
25840
+ this.A = A | 0;
25841
+ this.B = B | 0;
25842
+ this.C = C | 0;
25843
+ this.D = D | 0;
25844
+ this.E = E | 0;
25845
+ this.F = F | 0;
25846
+ this.G = G | 0;
25847
+ this.H = H | 0;
25848
+ }
25849
+ process(view, offset) {
25850
+ // Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array
25851
+ for (let i = 0; i < 16; i++, offset += 4)
25852
+ SHA256_W[i] = view.getUint32(offset, false);
25853
+ for (let i = 16; i < 64; i++) {
25854
+ const W15 = SHA256_W[i - 15];
25855
+ const W2 = SHA256_W[i - 2];
25856
+ const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ (W15 >>> 3);
25857
+ const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ (W2 >>> 10);
25858
+ SHA256_W[i] = (s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16]) | 0;
25859
+ }
25860
+ // Compression function main loop, 64 rounds
25861
+ let { A, B, C, D, E, F, G, H } = this;
25862
+ for (let i = 0; i < 64; i++) {
25863
+ const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
25864
+ const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;
25865
+ const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);
25866
+ const T2 = (sigma0 + Maj(A, B, C)) | 0;
25867
+ H = G;
25868
+ G = F;
25869
+ F = E;
25870
+ E = (D + T1) | 0;
25871
+ D = C;
25872
+ C = B;
25873
+ B = A;
25874
+ A = (T1 + T2) | 0;
25875
+ }
25876
+ // Add the compressed chunk to the current hash value
25877
+ A = (A + this.A) | 0;
25878
+ B = (B + this.B) | 0;
25879
+ C = (C + this.C) | 0;
25880
+ D = (D + this.D) | 0;
25881
+ E = (E + this.E) | 0;
25882
+ F = (F + this.F) | 0;
25883
+ G = (G + this.G) | 0;
25884
+ H = (H + this.H) | 0;
25885
+ this.set(A, B, C, D, E, F, G, H);
25886
+ }
25887
+ roundClean() {
25888
+ clean(SHA256_W);
25889
+ }
25890
+ destroy() {
25891
+ this.set(0, 0, 0, 0, 0, 0, 0, 0);
25892
+ clean(this.buffer);
25893
+ }
25894
+ }
25895
+ /**
25896
+ * SHA2-256 hash function from RFC 4634.
25897
+ *
25898
+ * It is the fastest JS hash, even faster than Blake3.
25899
+ * To break sha256 using birthday attack, attackers need to try 2^128 hashes.
25900
+ * BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025.
25901
+ */
25902
+ const sha256 = /* @__PURE__ */ createHasher(() => new SHA256());
25903
+
25897
25904
  /**
25898
25905
  * HMAC: RFC2104 message authentication code.
25899
25906
  * @module
25900
25907
  */
25901
- class HMAC extends Hash$1 {
25908
+ class HMAC extends Hash {
25902
25909
  constructor(hash, _key) {
25903
25910
  super();
25904
25911
  this.finished = false;
25905
25912
  this.destroyed = false;
25906
25913
  ahash(hash);
25907
- const key = toBytes$1(_key);
25914
+ const key = toBytes(_key);
25908
25915
  this.iHash = hash.create();
25909
25916
  if (typeof this.iHash.update !== 'function')
25910
25917
  throw new Error('Expected instance of class which extends utils.Hash');
@@ -37238,8 +37245,8 @@ function weierstrass(curveDef) {
37238
37245
  function getHash(hash) {
37239
37246
  return {
37240
37247
  hash,
37241
- hmac: (key, ...msgs) => hmac(hash, key, concatBytes$3(...msgs)),
37242
- randomBytes: randomBytes$1,
37248
+ hmac: (key, ...msgs) => hmac(hash, key, concatBytes$1(...msgs)),
37249
+ randomBytes,
37243
37250
  };
37244
37251
  }
37245
37252
  function createCurve(curveDef, defHash) {
@@ -37345,7 +37352,7 @@ const secp256k1 = createCurve({
37345
37352
  return { k1neg, k1, k2neg, k2 };
37346
37353
  },
37347
37354
  },
37348
- }, sha256$2);
37355
+ }, sha256);
37349
37356
 
37350
37357
  /**
37351
37358
  * Deserializes a {@link ox#Hex.Hex} signature into a structured {@link ox#Signature.Signature}.
@@ -42776,7 +42783,6 @@ class OffchainAuthProvider {
42776
42783
  this.config = config;
42777
42784
  // Signal to API layer that this client supports offchain transaction signing
42778
42785
  if (typeof window !== "undefined") {
42779
- console.log("TAROBASE_SUPPORTS_OFFCHAIN_SIGNING", "true");
42780
42786
  window.TAROBASE_SUPPORTS_OFFCHAIN_SIGNING = true;
42781
42787
  }
42782
42788
  }