@wagmi/core 0.9.0 → 0.9.1-cjs

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
- import {
2
- InjectedConnector
3
- } from "./chunk-BVC4KGLQ.js";
4
- import {
5
- __privateAdd,
6
- __privateGet,
7
- __privateMethod,
8
- __privateSet
9
- } from "./chunk-MQXBDTVK.js";
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');
10
10
 
11
11
  // src/utils/configureChains.ts
12
- import { providers } from "ethers";
12
+ var _ethers = require('ethers');
13
13
  function configureChains(defaultChains, providers2, {
14
14
  minQuorum = 1,
15
15
  pollingInterval = 4e3,
@@ -58,7 +58,7 @@ function configureChains(defaultChains, providers2, {
58
58
  return {
59
59
  chains,
60
60
  provider: ({ chainId }) => {
61
- const activeChain = chains.find((x) => x.id === chainId) ?? defaultChains[0];
61
+ const activeChain = _nullishCoalesce(chains.find((x) => x.id === chainId), () => ( defaultChains[0]));
62
62
  const chainProviders = providers_[activeChain.id];
63
63
  if (!chainProviders || !chainProviders[0])
64
64
  throw new Error(`No providers configured for chain "${activeChain.id}"`);
@@ -83,11 +83,11 @@ function configureChains(defaultChains, providers2, {
83
83
  });
84
84
  },
85
85
  webSocketProvider: ({ chainId }) => {
86
- const activeChain = chains.find((x) => x.id === chainId) ?? defaultChains[0];
86
+ const activeChain = _nullishCoalesce(chains.find((x) => x.id === chainId), () => ( defaultChains[0]));
87
87
  const chainWebSocketProviders = webSocketProviders_[activeChain.id];
88
88
  if (!chainWebSocketProviders)
89
89
  return void 0;
90
- const provider = chainWebSocketProviders[0]?.();
90
+ const provider = _optionalChain([chainWebSocketProviders, 'access', _ => _[0], 'optionalCall', _2 => _2()]);
91
91
  if (provider && activeChain.id === 42220) {
92
92
  provider.formatter.formats.block = {
93
93
  ...provider.formatter.formats.block,
@@ -103,22 +103,22 @@ function configureChains(defaultChains, providers2, {
103
103
  }
104
104
  function fallbackProvider(targetQuorum, minQuorum, providers_, { stallTimeout }) {
105
105
  try {
106
- return new providers.FallbackProvider(
106
+ return new _ethers.providers.FallbackProvider(
107
107
  providers_.map((chainProvider, index) => {
108
108
  const provider = chainProvider();
109
109
  return {
110
110
  provider,
111
- priority: provider.priority ?? index,
112
- stallTimeout: provider.stallTimeout ?? stallTimeout,
111
+ priority: _nullishCoalesce(provider.priority, () => ( index)),
112
+ stallTimeout: _nullishCoalesce(provider.stallTimeout, () => ( stallTimeout)),
113
113
  weight: provider.weight
114
114
  };
115
115
  }),
116
116
  targetQuorum
117
117
  );
118
118
  } catch (error) {
119
- if (error?.message?.includes(
119
+ if (_optionalChain([error, 'optionalAccess', _3 => _3.message, 'optionalAccess', _4 => _4.includes, 'call', _5 => _5(
120
120
  "quorum will always fail; larger than total weight"
121
- )) {
121
+ )])) {
122
122
  if (targetQuorum === minQuorum)
123
123
  throw error;
124
124
  return fallbackProvider(targetQuorum - 1, minQuorum, providers_, {
@@ -130,8 +130,8 @@ function fallbackProvider(targetQuorum, minQuorum, providers_, { stallTimeout })
130
130
  }
131
131
 
132
132
  // src/client.ts
133
- import { persist, subscribeWithSelector } from "zustand/middleware";
134
- import { createStore } from "zustand/vanilla";
133
+ var _middleware = require('zustand/middleware');
134
+ var _vanilla = require('zustand/vanilla');
135
135
 
136
136
  // src/utils/assertActiveChain.ts
137
137
  function assertActiveChain({
@@ -139,20 +139,20 @@ function assertActiveChain({
139
139
  signer
140
140
  }) {
141
141
  const { chain: activeChain, chains } = getNetwork();
142
- const activeChainId = activeChain?.id;
142
+ const activeChainId = _optionalChain([activeChain, 'optionalAccess', _6 => _6.id]);
143
143
  if (activeChainId && chainId !== activeChainId) {
144
144
  throw new ChainMismatchError({
145
- activeChain: chains.find((x) => x.id === activeChainId)?.name ?? `Chain ${activeChainId}`,
146
- targetChain: chains.find((x) => x.id === chainId)?.name ?? `Chain ${chainId}`
145
+ activeChain: _nullishCoalesce(_optionalChain([chains, 'access', _7 => _7.find, 'call', _8 => _8((x) => x.id === activeChainId), 'optionalAccess', _9 => _9.name]), () => ( `Chain ${activeChainId}`)),
146
+ targetChain: _nullishCoalesce(_optionalChain([chains, 'access', _10 => _10.find, 'call', _11 => _11((x) => x.id === chainId), 'optionalAccess', _12 => _12.name]), () => ( `Chain ${chainId}`))
147
147
  });
148
148
  }
149
149
  if (signer) {
150
- const signerChainId = signer.provider?.network?.chainId;
150
+ const signerChainId = _optionalChain([signer, 'access', _13 => _13.provider, 'optionalAccess', _14 => _14.network, 'optionalAccess', _15 => _15.chainId]);
151
151
  if (signerChainId && chainId !== signerChainId) {
152
152
  const connector = getClient().connector;
153
153
  throw new ChainNotConfiguredError({
154
154
  chainId,
155
- connectorId: connector?.id ?? "unknown"
155
+ connectorId: _nullishCoalesce(_optionalChain([connector, 'optionalAccess', _16 => _16.id]), () => ( "unknown"))
156
156
  });
157
157
  }
158
158
  }
@@ -213,7 +213,7 @@ function deepEqual(a, b) {
213
213
  }
214
214
 
215
215
  // src/utils/deserialize.ts
216
- import { BigNumber } from "ethers";
216
+
217
217
  var findAndReplace = (cacheRef, {
218
218
  find,
219
219
  replace
@@ -242,14 +242,14 @@ function deserialize(cachedString) {
242
242
  const cache = JSON.parse(cachedString);
243
243
  const deserializedCacheWithBigNumbers = findAndReplace(cache, {
244
244
  find: (data) => data.type === "BigNumber",
245
- replace: (data) => BigNumber.from(data.hex)
245
+ replace: (data) => _ethers.BigNumber.from(data.hex)
246
246
  });
247
247
  return deserializedCacheWithBigNumbers;
248
248
  }
249
249
 
250
250
  // src/utils/normalizeFunctionName.ts
251
- import { BigNumber as BigNumber2 } from "ethers";
252
- import { FunctionFragment, isAddress } from "ethers/lib/utils.js";
251
+
252
+ var _utilsjs = require('ethers/lib/utils.js');
253
253
  function normalizeFunctionName({
254
254
  contract,
255
255
  functionName,
@@ -257,8 +257,8 @@ function normalizeFunctionName({
257
257
  }) {
258
258
  if (functionName in contract.functions)
259
259
  return functionName;
260
- const argsLength = args?.length ?? 0;
261
- const overloadFunctions = Object.keys(contract.functions).filter((x) => x.startsWith(`${functionName}(`)).map((x) => ({ name: x, fragment: FunctionFragment.fromString(x) })).filter((x) => argsLength === x.fragment.inputs.length);
260
+ const argsLength = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _17 => _17.length]), () => ( 0));
261
+ const overloadFunctions = Object.keys(contract.functions).filter((x) => x.startsWith(`${functionName}(`)).map((x) => ({ name: x, fragment: _utilsjs.FunctionFragment.fromString(x) })).filter((x) => argsLength === x.fragment.inputs.length);
262
262
  for (const overloadFunction of overloadFunctions) {
263
263
  const matched = args.every((arg, index) => {
264
264
  const abiParameter = overloadFunction.fragment.inputs[index];
@@ -274,7 +274,7 @@ function isArgOfType(arg, abiParameter) {
274
274
  const abiParameterType = abiParameter.type;
275
275
  switch (abiParameterType) {
276
276
  case "address":
277
- return isAddress(arg);
277
+ return _utilsjs.isAddress.call(void 0, arg);
278
278
  case "bool":
279
279
  return argType === "boolean";
280
280
  case "function":
@@ -294,7 +294,7 @@ function isArgOfType(arg, abiParameter) {
294
294
  if (/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(
295
295
  abiParameterType
296
296
  ))
297
- return argType === "number" || argType === "bigint" || BigNumber2.isBigNumber(arg);
297
+ return argType === "number" || argType === "bigint" || _ethers.BigNumber.isBigNumber(arg);
298
298
  if (/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(abiParameterType))
299
299
  return argType === "string" || arg instanceof Uint8Array;
300
300
  if (/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(abiParameterType)) {
@@ -312,12 +312,12 @@ function isArgOfType(arg, abiParameter) {
312
312
 
313
313
  // src/utils/logger.ts
314
314
  function logWarn(message) {
315
- getClient()?.config.logger?.warn?.(message);
315
+ _optionalChain([getClient, 'call', _18 => _18(), 'optionalAccess', _19 => _19.config, 'access', _20 => _20.logger, 'optionalAccess', _21 => _21.warn, 'optionalCall', _22 => _22(message)]);
316
316
  }
317
317
 
318
318
  // src/utils/minimizeContractInterface.ts
319
- import { Contract } from "ethers";
320
- import { FormatTypes } from "ethers/lib/utils.js";
319
+
320
+
321
321
  function minimizeContractInterface(config) {
322
322
  try {
323
323
  const minimizedAbi = config.abi.filter(
@@ -327,8 +327,8 @@ function minimizeContractInterface(config) {
327
327
  throw new Error("Invalid ABI");
328
328
  return minimizedAbi;
329
329
  } catch (error) {
330
- const abi = Contract.getInterface(config.abi).format(
331
- FormatTypes.full
330
+ const abi = _ethers.Contract.getInterface(config.abi).format(
331
+ _utilsjs.FormatTypes.full
332
332
  );
333
333
  const minimizedInterface = Array.isArray(abi) ? abi : [abi];
334
334
  return minimizedInterface.filter((i) => i.includes(config.functionName));
@@ -348,7 +348,7 @@ function normalizeChainId(chainId) {
348
348
  }
349
349
 
350
350
  // src/utils/parseContractResult.ts
351
- import { Contract as Contract2 } from "ethers";
351
+
352
352
  function isPlainArray(value) {
353
353
  return Array.isArray(value) && Object.keys(value).length === value.length;
354
354
  }
@@ -358,9 +358,9 @@ function parseContractResult({
358
358
  functionName
359
359
  }) {
360
360
  if (data && isPlainArray(data)) {
361
- const iface = Contract2.getInterface(abi);
361
+ const iface = _ethers.Contract.getInterface(abi);
362
362
  const fragment = iface.getFunction(functionName);
363
- const isTuple = (fragment.outputs?.length || 0) > 1;
363
+ const isTuple = (_optionalChain([fragment, 'access', _23 => _23.outputs, 'optionalAccess', _24 => _24.length]) || 0) > 1;
364
364
  const data_ = isTuple ? data : [data];
365
365
  const encodedResult = iface.encodeFunctionResult(functionName, data_);
366
366
  const decodedResult = iface.decodeFunctionResult(
@@ -422,7 +422,7 @@ function serialize(value, replacer, indent, circularReplacer) {
422
422
  return JSON.stringify(
423
423
  value,
424
424
  createReplacer(replacer, circularReplacer),
425
- indent ?? void 0
425
+ _nullishCoalesce(indent, () => ( void 0))
426
426
  );
427
427
  }
428
428
 
@@ -470,7 +470,7 @@ var _isAutoConnecting, _lastUsedConnector, _addEffects, addEffects_fn;
470
470
  var Client = class {
471
471
  constructor({
472
472
  autoConnect = false,
473
- connectors = [new InjectedConnector()],
473
+ connectors = [new (0, _chunkBVC4KGLQjs.InjectedConnector)()],
474
474
  provider,
475
475
  storage = createStorage({
476
476
  storage: typeof window !== "undefined" ? window.localStorage : noopStorage
@@ -480,11 +480,11 @@ var Client = class {
480
480
  },
481
481
  webSocketProvider
482
482
  }) {
483
- __privateAdd(this, _addEffects);
483
+ _chunkMQXBDTVKjs.__privateAdd.call(void 0, this, _addEffects);
484
484
  this.providers = /* @__PURE__ */ new Map();
485
485
  this.webSocketProviders = /* @__PURE__ */ new Map();
486
- __privateAdd(this, _isAutoConnecting, void 0);
487
- __privateAdd(this, _lastUsedConnector, void 0);
486
+ _chunkMQXBDTVKjs.__privateAdd.call(void 0, this, _isAutoConnecting, void 0);
487
+ _chunkMQXBDTVKjs.__privateAdd.call(void 0, this, _lastUsedConnector, void 0);
488
488
  this.config = {
489
489
  autoConnect,
490
490
  connectors,
@@ -498,15 +498,15 @@ var Client = class {
498
498
  if (autoConnect) {
499
499
  try {
500
500
  const rawState = storage.getItem(storeKey);
501
- const data = rawState?.state?.data;
502
- status = data?.account ? "reconnecting" : "connecting";
503
- chainId = data?.chain?.id;
501
+ const data = _optionalChain([rawState, 'optionalAccess', _25 => _25.state, 'optionalAccess', _26 => _26.data]);
502
+ status = _optionalChain([data, 'optionalAccess', _27 => _27.account]) ? "reconnecting" : "connecting";
503
+ chainId = _optionalChain([data, 'optionalAccess', _28 => _28.chain, 'optionalAccess', _29 => _29.id]);
504
504
  } catch (_error) {
505
505
  }
506
506
  }
507
- this.store = createStore(
508
- subscribeWithSelector(
509
- persist(
507
+ this.store = _vanilla.createStore.call(void 0,
508
+ _middleware.subscribeWithSelector.call(void 0,
509
+ _middleware.persist.call(void 0,
510
510
  () => ({
511
511
  connectors: typeof connectors === "function" ? connectors() : connectors,
512
512
  provider: this.getProvider({ chainId }),
@@ -519,11 +519,11 @@ var Client = class {
519
519
  partialize: (state) => ({
520
520
  ...autoConnect && {
521
521
  data: {
522
- account: state?.data?.account,
523
- chain: state?.data?.chain
522
+ account: _optionalChain([state, 'optionalAccess', _30 => _30.data, 'optionalAccess', _31 => _31.account]),
523
+ chain: _optionalChain([state, 'optionalAccess', _32 => _32.data, 'optionalAccess', _33 => _33.chain])
524
524
  }
525
525
  },
526
- chains: state?.chains
526
+ chains: _optionalChain([state, 'optionalAccess', _34 => _34.chains])
527
527
  }),
528
528
  version: 2
529
529
  }
@@ -531,8 +531,8 @@ var Client = class {
531
531
  )
532
532
  );
533
533
  this.storage = storage;
534
- __privateSet(this, _lastUsedConnector, storage?.getItem("wallet"));
535
- __privateMethod(this, _addEffects, addEffects_fn).call(this);
534
+ _chunkMQXBDTVKjs.__privateSet.call(void 0, this, _lastUsedConnector, _optionalChain([storage, 'optionalAccess', _35 => _35.getItem, 'call', _36 => _36("wallet")]));
535
+ _chunkMQXBDTVKjs.__privateMethod.call(void 0, this, _addEffects, addEffects_fn).call(this);
536
536
  if (autoConnect && typeof window !== "undefined")
537
537
  setTimeout(async () => await this.autoConnect(), 0);
538
538
  }
@@ -552,7 +552,7 @@ var Client = class {
552
552
  return this.store.getState().error;
553
553
  }
554
554
  get lastUsedChainId() {
555
- return this.data?.chain?.id;
555
+ return _optionalChain([this, 'access', _37 => _37.data, 'optionalAccess', _38 => _38.chain, 'optionalAccess', _39 => _39.id]);
556
556
  }
557
557
  get provider() {
558
558
  return this.store.getState().provider;
@@ -582,21 +582,21 @@ var Client = class {
582
582
  }
583
583
  async destroy() {
584
584
  if (this.connector)
585
- await this.connector.disconnect?.();
586
- __privateSet(this, _isAutoConnecting, false);
585
+ await _optionalChain([this, 'access', _40 => _40.connector, 'access', _41 => _41.disconnect, 'optionalCall', _42 => _42()]);
586
+ _chunkMQXBDTVKjs.__privateSet.call(void 0, this, _isAutoConnecting, false);
587
587
  this.clearState();
588
588
  this.store.destroy();
589
589
  }
590
590
  async autoConnect() {
591
- if (__privateGet(this, _isAutoConnecting))
591
+ if (_chunkMQXBDTVKjs.__privateGet.call(void 0, this, _isAutoConnecting))
592
592
  return;
593
- __privateSet(this, _isAutoConnecting, true);
593
+ _chunkMQXBDTVKjs.__privateSet.call(void 0, this, _isAutoConnecting, true);
594
594
  this.setState((x) => ({
595
595
  ...x,
596
- status: x.data?.account ? "reconnecting" : "connecting"
596
+ status: _optionalChain([x, 'access', _43 => _43.data, 'optionalAccess', _44 => _44.account]) ? "reconnecting" : "connecting"
597
597
  }));
598
- const sorted = __privateGet(this, _lastUsedConnector) ? [...this.connectors].sort(
599
- (x) => x.id === __privateGet(this, _lastUsedConnector) ? -1 : 1
598
+ const sorted = _chunkMQXBDTVKjs.__privateGet.call(void 0, this, _lastUsedConnector) ? [...this.connectors].sort(
599
+ (x) => x.id === _chunkMQXBDTVKjs.__privateGet.call(void 0, this, _lastUsedConnector) ? -1 : 1
600
600
  ) : this.connectors;
601
601
  let connected = false;
602
602
  for (const connector of sorted) {
@@ -609,7 +609,7 @@ var Client = class {
609
609
  this.setState((x) => ({
610
610
  ...x,
611
611
  connector,
612
- chains: connector?.chains,
612
+ chains: _optionalChain([connector, 'optionalAccess', _45 => _45.chains]),
613
613
  data,
614
614
  status: "connected"
615
615
  }));
@@ -622,33 +622,33 @@ var Client = class {
622
622
  data: void 0,
623
623
  status: "disconnected"
624
624
  }));
625
- __privateSet(this, _isAutoConnecting, false);
625
+ _chunkMQXBDTVKjs.__privateSet.call(void 0, this, _isAutoConnecting, false);
626
626
  return this.data;
627
627
  }
628
628
  getProvider({ bust, chainId } = {}) {
629
- let provider_ = this.providers.get(chainId ?? -1);
629
+ let provider_ = this.providers.get(_nullishCoalesce(chainId, () => ( -1)));
630
630
  if (provider_ && !bust)
631
631
  return provider_;
632
632
  const { provider } = this.config;
633
633
  provider_ = typeof provider === "function" ? provider({ chainId }) : provider;
634
- this.providers.set(chainId ?? -1, provider_);
634
+ this.providers.set(_nullishCoalesce(chainId, () => ( -1)), provider_);
635
635
  return provider_;
636
636
  }
637
637
  getWebSocketProvider({
638
638
  bust,
639
639
  chainId
640
640
  } = {}) {
641
- let webSocketProvider_ = this.webSocketProviders.get(chainId ?? -1);
641
+ let webSocketProvider_ = this.webSocketProviders.get(_nullishCoalesce(chainId, () => ( -1)));
642
642
  if (webSocketProvider_ && !bust)
643
643
  return webSocketProvider_;
644
644
  const { webSocketProvider } = this.config;
645
645
  webSocketProvider_ = typeof webSocketProvider === "function" ? webSocketProvider({ chainId }) : webSocketProvider;
646
646
  if (webSocketProvider_)
647
- this.webSocketProviders.set(chainId ?? -1, webSocketProvider_);
647
+ this.webSocketProviders.set(_nullishCoalesce(chainId, () => ( -1)), webSocketProvider_);
648
648
  return webSocketProvider_;
649
649
  }
650
650
  setLastUsedConnector(lastUsedConnector = null) {
651
- this.storage?.setItem("wallet", lastUsedConnector);
651
+ _optionalChain([this, 'access', _46 => _46.storage, 'optionalAccess', _47 => _47.setItem, 'call', _48 => _48("wallet", lastUsedConnector)]);
652
652
  }
653
653
  };
654
654
  _isAutoConnecting = new WeakMap();
@@ -670,14 +670,14 @@ addEffects_fn = function() {
670
670
  this.store.subscribe(
671
671
  ({ connector }) => connector,
672
672
  (connector, prevConnector) => {
673
- prevConnector?.off?.("change", onChange);
674
- prevConnector?.off?.("disconnect", onDisconnect);
675
- prevConnector?.off?.("error", onError);
673
+ _optionalChain([prevConnector, 'optionalAccess', _49 => _49.off, 'optionalCall', _50 => _50("change", onChange)]);
674
+ _optionalChain([prevConnector, 'optionalAccess', _51 => _51.off, 'optionalCall', _52 => _52("disconnect", onDisconnect)]);
675
+ _optionalChain([prevConnector, 'optionalAccess', _53 => _53.off, 'optionalCall', _54 => _54("error", onError)]);
676
676
  if (!connector)
677
677
  return;
678
- connector.on?.("change", onChange);
679
- connector.on?.("disconnect", onDisconnect);
680
- connector.on?.("error", onError);
678
+ _optionalChain([connector, 'access', _55 => _55.on, 'optionalCall', _56 => _56("change", onChange)]);
679
+ _optionalChain([connector, 'access', _57 => _57.on, 'optionalCall', _58 => _58("disconnect", onDisconnect)]);
680
+ _optionalChain([connector, 'access', _59 => _59.on, 'optionalCall', _60 => _60("error", onError)]);
681
681
  }
682
682
  );
683
683
  const { provider, webSocketProvider } = this.config;
@@ -685,7 +685,7 @@ addEffects_fn = function() {
685
685
  const subscribeWebSocketProvider = typeof webSocketProvider === "function";
686
686
  if (subscribeProvider || subscribeWebSocketProvider)
687
687
  this.store.subscribe(
688
- ({ data }) => data?.chain?.id,
688
+ ({ data }) => _optionalChain([data, 'optionalAccess', _61 => _61.chain, 'optionalAccess', _62 => _62.id]),
689
689
  (chainId) => {
690
690
  this.setState((x) => ({
691
691
  ...x,
@@ -729,7 +729,7 @@ async function connect({
729
729
  client2.setState((x) => ({
730
730
  ...x,
731
731
  connector,
732
- chains: connector?.chains,
732
+ chains: _optionalChain([connector, 'optionalAccess', _63 => _63.chains]),
733
733
  data,
734
734
  status: "connected"
735
735
  }));
@@ -756,7 +756,7 @@ async function disconnect() {
756
756
  }
757
757
 
758
758
  // src/actions/accounts/fetchBalance.ts
759
- import { formatUnits as formatUnits3, parseBytes32String as parseBytes32String2 } from "ethers/lib/utils.js";
759
+
760
760
 
761
761
  // src/constants/abis.ts
762
762
  var erc20ABI = [
@@ -2041,7 +2041,7 @@ var units = [
2041
2041
  ];
2042
2042
 
2043
2043
  // src/actions/contracts/fetchToken.ts
2044
- import { formatUnits, parseBytes32String } from "ethers/lib/utils.js";
2044
+
2045
2045
  async function fetchToken({
2046
2046
  address,
2047
2047
  chainId,
@@ -2064,7 +2064,7 @@ async function fetchToken({
2064
2064
  name,
2065
2065
  symbol,
2066
2066
  totalSupply: {
2067
- formatted: formatUnits(totalSupply, units2),
2067
+ formatted: _utilsjs.formatUnits.call(void 0, totalSupply, units2),
2068
2068
  value: totalSupply
2069
2069
  }
2070
2070
  };
@@ -2077,8 +2077,8 @@ async function fetchToken({
2077
2077
  abi: erc20ABI_bytes32
2078
2078
  });
2079
2079
  return {
2080
- name: parseBytes32String(name),
2081
- symbol: parseBytes32String(symbol),
2080
+ name: _utilsjs.parseBytes32String.call(void 0, name),
2081
+ symbol: _utilsjs.parseBytes32String.call(void 0, symbol),
2082
2082
  ...rest
2083
2083
  };
2084
2084
  }
@@ -2087,13 +2087,13 @@ async function fetchToken({
2087
2087
  }
2088
2088
 
2089
2089
  // src/actions/contracts/getContract.ts
2090
- import { Contract as EthersContract } from "ethers";
2090
+
2091
2091
  function getContract({
2092
2092
  address,
2093
2093
  abi,
2094
2094
  signerOrProvider
2095
2095
  }) {
2096
- return new EthersContract(
2096
+ return new (0, _ethers.Contract)(
2097
2097
  address,
2098
2098
  abi,
2099
2099
  signerOrProvider
@@ -2110,7 +2110,7 @@ async function prepareWriteContract({
2110
2110
  signer: signer_,
2111
2111
  ...config
2112
2112
  }) {
2113
- const signer = signer_ ?? await fetchSigner({ chainId });
2113
+ const signer = await _asyncNullishCoalesce(signer_, async () => ( await fetchSigner({ chainId })));
2114
2114
  if (!signer)
2115
2115
  throw new ConnectorNotFoundError();
2116
2116
  if (chainId)
@@ -2132,7 +2132,7 @@ async function prepareWriteContract({
2132
2132
  address,
2133
2133
  functionName: normalizedFunctionName
2134
2134
  });
2135
- const params = [...args ?? [], ...overrides ? [overrides] : []];
2135
+ const params = [..._nullishCoalesce(args, () => ( [])), ...overrides ? [overrides] : []];
2136
2136
  const unsignedTransaction = await populateTransactionFn(
2137
2137
  ...params
2138
2138
  );
@@ -2206,11 +2206,11 @@ async function multicall({
2206
2206
  const chain = provider.chains.find((chain2) => chain2.id === chainId) || provider.chains[0];
2207
2207
  if (!chain)
2208
2208
  throw new ProviderChainsNotFound();
2209
- if (!chain?.contracts?.multicall3)
2209
+ if (!_optionalChain([chain, 'optionalAccess', _64 => _64.contracts, 'optionalAccess', _65 => _65.multicall3]))
2210
2210
  throw new ChainDoesNotSupportMulticallError({ chain });
2211
- if (typeof overrides?.blockTag === "number" && overrides?.blockTag < (chain.contracts.multicall3.blockCreated ?? 0))
2211
+ if (typeof _optionalChain([overrides, 'optionalAccess', _66 => _66.blockTag]) === "number" && _optionalChain([overrides, 'optionalAccess', _67 => _67.blockTag]) < (_nullishCoalesce(chain.contracts.multicall3.blockCreated, () => ( 0))))
2212
2212
  throw new ChainDoesNotSupportMulticallError({
2213
- blockNumber: overrides?.blockTag,
2213
+ blockNumber: _optionalChain([overrides, 'optionalAccess', _68 => _68.blockTag]),
2214
2214
  chain
2215
2215
  });
2216
2216
  const multicallContract = getContract({
@@ -2222,7 +2222,7 @@ async function multicall({
2222
2222
  ({ address, abi, functionName, ...config }) => {
2223
2223
  const { args } = config || {};
2224
2224
  const contract = getContract({ address, abi });
2225
- const params2 = args ?? [];
2225
+ const params2 = _nullishCoalesce(args, () => ( []));
2226
2226
  const normalizedFunctionName = normalizeFunctionName({
2227
2227
  contract,
2228
2228
  functionName,
@@ -2352,8 +2352,8 @@ async function readContract({
2352
2352
  address,
2353
2353
  functionName: normalizedFunctionName
2354
2354
  });
2355
- const params = [...args ?? [], ...overrides ? [overrides] : []];
2356
- return contractFunction?.(...params);
2355
+ const params = [..._nullishCoalesce(args, () => ( [])), ...overrides ? [overrides] : []];
2356
+ return _optionalChain([contractFunction, 'optionalCall', _69 => _69(...params)]);
2357
2357
  }
2358
2358
 
2359
2359
  // src/actions/contracts/readContracts.ts
@@ -2365,7 +2365,7 @@ async function readContracts({
2365
2365
  try {
2366
2366
  const provider = getProvider();
2367
2367
  const contractsByChainId = contracts.reduce((contracts2, contract, index) => {
2368
- const chainId = contract.chainId ?? provider.network.chainId;
2368
+ const chainId = _nullishCoalesce(contract.chainId, () => ( provider.network.chainId));
2369
2369
  return {
2370
2370
  ...contracts2,
2371
2371
  [chainId]: [...contracts2[chainId] || [], { contract, index }]
@@ -2417,7 +2417,7 @@ async function readContracts({
2417
2417
  const error = new ContractMethodRevertedError({
2418
2418
  address,
2419
2419
  functionName,
2420
- chainId: chainId ?? 1,
2420
+ chainId: _nullishCoalesce(chainId, () => ( 1)),
2421
2421
  args,
2422
2422
  errorMessage: result.reason
2423
2423
  });
@@ -2429,7 +2429,7 @@ async function readContracts({
2429
2429
  }
2430
2430
 
2431
2431
  // src/actions/contracts/watchContractEvent.ts
2432
- import { shallow } from "zustand/shallow";
2432
+ var _shallow = require('zustand/shallow');
2433
2433
  function watchContractEvent({
2434
2434
  address,
2435
2435
  abi,
@@ -2441,7 +2441,7 @@ function watchContractEvent({
2441
2441
  let contract;
2442
2442
  const watchEvent = async () => {
2443
2443
  if (contract)
2444
- contract?.off(eventName, handler);
2444
+ _optionalChain([contract, 'optionalAccess', _70 => _70.off, 'call', _71 => _71(eventName, handler)]);
2445
2445
  const signerOrProvider = getWebSocketProvider({ chainId }) || getProvider({ chainId });
2446
2446
  contract = getContract({
2447
2447
  address,
@@ -2461,16 +2461,16 @@ function watchContractEvent({
2461
2461
  webSocketProvider
2462
2462
  }),
2463
2463
  watchEvent,
2464
- { equalityFn: shallow }
2464
+ { equalityFn: _shallow.shallow }
2465
2465
  );
2466
2466
  return () => {
2467
- contract?.off(eventName, handler);
2467
+ _optionalChain([contract, 'optionalAccess', _72 => _72.off, 'call', _73 => _73(eventName, handler)]);
2468
2468
  unsubscribe();
2469
2469
  };
2470
2470
  }
2471
2471
 
2472
2472
  // src/actions/network-status/watchBlockNumber.ts
2473
- import { shallow as shallow2 } from "zustand/shallow";
2473
+
2474
2474
 
2475
2475
  // src/actions/network-status/fetchBlockNumber.ts
2476
2476
  async function fetchBlockNumber({
@@ -2487,12 +2487,12 @@ function watchBlockNumber(args, callback) {
2487
2487
  let previousProvider;
2488
2488
  const createListener = (provider) => {
2489
2489
  if (previousProvider) {
2490
- previousProvider?.off("block", debouncedCallback);
2490
+ _optionalChain([previousProvider, 'optionalAccess', _74 => _74.off, 'call', _75 => _75("block", debouncedCallback)]);
2491
2491
  }
2492
2492
  provider.on("block", debouncedCallback);
2493
2493
  previousProvider = provider;
2494
2494
  };
2495
- const provider_ = getWebSocketProvider({ chainId: args.chainId }) ?? getProvider({ chainId: args.chainId });
2495
+ const provider_ = _nullishCoalesce(getWebSocketProvider({ chainId: args.chainId }), () => ( getProvider({ chainId: args.chainId })));
2496
2496
  if (args.listen)
2497
2497
  createListener(provider_);
2498
2498
  let active = true;
@@ -2500,7 +2500,7 @@ function watchBlockNumber(args, callback) {
2500
2500
  const unsubscribe = client2.subscribe(
2501
2501
  ({ provider, webSocketProvider }) => ({ provider, webSocketProvider }),
2502
2502
  async ({ provider, webSocketProvider }) => {
2503
- const provider_2 = webSocketProvider ?? provider;
2503
+ const provider_2 = _nullishCoalesce(webSocketProvider, () => ( provider));
2504
2504
  if (args.listen && !args.chainId && provider_2) {
2505
2505
  createListener(provider_2);
2506
2506
  }
@@ -2510,14 +2510,14 @@ function watchBlockNumber(args, callback) {
2510
2510
  callback(blockNumber);
2511
2511
  },
2512
2512
  {
2513
- equalityFn: shallow2
2513
+ equalityFn: _shallow.shallow
2514
2514
  }
2515
2515
  );
2516
2516
  return () => {
2517
2517
  active = false;
2518
2518
  unsubscribe();
2519
- provider_?.off("block", debouncedCallback);
2520
- previousProvider?.off("block", debouncedCallback);
2519
+ _optionalChain([provider_, 'optionalAccess', _76 => _76.off, 'call', _77 => _77("block", debouncedCallback)]);
2520
+ _optionalChain([previousProvider, 'optionalAccess', _78 => _78.off, 'call', _79 => _79("block", debouncedCallback)]);
2521
2521
  };
2522
2522
  }
2523
2523
 
@@ -2529,7 +2529,7 @@ function watchMulticall(config, callback) {
2529
2529
  const unsubscribe = client2.subscribe(({ provider }) => provider, handleChange);
2530
2530
  return () => {
2531
2531
  unsubscribe();
2532
- unwatch?.();
2532
+ _optionalChain([unwatch, 'optionalCall', _80 => _80()]);
2533
2533
  };
2534
2534
  }
2535
2535
 
@@ -2541,7 +2541,7 @@ function watchReadContract(config, callback) {
2541
2541
  const unsubscribe = client2.subscribe(({ provider }) => provider, handleChange);
2542
2542
  return () => {
2543
2543
  unsubscribe();
2544
- unwatch?.();
2544
+ _optionalChain([unwatch, 'optionalCall', _81 => _81()]);
2545
2545
  };
2546
2546
  }
2547
2547
 
@@ -2553,7 +2553,7 @@ function watchReadContracts(config, callback) {
2553
2553
  const unsubscribe = client2.subscribe(({ provider }) => provider, handleChange);
2554
2554
  return () => {
2555
2555
  unsubscribe();
2556
- unwatch?.();
2556
+ _optionalChain([unwatch, 'optionalCall', _82 => _82()]);
2557
2557
  };
2558
2558
  }
2559
2559
 
@@ -2567,10 +2567,10 @@ async function fetchTransaction({
2567
2567
  }
2568
2568
 
2569
2569
  // src/actions/transactions/prepareSendTransaction.ts
2570
- import { isAddress as isAddress2 } from "ethers/lib/utils.js";
2570
+
2571
2571
 
2572
2572
  // src/actions/ens/fetchEnsAddress.ts
2573
- import { getAddress } from "ethers/lib/utils.js";
2573
+
2574
2574
  async function fetchEnsAddress({
2575
2575
  chainId,
2576
2576
  name
@@ -2578,7 +2578,7 @@ async function fetchEnsAddress({
2578
2578
  const provider = getProvider({ chainId });
2579
2579
  const address = await provider.resolveName(name);
2580
2580
  try {
2581
- return address ? getAddress(address) : null;
2581
+ return address ? _utilsjs.getAddress.call(void 0, address) : null;
2582
2582
  } catch (_error) {
2583
2583
  return null;
2584
2584
  }
@@ -2595,13 +2595,13 @@ async function fetchEnsAvatar({
2595
2595
  }
2596
2596
 
2597
2597
  // src/actions/ens/fetchEnsName.ts
2598
- import { getAddress as getAddress2 } from "ethers/lib/utils.js";
2598
+
2599
2599
  async function fetchEnsName({
2600
2600
  address,
2601
2601
  chainId
2602
2602
  }) {
2603
2603
  const provider = getProvider({ chainId });
2604
- return provider.lookupAddress(getAddress2(address));
2604
+ return provider.lookupAddress(_utilsjs.getAddress.call(void 0, address));
2605
2605
  }
2606
2606
 
2607
2607
  // src/actions/ens/fetchEnsResolver.ts
@@ -2620,13 +2620,13 @@ async function prepareSendTransaction({
2620
2620
  request,
2621
2621
  signer: signer_
2622
2622
  }) {
2623
- const signer = signer_ ?? await fetchSigner({ chainId });
2623
+ const signer = await _asyncNullishCoalesce(signer_, async () => ( await fetchSigner({ chainId })));
2624
2624
  if (!signer)
2625
2625
  throw new ConnectorNotFoundError();
2626
2626
  if (chainId)
2627
2627
  assertActiveChain({ chainId, signer });
2628
2628
  const [to, gasLimit] = await Promise.all([
2629
- isAddress2(request.to) ? Promise.resolve(request.to) : fetchEnsAddress({ name: request.to }),
2629
+ _utilsjs.isAddress.call(void 0, request.to) ? Promise.resolve(request.to) : fetchEnsAddress({ name: request.to }),
2630
2630
  request.gasLimit ? Promise.resolve(request.gasLimit) : signer.estimateGas(request)
2631
2631
  ]);
2632
2632
  if (!to)
@@ -2656,8 +2656,8 @@ async function sendTransaction({
2656
2656
  if (chainId)
2657
2657
  assertActiveChain({ chainId, signer });
2658
2658
  try {
2659
- const uncheckedSigner = signer.connectUnchecked?.();
2660
- const { hash, wait } = await (uncheckedSigner ?? signer).sendTransaction(
2659
+ const uncheckedSigner = _optionalChain([signer, 'access', _83 => _83.connectUnchecked, 'optionalCall', _84 => _84()]);
2660
+ const { hash, wait } = await (_nullishCoalesce(uncheckedSigner, () => ( signer))).sendTransaction(
2661
2661
  request
2662
2662
  );
2663
2663
  return { hash, wait };
@@ -2669,10 +2669,10 @@ async function sendTransaction({
2669
2669
  }
2670
2670
 
2671
2671
  // src/actions/transactions/waitForTransaction.ts
2672
- import { toUtf8String } from "ethers/lib/utils.js";
2672
+
2673
2673
 
2674
2674
  // src/actions/network-status/fetchFeeData.ts
2675
- import { formatUnits as formatUnits2 } from "ethers/lib/utils.js";
2675
+
2676
2676
  async function fetchFeeData({
2677
2677
  chainId,
2678
2678
  formatUnits: units2 = "wei"
@@ -2680,9 +2680,9 @@ async function fetchFeeData({
2680
2680
  const provider = getProvider({ chainId });
2681
2681
  const feeData = await provider.getFeeData();
2682
2682
  const formatted = {
2683
- gasPrice: feeData.gasPrice ? formatUnits2(feeData.gasPrice, units2) : null,
2684
- maxFeePerGas: feeData.maxFeePerGas ? formatUnits2(feeData.maxFeePerGas, units2) : null,
2685
- maxPriorityFeePerGas: feeData.maxPriorityFeePerGas ? formatUnits2(feeData.maxPriorityFeePerGas, units2) : null
2683
+ gasPrice: feeData.gasPrice ? _utilsjs.formatUnits.call(void 0, feeData.gasPrice, units2) : null,
2684
+ maxFeePerGas: feeData.maxFeePerGas ? _utilsjs.formatUnits.call(void 0, feeData.maxFeePerGas, units2) : null,
2685
+ maxPriorityFeePerGas: feeData.maxPriorityFeePerGas ? _utilsjs.formatUnits.call(void 0, feeData.maxPriorityFeePerGas, units2) : null
2686
2686
  };
2687
2687
  return { ...feeData, formatted };
2688
2688
  }
@@ -2701,7 +2701,7 @@ async function waitForTransaction({
2701
2701
  fetchTransaction({ hash })
2702
2702
  ]);
2703
2703
  let replaceable = null;
2704
- if (confirmations !== 0 && transaction?.to) {
2704
+ if (confirmations !== 0 && _optionalChain([transaction, 'optionalAccess', _85 => _85.to])) {
2705
2705
  replaceable = {
2706
2706
  data: transaction.data,
2707
2707
  from: transaction.from,
@@ -2720,15 +2720,15 @@ async function waitForTransaction({
2720
2720
  );
2721
2721
  if (receipt.status === 0) {
2722
2722
  const code = await provider.call(receipt, receipt.blockNumber);
2723
- const reason = toUtf8String(`0x${code.substring(138)}`);
2723
+ const reason = _utilsjs.toUtf8String.call(void 0, `0x${code.substring(138)}`);
2724
2724
  throw new Error(reason);
2725
2725
  }
2726
2726
  return receipt;
2727
2727
  } catch (err) {
2728
- if (err?.reason === "repriced") {
2729
- onSpeedUp?.(err.replacement);
2728
+ if (_optionalChain([err, 'optionalAccess', _86 => _86.reason]) === "repriced") {
2729
+ _optionalChain([onSpeedUp, 'optionalCall', _87 => _87(err.replacement)]);
2730
2730
  return waitForTransaction({
2731
- hash: err.replacement?.hash,
2731
+ hash: _optionalChain([err, 'access', _88 => _88.replacement, 'optionalAccess', _89 => _89.hash]),
2732
2732
  confirmations,
2733
2733
  timeout
2734
2734
  });
@@ -2738,35 +2738,35 @@ async function waitForTransaction({
2738
2738
  }
2739
2739
 
2740
2740
  // src/actions/transactions/watchPendingTransactions.ts
2741
- import { shallow as shallow3 } from "zustand/shallow";
2741
+
2742
2742
  function watchPendingTransactions(args, callback) {
2743
2743
  let previousProvider;
2744
2744
  const createListener = (provider) => {
2745
2745
  if (previousProvider) {
2746
- previousProvider?.off("pending", callback);
2746
+ _optionalChain([previousProvider, 'optionalAccess', _90 => _90.off, 'call', _91 => _91("pending", callback)]);
2747
2747
  }
2748
2748
  provider.on("pending", callback);
2749
2749
  previousProvider = provider;
2750
2750
  };
2751
- const provider_ = getWebSocketProvider({ chainId: args.chainId }) ?? getProvider({ chainId: args.chainId });
2751
+ const provider_ = _nullishCoalesce(getWebSocketProvider({ chainId: args.chainId }), () => ( getProvider({ chainId: args.chainId })));
2752
2752
  createListener(provider_);
2753
2753
  const client2 = getClient();
2754
2754
  const unsubscribe = client2.subscribe(
2755
2755
  ({ provider, webSocketProvider }) => ({ provider, webSocketProvider }),
2756
2756
  async ({ provider, webSocketProvider }) => {
2757
- const provider_2 = webSocketProvider ?? provider;
2757
+ const provider_2 = _nullishCoalesce(webSocketProvider, () => ( provider));
2758
2758
  if (!args.chainId && provider_2) {
2759
2759
  createListener(provider_2);
2760
2760
  }
2761
2761
  },
2762
2762
  {
2763
- equalityFn: shallow3
2763
+ equalityFn: _shallow.shallow
2764
2764
  }
2765
2765
  );
2766
2766
  return () => {
2767
2767
  unsubscribe();
2768
- provider_?.off("pending", callback);
2769
- previousProvider?.off("pending", callback);
2768
+ _optionalChain([provider_, 'optionalAccess', _92 => _92.off, 'call', _93 => _93("pending", callback)]);
2769
+ _optionalChain([previousProvider, 'optionalAccess', _94 => _94.off, 'call', _95 => _95("pending", callback)]);
2770
2770
  };
2771
2771
  }
2772
2772
 
@@ -2823,7 +2823,7 @@ async function fetchBalance({
2823
2823
  });
2824
2824
  return {
2825
2825
  decimals,
2826
- formatted: formatUnits3(value2 ?? "0", unit ?? decimals),
2826
+ formatted: _utilsjs.formatUnits.call(void 0, _nullishCoalesce(value2, () => ( "0")), _nullishCoalesce(unit, () => ( decimals))),
2827
2827
  symbol,
2828
2828
  value: value2
2829
2829
  };
@@ -2836,20 +2836,20 @@ async function fetchBalance({
2836
2836
  abi: erc20ABI_bytes32
2837
2837
  });
2838
2838
  return {
2839
- symbol: parseBytes32String2(symbol),
2839
+ symbol: _utilsjs.parseBytes32String.call(void 0, symbol),
2840
2840
  ...rest
2841
2841
  };
2842
2842
  }
2843
2843
  throw err;
2844
2844
  }
2845
2845
  }
2846
- const chains = [...client2.provider.chains || [], ...client2.chains ?? []];
2846
+ const chains = [...client2.provider.chains || [], ..._nullishCoalesce(client2.chains, () => ( []))];
2847
2847
  const value = await provider.getBalance(address);
2848
2848
  const chain = chains.find((x) => x.id === provider.network.chainId);
2849
2849
  return {
2850
- decimals: chain?.nativeCurrency.decimals ?? 18,
2851
- formatted: formatUnits3(value ?? "0", unit ?? "ether"),
2852
- symbol: chain?.nativeCurrency.symbol ?? "ETH",
2850
+ decimals: _nullishCoalesce(_optionalChain([chain, 'optionalAccess', _96 => _96.nativeCurrency, 'access', _97 => _97.decimals]), () => ( 18)),
2851
+ formatted: _utilsjs.formatUnits.call(void 0, _nullishCoalesce(value, () => ( "0")), _nullishCoalesce(unit, () => ( "ether"))),
2852
+ symbol: _nullishCoalesce(_optionalChain([chain, 'optionalAccess', _98 => _98.nativeCurrency, 'access', _99 => _99.symbol]), () => ( "ETH")),
2853
2853
  value
2854
2854
  };
2855
2855
  }
@@ -2859,7 +2859,7 @@ async function fetchSigner({
2859
2859
  chainId
2860
2860
  } = {}) {
2861
2861
  const client2 = getClient();
2862
- const signer = await client2.connector?.getSigner?.({ chainId }) || null;
2862
+ const signer = await _optionalChain([client2, 'access', _100 => _100.connector, 'optionalAccess', _101 => _101.getSigner, 'optionalCall', _102 => _102({ chainId })]) || null;
2863
2863
  return signer;
2864
2864
  }
2865
2865
 
@@ -2869,7 +2869,7 @@ function getAccount() {
2869
2869
  switch (status) {
2870
2870
  case "connected":
2871
2871
  return {
2872
- address: data?.account,
2872
+ address: _optionalChain([data, 'optionalAccess', _103 => _103.account]),
2873
2873
  connector,
2874
2874
  isConnected: true,
2875
2875
  isConnecting: false,
@@ -2879,9 +2879,9 @@ function getAccount() {
2879
2879
  };
2880
2880
  case "reconnecting":
2881
2881
  return {
2882
- address: data?.account,
2882
+ address: _optionalChain([data, 'optionalAccess', _104 => _104.account]),
2883
2883
  connector,
2884
- isConnected: !!data?.account,
2884
+ isConnected: !!_optionalChain([data, 'optionalAccess', _105 => _105.account]),
2885
2885
  isConnecting: false,
2886
2886
  isDisconnected: false,
2887
2887
  isReconnecting: true,
@@ -2889,7 +2889,7 @@ function getAccount() {
2889
2889
  };
2890
2890
  case "connecting":
2891
2891
  return {
2892
- address: data?.account,
2892
+ address: _optionalChain([data, 'optionalAccess', _106 => _106.account]),
2893
2893
  connector,
2894
2894
  isConnected: false,
2895
2895
  isConnecting: true,
@@ -2913,11 +2913,11 @@ function getAccount() {
2913
2913
  // src/actions/accounts/getNetwork.ts
2914
2914
  function getNetwork() {
2915
2915
  const client2 = getClient();
2916
- const chainId = client2.data?.chain?.id;
2917
- const activeChains = client2.chains ?? [];
2918
- const activeChain = [...client2.provider.chains || [], ...activeChains].find(
2916
+ const chainId = _optionalChain([client2, 'access', _107 => _107.data, 'optionalAccess', _108 => _108.chain, 'optionalAccess', _109 => _109.id]);
2917
+ const activeChains = _nullishCoalesce(client2.chains, () => ( []));
2918
+ const activeChain = _nullishCoalesce([...client2.provider.chains || [], ...activeChains].find(
2919
2919
  (x) => x.id === chainId
2920
- ) ?? {
2920
+ ), () => ( {
2921
2921
  id: chainId,
2922
2922
  name: `Chain ${chainId}`,
2923
2923
  network: `${chainId}`,
@@ -2926,11 +2926,11 @@ function getNetwork() {
2926
2926
  default: { http: [""] },
2927
2927
  public: { http: [""] }
2928
2928
  }
2929
- };
2929
+ }));
2930
2930
  return {
2931
2931
  chain: chainId ? {
2932
2932
  ...activeChain,
2933
- ...client2.data?.chain,
2933
+ ..._optionalChain([client2, 'access', _110 => _110.data, 'optionalAccess', _111 => _111.chain]),
2934
2934
  id: chainId
2935
2935
  } : void 0,
2936
2936
  chains: activeChains
@@ -2994,41 +2994,41 @@ async function switchNetwork({
2994
2994
  }
2995
2995
 
2996
2996
  // src/actions/accounts/watchAccount.ts
2997
- import { shallow as shallow4 } from "zustand/shallow";
2997
+
2998
2998
  function watchAccount(callback, { selector = (x) => x } = {}) {
2999
2999
  const client2 = getClient();
3000
3000
  const handleChange = () => callback(getAccount());
3001
3001
  const unsubscribe = client2.subscribe(
3002
3002
  ({ data, connector, status }) => selector({
3003
- address: data?.account,
3003
+ address: _optionalChain([data, 'optionalAccess', _112 => _112.account]),
3004
3004
  connector,
3005
3005
  status
3006
3006
  }),
3007
3007
  handleChange,
3008
3008
  {
3009
- equalityFn: shallow4
3009
+ equalityFn: _shallow.shallow
3010
3010
  }
3011
3011
  );
3012
3012
  return unsubscribe;
3013
3013
  }
3014
3014
 
3015
3015
  // src/actions/accounts/watchNetwork.ts
3016
- import { shallow as shallow5 } from "zustand/shallow";
3016
+
3017
3017
  function watchNetwork(callback, { selector = (x) => x } = {}) {
3018
3018
  const client2 = getClient();
3019
3019
  const handleChange = () => callback(getNetwork());
3020
3020
  const unsubscribe = client2.subscribe(
3021
- ({ data, chains }) => selector({ chainId: data?.chain?.id, chains }),
3021
+ ({ data, chains }) => selector({ chainId: _optionalChain([data, 'optionalAccess', _113 => _113.chain, 'optionalAccess', _114 => _114.id]), chains }),
3022
3022
  handleChange,
3023
3023
  {
3024
- equalityFn: shallow5
3024
+ equalityFn: _shallow.shallow
3025
3025
  }
3026
3026
  );
3027
3027
  return unsubscribe;
3028
3028
  }
3029
3029
 
3030
3030
  // src/actions/accounts/watchSigner.ts
3031
- import { shallow as shallow6 } from "zustand/shallow";
3031
+
3032
3032
  function watchSigner({ chainId }, callback) {
3033
3033
  const client2 = getClient();
3034
3034
  const handleChange = async () => {
@@ -3039,13 +3039,13 @@ function watchSigner({ chainId }, callback) {
3039
3039
  };
3040
3040
  const unsubscribe = client2.subscribe(
3041
3041
  ({ data, connector }) => ({
3042
- account: data?.account,
3043
- chainId: data?.chain?.id,
3042
+ account: _optionalChain([data, 'optionalAccess', _115 => _115.account]),
3043
+ chainId: _optionalChain([data, 'optionalAccess', _116 => _116.chain, 'optionalAccess', _117 => _117.id]),
3044
3044
  connector
3045
3045
  }),
3046
3046
  handleChange,
3047
3047
  {
3048
- equalityFn: shallow6
3048
+ equalityFn: _shallow.shallow
3049
3049
  }
3050
3050
  );
3051
3051
  return unsubscribe;
@@ -3131,14 +3131,14 @@ var ContractMethodDoesNotExistError = class extends Error {
3131
3131
  functionName
3132
3132
  }) {
3133
3133
  const { chains, network } = getProvider();
3134
- const chain = chains?.find(({ id }) => id === (chainId || network.chainId));
3135
- const blockExplorer = chain?.blockExplorers?.default;
3134
+ const chain = _optionalChain([chains, 'optionalAccess', _118 => _118.find, 'call', _119 => _119(({ id }) => id === (chainId || network.chainId))]);
3135
+ const blockExplorer = _optionalChain([chain, 'optionalAccess', _120 => _120.blockExplorers, 'optionalAccess', _121 => _121.default]);
3136
3136
  super(
3137
3137
  [
3138
3138
  `Function "${functionName}" on contract "${address}" does not exist.`,
3139
3139
  ...blockExplorer ? [
3140
3140
  "",
3141
- `${blockExplorer?.name}: ${blockExplorer?.url}/address/${address}#readContract`
3141
+ `${_optionalChain([blockExplorer, 'optionalAccess', _122 => _122.name])}: ${_optionalChain([blockExplorer, 'optionalAccess', _123 => _123.url])}/address/${address}#readContract`
3142
3142
  ] : []
3143
3143
  ].join("\n")
3144
3144
  );
@@ -3285,78 +3285,78 @@ var UserRejectedRequestError = class extends ProviderRpcError {
3285
3285
  }
3286
3286
  };
3287
3287
 
3288
- export {
3289
- configureChains,
3290
- RpcError,
3291
- ProviderRpcError,
3292
- AddChainError,
3293
- ChainDoesNotSupportMulticallError,
3294
- ChainMismatchError,
3295
- ChainNotConfiguredError,
3296
- ConnectorAlreadyConnectedError,
3297
- ConnectorNotFoundError,
3298
- ContractMethodDoesNotExistError,
3299
- ContractMethodNoResultError,
3300
- ContractMethodRevertedError,
3301
- ContractResultDecodeError,
3302
- ProviderChainsNotFound,
3303
- ResourceUnavailableError,
3304
- SwitchChainError,
3305
- SwitchChainNotSupportedError,
3306
- UserRejectedRequestError,
3307
- debounce,
3308
- deepEqual,
3309
- deserialize,
3310
- minimizeContractInterface,
3311
- normalizeChainId,
3312
- parseContractResult,
3313
- serialize,
3314
- noopStorage,
3315
- createStorage,
3316
- Client,
3317
- createClient,
3318
- getClient,
3319
- connect,
3320
- disconnect,
3321
- erc20ABI,
3322
- erc721ABI,
3323
- erc4626ABI,
3324
- units,
3325
- fetchToken,
3326
- getContract,
3327
- prepareWriteContract,
3328
- getProvider,
3329
- getWebSocketProvider,
3330
- watchProvider,
3331
- watchWebSocketProvider,
3332
- multicall,
3333
- readContract,
3334
- readContracts,
3335
- watchContractEvent,
3336
- fetchBlockNumber,
3337
- watchBlockNumber,
3338
- watchMulticall,
3339
- watchReadContract,
3340
- watchReadContracts,
3341
- fetchTransaction,
3342
- fetchEnsAddress,
3343
- fetchEnsAvatar,
3344
- fetchEnsName,
3345
- fetchEnsResolver,
3346
- prepareSendTransaction,
3347
- sendTransaction,
3348
- fetchFeeData,
3349
- waitForTransaction,
3350
- watchPendingTransactions,
3351
- writeContract,
3352
- fetchBalance,
3353
- fetchSigner,
3354
- getAccount,
3355
- getNetwork,
3356
- signMessage,
3357
- signTypedData,
3358
- switchNetwork,
3359
- watchAccount,
3360
- watchNetwork,
3361
- watchSigner
3362
- };
3288
+
3289
+
3290
+
3291
+
3292
+
3293
+
3294
+
3295
+
3296
+
3297
+
3298
+
3299
+
3300
+
3301
+
3302
+
3303
+
3304
+
3305
+
3306
+
3307
+
3308
+
3309
+
3310
+
3311
+
3312
+
3313
+
3314
+
3315
+
3316
+
3317
+
3318
+
3319
+
3320
+
3321
+
3322
+
3323
+
3324
+
3325
+
3326
+
3327
+
3328
+
3329
+
3330
+
3331
+
3332
+
3333
+
3334
+
3335
+
3336
+
3337
+
3338
+
3339
+
3340
+
3341
+
3342
+
3343
+
3344
+
3345
+
3346
+
3347
+
3348
+
3349
+
3350
+
3351
+
3352
+
3353
+
3354
+
3355
+
3356
+
3357
+
3358
+
3359
+
3360
+
3361
+
3362
+ exports.configureChains = configureChains; exports.RpcError = RpcError; exports.ProviderRpcError = ProviderRpcError; exports.AddChainError = AddChainError; exports.ChainDoesNotSupportMulticallError = ChainDoesNotSupportMulticallError; exports.ChainMismatchError = ChainMismatchError; exports.ChainNotConfiguredError = ChainNotConfiguredError; exports.ConnectorAlreadyConnectedError = ConnectorAlreadyConnectedError; exports.ConnectorNotFoundError = ConnectorNotFoundError; exports.ContractMethodDoesNotExistError = ContractMethodDoesNotExistError; exports.ContractMethodNoResultError = ContractMethodNoResultError; exports.ContractMethodRevertedError = ContractMethodRevertedError; exports.ContractResultDecodeError = ContractResultDecodeError; exports.ProviderChainsNotFound = ProviderChainsNotFound; exports.ResourceUnavailableError = ResourceUnavailableError; exports.SwitchChainError = SwitchChainError; exports.SwitchChainNotSupportedError = SwitchChainNotSupportedError; exports.UserRejectedRequestError = UserRejectedRequestError; exports.debounce = debounce; exports.deepEqual = deepEqual; exports.deserialize = deserialize; exports.minimizeContractInterface = minimizeContractInterface; exports.normalizeChainId = normalizeChainId; exports.parseContractResult = parseContractResult; exports.serialize = serialize; exports.noopStorage = noopStorage; exports.createStorage = createStorage; exports.Client = Client; exports.createClient = createClient; exports.getClient = getClient; exports.connect = connect; exports.disconnect = disconnect; exports.erc20ABI = erc20ABI; exports.erc721ABI = erc721ABI; exports.erc4626ABI = erc4626ABI; exports.units = units; exports.fetchToken = fetchToken; exports.getContract = getContract; exports.prepareWriteContract = prepareWriteContract; exports.getProvider = getProvider; exports.getWebSocketProvider = getWebSocketProvider; exports.watchProvider = watchProvider; exports.watchWebSocketProvider = watchWebSocketProvider; exports.multicall = multicall; exports.readContract = readContract; exports.readContracts = readContracts; exports.watchContractEvent = watchContractEvent; exports.fetchBlockNumber = fetchBlockNumber; exports.watchBlockNumber = watchBlockNumber; exports.watchMulticall = watchMulticall; exports.watchReadContract = watchReadContract; exports.watchReadContracts = watchReadContracts; exports.fetchTransaction = fetchTransaction; exports.fetchEnsAddress = fetchEnsAddress; exports.fetchEnsAvatar = fetchEnsAvatar; exports.fetchEnsName = fetchEnsName; exports.fetchEnsResolver = fetchEnsResolver; exports.prepareSendTransaction = prepareSendTransaction; exports.sendTransaction = sendTransaction; exports.fetchFeeData = fetchFeeData; exports.waitForTransaction = waitForTransaction; exports.watchPendingTransactions = watchPendingTransactions; exports.writeContract = writeContract; exports.fetchBalance = fetchBalance; exports.fetchSigner = fetchSigner; exports.getAccount = getAccount; exports.getNetwork = getNetwork; exports.signMessage = signMessage; exports.signTypedData = signTypedData; exports.switchNetwork = switchNetwork; exports.watchAccount = watchAccount; exports.watchNetwork = watchNetwork; exports.watchSigner = watchSigner;