@wagmi/core 0.8.10-cjs → 0.8.11

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 _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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 _ethers = require('ethers');
12
+ import { providers } from "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 = _nullishCoalesce(chains.find((x) => x.id === chainId), () => ( defaultChains[0]));
61
+ const activeChain = 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 = _nullishCoalesce(chains.find((x) => x.id === chainId), () => ( defaultChains[0]));
86
+ const activeChain = 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 = _optionalChain([chainWebSocketProviders, 'access', _ => _[0], 'optionalCall', _2 => _2()]);
90
+ const provider = chainWebSocketProviders[0]?.();
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 _ethers.providers.FallbackProvider(
106
+ return new providers.FallbackProvider(
107
107
  providers_.map((chainProvider, index) => {
108
108
  const provider = chainProvider();
109
109
  return {
110
110
  provider,
111
- priority: _nullishCoalesce(provider.priority, () => ( index)),
112
- stallTimeout: _nullishCoalesce(provider.stallTimeout, () => ( stallTimeout)),
111
+ priority: provider.priority ?? index,
112
+ stallTimeout: provider.stallTimeout ?? stallTimeout,
113
113
  weight: provider.weight
114
114
  };
115
115
  }),
116
116
  targetQuorum
117
117
  );
118
118
  } catch (error) {
119
- if (_optionalChain([error, 'optionalAccess', _3 => _3.message, 'optionalAccess', _4 => _4.includes, 'call', _5 => _5(
119
+ if (error?.message?.includes(
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
- var _middleware = require('zustand/middleware');
134
- var _vanilla = require('zustand/vanilla'); var _vanilla2 = _interopRequireDefault(_vanilla);
133
+ import { persist, subscribeWithSelector } from "zustand/middleware";
134
+ import { default as create } from "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 = _optionalChain([activeChain, 'optionalAccess', _6 => _6.id]);
142
+ const activeChainId = activeChain?.id;
143
143
  if (activeChainId && chainId !== activeChainId) {
144
144
  throw new ChainMismatchError({
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}`))
145
+ activeChain: chains.find((x) => x.id === activeChainId)?.name ?? `Chain ${activeChainId}`,
146
+ targetChain: chains.find((x) => x.id === chainId)?.name ?? `Chain ${chainId}`
147
147
  });
148
148
  }
149
149
  if (signer) {
150
- const signerChainId = _optionalChain([signer, 'access', _13 => _13.provider, 'optionalAccess', _14 => _14.network, 'optionalAccess', _15 => _15.chainId]);
150
+ const signerChainId = signer.provider?.network?.chainId;
151
151
  if (signerChainId && chainId !== signerChainId) {
152
152
  const connector = getClient().connector;
153
153
  throw new ChainNotConfiguredError({
154
154
  chainId,
155
- connectorId: _nullishCoalesce(_optionalChain([connector, 'optionalAccess', _16 => _16.id]), () => ( "unknown"))
155
+ connectorId: connector?.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
-
216
+ import { BigNumber } from "ethers";
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) => _ethers.BigNumber.from(data.hex)
245
+ replace: (data) => BigNumber.from(data.hex)
246
246
  });
247
247
  return deserializedCacheWithBigNumbers;
248
248
  }
249
249
 
250
250
  // src/utils/normalizeFunctionName.ts
251
-
252
- var _utilsjs = require('ethers/lib/utils.js');
251
+ import { BigNumber as BigNumber2 } from "ethers";
252
+ import { FunctionFragment, isAddress } from "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 = _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);
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);
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 _utilsjs.isAddress.call(void 0, arg);
277
+ return isAddress(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" || _ethers.BigNumber.isBigNumber(arg);
297
+ return argType === "number" || argType === "bigint" || BigNumber2.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
- _optionalChain([getClient, 'call', _18 => _18(), 'optionalAccess', _19 => _19.config, 'access', _20 => _20.logger, 'optionalAccess', _21 => _21.warn, 'optionalCall', _22 => _22(message)]);
315
+ getClient()?.config.logger?.warn?.(message);
316
316
  }
317
317
 
318
318
  // src/utils/minimizeContractInterface.ts
319
-
320
-
319
+ import { Contract } from "ethers";
320
+ import { FormatTypes } from "ethers/lib/utils.js";
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 = _ethers.Contract.getInterface(config.abi).format(
331
- _utilsjs.FormatTypes.full
330
+ const abi = Contract.getInterface(config.abi).format(
331
+ 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
-
351
+ import { Contract as Contract2 } from "ethers";
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 = _ethers.Contract.getInterface(abi);
361
+ const iface = Contract2.getInterface(abi);
362
362
  const fragment = iface.getFunction(functionName);
363
- const isTuple = (_optionalChain([fragment, 'access', _23 => _23.outputs, 'optionalAccess', _24 => _24.length]) || 0) > 1;
363
+ const isTuple = (fragment.outputs?.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
- _nullishCoalesce(indent, () => ( void 0))
425
+ 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 (0, _chunkBVC4KGLQjs.InjectedConnector)()],
473
+ connectors = [new 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
- _chunkMQXBDTVKjs.__privateAdd.call(void 0, this, _addEffects);
483
+ __privateAdd(this, _addEffects);
484
484
  this.providers = /* @__PURE__ */ new Map();
485
485
  this.webSocketProviders = /* @__PURE__ */ new Map();
486
- _chunkMQXBDTVKjs.__privateAdd.call(void 0, this, _isAutoConnecting, void 0);
487
- _chunkMQXBDTVKjs.__privateAdd.call(void 0, this, _lastUsedConnector, void 0);
486
+ __privateAdd(this, _isAutoConnecting, void 0);
487
+ __privateAdd(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 = _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]);
501
+ const data = rawState?.state?.data;
502
+ status = data?.account ? "reconnecting" : "connecting";
503
+ chainId = data?.chain?.id;
504
504
  } catch (_error) {
505
505
  }
506
506
  }
507
- this.store = _vanilla2.default.call(void 0,
508
- _middleware.subscribeWithSelector.call(void 0,
509
- _middleware.persist.call(void 0,
507
+ this.store = create(
508
+ subscribeWithSelector(
509
+ persist(
510
510
  () => ({
511
511
  connectors: typeof connectors === "function" ? connectors() : connectors,
512
512
  provider: this.getProvider({ chainId }),
@@ -520,11 +520,11 @@ var Client = class {
520
520
  partialize: (state) => ({
521
521
  ...autoConnect && {
522
522
  data: {
523
- account: _optionalChain([state, 'optionalAccess', _30 => _30.data, 'optionalAccess', _31 => _31.account]),
524
- chain: _optionalChain([state, 'optionalAccess', _32 => _32.data, 'optionalAccess', _33 => _33.chain])
523
+ account: state?.data?.account,
524
+ chain: state?.data?.chain
525
525
  }
526
526
  },
527
- chains: _optionalChain([state, 'optionalAccess', _34 => _34.chains])
527
+ chains: state?.chains
528
528
  }),
529
529
  serialize: (state) => state,
530
530
  version: 2
@@ -533,8 +533,8 @@ var Client = class {
533
533
  )
534
534
  );
535
535
  this.storage = storage;
536
- _chunkMQXBDTVKjs.__privateSet.call(void 0, this, _lastUsedConnector, _optionalChain([storage, 'optionalAccess', _35 => _35.getItem, 'call', _36 => _36("wallet")]));
537
- _chunkMQXBDTVKjs.__privateMethod.call(void 0, this, _addEffects, addEffects_fn).call(this);
536
+ __privateSet(this, _lastUsedConnector, storage?.getItem("wallet"));
537
+ __privateMethod(this, _addEffects, addEffects_fn).call(this);
538
538
  if (autoConnect && typeof window !== "undefined")
539
539
  setTimeout(async () => await this.autoConnect(), 0);
540
540
  }
@@ -554,7 +554,7 @@ var Client = class {
554
554
  return this.store.getState().error;
555
555
  }
556
556
  get lastUsedChainId() {
557
- return _optionalChain([this, 'access', _37 => _37.data, 'optionalAccess', _38 => _38.chain, 'optionalAccess', _39 => _39.id]);
557
+ return this.data?.chain?.id;
558
558
  }
559
559
  get provider() {
560
560
  return this.store.getState().provider;
@@ -584,21 +584,21 @@ var Client = class {
584
584
  }
585
585
  async destroy() {
586
586
  if (this.connector)
587
- await _optionalChain([this, 'access', _40 => _40.connector, 'access', _41 => _41.disconnect, 'optionalCall', _42 => _42()]);
588
- _chunkMQXBDTVKjs.__privateSet.call(void 0, this, _isAutoConnecting, false);
587
+ await this.connector.disconnect?.();
588
+ __privateSet(this, _isAutoConnecting, false);
589
589
  this.clearState();
590
590
  this.store.destroy();
591
591
  }
592
592
  async autoConnect() {
593
- if (_chunkMQXBDTVKjs.__privateGet.call(void 0, this, _isAutoConnecting))
593
+ if (__privateGet(this, _isAutoConnecting))
594
594
  return;
595
- _chunkMQXBDTVKjs.__privateSet.call(void 0, this, _isAutoConnecting, true);
595
+ __privateSet(this, _isAutoConnecting, true);
596
596
  this.setState((x) => ({
597
597
  ...x,
598
- status: _optionalChain([x, 'access', _43 => _43.data, 'optionalAccess', _44 => _44.account]) ? "reconnecting" : "connecting"
598
+ status: x.data?.account ? "reconnecting" : "connecting"
599
599
  }));
600
- const sorted = _chunkMQXBDTVKjs.__privateGet.call(void 0, this, _lastUsedConnector) ? [...this.connectors].sort(
601
- (x) => x.id === _chunkMQXBDTVKjs.__privateGet.call(void 0, this, _lastUsedConnector) ? -1 : 1
600
+ const sorted = __privateGet(this, _lastUsedConnector) ? [...this.connectors].sort(
601
+ (x) => x.id === __privateGet(this, _lastUsedConnector) ? -1 : 1
602
602
  ) : this.connectors;
603
603
  let connected = false;
604
604
  for (const connector of sorted) {
@@ -611,7 +611,7 @@ var Client = class {
611
611
  this.setState((x) => ({
612
612
  ...x,
613
613
  connector,
614
- chains: _optionalChain([connector, 'optionalAccess', _45 => _45.chains]),
614
+ chains: connector?.chains,
615
615
  data,
616
616
  status: "connected"
617
617
  }));
@@ -624,33 +624,33 @@ var Client = class {
624
624
  data: void 0,
625
625
  status: "disconnected"
626
626
  }));
627
- _chunkMQXBDTVKjs.__privateSet.call(void 0, this, _isAutoConnecting, false);
627
+ __privateSet(this, _isAutoConnecting, false);
628
628
  return this.data;
629
629
  }
630
630
  getProvider({ bust, chainId } = {}) {
631
- let provider_ = this.providers.get(_nullishCoalesce(chainId, () => ( -1)));
631
+ let provider_ = this.providers.get(chainId ?? -1);
632
632
  if (provider_ && !bust)
633
633
  return provider_;
634
634
  const { provider } = this.config;
635
635
  provider_ = typeof provider === "function" ? provider({ chainId }) : provider;
636
- this.providers.set(_nullishCoalesce(chainId, () => ( -1)), provider_);
636
+ this.providers.set(chainId ?? -1, provider_);
637
637
  return provider_;
638
638
  }
639
639
  getWebSocketProvider({
640
640
  bust,
641
641
  chainId
642
642
  } = {}) {
643
- let webSocketProvider_ = this.webSocketProviders.get(_nullishCoalesce(chainId, () => ( -1)));
643
+ let webSocketProvider_ = this.webSocketProviders.get(chainId ?? -1);
644
644
  if (webSocketProvider_ && !bust)
645
645
  return webSocketProvider_;
646
646
  const { webSocketProvider } = this.config;
647
647
  webSocketProvider_ = typeof webSocketProvider === "function" ? webSocketProvider({ chainId }) : webSocketProvider;
648
648
  if (webSocketProvider_)
649
- this.webSocketProviders.set(_nullishCoalesce(chainId, () => ( -1)), webSocketProvider_);
649
+ this.webSocketProviders.set(chainId ?? -1, webSocketProvider_);
650
650
  return webSocketProvider_;
651
651
  }
652
652
  setLastUsedConnector(lastUsedConnector = null) {
653
- _optionalChain([this, 'access', _46 => _46.storage, 'optionalAccess', _47 => _47.setItem, 'call', _48 => _48("wallet", lastUsedConnector)]);
653
+ this.storage?.setItem("wallet", lastUsedConnector);
654
654
  }
655
655
  };
656
656
  _isAutoConnecting = new WeakMap();
@@ -672,14 +672,14 @@ addEffects_fn = function() {
672
672
  this.store.subscribe(
673
673
  ({ connector }) => connector,
674
674
  (connector, prevConnector) => {
675
- _optionalChain([prevConnector, 'optionalAccess', _49 => _49.off, 'optionalCall', _50 => _50("change", onChange)]);
676
- _optionalChain([prevConnector, 'optionalAccess', _51 => _51.off, 'optionalCall', _52 => _52("disconnect", onDisconnect)]);
677
- _optionalChain([prevConnector, 'optionalAccess', _53 => _53.off, 'optionalCall', _54 => _54("error", onError)]);
675
+ prevConnector?.off?.("change", onChange);
676
+ prevConnector?.off?.("disconnect", onDisconnect);
677
+ prevConnector?.off?.("error", onError);
678
678
  if (!connector)
679
679
  return;
680
- _optionalChain([connector, 'access', _55 => _55.on, 'optionalCall', _56 => _56("change", onChange)]);
681
- _optionalChain([connector, 'access', _57 => _57.on, 'optionalCall', _58 => _58("disconnect", onDisconnect)]);
682
- _optionalChain([connector, 'access', _59 => _59.on, 'optionalCall', _60 => _60("error", onError)]);
680
+ connector.on?.("change", onChange);
681
+ connector.on?.("disconnect", onDisconnect);
682
+ connector.on?.("error", onError);
683
683
  }
684
684
  );
685
685
  const { provider, webSocketProvider } = this.config;
@@ -687,7 +687,7 @@ addEffects_fn = function() {
687
687
  const subscribeWebSocketProvider = typeof webSocketProvider === "function";
688
688
  if (subscribeProvider || subscribeWebSocketProvider)
689
689
  this.store.subscribe(
690
- ({ data }) => _optionalChain([data, 'optionalAccess', _61 => _61.chain, 'optionalAccess', _62 => _62.id]),
690
+ ({ data }) => data?.chain?.id,
691
691
  (chainId) => {
692
692
  this.setState((x) => ({
693
693
  ...x,
@@ -731,7 +731,7 @@ async function connect({
731
731
  client2.setState((x) => ({
732
732
  ...x,
733
733
  connector,
734
- chains: _optionalChain([connector, 'optionalAccess', _63 => _63.chains]),
734
+ chains: connector?.chains,
735
735
  data,
736
736
  status: "connected"
737
737
  }));
@@ -758,7 +758,7 @@ async function disconnect() {
758
758
  }
759
759
 
760
760
  // src/actions/accounts/fetchBalance.ts
761
-
761
+ import { formatUnits as formatUnits3, parseBytes32String as parseBytes32String2 } from "ethers/lib/utils.js";
762
762
 
763
763
  // src/constants/abis.ts
764
764
  var erc20ABI = [
@@ -2043,7 +2043,7 @@ var units = [
2043
2043
  ];
2044
2044
 
2045
2045
  // src/actions/contracts/fetchToken.ts
2046
-
2046
+ import { formatUnits, parseBytes32String } from "ethers/lib/utils.js";
2047
2047
  async function fetchToken({
2048
2048
  address,
2049
2049
  chainId,
@@ -2066,7 +2066,7 @@ async function fetchToken({
2066
2066
  name,
2067
2067
  symbol,
2068
2068
  totalSupply: {
2069
- formatted: _utilsjs.formatUnits.call(void 0, totalSupply, units2),
2069
+ formatted: formatUnits(totalSupply, units2),
2070
2070
  value: totalSupply
2071
2071
  }
2072
2072
  };
@@ -2079,8 +2079,8 @@ async function fetchToken({
2079
2079
  abi: erc20ABI_bytes32
2080
2080
  });
2081
2081
  return {
2082
- name: _utilsjs.parseBytes32String.call(void 0, name),
2083
- symbol: _utilsjs.parseBytes32String.call(void 0, symbol),
2082
+ name: parseBytes32String(name),
2083
+ symbol: parseBytes32String(symbol),
2084
2084
  ...rest
2085
2085
  };
2086
2086
  }
@@ -2089,13 +2089,13 @@ async function fetchToken({
2089
2089
  }
2090
2090
 
2091
2091
  // src/actions/contracts/getContract.ts
2092
-
2092
+ import { Contract as EthersContract } from "ethers";
2093
2093
  function getContract({
2094
2094
  address,
2095
2095
  abi,
2096
2096
  signerOrProvider
2097
2097
  }) {
2098
- return new (0, _ethers.Contract)(
2098
+ return new EthersContract(
2099
2099
  address,
2100
2100
  abi,
2101
2101
  signerOrProvider
@@ -2112,7 +2112,7 @@ async function prepareWriteContract({
2112
2112
  signer: signer_,
2113
2113
  ...config
2114
2114
  }) {
2115
- const signer = await _asyncNullishCoalesce(signer_, async () => ( await fetchSigner({ chainId })));
2115
+ const signer = signer_ ?? await fetchSigner({ chainId });
2116
2116
  if (!signer)
2117
2117
  throw new ConnectorNotFoundError();
2118
2118
  if (chainId)
@@ -2134,7 +2134,7 @@ async function prepareWriteContract({
2134
2134
  address,
2135
2135
  functionName: normalizedFunctionName
2136
2136
  });
2137
- const params = [..._nullishCoalesce(args, () => ( [])), ...overrides ? [overrides] : []];
2137
+ const params = [...args ?? [], ...overrides ? [overrides] : []];
2138
2138
  const unsignedTransaction = await populateTransactionFn(
2139
2139
  ...params
2140
2140
  );
@@ -2208,11 +2208,11 @@ async function multicall({
2208
2208
  const chain = provider.chains.find((chain2) => chain2.id === chainId) || provider.chains[0];
2209
2209
  if (!chain)
2210
2210
  throw new ProviderChainsNotFound();
2211
- if (!_optionalChain([chain, 'optionalAccess', _64 => _64.contracts, 'optionalAccess', _65 => _65.multicall3]))
2211
+ if (!chain?.contracts?.multicall3)
2212
2212
  throw new ChainDoesNotSupportMulticallError({ chain });
2213
- if (typeof _optionalChain([overrides, 'optionalAccess', _66 => _66.blockTag]) === "number" && _optionalChain([overrides, 'optionalAccess', _67 => _67.blockTag]) < (_nullishCoalesce(chain.contracts.multicall3.blockCreated, () => ( 0))))
2213
+ if (typeof overrides?.blockTag === "number" && overrides?.blockTag < (chain.contracts.multicall3.blockCreated ?? 0))
2214
2214
  throw new ChainDoesNotSupportMulticallError({
2215
- blockNumber: _optionalChain([overrides, 'optionalAccess', _68 => _68.blockTag]),
2215
+ blockNumber: overrides?.blockTag,
2216
2216
  chain
2217
2217
  });
2218
2218
  const multicallContract = getContract({
@@ -2224,7 +2224,7 @@ async function multicall({
2224
2224
  ({ address, abi, functionName, ...config }) => {
2225
2225
  const { args } = config || {};
2226
2226
  const contract = getContract({ address, abi });
2227
- const params2 = _nullishCoalesce(args, () => ( []));
2227
+ const params2 = args ?? [];
2228
2228
  const normalizedFunctionName = normalizeFunctionName({
2229
2229
  contract,
2230
2230
  functionName,
@@ -2354,8 +2354,8 @@ async function readContract({
2354
2354
  address,
2355
2355
  functionName: normalizedFunctionName
2356
2356
  });
2357
- const params = [..._nullishCoalesce(args, () => ( [])), ...overrides ? [overrides] : []];
2358
- return _optionalChain([contractFunction, 'optionalCall', _69 => _69(...params)]);
2357
+ const params = [...args ?? [], ...overrides ? [overrides] : []];
2358
+ return contractFunction?.(...params);
2359
2359
  }
2360
2360
 
2361
2361
  // src/actions/contracts/readContracts.ts
@@ -2367,7 +2367,7 @@ async function readContracts({
2367
2367
  try {
2368
2368
  const provider = getProvider();
2369
2369
  const contractsByChainId = contracts.reduce((contracts2, contract, index) => {
2370
- const chainId = _nullishCoalesce(contract.chainId, () => ( provider.network.chainId));
2370
+ const chainId = contract.chainId ?? provider.network.chainId;
2371
2371
  return {
2372
2372
  ...contracts2,
2373
2373
  [chainId]: [...contracts2[chainId] || [], { contract, index }]
@@ -2419,7 +2419,7 @@ async function readContracts({
2419
2419
  const error = new ContractMethodRevertedError({
2420
2420
  address,
2421
2421
  functionName,
2422
- chainId: _nullishCoalesce(chainId, () => ( 1)),
2422
+ chainId: chainId ?? 1,
2423
2423
  args,
2424
2424
  errorMessage: result.reason
2425
2425
  });
@@ -2431,7 +2431,7 @@ async function readContracts({
2431
2431
  }
2432
2432
 
2433
2433
  // src/actions/contracts/watchContractEvent.ts
2434
- var _shallow = require('zustand/shallow'); var _shallow2 = _interopRequireDefault(_shallow);
2434
+ import shallow from "zustand/shallow";
2435
2435
  function watchContractEvent({
2436
2436
  address,
2437
2437
  abi,
@@ -2443,7 +2443,7 @@ function watchContractEvent({
2443
2443
  let contract;
2444
2444
  const watchEvent = async () => {
2445
2445
  if (contract)
2446
- _optionalChain([contract, 'optionalAccess', _70 => _70.off, 'call', _71 => _71(eventName, handler)]);
2446
+ contract?.off(eventName, handler);
2447
2447
  const signerOrProvider = getWebSocketProvider({ chainId }) || getProvider({ chainId });
2448
2448
  contract = getContract({
2449
2449
  address,
@@ -2463,16 +2463,16 @@ function watchContractEvent({
2463
2463
  webSocketProvider
2464
2464
  }),
2465
2465
  watchEvent,
2466
- { equalityFn: _shallow2.default }
2466
+ { equalityFn: shallow }
2467
2467
  );
2468
2468
  return () => {
2469
- _optionalChain([contract, 'optionalAccess', _72 => _72.off, 'call', _73 => _73(eventName, handler)]);
2469
+ contract?.off(eventName, handler);
2470
2470
  unsubscribe();
2471
2471
  };
2472
2472
  }
2473
2473
 
2474
2474
  // src/actions/network-status/watchBlockNumber.ts
2475
-
2475
+ import shallow2 from "zustand/shallow";
2476
2476
 
2477
2477
  // src/actions/network-status/fetchBlockNumber.ts
2478
2478
  async function fetchBlockNumber({
@@ -2489,12 +2489,12 @@ function watchBlockNumber(args, callback) {
2489
2489
  let previousProvider;
2490
2490
  const createListener = (provider) => {
2491
2491
  if (previousProvider) {
2492
- _optionalChain([previousProvider, 'optionalAccess', _74 => _74.off, 'call', _75 => _75("block", debouncedCallback)]);
2492
+ previousProvider?.off("block", debouncedCallback);
2493
2493
  }
2494
2494
  provider.on("block", debouncedCallback);
2495
2495
  previousProvider = provider;
2496
2496
  };
2497
- const provider_ = _nullishCoalesce(getWebSocketProvider({ chainId: args.chainId }), () => ( getProvider({ chainId: args.chainId })));
2497
+ const provider_ = getWebSocketProvider({ chainId: args.chainId }) ?? getProvider({ chainId: args.chainId });
2498
2498
  if (args.listen)
2499
2499
  createListener(provider_);
2500
2500
  let active = true;
@@ -2502,7 +2502,7 @@ function watchBlockNumber(args, callback) {
2502
2502
  const unsubscribe = client2.subscribe(
2503
2503
  ({ provider, webSocketProvider }) => ({ provider, webSocketProvider }),
2504
2504
  async ({ provider, webSocketProvider }) => {
2505
- const provider_2 = _nullishCoalesce(webSocketProvider, () => ( provider));
2505
+ const provider_2 = webSocketProvider ?? provider;
2506
2506
  if (args.listen && !args.chainId && provider_2) {
2507
2507
  createListener(provider_2);
2508
2508
  }
@@ -2512,14 +2512,14 @@ function watchBlockNumber(args, callback) {
2512
2512
  callback(blockNumber);
2513
2513
  },
2514
2514
  {
2515
- equalityFn: _shallow2.default
2515
+ equalityFn: shallow2
2516
2516
  }
2517
2517
  );
2518
2518
  return () => {
2519
2519
  active = false;
2520
2520
  unsubscribe();
2521
- _optionalChain([provider_, 'optionalAccess', _76 => _76.off, 'call', _77 => _77("block", debouncedCallback)]);
2522
- _optionalChain([previousProvider, 'optionalAccess', _78 => _78.off, 'call', _79 => _79("block", debouncedCallback)]);
2521
+ provider_?.off("block", debouncedCallback);
2522
+ previousProvider?.off("block", debouncedCallback);
2523
2523
  };
2524
2524
  }
2525
2525
 
@@ -2531,7 +2531,7 @@ function watchMulticall(config, callback) {
2531
2531
  const unsubscribe = client2.subscribe(({ provider }) => provider, handleChange);
2532
2532
  return () => {
2533
2533
  unsubscribe();
2534
- _optionalChain([unwatch, 'optionalCall', _80 => _80()]);
2534
+ unwatch?.();
2535
2535
  };
2536
2536
  }
2537
2537
 
@@ -2543,7 +2543,7 @@ function watchReadContract(config, callback) {
2543
2543
  const unsubscribe = client2.subscribe(({ provider }) => provider, handleChange);
2544
2544
  return () => {
2545
2545
  unsubscribe();
2546
- _optionalChain([unwatch, 'optionalCall', _81 => _81()]);
2546
+ unwatch?.();
2547
2547
  };
2548
2548
  }
2549
2549
 
@@ -2555,7 +2555,7 @@ function watchReadContracts(config, callback) {
2555
2555
  const unsubscribe = client2.subscribe(({ provider }) => provider, handleChange);
2556
2556
  return () => {
2557
2557
  unsubscribe();
2558
- _optionalChain([unwatch, 'optionalCall', _82 => _82()]);
2558
+ unwatch?.();
2559
2559
  };
2560
2560
  }
2561
2561
 
@@ -2569,10 +2569,10 @@ async function fetchTransaction({
2569
2569
  }
2570
2570
 
2571
2571
  // src/actions/transactions/prepareSendTransaction.ts
2572
-
2572
+ import { isAddress as isAddress2 } from "ethers/lib/utils.js";
2573
2573
 
2574
2574
  // src/actions/ens/fetchEnsAddress.ts
2575
-
2575
+ import { getAddress } from "ethers/lib/utils.js";
2576
2576
  async function fetchEnsAddress({
2577
2577
  chainId,
2578
2578
  name
@@ -2580,7 +2580,7 @@ async function fetchEnsAddress({
2580
2580
  const provider = getProvider({ chainId });
2581
2581
  const address = await provider.resolveName(name);
2582
2582
  try {
2583
- return address ? _utilsjs.getAddress.call(void 0, address) : null;
2583
+ return address ? getAddress(address) : null;
2584
2584
  } catch (_error) {
2585
2585
  return null;
2586
2586
  }
@@ -2597,13 +2597,13 @@ async function fetchEnsAvatar({
2597
2597
  }
2598
2598
 
2599
2599
  // src/actions/ens/fetchEnsName.ts
2600
-
2600
+ import { getAddress as getAddress2 } from "ethers/lib/utils.js";
2601
2601
  async function fetchEnsName({
2602
2602
  address,
2603
2603
  chainId
2604
2604
  }) {
2605
2605
  const provider = getProvider({ chainId });
2606
- return provider.lookupAddress(_utilsjs.getAddress.call(void 0, address));
2606
+ return provider.lookupAddress(getAddress2(address));
2607
2607
  }
2608
2608
 
2609
2609
  // src/actions/ens/fetchEnsResolver.ts
@@ -2622,13 +2622,13 @@ async function prepareSendTransaction({
2622
2622
  request,
2623
2623
  signer: signer_
2624
2624
  }) {
2625
- const signer = await _asyncNullishCoalesce(signer_, async () => ( await fetchSigner({ chainId })));
2625
+ const signer = signer_ ?? await fetchSigner({ chainId });
2626
2626
  if (!signer)
2627
2627
  throw new ConnectorNotFoundError();
2628
2628
  if (chainId)
2629
2629
  assertActiveChain({ chainId, signer });
2630
2630
  const [to, gasLimit] = await Promise.all([
2631
- _utilsjs.isAddress.call(void 0, request.to) ? Promise.resolve(request.to) : fetchEnsAddress({ name: request.to }),
2631
+ isAddress2(request.to) ? Promise.resolve(request.to) : fetchEnsAddress({ name: request.to }),
2632
2632
  request.gasLimit ? Promise.resolve(request.gasLimit) : signer.estimateGas(request)
2633
2633
  ]);
2634
2634
  if (!to)
@@ -2658,8 +2658,8 @@ async function sendTransaction({
2658
2658
  if (chainId)
2659
2659
  assertActiveChain({ chainId, signer });
2660
2660
  try {
2661
- const uncheckedSigner = _optionalChain([signer, 'access', _83 => _83.connectUnchecked, 'optionalCall', _84 => _84()]);
2662
- const { hash, wait } = await (_nullishCoalesce(uncheckedSigner, () => ( signer))).sendTransaction(
2661
+ const uncheckedSigner = signer.connectUnchecked?.();
2662
+ const { hash, wait } = await (uncheckedSigner ?? signer).sendTransaction(
2663
2663
  request
2664
2664
  );
2665
2665
  return { hash, wait };
@@ -2671,10 +2671,10 @@ async function sendTransaction({
2671
2671
  }
2672
2672
 
2673
2673
  // src/actions/transactions/waitForTransaction.ts
2674
-
2674
+ import { toUtf8String } from "ethers/lib/utils.js";
2675
2675
 
2676
2676
  // src/actions/network-status/fetchFeeData.ts
2677
-
2677
+ import { formatUnits as formatUnits2 } from "ethers/lib/utils.js";
2678
2678
  async function fetchFeeData({
2679
2679
  chainId,
2680
2680
  formatUnits: units2 = "wei"
@@ -2682,9 +2682,9 @@ async function fetchFeeData({
2682
2682
  const provider = getProvider({ chainId });
2683
2683
  const feeData = await provider.getFeeData();
2684
2684
  const formatted = {
2685
- gasPrice: feeData.gasPrice ? _utilsjs.formatUnits.call(void 0, feeData.gasPrice, units2) : null,
2686
- maxFeePerGas: feeData.maxFeePerGas ? _utilsjs.formatUnits.call(void 0, feeData.maxFeePerGas, units2) : null,
2687
- maxPriorityFeePerGas: feeData.maxPriorityFeePerGas ? _utilsjs.formatUnits.call(void 0, feeData.maxPriorityFeePerGas, units2) : null
2685
+ gasPrice: feeData.gasPrice ? formatUnits2(feeData.gasPrice, units2) : null,
2686
+ maxFeePerGas: feeData.maxFeePerGas ? formatUnits2(feeData.maxFeePerGas, units2) : null,
2687
+ maxPriorityFeePerGas: feeData.maxPriorityFeePerGas ? formatUnits2(feeData.maxPriorityFeePerGas, units2) : null
2688
2688
  };
2689
2689
  return { ...feeData, formatted };
2690
2690
  }
@@ -2703,7 +2703,7 @@ async function waitForTransaction({
2703
2703
  fetchTransaction({ hash })
2704
2704
  ]);
2705
2705
  let replaceable = null;
2706
- if (confirmations !== 0 && _optionalChain([transaction, 'optionalAccess', _85 => _85.to])) {
2706
+ if (confirmations !== 0 && transaction?.to) {
2707
2707
  replaceable = {
2708
2708
  data: transaction.data,
2709
2709
  from: transaction.from,
@@ -2722,15 +2722,15 @@ async function waitForTransaction({
2722
2722
  );
2723
2723
  if (receipt.status === 0) {
2724
2724
  const code = await provider.call(receipt, receipt.blockNumber);
2725
- const reason = _utilsjs.toUtf8String.call(void 0, `0x${code.substring(138)}`);
2725
+ const reason = toUtf8String(`0x${code.substring(138)}`);
2726
2726
  throw new Error(reason);
2727
2727
  }
2728
2728
  return receipt;
2729
2729
  } catch (err) {
2730
- if (_optionalChain([err, 'optionalAccess', _86 => _86.reason]) === "repriced") {
2731
- _optionalChain([onSpeedUp, 'optionalCall', _87 => _87(err.replacement)]);
2730
+ if (err?.reason === "repriced") {
2731
+ onSpeedUp?.(err.replacement);
2732
2732
  return waitForTransaction({
2733
- hash: _optionalChain([err, 'access', _88 => _88.replacement, 'optionalAccess', _89 => _89.hash]),
2733
+ hash: err.replacement?.hash,
2734
2734
  confirmations,
2735
2735
  timeout
2736
2736
  });
@@ -2740,35 +2740,35 @@ async function waitForTransaction({
2740
2740
  }
2741
2741
 
2742
2742
  // src/actions/transactions/watchPendingTransactions.ts
2743
-
2743
+ import shallow3 from "zustand/shallow";
2744
2744
  function watchPendingTransactions(args, callback) {
2745
2745
  let previousProvider;
2746
2746
  const createListener = (provider) => {
2747
2747
  if (previousProvider) {
2748
- _optionalChain([previousProvider, 'optionalAccess', _90 => _90.off, 'call', _91 => _91("pending", callback)]);
2748
+ previousProvider?.off("pending", callback);
2749
2749
  }
2750
2750
  provider.on("pending", callback);
2751
2751
  previousProvider = provider;
2752
2752
  };
2753
- const provider_ = _nullishCoalesce(getWebSocketProvider({ chainId: args.chainId }), () => ( getProvider({ chainId: args.chainId })));
2753
+ const provider_ = getWebSocketProvider({ chainId: args.chainId }) ?? getProvider({ chainId: args.chainId });
2754
2754
  createListener(provider_);
2755
2755
  const client2 = getClient();
2756
2756
  const unsubscribe = client2.subscribe(
2757
2757
  ({ provider, webSocketProvider }) => ({ provider, webSocketProvider }),
2758
2758
  async ({ provider, webSocketProvider }) => {
2759
- const provider_2 = _nullishCoalesce(webSocketProvider, () => ( provider));
2759
+ const provider_2 = webSocketProvider ?? provider;
2760
2760
  if (!args.chainId && provider_2) {
2761
2761
  createListener(provider_2);
2762
2762
  }
2763
2763
  },
2764
2764
  {
2765
- equalityFn: _shallow2.default
2765
+ equalityFn: shallow3
2766
2766
  }
2767
2767
  );
2768
2768
  return () => {
2769
2769
  unsubscribe();
2770
- _optionalChain([provider_, 'optionalAccess', _92 => _92.off, 'call', _93 => _93("pending", callback)]);
2771
- _optionalChain([previousProvider, 'optionalAccess', _94 => _94.off, 'call', _95 => _95("pending", callback)]);
2770
+ provider_?.off("pending", callback);
2771
+ previousProvider?.off("pending", callback);
2772
2772
  };
2773
2773
  }
2774
2774
 
@@ -2833,7 +2833,7 @@ async function fetchBalance({
2833
2833
  });
2834
2834
  return {
2835
2835
  decimals,
2836
- formatted: _utilsjs.formatUnits.call(void 0, _nullishCoalesce(value2, () => ( "0")), _nullishCoalesce(unit, () => ( decimals))),
2836
+ formatted: formatUnits3(value2 ?? "0", unit ?? decimals),
2837
2837
  symbol,
2838
2838
  value: value2
2839
2839
  };
@@ -2846,20 +2846,20 @@ async function fetchBalance({
2846
2846
  abi: erc20ABI_bytes32
2847
2847
  });
2848
2848
  return {
2849
- symbol: _utilsjs.parseBytes32String.call(void 0, symbol),
2849
+ symbol: parseBytes32String2(symbol),
2850
2850
  ...rest
2851
2851
  };
2852
2852
  }
2853
2853
  throw err;
2854
2854
  }
2855
2855
  }
2856
- const chains = [...client2.provider.chains || [], ..._nullishCoalesce(client2.chains, () => ( []))];
2856
+ const chains = [...client2.provider.chains || [], ...client2.chains ?? []];
2857
2857
  const value = await provider.getBalance(address);
2858
2858
  const chain = chains.find((x) => x.id === provider.network.chainId);
2859
2859
  return {
2860
- decimals: _nullishCoalesce(_optionalChain([chain, 'optionalAccess', _96 => _96.nativeCurrency, 'access', _97 => _97.decimals]), () => ( 18)),
2861
- formatted: _utilsjs.formatUnits.call(void 0, _nullishCoalesce(value, () => ( "0")), _nullishCoalesce(unit, () => ( "ether"))),
2862
- symbol: _nullishCoalesce(_optionalChain([chain, 'optionalAccess', _98 => _98.nativeCurrency, 'access', _99 => _99.symbol]), () => ( "ETH")),
2860
+ decimals: chain?.nativeCurrency.decimals ?? 18,
2861
+ formatted: formatUnits3(value ?? "0", unit ?? "ether"),
2862
+ symbol: chain?.nativeCurrency.symbol ?? "ETH",
2863
2863
  value
2864
2864
  };
2865
2865
  }
@@ -2869,7 +2869,7 @@ async function fetchSigner({
2869
2869
  chainId
2870
2870
  } = {}) {
2871
2871
  const client2 = getClient();
2872
- const signer = await _optionalChain([client2, 'access', _100 => _100.connector, 'optionalAccess', _101 => _101.getSigner, 'optionalCall', _102 => _102({ chainId })]) || null;
2872
+ const signer = await client2.connector?.getSigner?.({ chainId }) || null;
2873
2873
  return signer;
2874
2874
  }
2875
2875
 
@@ -2879,7 +2879,7 @@ function getAccount() {
2879
2879
  switch (status) {
2880
2880
  case "connected":
2881
2881
  return {
2882
- address: _optionalChain([data, 'optionalAccess', _103 => _103.account]),
2882
+ address: data?.account,
2883
2883
  connector,
2884
2884
  isConnected: true,
2885
2885
  isConnecting: false,
@@ -2889,9 +2889,9 @@ function getAccount() {
2889
2889
  };
2890
2890
  case "reconnecting":
2891
2891
  return {
2892
- address: _optionalChain([data, 'optionalAccess', _104 => _104.account]),
2892
+ address: data?.account,
2893
2893
  connector,
2894
- isConnected: !!_optionalChain([data, 'optionalAccess', _105 => _105.account]),
2894
+ isConnected: !!data?.account,
2895
2895
  isConnecting: false,
2896
2896
  isDisconnected: false,
2897
2897
  isReconnecting: true,
@@ -2899,7 +2899,7 @@ function getAccount() {
2899
2899
  };
2900
2900
  case "connecting":
2901
2901
  return {
2902
- address: _optionalChain([data, 'optionalAccess', _106 => _106.account]),
2902
+ address: data?.account,
2903
2903
  connector,
2904
2904
  isConnected: false,
2905
2905
  isConnecting: true,
@@ -2923,11 +2923,11 @@ function getAccount() {
2923
2923
  // src/actions/accounts/getNetwork.ts
2924
2924
  function getNetwork() {
2925
2925
  const client2 = getClient();
2926
- const chainId = _optionalChain([client2, 'access', _107 => _107.data, 'optionalAccess', _108 => _108.chain, 'optionalAccess', _109 => _109.id]);
2927
- const activeChains = _nullishCoalesce(client2.chains, () => ( []));
2928
- const activeChain = _nullishCoalesce([...client2.provider.chains || [], ...activeChains].find(
2926
+ const chainId = client2.data?.chain?.id;
2927
+ const activeChains = client2.chains ?? [];
2928
+ const activeChain = [...client2.provider.chains || [], ...activeChains].find(
2929
2929
  (x) => x.id === chainId
2930
- ), () => ( {
2930
+ ) ?? {
2931
2931
  id: chainId,
2932
2932
  name: `Chain ${chainId}`,
2933
2933
  network: `${chainId}`,
@@ -2935,11 +2935,11 @@ function getNetwork() {
2935
2935
  rpcUrls: {
2936
2936
  default: { http: [""] }
2937
2937
  }
2938
- }));
2938
+ };
2939
2939
  return {
2940
2940
  chain: chainId ? {
2941
2941
  ...activeChain,
2942
- ..._optionalChain([client2, 'access', _110 => _110.data, 'optionalAccess', _111 => _111.chain]),
2942
+ ...client2.data?.chain,
2943
2943
  id: chainId
2944
2944
  } : void 0,
2945
2945
  chains: activeChains
@@ -3003,41 +3003,41 @@ async function switchNetwork({
3003
3003
  }
3004
3004
 
3005
3005
  // src/actions/accounts/watchAccount.ts
3006
-
3006
+ import shallow4 from "zustand/shallow";
3007
3007
  function watchAccount(callback, { selector = (x) => x } = {}) {
3008
3008
  const client2 = getClient();
3009
3009
  const handleChange = () => callback(getAccount());
3010
3010
  const unsubscribe = client2.subscribe(
3011
3011
  ({ data, connector, status }) => selector({
3012
- address: _optionalChain([data, 'optionalAccess', _112 => _112.account]),
3012
+ address: data?.account,
3013
3013
  connector,
3014
3014
  status
3015
3015
  }),
3016
3016
  handleChange,
3017
3017
  {
3018
- equalityFn: _shallow2.default
3018
+ equalityFn: shallow4
3019
3019
  }
3020
3020
  );
3021
3021
  return unsubscribe;
3022
3022
  }
3023
3023
 
3024
3024
  // src/actions/accounts/watchNetwork.ts
3025
-
3025
+ import shallow5 from "zustand/shallow";
3026
3026
  function watchNetwork(callback, { selector = (x) => x } = {}) {
3027
3027
  const client2 = getClient();
3028
3028
  const handleChange = () => callback(getNetwork());
3029
3029
  const unsubscribe = client2.subscribe(
3030
- ({ data, chains }) => selector({ chainId: _optionalChain([data, 'optionalAccess', _113 => _113.chain, 'optionalAccess', _114 => _114.id]), chains }),
3030
+ ({ data, chains }) => selector({ chainId: data?.chain?.id, chains }),
3031
3031
  handleChange,
3032
3032
  {
3033
- equalityFn: _shallow2.default
3033
+ equalityFn: shallow5
3034
3034
  }
3035
3035
  );
3036
3036
  return unsubscribe;
3037
3037
  }
3038
3038
 
3039
3039
  // src/actions/accounts/watchSigner.ts
3040
-
3040
+ import shallow6 from "zustand/shallow";
3041
3041
  function watchSigner({ chainId }, callback) {
3042
3042
  const client2 = getClient();
3043
3043
  const handleChange = async () => {
@@ -3048,13 +3048,13 @@ function watchSigner({ chainId }, callback) {
3048
3048
  };
3049
3049
  const unsubscribe = client2.subscribe(
3050
3050
  ({ data, connector }) => ({
3051
- account: _optionalChain([data, 'optionalAccess', _115 => _115.account]),
3052
- chainId: _optionalChain([data, 'optionalAccess', _116 => _116.chain, 'optionalAccess', _117 => _117.id]),
3051
+ account: data?.account,
3052
+ chainId: data?.chain?.id,
3053
3053
  connector
3054
3054
  }),
3055
3055
  handleChange,
3056
3056
  {
3057
- equalityFn: _shallow2.default
3057
+ equalityFn: shallow6
3058
3058
  }
3059
3059
  );
3060
3060
  return unsubscribe;
@@ -3140,14 +3140,14 @@ var ContractMethodDoesNotExistError = class extends Error {
3140
3140
  functionName
3141
3141
  }) {
3142
3142
  const { chains, network } = getProvider();
3143
- const chain = _optionalChain([chains, 'optionalAccess', _118 => _118.find, 'call', _119 => _119(({ id }) => id === (chainId || network.chainId))]);
3144
- const blockExplorer = _optionalChain([chain, 'optionalAccess', _120 => _120.blockExplorers, 'optionalAccess', _121 => _121.default]);
3143
+ const chain = chains?.find(({ id }) => id === (chainId || network.chainId));
3144
+ const blockExplorer = chain?.blockExplorers?.default;
3145
3145
  super(
3146
3146
  [
3147
3147
  `Function "${functionName}" on contract "${address}" does not exist.`,
3148
3148
  ...blockExplorer ? [
3149
3149
  "",
3150
- `${_optionalChain([blockExplorer, 'optionalAccess', _122 => _122.name])}: ${_optionalChain([blockExplorer, 'optionalAccess', _123 => _123.url])}/address/${address}#readContract`
3150
+ `${blockExplorer?.name}: ${blockExplorer?.url}/address/${address}#readContract`
3151
3151
  ] : []
3152
3152
  ].join("\n")
3153
3153
  );
@@ -3294,78 +3294,78 @@ var UserRejectedRequestError = class extends ProviderRpcError {
3294
3294
  }
3295
3295
  };
3296
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
-
3363
-
3364
-
3365
-
3366
-
3367
-
3368
-
3369
-
3370
-
3371
- 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;
3297
+ export {
3298
+ configureChains,
3299
+ RpcError,
3300
+ ProviderRpcError,
3301
+ AddChainError,
3302
+ ChainDoesNotSupportMulticallError,
3303
+ ChainMismatchError,
3304
+ ChainNotConfiguredError,
3305
+ ConnectorAlreadyConnectedError,
3306
+ ConnectorNotFoundError,
3307
+ ContractMethodDoesNotExistError,
3308
+ ContractMethodNoResultError,
3309
+ ContractMethodRevertedError,
3310
+ ContractResultDecodeError,
3311
+ ProviderChainsNotFound,
3312
+ ResourceUnavailableError,
3313
+ SwitchChainError,
3314
+ SwitchChainNotSupportedError,
3315
+ UserRejectedRequestError,
3316
+ debounce,
3317
+ deepEqual,
3318
+ deserialize,
3319
+ minimizeContractInterface,
3320
+ normalizeChainId,
3321
+ parseContractResult,
3322
+ serialize,
3323
+ noopStorage,
3324
+ createStorage,
3325
+ Client,
3326
+ createClient,
3327
+ getClient,
3328
+ connect,
3329
+ disconnect,
3330
+ erc20ABI,
3331
+ erc721ABI,
3332
+ erc4626ABI,
3333
+ units,
3334
+ fetchToken,
3335
+ getContract,
3336
+ prepareWriteContract,
3337
+ getProvider,
3338
+ getWebSocketProvider,
3339
+ watchProvider,
3340
+ watchWebSocketProvider,
3341
+ multicall,
3342
+ readContract,
3343
+ readContracts,
3344
+ watchContractEvent,
3345
+ fetchBlockNumber,
3346
+ watchBlockNumber,
3347
+ watchMulticall,
3348
+ watchReadContract,
3349
+ watchReadContracts,
3350
+ fetchTransaction,
3351
+ fetchEnsAddress,
3352
+ fetchEnsAvatar,
3353
+ fetchEnsName,
3354
+ fetchEnsResolver,
3355
+ prepareSendTransaction,
3356
+ sendTransaction,
3357
+ fetchFeeData,
3358
+ waitForTransaction,
3359
+ watchPendingTransactions,
3360
+ writeContract,
3361
+ fetchBalance,
3362
+ fetchSigner,
3363
+ getAccount,
3364
+ getNetwork,
3365
+ signMessage,
3366
+ signTypedData,
3367
+ switchNetwork,
3368
+ watchAccount,
3369
+ watchNetwork,
3370
+ watchSigner
3371
+ };