wagmi 0.11.7-cjs → 0.11.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions.js +83 -83
- package/dist/chains.js +105 -105
- package/dist/connectors/coinbaseWallet.js +5 -5
- package/dist/connectors/index.js +5 -5
- package/dist/connectors/injected.js +5 -5
- package/dist/connectors/ledger.js +5 -5
- package/dist/connectors/metaMask.js +5 -5
- package/dist/connectors/mock.js +5 -5
- package/dist/connectors/safe.js +5 -5
- package/dist/connectors/walletConnect.js +5 -5
- package/dist/index.js +291 -291
- package/dist/providers/alchemy.js +5 -5
- package/dist/providers/infura.js +5 -5
- package/dist/providers/jsonRpc.js +5 -5
- package/dist/providers/public.js +5 -5
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
// src/client.ts
|
|
2
|
+
import { createSyncStoragePersister } from "@tanstack/query-sync-storage-persister";
|
|
3
|
+
import { QueryClient } from "@tanstack/react-query";
|
|
4
|
+
import { persistQueryClient } from "@tanstack/react-query-persist-client";
|
|
5
|
+
import {
|
|
6
|
+
createClient as createCoreClient,
|
|
7
|
+
createStorage,
|
|
8
|
+
noopStorage
|
|
9
|
+
} from "@wagmi/core";
|
|
10
10
|
function createClient({
|
|
11
|
-
queryClient = new
|
|
11
|
+
queryClient = new QueryClient({
|
|
12
12
|
defaultOptions: {
|
|
13
13
|
queries: {
|
|
14
14
|
cacheTime: 1e3 * 60 * 60 * 24,
|
|
@@ -21,10 +21,10 @@ function createClient({
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
}),
|
|
24
|
-
storage =
|
|
25
|
-
storage: typeof window !== "undefined" && window.localStorage ? window.localStorage :
|
|
24
|
+
storage = createStorage({
|
|
25
|
+
storage: typeof window !== "undefined" && window.localStorage ? window.localStorage : noopStorage
|
|
26
26
|
}),
|
|
27
|
-
persister = typeof window !== "undefined" ?
|
|
27
|
+
persister = typeof window !== "undefined" ? createSyncStoragePersister({
|
|
28
28
|
key: "cache",
|
|
29
29
|
storage,
|
|
30
30
|
serialize: (x) => x,
|
|
@@ -32,12 +32,12 @@ function createClient({
|
|
|
32
32
|
}) : void 0,
|
|
33
33
|
...config
|
|
34
34
|
}) {
|
|
35
|
-
const client =
|
|
35
|
+
const client = createCoreClient({
|
|
36
36
|
...config,
|
|
37
37
|
storage
|
|
38
38
|
});
|
|
39
39
|
if (persister)
|
|
40
|
-
|
|
40
|
+
persistQueryClient({
|
|
41
41
|
queryClient,
|
|
42
42
|
persister,
|
|
43
43
|
dehydrateOptions: {
|
|
@@ -48,8 +48,8 @@ function createClient({
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
// src/context.ts
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
import { QueryClientProvider } from "@tanstack/react-query";
|
|
52
|
+
import * as React from "react";
|
|
53
53
|
var Context = React.createContext(void 0);
|
|
54
54
|
var queryClientContext = React.createContext(
|
|
55
55
|
void 0
|
|
@@ -59,7 +59,7 @@ function WagmiConfig({
|
|
|
59
59
|
client
|
|
60
60
|
}) {
|
|
61
61
|
return React.createElement(Context.Provider, {
|
|
62
|
-
children: React.createElement(
|
|
62
|
+
children: React.createElement(QueryClientProvider, {
|
|
63
63
|
children,
|
|
64
64
|
client: client.queryClient,
|
|
65
65
|
context: queryClientContext
|
|
@@ -80,20 +80,20 @@ function useClient() {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
// src/hooks/accounts/useAccount.ts
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
import { getAccount, getClient } from "@wagmi/core";
|
|
84
|
+
import * as React7 from "react";
|
|
85
85
|
|
|
86
86
|
// src/hooks/utils/query/useBaseQuery.ts
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
87
|
+
import {
|
|
88
|
+
notifyManager,
|
|
89
|
+
useIsRestoring,
|
|
90
|
+
useQueryClient,
|
|
91
|
+
useQueryErrorResetBoundary
|
|
92
|
+
} from "@tanstack/react-query";
|
|
93
|
+
import * as React2 from "react";
|
|
94
94
|
|
|
95
95
|
// src/hooks/utils/useSyncExternalStore.ts
|
|
96
|
-
|
|
96
|
+
import * as pkg from "use-sync-external-store/shim/index.js";
|
|
97
97
|
var useSyncExternalStore2 = pkg.useSyncExternalStore;
|
|
98
98
|
|
|
99
99
|
// src/hooks/utils/query/utils.ts
|
|
@@ -132,23 +132,23 @@ function trackResult(result, observer) {
|
|
|
132
132
|
|
|
133
133
|
// src/hooks/utils/query/useBaseQuery.ts
|
|
134
134
|
function useBaseQuery(options, Observer) {
|
|
135
|
-
const queryClient =
|
|
136
|
-
const isRestoring =
|
|
137
|
-
const errorResetBoundary =
|
|
135
|
+
const queryClient = useQueryClient({ context: options.context });
|
|
136
|
+
const isRestoring = useIsRestoring();
|
|
137
|
+
const errorResetBoundary = useQueryErrorResetBoundary();
|
|
138
138
|
const defaultedOptions = queryClient.defaultQueryOptions(options);
|
|
139
139
|
defaultedOptions._optimisticResults = isRestoring ? "isRestoring" : "optimistic";
|
|
140
140
|
if (defaultedOptions.onError) {
|
|
141
|
-
defaultedOptions.onError =
|
|
141
|
+
defaultedOptions.onError = notifyManager.batchCalls(
|
|
142
142
|
defaultedOptions.onError
|
|
143
143
|
);
|
|
144
144
|
}
|
|
145
145
|
if (defaultedOptions.onSuccess) {
|
|
146
|
-
defaultedOptions.onSuccess =
|
|
146
|
+
defaultedOptions.onSuccess = notifyManager.batchCalls(
|
|
147
147
|
defaultedOptions.onSuccess
|
|
148
148
|
);
|
|
149
149
|
}
|
|
150
150
|
if (defaultedOptions.onSettled) {
|
|
151
|
-
defaultedOptions.onSettled =
|
|
151
|
+
defaultedOptions.onSettled = notifyManager.batchCalls(
|
|
152
152
|
defaultedOptions.onSettled
|
|
153
153
|
);
|
|
154
154
|
}
|
|
@@ -171,7 +171,7 @@ function useBaseQuery(options, Observer) {
|
|
|
171
171
|
const result = observer.getOptimisticResult(defaultedOptions);
|
|
172
172
|
useSyncExternalStore2(
|
|
173
173
|
React2.useCallback(
|
|
174
|
-
(onStoreChange) => isRestoring ? () => void 0 : observer.subscribe(
|
|
174
|
+
(onStoreChange) => isRestoring ? () => void 0 : observer.subscribe(notifyManager.batchCalls(onStoreChange)),
|
|
175
175
|
[observer, isRestoring]
|
|
176
176
|
),
|
|
177
177
|
() => observer.getCurrentResult(),
|
|
@@ -185,12 +185,12 @@ function useBaseQuery(options, Observer) {
|
|
|
185
185
|
}, [defaultedOptions, observer]);
|
|
186
186
|
if (defaultedOptions.suspense && result.isLoading && result.isFetching && !isRestoring) {
|
|
187
187
|
throw observer.fetchOptimistic(defaultedOptions).then(({ data }) => {
|
|
188
|
-
|
|
189
|
-
|
|
188
|
+
defaultedOptions.onSuccess?.(data);
|
|
189
|
+
defaultedOptions.onSettled?.(data, null);
|
|
190
190
|
}).catch((error) => {
|
|
191
191
|
errorResetBoundary.clearReset();
|
|
192
|
-
|
|
193
|
-
|
|
192
|
+
defaultedOptions.onError?.(error);
|
|
193
|
+
defaultedOptions.onSettled?.(void 0, error);
|
|
194
194
|
});
|
|
195
195
|
}
|
|
196
196
|
if (result.isError && !errorResetBoundary.isReset() && !result.isFetching && shouldThrowError(defaultedOptions.useErrorBoundary, [
|
|
@@ -213,12 +213,12 @@ function useBaseQuery(options, Observer) {
|
|
|
213
213
|
}
|
|
214
214
|
|
|
215
215
|
// src/hooks/utils/query/useInfiniteQuery.ts
|
|
216
|
-
|
|
216
|
+
import { InfiniteQueryObserver } from "@tanstack/react-query";
|
|
217
217
|
function useInfiniteQuery(arg1, arg2, arg3) {
|
|
218
218
|
const parsedOptions = parseQueryArgs(arg1, arg2, arg3);
|
|
219
219
|
const baseQuery = useBaseQuery(
|
|
220
220
|
{ context: queryClientContext, ...parsedOptions },
|
|
221
|
-
|
|
221
|
+
InfiniteQueryObserver
|
|
222
222
|
);
|
|
223
223
|
const result = {
|
|
224
224
|
data: baseQuery.data,
|
|
@@ -255,20 +255,20 @@ function useInfiniteQuery(arg1, arg2, arg3) {
|
|
|
255
255
|
}
|
|
256
256
|
|
|
257
257
|
// src/hooks/utils/query/useMutation.ts
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
258
|
+
import {
|
|
259
|
+
parseMutationArgs,
|
|
260
|
+
useMutation as useMutation_
|
|
261
|
+
} from "@tanstack/react-query";
|
|
262
262
|
function useMutation(arg1, arg2, arg3) {
|
|
263
|
-
const options =
|
|
264
|
-
return
|
|
263
|
+
const options = parseMutationArgs(arg1, arg2, arg3);
|
|
264
|
+
return useMutation_({ context: queryClientContext, ...options });
|
|
265
265
|
}
|
|
266
266
|
|
|
267
267
|
// src/hooks/utils/query/useQuery.ts
|
|
268
|
-
|
|
268
|
+
import { QueryObserver } from "@tanstack/react-query";
|
|
269
269
|
function useQuery(arg1, arg2, arg3) {
|
|
270
270
|
const parsedOptions = parseQueryArgs(arg1, arg2, arg3);
|
|
271
|
-
const baseQuery = useBaseQuery({ context: queryClientContext, ...parsedOptions },
|
|
271
|
+
const baseQuery = useBaseQuery({ context: queryClientContext, ...parsedOptions }, QueryObserver);
|
|
272
272
|
const result = {
|
|
273
273
|
data: baseQuery.data,
|
|
274
274
|
error: baseQuery.error,
|
|
@@ -301,34 +301,34 @@ function useQuery(arg1, arg2, arg3) {
|
|
|
301
301
|
}
|
|
302
302
|
|
|
303
303
|
// src/hooks/utils/query/useQueryClient.ts
|
|
304
|
-
|
|
305
|
-
var useQueryClient2 = () =>
|
|
304
|
+
import { useQueryClient as useQueryClient_ } from "@tanstack/react-query";
|
|
305
|
+
var useQueryClient2 = () => useQueryClient_({ context: queryClientContext });
|
|
306
306
|
|
|
307
307
|
// src/hooks/providers/useProvider.ts
|
|
308
|
-
|
|
309
|
-
|
|
308
|
+
import { getProvider, watchProvider } from "@wagmi/core";
|
|
309
|
+
import { useSyncExternalStoreWithSelector } from "use-sync-external-store/shim/with-selector.js";
|
|
310
310
|
function useProvider({
|
|
311
311
|
chainId
|
|
312
312
|
} = {}) {
|
|
313
|
-
return
|
|
314
|
-
(cb) =>
|
|
315
|
-
() =>
|
|
316
|
-
() =>
|
|
313
|
+
return useSyncExternalStoreWithSelector(
|
|
314
|
+
(cb) => watchProvider({ chainId }, cb),
|
|
315
|
+
() => getProvider({ chainId }),
|
|
316
|
+
() => getProvider({ chainId }),
|
|
317
317
|
(x) => x,
|
|
318
318
|
(a, b) => a.network.chainId === b.network.chainId
|
|
319
319
|
);
|
|
320
320
|
}
|
|
321
321
|
|
|
322
322
|
// src/hooks/providers/useWebSocketProvider.ts
|
|
323
|
-
|
|
324
|
-
|
|
323
|
+
import { getWebSocketProvider, watchWebSocketProvider } from "@wagmi/core";
|
|
324
|
+
import { useSyncExternalStoreWithSelector as useSyncExternalStoreWithSelector2 } from "use-sync-external-store/shim/with-selector.js";
|
|
325
325
|
function useWebSocketProvider({ chainId } = {}) {
|
|
326
|
-
return
|
|
327
|
-
(cb) =>
|
|
328
|
-
() =>
|
|
329
|
-
() =>
|
|
326
|
+
return useSyncExternalStoreWithSelector2(
|
|
327
|
+
(cb) => watchWebSocketProvider({ chainId }, cb),
|
|
328
|
+
() => getWebSocketProvider({ chainId }),
|
|
329
|
+
() => getWebSocketProvider({ chainId }),
|
|
330
330
|
(x) => x,
|
|
331
|
-
(a, b) =>
|
|
331
|
+
(a, b) => a?.network.chainId === b?.network.chainId
|
|
332
332
|
);
|
|
333
333
|
}
|
|
334
334
|
|
|
@@ -339,23 +339,23 @@ function useChainId({ chainId } = {}) {
|
|
|
339
339
|
}
|
|
340
340
|
|
|
341
341
|
// src/hooks/utils/useForceUpdate.ts
|
|
342
|
-
|
|
342
|
+
import * as React3 from "react";
|
|
343
343
|
function useForceUpdate() {
|
|
344
344
|
const [, forceUpdate] = React3.useReducer((x) => x + 1, 0);
|
|
345
345
|
return forceUpdate;
|
|
346
346
|
}
|
|
347
347
|
|
|
348
348
|
// src/hooks/network-status/useBlockNumber.ts
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
349
|
+
import { fetchBlockNumber } from "@wagmi/core";
|
|
350
|
+
import { debounce } from "@wagmi/core/internal";
|
|
351
|
+
import * as React4 from "react";
|
|
352
352
|
function queryKey({ chainId, scopeKey }) {
|
|
353
353
|
return [{ entity: "blockNumber", chainId, scopeKey }];
|
|
354
354
|
}
|
|
355
355
|
function queryFn({
|
|
356
356
|
queryKey: [{ chainId }]
|
|
357
357
|
}) {
|
|
358
|
-
return
|
|
358
|
+
return fetchBlockNumber({ chainId });
|
|
359
359
|
}
|
|
360
360
|
function useBlockNumber({
|
|
361
361
|
cacheTime = 0,
|
|
@@ -379,13 +379,13 @@ function useBlockNumber({
|
|
|
379
379
|
return;
|
|
380
380
|
if (!watch && !onBlock)
|
|
381
381
|
return;
|
|
382
|
-
const listener =
|
|
382
|
+
const listener = debounce((blockNumber) => {
|
|
383
383
|
if (watch)
|
|
384
384
|
queryClient.setQueryData(queryKey({ chainId, scopeKey }), blockNumber);
|
|
385
385
|
if (onBlock)
|
|
386
386
|
onBlock(blockNumber);
|
|
387
387
|
}, 1);
|
|
388
|
-
const provider_ =
|
|
388
|
+
const provider_ = webSocketProvider ?? provider;
|
|
389
389
|
provider_.on("block", listener);
|
|
390
390
|
return () => {
|
|
391
391
|
provider_.off("block", listener);
|
|
@@ -412,8 +412,8 @@ function useBlockNumber({
|
|
|
412
412
|
}
|
|
413
413
|
|
|
414
414
|
// src/hooks/network-status/useFeeData.ts
|
|
415
|
-
|
|
416
|
-
|
|
415
|
+
import { fetchFeeData } from "@wagmi/core";
|
|
416
|
+
import * as React5 from "react";
|
|
417
417
|
function queryKey2({
|
|
418
418
|
chainId,
|
|
419
419
|
formatUnits,
|
|
@@ -424,7 +424,7 @@ function queryKey2({
|
|
|
424
424
|
function queryFn2({
|
|
425
425
|
queryKey: [{ chainId, formatUnits }]
|
|
426
426
|
}) {
|
|
427
|
-
return
|
|
427
|
+
return fetchFeeData({ chainId, formatUnits });
|
|
428
428
|
}
|
|
429
429
|
function useFeeData({
|
|
430
430
|
cacheTime,
|
|
@@ -481,13 +481,13 @@ function useInvalidateOnBlock({
|
|
|
481
481
|
}
|
|
482
482
|
|
|
483
483
|
// src/hooks/utils/useSyncExternalStoreWithTracked.ts
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
484
|
+
import { deepEqual } from "@wagmi/core";
|
|
485
|
+
import * as React6 from "react";
|
|
486
|
+
import { useSyncExternalStoreWithSelector as useSyncExternalStoreWithSelector3 } from "use-sync-external-store/shim/with-selector.js";
|
|
487
487
|
var isPlainObject = (obj) => typeof obj === "object" && !Array.isArray(obj);
|
|
488
|
-
function useSyncExternalStoreWithTracked(subscribe, getSnapshot, getServerSnapshot = getSnapshot, isEqual =
|
|
488
|
+
function useSyncExternalStoreWithTracked(subscribe, getSnapshot, getServerSnapshot = getSnapshot, isEqual = deepEqual) {
|
|
489
489
|
const trackedKeys = React6.useRef([]);
|
|
490
|
-
const result =
|
|
490
|
+
const result = useSyncExternalStoreWithSelector3(
|
|
491
491
|
subscribe,
|
|
492
492
|
getSnapshot,
|
|
493
493
|
getServerSnapshot,
|
|
@@ -539,10 +539,10 @@ function useSyncExternalStoreWithTracked(subscribe, getSnapshot, getServerSnapsh
|
|
|
539
539
|
function useAccount({ onConnect, onDisconnect } = {}) {
|
|
540
540
|
const watchAccount = React7.useCallback(
|
|
541
541
|
(callback) => {
|
|
542
|
-
const client =
|
|
542
|
+
const client = getClient();
|
|
543
543
|
const unsubscribe = client.subscribe(
|
|
544
544
|
(state) => ({
|
|
545
|
-
address:
|
|
545
|
+
address: state.data?.account,
|
|
546
546
|
connector: state.connector,
|
|
547
547
|
status: state.status
|
|
548
548
|
}),
|
|
@@ -555,14 +555,14 @@ function useAccount({ onConnect, onDisconnect } = {}) {
|
|
|
555
555
|
});
|
|
556
556
|
if (!!onDisconnect && prev.status === "connected" && curr.status === "disconnected")
|
|
557
557
|
onDisconnect();
|
|
558
|
-
return callback(
|
|
558
|
+
return callback(getAccount());
|
|
559
559
|
}
|
|
560
560
|
);
|
|
561
561
|
return unsubscribe;
|
|
562
562
|
},
|
|
563
563
|
[onConnect, onDisconnect]
|
|
564
564
|
);
|
|
565
|
-
const account = useSyncExternalStoreWithTracked(watchAccount,
|
|
565
|
+
const account = useSyncExternalStoreWithTracked(watchAccount, getAccount);
|
|
566
566
|
const previousStatusRef = React7.useRef();
|
|
567
567
|
const { address, connector, status } = account;
|
|
568
568
|
React7.useEffect(() => {
|
|
@@ -574,8 +574,8 @@ function useAccount({ onConnect, onDisconnect } = {}) {
|
|
|
574
574
|
}
|
|
575
575
|
|
|
576
576
|
// src/hooks/accounts/useBalance.ts
|
|
577
|
-
|
|
578
|
-
|
|
577
|
+
import { fetchBalance } from "@wagmi/core";
|
|
578
|
+
import * as React8 from "react";
|
|
579
579
|
function queryKey3({
|
|
580
580
|
address,
|
|
581
581
|
chainId,
|
|
@@ -599,7 +599,7 @@ function queryFn3({
|
|
|
599
599
|
}) {
|
|
600
600
|
if (!address)
|
|
601
601
|
throw new Error("address is required");
|
|
602
|
-
return
|
|
602
|
+
return fetchBalance({ address, chainId, formatUnits, token });
|
|
603
603
|
}
|
|
604
604
|
function useBalance({
|
|
605
605
|
address,
|
|
@@ -639,14 +639,14 @@ function useBalance({
|
|
|
639
639
|
}
|
|
640
640
|
|
|
641
641
|
// src/hooks/accounts/useConnect.ts
|
|
642
|
-
|
|
643
|
-
|
|
642
|
+
import { connect } from "@wagmi/core";
|
|
643
|
+
import * as React9 from "react";
|
|
644
644
|
var mutationKey = (args) => [{ entity: "connect", ...args }];
|
|
645
645
|
var mutationFn = (args) => {
|
|
646
646
|
const { connector, chainId } = args;
|
|
647
647
|
if (!connector)
|
|
648
648
|
throw new Error("connector is required");
|
|
649
|
-
return
|
|
649
|
+
return connect({ connector, chainId });
|
|
650
650
|
};
|
|
651
651
|
function useConnect({
|
|
652
652
|
chainId,
|
|
@@ -678,8 +678,8 @@ function useConnect({
|
|
|
678
678
|
const connect2 = React9.useCallback(
|
|
679
679
|
(args) => {
|
|
680
680
|
return mutate({
|
|
681
|
-
chainId:
|
|
682
|
-
connector:
|
|
681
|
+
chainId: args?.chainId ?? chainId,
|
|
682
|
+
connector: args?.connector ?? connector
|
|
683
683
|
});
|
|
684
684
|
},
|
|
685
685
|
[chainId, connector, mutate]
|
|
@@ -687,8 +687,8 @@ function useConnect({
|
|
|
687
687
|
const connectAsync = React9.useCallback(
|
|
688
688
|
(args) => {
|
|
689
689
|
return mutateAsync({
|
|
690
|
-
chainId:
|
|
691
|
-
connector:
|
|
690
|
+
chainId: args?.chainId ?? chainId,
|
|
691
|
+
connector: args?.connector ?? connector
|
|
692
692
|
});
|
|
693
693
|
},
|
|
694
694
|
[chainId, connector, mutateAsync]
|
|
@@ -703,7 +703,7 @@ function useConnect({
|
|
|
703
703
|
isIdle,
|
|
704
704
|
isLoading,
|
|
705
705
|
isSuccess,
|
|
706
|
-
pendingConnector:
|
|
706
|
+
pendingConnector: variables?.connector,
|
|
707
707
|
reset,
|
|
708
708
|
status,
|
|
709
709
|
variables
|
|
@@ -711,9 +711,9 @@ function useConnect({
|
|
|
711
711
|
}
|
|
712
712
|
|
|
713
713
|
// src/hooks/accounts/useDisconnect.ts
|
|
714
|
-
|
|
714
|
+
import { disconnect } from "@wagmi/core";
|
|
715
715
|
var mutationKey2 = [{ entity: "disconnect" }];
|
|
716
|
-
var mutationFn2 = () =>
|
|
716
|
+
var mutationFn2 = () => disconnect();
|
|
717
717
|
function useDisconnect({
|
|
718
718
|
onError,
|
|
719
719
|
onMutate,
|
|
@@ -762,21 +762,21 @@ function useDisconnect({
|
|
|
762
762
|
}
|
|
763
763
|
|
|
764
764
|
// src/hooks/accounts/useNetwork.ts
|
|
765
|
-
|
|
765
|
+
import { getNetwork, watchNetwork } from "@wagmi/core";
|
|
766
766
|
function useNetwork() {
|
|
767
|
-
return useSyncExternalStoreWithTracked(
|
|
767
|
+
return useSyncExternalStoreWithTracked(watchNetwork, getNetwork);
|
|
768
768
|
}
|
|
769
769
|
|
|
770
770
|
// src/hooks/accounts/useSigner.ts
|
|
771
|
-
|
|
772
|
-
|
|
771
|
+
import { fetchSigner, watchSigner } from "@wagmi/core";
|
|
772
|
+
import * as React10 from "react";
|
|
773
773
|
function queryKey4({ chainId }) {
|
|
774
774
|
return [{ entity: "signer", chainId, persist: false }];
|
|
775
775
|
}
|
|
776
776
|
function queryFn4({
|
|
777
777
|
queryKey: [{ chainId }]
|
|
778
778
|
}) {
|
|
779
|
-
return
|
|
779
|
+
return fetchSigner({ chainId });
|
|
780
780
|
}
|
|
781
781
|
function useSigner({
|
|
782
782
|
chainId: chainId_,
|
|
@@ -798,7 +798,7 @@ function useSigner({
|
|
|
798
798
|
});
|
|
799
799
|
const queryClient = useQueryClient2();
|
|
800
800
|
React10.useEffect(() => {
|
|
801
|
-
const unwatch =
|
|
801
|
+
const unwatch = watchSigner({ chainId }, (signer) => {
|
|
802
802
|
if (signer)
|
|
803
803
|
queryClient.invalidateQueries(queryKey4({ chainId }));
|
|
804
804
|
else
|
|
@@ -810,14 +810,14 @@ function useSigner({
|
|
|
810
810
|
}
|
|
811
811
|
|
|
812
812
|
// src/hooks/accounts/useSignMessage.ts
|
|
813
|
-
|
|
814
|
-
|
|
813
|
+
import { signMessage } from "@wagmi/core";
|
|
814
|
+
import * as React11 from "react";
|
|
815
815
|
var mutationKey3 = (args) => [{ entity: "signMessage", ...args }];
|
|
816
816
|
var mutationFn3 = (args) => {
|
|
817
817
|
const { message } = args;
|
|
818
818
|
if (!message)
|
|
819
819
|
throw new Error("message is required");
|
|
820
|
-
return
|
|
820
|
+
return signMessage({ message });
|
|
821
821
|
};
|
|
822
822
|
function useSignMessage({
|
|
823
823
|
message,
|
|
@@ -868,8 +868,8 @@ function useSignMessage({
|
|
|
868
868
|
}
|
|
869
869
|
|
|
870
870
|
// src/hooks/accounts/useSignTypedData.ts
|
|
871
|
-
|
|
872
|
-
|
|
871
|
+
import { signTypedData } from "@wagmi/core";
|
|
872
|
+
import * as React12 from "react";
|
|
873
873
|
function mutationKey4({ domain, types, value }) {
|
|
874
874
|
return [{ entity: "signTypedData", domain, types, value }];
|
|
875
875
|
}
|
|
@@ -881,7 +881,7 @@ function mutationFn4(args) {
|
|
|
881
881
|
throw new Error("types is required");
|
|
882
882
|
if (!value)
|
|
883
883
|
throw new Error("value is required");
|
|
884
|
-
return
|
|
884
|
+
return signTypedData({
|
|
885
885
|
domain,
|
|
886
886
|
types,
|
|
887
887
|
value
|
|
@@ -924,17 +924,17 @@ function useSignTypedData({
|
|
|
924
924
|
);
|
|
925
925
|
const signTypedData2 = React12.useCallback(
|
|
926
926
|
(args) => mutate({
|
|
927
|
-
domain:
|
|
928
|
-
types:
|
|
929
|
-
value:
|
|
927
|
+
domain: args?.domain ?? domain,
|
|
928
|
+
types: args?.types ?? types,
|
|
929
|
+
value: args?.value ?? value
|
|
930
930
|
}),
|
|
931
931
|
[domain, types, value, mutate]
|
|
932
932
|
);
|
|
933
933
|
const signTypedDataAsync = React12.useCallback(
|
|
934
934
|
(args) => mutateAsync({
|
|
935
|
-
domain:
|
|
936
|
-
types:
|
|
937
|
-
value:
|
|
935
|
+
domain: args?.domain ?? domain,
|
|
936
|
+
types: args?.types ?? types,
|
|
937
|
+
value: args?.value ?? value
|
|
938
938
|
}),
|
|
939
939
|
[domain, types, value, mutateAsync]
|
|
940
940
|
);
|
|
@@ -954,14 +954,14 @@ function useSignTypedData({
|
|
|
954
954
|
}
|
|
955
955
|
|
|
956
956
|
// src/hooks/accounts/useSwitchNetwork.ts
|
|
957
|
-
|
|
958
|
-
|
|
957
|
+
import { switchNetwork } from "@wagmi/core";
|
|
958
|
+
import * as React13 from "react";
|
|
959
959
|
var mutationKey5 = (args) => [{ entity: "switchNetwork", ...args }];
|
|
960
960
|
var mutationFn5 = (args) => {
|
|
961
961
|
const { chainId } = args;
|
|
962
962
|
if (!chainId)
|
|
963
963
|
throw new Error("chainId is required");
|
|
964
|
-
return
|
|
964
|
+
return switchNetwork({ chainId });
|
|
965
965
|
};
|
|
966
966
|
function useSwitchNetwork({
|
|
967
967
|
chainId,
|
|
@@ -992,11 +992,11 @@ function useSwitchNetwork({
|
|
|
992
992
|
onSuccess
|
|
993
993
|
});
|
|
994
994
|
const switchNetwork_ = React13.useCallback(
|
|
995
|
-
(chainId_) => mutate({ chainId:
|
|
995
|
+
(chainId_) => mutate({ chainId: chainId_ ?? chainId }),
|
|
996
996
|
[chainId, mutate]
|
|
997
997
|
);
|
|
998
998
|
const switchNetworkAsync_ = React13.useCallback(
|
|
999
|
-
(chainId_) => mutateAsync({ chainId:
|
|
999
|
+
(chainId_) => mutateAsync({ chainId: chainId_ ?? chainId }),
|
|
1000
1000
|
[chainId, mutateAsync]
|
|
1001
1001
|
);
|
|
1002
1002
|
React13.useEffect(() => {
|
|
@@ -1011,20 +1011,20 @@ function useSwitchNetwork({
|
|
|
1011
1011
|
}, [client, forceUpdate]);
|
|
1012
1012
|
let switchNetwork2;
|
|
1013
1013
|
let switchNetworkAsync;
|
|
1014
|
-
const supportsSwitchChain = !!
|
|
1014
|
+
const supportsSwitchChain = !!client.connector?.switchChain;
|
|
1015
1015
|
if (throwForSwitchChainNotSupported || supportsSwitchChain) {
|
|
1016
1016
|
switchNetwork2 = switchNetwork_;
|
|
1017
1017
|
switchNetworkAsync = switchNetworkAsync_;
|
|
1018
1018
|
}
|
|
1019
1019
|
return {
|
|
1020
|
-
chains:
|
|
1020
|
+
chains: client.chains ?? [],
|
|
1021
1021
|
data,
|
|
1022
1022
|
error,
|
|
1023
1023
|
isError,
|
|
1024
1024
|
isIdle,
|
|
1025
1025
|
isLoading,
|
|
1026
1026
|
isSuccess,
|
|
1027
|
-
pendingChainId:
|
|
1027
|
+
pendingChainId: variables?.chainId,
|
|
1028
1028
|
reset,
|
|
1029
1029
|
status,
|
|
1030
1030
|
switchNetwork: switchNetwork2,
|
|
@@ -1034,8 +1034,8 @@ function useSwitchNetwork({
|
|
|
1034
1034
|
}
|
|
1035
1035
|
|
|
1036
1036
|
// src/hooks/contracts/useContract.ts
|
|
1037
|
-
|
|
1038
|
-
|
|
1037
|
+
import { getContract } from "@wagmi/core";
|
|
1038
|
+
import * as React14 from "react";
|
|
1039
1039
|
function useContract({
|
|
1040
1040
|
address,
|
|
1041
1041
|
abi,
|
|
@@ -1044,7 +1044,7 @@ function useContract({
|
|
|
1044
1044
|
return React14.useMemo(() => {
|
|
1045
1045
|
if (!address || !abi)
|
|
1046
1046
|
return null;
|
|
1047
|
-
return
|
|
1047
|
+
return getContract({
|
|
1048
1048
|
address,
|
|
1049
1049
|
abi,
|
|
1050
1050
|
signerOrProvider: signerOrProvider === null ? void 0 : signerOrProvider
|
|
@@ -1053,7 +1053,7 @@ function useContract({
|
|
|
1053
1053
|
}
|
|
1054
1054
|
|
|
1055
1055
|
// src/hooks/contracts/useContractEvent.ts
|
|
1056
|
-
|
|
1056
|
+
import * as React15 from "react";
|
|
1057
1057
|
function useContractEvent({
|
|
1058
1058
|
address,
|
|
1059
1059
|
chainId,
|
|
@@ -1067,7 +1067,7 @@ function useContractEvent({
|
|
|
1067
1067
|
const contract = useContract({
|
|
1068
1068
|
address,
|
|
1069
1069
|
abi,
|
|
1070
|
-
signerOrProvider:
|
|
1070
|
+
signerOrProvider: webSocketProvider ?? provider
|
|
1071
1071
|
});
|
|
1072
1072
|
const callbackRef = React15.useRef(listener);
|
|
1073
1073
|
callbackRef.current = listener;
|
|
@@ -1086,9 +1086,9 @@ function useContractEvent({
|
|
|
1086
1086
|
}
|
|
1087
1087
|
|
|
1088
1088
|
// src/hooks/contracts/useContractInfiniteReads.ts
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1089
|
+
import { replaceEqualDeep } from "@tanstack/react-query";
|
|
1090
|
+
import { deepEqual as deepEqual2, readContracts } from "@wagmi/core";
|
|
1091
|
+
import * as React16 from "react";
|
|
1092
1092
|
function queryKey5({
|
|
1093
1093
|
allowFailure,
|
|
1094
1094
|
cacheKey,
|
|
@@ -1112,7 +1112,7 @@ function queryFn5({
|
|
|
1112
1112
|
queryKey: [{ allowFailure, overrides }],
|
|
1113
1113
|
pageParam
|
|
1114
1114
|
}) => {
|
|
1115
|
-
return
|
|
1115
|
+
return readContracts({
|
|
1116
1116
|
allowFailure,
|
|
1117
1117
|
contracts: contracts(pageParam || void 0),
|
|
1118
1118
|
overrides
|
|
@@ -1135,7 +1135,7 @@ function useContractInfiniteReads({
|
|
|
1135
1135
|
scopeKey,
|
|
1136
1136
|
select,
|
|
1137
1137
|
staleTime,
|
|
1138
|
-
structuralSharing = (oldData, newData) =>
|
|
1138
|
+
structuralSharing = (oldData, newData) => deepEqual2(oldData, newData) ? oldData : replaceEqualDeep(oldData, newData),
|
|
1139
1139
|
suspense
|
|
1140
1140
|
}) {
|
|
1141
1141
|
const queryKey_ = React16.useMemo(
|
|
@@ -1172,15 +1172,15 @@ function paginatedIndexesConfig(fn, {
|
|
|
1172
1172
|
return {
|
|
1173
1173
|
contracts,
|
|
1174
1174
|
getNextPageParam(lastPage, pages) {
|
|
1175
|
-
return
|
|
1175
|
+
return lastPage?.length === perPage ? pages.length : void 0;
|
|
1176
1176
|
}
|
|
1177
1177
|
};
|
|
1178
1178
|
}
|
|
1179
1179
|
|
|
1180
1180
|
// src/hooks/contracts/useContractRead.ts
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1181
|
+
import { replaceEqualDeep as replaceEqualDeep2 } from "@tanstack/react-query";
|
|
1182
|
+
import { deepEqual as deepEqual3, parseContractResult, readContract } from "@wagmi/core";
|
|
1183
|
+
import * as React17 from "react";
|
|
1184
1184
|
function queryKey6({
|
|
1185
1185
|
address,
|
|
1186
1186
|
args,
|
|
@@ -1211,14 +1211,14 @@ function queryFn6({ abi }) {
|
|
|
1211
1211
|
throw new Error("abi is required");
|
|
1212
1212
|
if (!address)
|
|
1213
1213
|
throw new Error("address is required");
|
|
1214
|
-
return await
|
|
1214
|
+
return await readContract({
|
|
1215
1215
|
address,
|
|
1216
1216
|
args,
|
|
1217
1217
|
chainId,
|
|
1218
1218
|
abi,
|
|
1219
1219
|
functionName,
|
|
1220
1220
|
overrides
|
|
1221
|
-
})
|
|
1221
|
+
}) ?? null;
|
|
1222
1222
|
};
|
|
1223
1223
|
}
|
|
1224
1224
|
function useContractRead({
|
|
@@ -1238,7 +1238,7 @@ function useContractRead({
|
|
|
1238
1238
|
scopeKey,
|
|
1239
1239
|
select,
|
|
1240
1240
|
staleTime,
|
|
1241
|
-
structuralSharing = (oldData, newData) =>
|
|
1241
|
+
structuralSharing = (oldData, newData) => deepEqual3(oldData, newData) ? oldData : replaceEqualDeep2(oldData, newData),
|
|
1242
1242
|
suspense,
|
|
1243
1243
|
watch
|
|
1244
1244
|
} = {}) {
|
|
@@ -1291,7 +1291,7 @@ function useContractRead({
|
|
|
1291
1291
|
enabled,
|
|
1292
1292
|
isDataEqual,
|
|
1293
1293
|
select(data) {
|
|
1294
|
-
const result = abi && functionName ?
|
|
1294
|
+
const result = abi && functionName ? parseContractResult({
|
|
1295
1295
|
abi,
|
|
1296
1296
|
data,
|
|
1297
1297
|
functionName
|
|
@@ -1309,9 +1309,9 @@ function useContractRead({
|
|
|
1309
1309
|
}
|
|
1310
1310
|
|
|
1311
1311
|
// src/hooks/contracts/useContractReads.ts
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1312
|
+
import { replaceEqualDeep as replaceEqualDeep3 } from "@tanstack/react-query";
|
|
1313
|
+
import { deepEqual as deepEqual4, parseContractResult as parseContractResult2, readContracts as readContracts2 } from "@wagmi/core";
|
|
1314
|
+
import * as React18 from "react";
|
|
1315
1315
|
function queryKey7({
|
|
1316
1316
|
allowFailure,
|
|
1317
1317
|
blockNumber,
|
|
@@ -1327,7 +1327,7 @@ function queryKey7({
|
|
|
1327
1327
|
blockNumber,
|
|
1328
1328
|
chainId,
|
|
1329
1329
|
scopeKey,
|
|
1330
|
-
contracts: (
|
|
1330
|
+
contracts: (contracts ?? []).map(
|
|
1331
1331
|
({ address, args, chainId: chainId2, functionName }) => ({
|
|
1332
1332
|
address,
|
|
1333
1333
|
args,
|
|
@@ -1349,7 +1349,7 @@ function queryFn7({ abis }) {
|
|
|
1349
1349
|
abi: abis[i]
|
|
1350
1350
|
})
|
|
1351
1351
|
);
|
|
1352
|
-
return
|
|
1352
|
+
return readContracts2({
|
|
1353
1353
|
allowFailure,
|
|
1354
1354
|
contracts,
|
|
1355
1355
|
overrides
|
|
@@ -1371,7 +1371,7 @@ function useContractReads({
|
|
|
1371
1371
|
scopeKey,
|
|
1372
1372
|
select,
|
|
1373
1373
|
staleTime,
|
|
1374
|
-
structuralSharing = (oldData, newData) =>
|
|
1374
|
+
structuralSharing = (oldData, newData) => deepEqual4(oldData, newData) ? oldData : replaceEqualDeep3(oldData, newData),
|
|
1375
1375
|
suspense,
|
|
1376
1376
|
watch
|
|
1377
1377
|
} = {}) {
|
|
@@ -1401,9 +1401,9 @@ function useContractReads({
|
|
|
1401
1401
|
);
|
|
1402
1402
|
const enabled = React18.useMemo(() => {
|
|
1403
1403
|
let enabled2 = Boolean(
|
|
1404
|
-
enabled_ &&
|
|
1404
|
+
enabled_ && contracts?.every(
|
|
1405
1405
|
(x) => x.abi && x.address && x.functionName
|
|
1406
|
-
)
|
|
1406
|
+
)
|
|
1407
1407
|
);
|
|
1408
1408
|
if (cacheOnBlock)
|
|
1409
1409
|
enabled2 = Boolean(enabled2 && blockNumber);
|
|
@@ -1413,7 +1413,7 @@ function useContractReads({
|
|
|
1413
1413
|
enabled: Boolean(enabled && watch && !cacheOnBlock),
|
|
1414
1414
|
queryKey: queryKey_
|
|
1415
1415
|
});
|
|
1416
|
-
const abis = (
|
|
1416
|
+
const abis = (contracts ?? []).map(
|
|
1417
1417
|
({ abi }) => abi
|
|
1418
1418
|
);
|
|
1419
1419
|
return useQuery(queryKey_, queryFn7({ abis }), {
|
|
@@ -1424,8 +1424,8 @@ function useContractReads({
|
|
|
1424
1424
|
staleTime,
|
|
1425
1425
|
select(data) {
|
|
1426
1426
|
const result = data.map((data2, i) => {
|
|
1427
|
-
const { abi, functionName } =
|
|
1428
|
-
return abi && functionName ?
|
|
1427
|
+
const { abi, functionName } = contracts?.[i] ?? {};
|
|
1428
|
+
return abi && functionName ? parseContractResult2({ abi, functionName, data: data2 }) : data2;
|
|
1429
1429
|
});
|
|
1430
1430
|
return select ? select(result) : result;
|
|
1431
1431
|
},
|
|
@@ -1438,8 +1438,8 @@ function useContractReads({
|
|
|
1438
1438
|
}
|
|
1439
1439
|
|
|
1440
1440
|
// src/hooks/contracts/useContractWrite.ts
|
|
1441
|
-
|
|
1442
|
-
|
|
1441
|
+
import { writeContract } from "@wagmi/core";
|
|
1442
|
+
import * as React19 from "react";
|
|
1443
1443
|
function mutationKey6({
|
|
1444
1444
|
address,
|
|
1445
1445
|
chainId,
|
|
@@ -1473,7 +1473,7 @@ function mutationFn6(config) {
|
|
|
1473
1473
|
case "prepared": {
|
|
1474
1474
|
if (!config.request)
|
|
1475
1475
|
throw new Error("request is required");
|
|
1476
|
-
return
|
|
1476
|
+
return writeContract({
|
|
1477
1477
|
mode: "prepared",
|
|
1478
1478
|
address: config.address,
|
|
1479
1479
|
chainId: config.chainId,
|
|
@@ -1483,7 +1483,7 @@ function mutationFn6(config) {
|
|
|
1483
1483
|
});
|
|
1484
1484
|
}
|
|
1485
1485
|
case "recklesslyUnprepared":
|
|
1486
|
-
return
|
|
1486
|
+
return writeContract({
|
|
1487
1487
|
address: config.address,
|
|
1488
1488
|
args: config.args,
|
|
1489
1489
|
chainId: config.chainId,
|
|
@@ -1544,12 +1544,12 @@ function useContractWrite(config = {}) {
|
|
|
1544
1544
|
}
|
|
1545
1545
|
return (overrideConfig) => mutate({
|
|
1546
1546
|
address,
|
|
1547
|
-
args:
|
|
1547
|
+
args: overrideConfig?.recklesslySetUnpreparedArgs ?? args,
|
|
1548
1548
|
chainId,
|
|
1549
1549
|
abi,
|
|
1550
1550
|
functionName,
|
|
1551
1551
|
mode: "recklesslyUnprepared",
|
|
1552
|
-
overrides:
|
|
1552
|
+
overrides: overrideConfig?.recklesslySetUnpreparedOverrides ?? overrides
|
|
1553
1553
|
});
|
|
1554
1554
|
}, [
|
|
1555
1555
|
address,
|
|
@@ -1577,12 +1577,12 @@ function useContractWrite(config = {}) {
|
|
|
1577
1577
|
}
|
|
1578
1578
|
return (overrideConfig) => mutateAsync({
|
|
1579
1579
|
address,
|
|
1580
|
-
args:
|
|
1580
|
+
args: overrideConfig?.recklesslySetUnpreparedArgs ?? args,
|
|
1581
1581
|
chainId,
|
|
1582
1582
|
abi,
|
|
1583
1583
|
functionName,
|
|
1584
1584
|
mode: "recklesslyUnprepared",
|
|
1585
|
-
overrides:
|
|
1585
|
+
overrides: overrideConfig?.recklesslySetUnpreparedOverrides ?? overrides
|
|
1586
1586
|
});
|
|
1587
1587
|
}, [
|
|
1588
1588
|
address,
|
|
@@ -1611,7 +1611,7 @@ function useContractWrite(config = {}) {
|
|
|
1611
1611
|
}
|
|
1612
1612
|
|
|
1613
1613
|
// src/hooks/contracts/usePrepareContractWrite.ts
|
|
1614
|
-
|
|
1614
|
+
import { prepareWriteContract } from "@wagmi/core";
|
|
1615
1615
|
function queryKey8({
|
|
1616
1616
|
activeChainId,
|
|
1617
1617
|
args,
|
|
@@ -1643,7 +1643,7 @@ function queryFn8({
|
|
|
1643
1643
|
}) => {
|
|
1644
1644
|
if (!abi)
|
|
1645
1645
|
throw new Error("abi is required");
|
|
1646
|
-
return
|
|
1646
|
+
return prepareWriteContract({
|
|
1647
1647
|
abi,
|
|
1648
1648
|
args,
|
|
1649
1649
|
address,
|
|
@@ -1674,13 +1674,13 @@ function usePrepareContractWrite({
|
|
|
1674
1674
|
const { data: signer } = useSigner({ chainId });
|
|
1675
1675
|
const prepareContractWriteQuery = useQuery(
|
|
1676
1676
|
queryKey8({
|
|
1677
|
-
activeChainId:
|
|
1677
|
+
activeChainId: activeChain?.id,
|
|
1678
1678
|
address,
|
|
1679
1679
|
args,
|
|
1680
1680
|
chainId,
|
|
1681
1681
|
functionName,
|
|
1682
1682
|
scopeKey,
|
|
1683
|
-
signerAddress:
|
|
1683
|
+
signerAddress: signer?._address,
|
|
1684
1684
|
overrides
|
|
1685
1685
|
}),
|
|
1686
1686
|
queryFn8({
|
|
@@ -1713,7 +1713,7 @@ function usePrepareContractWrite({
|
|
|
1713
1713
|
}
|
|
1714
1714
|
|
|
1715
1715
|
// src/hooks/contracts/useToken.ts
|
|
1716
|
-
|
|
1716
|
+
import { fetchToken } from "@wagmi/core";
|
|
1717
1717
|
function queryKey9({
|
|
1718
1718
|
address,
|
|
1719
1719
|
chainId,
|
|
@@ -1727,7 +1727,7 @@ function queryFn9({
|
|
|
1727
1727
|
}) {
|
|
1728
1728
|
if (!address)
|
|
1729
1729
|
throw new Error("address is required");
|
|
1730
|
-
return
|
|
1730
|
+
return fetchToken({ address, chainId, formatUnits });
|
|
1731
1731
|
}
|
|
1732
1732
|
function useToken({
|
|
1733
1733
|
address,
|
|
@@ -1759,7 +1759,7 @@ function useToken({
|
|
|
1759
1759
|
}
|
|
1760
1760
|
|
|
1761
1761
|
// src/hooks/ens/useEnsAddress.ts
|
|
1762
|
-
|
|
1762
|
+
import { fetchEnsAddress } from "@wagmi/core";
|
|
1763
1763
|
function queryKey10({ chainId, name, scopeKey }) {
|
|
1764
1764
|
return [{ entity: "ensAddress", chainId, name, scopeKey }];
|
|
1765
1765
|
}
|
|
@@ -1768,7 +1768,7 @@ function queryFn10({
|
|
|
1768
1768
|
}) {
|
|
1769
1769
|
if (!name)
|
|
1770
1770
|
throw new Error("name is required");
|
|
1771
|
-
return
|
|
1771
|
+
return fetchEnsAddress({ chainId, name });
|
|
1772
1772
|
}
|
|
1773
1773
|
function useEnsAddress({
|
|
1774
1774
|
cacheTime,
|
|
@@ -1795,7 +1795,7 @@ function useEnsAddress({
|
|
|
1795
1795
|
}
|
|
1796
1796
|
|
|
1797
1797
|
// src/hooks/ens/useEnsAvatar.ts
|
|
1798
|
-
|
|
1798
|
+
import { fetchEnsAvatar } from "@wagmi/core";
|
|
1799
1799
|
function queryKey11({
|
|
1800
1800
|
address,
|
|
1801
1801
|
chainId,
|
|
@@ -1808,7 +1808,7 @@ function queryFn11({
|
|
|
1808
1808
|
}) {
|
|
1809
1809
|
if (!address)
|
|
1810
1810
|
throw new Error("address is required");
|
|
1811
|
-
return
|
|
1811
|
+
return fetchEnsAvatar({ address, chainId });
|
|
1812
1812
|
}
|
|
1813
1813
|
function useEnsAvatar({
|
|
1814
1814
|
address,
|
|
@@ -1835,7 +1835,7 @@ function useEnsAvatar({
|
|
|
1835
1835
|
}
|
|
1836
1836
|
|
|
1837
1837
|
// src/hooks/ens/useEnsName.ts
|
|
1838
|
-
|
|
1838
|
+
import { fetchEnsName } from "@wagmi/core";
|
|
1839
1839
|
function queryKey12({
|
|
1840
1840
|
address,
|
|
1841
1841
|
chainId,
|
|
@@ -1848,7 +1848,7 @@ function queryFn12({
|
|
|
1848
1848
|
}) {
|
|
1849
1849
|
if (!address)
|
|
1850
1850
|
throw new Error("address is required");
|
|
1851
|
-
return
|
|
1851
|
+
return fetchEnsName({ address, chainId });
|
|
1852
1852
|
}
|
|
1853
1853
|
function useEnsName({
|
|
1854
1854
|
address,
|
|
@@ -1875,7 +1875,7 @@ function useEnsName({
|
|
|
1875
1875
|
}
|
|
1876
1876
|
|
|
1877
1877
|
// src/hooks/ens/useEnsResolver.ts
|
|
1878
|
-
|
|
1878
|
+
import { fetchEnsResolver } from "@wagmi/core";
|
|
1879
1879
|
function queryKey13({ chainId, name, scopeKey }) {
|
|
1880
1880
|
return [
|
|
1881
1881
|
{ entity: "ensResolver", chainId, name, scopeKey, persist: false }
|
|
@@ -1886,7 +1886,7 @@ function queryFn13({
|
|
|
1886
1886
|
}) {
|
|
1887
1887
|
if (!name)
|
|
1888
1888
|
throw new Error("name is required");
|
|
1889
|
-
return
|
|
1889
|
+
return fetchEnsResolver({ chainId, name });
|
|
1890
1890
|
}
|
|
1891
1891
|
function useEnsResolver({
|
|
1892
1892
|
chainId: chainId_,
|
|
@@ -1910,7 +1910,7 @@ function useEnsResolver({
|
|
|
1910
1910
|
}
|
|
1911
1911
|
|
|
1912
1912
|
// src/hooks/transactions/usePrepareSendTransaction.ts
|
|
1913
|
-
|
|
1913
|
+
import { prepareSendTransaction } from "@wagmi/core";
|
|
1914
1914
|
function queryKey14({
|
|
1915
1915
|
activeChainId,
|
|
1916
1916
|
chainId,
|
|
@@ -1933,9 +1933,9 @@ function queryFn14({ signer }) {
|
|
|
1933
1933
|
return ({
|
|
1934
1934
|
queryKey: [{ chainId, request }]
|
|
1935
1935
|
}) => {
|
|
1936
|
-
if (!
|
|
1936
|
+
if (!request?.to)
|
|
1937
1937
|
throw new Error("request.to is required");
|
|
1938
|
-
return
|
|
1938
|
+
return prepareSendTransaction({
|
|
1939
1939
|
chainId,
|
|
1940
1940
|
request: { ...request, to: request.to },
|
|
1941
1941
|
signer
|
|
@@ -1958,11 +1958,11 @@ function usePrepareSendTransaction({
|
|
|
1958
1958
|
const { data: signer } = useSigner({ chainId });
|
|
1959
1959
|
const prepareSendTransactionQuery = useQuery(
|
|
1960
1960
|
queryKey14({
|
|
1961
|
-
activeChainId:
|
|
1961
|
+
activeChainId: activeChain?.id,
|
|
1962
1962
|
chainId,
|
|
1963
1963
|
request,
|
|
1964
1964
|
scopeKey,
|
|
1965
|
-
signerAddress:
|
|
1965
|
+
signerAddress: signer?._address
|
|
1966
1966
|
}),
|
|
1967
1967
|
queryFn14({ signer }),
|
|
1968
1968
|
{
|
|
@@ -1985,11 +1985,11 @@ function usePrepareSendTransaction({
|
|
|
1985
1985
|
}
|
|
1986
1986
|
|
|
1987
1987
|
// src/hooks/transactions/useSendTransaction.ts
|
|
1988
|
-
|
|
1989
|
-
|
|
1988
|
+
import { sendTransaction } from "@wagmi/core";
|
|
1989
|
+
import * as React20 from "react";
|
|
1990
1990
|
var mutationKey7 = (args) => [{ entity: "sendTransaction", ...args }];
|
|
1991
1991
|
var mutationFn7 = ({ chainId, mode, request }) => {
|
|
1992
|
-
return
|
|
1992
|
+
return sendTransaction({
|
|
1993
1993
|
chainId,
|
|
1994
1994
|
mode,
|
|
1995
1995
|
request
|
|
@@ -2034,7 +2034,7 @@ function useSendTransaction({
|
|
|
2034
2034
|
(args) => mutate({
|
|
2035
2035
|
chainId,
|
|
2036
2036
|
mode,
|
|
2037
|
-
request:
|
|
2037
|
+
request: args?.recklesslySetUnpreparedRequest ?? request
|
|
2038
2038
|
}),
|
|
2039
2039
|
[chainId, mode, mutate, request]
|
|
2040
2040
|
);
|
|
@@ -2042,7 +2042,7 @@ function useSendTransaction({
|
|
|
2042
2042
|
(args) => mutateAsync({
|
|
2043
2043
|
chainId,
|
|
2044
2044
|
mode,
|
|
2045
|
-
request:
|
|
2045
|
+
request: args?.recklesslySetUnpreparedRequest ?? request
|
|
2046
2046
|
}),
|
|
2047
2047
|
[chainId, mode, mutateAsync, request]
|
|
2048
2048
|
);
|
|
@@ -2062,7 +2062,7 @@ function useSendTransaction({
|
|
|
2062
2062
|
}
|
|
2063
2063
|
|
|
2064
2064
|
// src/hooks/transactions/useTransaction.ts
|
|
2065
|
-
|
|
2065
|
+
import { fetchTransaction } from "@wagmi/core";
|
|
2066
2066
|
function queryKey15({ chainId, hash, scopeKey }) {
|
|
2067
2067
|
return [{ entity: "transaction", chainId, hash, scopeKey }];
|
|
2068
2068
|
}
|
|
@@ -2071,7 +2071,7 @@ function queryFn15({
|
|
|
2071
2071
|
}) {
|
|
2072
2072
|
if (!hash)
|
|
2073
2073
|
throw new Error("hash is required");
|
|
2074
|
-
return
|
|
2074
|
+
return fetchTransaction({ chainId, hash });
|
|
2075
2075
|
}
|
|
2076
2076
|
function useTransaction({
|
|
2077
2077
|
cacheTime = 0,
|
|
@@ -2098,7 +2098,7 @@ function useTransaction({
|
|
|
2098
2098
|
}
|
|
2099
2099
|
|
|
2100
2100
|
// src/hooks/transactions/useWaitForTransaction.ts
|
|
2101
|
-
|
|
2101
|
+
import { waitForTransaction } from "@wagmi/core";
|
|
2102
2102
|
function queryKey16({
|
|
2103
2103
|
confirmations,
|
|
2104
2104
|
chainId,
|
|
@@ -2125,7 +2125,7 @@ function queryFn16({
|
|
|
2125
2125
|
}) => {
|
|
2126
2126
|
if (!hash)
|
|
2127
2127
|
throw new Error("hash is required");
|
|
2128
|
-
return
|
|
2128
|
+
return waitForTransaction({
|
|
2129
2129
|
chainId,
|
|
2130
2130
|
confirmations,
|
|
2131
2131
|
hash,
|
|
@@ -2166,7 +2166,7 @@ function useWaitForTransaction({
|
|
|
2166
2166
|
}
|
|
2167
2167
|
|
|
2168
2168
|
// src/hooks/transactions/useWatchPendingTransactions.ts
|
|
2169
|
-
|
|
2169
|
+
import * as React21 from "react";
|
|
2170
2170
|
function useWatchPendingTransactions({
|
|
2171
2171
|
chainId: chainId_,
|
|
2172
2172
|
enabled = true,
|
|
@@ -2178,7 +2178,7 @@ function useWatchPendingTransactions({
|
|
|
2178
2178
|
React21.useEffect(() => {
|
|
2179
2179
|
if (!enabled)
|
|
2180
2180
|
return;
|
|
2181
|
-
const provider_ =
|
|
2181
|
+
const provider_ = webSocketProvider ?? provider;
|
|
2182
2182
|
provider_.on("pending", listener);
|
|
2183
2183
|
return () => {
|
|
2184
2184
|
provider_.off("pending", listener);
|
|
@@ -2187,105 +2187,105 @@ function useWatchPendingTransactions({
|
|
|
2187
2187
|
}
|
|
2188
2188
|
|
|
2189
2189
|
// src/index.ts
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2190
|
+
import {
|
|
2191
|
+
AddChainError,
|
|
2192
|
+
ChainDoesNotSupportMulticallError,
|
|
2193
|
+
ChainMismatchError,
|
|
2194
|
+
ChainNotConfiguredError,
|
|
2195
|
+
Connector,
|
|
2196
|
+
ConnectorAlreadyConnectedError,
|
|
2197
|
+
ConnectorNotFoundError,
|
|
2198
|
+
ContractMethodDoesNotExistError,
|
|
2199
|
+
ContractMethodNoResultError,
|
|
2200
|
+
ContractMethodRevertedError,
|
|
2201
|
+
ContractResultDecodeError,
|
|
2202
|
+
ProviderChainsNotFound,
|
|
2203
|
+
ProviderRpcError,
|
|
2204
|
+
ResourceUnavailableError,
|
|
2205
|
+
RpcError,
|
|
2206
|
+
SwitchChainError,
|
|
2207
|
+
SwitchChainNotSupportedError,
|
|
2208
|
+
UserRejectedRequestError,
|
|
2209
|
+
configureChains,
|
|
2210
|
+
createStorage as createStorage2,
|
|
2211
|
+
deepEqual as deepEqual5,
|
|
2212
|
+
deserialize,
|
|
2213
|
+
erc20ABI,
|
|
2214
|
+
erc721ABI,
|
|
2215
|
+
erc4626ABI,
|
|
2216
|
+
goerli,
|
|
2217
|
+
mainnet,
|
|
2218
|
+
readContracts as readContracts3,
|
|
2219
|
+
serialize
|
|
2220
|
+
} from "@wagmi/core";
|
|
2221
|
+
export {
|
|
2222
|
+
AddChainError,
|
|
2223
|
+
ChainDoesNotSupportMulticallError,
|
|
2224
|
+
ChainMismatchError,
|
|
2225
|
+
ChainNotConfiguredError,
|
|
2226
|
+
Connector,
|
|
2227
|
+
ConnectorAlreadyConnectedError,
|
|
2228
|
+
ConnectorNotFoundError,
|
|
2229
|
+
Context,
|
|
2230
|
+
ContractMethodDoesNotExistError,
|
|
2231
|
+
ContractMethodNoResultError,
|
|
2232
|
+
ContractMethodRevertedError,
|
|
2233
|
+
ContractResultDecodeError,
|
|
2234
|
+
ProviderChainsNotFound,
|
|
2235
|
+
ProviderRpcError,
|
|
2236
|
+
ResourceUnavailableError,
|
|
2237
|
+
RpcError,
|
|
2238
|
+
SwitchChainError,
|
|
2239
|
+
SwitchChainNotSupportedError,
|
|
2240
|
+
UserRejectedRequestError,
|
|
2241
|
+
WagmiConfig,
|
|
2242
|
+
configureChains,
|
|
2243
|
+
createClient,
|
|
2244
|
+
createStorage2 as createStorage,
|
|
2245
|
+
deepEqual5 as deepEqual,
|
|
2246
|
+
deserialize,
|
|
2247
|
+
erc20ABI,
|
|
2248
|
+
erc4626ABI,
|
|
2249
|
+
erc721ABI,
|
|
2250
|
+
goerli,
|
|
2251
|
+
mainnet,
|
|
2252
|
+
paginatedIndexesConfig,
|
|
2253
|
+
readContracts3 as readContracts,
|
|
2254
|
+
serialize,
|
|
2255
|
+
useAccount,
|
|
2256
|
+
useBalance,
|
|
2257
|
+
useBlockNumber,
|
|
2258
|
+
useChainId,
|
|
2259
|
+
useClient,
|
|
2260
|
+
useConnect,
|
|
2261
|
+
useContract,
|
|
2262
|
+
useContractEvent,
|
|
2263
|
+
useContractInfiniteReads,
|
|
2264
|
+
useContractRead,
|
|
2265
|
+
useContractReads,
|
|
2266
|
+
useContractWrite,
|
|
2267
|
+
useDisconnect,
|
|
2268
|
+
useEnsAddress,
|
|
2269
|
+
useEnsAvatar,
|
|
2270
|
+
useEnsName,
|
|
2271
|
+
useEnsResolver,
|
|
2272
|
+
useFeeData,
|
|
2273
|
+
useInfiniteQuery,
|
|
2274
|
+
useMutation,
|
|
2275
|
+
useNetwork,
|
|
2276
|
+
usePrepareContractWrite,
|
|
2277
|
+
usePrepareSendTransaction,
|
|
2278
|
+
useProvider,
|
|
2279
|
+
useQuery,
|
|
2280
|
+
useQueryClient2 as useQueryClient,
|
|
2281
|
+
useSendTransaction,
|
|
2282
|
+
useSignMessage,
|
|
2283
|
+
useSignTypedData,
|
|
2284
|
+
useSigner,
|
|
2285
|
+
useSwitchNetwork,
|
|
2286
|
+
useToken,
|
|
2287
|
+
useTransaction,
|
|
2288
|
+
useWaitForTransaction,
|
|
2289
|
+
useWatchPendingTransactions,
|
|
2290
|
+
useWebSocketProvider
|
|
2291
|
+
};
|