@wagmi/core 0.10.11 → 1.0.0-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.
Files changed (40) hide show
  1. package/README.md +2 -2
  2. package/dist/chains.js +187 -187
  3. package/dist/chunk-4FHLBJG5.js +2927 -0
  4. package/dist/chunk-BVC4KGLQ.js +8 -8
  5. package/dist/chunk-EQOEZP46.js +5 -5
  6. package/dist/chunk-KFW652VN.js +6 -6
  7. package/dist/chunk-KX4UEHS5.js +1 -0
  8. package/dist/chunk-MQXBDTVK.js +7 -7
  9. package/dist/chunk-OL6OIPEP.js +188 -188
  10. package/dist/connectors/coinbaseWallet.js +5 -5
  11. package/dist/connectors/index.js +9 -9
  12. package/dist/connectors/injected.js +7 -7
  13. package/dist/connectors/ledger.js +5 -5
  14. package/dist/connectors/metaMask.js +5 -5
  15. package/dist/connectors/mock.js +9 -9
  16. package/dist/connectors/safe.js +5 -5
  17. package/dist/connectors/walletConnect.js +5 -5
  18. package/dist/connectors/walletConnectLegacy.js +5 -5
  19. package/dist/index-fc9ab085.d.ts +22 -0
  20. package/dist/index.d.ts +1032 -1296
  21. package/dist/index.js +136 -166
  22. package/dist/internal/index.d.ts +18 -8
  23. package/dist/internal/index.js +10 -8
  24. package/dist/internal/test.d.ts +712 -9
  25. package/dist/internal/test.js +64 -52
  26. package/dist/providers/alchemy.d.ts +4 -6
  27. package/dist/providers/alchemy.js +13 -30
  28. package/dist/providers/infura.d.ts +4 -6
  29. package/dist/providers/infura.js +13 -30
  30. package/dist/providers/jsonRpc.d.ts +4 -7
  31. package/dist/providers/jsonRpc.js +8 -24
  32. package/dist/providers/public.d.ts +4 -7
  33. package/dist/providers/public.js +7 -22
  34. package/dist/window.d.ts +7 -0
  35. package/dist/window.js +1 -0
  36. package/package.json +12 -8
  37. package/window/package.json +4 -0
  38. package/dist/chunk-VQG3VKOR.js +0 -3367
  39. package/dist/getContract-2443b222.d.ts +0 -310
  40. package/dist/index-35b6525c.d.ts +0 -49
@@ -1,3367 +0,0 @@
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
-
11
- // src/utils/configureChains.ts
12
- import { providers } from "ethers";
13
- function configureChains(defaultChains, providers2, {
14
- minQuorum = 1,
15
- pollingInterval = 4e3,
16
- targetQuorum = 1,
17
- stallTimeout
18
- } = {}) {
19
- if (!defaultChains.length)
20
- throw new Error("must have at least one chain");
21
- if (targetQuorum < minQuorum)
22
- throw new Error("quorum cannot be lower than minQuorum");
23
- let chains = [];
24
- const providers_ = {};
25
- const webSocketProviders_ = {};
26
- for (const chain of defaultChains) {
27
- let configExists = false;
28
- for (const provider of providers2) {
29
- const apiConfig = provider(chain);
30
- if (!apiConfig)
31
- continue;
32
- configExists = true;
33
- if (!chains.some(({ id }) => id === chain.id)) {
34
- chains = [...chains, apiConfig.chain];
35
- }
36
- providers_[chain.id] = [
37
- ...providers_[chain.id] || [],
38
- apiConfig.provider
39
- ];
40
- if (apiConfig.webSocketProvider) {
41
- webSocketProviders_[chain.id] = [
42
- ...webSocketProviders_[chain.id] || [],
43
- apiConfig.webSocketProvider
44
- ];
45
- }
46
- }
47
- if (!configExists) {
48
- throw new Error(
49
- [
50
- `Could not find valid provider configuration for chain "${chain.name}".
51
- `,
52
- "You may need to add `jsonRpcProvider` to `configureChains` with the chain's RPC URLs.",
53
- "Read more: https://wagmi.sh/core/providers/jsonRpc"
54
- ].join("\n")
55
- );
56
- }
57
- }
58
- return {
59
- chains,
60
- provider: ({ chainId }) => {
61
- const activeChain = chains.find((x) => x.id === chainId) ?? defaultChains[0];
62
- const chainProviders = providers_[activeChain.id];
63
- if (!chainProviders || !chainProviders[0])
64
- throw new Error(`No providers configured for chain "${activeChain.id}"`);
65
- let provider;
66
- if (chainProviders.length === 1) {
67
- provider = chainProviders[0]();
68
- } else {
69
- provider = fallbackProvider(targetQuorum, minQuorum, chainProviders, {
70
- stallTimeout
71
- });
72
- }
73
- if (activeChain.id === 42220) {
74
- provider.formatter.formats.block = {
75
- ...provider.formatter.formats.block,
76
- difficulty: () => 0,
77
- gasLimit: () => 0
78
- };
79
- }
80
- return Object.assign(provider, {
81
- chains,
82
- pollingInterval
83
- });
84
- },
85
- webSocketProvider: ({ chainId }) => {
86
- const activeChain = chains.find((x) => x.id === chainId) ?? defaultChains[0];
87
- const chainWebSocketProviders = webSocketProviders_[activeChain.id];
88
- if (!chainWebSocketProviders)
89
- return void 0;
90
- const provider = chainWebSocketProviders[0]?.();
91
- if (provider && activeChain.id === 42220) {
92
- provider.formatter.formats.block = {
93
- ...provider.formatter.formats.block,
94
- difficulty: () => 0,
95
- gasLimit: () => 0
96
- };
97
- }
98
- return Object.assign(provider || {}, {
99
- chains
100
- });
101
- }
102
- };
103
- }
104
- function fallbackProvider(targetQuorum, minQuorum, providers_, { stallTimeout }) {
105
- try {
106
- return new providers.FallbackProvider(
107
- providers_.map((chainProvider, index) => {
108
- const provider = chainProvider();
109
- return {
110
- provider,
111
- priority: provider.priority ?? index,
112
- stallTimeout: provider.stallTimeout ?? stallTimeout,
113
- weight: provider.weight
114
- };
115
- }),
116
- targetQuorum
117
- );
118
- } catch (error) {
119
- if (error?.message?.includes(
120
- "quorum will always fail; larger than total weight"
121
- )) {
122
- if (targetQuorum === minQuorum)
123
- throw error;
124
- return fallbackProvider(targetQuorum - 1, minQuorum, providers_, {
125
- stallTimeout
126
- });
127
- }
128
- throw error;
129
- }
130
- }
131
-
132
- // src/client.ts
133
- import { persist, subscribeWithSelector } from "zustand/middleware";
134
- import { createStore } from "zustand/vanilla";
135
-
136
- // src/utils/assertActiveChain.ts
137
- function assertActiveChain({
138
- chainId,
139
- signer
140
- }) {
141
- const { chain: activeChain, chains } = getNetwork();
142
- const activeChainId = activeChain?.id;
143
- if (activeChainId && chainId !== activeChainId) {
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}`
147
- });
148
- }
149
- if (signer) {
150
- const signerChainId = signer.provider?.network?.chainId;
151
- if (signerChainId && chainId !== signerChainId) {
152
- const connector = getClient().connector;
153
- throw new ChainNotConfiguredError({
154
- chainId,
155
- connectorId: connector?.id ?? "unknown"
156
- });
157
- }
158
- }
159
- }
160
-
161
- // src/utils/debounce.ts
162
- function debounce(fn, waitTime = 0) {
163
- let timeout;
164
- return function(...args) {
165
- if (!waitTime)
166
- return fn(...args);
167
- if (timeout)
168
- clearTimeout(timeout);
169
- timeout = setTimeout(function() {
170
- timeout = null;
171
- fn(...args);
172
- }, waitTime);
173
- };
174
- }
175
-
176
- // src/utils/deepEqual.ts
177
- function deepEqual(a, b) {
178
- if (a === b)
179
- return true;
180
- if (a && b && typeof a === "object" && typeof b === "object") {
181
- if (a.constructor !== b.constructor)
182
- return false;
183
- let length;
184
- let i;
185
- if (Array.isArray(a) && Array.isArray(b)) {
186
- length = a.length;
187
- if (length != b.length)
188
- return false;
189
- for (i = length; i-- !== 0; )
190
- if (!deepEqual(a[i], b[i]))
191
- return false;
192
- return true;
193
- }
194
- if (a.valueOf !== Object.prototype.valueOf)
195
- return a.valueOf() === b.valueOf();
196
- if (a.toString !== Object.prototype.toString)
197
- return a.toString() === b.toString();
198
- const keys = Object.keys(a);
199
- length = keys.length;
200
- if (length !== Object.keys(b).length)
201
- return false;
202
- for (i = length; i-- !== 0; )
203
- if (!Object.prototype.hasOwnProperty.call(b, keys[i]))
204
- return false;
205
- for (i = length; i-- !== 0; ) {
206
- const key = keys[i];
207
- if (key && !deepEqual(a[key], b[key]))
208
- return false;
209
- }
210
- return true;
211
- }
212
- return a !== a && b !== b;
213
- }
214
-
215
- // src/utils/deserialize.ts
216
- import { BigNumber } from "ethers";
217
- var findAndReplace = (cacheRef, {
218
- find,
219
- replace
220
- }) => {
221
- if (cacheRef && find(cacheRef)) {
222
- return replace(cacheRef);
223
- }
224
- if (typeof cacheRef !== "object") {
225
- return cacheRef;
226
- }
227
- if (Array.isArray(cacheRef)) {
228
- return cacheRef.map((item) => findAndReplace(item, { find, replace }));
229
- }
230
- if (cacheRef instanceof Object) {
231
- return Object.entries(cacheRef).reduce(
232
- (curr, [key, value]) => ({
233
- ...curr,
234
- [key]: findAndReplace(value, { find, replace })
235
- }),
236
- {}
237
- );
238
- }
239
- return cacheRef;
240
- };
241
- function deserialize(cachedString) {
242
- const cache = JSON.parse(cachedString);
243
- const deserializedCacheWithBigNumbers = findAndReplace(cache, {
244
- find: (data) => data.type === "BigNumber",
245
- replace: (data) => BigNumber.from(data.hex)
246
- });
247
- return deserializedCacheWithBigNumbers;
248
- }
249
-
250
- // src/utils/normalizeFunctionName.ts
251
- import { BigNumber as BigNumber2 } from "ethers";
252
- import { FunctionFragment, isAddress } from "ethers/lib/utils.js";
253
- function normalizeFunctionName({
254
- contract,
255
- functionName,
256
- args = []
257
- }) {
258
- if (functionName in contract.functions)
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);
262
- for (const overloadFunction of overloadFunctions) {
263
- const matched = args.every((arg, index) => {
264
- const abiParameter = overloadFunction.fragment.inputs[index];
265
- return isArgOfType(arg, abiParameter);
266
- });
267
- if (matched)
268
- return overloadFunction.name;
269
- }
270
- return functionName;
271
- }
272
- function isArgOfType(arg, abiParameter) {
273
- const argType = typeof arg;
274
- const abiParameterType = abiParameter.type;
275
- switch (abiParameterType) {
276
- case "address":
277
- return isAddress(arg);
278
- case "bool":
279
- return argType === "boolean";
280
- case "function":
281
- return argType === "string";
282
- case "string":
283
- return argType === "string";
284
- default: {
285
- if (abiParameterType === "tuple" && "components" in abiParameter)
286
- return Object.values(abiParameter.components).every(
287
- (component, index) => {
288
- return isArgOfType(
289
- Object.values(arg)[index],
290
- component
291
- );
292
- }
293
- );
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
- abiParameterType
296
- ))
297
- return argType === "number" || argType === "bigint" || BigNumber2.isBigNumber(arg);
298
- if (/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(abiParameterType))
299
- return argType === "string" || arg instanceof Uint8Array;
300
- if (/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(abiParameterType)) {
301
- return Array.isArray(arg) && arg.every(
302
- (x) => isArgOfType(x, {
303
- ...abiParameter,
304
- type: abiParameterType.replace(/(\[[0-9]{0,}\])$/, "")
305
- })
306
- );
307
- }
308
- return false;
309
- }
310
- }
311
- }
312
-
313
- // src/utils/logger.ts
314
- function logWarn(message) {
315
- getClient()?.config.logger?.warn?.(message);
316
- }
317
-
318
- // src/utils/minimizeContractInterface.ts
319
- import { Contract } from "ethers";
320
- import { FormatTypes } from "ethers/lib/utils.js";
321
- function minimizeContractInterface(config) {
322
- try {
323
- const minimizedAbi = config.abi.filter(
324
- (x) => x.type === "function" && x.name === config.functionName
325
- );
326
- if (minimizedAbi.length === 0)
327
- throw new Error("Invalid ABI");
328
- return minimizedAbi;
329
- } catch (error) {
330
- const abi = Contract.getInterface(config.abi).format(
331
- FormatTypes.full
332
- );
333
- const minimizedInterface = Array.isArray(abi) ? abi : [abi];
334
- return minimizedInterface.filter((i) => i.includes(config.functionName));
335
- }
336
- }
337
-
338
- // src/utils/normalizeChainId.ts
339
- function normalizeChainId(chainId) {
340
- if (typeof chainId === "string")
341
- return Number.parseInt(
342
- chainId,
343
- chainId.trim().substring(0, 2) === "0x" ? 16 : 10
344
- );
345
- if (typeof chainId === "bigint")
346
- return Number(chainId);
347
- return chainId;
348
- }
349
-
350
- // src/utils/parseContractResult.ts
351
- import { Contract as Contract2 } from "ethers";
352
- function isPlainArray(value) {
353
- return Array.isArray(value) && Object.keys(value).length === value.length;
354
- }
355
- function parseContractResult({
356
- abi,
357
- data,
358
- functionName
359
- }) {
360
- if (data && isPlainArray(data)) {
361
- const iface = Contract2.getInterface(abi);
362
- const fragment = iface.getFunction(functionName);
363
- const isTuple = (fragment.outputs?.length || 0) > 1;
364
- const data_ = isTuple ? data : [data];
365
- const encodedResult = iface.encodeFunctionResult(functionName, data_);
366
- const decodedResult = iface.decodeFunctionResult(
367
- functionName,
368
- encodedResult
369
- );
370
- return isTuple ? decodedResult : decodedResult[0];
371
- }
372
- return data;
373
- }
374
-
375
- // src/utils/serialize.ts
376
- function getReferenceKey(keys, cutoff) {
377
- return keys.slice(0, cutoff).join(".") || ".";
378
- }
379
- function getCutoff(array, value) {
380
- const { length } = array;
381
- for (let index = 0; index < length; ++index) {
382
- if (array[index] === value) {
383
- return index + 1;
384
- }
385
- }
386
- return 0;
387
- }
388
- function createReplacer(replacer, circularReplacer) {
389
- const hasReplacer = typeof replacer === "function";
390
- const hasCircularReplacer = typeof circularReplacer === "function";
391
- const cache = [];
392
- const keys = [];
393
- return function replace(key, value) {
394
- if (typeof value === "object") {
395
- if (cache.length) {
396
- const thisCutoff = getCutoff(cache, this);
397
- if (thisCutoff === 0) {
398
- cache[cache.length] = this;
399
- } else {
400
- cache.splice(thisCutoff);
401
- keys.splice(thisCutoff);
402
- }
403
- keys[keys.length] = key;
404
- const valueCutoff = getCutoff(cache, value);
405
- if (valueCutoff !== 0) {
406
- return hasCircularReplacer ? circularReplacer.call(
407
- this,
408
- key,
409
- value,
410
- getReferenceKey(keys, valueCutoff)
411
- ) : `[ref=${getReferenceKey(keys, valueCutoff)}]`;
412
- }
413
- } else {
414
- cache[0] = value;
415
- keys[0] = key;
416
- }
417
- }
418
- return hasReplacer ? replacer.call(this, key, value) : value;
419
- };
420
- }
421
- function serialize(value, replacer, indent, circularReplacer) {
422
- return JSON.stringify(
423
- value,
424
- createReplacer(replacer, circularReplacer),
425
- indent ?? void 0
426
- );
427
- }
428
-
429
- // src/storage.ts
430
- var noopStorage = {
431
- getItem: (_key) => "",
432
- setItem: (_key, _value) => null,
433
- removeItem: (_key) => null
434
- };
435
- function createStorage({
436
- deserialize: deserialize2 = deserialize,
437
- key: prefix = "wagmi",
438
- serialize: serialize2 = serialize,
439
- storage
440
- }) {
441
- return {
442
- ...storage,
443
- getItem: (key, defaultState = null) => {
444
- const value = storage.getItem(`${prefix}.${key}`);
445
- try {
446
- return value ? deserialize2(value) : defaultState;
447
- } catch (error) {
448
- console.warn(error);
449
- return defaultState;
450
- }
451
- },
452
- setItem: (key, value) => {
453
- if (value === null) {
454
- storage.removeItem(`${prefix}.${key}`);
455
- } else {
456
- try {
457
- storage.setItem(`${prefix}.${key}`, serialize2(value));
458
- } catch (err) {
459
- console.error(err);
460
- }
461
- }
462
- },
463
- removeItem: (key) => storage.removeItem(`${prefix}.${key}`)
464
- };
465
- }
466
-
467
- // src/client.ts
468
- var storeKey = "store";
469
- var _isAutoConnecting, _lastUsedConnector, _addEffects, addEffects_fn;
470
- var Client = class {
471
- constructor({
472
- autoConnect = false,
473
- connectors = [new InjectedConnector()],
474
- provider,
475
- storage = createStorage({
476
- storage: typeof window !== "undefined" ? window.localStorage : noopStorage
477
- }),
478
- logger = {
479
- warn: console.warn
480
- },
481
- webSocketProvider
482
- }) {
483
- __privateAdd(this, _addEffects);
484
- this.providers = /* @__PURE__ */ new Map();
485
- this.webSocketProviders = /* @__PURE__ */ new Map();
486
- __privateAdd(this, _isAutoConnecting, void 0);
487
- __privateAdd(this, _lastUsedConnector, void 0);
488
- this.config = {
489
- autoConnect,
490
- connectors,
491
- logger,
492
- provider,
493
- storage,
494
- webSocketProvider
495
- };
496
- let status = "disconnected";
497
- let chainId;
498
- if (autoConnect) {
499
- try {
500
- const rawState = storage.getItem(storeKey);
501
- const data = rawState?.state?.data;
502
- status = data?.account ? "reconnecting" : "connecting";
503
- chainId = data?.chain?.id;
504
- } catch (_error) {
505
- }
506
- }
507
- this.store = createStore(
508
- subscribeWithSelector(
509
- persist(
510
- () => ({
511
- connectors: typeof connectors === "function" ? connectors() : connectors,
512
- provider: this.getProvider({ chainId }),
513
- status,
514
- webSocketProvider: this.getWebSocketProvider({ chainId })
515
- }),
516
- {
517
- name: storeKey,
518
- storage,
519
- partialize: (state) => ({
520
- ...autoConnect && {
521
- data: {
522
- account: state?.data?.account,
523
- chain: state?.data?.chain
524
- }
525
- },
526
- chains: state?.chains
527
- }),
528
- version: 2
529
- }
530
- )
531
- )
532
- );
533
- this.storage = storage;
534
- __privateSet(this, _lastUsedConnector, storage?.getItem("wallet"));
535
- __privateMethod(this, _addEffects, addEffects_fn).call(this);
536
- if (autoConnect && typeof window !== "undefined")
537
- setTimeout(async () => await this.autoConnect(), 0);
538
- }
539
- get chains() {
540
- return this.store.getState().chains;
541
- }
542
- get connectors() {
543
- return this.store.getState().connectors;
544
- }
545
- get connector() {
546
- return this.store.getState().connector;
547
- }
548
- get data() {
549
- return this.store.getState().data;
550
- }
551
- get error() {
552
- return this.store.getState().error;
553
- }
554
- get lastUsedChainId() {
555
- return this.data?.chain?.id;
556
- }
557
- get provider() {
558
- return this.store.getState().provider;
559
- }
560
- get status() {
561
- return this.store.getState().status;
562
- }
563
- get subscribe() {
564
- return this.store.subscribe;
565
- }
566
- get webSocketProvider() {
567
- return this.store.getState().webSocketProvider;
568
- }
569
- setState(updater) {
570
- const newState = typeof updater === "function" ? updater(this.store.getState()) : updater;
571
- this.store.setState(newState, true);
572
- }
573
- clearState() {
574
- this.setState((x) => ({
575
- ...x,
576
- chains: void 0,
577
- connector: void 0,
578
- data: void 0,
579
- error: void 0,
580
- status: "disconnected"
581
- }));
582
- }
583
- async destroy() {
584
- if (this.connector)
585
- await this.connector.disconnect?.();
586
- __privateSet(this, _isAutoConnecting, false);
587
- this.clearState();
588
- this.store.destroy();
589
- }
590
- async autoConnect() {
591
- if (__privateGet(this, _isAutoConnecting))
592
- return;
593
- __privateSet(this, _isAutoConnecting, true);
594
- this.setState((x) => ({
595
- ...x,
596
- status: x.data?.account ? "reconnecting" : "connecting"
597
- }));
598
- const sorted = __privateGet(this, _lastUsedConnector) ? [...this.connectors].sort(
599
- (x) => x.id === __privateGet(this, _lastUsedConnector) ? -1 : 1
600
- ) : this.connectors;
601
- let connected = false;
602
- for (const connector of sorted) {
603
- if (!connector.ready || !connector.isAuthorized)
604
- continue;
605
- const isAuthorized = await connector.isAuthorized();
606
- if (!isAuthorized)
607
- continue;
608
- const data = await connector.connect();
609
- this.setState((x) => ({
610
- ...x,
611
- connector,
612
- chains: connector?.chains,
613
- data,
614
- status: "connected"
615
- }));
616
- connected = true;
617
- break;
618
- }
619
- if (!connected)
620
- this.setState((x) => ({
621
- ...x,
622
- data: void 0,
623
- status: "disconnected"
624
- }));
625
- __privateSet(this, _isAutoConnecting, false);
626
- return this.data;
627
- }
628
- getProvider({ bust, chainId } = {}) {
629
- let provider_ = this.providers.get(chainId ?? -1);
630
- if (provider_ && !bust)
631
- return provider_;
632
- const { provider } = this.config;
633
- provider_ = typeof provider === "function" ? provider({ chainId }) : provider;
634
- this.providers.set(chainId ?? -1, provider_);
635
- return provider_;
636
- }
637
- getWebSocketProvider({
638
- bust,
639
- chainId
640
- } = {}) {
641
- let webSocketProvider_ = this.webSocketProviders.get(chainId ?? -1);
642
- if (webSocketProvider_ && !bust)
643
- return webSocketProvider_;
644
- const { webSocketProvider } = this.config;
645
- webSocketProvider_ = typeof webSocketProvider === "function" ? webSocketProvider({ chainId }) : webSocketProvider;
646
- if (webSocketProvider_)
647
- this.webSocketProviders.set(chainId ?? -1, webSocketProvider_);
648
- return webSocketProvider_;
649
- }
650
- setLastUsedConnector(lastUsedConnector = null) {
651
- this.storage?.setItem("wallet", lastUsedConnector);
652
- }
653
- };
654
- _isAutoConnecting = new WeakMap();
655
- _lastUsedConnector = new WeakMap();
656
- _addEffects = new WeakSet();
657
- addEffects_fn = function() {
658
- const onChange = (data) => {
659
- this.setState((x) => ({
660
- ...x,
661
- data: { ...x.data, ...data }
662
- }));
663
- };
664
- const onDisconnect = () => {
665
- this.clearState();
666
- };
667
- const onError = (error) => {
668
- this.setState((x) => ({ ...x, error }));
669
- };
670
- this.store.subscribe(
671
- ({ connector }) => connector,
672
- (connector, prevConnector) => {
673
- prevConnector?.off?.("change", onChange);
674
- prevConnector?.off?.("disconnect", onDisconnect);
675
- prevConnector?.off?.("error", onError);
676
- if (!connector)
677
- return;
678
- connector.on?.("change", onChange);
679
- connector.on?.("disconnect", onDisconnect);
680
- connector.on?.("error", onError);
681
- }
682
- );
683
- const { provider, webSocketProvider } = this.config;
684
- const subscribeProvider = typeof provider === "function";
685
- const subscribeWebSocketProvider = typeof webSocketProvider === "function";
686
- if (subscribeProvider || subscribeWebSocketProvider)
687
- this.store.subscribe(
688
- ({ data }) => data?.chain?.id,
689
- (chainId) => {
690
- this.setState((x) => ({
691
- ...x,
692
- provider: this.getProvider({ bust: true, chainId }),
693
- webSocketProvider: this.getWebSocketProvider({
694
- bust: true,
695
- chainId
696
- })
697
- }));
698
- }
699
- );
700
- };
701
- var client;
702
- function createClient(config) {
703
- const client_ = new Client(config);
704
- client = client_;
705
- return client_;
706
- }
707
- function getClient() {
708
- if (!client) {
709
- throw new Error(
710
- "No wagmi client found. Ensure you have set up a client: https://wagmi.sh/react/client"
711
- );
712
- }
713
- return client;
714
- }
715
-
716
- // src/actions/accounts/connect.ts
717
- async function connect({
718
- chainId,
719
- connector
720
- }) {
721
- const client2 = getClient();
722
- const activeConnector = client2.connector;
723
- if (activeConnector && connector.id === activeConnector.id)
724
- throw new ConnectorAlreadyConnectedError();
725
- try {
726
- client2.setState((x) => ({ ...x, status: "connecting" }));
727
- const data = await connector.connect({ chainId });
728
- client2.setLastUsedConnector(connector.id);
729
- client2.setState((x) => ({
730
- ...x,
731
- connector,
732
- chains: connector?.chains,
733
- data,
734
- status: "connected"
735
- }));
736
- client2.storage.setItem("connected", true);
737
- return { ...data, connector };
738
- } catch (err) {
739
- client2.setState((x) => {
740
- return {
741
- ...x,
742
- status: x.connector ? "connected" : "disconnected"
743
- };
744
- });
745
- throw err;
746
- }
747
- }
748
-
749
- // src/actions/accounts/disconnect.ts
750
- async function disconnect() {
751
- const client2 = getClient();
752
- if (client2.connector)
753
- await client2.connector.disconnect();
754
- client2.clearState();
755
- client2.storage.removeItem("connected");
756
- }
757
-
758
- // src/actions/accounts/fetchBalance.ts
759
- import { formatUnits as formatUnits3, parseBytes32String as parseBytes32String2 } from "ethers/lib/utils.js";
760
-
761
- // src/constants/abis.ts
762
- var erc20ABI = [
763
- {
764
- type: "event",
765
- name: "Approval",
766
- inputs: [
767
- {
768
- indexed: true,
769
- name: "owner",
770
- type: "address"
771
- },
772
- {
773
- indexed: true,
774
- name: "spender",
775
- type: "address"
776
- },
777
- {
778
- indexed: false,
779
- name: "value",
780
- type: "uint256"
781
- }
782
- ]
783
- },
784
- {
785
- type: "event",
786
- name: "Transfer",
787
- inputs: [
788
- {
789
- indexed: true,
790
- name: "from",
791
- type: "address"
792
- },
793
- {
794
- indexed: true,
795
- name: "to",
796
- type: "address"
797
- },
798
- {
799
- indexed: false,
800
- name: "value",
801
- type: "uint256"
802
- }
803
- ]
804
- },
805
- {
806
- type: "function",
807
- name: "allowance",
808
- stateMutability: "view",
809
- inputs: [
810
- {
811
- name: "owner",
812
- type: "address"
813
- },
814
- {
815
- name: "spender",
816
- type: "address"
817
- }
818
- ],
819
- outputs: [
820
- {
821
- name: "",
822
- type: "uint256"
823
- }
824
- ]
825
- },
826
- {
827
- type: "function",
828
- name: "approve",
829
- stateMutability: "nonpayable",
830
- inputs: [
831
- {
832
- name: "spender",
833
- type: "address"
834
- },
835
- {
836
- name: "amount",
837
- type: "uint256"
838
- }
839
- ],
840
- outputs: [
841
- {
842
- name: "",
843
- type: "bool"
844
- }
845
- ]
846
- },
847
- {
848
- type: "function",
849
- name: "balanceOf",
850
- stateMutability: "view",
851
- inputs: [
852
- {
853
- name: "account",
854
- type: "address"
855
- }
856
- ],
857
- outputs: [
858
- {
859
- name: "",
860
- type: "uint256"
861
- }
862
- ]
863
- },
864
- {
865
- type: "function",
866
- name: "decimals",
867
- stateMutability: "view",
868
- inputs: [],
869
- outputs: [
870
- {
871
- name: "",
872
- type: "uint8"
873
- }
874
- ]
875
- },
876
- {
877
- type: "function",
878
- name: "name",
879
- stateMutability: "view",
880
- inputs: [],
881
- outputs: [
882
- {
883
- name: "",
884
- type: "string"
885
- }
886
- ]
887
- },
888
- {
889
- type: "function",
890
- name: "symbol",
891
- stateMutability: "view",
892
- inputs: [],
893
- outputs: [
894
- {
895
- name: "",
896
- type: "string"
897
- }
898
- ]
899
- },
900
- {
901
- type: "function",
902
- name: "totalSupply",
903
- stateMutability: "view",
904
- inputs: [],
905
- outputs: [
906
- {
907
- name: "",
908
- type: "uint256"
909
- }
910
- ]
911
- },
912
- {
913
- type: "function",
914
- name: "transfer",
915
- stateMutability: "nonpayable",
916
- inputs: [
917
- {
918
- name: "recipient",
919
- type: "address"
920
- },
921
- {
922
- name: "amount",
923
- type: "uint256"
924
- }
925
- ],
926
- outputs: [
927
- {
928
- name: "",
929
- type: "bool"
930
- }
931
- ]
932
- },
933
- {
934
- type: "function",
935
- name: "transferFrom",
936
- stateMutability: "nonpayable",
937
- inputs: [
938
- {
939
- name: "sender",
940
- type: "address"
941
- },
942
- {
943
- name: "recipient",
944
- type: "address"
945
- },
946
- {
947
- name: "amount",
948
- type: "uint256"
949
- }
950
- ],
951
- outputs: [
952
- {
953
- name: "",
954
- type: "bool"
955
- }
956
- ]
957
- }
958
- ];
959
- var erc20ABI_bytes32 = [
960
- {
961
- type: "event",
962
- name: "Approval",
963
- inputs: [
964
- {
965
- indexed: true,
966
- name: "owner",
967
- type: "address"
968
- },
969
- {
970
- indexed: true,
971
- name: "spender",
972
- type: "address"
973
- },
974
- {
975
- indexed: false,
976
- name: "value",
977
- type: "uint256"
978
- }
979
- ]
980
- },
981
- {
982
- type: "event",
983
- name: "Transfer",
984
- inputs: [
985
- {
986
- indexed: true,
987
- name: "from",
988
- type: "address"
989
- },
990
- {
991
- indexed: true,
992
- name: "to",
993
- type: "address"
994
- },
995
- {
996
- indexed: false,
997
- name: "value",
998
- type: "uint256"
999
- }
1000
- ]
1001
- },
1002
- {
1003
- type: "function",
1004
- name: "allowance",
1005
- stateMutability: "view",
1006
- inputs: [
1007
- {
1008
- name: "owner",
1009
- type: "address"
1010
- },
1011
- {
1012
- name: "spender",
1013
- type: "address"
1014
- }
1015
- ],
1016
- outputs: [
1017
- {
1018
- name: "",
1019
- type: "uint256"
1020
- }
1021
- ]
1022
- },
1023
- {
1024
- type: "function",
1025
- name: "approve",
1026
- stateMutability: "nonpayable",
1027
- inputs: [
1028
- {
1029
- name: "spender",
1030
- type: "address"
1031
- },
1032
- {
1033
- name: "amount",
1034
- type: "uint256"
1035
- }
1036
- ],
1037
- outputs: [
1038
- {
1039
- name: "",
1040
- type: "bool"
1041
- }
1042
- ]
1043
- },
1044
- {
1045
- type: "function",
1046
- name: "balanceOf",
1047
- stateMutability: "view",
1048
- inputs: [
1049
- {
1050
- name: "account",
1051
- type: "address"
1052
- }
1053
- ],
1054
- outputs: [
1055
- {
1056
- name: "",
1057
- type: "uint256"
1058
- }
1059
- ]
1060
- },
1061
- {
1062
- type: "function",
1063
- name: "decimals",
1064
- stateMutability: "view",
1065
- inputs: [],
1066
- outputs: [
1067
- {
1068
- name: "",
1069
- type: "uint8"
1070
- }
1071
- ]
1072
- },
1073
- {
1074
- type: "function",
1075
- name: "name",
1076
- stateMutability: "view",
1077
- inputs: [],
1078
- outputs: [
1079
- {
1080
- name: "",
1081
- type: "bytes32"
1082
- }
1083
- ]
1084
- },
1085
- {
1086
- type: "function",
1087
- name: "symbol",
1088
- stateMutability: "view",
1089
- inputs: [],
1090
- outputs: [
1091
- {
1092
- name: "",
1093
- type: "bytes32"
1094
- }
1095
- ]
1096
- },
1097
- {
1098
- type: "function",
1099
- name: "totalSupply",
1100
- stateMutability: "view",
1101
- inputs: [],
1102
- outputs: [
1103
- {
1104
- name: "",
1105
- type: "uint256"
1106
- }
1107
- ]
1108
- },
1109
- {
1110
- type: "function",
1111
- name: "transfer",
1112
- stateMutability: "nonpayable",
1113
- inputs: [
1114
- {
1115
- name: "recipient",
1116
- type: "address"
1117
- },
1118
- {
1119
- name: "amount",
1120
- type: "uint256"
1121
- }
1122
- ],
1123
- outputs: [
1124
- {
1125
- name: "",
1126
- type: "bool"
1127
- }
1128
- ]
1129
- },
1130
- {
1131
- type: "function",
1132
- name: "transferFrom",
1133
- stateMutability: "nonpayable",
1134
- inputs: [
1135
- {
1136
- name: "sender",
1137
- type: "address"
1138
- },
1139
- {
1140
- name: "recipient",
1141
- type: "address"
1142
- },
1143
- {
1144
- name: "amount",
1145
- type: "uint256"
1146
- }
1147
- ],
1148
- outputs: [
1149
- {
1150
- name: "",
1151
- type: "bool"
1152
- }
1153
- ]
1154
- }
1155
- ];
1156
- var erc721ABI = [
1157
- {
1158
- type: "event",
1159
- name: "Approval",
1160
- inputs: [
1161
- {
1162
- indexed: true,
1163
- name: "owner",
1164
- type: "address"
1165
- },
1166
- {
1167
- indexed: true,
1168
- name: "spender",
1169
- type: "address"
1170
- },
1171
- {
1172
- indexed: true,
1173
- name: "tokenId",
1174
- type: "uint256"
1175
- }
1176
- ]
1177
- },
1178
- {
1179
- type: "event",
1180
- name: "ApprovalForAll",
1181
- inputs: [
1182
- {
1183
- indexed: true,
1184
- name: "owner",
1185
- type: "address"
1186
- },
1187
- {
1188
- indexed: true,
1189
- name: "operator",
1190
- type: "address"
1191
- },
1192
- {
1193
- indexed: false,
1194
- name: "approved",
1195
- type: "bool"
1196
- }
1197
- ]
1198
- },
1199
- {
1200
- type: "event",
1201
- name: "Transfer",
1202
- inputs: [
1203
- {
1204
- indexed: true,
1205
- name: "from",
1206
- type: "address"
1207
- },
1208
- {
1209
- indexed: true,
1210
- name: "to",
1211
- type: "address"
1212
- },
1213
- {
1214
- indexed: true,
1215
- name: "tokenId",
1216
- type: "uint256"
1217
- }
1218
- ]
1219
- },
1220
- {
1221
- type: "function",
1222
- name: "approve",
1223
- stateMutability: "payable",
1224
- inputs: [
1225
- {
1226
- name: "spender",
1227
- type: "address"
1228
- },
1229
- {
1230
- name: "tokenId",
1231
- type: "uint256"
1232
- }
1233
- ],
1234
- outputs: []
1235
- },
1236
- {
1237
- type: "function",
1238
- name: "balanceOf",
1239
- stateMutability: "view",
1240
- inputs: [
1241
- {
1242
- name: "account",
1243
- type: "address"
1244
- }
1245
- ],
1246
- outputs: [
1247
- {
1248
- name: "",
1249
- type: "uint256"
1250
- }
1251
- ]
1252
- },
1253
- {
1254
- type: "function",
1255
- name: "getApproved",
1256
- stateMutability: "view",
1257
- inputs: [
1258
- {
1259
- name: "tokenId",
1260
- type: "uint256"
1261
- }
1262
- ],
1263
- outputs: [
1264
- {
1265
- name: "",
1266
- type: "address"
1267
- }
1268
- ]
1269
- },
1270
- {
1271
- type: "function",
1272
- name: "isApprovedForAll",
1273
- stateMutability: "view",
1274
- inputs: [
1275
- {
1276
- name: "owner",
1277
- type: "address"
1278
- },
1279
- {
1280
- name: "operator",
1281
- type: "address"
1282
- }
1283
- ],
1284
- outputs: [
1285
- {
1286
- name: "",
1287
- type: "bool"
1288
- }
1289
- ]
1290
- },
1291
- {
1292
- type: "function",
1293
- name: "name",
1294
- stateMutability: "view",
1295
- inputs: [],
1296
- outputs: [
1297
- {
1298
- name: "",
1299
- type: "string"
1300
- }
1301
- ]
1302
- },
1303
- {
1304
- type: "function",
1305
- name: "ownerOf",
1306
- stateMutability: "view",
1307
- inputs: [
1308
- {
1309
- name: "tokenId",
1310
- type: "uint256"
1311
- }
1312
- ],
1313
- outputs: [
1314
- {
1315
- name: "owner",
1316
- type: "address"
1317
- }
1318
- ]
1319
- },
1320
- {
1321
- type: "function",
1322
- name: "safeTransferFrom",
1323
- stateMutability: "payable",
1324
- inputs: [
1325
- {
1326
- name: "from",
1327
- type: "address"
1328
- },
1329
- {
1330
- name: "to",
1331
- type: "address"
1332
- },
1333
- {
1334
- name: "tokenId",
1335
- type: "uint256"
1336
- }
1337
- ],
1338
- outputs: []
1339
- },
1340
- {
1341
- type: "function",
1342
- name: "safeTransferFrom",
1343
- stateMutability: "nonpayable",
1344
- inputs: [
1345
- {
1346
- name: "from",
1347
- type: "address"
1348
- },
1349
- {
1350
- name: "to",
1351
- type: "address"
1352
- },
1353
- {
1354
- name: "id",
1355
- type: "uint256"
1356
- },
1357
- {
1358
- name: "data",
1359
- type: "bytes"
1360
- }
1361
- ],
1362
- outputs: []
1363
- },
1364
- {
1365
- type: "function",
1366
- name: "setApprovalForAll",
1367
- stateMutability: "nonpayable",
1368
- inputs: [
1369
- {
1370
- name: "operator",
1371
- type: "address"
1372
- },
1373
- {
1374
- name: "approved",
1375
- type: "bool"
1376
- }
1377
- ],
1378
- outputs: []
1379
- },
1380
- {
1381
- type: "function",
1382
- name: "symbol",
1383
- stateMutability: "view",
1384
- inputs: [],
1385
- outputs: [
1386
- {
1387
- name: "",
1388
- type: "string"
1389
- }
1390
- ]
1391
- },
1392
- {
1393
- type: "function",
1394
- name: "tokenByIndex",
1395
- stateMutability: "view",
1396
- inputs: [
1397
- {
1398
- name: "index",
1399
- type: "uint256"
1400
- }
1401
- ],
1402
- outputs: [
1403
- {
1404
- name: "",
1405
- type: "uint256"
1406
- }
1407
- ]
1408
- },
1409
- {
1410
- type: "function",
1411
- name: "tokenByIndex",
1412
- stateMutability: "view",
1413
- inputs: [
1414
- {
1415
- name: "owner",
1416
- type: "address"
1417
- },
1418
- {
1419
- name: "index",
1420
- type: "uint256"
1421
- }
1422
- ],
1423
- outputs: [
1424
- {
1425
- name: "tokenId",
1426
- type: "uint256"
1427
- }
1428
- ]
1429
- },
1430
- {
1431
- type: "function",
1432
- name: "tokenURI",
1433
- stateMutability: "view",
1434
- inputs: [
1435
- {
1436
- name: "tokenId",
1437
- type: "uint256"
1438
- }
1439
- ],
1440
- outputs: [
1441
- {
1442
- name: "",
1443
- type: "string"
1444
- }
1445
- ]
1446
- },
1447
- {
1448
- type: "function",
1449
- name: "totalSupply",
1450
- stateMutability: "view",
1451
- inputs: [],
1452
- outputs: [
1453
- {
1454
- name: "",
1455
- type: "uint256"
1456
- }
1457
- ]
1458
- },
1459
- {
1460
- type: "function",
1461
- name: "transferFrom",
1462
- stateMutability: "payable",
1463
- inputs: [
1464
- {
1465
- name: "sender",
1466
- type: "address"
1467
- },
1468
- {
1469
- name: "recipient",
1470
- type: "address"
1471
- },
1472
- {
1473
- name: "tokeId",
1474
- type: "uint256"
1475
- }
1476
- ],
1477
- outputs: []
1478
- }
1479
- ];
1480
- var multicallABI = [
1481
- {
1482
- inputs: [
1483
- {
1484
- components: [
1485
- {
1486
- name: "target",
1487
- type: "address"
1488
- },
1489
- {
1490
- name: "allowFailure",
1491
- type: "bool"
1492
- },
1493
- {
1494
- name: "callData",
1495
- type: "bytes"
1496
- }
1497
- ],
1498
- name: "calls",
1499
- type: "tuple[]"
1500
- }
1501
- ],
1502
- name: "aggregate3",
1503
- outputs: [
1504
- {
1505
- components: [
1506
- {
1507
- name: "success",
1508
- type: "bool"
1509
- },
1510
- {
1511
- name: "returnData",
1512
- type: "bytes"
1513
- }
1514
- ],
1515
- name: "returnData",
1516
- type: "tuple[]"
1517
- }
1518
- ],
1519
- stateMutability: "view",
1520
- type: "function"
1521
- }
1522
- ];
1523
- var erc4626ABI = [
1524
- {
1525
- anonymous: false,
1526
- inputs: [
1527
- {
1528
- indexed: true,
1529
- name: "owner",
1530
- type: "address"
1531
- },
1532
- {
1533
- indexed: true,
1534
- name: "spender",
1535
- type: "address"
1536
- },
1537
- {
1538
- indexed: false,
1539
- name: "value",
1540
- type: "uint256"
1541
- }
1542
- ],
1543
- name: "Approval",
1544
- type: "event"
1545
- },
1546
- {
1547
- anonymous: false,
1548
- inputs: [
1549
- {
1550
- indexed: true,
1551
- name: "sender",
1552
- type: "address"
1553
- },
1554
- {
1555
- indexed: true,
1556
- name: "receiver",
1557
- type: "address"
1558
- },
1559
- {
1560
- indexed: false,
1561
- name: "assets",
1562
- type: "uint256"
1563
- },
1564
- {
1565
- indexed: false,
1566
- name: "shares",
1567
- type: "uint256"
1568
- }
1569
- ],
1570
- name: "Deposit",
1571
- type: "event"
1572
- },
1573
- {
1574
- anonymous: false,
1575
- inputs: [
1576
- {
1577
- indexed: true,
1578
- name: "from",
1579
- type: "address"
1580
- },
1581
- {
1582
- indexed: true,
1583
- name: "to",
1584
- type: "address"
1585
- },
1586
- {
1587
- indexed: false,
1588
- name: "value",
1589
- type: "uint256"
1590
- }
1591
- ],
1592
- name: "Transfer",
1593
- type: "event"
1594
- },
1595
- {
1596
- anonymous: false,
1597
- inputs: [
1598
- {
1599
- indexed: true,
1600
- name: "sender",
1601
- type: "address"
1602
- },
1603
- {
1604
- indexed: true,
1605
- name: "receiver",
1606
- type: "address"
1607
- },
1608
- {
1609
- indexed: true,
1610
- name: "owner",
1611
- type: "address"
1612
- },
1613
- {
1614
- indexed: false,
1615
- name: "assets",
1616
- type: "uint256"
1617
- },
1618
- {
1619
- indexed: false,
1620
- name: "shares",
1621
- type: "uint256"
1622
- }
1623
- ],
1624
- name: "Withdraw",
1625
- type: "event"
1626
- },
1627
- {
1628
- inputs: [
1629
- {
1630
- name: "owner",
1631
- type: "address"
1632
- },
1633
- {
1634
- name: "spender",
1635
- type: "address"
1636
- }
1637
- ],
1638
- name: "allowance",
1639
- outputs: [
1640
- {
1641
- name: "",
1642
- type: "uint256"
1643
- }
1644
- ],
1645
- stateMutability: "view",
1646
- type: "function"
1647
- },
1648
- {
1649
- inputs: [
1650
- {
1651
- name: "spender",
1652
- type: "address"
1653
- },
1654
- {
1655
- name: "amount",
1656
- type: "uint256"
1657
- }
1658
- ],
1659
- name: "approve",
1660
- outputs: [
1661
- {
1662
- name: "",
1663
- type: "bool"
1664
- }
1665
- ],
1666
- stateMutability: "nonpayable",
1667
- type: "function"
1668
- },
1669
- {
1670
- inputs: [],
1671
- name: "asset",
1672
- outputs: [
1673
- {
1674
- name: "assetTokenAddress",
1675
- type: "address"
1676
- }
1677
- ],
1678
- stateMutability: "view",
1679
- type: "function"
1680
- },
1681
- {
1682
- inputs: [
1683
- {
1684
- name: "account",
1685
- type: "address"
1686
- }
1687
- ],
1688
- name: "balanceOf",
1689
- outputs: [
1690
- {
1691
- name: "",
1692
- type: "uint256"
1693
- }
1694
- ],
1695
- stateMutability: "view",
1696
- type: "function"
1697
- },
1698
- {
1699
- inputs: [
1700
- {
1701
- name: "shares",
1702
- type: "uint256"
1703
- }
1704
- ],
1705
- name: "convertToAssets",
1706
- outputs: [
1707
- {
1708
- name: "assets",
1709
- type: "uint256"
1710
- }
1711
- ],
1712
- stateMutability: "view",
1713
- type: "function"
1714
- },
1715
- {
1716
- inputs: [
1717
- {
1718
- name: "assets",
1719
- type: "uint256"
1720
- }
1721
- ],
1722
- name: "convertToShares",
1723
- outputs: [
1724
- {
1725
- name: "shares",
1726
- type: "uint256"
1727
- }
1728
- ],
1729
- stateMutability: "view",
1730
- type: "function"
1731
- },
1732
- {
1733
- inputs: [
1734
- {
1735
- name: "assets",
1736
- type: "uint256"
1737
- },
1738
- {
1739
- name: "receiver",
1740
- type: "address"
1741
- }
1742
- ],
1743
- name: "deposit",
1744
- outputs: [
1745
- {
1746
- name: "shares",
1747
- type: "uint256"
1748
- }
1749
- ],
1750
- stateMutability: "nonpayable",
1751
- type: "function"
1752
- },
1753
- {
1754
- inputs: [
1755
- {
1756
- name: "caller",
1757
- type: "address"
1758
- }
1759
- ],
1760
- name: "maxDeposit",
1761
- outputs: [
1762
- {
1763
- name: "maxAssets",
1764
- type: "uint256"
1765
- }
1766
- ],
1767
- stateMutability: "view",
1768
- type: "function"
1769
- },
1770
- {
1771
- inputs: [
1772
- {
1773
- name: "caller",
1774
- type: "address"
1775
- }
1776
- ],
1777
- name: "maxMint",
1778
- outputs: [
1779
- {
1780
- name: "maxShares",
1781
- type: "uint256"
1782
- }
1783
- ],
1784
- stateMutability: "view",
1785
- type: "function"
1786
- },
1787
- {
1788
- inputs: [
1789
- {
1790
- name: "owner",
1791
- type: "address"
1792
- }
1793
- ],
1794
- name: "maxRedeem",
1795
- outputs: [
1796
- {
1797
- name: "maxShares",
1798
- type: "uint256"
1799
- }
1800
- ],
1801
- stateMutability: "view",
1802
- type: "function"
1803
- },
1804
- {
1805
- inputs: [
1806
- {
1807
- name: "owner",
1808
- type: "address"
1809
- }
1810
- ],
1811
- name: "maxWithdraw",
1812
- outputs: [
1813
- {
1814
- name: "maxAssets",
1815
- type: "uint256"
1816
- }
1817
- ],
1818
- stateMutability: "view",
1819
- type: "function"
1820
- },
1821
- {
1822
- inputs: [
1823
- {
1824
- name: "shares",
1825
- type: "uint256"
1826
- },
1827
- {
1828
- name: "receiver",
1829
- type: "address"
1830
- }
1831
- ],
1832
- name: "mint",
1833
- outputs: [
1834
- {
1835
- name: "assets",
1836
- type: "uint256"
1837
- }
1838
- ],
1839
- stateMutability: "nonpayable",
1840
- type: "function"
1841
- },
1842
- {
1843
- inputs: [
1844
- {
1845
- name: "assets",
1846
- type: "uint256"
1847
- }
1848
- ],
1849
- name: "previewDeposit",
1850
- outputs: [
1851
- {
1852
- name: "shares",
1853
- type: "uint256"
1854
- }
1855
- ],
1856
- stateMutability: "view",
1857
- type: "function"
1858
- },
1859
- {
1860
- inputs: [
1861
- {
1862
- name: "shares",
1863
- type: "uint256"
1864
- }
1865
- ],
1866
- name: "previewMint",
1867
- outputs: [
1868
- {
1869
- name: "assets",
1870
- type: "uint256"
1871
- }
1872
- ],
1873
- stateMutability: "view",
1874
- type: "function"
1875
- },
1876
- {
1877
- inputs: [
1878
- {
1879
- name: "shares",
1880
- type: "uint256"
1881
- }
1882
- ],
1883
- name: "previewRedeem",
1884
- outputs: [
1885
- {
1886
- name: "assets",
1887
- type: "uint256"
1888
- }
1889
- ],
1890
- stateMutability: "view",
1891
- type: "function"
1892
- },
1893
- {
1894
- inputs: [
1895
- {
1896
- name: "assets",
1897
- type: "uint256"
1898
- }
1899
- ],
1900
- name: "previewWithdraw",
1901
- outputs: [
1902
- {
1903
- name: "shares",
1904
- type: "uint256"
1905
- }
1906
- ],
1907
- stateMutability: "view",
1908
- type: "function"
1909
- },
1910
- {
1911
- inputs: [
1912
- {
1913
- name: "shares",
1914
- type: "uint256"
1915
- },
1916
- {
1917
- name: "receiver",
1918
- type: "address"
1919
- },
1920
- {
1921
- name: "owner",
1922
- type: "address"
1923
- }
1924
- ],
1925
- name: "redeem",
1926
- outputs: [
1927
- {
1928
- name: "assets",
1929
- type: "uint256"
1930
- }
1931
- ],
1932
- stateMutability: "nonpayable",
1933
- type: "function"
1934
- },
1935
- {
1936
- inputs: [],
1937
- name: "totalAssets",
1938
- outputs: [
1939
- {
1940
- name: "totalManagedAssets",
1941
- type: "uint256"
1942
- }
1943
- ],
1944
- stateMutability: "view",
1945
- type: "function"
1946
- },
1947
- {
1948
- inputs: [],
1949
- name: "totalSupply",
1950
- outputs: [
1951
- {
1952
- name: "",
1953
- type: "uint256"
1954
- }
1955
- ],
1956
- stateMutability: "view",
1957
- type: "function"
1958
- },
1959
- {
1960
- inputs: [
1961
- {
1962
- name: "to",
1963
- type: "address"
1964
- },
1965
- {
1966
- name: "amount",
1967
- type: "uint256"
1968
- }
1969
- ],
1970
- name: "transfer",
1971
- outputs: [
1972
- {
1973
- name: "",
1974
- type: "bool"
1975
- }
1976
- ],
1977
- stateMutability: "nonpayable",
1978
- type: "function"
1979
- },
1980
- {
1981
- inputs: [
1982
- {
1983
- name: "from",
1984
- type: "address"
1985
- },
1986
- {
1987
- name: "to",
1988
- type: "address"
1989
- },
1990
- {
1991
- name: "amount",
1992
- type: "uint256"
1993
- }
1994
- ],
1995
- name: "transferFrom",
1996
- outputs: [
1997
- {
1998
- name: "",
1999
- type: "bool"
2000
- }
2001
- ],
2002
- stateMutability: "nonpayable",
2003
- type: "function"
2004
- },
2005
- {
2006
- inputs: [
2007
- {
2008
- name: "assets",
2009
- type: "uint256"
2010
- },
2011
- {
2012
- name: "receiver",
2013
- type: "address"
2014
- },
2015
- {
2016
- name: "owner",
2017
- type: "address"
2018
- }
2019
- ],
2020
- name: "withdraw",
2021
- outputs: [
2022
- {
2023
- name: "shares",
2024
- type: "uint256"
2025
- }
2026
- ],
2027
- stateMutability: "nonpayable",
2028
- type: "function"
2029
- }
2030
- ];
2031
-
2032
- // src/constants/units.ts
2033
- var units = [
2034
- "wei",
2035
- "kwei",
2036
- "mwei",
2037
- "gwei",
2038
- "szabo",
2039
- "finney",
2040
- "ether"
2041
- ];
2042
-
2043
- // src/actions/contracts/fetchToken.ts
2044
- import { formatUnits, parseBytes32String } from "ethers/lib/utils.js";
2045
- async function fetchToken({
2046
- address,
2047
- chainId,
2048
- formatUnits: units2 = "ether"
2049
- }) {
2050
- async function fetchToken_({ abi }) {
2051
- const erc20Config = { address, abi, chainId };
2052
- const [decimals, name, symbol, totalSupply] = await readContracts({
2053
- allowFailure: false,
2054
- contracts: [
2055
- { ...erc20Config, functionName: "decimals" },
2056
- { ...erc20Config, functionName: "name" },
2057
- { ...erc20Config, functionName: "symbol" },
2058
- { ...erc20Config, functionName: "totalSupply" }
2059
- ]
2060
- });
2061
- return {
2062
- address,
2063
- decimals,
2064
- name,
2065
- symbol,
2066
- totalSupply: {
2067
- formatted: formatUnits(totalSupply, units2),
2068
- value: totalSupply
2069
- }
2070
- };
2071
- }
2072
- try {
2073
- return await fetchToken_({ abi: erc20ABI });
2074
- } catch (err) {
2075
- if (err instanceof ContractResultDecodeError) {
2076
- const { name, symbol, ...rest } = await fetchToken_({
2077
- abi: erc20ABI_bytes32
2078
- });
2079
- return {
2080
- name: parseBytes32String(name),
2081
- symbol: parseBytes32String(symbol),
2082
- ...rest
2083
- };
2084
- }
2085
- throw err;
2086
- }
2087
- }
2088
-
2089
- // src/actions/contracts/getContract.ts
2090
- import { Contract as EthersContract } from "ethers";
2091
- function getContract({
2092
- address,
2093
- abi,
2094
- signerOrProvider
2095
- }) {
2096
- return new EthersContract(
2097
- address,
2098
- abi,
2099
- signerOrProvider
2100
- );
2101
- }
2102
-
2103
- // src/actions/contracts/prepareWriteContract.ts
2104
- async function prepareWriteContract({
2105
- abi,
2106
- address,
2107
- chainId,
2108
- functionName,
2109
- overrides,
2110
- signer: signer_,
2111
- ...config
2112
- }) {
2113
- const signer = signer_ ?? await fetchSigner({ chainId });
2114
- if (!signer)
2115
- throw new ConnectorNotFoundError();
2116
- if (chainId)
2117
- assertActiveChain({ chainId, signer });
2118
- const contract = getContract({
2119
- address,
2120
- abi,
2121
- signerOrProvider: signer
2122
- });
2123
- const args = config.args;
2124
- const normalizedFunctionName = normalizeFunctionName({
2125
- contract,
2126
- functionName,
2127
- args
2128
- });
2129
- const populateTransactionFn = contract.populateTransaction[normalizedFunctionName];
2130
- if (!populateTransactionFn)
2131
- throw new ContractMethodDoesNotExistError({
2132
- address,
2133
- functionName: normalizedFunctionName
2134
- });
2135
- const params = [...args ?? [], ...overrides ? [overrides] : []];
2136
- const unsignedTransaction = await populateTransactionFn(
2137
- ...params
2138
- );
2139
- const gasLimit = unsignedTransaction.gasLimit || await signer.estimateGas(unsignedTransaction);
2140
- const minimizedAbi = minimizeContractInterface({
2141
- abi,
2142
- functionName
2143
- });
2144
- return {
2145
- abi: minimizedAbi,
2146
- address,
2147
- chainId,
2148
- functionName,
2149
- mode: "prepared",
2150
- request: {
2151
- ...unsignedTransaction,
2152
- gasLimit
2153
- }
2154
- };
2155
- }
2156
-
2157
- // src/actions/providers/getProvider.ts
2158
- function getProvider({
2159
- chainId
2160
- } = {}) {
2161
- const client2 = getClient();
2162
- if (chainId)
2163
- return client2.getProvider({ chainId }) || client2.provider;
2164
- return client2.provider;
2165
- }
2166
-
2167
- // src/actions/providers/getWebSocketProvider.ts
2168
- function getWebSocketProvider({
2169
- chainId
2170
- } = {}) {
2171
- const client2 = getClient();
2172
- if (chainId)
2173
- return client2.getWebSocketProvider({ chainId }) || client2.webSocketProvider;
2174
- return client2.webSocketProvider;
2175
- }
2176
-
2177
- // src/actions/providers/watchProvider.ts
2178
- function watchProvider(args, callback) {
2179
- const client2 = getClient();
2180
- const handleChange = async () => callback(getProvider(args));
2181
- const unsubscribe = client2.subscribe(({ provider }) => provider, handleChange);
2182
- return unsubscribe;
2183
- }
2184
-
2185
- // src/actions/providers/watchWebSocketProvider.ts
2186
- function watchWebSocketProvider(args, callback) {
2187
- const client2 = getClient();
2188
- const handleChange = async () => callback(getWebSocketProvider(args));
2189
- const unsubscribe = client2.subscribe(
2190
- ({ webSocketProvider }) => webSocketProvider,
2191
- handleChange
2192
- );
2193
- return unsubscribe;
2194
- }
2195
-
2196
- // src/actions/contracts/multicall.ts
2197
- async function multicall({
2198
- allowFailure = true,
2199
- chainId: chainIdOverride,
2200
- contracts,
2201
- overrides
2202
- }) {
2203
- const provider = getProvider({ chainId: chainIdOverride });
2204
- if (!provider.chains?.[0])
2205
- throw new ProviderChainsNotFound();
2206
- const chainId = provider.network.chainId;
2207
- if (typeof chainIdOverride !== "undefined" && chainIdOverride !== chainId)
2208
- throw new ChainNotConfiguredError({ chainId: chainIdOverride });
2209
- const chain = provider.chains.find((chain2) => chain2.id === chainId);
2210
- if (!chain)
2211
- throw new ChainNotConfiguredError({ chainId });
2212
- if (!chain?.contracts?.multicall3)
2213
- throw new ChainDoesNotSupportMulticallError({ chain });
2214
- if (typeof overrides?.blockTag === "number" && overrides?.blockTag < (chain.contracts.multicall3.blockCreated ?? 0))
2215
- throw new ChainDoesNotSupportMulticallError({
2216
- blockNumber: overrides?.blockTag,
2217
- chain
2218
- });
2219
- const multicallContract = getContract({
2220
- address: chain.contracts.multicall3.address,
2221
- abi: multicallABI,
2222
- signerOrProvider: provider
2223
- });
2224
- const calls = contracts.map(
2225
- ({ address, abi, functionName, ...config }) => {
2226
- const { args } = config || {};
2227
- const contract = getContract({ address, abi });
2228
- const params2 = args ?? [];
2229
- const normalizedFunctionName = normalizeFunctionName({
2230
- contract,
2231
- functionName,
2232
- args
2233
- });
2234
- try {
2235
- const contractFunction = contract[normalizedFunctionName];
2236
- if (!contractFunction)
2237
- logWarn(
2238
- `"${normalizedFunctionName}" is not in the interface for contract "${address}"`
2239
- );
2240
- const callData = contract.interface.encodeFunctionData(
2241
- normalizedFunctionName,
2242
- params2
2243
- );
2244
- return {
2245
- target: address,
2246
- allowFailure,
2247
- callData
2248
- };
2249
- } catch (err) {
2250
- if (!allowFailure)
2251
- throw err;
2252
- return {
2253
- target: address,
2254
- allowFailure,
2255
- callData: "0x"
2256
- };
2257
- }
2258
- }
2259
- );
2260
- const params = [...[calls], ...overrides ? [overrides] : []];
2261
- const results = await multicallContract.aggregate3(
2262
- ...params
2263
- );
2264
- return results.map(({ returnData, success }, i) => {
2265
- const { address, abi, functionName, ...rest } = contracts[i];
2266
- const contract = getContract({
2267
- address,
2268
- abi
2269
- });
2270
- const args = rest.args;
2271
- const normalizedFunctionName = normalizeFunctionName({
2272
- contract,
2273
- functionName,
2274
- args
2275
- });
2276
- if (!success) {
2277
- let error;
2278
- try {
2279
- contract.interface.decodeFunctionResult(
2280
- normalizedFunctionName,
2281
- returnData
2282
- );
2283
- } catch (err) {
2284
- error = new ContractMethodRevertedError({
2285
- address,
2286
- args,
2287
- chainId: chain.id,
2288
- functionName: normalizedFunctionName,
2289
- errorMessage: err.message
2290
- });
2291
- if (!allowFailure)
2292
- throw error;
2293
- logWarn(error.message);
2294
- }
2295
- return null;
2296
- }
2297
- if (returnData === "0x") {
2298
- const error = new ContractMethodNoResultError({
2299
- address,
2300
- args,
2301
- chainId: chain.id,
2302
- functionName: normalizedFunctionName
2303
- });
2304
- if (!allowFailure)
2305
- throw error;
2306
- logWarn(error.message);
2307
- return null;
2308
- }
2309
- try {
2310
- const result = contract.interface.decodeFunctionResult(
2311
- normalizedFunctionName,
2312
- returnData
2313
- );
2314
- return Array.isArray(result) && result.length === 1 ? result[0] : result;
2315
- } catch (err) {
2316
- const error = new ContractResultDecodeError({
2317
- address,
2318
- args,
2319
- chainId: chain.id,
2320
- functionName: normalizedFunctionName,
2321
- errorMessage: err.message
2322
- });
2323
- if (!allowFailure)
2324
- throw error;
2325
- logWarn(error.message);
2326
- return null;
2327
- }
2328
- });
2329
- }
2330
-
2331
- // src/actions/contracts/readContract.ts
2332
- async function readContract({
2333
- address,
2334
- chainId,
2335
- abi,
2336
- functionName,
2337
- overrides,
2338
- ...config
2339
- }) {
2340
- const provider = getProvider({ chainId });
2341
- const contract = getContract({
2342
- address,
2343
- abi,
2344
- signerOrProvider: provider
2345
- });
2346
- const args = config.args;
2347
- const normalizedFunctionName = normalizeFunctionName({
2348
- contract,
2349
- functionName,
2350
- args
2351
- });
2352
- const contractFunction = contract[normalizedFunctionName];
2353
- if (!contractFunction)
2354
- throw new ContractMethodDoesNotExistError({
2355
- address,
2356
- functionName: normalizedFunctionName
2357
- });
2358
- const params = [...args ?? [], ...overrides ? [overrides] : []];
2359
- return contractFunction?.(...params);
2360
- }
2361
-
2362
- // src/actions/contracts/readContracts.ts
2363
- async function readContracts({
2364
- allowFailure = true,
2365
- contracts,
2366
- overrides
2367
- }) {
2368
- try {
2369
- const provider = getProvider();
2370
- const contractsByChainId = contracts.reduce((contracts2, contract, index) => {
2371
- const chainId = contract.chainId ?? provider.network.chainId;
2372
- return {
2373
- ...contracts2,
2374
- [chainId]: [...contracts2[chainId] || [], { contract, index }]
2375
- };
2376
- }, {});
2377
- const promises = () => Object.entries(contractsByChainId).map(
2378
- ([chainId, contracts2]) => multicall({
2379
- allowFailure,
2380
- chainId: parseInt(chainId),
2381
- contracts: contracts2.map(({ contract }) => contract),
2382
- overrides
2383
- })
2384
- );
2385
- let multicallResults;
2386
- if (allowFailure) {
2387
- multicallResults = (await Promise.allSettled(promises())).map((result) => {
2388
- if (result.status === "fulfilled")
2389
- return result.value;
2390
- if (result.reason instanceof ChainDoesNotSupportMulticallError) {
2391
- logWarn(result.reason.message);
2392
- throw result.reason;
2393
- }
2394
- return null;
2395
- }).flat();
2396
- } else {
2397
- multicallResults = (await Promise.all(promises())).flat();
2398
- }
2399
- const resultIndexes = Object.values(contractsByChainId).map((contracts2) => contracts2.map(({ index }) => index)).flat();
2400
- return multicallResults.reduce((results, result, index) => {
2401
- if (results)
2402
- results[resultIndexes[index]] = result;
2403
- return results;
2404
- }, []);
2405
- } catch (err) {
2406
- if (err instanceof ContractResultDecodeError)
2407
- throw err;
2408
- if (err instanceof ContractMethodNoResultError)
2409
- throw err;
2410
- if (err instanceof ContractMethodRevertedError)
2411
- throw err;
2412
- const promises = () => contracts.map(
2413
- (contract) => readContract({ ...contract, overrides })
2414
- );
2415
- if (allowFailure)
2416
- return (await Promise.allSettled(promises())).map((result, i) => {
2417
- if (result.status === "fulfilled")
2418
- return result.value;
2419
- const { address, args, chainId, functionName } = contracts[i];
2420
- const error = new ContractMethodRevertedError({
2421
- address,
2422
- functionName,
2423
- chainId: chainId ?? 1,
2424
- args,
2425
- errorMessage: result.reason
2426
- });
2427
- logWarn(error.message);
2428
- return null;
2429
- });
2430
- return await Promise.all(promises());
2431
- }
2432
- }
2433
-
2434
- // src/actions/contracts/watchContractEvent.ts
2435
- import { shallow } from "zustand/shallow";
2436
- function watchContractEvent({
2437
- address,
2438
- abi,
2439
- chainId,
2440
- eventName,
2441
- once
2442
- }, callback) {
2443
- const handler = (...event) => callback(...event);
2444
- let contract;
2445
- const watchEvent = async () => {
2446
- if (contract)
2447
- contract?.off(eventName, handler);
2448
- const signerOrProvider = getWebSocketProvider({ chainId }) || getProvider({ chainId });
2449
- contract = getContract({
2450
- address,
2451
- abi,
2452
- signerOrProvider
2453
- });
2454
- if (once)
2455
- contract.once(eventName, handler);
2456
- else
2457
- contract.on(eventName, handler);
2458
- };
2459
- watchEvent();
2460
- const client2 = getClient();
2461
- const unsubscribe = client2.subscribe(
2462
- ({ provider, webSocketProvider }) => ({
2463
- provider,
2464
- webSocketProvider
2465
- }),
2466
- watchEvent,
2467
- { equalityFn: shallow }
2468
- );
2469
- return () => {
2470
- contract?.off(eventName, handler);
2471
- unsubscribe();
2472
- };
2473
- }
2474
-
2475
- // src/actions/network-status/watchBlockNumber.ts
2476
- import { shallow as shallow2 } from "zustand/shallow";
2477
-
2478
- // src/actions/network-status/fetchBlockNumber.ts
2479
- async function fetchBlockNumber({
2480
- chainId
2481
- } = {}) {
2482
- const provider = getProvider({ chainId });
2483
- const blockNumber = await provider.getBlockNumber();
2484
- return blockNumber;
2485
- }
2486
-
2487
- // src/actions/network-status/watchBlockNumber.ts
2488
- function watchBlockNumber(args, callback) {
2489
- const debouncedCallback = debounce(callback, 1);
2490
- let previousProvider;
2491
- const createListener = (provider) => {
2492
- if (previousProvider) {
2493
- previousProvider?.off("block", debouncedCallback);
2494
- }
2495
- provider.on("block", debouncedCallback);
2496
- previousProvider = provider;
2497
- };
2498
- const provider_ = getWebSocketProvider({ chainId: args.chainId }) ?? getProvider({ chainId: args.chainId });
2499
- if (args.listen)
2500
- createListener(provider_);
2501
- let active = true;
2502
- const client2 = getClient();
2503
- const unsubscribe = client2.subscribe(
2504
- ({ provider, webSocketProvider }) => ({ provider, webSocketProvider }),
2505
- async ({ provider, webSocketProvider }) => {
2506
- const provider_2 = webSocketProvider ?? provider;
2507
- if (args.listen && !args.chainId && provider_2) {
2508
- createListener(provider_2);
2509
- }
2510
- const blockNumber = await fetchBlockNumber({ chainId: args.chainId });
2511
- if (!active)
2512
- return;
2513
- callback(blockNumber);
2514
- },
2515
- {
2516
- equalityFn: shallow2
2517
- }
2518
- );
2519
- return () => {
2520
- active = false;
2521
- unsubscribe();
2522
- provider_?.off("block", debouncedCallback);
2523
- previousProvider?.off("block", debouncedCallback);
2524
- };
2525
- }
2526
-
2527
- // src/actions/contracts/watchMulticall.ts
2528
- function watchMulticall(config, callback) {
2529
- const client2 = getClient();
2530
- const handleChange = async () => callback(await multicall(config));
2531
- const unwatch = config.listenToBlock ? watchBlockNumber({ listen: true }, handleChange) : void 0;
2532
- const unsubscribe = client2.subscribe(({ provider }) => provider, handleChange);
2533
- return () => {
2534
- unsubscribe();
2535
- unwatch?.();
2536
- };
2537
- }
2538
-
2539
- // src/actions/contracts/watchReadContract.ts
2540
- function watchReadContract(config, callback) {
2541
- const client2 = getClient();
2542
- const handleChange = async () => callback(await readContract(config));
2543
- const unwatch = config.listenToBlock ? watchBlockNumber({ listen: true }, handleChange) : void 0;
2544
- const unsubscribe = client2.subscribe(({ provider }) => provider, handleChange);
2545
- return () => {
2546
- unsubscribe();
2547
- unwatch?.();
2548
- };
2549
- }
2550
-
2551
- // src/actions/contracts/watchReadContracts.ts
2552
- function watchReadContracts(config, callback) {
2553
- const client2 = getClient();
2554
- const handleChange = async () => callback(await readContracts(config));
2555
- const unwatch = config.listenToBlock ? watchBlockNumber({ listen: true }, handleChange) : void 0;
2556
- const unsubscribe = client2.subscribe(({ provider }) => provider, handleChange);
2557
- return () => {
2558
- unsubscribe();
2559
- unwatch?.();
2560
- };
2561
- }
2562
-
2563
- // src/actions/transactions/fetchTransaction.ts
2564
- async function fetchTransaction({
2565
- chainId,
2566
- hash
2567
- }) {
2568
- const provider = getProvider({ chainId });
2569
- return provider.getTransaction(hash);
2570
- }
2571
-
2572
- // src/actions/transactions/prepareSendTransaction.ts
2573
- import { isAddress as isAddress2 } from "ethers/lib/utils.js";
2574
-
2575
- // src/actions/ens/fetchEnsAddress.ts
2576
- import { getAddress } from "ethers/lib/utils.js";
2577
- async function fetchEnsAddress({
2578
- chainId,
2579
- name
2580
- }) {
2581
- const provider = getProvider({ chainId });
2582
- const address = await provider.resolveName(name);
2583
- try {
2584
- return address ? getAddress(address) : null;
2585
- } catch (_error) {
2586
- return null;
2587
- }
2588
- }
2589
-
2590
- // src/actions/ens/fetchEnsAvatar.ts
2591
- async function fetchEnsAvatar({
2592
- address,
2593
- chainId
2594
- }) {
2595
- const provider = getProvider({ chainId });
2596
- const avatar = await provider.getAvatar(address);
2597
- return avatar;
2598
- }
2599
-
2600
- // src/actions/ens/fetchEnsName.ts
2601
- import { getAddress as getAddress2 } from "ethers/lib/utils.js";
2602
- async function fetchEnsName({
2603
- address,
2604
- chainId
2605
- }) {
2606
- const provider = getProvider({ chainId });
2607
- return provider.lookupAddress(getAddress2(address));
2608
- }
2609
-
2610
- // src/actions/ens/fetchEnsResolver.ts
2611
- async function fetchEnsResolver({
2612
- chainId,
2613
- name
2614
- }) {
2615
- const provider = getProvider({ chainId });
2616
- const resolver = await provider.getResolver(name);
2617
- return resolver;
2618
- }
2619
-
2620
- // src/actions/transactions/prepareSendTransaction.ts
2621
- async function prepareSendTransaction({
2622
- chainId,
2623
- request,
2624
- signer: signer_
2625
- }) {
2626
- const signer = signer_ ?? await fetchSigner({ chainId });
2627
- if (!signer)
2628
- throw new ConnectorNotFoundError();
2629
- if (chainId)
2630
- assertActiveChain({ chainId, signer });
2631
- const [to, gasLimit] = await Promise.all([
2632
- isAddress2(request.to) ? Promise.resolve(request.to) : fetchEnsAddress({ name: request.to }),
2633
- request.gasLimit ? Promise.resolve(request.gasLimit) : signer.estimateGas(request)
2634
- ]);
2635
- if (!to)
2636
- throw new Error("Could not resolve ENS name");
2637
- return {
2638
- ...chainId ? { chainId } : {},
2639
- request: { ...request, gasLimit, to },
2640
- mode: "prepared"
2641
- };
2642
- }
2643
-
2644
- // src/actions/transactions/sendTransaction.ts
2645
- async function sendTransaction({
2646
- chainId,
2647
- mode,
2648
- request
2649
- }) {
2650
- const signer = await fetchSigner();
2651
- if (!signer)
2652
- throw new ConnectorNotFoundError();
2653
- if (mode === "prepared") {
2654
- if (!request.gasLimit)
2655
- throw new Error("`gasLimit` is required");
2656
- if (!request.to)
2657
- throw new Error("`to` is required");
2658
- }
2659
- if (chainId)
2660
- assertActiveChain({ chainId, signer });
2661
- try {
2662
- const uncheckedSigner = signer.connectUnchecked?.();
2663
- const { hash, wait } = await (uncheckedSigner ?? signer).sendTransaction(
2664
- request
2665
- );
2666
- return { hash, wait };
2667
- } catch (error) {
2668
- if (error.code === 4001 || error.code === "ACTION_REJECTED")
2669
- throw new UserRejectedRequestError(error);
2670
- throw error;
2671
- }
2672
- }
2673
-
2674
- // src/actions/transactions/waitForTransaction.ts
2675
- import { toUtf8String } from "ethers/lib/utils.js";
2676
-
2677
- // src/actions/network-status/fetchFeeData.ts
2678
- import { formatUnits as formatUnits2 } from "ethers/lib/utils.js";
2679
- async function fetchFeeData({
2680
- chainId,
2681
- formatUnits: units2 = "wei"
2682
- } = {}) {
2683
- const provider = getProvider({ chainId });
2684
- const feeData = await provider.getFeeData();
2685
- const formatted = {
2686
- gasPrice: feeData.gasPrice ? formatUnits2(feeData.gasPrice, units2) : null,
2687
- maxFeePerGas: feeData.maxFeePerGas ? formatUnits2(feeData.maxFeePerGas, units2) : null,
2688
- maxPriorityFeePerGas: feeData.maxPriorityFeePerGas ? formatUnits2(feeData.maxPriorityFeePerGas, units2) : null
2689
- };
2690
- return { ...feeData, formatted };
2691
- }
2692
-
2693
- // src/actions/transactions/waitForTransaction.ts
2694
- async function waitForTransaction({
2695
- chainId,
2696
- confirmations = 1,
2697
- hash,
2698
- onSpeedUp,
2699
- timeout = 0
2700
- }) {
2701
- const provider = getProvider({ chainId });
2702
- const [blockNumber, transaction] = await Promise.all([
2703
- fetchBlockNumber(),
2704
- fetchTransaction({ hash })
2705
- ]);
2706
- let replaceable = null;
2707
- if (confirmations !== 0 && transaction?.to) {
2708
- replaceable = {
2709
- data: transaction.data,
2710
- from: transaction.from,
2711
- nonce: transaction.nonce,
2712
- startBlock: blockNumber,
2713
- to: transaction.to,
2714
- value: transaction.value
2715
- };
2716
- }
2717
- try {
2718
- const receipt = await provider._waitForTransaction(
2719
- hash,
2720
- confirmations,
2721
- timeout,
2722
- replaceable
2723
- );
2724
- if (receipt.status === 0) {
2725
- const code = await provider.call(receipt, receipt.blockNumber);
2726
- const reason = toUtf8String(`0x${code.substring(138)}`);
2727
- throw new Error(reason);
2728
- }
2729
- return receipt;
2730
- } catch (err) {
2731
- if (err?.reason === "repriced") {
2732
- onSpeedUp?.(err.replacement);
2733
- return waitForTransaction({
2734
- hash: err.replacement?.hash,
2735
- confirmations,
2736
- timeout
2737
- });
2738
- }
2739
- throw err;
2740
- }
2741
- }
2742
-
2743
- // src/actions/transactions/watchPendingTransactions.ts
2744
- import { shallow as shallow3 } from "zustand/shallow";
2745
- function watchPendingTransactions(args, callback) {
2746
- let previousProvider;
2747
- const createListener = (provider) => {
2748
- if (previousProvider) {
2749
- previousProvider?.off("pending", callback);
2750
- }
2751
- provider.on("pending", callback);
2752
- previousProvider = provider;
2753
- };
2754
- const provider_ = getWebSocketProvider({ chainId: args.chainId }) ?? getProvider({ chainId: args.chainId });
2755
- createListener(provider_);
2756
- const client2 = getClient();
2757
- const unsubscribe = client2.subscribe(
2758
- ({ provider, webSocketProvider }) => ({ provider, webSocketProvider }),
2759
- async ({ provider, webSocketProvider }) => {
2760
- const provider_2 = webSocketProvider ?? provider;
2761
- if (!args.chainId && provider_2) {
2762
- createListener(provider_2);
2763
- }
2764
- },
2765
- {
2766
- equalityFn: shallow3
2767
- }
2768
- );
2769
- return () => {
2770
- unsubscribe();
2771
- provider_?.off("pending", callback);
2772
- previousProvider?.off("pending", callback);
2773
- };
2774
- }
2775
-
2776
- // src/actions/contracts/writeContract.ts
2777
- async function writeContract(config) {
2778
- const signer = await fetchSigner();
2779
- if (!signer)
2780
- throw new ConnectorNotFoundError();
2781
- if (config.chainId)
2782
- assertActiveChain({ chainId: config.chainId, signer });
2783
- let request;
2784
- if (config.mode === "prepared") {
2785
- request = config.request;
2786
- } else {
2787
- request = (await prepareWriteContract({
2788
- address: config.address,
2789
- args: config.args,
2790
- chainId: config.chainId,
2791
- abi: config.abi,
2792
- functionName: config.functionName,
2793
- overrides: config.overrides
2794
- })).request;
2795
- }
2796
- const transaction = await sendTransaction({
2797
- request,
2798
- mode: "prepared"
2799
- });
2800
- return transaction;
2801
- }
2802
-
2803
- // src/actions/accounts/fetchBalance.ts
2804
- async function fetchBalance({
2805
- address,
2806
- chainId,
2807
- formatUnits: unit,
2808
- token
2809
- }) {
2810
- const client2 = getClient();
2811
- const provider = getProvider({ chainId });
2812
- if (token) {
2813
- const fetchContractBalance = async ({ abi }) => {
2814
- const erc20Config = { abi, address: token, chainId };
2815
- const [value2, decimals, symbol] = await readContracts({
2816
- allowFailure: false,
2817
- contracts: [
2818
- {
2819
- ...erc20Config,
2820
- functionName: "balanceOf",
2821
- args: [address]
2822
- },
2823
- { ...erc20Config, functionName: "decimals" },
2824
- { ...erc20Config, functionName: "symbol" }
2825
- ]
2826
- });
2827
- return {
2828
- decimals,
2829
- formatted: formatUnits3(value2 ?? "0", unit ?? decimals),
2830
- symbol,
2831
- value: value2
2832
- };
2833
- };
2834
- try {
2835
- return await fetchContractBalance({ abi: erc20ABI });
2836
- } catch (err) {
2837
- if (err instanceof ContractResultDecodeError) {
2838
- const { symbol, ...rest } = await fetchContractBalance({
2839
- abi: erc20ABI_bytes32
2840
- });
2841
- return {
2842
- symbol: parseBytes32String2(symbol),
2843
- ...rest
2844
- };
2845
- }
2846
- throw err;
2847
- }
2848
- }
2849
- const chains = [...client2.provider.chains || [], ...client2.chains ?? []];
2850
- const value = await provider.getBalance(address);
2851
- const chain = chains.find((x) => x.id === provider.network.chainId);
2852
- return {
2853
- decimals: chain?.nativeCurrency.decimals ?? 18,
2854
- formatted: formatUnits3(value ?? "0", unit ?? "ether"),
2855
- symbol: chain?.nativeCurrency.symbol ?? "ETH",
2856
- value
2857
- };
2858
- }
2859
-
2860
- // src/actions/accounts/fetchSigner.ts
2861
- async function fetchSigner({
2862
- chainId
2863
- } = {}) {
2864
- const client2 = getClient();
2865
- const signer = await client2.connector?.getSigner?.({ chainId }) || null;
2866
- return signer;
2867
- }
2868
-
2869
- // src/actions/accounts/getAccount.ts
2870
- function getAccount() {
2871
- const { data, connector, status } = getClient();
2872
- switch (status) {
2873
- case "connected":
2874
- return {
2875
- address: data?.account,
2876
- connector,
2877
- isConnected: true,
2878
- isConnecting: false,
2879
- isDisconnected: false,
2880
- isReconnecting: false,
2881
- status
2882
- };
2883
- case "reconnecting":
2884
- return {
2885
- address: data?.account,
2886
- connector,
2887
- isConnected: !!data?.account,
2888
- isConnecting: false,
2889
- isDisconnected: false,
2890
- isReconnecting: true,
2891
- status
2892
- };
2893
- case "connecting":
2894
- return {
2895
- address: data?.account,
2896
- connector,
2897
- isConnected: false,
2898
- isConnecting: true,
2899
- isDisconnected: false,
2900
- isReconnecting: false,
2901
- status
2902
- };
2903
- case "disconnected":
2904
- return {
2905
- address: void 0,
2906
- connector: void 0,
2907
- isConnected: false,
2908
- isConnecting: false,
2909
- isDisconnected: true,
2910
- isReconnecting: false,
2911
- status
2912
- };
2913
- }
2914
- }
2915
-
2916
- // src/actions/accounts/getNetwork.ts
2917
- function getNetwork() {
2918
- const client2 = getClient();
2919
- const chainId = client2.data?.chain?.id;
2920
- const activeChains = client2.chains ?? [];
2921
- const activeChain = [...client2.provider.chains || [], ...activeChains].find(
2922
- (x) => x.id === chainId
2923
- ) ?? {
2924
- id: chainId,
2925
- name: `Chain ${chainId}`,
2926
- network: `${chainId}`,
2927
- nativeCurrency: { name: "Ether", decimals: 18, symbol: "ETH" },
2928
- rpcUrls: {
2929
- default: { http: [""] },
2930
- public: { http: [""] }
2931
- }
2932
- };
2933
- return {
2934
- chain: chainId ? {
2935
- ...activeChain,
2936
- ...client2.data?.chain,
2937
- id: chainId
2938
- } : void 0,
2939
- chains: activeChains
2940
- };
2941
- }
2942
-
2943
- // src/actions/accounts/signMessage.ts
2944
- async function signMessage(args) {
2945
- try {
2946
- const signer = await fetchSigner();
2947
- if (!signer)
2948
- throw new ConnectorNotFoundError();
2949
- return await signer.signMessage(
2950
- args.message
2951
- );
2952
- } catch (error) {
2953
- if (error.code === 4001 || error.code === "ACTION_REJECTED")
2954
- throw new UserRejectedRequestError(error);
2955
- throw error;
2956
- }
2957
- }
2958
-
2959
- // src/actions/accounts/signTypedData.ts
2960
- async function signTypedData({
2961
- domain,
2962
- types,
2963
- value
2964
- }) {
2965
- const signer = await fetchSigner();
2966
- if (!signer)
2967
- throw new ConnectorNotFoundError();
2968
- const { chainId: chainId_ } = domain;
2969
- const chainId = chainId_ ? normalizeChainId(chainId_) : void 0;
2970
- if (chainId)
2971
- assertActiveChain({ chainId, signer });
2972
- const types_ = Object.entries(types).filter(([key]) => key !== "EIP712Domain").reduce((types2, [key, attributes]) => {
2973
- types2[key] = attributes.filter((attr) => attr.type !== "EIP712Domain");
2974
- return types2;
2975
- }, {});
2976
- try {
2977
- return await signer._signTypedData(domain, types_, value);
2978
- } catch (error) {
2979
- if (error.code === 4001 || error.code === "ACTION_REJECTED")
2980
- throw new UserRejectedRequestError(error);
2981
- throw error;
2982
- }
2983
- }
2984
-
2985
- // src/actions/accounts/switchNetwork.ts
2986
- async function switchNetwork({
2987
- chainId
2988
- }) {
2989
- const { connector } = getClient();
2990
- if (!connector)
2991
- throw new ConnectorNotFoundError();
2992
- if (!connector.switchChain)
2993
- throw new SwitchChainNotSupportedError({
2994
- connector
2995
- });
2996
- return connector.switchChain(chainId);
2997
- }
2998
-
2999
- // src/actions/accounts/watchAccount.ts
3000
- import { shallow as shallow4 } from "zustand/shallow";
3001
- function watchAccount(callback, { selector = (x) => x } = {}) {
3002
- const client2 = getClient();
3003
- const handleChange = () => callback(getAccount());
3004
- const unsubscribe = client2.subscribe(
3005
- ({ data, connector, status }) => selector({
3006
- address: data?.account,
3007
- connector,
3008
- status
3009
- }),
3010
- handleChange,
3011
- {
3012
- equalityFn: shallow4
3013
- }
3014
- );
3015
- return unsubscribe;
3016
- }
3017
-
3018
- // src/actions/accounts/watchNetwork.ts
3019
- import { shallow as shallow5 } from "zustand/shallow";
3020
- function watchNetwork(callback, { selector = (x) => x } = {}) {
3021
- const client2 = getClient();
3022
- const handleChange = () => callback(getNetwork());
3023
- const unsubscribe = client2.subscribe(
3024
- ({ data, chains }) => selector({ chainId: data?.chain?.id, chains }),
3025
- handleChange,
3026
- {
3027
- equalityFn: shallow5
3028
- }
3029
- );
3030
- return unsubscribe;
3031
- }
3032
-
3033
- // src/actions/accounts/watchSigner.ts
3034
- import { shallow as shallow6 } from "zustand/shallow";
3035
- function watchSigner({ chainId }, callback) {
3036
- const client2 = getClient();
3037
- const handleChange = async () => {
3038
- const signer = await fetchSigner({ chainId });
3039
- if (!getClient().connector)
3040
- return callback(null);
3041
- return callback(signer);
3042
- };
3043
- const unsubscribe = client2.subscribe(
3044
- ({ data, connector }) => ({
3045
- account: data?.account,
3046
- chainId: data?.chain?.id,
3047
- connector
3048
- }),
3049
- handleChange,
3050
- {
3051
- equalityFn: shallow6
3052
- }
3053
- );
3054
- return unsubscribe;
3055
- }
3056
-
3057
- // src/errors.ts
3058
- var RpcError = class extends Error {
3059
- constructor(message, options) {
3060
- const { cause, code, data } = options;
3061
- if (!Number.isInteger(code))
3062
- throw new Error('"code" must be an integer.');
3063
- if (!message || typeof message !== "string")
3064
- throw new Error('"message" must be a nonempty string.');
3065
- super(message);
3066
- this.cause = cause;
3067
- this.code = code;
3068
- this.data = data;
3069
- }
3070
- };
3071
- var ProviderRpcError = class extends RpcError {
3072
- constructor(message, options) {
3073
- const { cause, code, data } = options;
3074
- if (!(Number.isInteger(code) && code >= 1e3 && code <= 4999))
3075
- throw new Error(
3076
- '"code" must be an integer such that: 1000 <= code <= 4999'
3077
- );
3078
- super(message, { cause, code, data });
3079
- }
3080
- };
3081
- var AddChainError = class extends Error {
3082
- constructor() {
3083
- super(...arguments);
3084
- this.name = "AddChainError";
3085
- this.message = "Error adding chain";
3086
- }
3087
- };
3088
- var ChainDoesNotSupportMulticallError = class extends Error {
3089
- constructor({ blockNumber, chain }) {
3090
- super(
3091
- `Chain "${chain.name}" does not support multicall${blockNumber ? ` on block ${blockNumber}` : ""}.`
3092
- );
3093
- this.name = "ChainDoesNotSupportMulticall";
3094
- }
3095
- };
3096
- var ChainMismatchError = class extends Error {
3097
- constructor({
3098
- activeChain,
3099
- targetChain
3100
- }) {
3101
- super(
3102
- `Chain mismatch: Expected "${targetChain}", received "${activeChain}".`
3103
- );
3104
- this.name = "ChainMismatchError";
3105
- }
3106
- };
3107
- var ChainNotConfiguredError = class extends Error {
3108
- constructor({
3109
- chainId,
3110
- connectorId
3111
- }) {
3112
- super(
3113
- `Chain "${chainId}" not configured${connectorId ? ` for connector "${connectorId}"` : ""}.`
3114
- );
3115
- this.name = "ChainNotConfigured";
3116
- }
3117
- };
3118
- var ConnectorAlreadyConnectedError = class extends Error {
3119
- constructor() {
3120
- super(...arguments);
3121
- this.name = "ConnectorAlreadyConnectedError";
3122
- this.message = "Connector already connected";
3123
- }
3124
- };
3125
- var ConnectorNotFoundError = class extends Error {
3126
- constructor() {
3127
- super(...arguments);
3128
- this.name = "ConnectorNotFoundError";
3129
- this.message = "Connector not found";
3130
- }
3131
- };
3132
- var ContractMethodDoesNotExistError = class extends Error {
3133
- constructor({
3134
- address,
3135
- chainId,
3136
- functionName
3137
- }) {
3138
- const { chains, network } = getProvider();
3139
- const chain = chains?.find(({ id }) => id === (chainId || network.chainId));
3140
- const blockExplorer = chain?.blockExplorers?.default;
3141
- super(
3142
- [
3143
- `Function "${functionName}" on contract "${address}" does not exist.`,
3144
- ...blockExplorer ? [
3145
- "",
3146
- `${blockExplorer?.name}: ${blockExplorer?.url}/address/${address}#readContract`
3147
- ] : []
3148
- ].join("\n")
3149
- );
3150
- this.name = "ContractMethodDoesNotExistError";
3151
- }
3152
- };
3153
- var ContractMethodNoResultError = class extends Error {
3154
- constructor({
3155
- address,
3156
- args,
3157
- chainId,
3158
- functionName
3159
- }) {
3160
- super(
3161
- [
3162
- "Contract read returned an empty response. This could be due to any of the following:",
3163
- `- The contract does not have the function "${functionName}",`,
3164
- "- The parameters passed to the contract function may be invalid, or",
3165
- "- The address is not a contract.",
3166
- "",
3167
- `Config:`,
3168
- JSON.stringify(
3169
- {
3170
- address,
3171
- abi: "...",
3172
- functionName,
3173
- chainId,
3174
- args
3175
- },
3176
- null,
3177
- 2
3178
- )
3179
- ].join("\n")
3180
- );
3181
- this.name = "ContractMethodNoResultError";
3182
- }
3183
- };
3184
- var ContractMethodRevertedError = class extends Error {
3185
- constructor({
3186
- address,
3187
- args,
3188
- chainId,
3189
- functionName,
3190
- errorMessage
3191
- }) {
3192
- super(
3193
- [
3194
- "Contract method reverted with an error.",
3195
- "",
3196
- `Config:`,
3197
- JSON.stringify(
3198
- {
3199
- address,
3200
- abi: "...",
3201
- functionName,
3202
- chainId,
3203
- args
3204
- },
3205
- null,
3206
- 2
3207
- ),
3208
- "",
3209
- `Details: ${errorMessage}`
3210
- ].join("\n")
3211
- );
3212
- this.name = "ContractMethodRevertedError";
3213
- }
3214
- };
3215
- var ContractResultDecodeError = class extends Error {
3216
- constructor({
3217
- address,
3218
- args,
3219
- chainId,
3220
- functionName,
3221
- errorMessage
3222
- }) {
3223
- super(
3224
- [
3225
- "Failed to decode contract function result.",
3226
- "",
3227
- `Config:`,
3228
- JSON.stringify(
3229
- {
3230
- address,
3231
- abi: "...",
3232
- functionName,
3233
- chainId,
3234
- args
3235
- },
3236
- null,
3237
- 2
3238
- ),
3239
- "",
3240
- `Details: ${errorMessage}`
3241
- ].join("\n")
3242
- );
3243
- this.name = "ContractResultDecodeError";
3244
- }
3245
- };
3246
- var ProviderChainsNotFound = class extends Error {
3247
- constructor() {
3248
- super(...arguments);
3249
- this.name = "ProviderChainsNotFound";
3250
- this.message = [
3251
- "No chains were found on the wagmi provider. Some functions that require a chain may not work.",
3252
- "",
3253
- "It is recommended to add a list of chains to the provider in `createClient`.",
3254
- "",
3255
- "Example:",
3256
- "",
3257
- "```",
3258
- "import { getDefaultProvider } from 'ethers'",
3259
- "import { chain, createClient } from 'wagmi'",
3260
- "",
3261
- "createClient({",
3262
- " provider: Object.assign(getDefaultProvider(), { chains: [chain.mainnet] })",
3263
- "})",
3264
- "```"
3265
- ].join("\n");
3266
- }
3267
- };
3268
- var ResourceUnavailableError = class extends RpcError {
3269
- constructor(cause) {
3270
- super("Resource unavailable", { cause, code: -32002 });
3271
- this.name = "ResourceUnavailable";
3272
- }
3273
- };
3274
- var SwitchChainError = class extends ProviderRpcError {
3275
- constructor(cause) {
3276
- super("Error switching chain", { cause, code: 4902 });
3277
- this.name = "SwitchChainError";
3278
- }
3279
- };
3280
- var SwitchChainNotSupportedError = class extends Error {
3281
- constructor({ connector }) {
3282
- super(`"${connector.name}" does not support programmatic chain switching.`);
3283
- this.name = "SwitchChainNotSupportedError";
3284
- }
3285
- };
3286
- var UserRejectedRequestError = class extends ProviderRpcError {
3287
- constructor(cause) {
3288
- super("User rejected request", { cause, code: 4001 });
3289
- this.name = "UserRejectedRequestError";
3290
- }
3291
- };
3292
-
3293
- export {
3294
- configureChains,
3295
- RpcError,
3296
- ProviderRpcError,
3297
- AddChainError,
3298
- ChainDoesNotSupportMulticallError,
3299
- ChainMismatchError,
3300
- ChainNotConfiguredError,
3301
- ConnectorAlreadyConnectedError,
3302
- ConnectorNotFoundError,
3303
- ContractMethodDoesNotExistError,
3304
- ContractMethodNoResultError,
3305
- ContractMethodRevertedError,
3306
- ContractResultDecodeError,
3307
- ProviderChainsNotFound,
3308
- ResourceUnavailableError,
3309
- SwitchChainError,
3310
- SwitchChainNotSupportedError,
3311
- UserRejectedRequestError,
3312
- debounce,
3313
- deepEqual,
3314
- deserialize,
3315
- minimizeContractInterface,
3316
- normalizeChainId,
3317
- parseContractResult,
3318
- serialize,
3319
- noopStorage,
3320
- createStorage,
3321
- Client,
3322
- createClient,
3323
- getClient,
3324
- connect,
3325
- disconnect,
3326
- erc20ABI,
3327
- erc721ABI,
3328
- erc4626ABI,
3329
- units,
3330
- fetchToken,
3331
- getContract,
3332
- prepareWriteContract,
3333
- getProvider,
3334
- getWebSocketProvider,
3335
- watchProvider,
3336
- watchWebSocketProvider,
3337
- multicall,
3338
- readContract,
3339
- readContracts,
3340
- watchContractEvent,
3341
- fetchBlockNumber,
3342
- watchBlockNumber,
3343
- watchMulticall,
3344
- watchReadContract,
3345
- watchReadContracts,
3346
- fetchTransaction,
3347
- fetchEnsAddress,
3348
- fetchEnsAvatar,
3349
- fetchEnsName,
3350
- fetchEnsResolver,
3351
- prepareSendTransaction,
3352
- sendTransaction,
3353
- fetchFeeData,
3354
- waitForTransaction,
3355
- watchPendingTransactions,
3356
- writeContract,
3357
- fetchBalance,
3358
- fetchSigner,
3359
- getAccount,
3360
- getNetwork,
3361
- signMessage,
3362
- signTypedData,
3363
- switchNetwork,
3364
- watchAccount,
3365
- watchNetwork,
3366
- watchSigner
3367
- };