@wagmi/core 1.3.2-cjs → 1.3.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.
@@ -1,15 +1,15 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
-
3
- var _chunkBVC4KGLQjs = require('./chunk-BVC4KGLQ.js');
4
-
5
-
6
-
7
-
8
-
9
- var _chunkMQXBDTVKjs = require('./chunk-MQXBDTVK.js');
1
+ import {
2
+ InjectedConnector
3
+ } from "./chunk-BVC4KGLQ.js";
4
+ import {
5
+ __privateAdd,
6
+ __privateGet,
7
+ __privateMethod,
8
+ __privateSet
9
+ } from "./chunk-MQXBDTVK.js";
10
10
 
11
11
  // src/utils/configureChains.ts
12
- var _viem = require('viem');
12
+ import { createPublicClient, fallback, http, webSocket } from "viem";
13
13
  function configureChains(defaultChains, providers, {
14
14
  batch = { multicall: { wait: 32 } },
15
15
  pollingInterval = 4e3,
@@ -58,15 +58,15 @@ function configureChains(defaultChains, providers, {
58
58
  return {
59
59
  chains,
60
60
  publicClient: ({ chainId }) => {
61
- const activeChain = _nullishCoalesce(chains.find((x) => x.id === chainId), () => ( defaultChains[0]));
61
+ const activeChain = chains.find((x) => x.id === chainId) ?? defaultChains[0];
62
62
  const chainHttpUrls = httpUrls[activeChain.id];
63
63
  if (!chainHttpUrls || !chainHttpUrls[0])
64
64
  throw new Error(`No providers configured for chain "${activeChain.id}"`);
65
- const publicClient = _viem.createPublicClient.call(void 0, {
65
+ const publicClient = createPublicClient({
66
66
  batch,
67
67
  chain: activeChain,
68
- transport: _viem.fallback.call(void 0,
69
- chainHttpUrls.map((url) => _viem.http.call(void 0, url, { timeout: stallTimeout })),
68
+ transport: fallback(
69
+ chainHttpUrls.map((url) => http(url, { timeout: stallTimeout })),
70
70
  { rank, retryCount, retryDelay }
71
71
  ),
72
72
  pollingInterval
@@ -76,15 +76,15 @@ function configureChains(defaultChains, providers, {
76
76
  });
77
77
  },
78
78
  webSocketPublicClient: ({ chainId }) => {
79
- const activeChain = _nullishCoalesce(chains.find((x) => x.id === chainId), () => ( defaultChains[0]));
79
+ const activeChain = chains.find((x) => x.id === chainId) ?? defaultChains[0];
80
80
  const chainWsUrls = wsUrls[activeChain.id];
81
81
  if (!chainWsUrls || !chainWsUrls[0])
82
82
  return void 0;
83
- const publicClient = _viem.createPublicClient.call(void 0, {
83
+ const publicClient = createPublicClient({
84
84
  batch,
85
85
  chain: activeChain,
86
- transport: _viem.fallback.call(void 0,
87
- chainWsUrls.map((url) => _viem.webSocket.call(void 0, url, { timeout: stallTimeout })),
86
+ transport: fallback(
87
+ chainWsUrls.map((url) => webSocket(url, { timeout: stallTimeout })),
88
88
  { rank, retryCount, retryDelay }
89
89
  ),
90
90
  pollingInterval
@@ -97,7 +97,7 @@ function configureChains(defaultChains, providers, {
97
97
  }
98
98
 
99
99
  // src/errors.ts
100
- var _connectors = require('@wagmi/connectors');
100
+ import { ConnectorNotFoundError } from "@wagmi/connectors";
101
101
  var ChainMismatchError = class extends Error {
102
102
  constructor({
103
103
  activeChain,
@@ -247,13 +247,13 @@ function getSendTransactionParameters(args) {
247
247
  }
248
248
 
249
249
  // src/utils/getUnit.ts
250
-
250
+ import { weiUnits } from "viem";
251
251
  function getUnit(unit) {
252
252
  if (typeof unit === "number")
253
253
  return unit;
254
254
  if (unit === "wei")
255
255
  return 0;
256
- return Math.abs(_viem.weiUnits[unit]);
256
+ return Math.abs(weiUnits[unit]);
257
257
  }
258
258
 
259
259
  // src/utils/serialize.ts
@@ -307,15 +307,15 @@ function serialize(value, replacer, indent, circularReplacer) {
307
307
  value,
308
308
  createReplacer((key, value_) => {
309
309
  const value2 = typeof value_ === "bigint" ? `#bigint.${value_.toString()}` : value_;
310
- return _optionalChain([replacer, 'optionalCall', _2 => _2(key, value2)]) || value2;
310
+ return replacer?.(key, value2) || value2;
311
311
  }, circularReplacer),
312
- _nullishCoalesce(indent, () => ( void 0))
312
+ indent ?? void 0
313
313
  );
314
314
  }
315
315
 
316
316
  // src/config.ts
317
- var _middleware = require('zustand/middleware');
318
- var _vanilla = require('zustand/vanilla');
317
+ import { persist, subscribeWithSelector } from "zustand/middleware";
318
+ import { createStore } from "zustand/vanilla";
319
319
 
320
320
  // src/storage.ts
321
321
  var noopStorage = {
@@ -361,7 +361,7 @@ var _isAutoConnecting, _lastUsedConnector, _addEffects, addEffects_fn;
361
361
  var Config = class {
362
362
  constructor({
363
363
  autoConnect = false,
364
- connectors = [new (0, _chunkBVC4KGLQjs.InjectedConnector)()],
364
+ connectors = [new InjectedConnector()],
365
365
  publicClient,
366
366
  storage = createStorage({
367
367
  storage: typeof window !== "undefined" ? window.localStorage : noopStorage
@@ -371,11 +371,11 @@ var Config = class {
371
371
  },
372
372
  webSocketPublicClient
373
373
  }) {
374
- _chunkMQXBDTVKjs.__privateAdd.call(void 0, this, _addEffects);
374
+ __privateAdd(this, _addEffects);
375
375
  this.publicClients = /* @__PURE__ */ new Map();
376
376
  this.webSocketPublicClients = /* @__PURE__ */ new Map();
377
- _chunkMQXBDTVKjs.__privateAdd.call(void 0, this, _isAutoConnecting, void 0);
378
- _chunkMQXBDTVKjs.__privateAdd.call(void 0, this, _lastUsedConnector, void 0);
377
+ __privateAdd(this, _isAutoConnecting, void 0);
378
+ __privateAdd(this, _lastUsedConnector, void 0);
379
379
  this.args = {
380
380
  autoConnect,
381
381
  connectors,
@@ -389,17 +389,17 @@ var Config = class {
389
389
  if (autoConnect) {
390
390
  try {
391
391
  const rawState = storage.getItem(storeKey);
392
- const data = _optionalChain([rawState, 'optionalAccess', _3 => _3.state, 'optionalAccess', _4 => _4.data]);
393
- status = _optionalChain([data, 'optionalAccess', _5 => _5.account]) ? "reconnecting" : "connecting";
394
- chainId = _optionalChain([data, 'optionalAccess', _6 => _6.chain, 'optionalAccess', _7 => _7.id]);
392
+ const data = rawState?.state?.data;
393
+ status = data?.account ? "reconnecting" : "connecting";
394
+ chainId = data?.chain?.id;
395
395
  } catch (_error) {
396
396
  }
397
397
  }
398
398
  const connectors_ = typeof connectors === "function" ? connectors() : connectors;
399
399
  connectors_.forEach((connector) => connector.setStorage(storage));
400
- this.store = _vanilla.createStore.call(void 0,
401
- _middleware.subscribeWithSelector.call(void 0,
402
- _middleware.persist.call(void 0,
400
+ this.store = createStore(
401
+ subscribeWithSelector(
402
+ persist(
403
403
  () => ({
404
404
  connectors: connectors_,
405
405
  publicClient: this.getPublicClient({ chainId }),
@@ -412,11 +412,11 @@ var Config = class {
412
412
  partialize: (state) => ({
413
413
  ...autoConnect && {
414
414
  data: {
415
- account: _optionalChain([state, 'optionalAccess', _8 => _8.data, 'optionalAccess', _9 => _9.account]),
416
- chain: _optionalChain([state, 'optionalAccess', _10 => _10.data, 'optionalAccess', _11 => _11.chain])
415
+ account: state?.data?.account,
416
+ chain: state?.data?.chain
417
417
  }
418
418
  },
419
- chains: _optionalChain([state, 'optionalAccess', _12 => _12.chains])
419
+ chains: state?.chains
420
420
  }),
421
421
  version: 2
422
422
  }
@@ -424,8 +424,8 @@ var Config = class {
424
424
  )
425
425
  );
426
426
  this.storage = storage;
427
- _chunkMQXBDTVKjs.__privateSet.call(void 0, this, _lastUsedConnector, _optionalChain([storage, 'optionalAccess', _13 => _13.getItem, 'call', _14 => _14("wallet")]));
428
- _chunkMQXBDTVKjs.__privateMethod.call(void 0, this, _addEffects, addEffects_fn).call(this);
427
+ __privateSet(this, _lastUsedConnector, storage?.getItem("wallet"));
428
+ __privateMethod(this, _addEffects, addEffects_fn).call(this);
429
429
  if (autoConnect && typeof window !== "undefined")
430
430
  setTimeout(async () => await this.autoConnect(), 0);
431
431
  }
@@ -445,7 +445,7 @@ var Config = class {
445
445
  return this.store.getState().error;
446
446
  }
447
447
  get lastUsedChainId() {
448
- return _optionalChain([this, 'access', _15 => _15.data, 'optionalAccess', _16 => _16.chain, 'optionalAccess', _17 => _17.id]);
448
+ return this.data?.chain?.id;
449
449
  }
450
450
  get publicClient() {
451
451
  return this.store.getState().publicClient;
@@ -475,21 +475,21 @@ var Config = class {
475
475
  }
476
476
  async destroy() {
477
477
  if (this.connector)
478
- await _optionalChain([this, 'access', _18 => _18.connector, 'access', _19 => _19.disconnect, 'optionalCall', _20 => _20()]);
479
- _chunkMQXBDTVKjs.__privateSet.call(void 0, this, _isAutoConnecting, false);
478
+ await this.connector.disconnect?.();
479
+ __privateSet(this, _isAutoConnecting, false);
480
480
  this.clearState();
481
481
  this.store.destroy();
482
482
  }
483
483
  async autoConnect() {
484
- if (_chunkMQXBDTVKjs.__privateGet.call(void 0, this, _isAutoConnecting))
484
+ if (__privateGet(this, _isAutoConnecting))
485
485
  return;
486
- _chunkMQXBDTVKjs.__privateSet.call(void 0, this, _isAutoConnecting, true);
486
+ __privateSet(this, _isAutoConnecting, true);
487
487
  this.setState((x) => ({
488
488
  ...x,
489
- status: _optionalChain([x, 'access', _21 => _21.data, 'optionalAccess', _22 => _22.account]) ? "reconnecting" : "connecting"
489
+ status: x.data?.account ? "reconnecting" : "connecting"
490
490
  }));
491
- const sorted = _chunkMQXBDTVKjs.__privateGet.call(void 0, this, _lastUsedConnector) ? [...this.connectors].sort(
492
- (x) => x.id === _chunkMQXBDTVKjs.__privateGet.call(void 0, this, _lastUsedConnector) ? -1 : 1
491
+ const sorted = __privateGet(this, _lastUsedConnector) ? [...this.connectors].sort(
492
+ (x) => x.id === __privateGet(this, _lastUsedConnector) ? -1 : 1
493
493
  ) : this.connectors;
494
494
  let connected = false;
495
495
  for (const connector of sorted) {
@@ -502,7 +502,7 @@ var Config = class {
502
502
  this.setState((x) => ({
503
503
  ...x,
504
504
  connector,
505
- chains: _optionalChain([connector, 'optionalAccess', _23 => _23.chains]),
505
+ chains: connector?.chains,
506
506
  data,
507
507
  status: "connected"
508
508
  }));
@@ -515,7 +515,7 @@ var Config = class {
515
515
  data: void 0,
516
516
  status: "disconnected"
517
517
  }));
518
- _chunkMQXBDTVKjs.__privateSet.call(void 0, this, _isAutoConnecting, false);
518
+ __privateSet(this, _isAutoConnecting, false);
519
519
  return this.data;
520
520
  }
521
521
  setConnectors(connectors) {
@@ -532,18 +532,18 @@ var Config = class {
532
532
  }
533
533
  getPublicClient({ chainId } = {}) {
534
534
  let publicClient_ = this.publicClients.get(-1);
535
- if (publicClient_ && _optionalChain([publicClient_, 'optionalAccess', _24 => _24.chain, 'access', _25 => _25.id]) === chainId)
535
+ if (publicClient_ && publicClient_?.chain.id === chainId)
536
536
  return publicClient_;
537
- publicClient_ = this.publicClients.get(_nullishCoalesce(chainId, () => ( -1)));
537
+ publicClient_ = this.publicClients.get(chainId ?? -1);
538
538
  if (publicClient_)
539
539
  return publicClient_;
540
540
  const { publicClient } = this.args;
541
541
  publicClient_ = typeof publicClient === "function" ? publicClient({ chainId }) : publicClient;
542
- this.publicClients.set(_nullishCoalesce(chainId, () => ( -1)), publicClient_);
542
+ this.publicClients.set(chainId ?? -1, publicClient_);
543
543
  return publicClient_;
544
544
  }
545
545
  setPublicClient(publicClient) {
546
- const chainId = _optionalChain([this, 'access', _26 => _26.data, 'optionalAccess', _27 => _27.chain, 'optionalAccess', _28 => _28.id]);
546
+ const chainId = this.data?.chain?.id;
547
547
  this.args = {
548
548
  ...this.args,
549
549
  publicClient
@@ -556,19 +556,19 @@ var Config = class {
556
556
  }
557
557
  getWebSocketPublicClient({ chainId } = {}) {
558
558
  let webSocketPublicClient_ = this.webSocketPublicClients.get(-1);
559
- if (webSocketPublicClient_ && _optionalChain([webSocketPublicClient_, 'optionalAccess', _29 => _29.chain, 'access', _30 => _30.id]) === chainId)
559
+ if (webSocketPublicClient_ && webSocketPublicClient_?.chain.id === chainId)
560
560
  return webSocketPublicClient_;
561
- webSocketPublicClient_ = this.webSocketPublicClients.get(_nullishCoalesce(chainId, () => ( -1)));
561
+ webSocketPublicClient_ = this.webSocketPublicClients.get(chainId ?? -1);
562
562
  if (webSocketPublicClient_)
563
563
  return webSocketPublicClient_;
564
564
  const { webSocketPublicClient } = this.args;
565
565
  webSocketPublicClient_ = typeof webSocketPublicClient === "function" ? webSocketPublicClient({ chainId }) : webSocketPublicClient;
566
566
  if (webSocketPublicClient_)
567
- this.webSocketPublicClients.set(_nullishCoalesce(chainId, () => ( -1)), webSocketPublicClient_);
567
+ this.webSocketPublicClients.set(chainId ?? -1, webSocketPublicClient_);
568
568
  return webSocketPublicClient_;
569
569
  }
570
570
  setWebSocketPublicClient(webSocketPublicClient) {
571
- const chainId = _optionalChain([this, 'access', _31 => _31.data, 'optionalAccess', _32 => _32.chain, 'optionalAccess', _33 => _33.id]);
571
+ const chainId = this.data?.chain?.id;
572
572
  this.args = {
573
573
  ...this.args,
574
574
  webSocketPublicClient
@@ -582,7 +582,7 @@ var Config = class {
582
582
  }));
583
583
  }
584
584
  setLastUsedConnector(lastUsedConnector = null) {
585
- _optionalChain([this, 'access', _34 => _34.storage, 'optionalAccess', _35 => _35.setItem, 'call', _36 => _36("wallet", lastUsedConnector)]);
585
+ this.storage?.setItem("wallet", lastUsedConnector);
586
586
  }
587
587
  };
588
588
  _isAutoConnecting = new WeakMap();
@@ -604,14 +604,14 @@ addEffects_fn = function() {
604
604
  this.store.subscribe(
605
605
  ({ connector }) => connector,
606
606
  (connector, prevConnector) => {
607
- _optionalChain([prevConnector, 'optionalAccess', _37 => _37.off, 'optionalCall', _38 => _38("change", onChange)]);
608
- _optionalChain([prevConnector, 'optionalAccess', _39 => _39.off, 'optionalCall', _40 => _40("disconnect", onDisconnect)]);
609
- _optionalChain([prevConnector, 'optionalAccess', _41 => _41.off, 'optionalCall', _42 => _42("error", onError)]);
607
+ prevConnector?.off?.("change", onChange);
608
+ prevConnector?.off?.("disconnect", onDisconnect);
609
+ prevConnector?.off?.("error", onError);
610
610
  if (!connector)
611
611
  return;
612
- _optionalChain([connector, 'access', _43 => _43.on, 'optionalCall', _44 => _44("change", onChange)]);
613
- _optionalChain([connector, 'access', _45 => _45.on, 'optionalCall', _46 => _46("disconnect", onDisconnect)]);
614
- _optionalChain([connector, 'access', _47 => _47.on, 'optionalCall', _48 => _48("error", onError)]);
612
+ connector.on?.("change", onChange);
613
+ connector.on?.("disconnect", onDisconnect);
614
+ connector.on?.("error", onError);
615
615
  }
616
616
  );
617
617
  const { publicClient, webSocketPublicClient } = this.args;
@@ -619,7 +619,7 @@ addEffects_fn = function() {
619
619
  const subscribeWebSocketPublicClient = typeof webSocketPublicClient === "function";
620
620
  if (subscribePublicClient || subscribeWebSocketPublicClient)
621
621
  this.store.subscribe(
622
- ({ data }) => _optionalChain([data, 'optionalAccess', _49 => _49.chain, 'optionalAccess', _50 => _50.id]),
622
+ ({ data }) => data?.chain?.id,
623
623
  (chainId) => {
624
624
  this.setState((x) => ({
625
625
  ...x,
@@ -659,7 +659,7 @@ async function connect({ chainId, connector }) {
659
659
  config2.setState((x) => ({
660
660
  ...x,
661
661
  connector,
662
- chains: _optionalChain([connector, 'optionalAccess', _51 => _51.chains]),
662
+ chains: connector?.chains,
663
663
  data,
664
664
  status: "connected"
665
665
  }));
@@ -686,12 +686,12 @@ async function disconnect() {
686
686
  }
687
687
 
688
688
  // src/actions/accounts/fetchBalance.ts
689
-
690
-
691
-
692
-
693
-
694
-
689
+ import {
690
+ ContractFunctionExecutionError as ContractFunctionExecutionError3,
691
+ formatUnits as formatUnits2,
692
+ hexToString as hexToString2,
693
+ trim as trim2
694
+ } from "viem";
695
695
 
696
696
  // src/constants/abis.ts
697
697
  var erc20ABI = [
@@ -1922,12 +1922,12 @@ var erc4626ABI = [
1922
1922
  ];
1923
1923
 
1924
1924
  // src/actions/contracts/fetchToken.ts
1925
-
1926
-
1927
-
1928
-
1929
-
1930
-
1925
+ import {
1926
+ ContractFunctionExecutionError,
1927
+ formatUnits,
1928
+ hexToString,
1929
+ trim
1930
+ } from "viem";
1931
1931
  async function fetchToken({
1932
1932
  address,
1933
1933
  chainId,
@@ -1950,7 +1950,7 @@ async function fetchToken({
1950
1950
  name,
1951
1951
  symbol,
1952
1952
  totalSupply: {
1953
- formatted: _viem.formatUnits.call(void 0, totalSupply, getUnit(unit)),
1953
+ formatted: formatUnits(totalSupply, getUnit(unit)),
1954
1954
  value: totalSupply
1955
1955
  }
1956
1956
  };
@@ -1958,13 +1958,13 @@ async function fetchToken({
1958
1958
  try {
1959
1959
  return await fetchToken_({ abi: erc20ABI });
1960
1960
  } catch (err) {
1961
- if (err instanceof _viem.ContractFunctionExecutionError) {
1961
+ if (err instanceof ContractFunctionExecutionError) {
1962
1962
  const { name, symbol, ...rest } = await fetchToken_({
1963
1963
  abi: erc20ABI_bytes32
1964
1964
  });
1965
1965
  return {
1966
- name: _viem.hexToString.call(void 0, _viem.trim.call(void 0, name, { dir: "right" })),
1967
- symbol: _viem.hexToString.call(void 0, _viem.trim.call(void 0, symbol, { dir: "right" })),
1966
+ name: hexToString(trim(name, { dir: "right" })),
1967
+ symbol: hexToString(trim(symbol, { dir: "right" })),
1968
1968
  ...rest
1969
1969
  };
1970
1970
  }
@@ -1985,7 +1985,7 @@ async function getWalletClient({
1985
1985
  chainId
1986
1986
  } = {}) {
1987
1987
  const config2 = getConfig();
1988
- const walletClient = await _optionalChain([config2, 'access', _52 => _52.connector, 'optionalAccess', _53 => _53.getWalletClient, 'optionalCall', _54 => _54({ chainId })]) || null;
1988
+ const walletClient = await config2.connector?.getWalletClient?.({ chainId }) || null;
1989
1989
  return walletClient;
1990
1990
  }
1991
1991
 
@@ -2011,7 +2011,7 @@ function watchPublicClient(args, callback) {
2011
2011
  }
2012
2012
 
2013
2013
  // src/actions/viem/watchWalletClient.ts
2014
- var _shallow = require('zustand/shallow');
2014
+ import { shallow } from "zustand/shallow";
2015
2015
  function watchWalletClient({ chainId }, callback) {
2016
2016
  const config2 = getConfig();
2017
2017
  const handleChange = async ({ chainId: chainId_ }) => {
@@ -2024,13 +2024,13 @@ function watchWalletClient({ chainId }, callback) {
2024
2024
  };
2025
2025
  const unsubscribe = config2.subscribe(
2026
2026
  ({ data, connector }) => ({
2027
- account: _optionalChain([data, 'optionalAccess', _55 => _55.account]),
2028
- chainId: _optionalChain([data, 'optionalAccess', _56 => _56.chain, 'optionalAccess', _57 => _57.id]),
2027
+ account: data?.account,
2028
+ chainId: data?.chain?.id,
2029
2029
  connector
2030
2030
  }),
2031
2031
  handleChange,
2032
2032
  {
2033
- equalityFn: _shallow.shallow
2033
+ equalityFn: shallow
2034
2034
  }
2035
2035
  );
2036
2036
  return unsubscribe;
@@ -2058,9 +2058,9 @@ async function prepareWriteContract({
2058
2058
  ...config2
2059
2059
  }) {
2060
2060
  const publicClient = getPublicClient({ chainId });
2061
- const walletClient = await _asyncNullishCoalesce(walletClient_, async () => ( await getWalletClient({ chainId })));
2061
+ const walletClient = walletClient_ ?? await getWalletClient({ chainId });
2062
2062
  if (!walletClient)
2063
- throw new (0, _connectors.ConnectorNotFoundError)();
2063
+ throw new ConnectorNotFoundError();
2064
2064
  if (chainId)
2065
2065
  assertActiveChain({ chainId });
2066
2066
  const {
@@ -2106,7 +2106,7 @@ async function prepareWriteContract({
2106
2106
  }
2107
2107
 
2108
2108
  // src/actions/contracts/getContract.ts
2109
-
2109
+ import { getContract as getContract_ } from "viem";
2110
2110
  function getContract({
2111
2111
  address,
2112
2112
  abi,
@@ -2114,7 +2114,7 @@ function getContract({
2114
2114
  walletClient
2115
2115
  }) {
2116
2116
  const publicClient = getPublicClient({ chainId });
2117
- return _viem.getContract.call(void 0, {
2117
+ return getContract_({
2118
2118
  address,
2119
2119
  abi,
2120
2120
  publicClient,
@@ -2136,7 +2136,7 @@ async function multicall({
2136
2136
  if (chainId && publicClient.chain.id !== chainId)
2137
2137
  throw new ChainNotConfiguredError({ chainId });
2138
2138
  return publicClient.multicall({
2139
- allowFailure: _nullishCoalesce(args.allowFailure, () => ( true)),
2139
+ allowFailure: args.allowFailure ?? true,
2140
2140
  blockNumber,
2141
2141
  blockTag,
2142
2142
  contracts
@@ -2167,7 +2167,7 @@ async function readContract({
2167
2167
  }
2168
2168
 
2169
2169
  // src/actions/contracts/readContracts.ts
2170
-
2170
+ import { ContractFunctionExecutionError as ContractFunctionExecutionError2 } from "viem";
2171
2171
  async function readContracts({
2172
2172
  contracts,
2173
2173
  blockNumber,
@@ -2178,7 +2178,7 @@ async function readContracts({
2178
2178
  try {
2179
2179
  const publicClient = getPublicClient();
2180
2180
  const contractsByChainId = contracts.reduce((contracts2, contract, index) => {
2181
- const chainId = _nullishCoalesce(contract.chainId, () => ( publicClient.chain.id));
2181
+ const chainId = contract.chainId ?? publicClient.chain.id;
2182
2182
  return {
2183
2183
  ...contracts2,
2184
2184
  [chainId]: [...contracts2[chainId] || [], { contract, index }]
@@ -2205,7 +2205,7 @@ async function readContracts({
2205
2205
  return results;
2206
2206
  }, []);
2207
2207
  } catch (err) {
2208
- if (err instanceof _viem.ContractFunctionExecutionError)
2208
+ if (err instanceof ContractFunctionExecutionError2)
2209
2209
  throw err;
2210
2210
  const promises = () => contracts.map(
2211
2211
  (contract) => readContract({ ...contract, blockNumber, blockTag })
@@ -2221,7 +2221,7 @@ async function readContracts({
2221
2221
  }
2222
2222
 
2223
2223
  // src/actions/contracts/watchContractEvent.ts
2224
-
2224
+ import { shallow as shallow2 } from "zustand/shallow";
2225
2225
  function watchContractEvent({
2226
2226
  address,
2227
2227
  abi,
@@ -2248,16 +2248,16 @@ function watchContractEvent({
2248
2248
  webSocketPublicClient
2249
2249
  }),
2250
2250
  watchEvent,
2251
- { equalityFn: _shallow.shallow }
2251
+ { equalityFn: shallow2 }
2252
2252
  );
2253
2253
  return () => {
2254
- _optionalChain([unwatch, 'optionalCall', _58 => _58()]);
2254
+ unwatch?.();
2255
2255
  unsubscribe();
2256
2256
  };
2257
2257
  }
2258
2258
 
2259
2259
  // src/actions/network-status/watchBlockNumber.ts
2260
-
2260
+ import { shallow as shallow3 } from "zustand/shallow";
2261
2261
  function watchBlockNumber(args, callback) {
2262
2262
  let unwatch;
2263
2263
  const createListener = (publicClient) => {
@@ -2269,7 +2269,7 @@ function watchBlockNumber(args, callback) {
2269
2269
  poll: true
2270
2270
  });
2271
2271
  };
2272
- const publicClient_ = _nullishCoalesce(getWebSocketPublicClient({ chainId: args.chainId }), () => ( getPublicClient({ chainId: args.chainId })));
2272
+ const publicClient_ = getWebSocketPublicClient({ chainId: args.chainId }) ?? getPublicClient({ chainId: args.chainId });
2273
2273
  if (args.listen)
2274
2274
  createListener(publicClient_);
2275
2275
  const config2 = getConfig();
@@ -2279,18 +2279,18 @@ function watchBlockNumber(args, callback) {
2279
2279
  webSocketPublicClient
2280
2280
  }),
2281
2281
  async ({ publicClient, webSocketPublicClient }) => {
2282
- const publicClient_2 = _nullishCoalesce(webSocketPublicClient, () => ( publicClient));
2282
+ const publicClient_2 = webSocketPublicClient ?? publicClient;
2283
2283
  if (args.listen && !args.chainId && publicClient_2) {
2284
2284
  createListener(publicClient_2);
2285
2285
  }
2286
2286
  },
2287
2287
  {
2288
- equalityFn: _shallow.shallow
2288
+ equalityFn: shallow3
2289
2289
  }
2290
2290
  );
2291
2291
  return () => {
2292
2292
  unsubscribe();
2293
- _optionalChain([unwatch, 'optionalCall', _59 => _59()]);
2293
+ unwatch?.();
2294
2294
  };
2295
2295
  }
2296
2296
 
@@ -2305,7 +2305,7 @@ function watchMulticall(args, callback) {
2305
2305
  );
2306
2306
  return () => {
2307
2307
  unsubscribe();
2308
- _optionalChain([unwatch, 'optionalCall', _60 => _60()]);
2308
+ unwatch?.();
2309
2309
  };
2310
2310
  }
2311
2311
 
@@ -2320,7 +2320,7 @@ function watchReadContract(args, callback) {
2320
2320
  );
2321
2321
  return () => {
2322
2322
  unsubscribe();
2323
- _optionalChain([unwatch, 'optionalCall', _61 => _61()]);
2323
+ unwatch?.();
2324
2324
  };
2325
2325
  }
2326
2326
 
@@ -2335,7 +2335,7 @@ function watchReadContracts(args, callback) {
2335
2335
  );
2336
2336
  return () => {
2337
2337
  unsubscribe();
2338
- _optionalChain([unwatch, 'optionalCall', _62 => _62()]);
2338
+ unwatch?.();
2339
2339
  };
2340
2340
  }
2341
2341
 
@@ -2343,7 +2343,7 @@ function watchReadContracts(args, callback) {
2343
2343
  async function writeContract(config2) {
2344
2344
  const walletClient = await getWalletClient({ chainId: config2.chainId });
2345
2345
  if (!walletClient)
2346
- throw new (0, _connectors.ConnectorNotFoundError)();
2346
+ throw new ConnectorNotFoundError();
2347
2347
  if (config2.chainId)
2348
2348
  assertActiveChain({ chainId: config2.chainId });
2349
2349
  let request;
@@ -2387,7 +2387,7 @@ async function fetchBalance({
2387
2387
  });
2388
2388
  return {
2389
2389
  decimals,
2390
- formatted: _viem.formatUnits.call(void 0, _nullishCoalesce(value2, () => ( "0")), getUnit(_nullishCoalesce(unit, () => ( decimals)))),
2390
+ formatted: formatUnits2(value2 ?? "0", getUnit(unit ?? decimals)),
2391
2391
  symbol,
2392
2392
  value: value2
2393
2393
  };
@@ -2395,12 +2395,12 @@ async function fetchBalance({
2395
2395
  try {
2396
2396
  return await fetchContractBalance({ abi: erc20ABI });
2397
2397
  } catch (err) {
2398
- if (err instanceof _viem.ContractFunctionExecutionError) {
2398
+ if (err instanceof ContractFunctionExecutionError3) {
2399
2399
  const { symbol, ...rest } = await fetchContractBalance({
2400
2400
  abi: erc20ABI_bytes32
2401
2401
  });
2402
2402
  return {
2403
- symbol: _viem.hexToString.call(void 0, _viem.trim.call(void 0, symbol, { dir: "right" })),
2403
+ symbol: hexToString2(trim2(symbol, { dir: "right" })),
2404
2404
  ...rest
2405
2405
  };
2406
2406
  }
@@ -2409,14 +2409,14 @@ async function fetchBalance({
2409
2409
  }
2410
2410
  const chains = [
2411
2411
  ...config2.publicClient.chains || [],
2412
- ..._nullishCoalesce(config2.chains, () => ( []))
2412
+ ...config2.chains ?? []
2413
2413
  ];
2414
2414
  const value = await publicClient.getBalance({ address });
2415
2415
  const chain = chains.find((x) => x.id === publicClient.chain.id);
2416
2416
  return {
2417
- decimals: _nullishCoalesce(_optionalChain([chain, 'optionalAccess', _63 => _63.nativeCurrency, 'access', _64 => _64.decimals]), () => ( 18)),
2418
- formatted: _viem.formatUnits.call(void 0, _nullishCoalesce(value, () => ( "0")), getUnit(_nullishCoalesce(unit, () => ( 18)))),
2419
- symbol: _nullishCoalesce(_optionalChain([chain, 'optionalAccess', _65 => _65.nativeCurrency, 'access', _66 => _66.symbol]), () => ( "ETH")),
2417
+ decimals: chain?.nativeCurrency.decimals ?? 18,
2418
+ formatted: formatUnits2(value ?? "0", getUnit(unit ?? 18)),
2419
+ symbol: chain?.nativeCurrency.symbol ?? "ETH",
2420
2420
  value
2421
2421
  };
2422
2422
  }
@@ -2427,7 +2427,7 @@ function getAccount() {
2427
2427
  switch (status) {
2428
2428
  case "connected":
2429
2429
  return {
2430
- address: _optionalChain([data, 'optionalAccess', _67 => _67.account]),
2430
+ address: data?.account,
2431
2431
  connector,
2432
2432
  isConnected: true,
2433
2433
  isConnecting: false,
@@ -2437,9 +2437,9 @@ function getAccount() {
2437
2437
  };
2438
2438
  case "reconnecting":
2439
2439
  return {
2440
- address: _optionalChain([data, 'optionalAccess', _68 => _68.account]),
2440
+ address: data?.account,
2441
2441
  connector,
2442
- isConnected: !!_optionalChain([data, 'optionalAccess', _69 => _69.account]),
2442
+ isConnected: !!data?.account,
2443
2443
  isConnecting: false,
2444
2444
  isDisconnected: false,
2445
2445
  isReconnecting: true,
@@ -2447,7 +2447,7 @@ function getAccount() {
2447
2447
  };
2448
2448
  case "connecting":
2449
2449
  return {
2450
- address: _optionalChain([data, 'optionalAccess', _70 => _70.account]),
2450
+ address: data?.account,
2451
2451
  connector,
2452
2452
  isConnected: false,
2453
2453
  isConnecting: true,
@@ -2471,12 +2471,12 @@ function getAccount() {
2471
2471
  // src/actions/accounts/getNetwork.ts
2472
2472
  function getNetwork() {
2473
2473
  const config2 = getConfig();
2474
- const chainId = _optionalChain([config2, 'access', _71 => _71.data, 'optionalAccess', _72 => _72.chain, 'optionalAccess', _73 => _73.id]);
2475
- const activeChains = _nullishCoalesce(config2.chains, () => ( []));
2476
- const activeChain = _nullishCoalesce([
2477
- ..._optionalChain([config2, 'access', _74 => _74.publicClient, 'optionalAccess', _75 => _75.chains]) || [],
2474
+ const chainId = config2.data?.chain?.id;
2475
+ const activeChains = config2.chains ?? [];
2476
+ const activeChain = [
2477
+ ...config2.publicClient?.chains || [],
2478
2478
  ...activeChains
2479
- ].find((x) => x.id === chainId), () => ( {
2479
+ ].find((x) => x.id === chainId) ?? {
2480
2480
  id: chainId,
2481
2481
  name: `Chain ${chainId}`,
2482
2482
  network: `${chainId}`,
@@ -2485,11 +2485,11 @@ function getNetwork() {
2485
2485
  default: { http: [""] },
2486
2486
  public: { http: [""] }
2487
2487
  }
2488
- }));
2488
+ };
2489
2489
  return {
2490
2490
  chain: chainId ? {
2491
2491
  ...activeChain,
2492
- ..._optionalChain([config2, 'access', _76 => _76.data, 'optionalAccess', _77 => _77.chain]),
2492
+ ...config2.data?.chain,
2493
2493
  id: chainId
2494
2494
  } : void 0,
2495
2495
  chains: activeChains
@@ -2500,7 +2500,7 @@ function getNetwork() {
2500
2500
  async function signMessage(args) {
2501
2501
  const walletClient = await getWalletClient();
2502
2502
  if (!walletClient)
2503
- throw new (0, _connectors.ConnectorNotFoundError)();
2503
+ throw new ConnectorNotFoundError();
2504
2504
  return await walletClient.signMessage({
2505
2505
  message: args.message
2506
2506
  });
@@ -2515,7 +2515,7 @@ async function signTypedData({
2515
2515
  }) {
2516
2516
  const walletClient = await getWalletClient();
2517
2517
  if (!walletClient)
2518
- throw new (0, _connectors.ConnectorNotFoundError)();
2518
+ throw new ConnectorNotFoundError();
2519
2519
  const { chainId } = domain;
2520
2520
  if (chainId)
2521
2521
  assertActiveChain({ chainId });
@@ -2533,7 +2533,7 @@ async function switchNetwork({
2533
2533
  }) {
2534
2534
  const { connector } = getConfig();
2535
2535
  if (!connector)
2536
- throw new (0, _connectors.ConnectorNotFoundError)();
2536
+ throw new ConnectorNotFoundError();
2537
2537
  if (!connector.switchChain)
2538
2538
  throw new SwitchChainNotSupportedError({
2539
2539
  connector
@@ -2542,90 +2542,90 @@ async function switchNetwork({
2542
2542
  }
2543
2543
 
2544
2544
  // src/actions/accounts/watchAccount.ts
2545
-
2545
+ import { shallow as shallow4 } from "zustand/shallow";
2546
2546
  function watchAccount(callback, { selector = (x) => x } = {}) {
2547
2547
  const config2 = getConfig();
2548
2548
  const handleChange = () => callback(getAccount());
2549
2549
  const unsubscribe = config2.subscribe(
2550
2550
  ({ data, connector, status }) => selector({
2551
- address: _optionalChain([data, 'optionalAccess', _78 => _78.account]),
2551
+ address: data?.account,
2552
2552
  connector,
2553
2553
  status
2554
2554
  }),
2555
2555
  handleChange,
2556
2556
  {
2557
- equalityFn: _shallow.shallow
2557
+ equalityFn: shallow4
2558
2558
  }
2559
2559
  );
2560
2560
  return unsubscribe;
2561
2561
  }
2562
2562
 
2563
2563
  // src/actions/accounts/watchNetwork.ts
2564
-
2564
+ import { shallow as shallow5 } from "zustand/shallow";
2565
2565
  function watchNetwork(callback, { selector = (x) => x } = {}) {
2566
2566
  const config2 = getConfig();
2567
2567
  const handleChange = () => callback(getNetwork());
2568
2568
  const unsubscribe = config2.subscribe(
2569
- ({ data, chains }) => selector({ chainId: _optionalChain([data, 'optionalAccess', _79 => _79.chain, 'optionalAccess', _80 => _80.id]), chains }),
2569
+ ({ data, chains }) => selector({ chainId: data?.chain?.id, chains }),
2570
2570
  handleChange,
2571
2571
  {
2572
- equalityFn: _shallow.shallow
2572
+ equalityFn: shallow5
2573
2573
  }
2574
2574
  );
2575
2575
  return unsubscribe;
2576
2576
  }
2577
2577
 
2578
2578
  // src/actions/ens/fetchEnsAddress.ts
2579
-
2580
- var _ens = require('viem/ens');
2579
+ import { getAddress } from "viem";
2580
+ import { normalize } from "viem/ens";
2581
2581
  async function fetchEnsAddress({
2582
2582
  chainId,
2583
2583
  name
2584
2584
  }) {
2585
2585
  const publicClient = getPublicClient({ chainId });
2586
2586
  const address = await publicClient.getEnsAddress({
2587
- name: _ens.normalize.call(void 0, name)
2587
+ name: normalize(name)
2588
2588
  });
2589
2589
  try {
2590
2590
  if (address === "0x0000000000000000000000000000000000000000")
2591
2591
  return null;
2592
- return address ? _viem.getAddress.call(void 0, address) : null;
2592
+ return address ? getAddress(address) : null;
2593
2593
  } catch (_error) {
2594
2594
  return null;
2595
2595
  }
2596
2596
  }
2597
2597
 
2598
2598
  // src/actions/ens/fetchEnsAvatar.ts
2599
-
2599
+ import { normalize as normalize2 } from "viem/ens";
2600
2600
  async function fetchEnsAvatar({
2601
2601
  name,
2602
2602
  chainId
2603
2603
  }) {
2604
2604
  const publicClient = getPublicClient({ chainId });
2605
- const avatar = await publicClient.getEnsAvatar({ name: _ens.normalize.call(void 0, name) });
2605
+ const avatar = await publicClient.getEnsAvatar({ name: normalize2(name) });
2606
2606
  return avatar;
2607
2607
  }
2608
2608
 
2609
2609
  // src/actions/ens/fetchEnsName.ts
2610
-
2610
+ import { getAddress as getAddress2 } from "viem";
2611
2611
  async function fetchEnsName({
2612
2612
  address,
2613
2613
  chainId
2614
2614
  }) {
2615
2615
  const publicClient = getPublicClient({ chainId });
2616
2616
  return publicClient.getEnsName({
2617
- address: _viem.getAddress.call(void 0, address)
2617
+ address: getAddress2(address)
2618
2618
  });
2619
2619
  }
2620
2620
 
2621
2621
  // src/actions/ens/fetchEnsResolver.ts
2622
-
2622
+ import { normalize as normalize3 } from "viem/ens";
2623
2623
  async function fetchEnsResolver({
2624
2624
  chainId,
2625
2625
  name
2626
2626
  }) {
2627
2627
  const publicClient = getPublicClient({ chainId });
2628
- const resolver = await publicClient.getEnsResolver({ name: _ens.normalize.call(void 0, name) });
2628
+ const resolver = await publicClient.getEnsResolver({ name: normalize3(name) });
2629
2629
  return resolver;
2630
2630
  }
2631
2631
 
@@ -2639,7 +2639,7 @@ async function fetchBlockNumber({
2639
2639
  }
2640
2640
 
2641
2641
  // src/actions/network-status/fetchFeeData.ts
2642
-
2642
+ import { formatUnits as formatUnits3, parseGwei } from "viem";
2643
2643
  async function fetchFeeData({
2644
2644
  chainId,
2645
2645
  formatUnits: units = "gwei"
@@ -2649,21 +2649,21 @@ async function fetchFeeData({
2649
2649
  let gasPrice = null;
2650
2650
  try {
2651
2651
  gasPrice = await publicClient.getGasPrice();
2652
- } catch (e) {
2652
+ } catch {
2653
2653
  }
2654
2654
  let lastBaseFeePerGas = null;
2655
2655
  let maxFeePerGas = null;
2656
2656
  let maxPriorityFeePerGas = null;
2657
- if (_optionalChain([block, 'optionalAccess', _81 => _81.baseFeePerGas])) {
2657
+ if (block?.baseFeePerGas) {
2658
2658
  lastBaseFeePerGas = block.baseFeePerGas;
2659
- maxPriorityFeePerGas = _viem.parseGwei.call(void 0, "1");
2659
+ maxPriorityFeePerGas = parseGwei("1");
2660
2660
  maxFeePerGas = block.baseFeePerGas * 2n + maxPriorityFeePerGas;
2661
2661
  }
2662
2662
  const unit = getUnit(units);
2663
2663
  const formatted = {
2664
- gasPrice: gasPrice ? _viem.formatUnits.call(void 0, gasPrice, unit) : null,
2665
- maxFeePerGas: maxFeePerGas ? _viem.formatUnits.call(void 0, maxFeePerGas, unit) : null,
2666
- maxPriorityFeePerGas: maxPriorityFeePerGas ? _viem.formatUnits.call(void 0, maxPriorityFeePerGas, unit) : null
2664
+ gasPrice: gasPrice ? formatUnits3(gasPrice, unit) : null,
2665
+ maxFeePerGas: maxFeePerGas ? formatUnits3(maxFeePerGas, unit) : null,
2666
+ maxPriorityFeePerGas: maxPriorityFeePerGas ? formatUnits3(maxPriorityFeePerGas, unit) : null
2667
2667
  };
2668
2668
  return {
2669
2669
  lastBaseFeePerGas,
@@ -2684,7 +2684,7 @@ async function fetchTransaction({
2684
2684
  }
2685
2685
 
2686
2686
  // src/actions/transactions/prepareSendTransaction.ts
2687
-
2687
+ import { isAddress } from "viem";
2688
2688
  async function prepareSendTransaction({
2689
2689
  accessList,
2690
2690
  account,
@@ -2700,19 +2700,19 @@ async function prepareSendTransaction({
2700
2700
  walletClient: walletClient_
2701
2701
  }) {
2702
2702
  const publicClient = getPublicClient({ chainId });
2703
- const walletClient = await _asyncNullishCoalesce(walletClient_, async () => ( await getWalletClient({ chainId })));
2703
+ const walletClient = walletClient_ ?? await getWalletClient({ chainId });
2704
2704
  if (!walletClient)
2705
- throw new (0, _connectors.ConnectorNotFoundError)();
2705
+ throw new ConnectorNotFoundError();
2706
2706
  if (chainId)
2707
2707
  assertActiveChain({ chainId });
2708
- const to = (to_ && !_viem.isAddress.call(void 0, to_) ? await fetchEnsAddress({ name: to_ }) : to_) || void 0;
2709
- if (to && !_viem.isAddress.call(void 0, to))
2708
+ const to = (to_ && !isAddress(to_) ? await fetchEnsAddress({ name: to_ }) : to_) || void 0;
2709
+ if (to && !isAddress(to))
2710
2710
  throw new Error("Invalid address");
2711
2711
  const gas = typeof gas_ === "undefined" ? await publicClient.estimateGas({
2712
2712
  accessList,
2713
2713
  account: walletClient.account,
2714
2714
  data,
2715
- gas: _nullishCoalesce(gas_, () => ( void 0)),
2715
+ gas: gas_ ?? void 0,
2716
2716
  gasPrice,
2717
2717
  maxFeePerGas,
2718
2718
  maxPriorityFeePerGas,
@@ -2753,7 +2753,7 @@ async function sendTransaction({
2753
2753
  }) {
2754
2754
  const walletClient = await getWalletClient({ chainId });
2755
2755
  if (!walletClient)
2756
- throw new (0, _connectors.ConnectorNotFoundError)();
2756
+ throw new ConnectorNotFoundError();
2757
2757
  if (chainId)
2758
2758
  assertActiveChain({ chainId });
2759
2759
  let args;
@@ -2791,7 +2791,7 @@ async function sendTransaction({
2791
2791
  }
2792
2792
 
2793
2793
  // src/actions/transactions/waitForTransaction.ts
2794
-
2794
+ import { hexToString as hexToString3 } from "viem";
2795
2795
  async function waitForTransaction({
2796
2796
  chainId,
2797
2797
  confirmations = 1,
@@ -2816,14 +2816,14 @@ async function waitForTransaction({
2816
2816
  maxFeePerGas: txn.type === "eip1559" ? txn.maxFeePerGas : void 0,
2817
2817
  maxPriorityFeePerGas: txn.type === "eip1559" ? txn.maxPriorityFeePerGas : void 0
2818
2818
  });
2819
- const reason = _viem.hexToString.call(void 0, `0x${code.substring(138)}`);
2819
+ const reason = hexToString3(`0x${code.substring(138)}`);
2820
2820
  throw new Error(reason);
2821
2821
  }
2822
2822
  return receipt;
2823
2823
  }
2824
2824
 
2825
2825
  // src/actions/transactions/watchPendingTransactions.ts
2826
-
2826
+ import { shallow as shallow6 } from "zustand/shallow";
2827
2827
  function watchPendingTransactions(args, callback) {
2828
2828
  let unwatch;
2829
2829
  const createListener = (publicClient) => {
@@ -2834,7 +2834,7 @@ function watchPendingTransactions(args, callback) {
2834
2834
  poll: true
2835
2835
  });
2836
2836
  };
2837
- const publicClient_ = _nullishCoalesce(getWebSocketPublicClient({ chainId: args.chainId }), () => ( getPublicClient({ chainId: args.chainId })));
2837
+ const publicClient_ = getWebSocketPublicClient({ chainId: args.chainId }) ?? getPublicClient({ chainId: args.chainId });
2838
2838
  createListener(publicClient_);
2839
2839
  const config2 = getConfig();
2840
2840
  const unsubscribe = config2.subscribe(
@@ -2843,92 +2843,92 @@ function watchPendingTransactions(args, callback) {
2843
2843
  webSocketPublicClient
2844
2844
  }),
2845
2845
  async ({ publicClient, webSocketPublicClient }) => {
2846
- const publicClient_2 = _nullishCoalesce(webSocketPublicClient, () => ( publicClient));
2846
+ const publicClient_2 = webSocketPublicClient ?? publicClient;
2847
2847
  if (!args.chainId && publicClient_2) {
2848
2848
  createListener(publicClient_2);
2849
2849
  }
2850
2850
  },
2851
2851
  {
2852
- equalityFn: _shallow.shallow
2852
+ equalityFn: shallow6
2853
2853
  }
2854
2854
  );
2855
2855
  return () => {
2856
2856
  unsubscribe();
2857
- _optionalChain([unwatch, 'optionalCall', _82 => _82()]);
2857
+ unwatch?.();
2858
2858
  };
2859
2859
  }
2860
2860
 
2861
2861
  // src/utils/assertActiveChain.ts
2862
2862
  function assertActiveChain({ chainId }) {
2863
2863
  const { chain: activeChain, chains } = getNetwork();
2864
- const activeChainId = _optionalChain([activeChain, 'optionalAccess', _83 => _83.id]);
2864
+ const activeChainId = activeChain?.id;
2865
2865
  if (activeChainId && chainId !== activeChainId) {
2866
2866
  throw new ChainMismatchError({
2867
- activeChain: _nullishCoalesce(_optionalChain([chains, 'access', _84 => _84.find, 'call', _85 => _85((x) => x.id === activeChainId), 'optionalAccess', _86 => _86.name]), () => ( `Chain ${activeChainId}`)),
2868
- targetChain: _nullishCoalesce(_optionalChain([chains, 'access', _87 => _87.find, 'call', _88 => _88((x) => x.id === chainId), 'optionalAccess', _89 => _89.name]), () => ( `Chain ${chainId}`))
2867
+ activeChain: chains.find((x) => x.id === activeChainId)?.name ?? `Chain ${activeChainId}`,
2868
+ targetChain: chains.find((x) => x.id === chainId)?.name ?? `Chain ${chainId}`
2869
2869
  });
2870
2870
  }
2871
2871
  }
2872
2872
 
2873
-
2874
-
2875
-
2876
-
2877
-
2878
-
2879
-
2880
-
2881
-
2882
-
2883
-
2884
-
2885
-
2886
-
2887
-
2888
-
2889
-
2890
-
2891
-
2892
-
2893
-
2894
-
2895
-
2896
-
2897
-
2898
-
2899
-
2900
-
2901
-
2902
-
2903
-
2904
-
2905
-
2906
-
2907
-
2908
-
2909
-
2910
-
2911
-
2912
-
2913
-
2914
-
2915
-
2916
-
2917
-
2918
-
2919
-
2920
-
2921
-
2922
-
2923
-
2924
-
2925
-
2926
-
2927
-
2928
-
2929
-
2930
-
2931
-
2932
-
2933
-
2934
- exports.configureChains = configureChains; exports.ChainMismatchError = ChainMismatchError; exports.ChainNotConfiguredError = ChainNotConfiguredError; exports.ConnectorAlreadyConnectedError = ConnectorAlreadyConnectedError; exports.ConfigChainsNotFound = ConfigChainsNotFound; exports.SwitchChainNotSupportedError = SwitchChainNotSupportedError; exports.ConnectorNotFoundError = _connectors.ConnectorNotFoundError; exports.deepEqual = deepEqual; exports.deserialize = deserialize; exports.getCallParameters = getCallParameters; exports.getSendTransactionParameters = getSendTransactionParameters; exports.getUnit = getUnit; exports.serialize = serialize; exports.noopStorage = noopStorage; exports.createStorage = createStorage; exports.Config = Config; exports.createConfig = createConfig; exports.getConfig = getConfig; exports.connect = connect; exports.disconnect = disconnect; exports.erc20ABI = erc20ABI; exports.erc721ABI = erc721ABI; exports.erc4626ABI = erc4626ABI; exports.fetchToken = fetchToken; exports.getPublicClient = getPublicClient; exports.getWalletClient = getWalletClient; exports.getWebSocketPublicClient = getWebSocketPublicClient; exports.watchPublicClient = watchPublicClient; exports.watchWalletClient = watchWalletClient; exports.watchWebSocketPublicClient = watchWebSocketPublicClient; exports.prepareWriteContract = prepareWriteContract; exports.getContract = getContract; exports.multicall = multicall; exports.readContract = readContract; exports.readContracts = readContracts; exports.watchContractEvent = watchContractEvent; exports.watchBlockNumber = watchBlockNumber; exports.watchMulticall = watchMulticall; exports.watchReadContract = watchReadContract; exports.watchReadContracts = watchReadContracts; exports.writeContract = writeContract; exports.fetchBalance = fetchBalance; exports.getAccount = getAccount; exports.getNetwork = getNetwork; exports.signMessage = signMessage; exports.signTypedData = signTypedData; exports.switchNetwork = switchNetwork; exports.watchAccount = watchAccount; exports.watchNetwork = watchNetwork; exports.fetchEnsAddress = fetchEnsAddress; exports.fetchEnsAvatar = fetchEnsAvatar; exports.fetchEnsName = fetchEnsName; exports.fetchEnsResolver = fetchEnsResolver; exports.fetchBlockNumber = fetchBlockNumber; exports.fetchFeeData = fetchFeeData; exports.fetchTransaction = fetchTransaction; exports.prepareSendTransaction = prepareSendTransaction; exports.sendTransaction = sendTransaction; exports.waitForTransaction = waitForTransaction; exports.watchPendingTransactions = watchPendingTransactions;
2873
+ export {
2874
+ configureChains,
2875
+ ChainMismatchError,
2876
+ ChainNotConfiguredError,
2877
+ ConnectorAlreadyConnectedError,
2878
+ ConfigChainsNotFound,
2879
+ SwitchChainNotSupportedError,
2880
+ ConnectorNotFoundError,
2881
+ deepEqual,
2882
+ deserialize,
2883
+ getCallParameters,
2884
+ getSendTransactionParameters,
2885
+ getUnit,
2886
+ serialize,
2887
+ noopStorage,
2888
+ createStorage,
2889
+ Config,
2890
+ createConfig,
2891
+ getConfig,
2892
+ connect,
2893
+ disconnect,
2894
+ erc20ABI,
2895
+ erc721ABI,
2896
+ erc4626ABI,
2897
+ fetchToken,
2898
+ getPublicClient,
2899
+ getWalletClient,
2900
+ getWebSocketPublicClient,
2901
+ watchPublicClient,
2902
+ watchWalletClient,
2903
+ watchWebSocketPublicClient,
2904
+ prepareWriteContract,
2905
+ getContract,
2906
+ multicall,
2907
+ readContract,
2908
+ readContracts,
2909
+ watchContractEvent,
2910
+ watchBlockNumber,
2911
+ watchMulticall,
2912
+ watchReadContract,
2913
+ watchReadContracts,
2914
+ writeContract,
2915
+ fetchBalance,
2916
+ getAccount,
2917
+ getNetwork,
2918
+ signMessage,
2919
+ signTypedData,
2920
+ switchNetwork,
2921
+ watchAccount,
2922
+ watchNetwork,
2923
+ fetchEnsAddress,
2924
+ fetchEnsAvatar,
2925
+ fetchEnsName,
2926
+ fetchEnsResolver,
2927
+ fetchBlockNumber,
2928
+ fetchFeeData,
2929
+ fetchTransaction,
2930
+ prepareSendTransaction,
2931
+ sendTransaction,
2932
+ waitForTransaction,
2933
+ watchPendingTransactions
2934
+ };