wagmi 1.4.1 → 2.0.0
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/esm/context.js +16 -0
- package/dist/esm/context.js.map +1 -0
- package/dist/esm/errors/base.js +20 -0
- package/dist/esm/errors/base.js.map +1 -0
- package/dist/esm/errors/context.js +13 -0
- package/dist/esm/errors/context.js.map +1 -0
- package/dist/esm/exports/actions.js +4 -0
- package/dist/esm/exports/actions.js.map +1 -0
- package/dist/esm/exports/chains.js +4 -0
- package/dist/esm/exports/chains.js.map +1 -0
- package/dist/esm/exports/connectors.js +4 -0
- package/dist/esm/exports/connectors.js.map +1 -0
- package/dist/esm/exports/index.js +63 -0
- package/dist/esm/exports/index.js.map +1 -0
- package/dist/esm/exports/query.js +4 -0
- package/dist/esm/exports/query.js.map +1 -0
- package/dist/esm/hooks/useAccount.js +10 -0
- package/dist/esm/hooks/useAccount.js.map +1 -0
- package/dist/esm/hooks/useAccountEffect.js +29 -0
- package/dist/esm/hooks/useAccountEffect.js.map +1 -0
- package/dist/esm/hooks/useBalance.js +19 -0
- package/dist/esm/hooks/useBalance.js.map +1 -0
- package/dist/esm/hooks/useBlockNumber.js +37 -0
- package/dist/esm/hooks/useBlockNumber.js.map +1 -0
- package/dist/esm/hooks/useChainId.js +10 -0
- package/dist/esm/hooks/useChainId.js.map +1 -0
- package/dist/esm/hooks/useClient.js +10 -0
- package/dist/esm/hooks/useClient.js.map +1 -0
- package/dist/esm/hooks/useConfig.js +13 -0
- package/dist/esm/hooks/useConfig.js.map +1 -0
- package/dist/esm/hooks/useConnect.js +22 -0
- package/dist/esm/hooks/useConnect.js.map +1 -0
- package/dist/esm/hooks/useConnections.js +10 -0
- package/dist/esm/hooks/useConnections.js.map +1 -0
- package/dist/esm/hooks/useConnectorClient.js +40 -0
- package/dist/esm/hooks/useConnectorClient.js.map +1 -0
- package/dist/esm/hooks/useContractRead.js +26 -0
- package/dist/esm/hooks/useContractRead.js.map +1 -0
- package/dist/esm/hooks/useContractReads.js +38 -0
- package/dist/esm/hooks/useContractReads.js.map +1 -0
- package/dist/esm/hooks/useContractSimulate.js +24 -0
- package/dist/esm/hooks/useContractSimulate.js.map +1 -0
- package/dist/esm/hooks/useContractWrite.js +20 -0
- package/dist/esm/hooks/useContractWrite.js.map +1 -0
- package/dist/esm/hooks/useDisconnect.js +23 -0
- package/dist/esm/hooks/useDisconnect.js.map +1 -0
- package/dist/esm/hooks/useEnsAddress.js +19 -0
- package/dist/esm/hooks/useEnsAddress.js.map +1 -0
- package/dist/esm/hooks/useEnsAvatar.js +19 -0
- package/dist/esm/hooks/useEnsAvatar.js.map +1 -0
- package/dist/esm/hooks/useEnsName.js +19 -0
- package/dist/esm/hooks/useEnsName.js.map +1 -0
- package/dist/esm/hooks/useEnsResolver.js +19 -0
- package/dist/esm/hooks/useEnsResolver.js.map +1 -0
- package/dist/esm/hooks/useEstimateFeesPerGas.js +19 -0
- package/dist/esm/hooks/useEstimateFeesPerGas.js.map +1 -0
- package/dist/esm/hooks/useEstimateGas.js +25 -0
- package/dist/esm/hooks/useEstimateGas.js.map +1 -0
- package/dist/esm/hooks/usePublicClient.js +10 -0
- package/dist/esm/hooks/usePublicClient.js.map +1 -0
- package/dist/esm/hooks/useReconnect.js +22 -0
- package/dist/esm/hooks/useReconnect.js.map +1 -0
- package/dist/esm/hooks/useSendTransaction.js +20 -0
- package/dist/esm/hooks/useSendTransaction.js.map +1 -0
- package/dist/esm/hooks/useSignMessage.js +21 -0
- package/dist/esm/hooks/useSignMessage.js.map +1 -0
- package/dist/esm/hooks/useSignTypedData.js +20 -0
- package/dist/esm/hooks/useSignTypedData.js.map +1 -0
- package/dist/esm/hooks/useSwitchAccount.js +22 -0
- package/dist/esm/hooks/useSwitchAccount.js.map +1 -0
- package/dist/esm/hooks/useSwitchChain.js +21 -0
- package/dist/esm/hooks/useSwitchChain.js.map +1 -0
- package/dist/esm/hooks/useSyncExternalStoreWithTracked.js +40 -0
- package/dist/esm/hooks/useSyncExternalStoreWithTracked.js.map +1 -0
- package/dist/esm/hooks/useToken.js +19 -0
- package/dist/esm/hooks/useToken.js.map +1 -0
- package/dist/esm/hooks/useTransaction.js +19 -0
- package/dist/esm/hooks/useTransaction.js.map +1 -0
- package/dist/esm/hooks/useWaitForTransactionReceipt.js +19 -0
- package/dist/esm/hooks/useWaitForTransactionReceipt.js.map +1 -0
- package/dist/esm/hooks/useWalletClient.js +42 -0
- package/dist/esm/hooks/useWalletClient.js.map +1 -0
- package/dist/esm/hooks/useWatchBlockNumber.js +25 -0
- package/dist/esm/hooks/useWatchBlockNumber.js.map +1 -0
- package/dist/esm/hooks/useWatchContractEvent.js +25 -0
- package/dist/esm/hooks/useWatchContractEvent.js.map +1 -0
- package/dist/esm/hooks/useWatchPendingTransactions.js +25 -0
- package/dist/esm/hooks/useWatchPendingTransactions.js.map +1 -0
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -0
- package/dist/esm/types/properties.js +2 -0
- package/dist/esm/types/properties.js.map +1 -0
- package/dist/esm/utils/getVersion.js +3 -0
- package/dist/esm/utils/getVersion.js.map +1 -0
- package/dist/esm/utils/query.js +21 -0
- package/dist/esm/utils/query.js.map +1 -0
- package/dist/esm/version.js +2 -0
- package/dist/esm/version.js.map +1 -0
- package/dist/types/context.d.ts +11 -0
- package/dist/types/context.d.ts.map +1 -0
- package/dist/types/errors/base.d.ts +7 -0
- package/dist/types/errors/base.d.ts.map +1 -0
- package/dist/types/errors/context.d.ts +6 -0
- package/dist/types/errors/context.d.ts.map +1 -0
- package/dist/types/exports/actions.d.ts +2 -0
- package/dist/types/exports/actions.d.ts.map +1 -0
- package/dist/types/exports/chains.d.ts +2 -0
- package/dist/types/exports/chains.d.ts.map +1 -0
- package/dist/types/exports/connectors.d.ts +2 -0
- package/dist/types/exports/connectors.d.ts.map +1 -0
- package/dist/types/exports/index.d.ts +46 -0
- package/dist/types/exports/index.d.ts.map +1 -0
- package/dist/types/exports/query.d.ts +2 -0
- package/dist/types/exports/query.d.ts.map +1 -0
- package/dist/types/hooks/useAccount.d.ts +7 -0
- package/dist/types/hooks/useAccount.d.ts.map +1 -0
- package/dist/types/hooks/useAccountEffect.d.ts +14 -0
- package/dist/types/hooks/useAccountEffect.d.ts.map +1 -0
- package/dist/types/hooks/useBalance.d.ts +13 -0
- package/dist/types/hooks/useBalance.d.ts.map +1 -0
- package/dist/types/hooks/useBlockNumber.d.ts +14 -0
- package/dist/types/hooks/useBlockNumber.d.ts.map +1 -0
- package/dist/types/hooks/useChainId.d.ts +7 -0
- package/dist/types/hooks/useChainId.d.ts.map +1 -0
- package/dist/types/hooks/useClient.d.ts +8 -0
- package/dist/types/hooks/useClient.d.ts.map +1 -0
- package/dist/types/hooks/useConfig.d.ts +7 -0
- package/dist/types/hooks/useConfig.d.ts.map +1 -0
- package/dist/types/hooks/useConnect.d.ts +16 -0
- package/dist/types/hooks/useConnect.d.ts.map +1 -0
- package/dist/types/hooks/useConnections.d.ts +7 -0
- package/dist/types/hooks/useConnections.d.ts.map +1 -0
- package/dist/types/hooks/useConnectorClient.d.ts +12 -0
- package/dist/types/hooks/useConnectorClient.d.ts.map +1 -0
- package/dist/types/hooks/useContractRead.d.ts +13 -0
- package/dist/types/hooks/useContractRead.d.ts.map +1 -0
- package/dist/types/hooks/useContractReads.d.ts +13 -0
- package/dist/types/hooks/useContractReads.d.ts.map +1 -0
- package/dist/types/hooks/useContractSimulate.d.ts +12 -0
- package/dist/types/hooks/useContractSimulate.d.ts.map +1 -0
- package/dist/types/hooks/useContractWrite.d.ts +15 -0
- package/dist/types/hooks/useContractWrite.d.ts.map +1 -0
- package/dist/types/hooks/useDisconnect.d.ts +16 -0
- package/dist/types/hooks/useDisconnect.d.ts.map +1 -0
- package/dist/types/hooks/useEnsAddress.d.ts +12 -0
- package/dist/types/hooks/useEnsAddress.d.ts.map +1 -0
- package/dist/types/hooks/useEnsAvatar.d.ts +12 -0
- package/dist/types/hooks/useEnsAvatar.d.ts.map +1 -0
- package/dist/types/hooks/useEnsName.d.ts +12 -0
- package/dist/types/hooks/useEnsName.d.ts.map +1 -0
- package/dist/types/hooks/useEnsResolver.d.ts +12 -0
- package/dist/types/hooks/useEnsResolver.d.ts.map +1 -0
- package/dist/types/hooks/useEstimateFeesPerGas.d.ts +13 -0
- package/dist/types/hooks/useEstimateFeesPerGas.d.ts.map +1 -0
- package/dist/types/hooks/useEstimateGas.d.ts +11 -0
- package/dist/types/hooks/useEstimateGas.d.ts.map +1 -0
- package/dist/types/hooks/usePublicClient.d.ts +8 -0
- package/dist/types/hooks/usePublicClient.d.ts.map +1 -0
- package/dist/types/hooks/useReconnect.d.ts +16 -0
- package/dist/types/hooks/useReconnect.d.ts.map +1 -0
- package/dist/types/hooks/useSendTransaction.d.ts +15 -0
- package/dist/types/hooks/useSendTransaction.d.ts.map +1 -0
- package/dist/types/hooks/useSignMessage.d.ts +15 -0
- package/dist/types/hooks/useSignMessage.d.ts.map +1 -0
- package/dist/types/hooks/useSignTypedData.d.ts +15 -0
- package/dist/types/hooks/useSignTypedData.d.ts.map +1 -0
- package/dist/types/hooks/useSwitchAccount.d.ts +16 -0
- package/dist/types/hooks/useSwitchAccount.d.ts.map +1 -0
- package/dist/types/hooks/useSwitchChain.d.ts +16 -0
- package/dist/types/hooks/useSwitchChain.d.ts.map +1 -0
- package/dist/types/hooks/useSyncExternalStoreWithTracked.d.ts +2 -0
- package/dist/types/hooks/useSyncExternalStoreWithTracked.d.ts.map +1 -0
- package/dist/types/hooks/useToken.d.ts +12 -0
- package/dist/types/hooks/useToken.d.ts.map +1 -0
- package/dist/types/hooks/useTransaction.d.ts +12 -0
- package/dist/types/hooks/useTransaction.d.ts.map +1 -0
- package/dist/types/hooks/useWaitForTransactionReceipt.d.ts +12 -0
- package/dist/types/hooks/useWaitForTransactionReceipt.d.ts.map +1 -0
- package/dist/types/hooks/useWalletClient.d.ts +12 -0
- package/dist/types/hooks/useWalletClient.d.ts.map +1 -0
- package/dist/types/hooks/useWatchBlockNumber.d.ts +8 -0
- package/dist/types/hooks/useWatchBlockNumber.d.ts.map +1 -0
- package/dist/types/hooks/useWatchContractEvent.d.ts +9 -0
- package/dist/types/hooks/useWatchContractEvent.d.ts.map +1 -0
- package/dist/types/hooks/useWatchPendingTransactions.d.ts +8 -0
- package/dist/types/hooks/useWatchPendingTransactions.d.ts.map +1 -0
- package/dist/types/types/properties.d.ts +8 -0
- package/dist/types/types/properties.d.ts.map +1 -0
- package/dist/types/utils/getVersion.d.ts +2 -0
- package/dist/types/utils/getVersion.d.ts.map +1 -0
- package/dist/types/utils/query.d.ts +15 -0
- package/dist/types/utils/query.d.ts.map +1 -0
- package/dist/types/version.d.ts +2 -0
- package/dist/types/version.d.ts.map +1 -0
- package/package.json +65 -103
- package/src/context.ts +27 -0
- package/src/errors/base.ts +13 -0
- package/src/errors/context.ts +8 -0
- package/src/exports/actions.ts +4 -0
- package/src/exports/chains.ts +4 -0
- package/src/exports/connectors.ts +4 -0
- package/src/exports/index.ts +284 -0
- package/src/exports/query.ts +4 -0
- package/src/hooks/useAccount.ts +27 -0
- package/src/hooks/useAccountEffect.ts +55 -0
- package/src/hooks/useBalance.ts +65 -0
- package/src/hooks/useBlockNumber.ts +97 -0
- package/src/hooks/useChainId.ts +31 -0
- package/src/hooks/useClient.ts +43 -0
- package/src/hooks/useConfig.ts +22 -0
- package/src/hooks/useConnect.ts +80 -0
- package/src/hooks/useConnections.ts +27 -0
- package/src/hooks/useConnectorClient.ts +95 -0
- package/src/hooks/useContractRead.ts +107 -0
- package/src/hooks/useContractReads.ts +98 -0
- package/src/hooks/useContractSimulate.ts +117 -0
- package/src/hooks/useContractWrite.ts +83 -0
- package/src/hooks/useDisconnect.ts +68 -0
- package/src/hooks/useEnsAddress.ts +61 -0
- package/src/hooks/useEnsAvatar.ts +59 -0
- package/src/hooks/useEnsName.ts +61 -0
- package/src/hooks/useEnsResolver.ts +61 -0
- package/src/hooks/useEstimateFeesPerGas.ts +69 -0
- package/src/hooks/useEstimateGas.ts +72 -0
- package/src/hooks/usePublicClient.ts +45 -0
- package/src/hooks/useReconnect.ts +67 -0
- package/src/hooks/useSendTransaction.ts +79 -0
- package/src/hooks/useSignMessage.ts +65 -0
- package/src/hooks/useSignTypedData.ts +66 -0
- package/src/hooks/useSwitchAccount.ts +82 -0
- package/src/hooks/useSwitchChain.ts +77 -0
- package/src/hooks/useSyncExternalStoreWithTracked.ts +67 -0
- package/src/hooks/useToken.ts +63 -0
- package/src/hooks/useTransaction.ts +68 -0
- package/src/hooks/useWaitForTransactionReceipt.ts +74 -0
- package/src/hooks/useWalletClient.ts +96 -0
- package/src/hooks/useWatchBlockNumber.ts +49 -0
- package/src/hooks/useWatchContractEvent.ts +64 -0
- package/src/hooks/useWatchPendingTransactions.ts +52 -0
- package/src/types/properties.ts +9 -0
- package/src/utils/getVersion.ts +3 -0
- package/src/utils/query.ts +102 -0
- package/src/version.ts +1 -0
- package/README.md +0 -30
- package/actions/package.json +0 -4
- package/chains/package.json +0 -4
- package/connectors/coinbaseWallet/package.json +0 -4
- package/connectors/injected/package.json +0 -4
- package/connectors/ledger/package.json +0 -4
- package/connectors/metaMask/package.json +0 -4
- package/connectors/mock/package.json +0 -4
- package/connectors/package.json +0 -4
- package/connectors/safe/package.json +0 -4
- package/connectors/walletConnect/package.json +0 -4
- package/connectors/walletConnectLegacy/package.json +0 -4
- package/dist/actions.d.ts +0 -1
- package/dist/actions.js +0 -85
- package/dist/chains.d.ts +0 -2
- package/dist/chains.js +0 -4
- package/dist/connectors/coinbaseWallet.d.ts +0 -1
- package/dist/connectors/coinbaseWallet.js +0 -7
- package/dist/connectors/index.d.ts +0 -1
- package/dist/connectors/index.js +0 -7
- package/dist/connectors/injected.d.ts +0 -1
- package/dist/connectors/injected.js +0 -7
- package/dist/connectors/ledger.d.ts +0 -1
- package/dist/connectors/ledger.js +0 -7
- package/dist/connectors/metaMask.d.ts +0 -1
- package/dist/connectors/metaMask.js +0 -7
- package/dist/connectors/mock.d.ts +0 -1
- package/dist/connectors/mock.js +0 -7
- package/dist/connectors/safe.d.ts +0 -1
- package/dist/connectors/safe.js +0 -7
- package/dist/connectors/walletConnect.d.ts +0 -1
- package/dist/connectors/walletConnect.js +0 -7
- package/dist/connectors/walletConnectLegacy.d.ts +0 -1
- package/dist/connectors/walletConnectLegacy.js +0 -7
- package/dist/index.d.ts +0 -958
- package/dist/index.js +0 -2564
- package/dist/providers/alchemy.d.ts +0 -1
- package/dist/providers/alchemy.js +0 -7
- package/dist/providers/infura.d.ts +0 -1
- package/dist/providers/infura.js +0 -7
- package/dist/providers/jsonRpc.d.ts +0 -1
- package/dist/providers/jsonRpc.js +0 -7
- package/dist/providers/public.d.ts +0 -1
- package/dist/providers/public.js +0 -7
- package/dist/window.d.ts +0 -76
- package/dist/window.js +0 -1
- package/providers/alchemy/package.json +0 -4
- package/providers/infura/package.json +0 -4
- package/providers/jsonRpc/package.json +0 -4
- package/providers/public/package.json +0 -4
- package/window/package.json +0 -4
package/dist/index.js
DELETED
|
@@ -1,2564 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
// src/config.ts
|
|
4
|
-
import { createSyncStoragePersister } from "@tanstack/query-sync-storage-persister";
|
|
5
|
-
import { QueryClient } from "@tanstack/react-query";
|
|
6
|
-
import { persistQueryClient } from "@tanstack/react-query-persist-client";
|
|
7
|
-
import {
|
|
8
|
-
createConfig as createCoreConfig,
|
|
9
|
-
createStorage,
|
|
10
|
-
noopStorage
|
|
11
|
-
} from "@wagmi/core";
|
|
12
|
-
function createConfig({
|
|
13
|
-
queryClient = new QueryClient({
|
|
14
|
-
defaultOptions: {
|
|
15
|
-
queries: {
|
|
16
|
-
cacheTime: 1e3 * 60 * 60 * 24,
|
|
17
|
-
networkMode: "offlineFirst",
|
|
18
|
-
refetchOnWindowFocus: false,
|
|
19
|
-
retry: 0
|
|
20
|
-
},
|
|
21
|
-
mutations: {
|
|
22
|
-
networkMode: "offlineFirst"
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}),
|
|
26
|
-
storage = createStorage({
|
|
27
|
-
storage: typeof window !== "undefined" && window.localStorage ? window.localStorage : noopStorage
|
|
28
|
-
}),
|
|
29
|
-
persister = typeof window !== "undefined" ? createSyncStoragePersister({
|
|
30
|
-
key: "cache",
|
|
31
|
-
storage,
|
|
32
|
-
serialize: (x) => x,
|
|
33
|
-
deserialize: (x) => x
|
|
34
|
-
}) : void 0,
|
|
35
|
-
...args
|
|
36
|
-
}) {
|
|
37
|
-
const config = createCoreConfig({
|
|
38
|
-
...args,
|
|
39
|
-
storage
|
|
40
|
-
});
|
|
41
|
-
if (persister)
|
|
42
|
-
persistQueryClient({
|
|
43
|
-
queryClient,
|
|
44
|
-
persister,
|
|
45
|
-
dehydrateOptions: {
|
|
46
|
-
shouldDehydrateQuery: (query) => query.cacheTime !== 0 && query.queryKey[0].persist !== false
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
return Object.assign(config, { queryClient });
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// src/context.ts
|
|
53
|
-
import { QueryClientProvider } from "@tanstack/react-query";
|
|
54
|
-
import * as React from "react";
|
|
55
|
-
var Context = React.createContext(void 0);
|
|
56
|
-
var queryClientContext = React.createContext(
|
|
57
|
-
void 0
|
|
58
|
-
);
|
|
59
|
-
function WagmiConfig({
|
|
60
|
-
children,
|
|
61
|
-
config
|
|
62
|
-
}) {
|
|
63
|
-
return React.createElement(Context.Provider, {
|
|
64
|
-
children: React.createElement(QueryClientProvider, {
|
|
65
|
-
children,
|
|
66
|
-
client: config.queryClient,
|
|
67
|
-
context: queryClientContext
|
|
68
|
-
}),
|
|
69
|
-
value: config
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
function useConfig() {
|
|
73
|
-
const config = React.useContext(Context);
|
|
74
|
-
if (!config)
|
|
75
|
-
throw new Error(
|
|
76
|
-
[
|
|
77
|
-
"`useConfig` must be used within `WagmiConfig`.\n",
|
|
78
|
-
"Read more: https://wagmi.sh/react/WagmiConfig"
|
|
79
|
-
].join("\n")
|
|
80
|
-
);
|
|
81
|
-
return config;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// src/hooks/accounts/useAccount.ts
|
|
85
|
-
import { getAccount, watchAccount } from "@wagmi/core";
|
|
86
|
-
import * as React9 from "react";
|
|
87
|
-
|
|
88
|
-
// src/hooks/utils/query/useBaseQuery.ts
|
|
89
|
-
import {
|
|
90
|
-
notifyManager,
|
|
91
|
-
useIsRestoring,
|
|
92
|
-
useQueryClient,
|
|
93
|
-
useQueryErrorResetBoundary
|
|
94
|
-
} from "@tanstack/react-query";
|
|
95
|
-
import * as React2 from "react";
|
|
96
|
-
|
|
97
|
-
// src/hooks/utils/useSyncExternalStore.ts
|
|
98
|
-
import * as pkg from "use-sync-external-store/shim/index.js";
|
|
99
|
-
var useSyncExternalStore2 = pkg.useSyncExternalStore;
|
|
100
|
-
|
|
101
|
-
// src/hooks/utils/query/utils.ts
|
|
102
|
-
function isQueryKey(value) {
|
|
103
|
-
return Array.isArray(value);
|
|
104
|
-
}
|
|
105
|
-
function isPlainObject(o) {
|
|
106
|
-
if (!hasObjectPrototype(o)) {
|
|
107
|
-
return false;
|
|
108
|
-
}
|
|
109
|
-
const ctor = o.constructor;
|
|
110
|
-
if (typeof ctor === "undefined") {
|
|
111
|
-
return true;
|
|
112
|
-
}
|
|
113
|
-
const prot = ctor.prototype;
|
|
114
|
-
if (!hasObjectPrototype(prot)) {
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
if (!prot.hasOwnProperty("isPrototypeOf")) {
|
|
118
|
-
return false;
|
|
119
|
-
}
|
|
120
|
-
return true;
|
|
121
|
-
}
|
|
122
|
-
function hasObjectPrototype(o) {
|
|
123
|
-
return Object.prototype.toString.call(o) === "[object Object]";
|
|
124
|
-
}
|
|
125
|
-
function parseQueryArgs(arg1, arg2, arg3) {
|
|
126
|
-
if (!isQueryKey(arg1)) {
|
|
127
|
-
return arg1;
|
|
128
|
-
}
|
|
129
|
-
if (typeof arg2 === "function") {
|
|
130
|
-
return { ...arg3, queryKey: arg1, queryFn: arg2 };
|
|
131
|
-
}
|
|
132
|
-
return { ...arg2, queryKey: arg1 };
|
|
133
|
-
}
|
|
134
|
-
function queryKeyHashFn(queryKey17) {
|
|
135
|
-
return JSON.stringify(
|
|
136
|
-
queryKey17,
|
|
137
|
-
(_, val) => isPlainObject(val) ? Object.keys(val).sort().reduce((result, key) => {
|
|
138
|
-
result[key] = val[key];
|
|
139
|
-
return result;
|
|
140
|
-
}, {}) : typeof val === "bigint" ? val.toString() : val
|
|
141
|
-
);
|
|
142
|
-
}
|
|
143
|
-
function shouldThrowError(_useErrorBoundary, params) {
|
|
144
|
-
if (typeof _useErrorBoundary === "function") {
|
|
145
|
-
return _useErrorBoundary(...params);
|
|
146
|
-
}
|
|
147
|
-
return !!_useErrorBoundary;
|
|
148
|
-
}
|
|
149
|
-
function trackResult(result, observer) {
|
|
150
|
-
const trackedResult = {};
|
|
151
|
-
Object.keys(result).forEach((key) => {
|
|
152
|
-
Object.defineProperty(trackedResult, key, {
|
|
153
|
-
configurable: false,
|
|
154
|
-
enumerable: true,
|
|
155
|
-
get: () => {
|
|
156
|
-
observer.trackedProps.add(key);
|
|
157
|
-
return result[key];
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
return trackedResult;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// src/hooks/utils/query/useBaseQuery.ts
|
|
165
|
-
function useBaseQuery(options, Observer) {
|
|
166
|
-
const queryClient = useQueryClient({ context: options.context });
|
|
167
|
-
const isRestoring = useIsRestoring();
|
|
168
|
-
const errorResetBoundary = useQueryErrorResetBoundary();
|
|
169
|
-
const defaultedOptions = queryClient.defaultQueryOptions({
|
|
170
|
-
...options,
|
|
171
|
-
queryKeyHashFn
|
|
172
|
-
});
|
|
173
|
-
defaultedOptions._optimisticResults = isRestoring ? "isRestoring" : "optimistic";
|
|
174
|
-
if (defaultedOptions.onError) {
|
|
175
|
-
defaultedOptions.onError = notifyManager.batchCalls(
|
|
176
|
-
defaultedOptions.onError
|
|
177
|
-
);
|
|
178
|
-
}
|
|
179
|
-
if (defaultedOptions.onSuccess) {
|
|
180
|
-
defaultedOptions.onSuccess = notifyManager.batchCalls(
|
|
181
|
-
defaultedOptions.onSuccess
|
|
182
|
-
);
|
|
183
|
-
}
|
|
184
|
-
if (defaultedOptions.onSettled) {
|
|
185
|
-
defaultedOptions.onSettled = notifyManager.batchCalls(
|
|
186
|
-
defaultedOptions.onSettled
|
|
187
|
-
);
|
|
188
|
-
}
|
|
189
|
-
if (defaultedOptions.suspense) {
|
|
190
|
-
if (typeof defaultedOptions.staleTime !== "number") {
|
|
191
|
-
defaultedOptions.staleTime = 1e3;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
if (defaultedOptions.suspense || defaultedOptions.useErrorBoundary) {
|
|
195
|
-
if (!errorResetBoundary.isReset()) {
|
|
196
|
-
defaultedOptions.retryOnMount = false;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
const [observer] = React2.useState(
|
|
200
|
-
() => new Observer(
|
|
201
|
-
queryClient,
|
|
202
|
-
defaultedOptions
|
|
203
|
-
)
|
|
204
|
-
);
|
|
205
|
-
const result = observer.getOptimisticResult(defaultedOptions);
|
|
206
|
-
useSyncExternalStore2(
|
|
207
|
-
React2.useCallback(
|
|
208
|
-
(onStoreChange) => isRestoring ? () => void 0 : observer.subscribe(notifyManager.batchCalls(onStoreChange)),
|
|
209
|
-
[observer, isRestoring]
|
|
210
|
-
),
|
|
211
|
-
() => observer.getCurrentResult(),
|
|
212
|
-
() => observer.getCurrentResult()
|
|
213
|
-
);
|
|
214
|
-
React2.useEffect(() => {
|
|
215
|
-
errorResetBoundary.clearReset();
|
|
216
|
-
}, [errorResetBoundary]);
|
|
217
|
-
React2.useEffect(() => {
|
|
218
|
-
observer.setOptions(defaultedOptions, { listeners: false });
|
|
219
|
-
}, [defaultedOptions, observer]);
|
|
220
|
-
if (defaultedOptions.suspense && result.isLoading && result.isFetching && !isRestoring) {
|
|
221
|
-
throw observer.fetchOptimistic(defaultedOptions).then(({ data }) => {
|
|
222
|
-
defaultedOptions.onSuccess?.(data);
|
|
223
|
-
defaultedOptions.onSettled?.(data, null);
|
|
224
|
-
}).catch((error) => {
|
|
225
|
-
errorResetBoundary.clearReset();
|
|
226
|
-
defaultedOptions.onError?.(error);
|
|
227
|
-
defaultedOptions.onSettled?.(void 0, error);
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
if (result.isError && !errorResetBoundary.isReset() && !result.isFetching && shouldThrowError(defaultedOptions.useErrorBoundary, [
|
|
231
|
-
result.error,
|
|
232
|
-
observer.getCurrentQuery()
|
|
233
|
-
])) {
|
|
234
|
-
throw result.error;
|
|
235
|
-
}
|
|
236
|
-
const status = result.status === "loading" && result.fetchStatus === "idle" ? "idle" : result.status;
|
|
237
|
-
const isIdle = status === "idle";
|
|
238
|
-
const isLoading = status === "loading" && result.fetchStatus === "fetching";
|
|
239
|
-
return {
|
|
240
|
-
...result,
|
|
241
|
-
defaultedOptions,
|
|
242
|
-
isIdle,
|
|
243
|
-
isLoading,
|
|
244
|
-
observer,
|
|
245
|
-
status
|
|
246
|
-
};
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
// src/hooks/utils/query/useInfiniteQuery.ts
|
|
250
|
-
import { InfiniteQueryObserver } from "@tanstack/react-query";
|
|
251
|
-
function useInfiniteQuery(arg1, arg2, arg3) {
|
|
252
|
-
const parsedOptions = parseQueryArgs(arg1, arg2, arg3);
|
|
253
|
-
const baseQuery = useBaseQuery(
|
|
254
|
-
{ context: queryClientContext, ...parsedOptions },
|
|
255
|
-
InfiniteQueryObserver
|
|
256
|
-
);
|
|
257
|
-
const result = {
|
|
258
|
-
data: baseQuery.data,
|
|
259
|
-
error: baseQuery.error,
|
|
260
|
-
fetchNextPage: baseQuery.fetchNextPage,
|
|
261
|
-
fetchStatus: baseQuery.fetchStatus,
|
|
262
|
-
hasNextPage: baseQuery.hasNextPage,
|
|
263
|
-
isError: baseQuery.isError,
|
|
264
|
-
isFetched: baseQuery.isFetched,
|
|
265
|
-
isFetchedAfterMount: baseQuery.isFetchedAfterMount,
|
|
266
|
-
isFetching: baseQuery.isFetching,
|
|
267
|
-
isFetchingNextPage: baseQuery.isFetchingNextPage,
|
|
268
|
-
isIdle: baseQuery.isIdle,
|
|
269
|
-
isLoading: baseQuery.isLoading,
|
|
270
|
-
isRefetching: baseQuery.isRefetching,
|
|
271
|
-
isSuccess: baseQuery.isSuccess,
|
|
272
|
-
refetch: baseQuery.refetch,
|
|
273
|
-
status: baseQuery.status,
|
|
274
|
-
internal: {
|
|
275
|
-
dataUpdatedAt: baseQuery.dataUpdatedAt,
|
|
276
|
-
errorUpdatedAt: baseQuery.errorUpdatedAt,
|
|
277
|
-
failureCount: baseQuery.failureCount,
|
|
278
|
-
isFetchedAfterMount: baseQuery.isFetchedAfterMount,
|
|
279
|
-
isLoadingError: baseQuery.isLoadingError,
|
|
280
|
-
isPaused: baseQuery.isPaused,
|
|
281
|
-
isPlaceholderData: baseQuery.isPlaceholderData,
|
|
282
|
-
isPreviousData: baseQuery.isPreviousData,
|
|
283
|
-
isRefetchError: baseQuery.isRefetchError,
|
|
284
|
-
isStale: baseQuery.isStale,
|
|
285
|
-
remove: baseQuery.remove
|
|
286
|
-
}
|
|
287
|
-
};
|
|
288
|
-
return !baseQuery.defaultedOptions.notifyOnChangeProps ? trackResult(result, baseQuery.observer) : result;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
// src/hooks/utils/query/useMutation.ts
|
|
292
|
-
import {
|
|
293
|
-
parseMutationArgs,
|
|
294
|
-
useMutation as useMutation_
|
|
295
|
-
} from "@tanstack/react-query";
|
|
296
|
-
function useMutation(arg1, arg2, arg3) {
|
|
297
|
-
const options = parseMutationArgs(arg1, arg2, arg3);
|
|
298
|
-
return useMutation_({ context: queryClientContext, ...options });
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
// src/hooks/utils/query/useQuery.ts
|
|
302
|
-
import { QueryObserver } from "@tanstack/react-query";
|
|
303
|
-
function useQuery(arg1, arg2, arg3) {
|
|
304
|
-
const parsedOptions = parseQueryArgs(arg1, arg2, arg3);
|
|
305
|
-
const baseQuery = useBaseQuery({ context: queryClientContext, ...parsedOptions }, QueryObserver);
|
|
306
|
-
const result = {
|
|
307
|
-
data: baseQuery.data,
|
|
308
|
-
error: baseQuery.error,
|
|
309
|
-
fetchStatus: baseQuery.fetchStatus,
|
|
310
|
-
isError: baseQuery.isError,
|
|
311
|
-
isFetched: baseQuery.isFetched,
|
|
312
|
-
isFetchedAfterMount: baseQuery.isFetchedAfterMount,
|
|
313
|
-
isFetching: baseQuery.isFetching,
|
|
314
|
-
isIdle: baseQuery.isIdle,
|
|
315
|
-
isLoading: baseQuery.isLoading,
|
|
316
|
-
isRefetching: baseQuery.isRefetching,
|
|
317
|
-
isSuccess: baseQuery.isSuccess,
|
|
318
|
-
refetch: baseQuery.refetch,
|
|
319
|
-
status: baseQuery.status,
|
|
320
|
-
internal: {
|
|
321
|
-
dataUpdatedAt: baseQuery.dataUpdatedAt,
|
|
322
|
-
errorUpdatedAt: baseQuery.errorUpdatedAt,
|
|
323
|
-
failureCount: baseQuery.failureCount,
|
|
324
|
-
isFetchedAfterMount: baseQuery.isFetchedAfterMount,
|
|
325
|
-
isLoadingError: baseQuery.isLoadingError,
|
|
326
|
-
isPaused: baseQuery.isPaused,
|
|
327
|
-
isPlaceholderData: baseQuery.isPlaceholderData,
|
|
328
|
-
isPreviousData: baseQuery.isPreviousData,
|
|
329
|
-
isRefetchError: baseQuery.isRefetchError,
|
|
330
|
-
isStale: baseQuery.isStale,
|
|
331
|
-
remove: baseQuery.remove
|
|
332
|
-
}
|
|
333
|
-
};
|
|
334
|
-
return !baseQuery.defaultedOptions.notifyOnChangeProps ? trackResult(result, baseQuery.observer) : result;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
// src/hooks/utils/query/useQueryClient.ts
|
|
338
|
-
import { useQueryClient as useQueryClient_ } from "@tanstack/react-query";
|
|
339
|
-
var useQueryClient2 = () => useQueryClient_({ context: queryClientContext });
|
|
340
|
-
|
|
341
|
-
// src/hooks/viem/usePublicClient.ts
|
|
342
|
-
import { getPublicClient, watchPublicClient } from "@wagmi/core";
|
|
343
|
-
import { useSyncExternalStoreWithSelector } from "use-sync-external-store/shim/with-selector.js";
|
|
344
|
-
function usePublicClient({
|
|
345
|
-
chainId
|
|
346
|
-
} = {}) {
|
|
347
|
-
return useSyncExternalStoreWithSelector(
|
|
348
|
-
(cb) => watchPublicClient({ chainId }, cb),
|
|
349
|
-
() => getPublicClient({ chainId }),
|
|
350
|
-
() => getPublicClient({ chainId }),
|
|
351
|
-
(x) => x,
|
|
352
|
-
(a, b) => a.uid === b.uid
|
|
353
|
-
);
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
// src/hooks/viem/useWalletClient.ts
|
|
357
|
-
import { getWalletClient, watchWalletClient } from "@wagmi/core";
|
|
358
|
-
import * as React3 from "react";
|
|
359
|
-
function queryKey({ chainId }) {
|
|
360
|
-
return [{ entity: "walletClient", chainId, persist: false }];
|
|
361
|
-
}
|
|
362
|
-
function queryFn({
|
|
363
|
-
queryKey: [{ chainId }]
|
|
364
|
-
}) {
|
|
365
|
-
return getWalletClient({ chainId });
|
|
366
|
-
}
|
|
367
|
-
function useWalletClient({
|
|
368
|
-
chainId: chainId_,
|
|
369
|
-
suspense,
|
|
370
|
-
onError,
|
|
371
|
-
onSettled,
|
|
372
|
-
onSuccess
|
|
373
|
-
} = {}) {
|
|
374
|
-
const { connector } = useAccount();
|
|
375
|
-
const chainId = useChainId({ chainId: chainId_ });
|
|
376
|
-
const walletClientQuery = useQuery(queryKey({ chainId }), queryFn, {
|
|
377
|
-
cacheTime: 0,
|
|
378
|
-
enabled: Boolean(connector),
|
|
379
|
-
staleTime: Infinity,
|
|
380
|
-
suspense,
|
|
381
|
-
onError,
|
|
382
|
-
onSettled,
|
|
383
|
-
onSuccess
|
|
384
|
-
});
|
|
385
|
-
const queryClient = useQueryClient2();
|
|
386
|
-
React3.useEffect(() => {
|
|
387
|
-
const unwatch = watchWalletClient({ chainId }, (walletClient) => {
|
|
388
|
-
if (walletClient)
|
|
389
|
-
queryClient.invalidateQueries(queryKey({ chainId }));
|
|
390
|
-
else
|
|
391
|
-
queryClient.removeQueries(queryKey({ chainId }));
|
|
392
|
-
});
|
|
393
|
-
return unwatch;
|
|
394
|
-
}, [queryClient, chainId]);
|
|
395
|
-
return walletClientQuery;
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
// src/hooks/viem/useWebSocketPublicClient.ts
|
|
399
|
-
import {
|
|
400
|
-
getWebSocketPublicClient,
|
|
401
|
-
watchWebSocketPublicClient
|
|
402
|
-
} from "@wagmi/core";
|
|
403
|
-
import { useSyncExternalStoreWithSelector as useSyncExternalStoreWithSelector2 } from "use-sync-external-store/shim/with-selector.js";
|
|
404
|
-
function useWebSocketPublicClient({ chainId } = {}) {
|
|
405
|
-
return useSyncExternalStoreWithSelector2(
|
|
406
|
-
(cb) => watchWebSocketPublicClient({ chainId }, cb),
|
|
407
|
-
() => getWebSocketPublicClient({ chainId }),
|
|
408
|
-
() => getWebSocketPublicClient({ chainId }),
|
|
409
|
-
(x) => x,
|
|
410
|
-
(a, b) => a?.uid === b?.uid
|
|
411
|
-
);
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
// src/hooks/utils/useChainId.ts
|
|
415
|
-
function useChainId({ chainId } = {}) {
|
|
416
|
-
const publicClient = usePublicClient({ chainId });
|
|
417
|
-
return publicClient.chain.id;
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
// src/hooks/utils/useForceUpdate.ts
|
|
421
|
-
import * as React4 from "react";
|
|
422
|
-
function useForceUpdate() {
|
|
423
|
-
const [, forceUpdate] = React4.useReducer((x) => x + 1, 0);
|
|
424
|
-
return forceUpdate;
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
// src/hooks/utils/useInvalidateOnBlock.ts
|
|
428
|
-
import * as React7 from "react";
|
|
429
|
-
|
|
430
|
-
// src/hooks/network-status/useBlockNumber.ts
|
|
431
|
-
import { fetchBlockNumber } from "@wagmi/core";
|
|
432
|
-
import * as React5 from "react";
|
|
433
|
-
function queryKey2({ chainId, scopeKey }) {
|
|
434
|
-
return [{ entity: "blockNumber", chainId, scopeKey }];
|
|
435
|
-
}
|
|
436
|
-
function queryFn2({
|
|
437
|
-
queryKey: [{ chainId }]
|
|
438
|
-
}) {
|
|
439
|
-
return fetchBlockNumber({ chainId });
|
|
440
|
-
}
|
|
441
|
-
function useBlockNumber({
|
|
442
|
-
cacheTime = 0,
|
|
443
|
-
chainId: chainId_,
|
|
444
|
-
enabled = true,
|
|
445
|
-
scopeKey,
|
|
446
|
-
staleTime,
|
|
447
|
-
suspense,
|
|
448
|
-
watch = false,
|
|
449
|
-
onBlock,
|
|
450
|
-
onError,
|
|
451
|
-
onSettled,
|
|
452
|
-
onSuccess
|
|
453
|
-
} = {}) {
|
|
454
|
-
const chainId = useChainId({ chainId: chainId_ });
|
|
455
|
-
const publicClient = usePublicClient({ chainId });
|
|
456
|
-
const webSocketPublicClient = useWebSocketPublicClient({ chainId });
|
|
457
|
-
const queryClient = useQueryClient2();
|
|
458
|
-
React5.useEffect(() => {
|
|
459
|
-
if (!enabled)
|
|
460
|
-
return;
|
|
461
|
-
if (!watch && !onBlock)
|
|
462
|
-
return;
|
|
463
|
-
const publicClient_ = webSocketPublicClient ?? publicClient;
|
|
464
|
-
const unwatch = publicClient_.watchBlockNumber({
|
|
465
|
-
onBlockNumber: (blockNumber) => {
|
|
466
|
-
if (watch)
|
|
467
|
-
queryClient.setQueryData(queryKey2({ chainId, scopeKey }), blockNumber);
|
|
468
|
-
if (onBlock)
|
|
469
|
-
onBlock(blockNumber);
|
|
470
|
-
},
|
|
471
|
-
emitOnBegin: true
|
|
472
|
-
});
|
|
473
|
-
return unwatch;
|
|
474
|
-
}, [
|
|
475
|
-
chainId,
|
|
476
|
-
scopeKey,
|
|
477
|
-
onBlock,
|
|
478
|
-
publicClient,
|
|
479
|
-
queryClient,
|
|
480
|
-
watch,
|
|
481
|
-
webSocketPublicClient,
|
|
482
|
-
enabled
|
|
483
|
-
]);
|
|
484
|
-
return useQuery(queryKey2({ scopeKey, chainId }), queryFn2, {
|
|
485
|
-
cacheTime,
|
|
486
|
-
enabled,
|
|
487
|
-
staleTime,
|
|
488
|
-
suspense,
|
|
489
|
-
onError,
|
|
490
|
-
onSettled,
|
|
491
|
-
onSuccess
|
|
492
|
-
});
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
// src/hooks/network-status/useFeeData.ts
|
|
496
|
-
import { fetchFeeData } from "@wagmi/core";
|
|
497
|
-
import * as React6 from "react";
|
|
498
|
-
function queryKey3({
|
|
499
|
-
chainId,
|
|
500
|
-
formatUnits,
|
|
501
|
-
scopeKey
|
|
502
|
-
}) {
|
|
503
|
-
return [{ entity: "feeData", chainId, formatUnits, scopeKey }];
|
|
504
|
-
}
|
|
505
|
-
function queryFn3({
|
|
506
|
-
queryKey: [{ chainId, formatUnits }]
|
|
507
|
-
}) {
|
|
508
|
-
return fetchFeeData({ chainId, formatUnits });
|
|
509
|
-
}
|
|
510
|
-
function useFeeData({
|
|
511
|
-
cacheTime,
|
|
512
|
-
chainId: chainId_,
|
|
513
|
-
enabled = true,
|
|
514
|
-
formatUnits = "gwei",
|
|
515
|
-
scopeKey,
|
|
516
|
-
staleTime,
|
|
517
|
-
suspense,
|
|
518
|
-
watch,
|
|
519
|
-
onError,
|
|
520
|
-
onSettled,
|
|
521
|
-
onSuccess
|
|
522
|
-
} = {}) {
|
|
523
|
-
const chainId = useChainId({ chainId: chainId_ });
|
|
524
|
-
const queryKey_ = React6.useMemo(
|
|
525
|
-
() => queryKey3({
|
|
526
|
-
chainId,
|
|
527
|
-
formatUnits,
|
|
528
|
-
scopeKey
|
|
529
|
-
}),
|
|
530
|
-
[chainId, formatUnits, scopeKey]
|
|
531
|
-
);
|
|
532
|
-
const feeDataQuery = useQuery(queryKey_, queryFn3, {
|
|
533
|
-
cacheTime,
|
|
534
|
-
enabled,
|
|
535
|
-
staleTime,
|
|
536
|
-
suspense,
|
|
537
|
-
onError,
|
|
538
|
-
onSettled,
|
|
539
|
-
onSuccess
|
|
540
|
-
});
|
|
541
|
-
useInvalidateOnBlock({
|
|
542
|
-
chainId,
|
|
543
|
-
enabled: Boolean(enabled && watch),
|
|
544
|
-
queryKey: queryKey_
|
|
545
|
-
});
|
|
546
|
-
return feeDataQuery;
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
// src/hooks/utils/useInvalidateOnBlock.ts
|
|
550
|
-
function useInvalidateOnBlock({
|
|
551
|
-
chainId,
|
|
552
|
-
enabled,
|
|
553
|
-
queryKey: queryKey17
|
|
554
|
-
}) {
|
|
555
|
-
const queryClient = useQueryClient2();
|
|
556
|
-
const onBlock = React7.useCallback(
|
|
557
|
-
() => queryClient.invalidateQueries({ queryKey: queryKey17 }, { cancelRefetch: false }),
|
|
558
|
-
[queryClient, queryKey17]
|
|
559
|
-
);
|
|
560
|
-
useBlockNumber({
|
|
561
|
-
chainId,
|
|
562
|
-
enabled,
|
|
563
|
-
onBlock: enabled ? onBlock : void 0,
|
|
564
|
-
scopeKey: enabled ? void 0 : "idle"
|
|
565
|
-
});
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
// src/hooks/utils/useSyncExternalStoreWithTracked.ts
|
|
569
|
-
import { deepEqual } from "@wagmi/core";
|
|
570
|
-
import * as React8 from "react";
|
|
571
|
-
import { useSyncExternalStoreWithSelector as useSyncExternalStoreWithSelector3 } from "use-sync-external-store/shim/with-selector.js";
|
|
572
|
-
var isPlainObject2 = (obj) => typeof obj === "object" && !Array.isArray(obj);
|
|
573
|
-
function useSyncExternalStoreWithTracked(subscribe, getSnapshot, getServerSnapshot = getSnapshot, isEqual = deepEqual) {
|
|
574
|
-
const trackedKeys = React8.useRef([]);
|
|
575
|
-
const result = useSyncExternalStoreWithSelector3(
|
|
576
|
-
subscribe,
|
|
577
|
-
getSnapshot,
|
|
578
|
-
getServerSnapshot,
|
|
579
|
-
(x) => x,
|
|
580
|
-
(a, b) => {
|
|
581
|
-
if (isPlainObject2(a) && isPlainObject2(b) && trackedKeys.current.length) {
|
|
582
|
-
for (const key of trackedKeys.current) {
|
|
583
|
-
const equal = isEqual(
|
|
584
|
-
a[key],
|
|
585
|
-
b[key]
|
|
586
|
-
);
|
|
587
|
-
if (!equal)
|
|
588
|
-
return false;
|
|
589
|
-
}
|
|
590
|
-
return true;
|
|
591
|
-
}
|
|
592
|
-
return isEqual(a, b);
|
|
593
|
-
}
|
|
594
|
-
);
|
|
595
|
-
if (isPlainObject2(result)) {
|
|
596
|
-
const trackedResult = { ...result };
|
|
597
|
-
Object.defineProperties(
|
|
598
|
-
trackedResult,
|
|
599
|
-
Object.entries(trackedResult).reduce(
|
|
600
|
-
(res, [key, value]) => {
|
|
601
|
-
return {
|
|
602
|
-
...res,
|
|
603
|
-
[key]: {
|
|
604
|
-
configurable: false,
|
|
605
|
-
enumerable: true,
|
|
606
|
-
get: () => {
|
|
607
|
-
if (!trackedKeys.current.includes(key)) {
|
|
608
|
-
trackedKeys.current.push(key);
|
|
609
|
-
}
|
|
610
|
-
return value;
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
};
|
|
614
|
-
},
|
|
615
|
-
{}
|
|
616
|
-
)
|
|
617
|
-
);
|
|
618
|
-
return trackedResult;
|
|
619
|
-
}
|
|
620
|
-
return result;
|
|
621
|
-
}
|
|
622
|
-
|
|
623
|
-
// src/hooks/accounts/useAccount.ts
|
|
624
|
-
function useAccount({ onConnect, onDisconnect } = {}) {
|
|
625
|
-
const config = useConfig();
|
|
626
|
-
const watchAccount_ = React9.useCallback(
|
|
627
|
-
(callback) => watchAccount(callback),
|
|
628
|
-
[config]
|
|
629
|
-
);
|
|
630
|
-
const account = useSyncExternalStoreWithTracked(watchAccount_, getAccount);
|
|
631
|
-
const previousAccountRef = React9.useRef();
|
|
632
|
-
const previousAccount = previousAccountRef.current;
|
|
633
|
-
React9.useEffect(() => {
|
|
634
|
-
if (previousAccount?.status !== "connected" && account.status === "connected") {
|
|
635
|
-
onConnect?.({
|
|
636
|
-
address: account.address,
|
|
637
|
-
connector: account.connector,
|
|
638
|
-
isReconnected: previousAccount?.status === "reconnecting" || previousAccount?.status === void 0
|
|
639
|
-
});
|
|
640
|
-
}
|
|
641
|
-
if (previousAccount?.status === "connected" && account.status === "disconnected") {
|
|
642
|
-
onDisconnect?.();
|
|
643
|
-
}
|
|
644
|
-
previousAccountRef.current = account;
|
|
645
|
-
}, [onConnect, onDisconnect, previousAccount, account]);
|
|
646
|
-
return account;
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
// src/hooks/accounts/useBalance.ts
|
|
650
|
-
import { fetchBalance } from "@wagmi/core";
|
|
651
|
-
import * as React10 from "react";
|
|
652
|
-
function queryKey4({
|
|
653
|
-
address,
|
|
654
|
-
chainId,
|
|
655
|
-
formatUnits,
|
|
656
|
-
scopeKey,
|
|
657
|
-
token
|
|
658
|
-
}) {
|
|
659
|
-
return [
|
|
660
|
-
{
|
|
661
|
-
entity: "balance",
|
|
662
|
-
address,
|
|
663
|
-
chainId,
|
|
664
|
-
formatUnits,
|
|
665
|
-
scopeKey,
|
|
666
|
-
token
|
|
667
|
-
}
|
|
668
|
-
];
|
|
669
|
-
}
|
|
670
|
-
function queryFn4({
|
|
671
|
-
queryKey: [{ address, chainId, formatUnits, token }]
|
|
672
|
-
}) {
|
|
673
|
-
if (!address)
|
|
674
|
-
throw new Error("address is required");
|
|
675
|
-
return fetchBalance({ address, chainId, formatUnits, token });
|
|
676
|
-
}
|
|
677
|
-
function useBalance({
|
|
678
|
-
address,
|
|
679
|
-
cacheTime,
|
|
680
|
-
chainId: chainId_,
|
|
681
|
-
enabled = true,
|
|
682
|
-
formatUnits,
|
|
683
|
-
scopeKey,
|
|
684
|
-
staleTime,
|
|
685
|
-
suspense,
|
|
686
|
-
token,
|
|
687
|
-
watch,
|
|
688
|
-
onError,
|
|
689
|
-
onSettled,
|
|
690
|
-
onSuccess
|
|
691
|
-
} = {}) {
|
|
692
|
-
const chainId = useChainId({ chainId: chainId_ });
|
|
693
|
-
const queryKey_ = React10.useMemo(
|
|
694
|
-
() => queryKey4({ address, chainId, formatUnits, scopeKey, token }),
|
|
695
|
-
[address, chainId, formatUnits, scopeKey, token]
|
|
696
|
-
);
|
|
697
|
-
const balanceQuery = useQuery(queryKey_, queryFn4, {
|
|
698
|
-
cacheTime,
|
|
699
|
-
enabled: Boolean(enabled && address),
|
|
700
|
-
staleTime,
|
|
701
|
-
suspense,
|
|
702
|
-
onError,
|
|
703
|
-
onSettled,
|
|
704
|
-
onSuccess
|
|
705
|
-
});
|
|
706
|
-
useInvalidateOnBlock({
|
|
707
|
-
chainId,
|
|
708
|
-
enabled: Boolean(enabled && watch && address),
|
|
709
|
-
queryKey: queryKey_
|
|
710
|
-
});
|
|
711
|
-
return balanceQuery;
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
// src/hooks/accounts/useConnect.ts
|
|
715
|
-
import { connect } from "@wagmi/core";
|
|
716
|
-
import * as React11 from "react";
|
|
717
|
-
var mutationKey = (args) => [{ entity: "connect", ...args }];
|
|
718
|
-
var mutationFn = (args) => {
|
|
719
|
-
const { connector, chainId } = args;
|
|
720
|
-
if (!connector)
|
|
721
|
-
throw new Error("connector is required");
|
|
722
|
-
return connect({ connector, chainId });
|
|
723
|
-
};
|
|
724
|
-
function useConnect({
|
|
725
|
-
chainId,
|
|
726
|
-
connector,
|
|
727
|
-
onError,
|
|
728
|
-
onMutate,
|
|
729
|
-
onSettled,
|
|
730
|
-
onSuccess
|
|
731
|
-
} = {}) {
|
|
732
|
-
const config = useConfig();
|
|
733
|
-
const {
|
|
734
|
-
data,
|
|
735
|
-
error,
|
|
736
|
-
isError,
|
|
737
|
-
isIdle,
|
|
738
|
-
isLoading,
|
|
739
|
-
isSuccess,
|
|
740
|
-
mutate,
|
|
741
|
-
mutateAsync,
|
|
742
|
-
reset,
|
|
743
|
-
status,
|
|
744
|
-
variables
|
|
745
|
-
} = useMutation(mutationKey({ connector, chainId }), mutationFn, {
|
|
746
|
-
onError,
|
|
747
|
-
onMutate,
|
|
748
|
-
onSettled,
|
|
749
|
-
onSuccess
|
|
750
|
-
});
|
|
751
|
-
const connect2 = React11.useCallback(
|
|
752
|
-
(args) => {
|
|
753
|
-
return mutate({
|
|
754
|
-
chainId: args?.chainId ?? chainId,
|
|
755
|
-
connector: args?.connector ?? connector
|
|
756
|
-
});
|
|
757
|
-
},
|
|
758
|
-
[chainId, connector, mutate]
|
|
759
|
-
);
|
|
760
|
-
const connectAsync = React11.useCallback(
|
|
761
|
-
(args) => {
|
|
762
|
-
return mutateAsync({
|
|
763
|
-
chainId: args?.chainId ?? chainId,
|
|
764
|
-
connector: args?.connector ?? connector
|
|
765
|
-
});
|
|
766
|
-
},
|
|
767
|
-
[chainId, connector, mutateAsync]
|
|
768
|
-
);
|
|
769
|
-
return {
|
|
770
|
-
connect: connect2,
|
|
771
|
-
connectAsync,
|
|
772
|
-
connectors: config.connectors,
|
|
773
|
-
data,
|
|
774
|
-
error,
|
|
775
|
-
isError,
|
|
776
|
-
isIdle,
|
|
777
|
-
isLoading,
|
|
778
|
-
isSuccess,
|
|
779
|
-
pendingConnector: variables?.connector,
|
|
780
|
-
reset,
|
|
781
|
-
status,
|
|
782
|
-
variables
|
|
783
|
-
};
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
// src/hooks/accounts/useDisconnect.ts
|
|
787
|
-
import { disconnect } from "@wagmi/core";
|
|
788
|
-
var mutationKey2 = [{ entity: "disconnect" }];
|
|
789
|
-
var mutationFn2 = () => disconnect();
|
|
790
|
-
function useDisconnect({
|
|
791
|
-
onError,
|
|
792
|
-
onMutate,
|
|
793
|
-
onSettled,
|
|
794
|
-
onSuccess
|
|
795
|
-
} = {}) {
|
|
796
|
-
const {
|
|
797
|
-
error,
|
|
798
|
-
isError,
|
|
799
|
-
isIdle,
|
|
800
|
-
isLoading,
|
|
801
|
-
isSuccess,
|
|
802
|
-
mutate: disconnect2,
|
|
803
|
-
mutateAsync: disconnectAsync,
|
|
804
|
-
reset,
|
|
805
|
-
status
|
|
806
|
-
} = useMutation(mutationKey2, mutationFn2, {
|
|
807
|
-
...onError ? {
|
|
808
|
-
onError(error2, _variables, context) {
|
|
809
|
-
onError(error2, context);
|
|
810
|
-
}
|
|
811
|
-
} : {},
|
|
812
|
-
onMutate,
|
|
813
|
-
...onSettled ? {
|
|
814
|
-
onSettled(_data, error2, _variables, context) {
|
|
815
|
-
onSettled(error2, context);
|
|
816
|
-
}
|
|
817
|
-
} : {},
|
|
818
|
-
...onSuccess ? {
|
|
819
|
-
onSuccess(_data, _variables, context) {
|
|
820
|
-
onSuccess(context);
|
|
821
|
-
}
|
|
822
|
-
} : {}
|
|
823
|
-
});
|
|
824
|
-
return {
|
|
825
|
-
disconnect: disconnect2,
|
|
826
|
-
disconnectAsync,
|
|
827
|
-
error,
|
|
828
|
-
isError,
|
|
829
|
-
isIdle,
|
|
830
|
-
isLoading,
|
|
831
|
-
isSuccess,
|
|
832
|
-
reset,
|
|
833
|
-
status
|
|
834
|
-
};
|
|
835
|
-
}
|
|
836
|
-
|
|
837
|
-
// src/hooks/accounts/useNetwork.ts
|
|
838
|
-
import { getNetwork, watchNetwork } from "@wagmi/core";
|
|
839
|
-
import { useCallback as useCallback5 } from "react";
|
|
840
|
-
function useNetwork() {
|
|
841
|
-
const config = useConfig();
|
|
842
|
-
const watchNetwork_ = useCallback5(
|
|
843
|
-
(callback) => watchNetwork(callback),
|
|
844
|
-
[config]
|
|
845
|
-
);
|
|
846
|
-
return useSyncExternalStoreWithTracked(watchNetwork_, getNetwork);
|
|
847
|
-
}
|
|
848
|
-
|
|
849
|
-
// src/hooks/accounts/useSignMessage.ts
|
|
850
|
-
import { signMessage } from "@wagmi/core";
|
|
851
|
-
import * as React12 from "react";
|
|
852
|
-
var mutationKey3 = (args) => [{ entity: "signMessage", ...args }];
|
|
853
|
-
var mutationFn3 = (args) => {
|
|
854
|
-
const { message } = args;
|
|
855
|
-
if (!message)
|
|
856
|
-
throw new Error("message is required");
|
|
857
|
-
return signMessage({ message });
|
|
858
|
-
};
|
|
859
|
-
function useSignMessage({
|
|
860
|
-
message,
|
|
861
|
-
onError,
|
|
862
|
-
onMutate,
|
|
863
|
-
onSettled,
|
|
864
|
-
onSuccess
|
|
865
|
-
} = {}) {
|
|
866
|
-
const {
|
|
867
|
-
data,
|
|
868
|
-
error,
|
|
869
|
-
isError,
|
|
870
|
-
isIdle,
|
|
871
|
-
isLoading,
|
|
872
|
-
isSuccess,
|
|
873
|
-
mutate,
|
|
874
|
-
mutateAsync,
|
|
875
|
-
reset,
|
|
876
|
-
status,
|
|
877
|
-
variables
|
|
878
|
-
} = useMutation(mutationKey3({ message }), mutationFn3, {
|
|
879
|
-
onError,
|
|
880
|
-
onMutate,
|
|
881
|
-
onSettled,
|
|
882
|
-
onSuccess
|
|
883
|
-
});
|
|
884
|
-
const signMessage2 = React12.useCallback(
|
|
885
|
-
(args) => mutate(args || { message }),
|
|
886
|
-
[message, mutate]
|
|
887
|
-
);
|
|
888
|
-
const signMessageAsync = React12.useCallback(
|
|
889
|
-
(args) => mutateAsync(args || { message }),
|
|
890
|
-
[message, mutateAsync]
|
|
891
|
-
);
|
|
892
|
-
return {
|
|
893
|
-
data,
|
|
894
|
-
error,
|
|
895
|
-
isError,
|
|
896
|
-
isIdle,
|
|
897
|
-
isLoading,
|
|
898
|
-
isSuccess,
|
|
899
|
-
reset,
|
|
900
|
-
signMessage: signMessage2,
|
|
901
|
-
signMessageAsync,
|
|
902
|
-
status,
|
|
903
|
-
variables
|
|
904
|
-
};
|
|
905
|
-
}
|
|
906
|
-
|
|
907
|
-
// src/hooks/accounts/useSignTypedData.ts
|
|
908
|
-
import { signTypedData } from "@wagmi/core";
|
|
909
|
-
import * as React13 from "react";
|
|
910
|
-
function mutationKey4({ domain, types, message, primaryType }) {
|
|
911
|
-
return [
|
|
912
|
-
{ entity: "signTypedData", domain, types, message, primaryType }
|
|
913
|
-
];
|
|
914
|
-
}
|
|
915
|
-
function mutationFn4(args) {
|
|
916
|
-
const { domain, types, primaryType, message } = args;
|
|
917
|
-
if (!domain)
|
|
918
|
-
throw new Error("domain is required");
|
|
919
|
-
if (!types)
|
|
920
|
-
throw new Error("types is required");
|
|
921
|
-
if (!primaryType)
|
|
922
|
-
throw new Error("primaryType is required");
|
|
923
|
-
if (!message)
|
|
924
|
-
throw new Error("message is required");
|
|
925
|
-
return signTypedData({
|
|
926
|
-
domain,
|
|
927
|
-
message,
|
|
928
|
-
primaryType,
|
|
929
|
-
types
|
|
930
|
-
});
|
|
931
|
-
}
|
|
932
|
-
function useSignTypedData({
|
|
933
|
-
domain,
|
|
934
|
-
types,
|
|
935
|
-
message,
|
|
936
|
-
primaryType,
|
|
937
|
-
onError,
|
|
938
|
-
onMutate,
|
|
939
|
-
onSettled,
|
|
940
|
-
onSuccess
|
|
941
|
-
} = {}) {
|
|
942
|
-
const {
|
|
943
|
-
data,
|
|
944
|
-
error,
|
|
945
|
-
isError,
|
|
946
|
-
isIdle,
|
|
947
|
-
isLoading,
|
|
948
|
-
isSuccess,
|
|
949
|
-
mutate,
|
|
950
|
-
mutateAsync,
|
|
951
|
-
reset,
|
|
952
|
-
status,
|
|
953
|
-
variables
|
|
954
|
-
} = useMutation(
|
|
955
|
-
mutationKey4({
|
|
956
|
-
domain,
|
|
957
|
-
message,
|
|
958
|
-
primaryType,
|
|
959
|
-
types
|
|
960
|
-
}),
|
|
961
|
-
mutationFn4,
|
|
962
|
-
{
|
|
963
|
-
onError,
|
|
964
|
-
onMutate,
|
|
965
|
-
onSettled,
|
|
966
|
-
onSuccess
|
|
967
|
-
}
|
|
968
|
-
);
|
|
969
|
-
const signTypedData2 = React13.useCallback(
|
|
970
|
-
(args) => mutate({
|
|
971
|
-
domain: args?.domain ?? domain,
|
|
972
|
-
types: args?.types ?? types,
|
|
973
|
-
message: args?.message ?? message,
|
|
974
|
-
primaryType: args?.primaryType ?? primaryType
|
|
975
|
-
}),
|
|
976
|
-
[domain, types, primaryType, message, mutate]
|
|
977
|
-
);
|
|
978
|
-
const signTypedDataAsync = React13.useCallback(
|
|
979
|
-
(args) => mutateAsync({
|
|
980
|
-
domain: args?.domain ?? domain,
|
|
981
|
-
types: args?.types ?? types,
|
|
982
|
-
message: args?.message ?? message,
|
|
983
|
-
primaryType: args?.primaryType ?? primaryType
|
|
984
|
-
}),
|
|
985
|
-
[domain, types, primaryType, message, mutateAsync]
|
|
986
|
-
);
|
|
987
|
-
return {
|
|
988
|
-
data,
|
|
989
|
-
error,
|
|
990
|
-
isError,
|
|
991
|
-
isIdle,
|
|
992
|
-
isLoading,
|
|
993
|
-
isSuccess,
|
|
994
|
-
reset,
|
|
995
|
-
signTypedData: signTypedData2,
|
|
996
|
-
signTypedDataAsync,
|
|
997
|
-
status,
|
|
998
|
-
variables
|
|
999
|
-
};
|
|
1000
|
-
}
|
|
1001
|
-
|
|
1002
|
-
// src/hooks/accounts/useSwitchNetwork.ts
|
|
1003
|
-
import { switchNetwork } from "@wagmi/core";
|
|
1004
|
-
import * as React14 from "react";
|
|
1005
|
-
var mutationKey5 = (args) => [{ entity: "switchNetwork", ...args }];
|
|
1006
|
-
var mutationFn5 = (args) => {
|
|
1007
|
-
const { chainId } = args;
|
|
1008
|
-
if (!chainId)
|
|
1009
|
-
throw new Error("chainId is required");
|
|
1010
|
-
return switchNetwork({ chainId });
|
|
1011
|
-
};
|
|
1012
|
-
function useSwitchNetwork({
|
|
1013
|
-
chainId,
|
|
1014
|
-
throwForSwitchChainNotSupported,
|
|
1015
|
-
onError,
|
|
1016
|
-
onMutate,
|
|
1017
|
-
onSettled,
|
|
1018
|
-
onSuccess
|
|
1019
|
-
} = {}) {
|
|
1020
|
-
const config = useConfig();
|
|
1021
|
-
const forceUpdate = useForceUpdate();
|
|
1022
|
-
const {
|
|
1023
|
-
data,
|
|
1024
|
-
error,
|
|
1025
|
-
isError,
|
|
1026
|
-
isIdle,
|
|
1027
|
-
isLoading,
|
|
1028
|
-
isSuccess,
|
|
1029
|
-
mutate,
|
|
1030
|
-
mutateAsync,
|
|
1031
|
-
reset,
|
|
1032
|
-
status,
|
|
1033
|
-
variables
|
|
1034
|
-
} = useMutation(mutationKey5({ chainId }), mutationFn5, {
|
|
1035
|
-
onError,
|
|
1036
|
-
onMutate,
|
|
1037
|
-
onSettled,
|
|
1038
|
-
onSuccess
|
|
1039
|
-
});
|
|
1040
|
-
const switchNetwork_ = React14.useCallback(
|
|
1041
|
-
(chainId_) => mutate({ chainId: chainId_ ?? chainId }),
|
|
1042
|
-
[chainId, mutate]
|
|
1043
|
-
);
|
|
1044
|
-
const switchNetworkAsync_ = React14.useCallback(
|
|
1045
|
-
(chainId_) => mutateAsync({ chainId: chainId_ ?? chainId }),
|
|
1046
|
-
[chainId, mutateAsync]
|
|
1047
|
-
);
|
|
1048
|
-
React14.useEffect(() => {
|
|
1049
|
-
const unwatch = config.subscribe(
|
|
1050
|
-
({ chains, connector }) => ({
|
|
1051
|
-
chains,
|
|
1052
|
-
connector
|
|
1053
|
-
}),
|
|
1054
|
-
forceUpdate
|
|
1055
|
-
);
|
|
1056
|
-
return unwatch;
|
|
1057
|
-
}, [config, forceUpdate]);
|
|
1058
|
-
let switchNetwork2;
|
|
1059
|
-
let switchNetworkAsync;
|
|
1060
|
-
const supportsSwitchChain = !!config.connector?.switchChain;
|
|
1061
|
-
if (throwForSwitchChainNotSupported || supportsSwitchChain) {
|
|
1062
|
-
switchNetwork2 = switchNetwork_;
|
|
1063
|
-
switchNetworkAsync = switchNetworkAsync_;
|
|
1064
|
-
}
|
|
1065
|
-
return {
|
|
1066
|
-
chains: config.chains ?? [],
|
|
1067
|
-
data,
|
|
1068
|
-
error,
|
|
1069
|
-
isError,
|
|
1070
|
-
isIdle,
|
|
1071
|
-
isLoading,
|
|
1072
|
-
isSuccess,
|
|
1073
|
-
pendingChainId: variables?.chainId,
|
|
1074
|
-
reset,
|
|
1075
|
-
status,
|
|
1076
|
-
switchNetwork: switchNetwork2,
|
|
1077
|
-
switchNetworkAsync,
|
|
1078
|
-
variables
|
|
1079
|
-
};
|
|
1080
|
-
}
|
|
1081
|
-
|
|
1082
|
-
// src/hooks/contracts/useContractEvent.ts
|
|
1083
|
-
import * as React15 from "react";
|
|
1084
|
-
function useContractEvent({
|
|
1085
|
-
address,
|
|
1086
|
-
chainId,
|
|
1087
|
-
abi,
|
|
1088
|
-
listener,
|
|
1089
|
-
eventName
|
|
1090
|
-
} = {}) {
|
|
1091
|
-
const publicClient = usePublicClient({ chainId });
|
|
1092
|
-
const webSocketPublicClient = useWebSocketPublicClient({ chainId });
|
|
1093
|
-
const unwatch = React15.useRef();
|
|
1094
|
-
React15.useEffect(() => {
|
|
1095
|
-
if (!abi || !address || !eventName)
|
|
1096
|
-
return;
|
|
1097
|
-
const publicClient_ = webSocketPublicClient || publicClient;
|
|
1098
|
-
unwatch.current = publicClient_.watchContractEvent({
|
|
1099
|
-
abi,
|
|
1100
|
-
address,
|
|
1101
|
-
eventName,
|
|
1102
|
-
onLogs: listener
|
|
1103
|
-
});
|
|
1104
|
-
return unwatch.current;
|
|
1105
|
-
}, [abi, address, eventName, publicClient.uid, webSocketPublicClient?.uid]);
|
|
1106
|
-
return unwatch.current;
|
|
1107
|
-
}
|
|
1108
|
-
|
|
1109
|
-
// src/hooks/contracts/useContractInfiniteReads.ts
|
|
1110
|
-
import { replaceEqualDeep } from "@tanstack/react-query";
|
|
1111
|
-
import { deepEqual as deepEqual2, readContracts } from "@wagmi/core";
|
|
1112
|
-
import * as React16 from "react";
|
|
1113
|
-
function queryKey5({
|
|
1114
|
-
allowFailure,
|
|
1115
|
-
blockNumber,
|
|
1116
|
-
blockTag,
|
|
1117
|
-
cacheKey,
|
|
1118
|
-
scopeKey
|
|
1119
|
-
}) {
|
|
1120
|
-
return [
|
|
1121
|
-
{
|
|
1122
|
-
entity: "readContractsInfinite",
|
|
1123
|
-
allowFailure,
|
|
1124
|
-
blockNumber,
|
|
1125
|
-
blockTag,
|
|
1126
|
-
cacheKey,
|
|
1127
|
-
scopeKey
|
|
1128
|
-
}
|
|
1129
|
-
];
|
|
1130
|
-
}
|
|
1131
|
-
function queryFn5({
|
|
1132
|
-
contracts
|
|
1133
|
-
}) {
|
|
1134
|
-
return ({
|
|
1135
|
-
queryKey: [{ allowFailure, blockNumber, blockTag }],
|
|
1136
|
-
pageParam
|
|
1137
|
-
}) => {
|
|
1138
|
-
return readContracts({
|
|
1139
|
-
allowFailure,
|
|
1140
|
-
blockNumber,
|
|
1141
|
-
blockTag,
|
|
1142
|
-
contracts: contracts(pageParam || void 0)
|
|
1143
|
-
});
|
|
1144
|
-
};
|
|
1145
|
-
}
|
|
1146
|
-
function useContractInfiniteReads({
|
|
1147
|
-
allowFailure,
|
|
1148
|
-
blockNumber,
|
|
1149
|
-
blockTag,
|
|
1150
|
-
cacheKey,
|
|
1151
|
-
cacheTime,
|
|
1152
|
-
contracts,
|
|
1153
|
-
enabled: enabled_ = true,
|
|
1154
|
-
getNextPageParam,
|
|
1155
|
-
isDataEqual,
|
|
1156
|
-
keepPreviousData,
|
|
1157
|
-
onError,
|
|
1158
|
-
onSettled,
|
|
1159
|
-
onSuccess,
|
|
1160
|
-
scopeKey,
|
|
1161
|
-
select,
|
|
1162
|
-
staleTime,
|
|
1163
|
-
structuralSharing = (oldData, newData) => deepEqual2(oldData, newData) ? oldData : replaceEqualDeep(oldData, newData),
|
|
1164
|
-
suspense
|
|
1165
|
-
}) {
|
|
1166
|
-
const queryKey_ = React16.useMemo(
|
|
1167
|
-
() => queryKey5({ allowFailure, blockNumber, blockTag, cacheKey, scopeKey }),
|
|
1168
|
-
[allowFailure, blockNumber, blockTag, cacheKey, scopeKey]
|
|
1169
|
-
);
|
|
1170
|
-
const enabled = React16.useMemo(() => {
|
|
1171
|
-
const enabled2 = Boolean(enabled_ && contracts);
|
|
1172
|
-
return enabled2;
|
|
1173
|
-
}, [contracts, enabled_]);
|
|
1174
|
-
return useInfiniteQuery(queryKey_, queryFn5({ contracts }), {
|
|
1175
|
-
cacheTime,
|
|
1176
|
-
enabled,
|
|
1177
|
-
getNextPageParam,
|
|
1178
|
-
isDataEqual,
|
|
1179
|
-
keepPreviousData,
|
|
1180
|
-
select,
|
|
1181
|
-
staleTime,
|
|
1182
|
-
structuralSharing,
|
|
1183
|
-
suspense,
|
|
1184
|
-
onError,
|
|
1185
|
-
onSettled,
|
|
1186
|
-
onSuccess
|
|
1187
|
-
});
|
|
1188
|
-
}
|
|
1189
|
-
function paginatedIndexesConfig(fn, {
|
|
1190
|
-
perPage,
|
|
1191
|
-
start,
|
|
1192
|
-
direction
|
|
1193
|
-
}) {
|
|
1194
|
-
const contracts = (page = 0) => [...Array(perPage).keys()].map((index) => {
|
|
1195
|
-
return direction === "increment" ? start + index + page * perPage : start - index - page * perPage;
|
|
1196
|
-
}).filter((index) => index >= 0).flatMap(fn);
|
|
1197
|
-
return {
|
|
1198
|
-
contracts,
|
|
1199
|
-
getNextPageParam(lastPage, pages) {
|
|
1200
|
-
return lastPage?.length === perPage ? pages.length : void 0;
|
|
1201
|
-
}
|
|
1202
|
-
};
|
|
1203
|
-
}
|
|
1204
|
-
|
|
1205
|
-
// src/hooks/contracts/useContractRead.ts
|
|
1206
|
-
import { replaceEqualDeep as replaceEqualDeep2 } from "@tanstack/react-query";
|
|
1207
|
-
import { deepEqual as deepEqual3, readContract } from "@wagmi/core";
|
|
1208
|
-
import * as React17 from "react";
|
|
1209
|
-
function queryKey6({
|
|
1210
|
-
account,
|
|
1211
|
-
address,
|
|
1212
|
-
args,
|
|
1213
|
-
blockNumber,
|
|
1214
|
-
blockTag,
|
|
1215
|
-
chainId,
|
|
1216
|
-
functionName,
|
|
1217
|
-
scopeKey
|
|
1218
|
-
}) {
|
|
1219
|
-
return [
|
|
1220
|
-
{
|
|
1221
|
-
entity: "readContract",
|
|
1222
|
-
account,
|
|
1223
|
-
address,
|
|
1224
|
-
args,
|
|
1225
|
-
blockNumber,
|
|
1226
|
-
blockTag,
|
|
1227
|
-
chainId,
|
|
1228
|
-
functionName,
|
|
1229
|
-
scopeKey
|
|
1230
|
-
}
|
|
1231
|
-
];
|
|
1232
|
-
}
|
|
1233
|
-
function queryFn6({ abi }) {
|
|
1234
|
-
return async ({
|
|
1235
|
-
queryKey: [
|
|
1236
|
-
{ account, address, args, blockNumber, blockTag, chainId, functionName }
|
|
1237
|
-
]
|
|
1238
|
-
}) => {
|
|
1239
|
-
if (!abi)
|
|
1240
|
-
throw new Error("abi is required");
|
|
1241
|
-
if (!address)
|
|
1242
|
-
throw new Error("address is required");
|
|
1243
|
-
return await readContract({
|
|
1244
|
-
account,
|
|
1245
|
-
address,
|
|
1246
|
-
args,
|
|
1247
|
-
blockNumber,
|
|
1248
|
-
blockTag,
|
|
1249
|
-
chainId,
|
|
1250
|
-
abi,
|
|
1251
|
-
functionName
|
|
1252
|
-
}) ?? null;
|
|
1253
|
-
};
|
|
1254
|
-
}
|
|
1255
|
-
function useContractRead({
|
|
1256
|
-
abi,
|
|
1257
|
-
address,
|
|
1258
|
-
account,
|
|
1259
|
-
args,
|
|
1260
|
-
blockNumber: blockNumberOverride,
|
|
1261
|
-
blockTag,
|
|
1262
|
-
cacheOnBlock = false,
|
|
1263
|
-
cacheTime,
|
|
1264
|
-
chainId: chainId_,
|
|
1265
|
-
enabled: enabled_ = true,
|
|
1266
|
-
functionName,
|
|
1267
|
-
isDataEqual,
|
|
1268
|
-
keepPreviousData,
|
|
1269
|
-
onError,
|
|
1270
|
-
onSettled,
|
|
1271
|
-
onSuccess,
|
|
1272
|
-
scopeKey,
|
|
1273
|
-
select,
|
|
1274
|
-
staleTime,
|
|
1275
|
-
structuralSharing = (oldData, newData) => deepEqual3(oldData, newData) ? oldData : replaceEqualDeep2(oldData, newData),
|
|
1276
|
-
suspense,
|
|
1277
|
-
watch
|
|
1278
|
-
} = {}) {
|
|
1279
|
-
const chainId = useChainId({ chainId: chainId_ });
|
|
1280
|
-
const { data: blockNumber_ } = useBlockNumber({
|
|
1281
|
-
chainId,
|
|
1282
|
-
enabled: watch || cacheOnBlock,
|
|
1283
|
-
scopeKey: watch || cacheOnBlock ? void 0 : "idle",
|
|
1284
|
-
watch
|
|
1285
|
-
});
|
|
1286
|
-
const blockNumber = blockNumberOverride ?? blockNumber_;
|
|
1287
|
-
const queryKey_ = React17.useMemo(
|
|
1288
|
-
() => queryKey6({
|
|
1289
|
-
account,
|
|
1290
|
-
address,
|
|
1291
|
-
args,
|
|
1292
|
-
blockNumber: cacheOnBlock ? blockNumber : void 0,
|
|
1293
|
-
blockTag,
|
|
1294
|
-
chainId,
|
|
1295
|
-
functionName,
|
|
1296
|
-
scopeKey
|
|
1297
|
-
}),
|
|
1298
|
-
[
|
|
1299
|
-
account,
|
|
1300
|
-
address,
|
|
1301
|
-
args,
|
|
1302
|
-
blockNumber,
|
|
1303
|
-
blockTag,
|
|
1304
|
-
cacheOnBlock,
|
|
1305
|
-
chainId,
|
|
1306
|
-
functionName,
|
|
1307
|
-
scopeKey
|
|
1308
|
-
]
|
|
1309
|
-
);
|
|
1310
|
-
const enabled = React17.useMemo(() => {
|
|
1311
|
-
let enabled2 = Boolean(enabled_ && abi && address && functionName);
|
|
1312
|
-
if (cacheOnBlock)
|
|
1313
|
-
enabled2 = Boolean(enabled2 && blockNumber);
|
|
1314
|
-
return enabled2;
|
|
1315
|
-
}, [abi, address, blockNumber, cacheOnBlock, enabled_, functionName]);
|
|
1316
|
-
useInvalidateOnBlock({
|
|
1317
|
-
chainId,
|
|
1318
|
-
enabled: Boolean(enabled && watch && !cacheOnBlock),
|
|
1319
|
-
queryKey: queryKey_
|
|
1320
|
-
});
|
|
1321
|
-
return useQuery(
|
|
1322
|
-
queryKey_,
|
|
1323
|
-
queryFn6({
|
|
1324
|
-
abi
|
|
1325
|
-
}),
|
|
1326
|
-
{
|
|
1327
|
-
cacheTime,
|
|
1328
|
-
enabled,
|
|
1329
|
-
isDataEqual,
|
|
1330
|
-
keepPreviousData,
|
|
1331
|
-
select,
|
|
1332
|
-
staleTime,
|
|
1333
|
-
structuralSharing,
|
|
1334
|
-
suspense,
|
|
1335
|
-
onError,
|
|
1336
|
-
onSettled,
|
|
1337
|
-
onSuccess
|
|
1338
|
-
}
|
|
1339
|
-
);
|
|
1340
|
-
}
|
|
1341
|
-
|
|
1342
|
-
// src/hooks/contracts/useContractReads.ts
|
|
1343
|
-
import { replaceEqualDeep as replaceEqualDeep3 } from "@tanstack/react-query";
|
|
1344
|
-
import { deepEqual as deepEqual4, readContracts as readContracts2 } from "@wagmi/core";
|
|
1345
|
-
import * as React18 from "react";
|
|
1346
|
-
function queryKey7({
|
|
1347
|
-
allowFailure,
|
|
1348
|
-
blockNumber,
|
|
1349
|
-
blockTag,
|
|
1350
|
-
chainId,
|
|
1351
|
-
contracts,
|
|
1352
|
-
scopeKey
|
|
1353
|
-
}) {
|
|
1354
|
-
return [
|
|
1355
|
-
{
|
|
1356
|
-
entity: "readContracts",
|
|
1357
|
-
allowFailure,
|
|
1358
|
-
blockNumber,
|
|
1359
|
-
blockTag,
|
|
1360
|
-
chainId,
|
|
1361
|
-
scopeKey,
|
|
1362
|
-
contracts: (contracts ?? []).map(({ address, args, chainId: chainId2, functionName }) => ({
|
|
1363
|
-
address,
|
|
1364
|
-
args,
|
|
1365
|
-
chainId: chainId2,
|
|
1366
|
-
functionName
|
|
1367
|
-
}))
|
|
1368
|
-
}
|
|
1369
|
-
];
|
|
1370
|
-
}
|
|
1371
|
-
function queryFn7({ abis }) {
|
|
1372
|
-
return ({
|
|
1373
|
-
queryKey: [{ allowFailure, blockNumber, blockTag, contracts: contracts_ }]
|
|
1374
|
-
}) => {
|
|
1375
|
-
const contracts = contracts_.map((contract, i) => ({
|
|
1376
|
-
...contract,
|
|
1377
|
-
abi: abis[i]
|
|
1378
|
-
}));
|
|
1379
|
-
return readContracts2({
|
|
1380
|
-
allowFailure,
|
|
1381
|
-
contracts,
|
|
1382
|
-
blockNumber,
|
|
1383
|
-
blockTag
|
|
1384
|
-
});
|
|
1385
|
-
};
|
|
1386
|
-
}
|
|
1387
|
-
function useContractReads({
|
|
1388
|
-
allowFailure: allowFailure_,
|
|
1389
|
-
blockNumber: blockNumberOverride,
|
|
1390
|
-
blockTag,
|
|
1391
|
-
cacheOnBlock = false,
|
|
1392
|
-
cacheTime,
|
|
1393
|
-
contracts,
|
|
1394
|
-
enabled: enabled_ = true,
|
|
1395
|
-
isDataEqual,
|
|
1396
|
-
keepPreviousData,
|
|
1397
|
-
onError,
|
|
1398
|
-
onSettled,
|
|
1399
|
-
onSuccess,
|
|
1400
|
-
scopeKey,
|
|
1401
|
-
select,
|
|
1402
|
-
staleTime,
|
|
1403
|
-
structuralSharing = (oldData, newData) => deepEqual4(oldData, newData) ? oldData : replaceEqualDeep3(oldData, newData),
|
|
1404
|
-
suspense,
|
|
1405
|
-
watch
|
|
1406
|
-
} = {}) {
|
|
1407
|
-
const allowFailure = allowFailure_ ?? true;
|
|
1408
|
-
const { data: blockNumber_ } = useBlockNumber({
|
|
1409
|
-
enabled: watch || cacheOnBlock,
|
|
1410
|
-
watch
|
|
1411
|
-
});
|
|
1412
|
-
const chainId = useChainId();
|
|
1413
|
-
const blockNumber = blockNumberOverride ?? blockNumber_;
|
|
1414
|
-
const queryKey_ = React18.useMemo(
|
|
1415
|
-
() => queryKey7({
|
|
1416
|
-
allowFailure,
|
|
1417
|
-
blockNumber: cacheOnBlock ? blockNumber : void 0,
|
|
1418
|
-
blockTag,
|
|
1419
|
-
chainId,
|
|
1420
|
-
contracts,
|
|
1421
|
-
scopeKey
|
|
1422
|
-
}),
|
|
1423
|
-
[
|
|
1424
|
-
allowFailure,
|
|
1425
|
-
blockNumber,
|
|
1426
|
-
blockTag,
|
|
1427
|
-
cacheOnBlock,
|
|
1428
|
-
chainId,
|
|
1429
|
-
scopeKey,
|
|
1430
|
-
contracts
|
|
1431
|
-
]
|
|
1432
|
-
);
|
|
1433
|
-
const enabled = React18.useMemo(() => {
|
|
1434
|
-
let enabled2 = Boolean(
|
|
1435
|
-
enabled_ && contracts?.every(
|
|
1436
|
-
(x) => x.abi && x.address && x.functionName
|
|
1437
|
-
)
|
|
1438
|
-
);
|
|
1439
|
-
if (cacheOnBlock)
|
|
1440
|
-
enabled2 = Boolean(enabled2 && blockNumber);
|
|
1441
|
-
return enabled2;
|
|
1442
|
-
}, [blockNumber, cacheOnBlock, contracts, enabled_]);
|
|
1443
|
-
useInvalidateOnBlock({
|
|
1444
|
-
enabled: Boolean(enabled && watch && !cacheOnBlock),
|
|
1445
|
-
queryKey: queryKey_
|
|
1446
|
-
});
|
|
1447
|
-
const abis = (contracts ?? []).map(
|
|
1448
|
-
({ abi }) => abi
|
|
1449
|
-
);
|
|
1450
|
-
return useQuery(queryKey_, queryFn7({ abis }), {
|
|
1451
|
-
cacheTime,
|
|
1452
|
-
enabled,
|
|
1453
|
-
isDataEqual,
|
|
1454
|
-
keepPreviousData,
|
|
1455
|
-
staleTime,
|
|
1456
|
-
select,
|
|
1457
|
-
structuralSharing,
|
|
1458
|
-
suspense,
|
|
1459
|
-
onError,
|
|
1460
|
-
onSettled,
|
|
1461
|
-
onSuccess
|
|
1462
|
-
});
|
|
1463
|
-
}
|
|
1464
|
-
|
|
1465
|
-
// src/hooks/contracts/useContractWrite.ts
|
|
1466
|
-
import { writeContract } from "@wagmi/core";
|
|
1467
|
-
import { getSendTransactionParameters } from "@wagmi/core/internal";
|
|
1468
|
-
import * as React19 from "react";
|
|
1469
|
-
function mutationKey6({
|
|
1470
|
-
address,
|
|
1471
|
-
abi,
|
|
1472
|
-
functionName,
|
|
1473
|
-
...config
|
|
1474
|
-
}) {
|
|
1475
|
-
const {
|
|
1476
|
-
args,
|
|
1477
|
-
accessList,
|
|
1478
|
-
account,
|
|
1479
|
-
gas,
|
|
1480
|
-
gasPrice,
|
|
1481
|
-
maxFeePerGas,
|
|
1482
|
-
maxPriorityFeePerGas,
|
|
1483
|
-
nonce,
|
|
1484
|
-
request,
|
|
1485
|
-
value
|
|
1486
|
-
} = config;
|
|
1487
|
-
return [
|
|
1488
|
-
{
|
|
1489
|
-
entity: "writeContract",
|
|
1490
|
-
address,
|
|
1491
|
-
args,
|
|
1492
|
-
abi,
|
|
1493
|
-
accessList,
|
|
1494
|
-
account,
|
|
1495
|
-
functionName,
|
|
1496
|
-
gas,
|
|
1497
|
-
gasPrice,
|
|
1498
|
-
maxFeePerGas,
|
|
1499
|
-
maxPriorityFeePerGas,
|
|
1500
|
-
nonce,
|
|
1501
|
-
request,
|
|
1502
|
-
value
|
|
1503
|
-
}
|
|
1504
|
-
];
|
|
1505
|
-
}
|
|
1506
|
-
function mutationFn6(config) {
|
|
1507
|
-
if (config.mode === "prepared") {
|
|
1508
|
-
if (!config.request)
|
|
1509
|
-
throw new Error("request is required");
|
|
1510
|
-
return writeContract({
|
|
1511
|
-
mode: "prepared",
|
|
1512
|
-
request: config.request
|
|
1513
|
-
});
|
|
1514
|
-
}
|
|
1515
|
-
if (!config.address)
|
|
1516
|
-
throw new Error("address is required");
|
|
1517
|
-
if (!config.abi)
|
|
1518
|
-
throw new Error("abi is required");
|
|
1519
|
-
if (!config.functionName)
|
|
1520
|
-
throw new Error("functionName is required");
|
|
1521
|
-
return writeContract({
|
|
1522
|
-
address: config.address,
|
|
1523
|
-
args: config.args,
|
|
1524
|
-
chainId: config.chainId,
|
|
1525
|
-
abi: config.abi,
|
|
1526
|
-
functionName: config.functionName,
|
|
1527
|
-
accessList: config.accessList,
|
|
1528
|
-
account: config.account,
|
|
1529
|
-
gas: config.gas,
|
|
1530
|
-
gasPrice: config.gasPrice,
|
|
1531
|
-
maxFeePerGas: config.maxFeePerGas,
|
|
1532
|
-
maxPriorityFeePerGas: config.maxPriorityFeePerGas,
|
|
1533
|
-
nonce: config.nonce,
|
|
1534
|
-
value: config.value
|
|
1535
|
-
});
|
|
1536
|
-
}
|
|
1537
|
-
function useContractWrite(config) {
|
|
1538
|
-
const { address, abi, args, chainId, functionName, mode, request } = config;
|
|
1539
|
-
const {
|
|
1540
|
-
accessList,
|
|
1541
|
-
account,
|
|
1542
|
-
gas,
|
|
1543
|
-
gasPrice,
|
|
1544
|
-
maxFeePerGas,
|
|
1545
|
-
maxPriorityFeePerGas,
|
|
1546
|
-
nonce,
|
|
1547
|
-
value
|
|
1548
|
-
} = getSendTransactionParameters(config);
|
|
1549
|
-
const {
|
|
1550
|
-
data,
|
|
1551
|
-
error,
|
|
1552
|
-
isError,
|
|
1553
|
-
isIdle,
|
|
1554
|
-
isLoading,
|
|
1555
|
-
isSuccess,
|
|
1556
|
-
mutate,
|
|
1557
|
-
mutateAsync,
|
|
1558
|
-
reset,
|
|
1559
|
-
status,
|
|
1560
|
-
variables
|
|
1561
|
-
} = useMutation(
|
|
1562
|
-
mutationKey6({
|
|
1563
|
-
address,
|
|
1564
|
-
abi,
|
|
1565
|
-
functionName,
|
|
1566
|
-
chainId,
|
|
1567
|
-
mode,
|
|
1568
|
-
args,
|
|
1569
|
-
accessList,
|
|
1570
|
-
account,
|
|
1571
|
-
gas,
|
|
1572
|
-
gasPrice,
|
|
1573
|
-
maxFeePerGas,
|
|
1574
|
-
maxPriorityFeePerGas,
|
|
1575
|
-
nonce,
|
|
1576
|
-
request,
|
|
1577
|
-
value
|
|
1578
|
-
}),
|
|
1579
|
-
mutationFn6,
|
|
1580
|
-
{
|
|
1581
|
-
onError: config.onError,
|
|
1582
|
-
onMutate: config.onMutate,
|
|
1583
|
-
onSettled: config.onSettled,
|
|
1584
|
-
onSuccess: config.onSuccess
|
|
1585
|
-
}
|
|
1586
|
-
);
|
|
1587
|
-
const write = React19.useMemo(() => {
|
|
1588
|
-
if (config.mode === "prepared") {
|
|
1589
|
-
if (!request)
|
|
1590
|
-
return void 0;
|
|
1591
|
-
return () => mutate({
|
|
1592
|
-
mode: "prepared",
|
|
1593
|
-
request: config.request,
|
|
1594
|
-
chainId: config.chainId
|
|
1595
|
-
});
|
|
1596
|
-
}
|
|
1597
|
-
return (overrideConfig) => mutate({
|
|
1598
|
-
address,
|
|
1599
|
-
args,
|
|
1600
|
-
abi,
|
|
1601
|
-
functionName,
|
|
1602
|
-
chainId,
|
|
1603
|
-
accessList,
|
|
1604
|
-
account,
|
|
1605
|
-
gas,
|
|
1606
|
-
gasPrice,
|
|
1607
|
-
maxFeePerGas,
|
|
1608
|
-
maxPriorityFeePerGas,
|
|
1609
|
-
nonce,
|
|
1610
|
-
value,
|
|
1611
|
-
...overrideConfig
|
|
1612
|
-
});
|
|
1613
|
-
}, [
|
|
1614
|
-
accessList,
|
|
1615
|
-
account,
|
|
1616
|
-
abi,
|
|
1617
|
-
address,
|
|
1618
|
-
args,
|
|
1619
|
-
chainId,
|
|
1620
|
-
config.chainId,
|
|
1621
|
-
config.mode,
|
|
1622
|
-
config.request,
|
|
1623
|
-
functionName,
|
|
1624
|
-
gas,
|
|
1625
|
-
gasPrice,
|
|
1626
|
-
maxFeePerGas,
|
|
1627
|
-
maxPriorityFeePerGas,
|
|
1628
|
-
mutate,
|
|
1629
|
-
nonce,
|
|
1630
|
-
request,
|
|
1631
|
-
value
|
|
1632
|
-
]);
|
|
1633
|
-
const writeAsync = React19.useMemo(() => {
|
|
1634
|
-
if (config.mode === "prepared") {
|
|
1635
|
-
if (!request)
|
|
1636
|
-
return void 0;
|
|
1637
|
-
return () => mutateAsync({
|
|
1638
|
-
mode: "prepared",
|
|
1639
|
-
request: config.request
|
|
1640
|
-
});
|
|
1641
|
-
}
|
|
1642
|
-
return (overrideConfig) => mutateAsync({
|
|
1643
|
-
address,
|
|
1644
|
-
args,
|
|
1645
|
-
abi,
|
|
1646
|
-
chainId,
|
|
1647
|
-
functionName,
|
|
1648
|
-
accessList,
|
|
1649
|
-
account,
|
|
1650
|
-
gas,
|
|
1651
|
-
gasPrice,
|
|
1652
|
-
maxFeePerGas,
|
|
1653
|
-
maxPriorityFeePerGas,
|
|
1654
|
-
nonce,
|
|
1655
|
-
value,
|
|
1656
|
-
...overrideConfig
|
|
1657
|
-
});
|
|
1658
|
-
}, [
|
|
1659
|
-
accessList,
|
|
1660
|
-
account,
|
|
1661
|
-
abi,
|
|
1662
|
-
address,
|
|
1663
|
-
args,
|
|
1664
|
-
chainId,
|
|
1665
|
-
config.mode,
|
|
1666
|
-
config.request,
|
|
1667
|
-
functionName,
|
|
1668
|
-
gas,
|
|
1669
|
-
gasPrice,
|
|
1670
|
-
maxFeePerGas,
|
|
1671
|
-
maxPriorityFeePerGas,
|
|
1672
|
-
mutateAsync,
|
|
1673
|
-
nonce,
|
|
1674
|
-
request,
|
|
1675
|
-
value
|
|
1676
|
-
]);
|
|
1677
|
-
return {
|
|
1678
|
-
data,
|
|
1679
|
-
error,
|
|
1680
|
-
isError,
|
|
1681
|
-
isIdle,
|
|
1682
|
-
isLoading,
|
|
1683
|
-
isSuccess,
|
|
1684
|
-
reset,
|
|
1685
|
-
status,
|
|
1686
|
-
variables,
|
|
1687
|
-
write,
|
|
1688
|
-
writeAsync
|
|
1689
|
-
};
|
|
1690
|
-
}
|
|
1691
|
-
|
|
1692
|
-
// src/hooks/contracts/usePrepareContractWrite.ts
|
|
1693
|
-
import { prepareWriteContract } from "@wagmi/core";
|
|
1694
|
-
import { getCallParameters } from "@wagmi/core/internal";
|
|
1695
|
-
function queryKey8({
|
|
1696
|
-
accessList,
|
|
1697
|
-
account,
|
|
1698
|
-
activeChainId,
|
|
1699
|
-
args,
|
|
1700
|
-
address,
|
|
1701
|
-
blockNumber,
|
|
1702
|
-
blockTag,
|
|
1703
|
-
chainId,
|
|
1704
|
-
functionName,
|
|
1705
|
-
gas,
|
|
1706
|
-
gasPrice,
|
|
1707
|
-
maxFeePerGas,
|
|
1708
|
-
maxPriorityFeePerGas,
|
|
1709
|
-
nonce,
|
|
1710
|
-
scopeKey,
|
|
1711
|
-
walletClientAddress,
|
|
1712
|
-
value
|
|
1713
|
-
}) {
|
|
1714
|
-
return [
|
|
1715
|
-
{
|
|
1716
|
-
entity: "prepareContractTransaction",
|
|
1717
|
-
accessList,
|
|
1718
|
-
account,
|
|
1719
|
-
activeChainId,
|
|
1720
|
-
address,
|
|
1721
|
-
args,
|
|
1722
|
-
blockNumber,
|
|
1723
|
-
blockTag,
|
|
1724
|
-
chainId,
|
|
1725
|
-
functionName,
|
|
1726
|
-
gas,
|
|
1727
|
-
gasPrice,
|
|
1728
|
-
maxFeePerGas,
|
|
1729
|
-
maxPriorityFeePerGas,
|
|
1730
|
-
nonce,
|
|
1731
|
-
scopeKey,
|
|
1732
|
-
walletClientAddress,
|
|
1733
|
-
value
|
|
1734
|
-
}
|
|
1735
|
-
];
|
|
1736
|
-
}
|
|
1737
|
-
function queryFn8({
|
|
1738
|
-
abi,
|
|
1739
|
-
walletClient
|
|
1740
|
-
}) {
|
|
1741
|
-
return ({
|
|
1742
|
-
queryKey: [
|
|
1743
|
-
{
|
|
1744
|
-
accessList,
|
|
1745
|
-
account,
|
|
1746
|
-
args,
|
|
1747
|
-
address,
|
|
1748
|
-
blockNumber,
|
|
1749
|
-
blockTag,
|
|
1750
|
-
chainId,
|
|
1751
|
-
functionName,
|
|
1752
|
-
gas,
|
|
1753
|
-
gasPrice,
|
|
1754
|
-
maxFeePerGas,
|
|
1755
|
-
maxPriorityFeePerGas,
|
|
1756
|
-
nonce,
|
|
1757
|
-
value
|
|
1758
|
-
}
|
|
1759
|
-
]
|
|
1760
|
-
}) => {
|
|
1761
|
-
if (!abi)
|
|
1762
|
-
throw new Error("abi is required");
|
|
1763
|
-
if (!address)
|
|
1764
|
-
throw new Error("address is required");
|
|
1765
|
-
if (!functionName)
|
|
1766
|
-
throw new Error("functionName is required");
|
|
1767
|
-
return prepareWriteContract({
|
|
1768
|
-
abi,
|
|
1769
|
-
accessList,
|
|
1770
|
-
account,
|
|
1771
|
-
args,
|
|
1772
|
-
address,
|
|
1773
|
-
blockNumber,
|
|
1774
|
-
blockTag,
|
|
1775
|
-
chainId,
|
|
1776
|
-
functionName,
|
|
1777
|
-
gas,
|
|
1778
|
-
gasPrice,
|
|
1779
|
-
maxFeePerGas,
|
|
1780
|
-
maxPriorityFeePerGas,
|
|
1781
|
-
nonce,
|
|
1782
|
-
walletClient,
|
|
1783
|
-
value
|
|
1784
|
-
});
|
|
1785
|
-
};
|
|
1786
|
-
}
|
|
1787
|
-
function usePrepareContractWrite({
|
|
1788
|
-
address,
|
|
1789
|
-
abi,
|
|
1790
|
-
functionName,
|
|
1791
|
-
chainId,
|
|
1792
|
-
args,
|
|
1793
|
-
cacheTime,
|
|
1794
|
-
enabled = true,
|
|
1795
|
-
scopeKey,
|
|
1796
|
-
staleTime,
|
|
1797
|
-
suspense,
|
|
1798
|
-
onError,
|
|
1799
|
-
onSettled,
|
|
1800
|
-
onSuccess,
|
|
1801
|
-
...config
|
|
1802
|
-
} = {}) {
|
|
1803
|
-
const { chain: activeChain } = useNetwork();
|
|
1804
|
-
const { data: walletClient } = useWalletClient({ chainId });
|
|
1805
|
-
const {
|
|
1806
|
-
accessList,
|
|
1807
|
-
account,
|
|
1808
|
-
blockNumber,
|
|
1809
|
-
blockTag,
|
|
1810
|
-
gas,
|
|
1811
|
-
gasPrice,
|
|
1812
|
-
maxFeePerGas,
|
|
1813
|
-
maxPriorityFeePerGas,
|
|
1814
|
-
nonce,
|
|
1815
|
-
value
|
|
1816
|
-
} = getCallParameters(config);
|
|
1817
|
-
const prepareContractWriteQuery = useQuery(
|
|
1818
|
-
queryKey8({
|
|
1819
|
-
accessList,
|
|
1820
|
-
account,
|
|
1821
|
-
activeChainId: activeChain?.id,
|
|
1822
|
-
address,
|
|
1823
|
-
args,
|
|
1824
|
-
blockNumber,
|
|
1825
|
-
blockTag,
|
|
1826
|
-
chainId,
|
|
1827
|
-
functionName,
|
|
1828
|
-
gas,
|
|
1829
|
-
gasPrice,
|
|
1830
|
-
maxFeePerGas,
|
|
1831
|
-
maxPriorityFeePerGas,
|
|
1832
|
-
nonce,
|
|
1833
|
-
scopeKey,
|
|
1834
|
-
walletClientAddress: walletClient?.account.address,
|
|
1835
|
-
value
|
|
1836
|
-
}),
|
|
1837
|
-
queryFn8({
|
|
1838
|
-
abi,
|
|
1839
|
-
walletClient
|
|
1840
|
-
}),
|
|
1841
|
-
{
|
|
1842
|
-
cacheTime,
|
|
1843
|
-
enabled: Boolean(
|
|
1844
|
-
enabled && abi && address && functionName && walletClient
|
|
1845
|
-
),
|
|
1846
|
-
staleTime,
|
|
1847
|
-
suspense,
|
|
1848
|
-
onError,
|
|
1849
|
-
onSettled,
|
|
1850
|
-
onSuccess
|
|
1851
|
-
}
|
|
1852
|
-
);
|
|
1853
|
-
return Object.assign(prepareContractWriteQuery, {
|
|
1854
|
-
config: {
|
|
1855
|
-
chainId,
|
|
1856
|
-
mode: "prepared",
|
|
1857
|
-
request: void 0,
|
|
1858
|
-
...prepareContractWriteQuery.data
|
|
1859
|
-
}
|
|
1860
|
-
});
|
|
1861
|
-
}
|
|
1862
|
-
|
|
1863
|
-
// src/hooks/contracts/useToken.ts
|
|
1864
|
-
import { fetchToken } from "@wagmi/core";
|
|
1865
|
-
function queryKey9({
|
|
1866
|
-
address,
|
|
1867
|
-
chainId,
|
|
1868
|
-
formatUnits,
|
|
1869
|
-
scopeKey
|
|
1870
|
-
}) {
|
|
1871
|
-
return [{ entity: "token", address, chainId, formatUnits, scopeKey }];
|
|
1872
|
-
}
|
|
1873
|
-
function queryFn9({
|
|
1874
|
-
queryKey: [{ address, chainId, formatUnits }]
|
|
1875
|
-
}) {
|
|
1876
|
-
if (!address)
|
|
1877
|
-
throw new Error("address is required");
|
|
1878
|
-
return fetchToken({ address, chainId, formatUnits });
|
|
1879
|
-
}
|
|
1880
|
-
function useToken({
|
|
1881
|
-
address,
|
|
1882
|
-
chainId: chainId_,
|
|
1883
|
-
formatUnits = "ether",
|
|
1884
|
-
cacheTime,
|
|
1885
|
-
enabled = true,
|
|
1886
|
-
scopeKey,
|
|
1887
|
-
staleTime = 1e3 * 60 * 60 * 24,
|
|
1888
|
-
suspense,
|
|
1889
|
-
onError,
|
|
1890
|
-
onSettled,
|
|
1891
|
-
onSuccess
|
|
1892
|
-
} = {}) {
|
|
1893
|
-
const chainId = useChainId({ chainId: chainId_ });
|
|
1894
|
-
return useQuery(
|
|
1895
|
-
queryKey9({ address, chainId, formatUnits, scopeKey }),
|
|
1896
|
-
queryFn9,
|
|
1897
|
-
{
|
|
1898
|
-
cacheTime,
|
|
1899
|
-
enabled: Boolean(enabled && address),
|
|
1900
|
-
staleTime,
|
|
1901
|
-
suspense,
|
|
1902
|
-
onError,
|
|
1903
|
-
onSettled,
|
|
1904
|
-
onSuccess
|
|
1905
|
-
}
|
|
1906
|
-
);
|
|
1907
|
-
}
|
|
1908
|
-
|
|
1909
|
-
// src/hooks/ens/useEnsAddress.ts
|
|
1910
|
-
import { fetchEnsAddress } from "@wagmi/core";
|
|
1911
|
-
function queryKey10({ chainId, name, scopeKey }) {
|
|
1912
|
-
return [{ entity: "ensAddress", chainId, name, scopeKey }];
|
|
1913
|
-
}
|
|
1914
|
-
function queryFn10({
|
|
1915
|
-
queryKey: [{ chainId, name }]
|
|
1916
|
-
}) {
|
|
1917
|
-
if (!name)
|
|
1918
|
-
throw new Error("name is required");
|
|
1919
|
-
return fetchEnsAddress({ chainId, name });
|
|
1920
|
-
}
|
|
1921
|
-
function useEnsAddress({
|
|
1922
|
-
cacheTime,
|
|
1923
|
-
chainId: chainId_,
|
|
1924
|
-
enabled = true,
|
|
1925
|
-
name,
|
|
1926
|
-
scopeKey,
|
|
1927
|
-
staleTime = 1e3 * 60 * 60 * 24,
|
|
1928
|
-
suspense,
|
|
1929
|
-
onError,
|
|
1930
|
-
onSettled,
|
|
1931
|
-
onSuccess
|
|
1932
|
-
} = {}) {
|
|
1933
|
-
const chainId = useChainId({ chainId: chainId_ });
|
|
1934
|
-
return useQuery(queryKey10({ chainId, name, scopeKey }), queryFn10, {
|
|
1935
|
-
cacheTime,
|
|
1936
|
-
enabled: Boolean(enabled && chainId && name),
|
|
1937
|
-
staleTime,
|
|
1938
|
-
suspense,
|
|
1939
|
-
onError,
|
|
1940
|
-
onSettled,
|
|
1941
|
-
onSuccess
|
|
1942
|
-
});
|
|
1943
|
-
}
|
|
1944
|
-
|
|
1945
|
-
// src/hooks/ens/useEnsAvatar.ts
|
|
1946
|
-
import { fetchEnsAvatar } from "@wagmi/core";
|
|
1947
|
-
function queryKey11({ name, chainId, scopeKey }) {
|
|
1948
|
-
return [{ entity: "ensAvatar", name, chainId, scopeKey }];
|
|
1949
|
-
}
|
|
1950
|
-
function queryFn11({
|
|
1951
|
-
queryKey: [{ name, chainId }]
|
|
1952
|
-
}) {
|
|
1953
|
-
if (!name)
|
|
1954
|
-
throw new Error("name is required");
|
|
1955
|
-
return fetchEnsAvatar({ name, chainId });
|
|
1956
|
-
}
|
|
1957
|
-
function useEnsAvatar({
|
|
1958
|
-
cacheTime,
|
|
1959
|
-
chainId: chainId_,
|
|
1960
|
-
enabled = true,
|
|
1961
|
-
name,
|
|
1962
|
-
scopeKey,
|
|
1963
|
-
staleTime = 1e3 * 60 * 60 * 24,
|
|
1964
|
-
suspense,
|
|
1965
|
-
onError,
|
|
1966
|
-
onSettled,
|
|
1967
|
-
onSuccess
|
|
1968
|
-
} = {}) {
|
|
1969
|
-
const chainId = useChainId({ chainId: chainId_ });
|
|
1970
|
-
return useQuery(queryKey11({ name, chainId, scopeKey }), queryFn11, {
|
|
1971
|
-
cacheTime,
|
|
1972
|
-
enabled: Boolean(enabled && name && chainId),
|
|
1973
|
-
staleTime,
|
|
1974
|
-
suspense,
|
|
1975
|
-
onError,
|
|
1976
|
-
onSettled,
|
|
1977
|
-
onSuccess
|
|
1978
|
-
});
|
|
1979
|
-
}
|
|
1980
|
-
|
|
1981
|
-
// src/hooks/ens/useEnsName.ts
|
|
1982
|
-
import { fetchEnsName } from "@wagmi/core";
|
|
1983
|
-
function queryKey12({
|
|
1984
|
-
address,
|
|
1985
|
-
chainId,
|
|
1986
|
-
scopeKey
|
|
1987
|
-
}) {
|
|
1988
|
-
return [{ entity: "ensName", address, chainId, scopeKey }];
|
|
1989
|
-
}
|
|
1990
|
-
function queryFn12({
|
|
1991
|
-
queryKey: [{ address, chainId }]
|
|
1992
|
-
}) {
|
|
1993
|
-
if (!address)
|
|
1994
|
-
throw new Error("address is required");
|
|
1995
|
-
return fetchEnsName({ address, chainId });
|
|
1996
|
-
}
|
|
1997
|
-
function useEnsName({
|
|
1998
|
-
address,
|
|
1999
|
-
cacheTime,
|
|
2000
|
-
chainId: chainId_,
|
|
2001
|
-
enabled = true,
|
|
2002
|
-
scopeKey,
|
|
2003
|
-
staleTime = 1e3 * 60 * 60 * 24,
|
|
2004
|
-
suspense,
|
|
2005
|
-
onError,
|
|
2006
|
-
onSettled,
|
|
2007
|
-
onSuccess
|
|
2008
|
-
} = {}) {
|
|
2009
|
-
const chainId = useChainId({ chainId: chainId_ });
|
|
2010
|
-
return useQuery(queryKey12({ address, chainId, scopeKey }), queryFn12, {
|
|
2011
|
-
cacheTime,
|
|
2012
|
-
enabled: Boolean(enabled && address && chainId),
|
|
2013
|
-
staleTime,
|
|
2014
|
-
suspense,
|
|
2015
|
-
onError,
|
|
2016
|
-
onSettled,
|
|
2017
|
-
onSuccess
|
|
2018
|
-
});
|
|
2019
|
-
}
|
|
2020
|
-
|
|
2021
|
-
// src/hooks/ens/useEnsResolver.ts
|
|
2022
|
-
import { fetchEnsResolver } from "@wagmi/core";
|
|
2023
|
-
function queryKey13({ chainId, name, scopeKey }) {
|
|
2024
|
-
return [
|
|
2025
|
-
{ entity: "ensResolver", chainId, name, scopeKey, persist: false }
|
|
2026
|
-
];
|
|
2027
|
-
}
|
|
2028
|
-
function queryFn13({
|
|
2029
|
-
queryKey: [{ chainId, name }]
|
|
2030
|
-
}) {
|
|
2031
|
-
if (!name)
|
|
2032
|
-
throw new Error("name is required");
|
|
2033
|
-
return fetchEnsResolver({ chainId, name });
|
|
2034
|
-
}
|
|
2035
|
-
function useEnsResolver({
|
|
2036
|
-
chainId: chainId_,
|
|
2037
|
-
name,
|
|
2038
|
-
enabled = true,
|
|
2039
|
-
scopeKey,
|
|
2040
|
-
suspense,
|
|
2041
|
-
onError,
|
|
2042
|
-
onSettled,
|
|
2043
|
-
onSuccess
|
|
2044
|
-
} = {}) {
|
|
2045
|
-
const chainId = useChainId({ chainId: chainId_ });
|
|
2046
|
-
return useQuery(queryKey13({ chainId, name, scopeKey }), queryFn13, {
|
|
2047
|
-
cacheTime: 0,
|
|
2048
|
-
enabled: Boolean(enabled && chainId && name),
|
|
2049
|
-
suspense,
|
|
2050
|
-
onError,
|
|
2051
|
-
onSettled,
|
|
2052
|
-
onSuccess
|
|
2053
|
-
});
|
|
2054
|
-
}
|
|
2055
|
-
|
|
2056
|
-
// src/hooks/transactions/usePrepareSendTransaction.ts
|
|
2057
|
-
import { prepareSendTransaction } from "@wagmi/core";
|
|
2058
|
-
function queryKey14({
|
|
2059
|
-
accessList,
|
|
2060
|
-
account,
|
|
2061
|
-
activeChainId,
|
|
2062
|
-
chainId,
|
|
2063
|
-
data,
|
|
2064
|
-
gas,
|
|
2065
|
-
gasPrice,
|
|
2066
|
-
maxFeePerGas,
|
|
2067
|
-
maxPriorityFeePerGas,
|
|
2068
|
-
nonce,
|
|
2069
|
-
to,
|
|
2070
|
-
value,
|
|
2071
|
-
scopeKey,
|
|
2072
|
-
walletClientAddress
|
|
2073
|
-
}) {
|
|
2074
|
-
return [
|
|
2075
|
-
{
|
|
2076
|
-
entity: "prepareSendTransaction",
|
|
2077
|
-
activeChainId,
|
|
2078
|
-
accessList,
|
|
2079
|
-
account,
|
|
2080
|
-
chainId,
|
|
2081
|
-
data,
|
|
2082
|
-
gas,
|
|
2083
|
-
gasPrice,
|
|
2084
|
-
maxFeePerGas,
|
|
2085
|
-
maxPriorityFeePerGas,
|
|
2086
|
-
nonce,
|
|
2087
|
-
to,
|
|
2088
|
-
value,
|
|
2089
|
-
scopeKey,
|
|
2090
|
-
walletClientAddress
|
|
2091
|
-
}
|
|
2092
|
-
];
|
|
2093
|
-
}
|
|
2094
|
-
function queryFn14({ walletClient }) {
|
|
2095
|
-
return ({
|
|
2096
|
-
queryKey: [
|
|
2097
|
-
{
|
|
2098
|
-
accessList,
|
|
2099
|
-
account,
|
|
2100
|
-
chainId,
|
|
2101
|
-
data,
|
|
2102
|
-
gas,
|
|
2103
|
-
gasPrice,
|
|
2104
|
-
maxFeePerGas,
|
|
2105
|
-
maxPriorityFeePerGas,
|
|
2106
|
-
nonce,
|
|
2107
|
-
to,
|
|
2108
|
-
value
|
|
2109
|
-
}
|
|
2110
|
-
]
|
|
2111
|
-
}) => {
|
|
2112
|
-
if (!to)
|
|
2113
|
-
throw new Error("to is required");
|
|
2114
|
-
return prepareSendTransaction({
|
|
2115
|
-
accessList,
|
|
2116
|
-
account,
|
|
2117
|
-
chainId,
|
|
2118
|
-
data,
|
|
2119
|
-
gas,
|
|
2120
|
-
gasPrice,
|
|
2121
|
-
maxFeePerGas,
|
|
2122
|
-
maxPriorityFeePerGas,
|
|
2123
|
-
nonce,
|
|
2124
|
-
to,
|
|
2125
|
-
value,
|
|
2126
|
-
walletClient
|
|
2127
|
-
});
|
|
2128
|
-
};
|
|
2129
|
-
}
|
|
2130
|
-
function usePrepareSendTransaction({
|
|
2131
|
-
accessList,
|
|
2132
|
-
account,
|
|
2133
|
-
chainId,
|
|
2134
|
-
cacheTime,
|
|
2135
|
-
data,
|
|
2136
|
-
enabled = true,
|
|
2137
|
-
gas,
|
|
2138
|
-
gasPrice,
|
|
2139
|
-
maxFeePerGas,
|
|
2140
|
-
maxPriorityFeePerGas,
|
|
2141
|
-
nonce,
|
|
2142
|
-
scopeKey,
|
|
2143
|
-
staleTime,
|
|
2144
|
-
suspense,
|
|
2145
|
-
to,
|
|
2146
|
-
value,
|
|
2147
|
-
onError,
|
|
2148
|
-
onSettled,
|
|
2149
|
-
onSuccess
|
|
2150
|
-
} = {}) {
|
|
2151
|
-
const { chain: activeChain } = useNetwork();
|
|
2152
|
-
const { data: walletClient } = useWalletClient({ chainId });
|
|
2153
|
-
const prepareSendTransactionQuery = useQuery(
|
|
2154
|
-
queryKey14({
|
|
2155
|
-
accessList,
|
|
2156
|
-
activeChainId: activeChain?.id,
|
|
2157
|
-
account,
|
|
2158
|
-
chainId,
|
|
2159
|
-
data,
|
|
2160
|
-
gas,
|
|
2161
|
-
gasPrice,
|
|
2162
|
-
maxFeePerGas,
|
|
2163
|
-
maxPriorityFeePerGas,
|
|
2164
|
-
nonce,
|
|
2165
|
-
scopeKey,
|
|
2166
|
-
to,
|
|
2167
|
-
value,
|
|
2168
|
-
walletClientAddress: walletClient?.account.address
|
|
2169
|
-
}),
|
|
2170
|
-
queryFn14({ walletClient }),
|
|
2171
|
-
{
|
|
2172
|
-
cacheTime,
|
|
2173
|
-
enabled: Boolean(enabled && walletClient && to),
|
|
2174
|
-
staleTime,
|
|
2175
|
-
suspense,
|
|
2176
|
-
onError,
|
|
2177
|
-
onSettled,
|
|
2178
|
-
onSuccess
|
|
2179
|
-
}
|
|
2180
|
-
);
|
|
2181
|
-
return Object.assign(prepareSendTransactionQuery, {
|
|
2182
|
-
config: {
|
|
2183
|
-
mode: "prepared",
|
|
2184
|
-
...prepareSendTransactionQuery.isSuccess ? prepareSendTransactionQuery.data : void 0
|
|
2185
|
-
}
|
|
2186
|
-
});
|
|
2187
|
-
}
|
|
2188
|
-
|
|
2189
|
-
// src/hooks/transactions/useSendTransaction.ts
|
|
2190
|
-
import { sendTransaction } from "@wagmi/core";
|
|
2191
|
-
import * as React20 from "react";
|
|
2192
|
-
var mutationKey7 = (args) => [{ entity: "sendTransaction", ...args }];
|
|
2193
|
-
var mutationFn7 = ({
|
|
2194
|
-
accessList,
|
|
2195
|
-
account,
|
|
2196
|
-
chainId,
|
|
2197
|
-
data,
|
|
2198
|
-
gas,
|
|
2199
|
-
gasPrice,
|
|
2200
|
-
maxFeePerGas,
|
|
2201
|
-
maxPriorityFeePerGas,
|
|
2202
|
-
mode,
|
|
2203
|
-
nonce,
|
|
2204
|
-
to,
|
|
2205
|
-
value
|
|
2206
|
-
}) => {
|
|
2207
|
-
if (!to)
|
|
2208
|
-
throw new Error("to is required.");
|
|
2209
|
-
return sendTransaction({
|
|
2210
|
-
accessList,
|
|
2211
|
-
account,
|
|
2212
|
-
chainId,
|
|
2213
|
-
data,
|
|
2214
|
-
gas,
|
|
2215
|
-
gasPrice,
|
|
2216
|
-
maxFeePerGas,
|
|
2217
|
-
maxPriorityFeePerGas,
|
|
2218
|
-
mode,
|
|
2219
|
-
nonce,
|
|
2220
|
-
to,
|
|
2221
|
-
value
|
|
2222
|
-
});
|
|
2223
|
-
};
|
|
2224
|
-
function useSendTransaction({
|
|
2225
|
-
accessList,
|
|
2226
|
-
account,
|
|
2227
|
-
chainId,
|
|
2228
|
-
data: data_,
|
|
2229
|
-
gas,
|
|
2230
|
-
gasPrice,
|
|
2231
|
-
maxFeePerGas,
|
|
2232
|
-
maxPriorityFeePerGas,
|
|
2233
|
-
mode,
|
|
2234
|
-
nonce,
|
|
2235
|
-
to,
|
|
2236
|
-
value,
|
|
2237
|
-
onError,
|
|
2238
|
-
onMutate,
|
|
2239
|
-
onSettled,
|
|
2240
|
-
onSuccess
|
|
2241
|
-
} = {}) {
|
|
2242
|
-
const {
|
|
2243
|
-
data,
|
|
2244
|
-
error,
|
|
2245
|
-
isError,
|
|
2246
|
-
isIdle,
|
|
2247
|
-
isLoading,
|
|
2248
|
-
isSuccess,
|
|
2249
|
-
mutate,
|
|
2250
|
-
mutateAsync,
|
|
2251
|
-
reset,
|
|
2252
|
-
status,
|
|
2253
|
-
variables
|
|
2254
|
-
} = useMutation(
|
|
2255
|
-
mutationKey7({
|
|
2256
|
-
accessList,
|
|
2257
|
-
account,
|
|
2258
|
-
chainId,
|
|
2259
|
-
data: data_,
|
|
2260
|
-
gas,
|
|
2261
|
-
gasPrice,
|
|
2262
|
-
maxFeePerGas,
|
|
2263
|
-
maxPriorityFeePerGas,
|
|
2264
|
-
mode,
|
|
2265
|
-
nonce,
|
|
2266
|
-
to,
|
|
2267
|
-
value
|
|
2268
|
-
}),
|
|
2269
|
-
mutationFn7,
|
|
2270
|
-
{
|
|
2271
|
-
onError,
|
|
2272
|
-
onMutate,
|
|
2273
|
-
onSettled,
|
|
2274
|
-
onSuccess
|
|
2275
|
-
}
|
|
2276
|
-
);
|
|
2277
|
-
const sendTransaction2 = React20.useCallback(
|
|
2278
|
-
(args) => mutate({
|
|
2279
|
-
chainId,
|
|
2280
|
-
mode,
|
|
2281
|
-
...args || {
|
|
2282
|
-
accessList,
|
|
2283
|
-
account,
|
|
2284
|
-
chainId,
|
|
2285
|
-
data: data_,
|
|
2286
|
-
gas,
|
|
2287
|
-
gasPrice,
|
|
2288
|
-
maxFeePerGas,
|
|
2289
|
-
maxPriorityFeePerGas,
|
|
2290
|
-
mode,
|
|
2291
|
-
nonce,
|
|
2292
|
-
value,
|
|
2293
|
-
to
|
|
2294
|
-
}
|
|
2295
|
-
}),
|
|
2296
|
-
[
|
|
2297
|
-
accessList,
|
|
2298
|
-
account,
|
|
2299
|
-
chainId,
|
|
2300
|
-
data_,
|
|
2301
|
-
gas,
|
|
2302
|
-
gasPrice,
|
|
2303
|
-
maxFeePerGas,
|
|
2304
|
-
maxPriorityFeePerGas,
|
|
2305
|
-
mode,
|
|
2306
|
-
mutate,
|
|
2307
|
-
nonce,
|
|
2308
|
-
to,
|
|
2309
|
-
value
|
|
2310
|
-
]
|
|
2311
|
-
);
|
|
2312
|
-
const sendTransactionAsync = React20.useCallback(
|
|
2313
|
-
(args) => mutateAsync({
|
|
2314
|
-
chainId,
|
|
2315
|
-
mode,
|
|
2316
|
-
...args || {
|
|
2317
|
-
accessList,
|
|
2318
|
-
account,
|
|
2319
|
-
chainId,
|
|
2320
|
-
data: data_,
|
|
2321
|
-
gas,
|
|
2322
|
-
gasPrice,
|
|
2323
|
-
maxFeePerGas,
|
|
2324
|
-
maxPriorityFeePerGas,
|
|
2325
|
-
mode,
|
|
2326
|
-
nonce,
|
|
2327
|
-
value,
|
|
2328
|
-
to
|
|
2329
|
-
}
|
|
2330
|
-
}),
|
|
2331
|
-
[
|
|
2332
|
-
accessList,
|
|
2333
|
-
account,
|
|
2334
|
-
chainId,
|
|
2335
|
-
data_,
|
|
2336
|
-
gas,
|
|
2337
|
-
gasPrice,
|
|
2338
|
-
maxFeePerGas,
|
|
2339
|
-
maxPriorityFeePerGas,
|
|
2340
|
-
mode,
|
|
2341
|
-
mutateAsync,
|
|
2342
|
-
nonce,
|
|
2343
|
-
to,
|
|
2344
|
-
value
|
|
2345
|
-
]
|
|
2346
|
-
);
|
|
2347
|
-
return {
|
|
2348
|
-
data,
|
|
2349
|
-
error,
|
|
2350
|
-
isError,
|
|
2351
|
-
isIdle,
|
|
2352
|
-
isLoading,
|
|
2353
|
-
isSuccess,
|
|
2354
|
-
reset,
|
|
2355
|
-
sendTransaction: mode === "prepared" && !to ? void 0 : sendTransaction2,
|
|
2356
|
-
sendTransactionAsync: mode === "prepared" && !to ? void 0 : sendTransactionAsync,
|
|
2357
|
-
status,
|
|
2358
|
-
variables
|
|
2359
|
-
};
|
|
2360
|
-
}
|
|
2361
|
-
|
|
2362
|
-
// src/hooks/transactions/useTransaction.ts
|
|
2363
|
-
import { fetchTransaction } from "@wagmi/core";
|
|
2364
|
-
function queryKey15({ chainId, hash, scopeKey }) {
|
|
2365
|
-
return [{ entity: "transaction", chainId, hash, scopeKey }];
|
|
2366
|
-
}
|
|
2367
|
-
function queryFn15({
|
|
2368
|
-
queryKey: [{ chainId, hash }]
|
|
2369
|
-
}) {
|
|
2370
|
-
if (!hash)
|
|
2371
|
-
throw new Error("hash is required");
|
|
2372
|
-
return fetchTransaction({ chainId, hash });
|
|
2373
|
-
}
|
|
2374
|
-
function useTransaction({
|
|
2375
|
-
cacheTime = 0,
|
|
2376
|
-
chainId: chainId_,
|
|
2377
|
-
enabled = true,
|
|
2378
|
-
hash,
|
|
2379
|
-
scopeKey,
|
|
2380
|
-
staleTime,
|
|
2381
|
-
suspense,
|
|
2382
|
-
onError,
|
|
2383
|
-
onSettled,
|
|
2384
|
-
onSuccess
|
|
2385
|
-
} = {}) {
|
|
2386
|
-
const chainId = useChainId({ chainId: chainId_ });
|
|
2387
|
-
return useQuery(queryKey15({ chainId, hash, scopeKey }), queryFn15, {
|
|
2388
|
-
cacheTime,
|
|
2389
|
-
enabled: Boolean(enabled && hash),
|
|
2390
|
-
staleTime,
|
|
2391
|
-
suspense,
|
|
2392
|
-
onError,
|
|
2393
|
-
onSettled,
|
|
2394
|
-
onSuccess
|
|
2395
|
-
});
|
|
2396
|
-
}
|
|
2397
|
-
|
|
2398
|
-
// src/hooks/transactions/useWaitForTransaction.ts
|
|
2399
|
-
import { waitForTransaction } from "@wagmi/core";
|
|
2400
|
-
function queryKey16({
|
|
2401
|
-
confirmations,
|
|
2402
|
-
chainId,
|
|
2403
|
-
hash,
|
|
2404
|
-
scopeKey,
|
|
2405
|
-
timeout
|
|
2406
|
-
}) {
|
|
2407
|
-
return [
|
|
2408
|
-
{
|
|
2409
|
-
entity: "waitForTransaction",
|
|
2410
|
-
confirmations,
|
|
2411
|
-
chainId,
|
|
2412
|
-
hash,
|
|
2413
|
-
scopeKey,
|
|
2414
|
-
timeout
|
|
2415
|
-
}
|
|
2416
|
-
];
|
|
2417
|
-
}
|
|
2418
|
-
function queryFn16({
|
|
2419
|
-
onReplaced
|
|
2420
|
-
}) {
|
|
2421
|
-
return ({
|
|
2422
|
-
queryKey: [{ chainId, confirmations, hash, timeout }]
|
|
2423
|
-
}) => {
|
|
2424
|
-
if (!hash)
|
|
2425
|
-
throw new Error("hash is required");
|
|
2426
|
-
return waitForTransaction({
|
|
2427
|
-
chainId,
|
|
2428
|
-
confirmations,
|
|
2429
|
-
hash,
|
|
2430
|
-
onReplaced,
|
|
2431
|
-
timeout
|
|
2432
|
-
});
|
|
2433
|
-
};
|
|
2434
|
-
}
|
|
2435
|
-
function useWaitForTransaction({
|
|
2436
|
-
chainId: chainId_,
|
|
2437
|
-
confirmations,
|
|
2438
|
-
hash,
|
|
2439
|
-
timeout,
|
|
2440
|
-
cacheTime,
|
|
2441
|
-
enabled = true,
|
|
2442
|
-
scopeKey,
|
|
2443
|
-
staleTime,
|
|
2444
|
-
suspense,
|
|
2445
|
-
onError,
|
|
2446
|
-
onReplaced,
|
|
2447
|
-
onSettled,
|
|
2448
|
-
onSuccess
|
|
2449
|
-
} = {}) {
|
|
2450
|
-
const chainId = useChainId({ chainId: chainId_ });
|
|
2451
|
-
return useQuery(
|
|
2452
|
-
queryKey16({ chainId, confirmations, hash, scopeKey, timeout }),
|
|
2453
|
-
queryFn16({ onReplaced }),
|
|
2454
|
-
{
|
|
2455
|
-
cacheTime,
|
|
2456
|
-
enabled: Boolean(enabled && hash),
|
|
2457
|
-
staleTime,
|
|
2458
|
-
suspense,
|
|
2459
|
-
onError,
|
|
2460
|
-
onSettled,
|
|
2461
|
-
onSuccess
|
|
2462
|
-
}
|
|
2463
|
-
);
|
|
2464
|
-
}
|
|
2465
|
-
|
|
2466
|
-
// src/hooks/transactions/useWatchPendingTransactions.ts
|
|
2467
|
-
import * as React21 from "react";
|
|
2468
|
-
function useWatchPendingTransactions({
|
|
2469
|
-
chainId: chainId_,
|
|
2470
|
-
enabled = true,
|
|
2471
|
-
listener
|
|
2472
|
-
}) {
|
|
2473
|
-
const chainId = useChainId({ chainId: chainId_ });
|
|
2474
|
-
const publicClient = usePublicClient({ chainId });
|
|
2475
|
-
const webSocketPublicClient = useWebSocketPublicClient({ chainId });
|
|
2476
|
-
React21.useEffect(() => {
|
|
2477
|
-
if (!enabled)
|
|
2478
|
-
return;
|
|
2479
|
-
const publicClient_ = webSocketPublicClient ?? publicClient;
|
|
2480
|
-
return publicClient_.watchPendingTransactions({
|
|
2481
|
-
onTransactions: listener
|
|
2482
|
-
});
|
|
2483
|
-
}, [enabled, listener, publicClient, webSocketPublicClient]);
|
|
2484
|
-
}
|
|
2485
|
-
|
|
2486
|
-
// src/index.ts
|
|
2487
|
-
import {
|
|
2488
|
-
ChainMismatchError,
|
|
2489
|
-
ChainNotConfiguredError,
|
|
2490
|
-
Connector,
|
|
2491
|
-
ConnectorAlreadyConnectedError,
|
|
2492
|
-
ConnectorNotFoundError,
|
|
2493
|
-
ConfigChainsNotFound,
|
|
2494
|
-
SwitchChainNotSupportedError,
|
|
2495
|
-
configureChains,
|
|
2496
|
-
createStorage as createStorage2,
|
|
2497
|
-
deepEqual as deepEqual5,
|
|
2498
|
-
deserialize,
|
|
2499
|
-
erc20ABI,
|
|
2500
|
-
erc721ABI,
|
|
2501
|
-
erc4626ABI,
|
|
2502
|
-
readContracts as readContracts3,
|
|
2503
|
-
serialize
|
|
2504
|
-
} from "@wagmi/core";
|
|
2505
|
-
import { mainnet, sepolia } from "viem/chains";
|
|
2506
|
-
export {
|
|
2507
|
-
ChainMismatchError,
|
|
2508
|
-
ChainNotConfiguredError,
|
|
2509
|
-
ConfigChainsNotFound,
|
|
2510
|
-
Connector,
|
|
2511
|
-
ConnectorAlreadyConnectedError,
|
|
2512
|
-
ConnectorNotFoundError,
|
|
2513
|
-
Context,
|
|
2514
|
-
SwitchChainNotSupportedError,
|
|
2515
|
-
WagmiConfig,
|
|
2516
|
-
configureChains,
|
|
2517
|
-
createConfig,
|
|
2518
|
-
createStorage2 as createStorage,
|
|
2519
|
-
deepEqual5 as deepEqual,
|
|
2520
|
-
deserialize,
|
|
2521
|
-
erc20ABI,
|
|
2522
|
-
erc4626ABI,
|
|
2523
|
-
erc721ABI,
|
|
2524
|
-
mainnet,
|
|
2525
|
-
paginatedIndexesConfig,
|
|
2526
|
-
readContracts3 as readContracts,
|
|
2527
|
-
sepolia,
|
|
2528
|
-
serialize,
|
|
2529
|
-
useAccount,
|
|
2530
|
-
useBalance,
|
|
2531
|
-
useBlockNumber,
|
|
2532
|
-
useChainId,
|
|
2533
|
-
useConfig,
|
|
2534
|
-
useConnect,
|
|
2535
|
-
useContractEvent,
|
|
2536
|
-
useContractInfiniteReads,
|
|
2537
|
-
useContractRead,
|
|
2538
|
-
useContractReads,
|
|
2539
|
-
useContractWrite,
|
|
2540
|
-
useDisconnect,
|
|
2541
|
-
useEnsAddress,
|
|
2542
|
-
useEnsAvatar,
|
|
2543
|
-
useEnsName,
|
|
2544
|
-
useEnsResolver,
|
|
2545
|
-
useFeeData,
|
|
2546
|
-
useInfiniteQuery,
|
|
2547
|
-
useMutation,
|
|
2548
|
-
useNetwork,
|
|
2549
|
-
usePrepareContractWrite,
|
|
2550
|
-
usePrepareSendTransaction,
|
|
2551
|
-
usePublicClient,
|
|
2552
|
-
useQuery,
|
|
2553
|
-
useQueryClient2 as useQueryClient,
|
|
2554
|
-
useSendTransaction,
|
|
2555
|
-
useSignMessage,
|
|
2556
|
-
useSignTypedData,
|
|
2557
|
-
useSwitchNetwork,
|
|
2558
|
-
useToken,
|
|
2559
|
-
useTransaction,
|
|
2560
|
-
useWaitForTransaction,
|
|
2561
|
-
useWalletClient,
|
|
2562
|
-
useWatchPendingTransactions,
|
|
2563
|
-
useWebSocketPublicClient
|
|
2564
|
-
};
|