@wagmi/vue 0.0.0-canary-20240515232917
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/LICENSE +21 -0
- package/README.md +14 -0
- package/actions/package.json +5 -0
- package/chains/package.json +5 -0
- package/connectors/package.json +5 -0
- package/dist/esm/composables/useAccount.js +18 -0
- package/dist/esm/composables/useAccount.js.map +1 -0
- package/dist/esm/composables/useAccountEffect.js +37 -0
- package/dist/esm/composables/useAccountEffect.js.map +1 -0
- package/dist/esm/composables/useBalance.js +24 -0
- package/dist/esm/composables/useBalance.js.map +1 -0
- package/dist/esm/composables/useBlockNumber.js +46 -0
- package/dist/esm/composables/useBlockNumber.js.map +1 -0
- package/dist/esm/composables/useChainId.js +17 -0
- package/dist/esm/composables/useChainId.js.map +1 -0
- package/dist/esm/composables/useChains.js +17 -0
- package/dist/esm/composables/useChains.js.map +1 -0
- package/dist/esm/composables/useClient.js +23 -0
- package/dist/esm/composables/useClient.js.map +1 -0
- package/dist/esm/composables/useConfig.js +19 -0
- package/dist/esm/composables/useConfig.js.map +1 -0
- package/dist/esm/composables/useConnect.js +29 -0
- package/dist/esm/composables/useConnect.js.map +1 -0
- package/dist/esm/composables/useConnections.js +16 -0
- package/dist/esm/composables/useConnections.js.map +1 -0
- package/dist/esm/composables/useConnectorClient.js +49 -0
- package/dist/esm/composables/useConnectorClient.js.map +1 -0
- package/dist/esm/composables/useConnectors.js +16 -0
- package/dist/esm/composables/useConnectors.js.map +1 -0
- package/dist/esm/composables/useDisconnect.js +24 -0
- package/dist/esm/composables/useDisconnect.js.map +1 -0
- package/dist/esm/composables/useEnsAddress.js +24 -0
- package/dist/esm/composables/useEnsAddress.js.map +1 -0
- package/dist/esm/composables/useEnsAvatar.js +24 -0
- package/dist/esm/composables/useEnsAvatar.js.map +1 -0
- package/dist/esm/composables/useEnsName.js +24 -0
- package/dist/esm/composables/useEnsName.js.map +1 -0
- package/dist/esm/composables/useEstimateGas.js +29 -0
- package/dist/esm/composables/useEstimateGas.js.map +1 -0
- package/dist/esm/composables/useReadContract.js +28 -0
- package/dist/esm/composables/useReadContract.js.map +1 -0
- package/dist/esm/composables/useReconnect.js +21 -0
- package/dist/esm/composables/useReconnect.js.map +1 -0
- package/dist/esm/composables/useSendTransaction.js +19 -0
- package/dist/esm/composables/useSendTransaction.js.map +1 -0
- package/dist/esm/composables/useSignMessage.js +20 -0
- package/dist/esm/composables/useSignMessage.js.map +1 -0
- package/dist/esm/composables/useSignTypedData.js +19 -0
- package/dist/esm/composables/useSignTypedData.js.map +1 -0
- package/dist/esm/composables/useSimulateContract.js +34 -0
- package/dist/esm/composables/useSimulateContract.js.map +1 -0
- package/dist/esm/composables/useSwitchAccount.js +23 -0
- package/dist/esm/composables/useSwitchAccount.js.map +1 -0
- package/dist/esm/composables/useSwitchChain.js +25 -0
- package/dist/esm/composables/useSwitchChain.js.map +1 -0
- package/dist/esm/composables/useTransaction.js +29 -0
- package/dist/esm/composables/useTransaction.js.map +1 -0
- package/dist/esm/composables/useTransactionReceipt.js +31 -0
- package/dist/esm/composables/useTransactionReceipt.js.map +1 -0
- package/dist/esm/composables/useWaitForTransactionReceipt.js +28 -0
- package/dist/esm/composables/useWaitForTransactionReceipt.js.map +1 -0
- package/dist/esm/composables/useWatchBlockNumber.js +27 -0
- package/dist/esm/composables/useWatchBlockNumber.js.map +1 -0
- package/dist/esm/composables/useWriteContract.js +19 -0
- package/dist/esm/composables/useWriteContract.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/plugin.js +28 -0
- package/dist/esm/errors/plugin.js.map +1 -0
- package/dist/esm/exports/actions.js +5 -0
- package/dist/esm/exports/actions.js.map +1 -0
- package/dist/esm/exports/chains.js +5 -0
- package/dist/esm/exports/chains.js.map +1 -0
- package/dist/esm/exports/connectors.js +5 -0
- package/dist/esm/exports/connectors.js.map +1 -0
- package/dist/esm/exports/index.js +55 -0
- package/dist/esm/exports/index.js.map +1 -0
- package/dist/esm/exports/nuxt.js +4 -0
- package/dist/esm/exports/nuxt.js.map +1 -0
- package/dist/esm/exports/query.js +7 -0
- package/dist/esm/exports/query.js.map +1 -0
- package/dist/esm/nuxt/module.js +53 -0
- package/dist/esm/nuxt/module.js.map +1 -0
- package/dist/esm/nuxt/runtime/composables.js +2 -0
- package/dist/esm/nuxt/runtime/composables.js.map +1 -0
- package/dist/esm/plugin.js +14 -0
- package/dist/esm/plugin.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/types/ref.js +3 -0
- package/dist/esm/types/ref.js.map +1 -0
- package/dist/esm/utils/cloneDeep.js +36 -0
- package/dist/esm/utils/cloneDeep.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 +73 -0
- package/dist/esm/utils/query.js.map +1 -0
- package/dist/esm/utils/updateState.js +7 -0
- package/dist/esm/utils/updateState.js.map +1 -0
- package/dist/esm/version.js +2 -0
- package/dist/esm/version.js.map +1 -0
- package/dist/types/composables/useAccount.d.ts +8 -0
- package/dist/types/composables/useAccount.d.ts.map +1 -0
- package/dist/types/composables/useAccountEffect.d.ts +15 -0
- package/dist/types/composables/useAccountEffect.d.ts.map +1 -0
- package/dist/types/composables/useBalance.d.ts +12 -0
- package/dist/types/composables/useBalance.d.ts.map +1 -0
- package/dist/types/composables/useBlockNumber.d.ts +14 -0
- package/dist/types/composables/useBlockNumber.d.ts.map +1 -0
- package/dist/types/composables/useChainId.d.ts +8 -0
- package/dist/types/composables/useChainId.d.ts.map +1 -0
- package/dist/types/composables/useChains.d.ts +9 -0
- package/dist/types/composables/useChains.d.ts.map +1 -0
- package/dist/types/composables/useClient.d.ts +10 -0
- package/dist/types/composables/useClient.d.ts.map +1 -0
- package/dist/types/composables/useConfig.d.ts +8 -0
- package/dist/types/composables/useConfig.d.ts.map +1 -0
- package/dist/types/composables/useConnect.d.ts +16 -0
- package/dist/types/composables/useConnect.d.ts.map +1 -0
- package/dist/types/composables/useConnections.d.ts +8 -0
- package/dist/types/composables/useConnections.d.ts.map +1 -0
- package/dist/types/composables/useConnectorClient.d.ts +13 -0
- package/dist/types/composables/useConnectorClient.d.ts.map +1 -0
- package/dist/types/composables/useConnectors.d.ts +8 -0
- package/dist/types/composables/useConnectors.d.ts.map +1 -0
- package/dist/types/composables/useDisconnect.d.ts +17 -0
- package/dist/types/composables/useDisconnect.d.ts.map +1 -0
- package/dist/types/composables/useEnsAddress.d.ts +11 -0
- package/dist/types/composables/useEnsAddress.d.ts.map +1 -0
- package/dist/types/composables/useEnsAvatar.d.ts +11 -0
- package/dist/types/composables/useEnsAvatar.d.ts.map +1 -0
- package/dist/types/composables/useEnsName.d.ts +11 -0
- package/dist/types/composables/useEnsName.d.ts.map +1 -0
- package/dist/types/composables/useEstimateGas.d.ts +10 -0
- package/dist/types/composables/useEstimateGas.d.ts.map +1 -0
- package/dist/types/composables/useReadContract.d.ts +12 -0
- package/dist/types/composables/useReadContract.d.ts.map +1 -0
- package/dist/types/composables/useReconnect.d.ts +16 -0
- package/dist/types/composables/useReconnect.d.ts.map +1 -0
- package/dist/types/composables/useSendTransaction.d.ts +15 -0
- package/dist/types/composables/useSendTransaction.d.ts.map +1 -0
- package/dist/types/composables/useSignMessage.d.ts +15 -0
- package/dist/types/composables/useSignMessage.d.ts.map +1 -0
- package/dist/types/composables/useSignTypedData.d.ts +15 -0
- package/dist/types/composables/useSignTypedData.d.ts.map +1 -0
- package/dist/types/composables/useSimulateContract.d.ts +12 -0
- package/dist/types/composables/useSimulateContract.d.ts.map +1 -0
- package/dist/types/composables/useSwitchAccount.d.ts +17 -0
- package/dist/types/composables/useSwitchAccount.d.ts.map +1 -0
- package/dist/types/composables/useSwitchChain.d.ts +17 -0
- package/dist/types/composables/useSwitchChain.d.ts.map +1 -0
- package/dist/types/composables/useTransaction.d.ts +11 -0
- package/dist/types/composables/useTransaction.d.ts.map +1 -0
- package/dist/types/composables/useTransactionReceipt.d.ts +12 -0
- package/dist/types/composables/useTransactionReceipt.d.ts.map +1 -0
- package/dist/types/composables/useWaitForTransactionReceipt.d.ts +11 -0
- package/dist/types/composables/useWaitForTransactionReceipt.d.ts.map +1 -0
- package/dist/types/composables/useWatchBlockNumber.d.ts +9 -0
- package/dist/types/composables/useWatchBlockNumber.d.ts.map +1 -0
- package/dist/types/composables/useWriteContract.d.ts +15 -0
- package/dist/types/composables/useWriteContract.d.ts.map +1 -0
- package/dist/types/errors/base.d.ts +10 -0
- package/dist/types/errors/base.d.ts.map +1 -0
- package/dist/types/errors/plugin.d.ts +16 -0
- package/dist/types/errors/plugin.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 +36 -0
- package/dist/types/exports/index.d.ts.map +1 -0
- package/dist/types/exports/nuxt.d.ts +4 -0
- package/dist/types/exports/nuxt.d.ts.map +1 -0
- package/dist/types/exports/query.d.ts +4 -0
- package/dist/types/exports/query.d.ts.map +1 -0
- package/dist/types/nuxt/module.d.ts +4 -0
- package/dist/types/nuxt/module.d.ts.map +1 -0
- package/dist/types/nuxt/runtime/composables.d.ts +2 -0
- package/dist/types/nuxt/runtime/composables.d.ts.map +1 -0
- package/dist/types/plugin.d.ts +11 -0
- package/dist/types/plugin.d.ts.map +1 -0
- package/dist/types/types/properties.d.ts +15 -0
- package/dist/types/types/properties.d.ts.map +1 -0
- package/dist/types/types/ref.d.ts +12 -0
- package/dist/types/types/ref.d.ts.map +1 -0
- package/dist/types/utils/cloneDeep.d.ts +3 -0
- package/dist/types/utils/cloneDeep.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 +17 -0
- package/dist/types/utils/query.d.ts.map +1 -0
- package/dist/types/utils/updateState.d.ts +2 -0
- package/dist/types/utils/updateState.d.ts.map +1 -0
- package/dist/types/version.d.ts +2 -0
- package/dist/types/version.d.ts.map +1 -0
- package/nuxt/package.json +5 -0
- package/package.json +108 -0
- package/query/package.json +5 -0
- package/src/composables/useAccount.ts +37 -0
- package/src/composables/useAccountEffect.ts +66 -0
- package/src/composables/useBalance.ts +69 -0
- package/src/composables/useBlockNumber.ts +118 -0
- package/src/composables/useChainId.ts +35 -0
- package/src/composables/useChains.ts +38 -0
- package/src/composables/useClient.ts +66 -0
- package/src/composables/useConfig.ts +34 -0
- package/src/composables/useConnect.ts +91 -0
- package/src/composables/useConnections.ts +30 -0
- package/src/composables/useConnectorClient.ts +127 -0
- package/src/composables/useConnectors.ts +30 -0
- package/src/composables/useDisconnect.ts +70 -0
- package/src/composables/useEnsAddress.ts +65 -0
- package/src/composables/useEnsAvatar.ts +65 -0
- package/src/composables/useEnsName.ts +65 -0
- package/src/composables/useEstimateGas.ts +83 -0
- package/src/composables/useReadContract.ts +121 -0
- package/src/composables/useReconnect.ts +65 -0
- package/src/composables/useSendTransaction.ts +76 -0
- package/src/composables/useSignMessage.ts +63 -0
- package/src/composables/useSignTypedData.ts +64 -0
- package/src/composables/useSimulateContract.ts +148 -0
- package/src/composables/useSwitchAccount.ts +84 -0
- package/src/composables/useSwitchChain.ts +80 -0
- package/src/composables/useTransaction.ts +88 -0
- package/src/composables/useTransactionReceipt.ts +85 -0
- package/src/composables/useWaitForTransactionReceipt.ts +81 -0
- package/src/composables/useWatchBlockNumber.ts +61 -0
- package/src/composables/useWriteContract.ts +85 -0
- package/src/errors/base.ts +14 -0
- package/src/errors/plugin.ts +31 -0
- package/src/exports/actions.ts +5 -0
- package/src/exports/chains.ts +5 -0
- package/src/exports/connectors.ts +5 -0
- package/src/exports/index.ts +260 -0
- package/src/exports/nuxt.ts +4 -0
- package/src/exports/query.ts +17 -0
- package/src/nuxt/module.ts +59 -0
- package/src/nuxt/runtime/composables.ts +1 -0
- package/src/plugin.ts +22 -0
- package/src/types/properties.ts +27 -0
- package/src/types/ref.ts +36 -0
- package/src/utils/cloneDeep.ts +43 -0
- package/src/utils/getVersion.ts +3 -0
- package/src/utils/query.ts +161 -0
- package/src/utils/updateState.ts +10 -0
- package/src/version.ts +1 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { useQueryClient } from '@tanstack/vue-query'
|
|
2
|
+
import type {
|
|
3
|
+
Config,
|
|
4
|
+
Connector,
|
|
5
|
+
GetConnectorClientErrorType,
|
|
6
|
+
ResolvedRegister,
|
|
7
|
+
} from '@wagmi/core'
|
|
8
|
+
import { type Evaluate, type Omit } from '@wagmi/core/internal'
|
|
9
|
+
import {
|
|
10
|
+
type GetConnectorClientData,
|
|
11
|
+
type GetConnectorClientOptions,
|
|
12
|
+
type GetConnectorClientQueryFnData,
|
|
13
|
+
type GetConnectorClientQueryKey,
|
|
14
|
+
getConnectorClientQueryOptions,
|
|
15
|
+
} from '@wagmi/core/query'
|
|
16
|
+
import { computed, ref, watchEffect } from 'vue'
|
|
17
|
+
|
|
18
|
+
import type { ConfigParameter } from '../types/properties.js'
|
|
19
|
+
import type { DeepMaybeRef, DeepUnwrapRef } from '../types/ref.js'
|
|
20
|
+
import { deepUnref } from '../utils/cloneDeep.js'
|
|
21
|
+
import {
|
|
22
|
+
type UseQueryParameters,
|
|
23
|
+
type UseQueryReturnType,
|
|
24
|
+
useQuery,
|
|
25
|
+
} from '../utils/query.js'
|
|
26
|
+
import { useAccount } from './useAccount.js'
|
|
27
|
+
import { useChainId } from './useChainId.js'
|
|
28
|
+
import { useConfig } from './useConfig.js'
|
|
29
|
+
|
|
30
|
+
export type UseConnectorClientParameters<
|
|
31
|
+
config extends Config = Config,
|
|
32
|
+
chainId extends config['chains'][number]['id'] = config['chains'][number]['id'],
|
|
33
|
+
selectData = GetConnectorClientData<config, chainId>,
|
|
34
|
+
> = Evaluate<
|
|
35
|
+
DeepMaybeRef<
|
|
36
|
+
GetConnectorClientOptions<config, chainId> &
|
|
37
|
+
ConfigParameter<config> & {
|
|
38
|
+
query?:
|
|
39
|
+
| Evaluate<
|
|
40
|
+
Omit<
|
|
41
|
+
DeepUnwrapRef<
|
|
42
|
+
UseQueryParameters<
|
|
43
|
+
GetConnectorClientQueryFnData<config, chainId>,
|
|
44
|
+
GetConnectorClientErrorType,
|
|
45
|
+
selectData,
|
|
46
|
+
GetConnectorClientQueryKey<config, chainId>
|
|
47
|
+
>
|
|
48
|
+
>,
|
|
49
|
+
'gcTime' | 'staleTime'
|
|
50
|
+
>
|
|
51
|
+
>
|
|
52
|
+
| undefined
|
|
53
|
+
}
|
|
54
|
+
>
|
|
55
|
+
>
|
|
56
|
+
|
|
57
|
+
export type UseConnectorClientReturnType<
|
|
58
|
+
config extends Config = Config,
|
|
59
|
+
chainId extends config['chains'][number]['id'] = config['chains'][number]['id'],
|
|
60
|
+
selectData = GetConnectorClientData<config, chainId>,
|
|
61
|
+
> = UseQueryReturnType<selectData, GetConnectorClientErrorType>
|
|
62
|
+
|
|
63
|
+
/** https://wagmi.sh/vue/api/composables/useConnectorClient */
|
|
64
|
+
export function useConnectorClient<
|
|
65
|
+
config extends Config = ResolvedRegister['config'],
|
|
66
|
+
chainId extends config['chains'][number]['id'] = config['chains'][number]['id'],
|
|
67
|
+
selectData = GetConnectorClientData<config, chainId>,
|
|
68
|
+
>(
|
|
69
|
+
parameters_: UseConnectorClientParameters<config, chainId, selectData> = {},
|
|
70
|
+
): UseConnectorClientReturnType<config, chainId, selectData> {
|
|
71
|
+
const parameters = computed(() => deepUnref(parameters_))
|
|
72
|
+
|
|
73
|
+
const config = useConfig(parameters)
|
|
74
|
+
const queryClient = useQueryClient()
|
|
75
|
+
const {
|
|
76
|
+
address,
|
|
77
|
+
connector: accountConnector,
|
|
78
|
+
status,
|
|
79
|
+
} = useAccount({ config })
|
|
80
|
+
const configChainId = useChainId({ config })
|
|
81
|
+
|
|
82
|
+
const queryOptions = computed(() => {
|
|
83
|
+
const {
|
|
84
|
+
chainId = configChainId.value,
|
|
85
|
+
connector = accountConnector.value,
|
|
86
|
+
query = {},
|
|
87
|
+
} = parameters.value
|
|
88
|
+
const { queryKey, ...options } = getConnectorClientQueryOptions<
|
|
89
|
+
config,
|
|
90
|
+
chainId
|
|
91
|
+
>(config as config, {
|
|
92
|
+
...deepUnref(parameters),
|
|
93
|
+
chainId: chainId as chainId,
|
|
94
|
+
connector: connector as Connector,
|
|
95
|
+
})
|
|
96
|
+
const enabled = Boolean(
|
|
97
|
+
status.value !== 'disconnected' && (query.enabled ?? true),
|
|
98
|
+
)
|
|
99
|
+
return {
|
|
100
|
+
...query,
|
|
101
|
+
...options,
|
|
102
|
+
queryKey,
|
|
103
|
+
enabled,
|
|
104
|
+
staleTime: Infinity,
|
|
105
|
+
}
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
const addressRef = ref(address)
|
|
109
|
+
watchEffect(() => {
|
|
110
|
+
const previousAddress = addressRef.value
|
|
111
|
+
if (!address && previousAddress) {
|
|
112
|
+
// remove when account is disconnected
|
|
113
|
+
queryClient.removeQueries({ queryKey: queryOptions.value.queryKey })
|
|
114
|
+
addressRef.value = undefined
|
|
115
|
+
} else if (address.value !== previousAddress) {
|
|
116
|
+
// invalidate when address changes
|
|
117
|
+
queryClient.invalidateQueries({ queryKey: queryOptions.value.queryKey })
|
|
118
|
+
addressRef.value = address.value
|
|
119
|
+
}
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
return useQuery(queryOptions as any) as UseConnectorClientReturnType<
|
|
123
|
+
config,
|
|
124
|
+
chainId,
|
|
125
|
+
selectData
|
|
126
|
+
>
|
|
127
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type GetConnectorsReturnType,
|
|
3
|
+
getConnectors,
|
|
4
|
+
watchConnectors,
|
|
5
|
+
} from '@wagmi/core'
|
|
6
|
+
import { type Ref, onScopeDispose, ref } from 'vue'
|
|
7
|
+
|
|
8
|
+
import type { ConfigParameter } from '../types/properties.js'
|
|
9
|
+
import { useConfig } from './useConfig.js'
|
|
10
|
+
|
|
11
|
+
export type UseConnectorsParameters = ConfigParameter
|
|
12
|
+
|
|
13
|
+
export type UseConnectorsReturnType = Ref<GetConnectorsReturnType>
|
|
14
|
+
|
|
15
|
+
/** https://wagmi.sh/vue/api/composables/useConnectors */
|
|
16
|
+
export function useConnectors(
|
|
17
|
+
parameters: UseConnectorsParameters = {},
|
|
18
|
+
): UseConnectorsReturnType {
|
|
19
|
+
const config = useConfig(parameters)
|
|
20
|
+
|
|
21
|
+
const connectors = ref(getConnectors(config))
|
|
22
|
+
const unsubscribe = watchConnectors(config, {
|
|
23
|
+
onChange(data) {
|
|
24
|
+
connectors.value = data
|
|
25
|
+
},
|
|
26
|
+
})
|
|
27
|
+
onScopeDispose(() => unsubscribe())
|
|
28
|
+
|
|
29
|
+
return connectors
|
|
30
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { useMutation } from '@tanstack/vue-query'
|
|
2
|
+
import { type Connector, type DisconnectErrorType } from '@wagmi/core'
|
|
3
|
+
import type { Evaluate } from '@wagmi/core/internal'
|
|
4
|
+
import {
|
|
5
|
+
type DisconnectData,
|
|
6
|
+
type DisconnectMutate,
|
|
7
|
+
type DisconnectMutateAsync,
|
|
8
|
+
type DisconnectVariables,
|
|
9
|
+
disconnectMutationOptions,
|
|
10
|
+
} from '@wagmi/core/query'
|
|
11
|
+
import { type Ref, computed } from 'vue'
|
|
12
|
+
|
|
13
|
+
import type { ConfigParameter } from '../types/properties.js'
|
|
14
|
+
import type {
|
|
15
|
+
UseMutationParameters,
|
|
16
|
+
UseMutationReturnType,
|
|
17
|
+
} from '../utils/query.js'
|
|
18
|
+
import { useConfig } from './useConfig.js'
|
|
19
|
+
import { useConnections } from './useConnections.js'
|
|
20
|
+
|
|
21
|
+
export type UseDisconnectParameters<context = unknown> = Evaluate<
|
|
22
|
+
ConfigParameter & {
|
|
23
|
+
mutation?:
|
|
24
|
+
| UseMutationParameters<
|
|
25
|
+
DisconnectData,
|
|
26
|
+
DisconnectErrorType,
|
|
27
|
+
DisconnectVariables,
|
|
28
|
+
context
|
|
29
|
+
>
|
|
30
|
+
| undefined
|
|
31
|
+
}
|
|
32
|
+
>
|
|
33
|
+
|
|
34
|
+
export type UseDisconnectReturnType<context = unknown> = Evaluate<
|
|
35
|
+
UseMutationReturnType<
|
|
36
|
+
DisconnectData,
|
|
37
|
+
DisconnectErrorType,
|
|
38
|
+
DisconnectVariables,
|
|
39
|
+
context
|
|
40
|
+
> & {
|
|
41
|
+
connectors: Ref<readonly Connector[]>
|
|
42
|
+
disconnect: DisconnectMutate<context>
|
|
43
|
+
disconnectAsync: DisconnectMutateAsync<context>
|
|
44
|
+
}
|
|
45
|
+
>
|
|
46
|
+
|
|
47
|
+
/** https://wagmi.sh/vue/api/composables/useDisconnect */
|
|
48
|
+
export function useDisconnect<context = unknown>(
|
|
49
|
+
parameters: UseDisconnectParameters<context> = {},
|
|
50
|
+
): UseDisconnectReturnType<context> {
|
|
51
|
+
const { mutation } = parameters
|
|
52
|
+
|
|
53
|
+
const config = useConfig(parameters)
|
|
54
|
+
const connections = useConnections({ config })
|
|
55
|
+
|
|
56
|
+
const mutationOptions = disconnectMutationOptions(config)
|
|
57
|
+
const { mutate, mutateAsync, ...result } = useMutation({
|
|
58
|
+
...mutation,
|
|
59
|
+
...mutationOptions,
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
...result,
|
|
64
|
+
connectors: computed(() =>
|
|
65
|
+
connections.value.map((connection) => connection.connector),
|
|
66
|
+
),
|
|
67
|
+
disconnect: mutate,
|
|
68
|
+
disconnectAsync: mutateAsync,
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Config,
|
|
3
|
+
GetEnsAddressErrorType,
|
|
4
|
+
ResolvedRegister,
|
|
5
|
+
} from '@wagmi/core'
|
|
6
|
+
import { type Evaluate } from '@wagmi/core/internal'
|
|
7
|
+
import {
|
|
8
|
+
type GetEnsAddressData,
|
|
9
|
+
type GetEnsAddressOptions,
|
|
10
|
+
type GetEnsAddressQueryFnData,
|
|
11
|
+
type GetEnsAddressQueryKey,
|
|
12
|
+
getEnsAddressQueryOptions,
|
|
13
|
+
} from '@wagmi/core/query'
|
|
14
|
+
import { computed } from 'vue'
|
|
15
|
+
|
|
16
|
+
import type { ConfigParameter, QueryParameter } from '../types/properties.js'
|
|
17
|
+
import type { DeepMaybeRef } from '../types/ref.js'
|
|
18
|
+
import { deepUnref } from '../utils/cloneDeep.js'
|
|
19
|
+
import { type UseQueryReturnType, useQuery } from '../utils/query.js'
|
|
20
|
+
import { useChainId } from './useChainId.js'
|
|
21
|
+
import { useConfig } from './useConfig.js'
|
|
22
|
+
|
|
23
|
+
export type UseEnsAddressParameters<
|
|
24
|
+
config extends Config = Config,
|
|
25
|
+
selectData = GetEnsAddressData,
|
|
26
|
+
> = Evaluate<
|
|
27
|
+
DeepMaybeRef<
|
|
28
|
+
GetEnsAddressOptions<config> &
|
|
29
|
+
ConfigParameter<config> &
|
|
30
|
+
QueryParameter<
|
|
31
|
+
GetEnsAddressQueryFnData,
|
|
32
|
+
GetEnsAddressErrorType,
|
|
33
|
+
selectData,
|
|
34
|
+
GetEnsAddressQueryKey<config>
|
|
35
|
+
>
|
|
36
|
+
>
|
|
37
|
+
>
|
|
38
|
+
|
|
39
|
+
export type UseEnsAddressReturnType<selectData = GetEnsAddressData> =
|
|
40
|
+
UseQueryReturnType<selectData, GetEnsAddressErrorType>
|
|
41
|
+
|
|
42
|
+
/** https://wagmi.sh/vue/api/composables/useEnsAddress */
|
|
43
|
+
export function useEnsAddress<
|
|
44
|
+
config extends Config = ResolvedRegister['config'],
|
|
45
|
+
selectData = GetEnsAddressData,
|
|
46
|
+
>(
|
|
47
|
+
parameters_: UseEnsAddressParameters<config, selectData> = {},
|
|
48
|
+
): UseEnsAddressReturnType<selectData> {
|
|
49
|
+
const parameters = computed(() => deepUnref(parameters_))
|
|
50
|
+
|
|
51
|
+
const config = useConfig(parameters)
|
|
52
|
+
const configChainId = useChainId({ config })
|
|
53
|
+
|
|
54
|
+
const queryOptions = computed(() => {
|
|
55
|
+
const { chainId = configChainId.value, name, query = {} } = parameters.value
|
|
56
|
+
const options = getEnsAddressQueryOptions(config, {
|
|
57
|
+
...parameters.value,
|
|
58
|
+
chainId,
|
|
59
|
+
})
|
|
60
|
+
const enabled = Boolean(name && (query.enabled ?? true))
|
|
61
|
+
return { ...query, ...options, enabled }
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
return useQuery(queryOptions as any) as UseEnsAddressReturnType<selectData>
|
|
65
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Config,
|
|
3
|
+
GetEnsAvatarErrorType,
|
|
4
|
+
ResolvedRegister,
|
|
5
|
+
} from '@wagmi/core'
|
|
6
|
+
import { type Evaluate } from '@wagmi/core/internal'
|
|
7
|
+
import {
|
|
8
|
+
type GetEnsAvatarData,
|
|
9
|
+
type GetEnsAvatarOptions,
|
|
10
|
+
type GetEnsAvatarQueryFnData,
|
|
11
|
+
type GetEnsAvatarQueryKey,
|
|
12
|
+
getEnsAvatarQueryOptions,
|
|
13
|
+
} from '@wagmi/core/query'
|
|
14
|
+
import { computed } from 'vue'
|
|
15
|
+
|
|
16
|
+
import type { ConfigParameter, QueryParameter } from '../types/properties.js'
|
|
17
|
+
import type { DeepMaybeRef } from '../types/ref.js'
|
|
18
|
+
import { deepUnref } from '../utils/cloneDeep.js'
|
|
19
|
+
import { type UseQueryReturnType, useQuery } from '../utils/query.js'
|
|
20
|
+
import { useChainId } from './useChainId.js'
|
|
21
|
+
import { useConfig } from './useConfig.js'
|
|
22
|
+
|
|
23
|
+
export type UseEnsAvatarParameters<
|
|
24
|
+
config extends Config = Config,
|
|
25
|
+
selectData = GetEnsAvatarData,
|
|
26
|
+
> = Evaluate<
|
|
27
|
+
DeepMaybeRef<
|
|
28
|
+
GetEnsAvatarOptions<config> &
|
|
29
|
+
ConfigParameter<config> &
|
|
30
|
+
QueryParameter<
|
|
31
|
+
GetEnsAvatarQueryFnData,
|
|
32
|
+
GetEnsAvatarErrorType,
|
|
33
|
+
selectData,
|
|
34
|
+
GetEnsAvatarQueryKey<config>
|
|
35
|
+
>
|
|
36
|
+
>
|
|
37
|
+
>
|
|
38
|
+
|
|
39
|
+
export type UseEnsAvatarReturnType<selectData = GetEnsAvatarData> =
|
|
40
|
+
UseQueryReturnType<selectData, GetEnsAvatarErrorType>
|
|
41
|
+
|
|
42
|
+
/** https://wagmi.sh/vue/api/composables/useEnsAvatar */
|
|
43
|
+
export function useEnsAvatar<
|
|
44
|
+
config extends Config = ResolvedRegister['config'],
|
|
45
|
+
selectData = GetEnsAvatarData,
|
|
46
|
+
>(
|
|
47
|
+
parameters_: UseEnsAvatarParameters<config, selectData> = {},
|
|
48
|
+
): UseEnsAvatarReturnType<selectData> {
|
|
49
|
+
const parameters = computed(() => deepUnref(parameters_))
|
|
50
|
+
|
|
51
|
+
const config = useConfig(parameters)
|
|
52
|
+
const configChainId = useChainId({ config })
|
|
53
|
+
|
|
54
|
+
const queryOptions = computed(() => {
|
|
55
|
+
const { chainId = configChainId.value, name, query = {} } = parameters.value
|
|
56
|
+
const options = getEnsAvatarQueryOptions(config, {
|
|
57
|
+
...parameters.value,
|
|
58
|
+
chainId,
|
|
59
|
+
})
|
|
60
|
+
const enabled = Boolean(name && (query.enabled ?? true))
|
|
61
|
+
return { ...query, ...options, enabled }
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
return useQuery(queryOptions as any) as UseEnsAvatarReturnType<selectData>
|
|
65
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { Config, GetEnsNameErrorType, ResolvedRegister } from '@wagmi/core'
|
|
2
|
+
import { type Evaluate } from '@wagmi/core/internal'
|
|
3
|
+
import {
|
|
4
|
+
type GetEnsNameData,
|
|
5
|
+
type GetEnsNameOptions,
|
|
6
|
+
type GetEnsNameQueryFnData,
|
|
7
|
+
type GetEnsNameQueryKey,
|
|
8
|
+
getEnsNameQueryOptions,
|
|
9
|
+
} from '@wagmi/core/query'
|
|
10
|
+
|
|
11
|
+
import { computed } from 'vue'
|
|
12
|
+
import type { ConfigParameter, QueryParameter } from '../types/properties.js'
|
|
13
|
+
import type { DeepMaybeRef } from '../types/ref.js'
|
|
14
|
+
import { deepUnref } from '../utils/cloneDeep.js'
|
|
15
|
+
import { type UseQueryReturnType, useQuery } from '../utils/query.js'
|
|
16
|
+
import { useChainId } from './useChainId.js'
|
|
17
|
+
import { useConfig } from './useConfig.js'
|
|
18
|
+
|
|
19
|
+
export type UseEnsNameParameters<
|
|
20
|
+
config extends Config = Config,
|
|
21
|
+
selectData = GetEnsNameData,
|
|
22
|
+
> = Evaluate<
|
|
23
|
+
DeepMaybeRef<
|
|
24
|
+
GetEnsNameOptions<config> &
|
|
25
|
+
ConfigParameter<config> &
|
|
26
|
+
QueryParameter<
|
|
27
|
+
GetEnsNameQueryFnData,
|
|
28
|
+
GetEnsNameErrorType,
|
|
29
|
+
selectData,
|
|
30
|
+
GetEnsNameQueryKey<config>
|
|
31
|
+
>
|
|
32
|
+
>
|
|
33
|
+
>
|
|
34
|
+
|
|
35
|
+
export type UseEnsNameReturnType<selectData = GetEnsNameData> =
|
|
36
|
+
UseQueryReturnType<selectData, GetEnsNameErrorType>
|
|
37
|
+
|
|
38
|
+
/** https://wagmi.sh/vue/api/composables/useEnsName */
|
|
39
|
+
export function useEnsName<
|
|
40
|
+
config extends Config = ResolvedRegister['config'],
|
|
41
|
+
selectData = GetEnsNameData,
|
|
42
|
+
>(
|
|
43
|
+
parameters_: UseEnsNameParameters<config, selectData> = {},
|
|
44
|
+
): UseEnsNameReturnType<selectData> {
|
|
45
|
+
const parameters = computed(() => deepUnref(parameters_))
|
|
46
|
+
|
|
47
|
+
const config = useConfig(parameters)
|
|
48
|
+
const configChainId = useChainId({ config })
|
|
49
|
+
|
|
50
|
+
const queryOptions = computed(() => {
|
|
51
|
+
const {
|
|
52
|
+
address,
|
|
53
|
+
chainId = configChainId.value,
|
|
54
|
+
query = {},
|
|
55
|
+
} = parameters.value
|
|
56
|
+
const options = getEnsNameQueryOptions(config, {
|
|
57
|
+
...parameters.value,
|
|
58
|
+
chainId,
|
|
59
|
+
})
|
|
60
|
+
const enabled = Boolean(address && (query.enabled ?? true))
|
|
61
|
+
return { ...query, ...options, enabled }
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
return useQuery(queryOptions as any) as UseEnsNameReturnType<selectData>
|
|
65
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Config,
|
|
3
|
+
EstimateGasErrorType,
|
|
4
|
+
ResolvedRegister,
|
|
5
|
+
} from '@wagmi/core'
|
|
6
|
+
import {
|
|
7
|
+
type EstimateGasData,
|
|
8
|
+
type EstimateGasOptions,
|
|
9
|
+
type EstimateGasQueryFnData,
|
|
10
|
+
type EstimateGasQueryKey,
|
|
11
|
+
estimateGasQueryOptions,
|
|
12
|
+
} from '@wagmi/core/query'
|
|
13
|
+
import { computed } from 'vue'
|
|
14
|
+
|
|
15
|
+
import type { ConfigParameter, QueryParameter } from '../types/properties.js'
|
|
16
|
+
import type { DeepMaybeRef } from '../types/ref.js'
|
|
17
|
+
import { deepUnref } from '../utils/cloneDeep.js'
|
|
18
|
+
import { type UseQueryReturnType, useQuery } from '../utils/query.js'
|
|
19
|
+
import { useChainId } from './useChainId.js'
|
|
20
|
+
import { useConfig } from './useConfig.js'
|
|
21
|
+
import { useConnectorClient } from './useConnectorClient.js'
|
|
22
|
+
|
|
23
|
+
export type UseEstimateGasParameters<
|
|
24
|
+
config extends Config = Config,
|
|
25
|
+
chainId extends config['chains'][number]['id'] | undefined = undefined,
|
|
26
|
+
selectData = EstimateGasData,
|
|
27
|
+
> = DeepMaybeRef<
|
|
28
|
+
EstimateGasOptions<config, chainId> &
|
|
29
|
+
ConfigParameter<config> &
|
|
30
|
+
QueryParameter<
|
|
31
|
+
EstimateGasQueryFnData,
|
|
32
|
+
EstimateGasErrorType,
|
|
33
|
+
selectData,
|
|
34
|
+
EstimateGasQueryKey<config, chainId>
|
|
35
|
+
>
|
|
36
|
+
>
|
|
37
|
+
|
|
38
|
+
export type UseEstimateGasReturnType<selectData = EstimateGasData> =
|
|
39
|
+
UseQueryReturnType<selectData, EstimateGasErrorType>
|
|
40
|
+
|
|
41
|
+
/** https://wagmi.sh/react/api/hooks/useEstimateGas */
|
|
42
|
+
export function useEstimateGas<
|
|
43
|
+
config extends Config = ResolvedRegister['config'],
|
|
44
|
+
chainId extends config['chains'][number]['id'] | undefined = undefined,
|
|
45
|
+
selectData = EstimateGasData,
|
|
46
|
+
>(
|
|
47
|
+
parameters?: UseEstimateGasParameters<config, chainId, selectData>,
|
|
48
|
+
): UseEstimateGasReturnType<selectData>
|
|
49
|
+
|
|
50
|
+
export function useEstimateGas(
|
|
51
|
+
parameters_: UseEstimateGasParameters = {},
|
|
52
|
+
): UseEstimateGasReturnType {
|
|
53
|
+
const parameters = computed(() => deepUnref(parameters_))
|
|
54
|
+
|
|
55
|
+
const config = useConfig(parameters)
|
|
56
|
+
const { data: connectorClient } = useConnectorClient(
|
|
57
|
+
computed(() => ({
|
|
58
|
+
connector: parameters.value.connector,
|
|
59
|
+
query: { enabled: parameters.value.account === undefined },
|
|
60
|
+
})),
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
const configChainId = useChainId({ config })
|
|
64
|
+
|
|
65
|
+
const queryOptions = computed(() => {
|
|
66
|
+
const {
|
|
67
|
+
account = connectorClient?.value?.account,
|
|
68
|
+
chainId = configChainId.value,
|
|
69
|
+
connector,
|
|
70
|
+
query = {},
|
|
71
|
+
} = parameters.value
|
|
72
|
+
const options = estimateGasQueryOptions(config, {
|
|
73
|
+
...parameters.value,
|
|
74
|
+
account,
|
|
75
|
+
chainId,
|
|
76
|
+
connector,
|
|
77
|
+
})
|
|
78
|
+
const enabled = Boolean((account || connector) && (query.enabled ?? true))
|
|
79
|
+
return { ...query, ...options, enabled }
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
return useQuery(queryOptions)
|
|
83
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type Config,
|
|
3
|
+
type ReadContractErrorType,
|
|
4
|
+
type ResolvedRegister,
|
|
5
|
+
} from '@wagmi/core'
|
|
6
|
+
import { type UnionEvaluate } from '@wagmi/core/internal'
|
|
7
|
+
import {
|
|
8
|
+
type ReadContractData,
|
|
9
|
+
type ReadContractOptions,
|
|
10
|
+
type ReadContractQueryFnData,
|
|
11
|
+
type ReadContractQueryKey,
|
|
12
|
+
readContractQueryOptions,
|
|
13
|
+
structuralSharing,
|
|
14
|
+
} from '@wagmi/core/query'
|
|
15
|
+
import {
|
|
16
|
+
type Abi,
|
|
17
|
+
type ContractFunctionArgs,
|
|
18
|
+
type ContractFunctionName,
|
|
19
|
+
} from 'viem'
|
|
20
|
+
|
|
21
|
+
import { computed } from 'vue'
|
|
22
|
+
import type { ConfigParameter, QueryParameter } from '../types/properties.js'
|
|
23
|
+
import type { DeepMaybeRef } from '../types/ref.js'
|
|
24
|
+
import { deepUnref } from '../utils/cloneDeep.js'
|
|
25
|
+
import { type UseQueryReturnType, useQuery } from '../utils/query.js'
|
|
26
|
+
import { useChainId } from './useChainId.js'
|
|
27
|
+
import { useConfig } from './useConfig.js'
|
|
28
|
+
|
|
29
|
+
export type UseReadContractParameters<
|
|
30
|
+
abi extends Abi | readonly unknown[] = Abi,
|
|
31
|
+
functionName extends ContractFunctionName<
|
|
32
|
+
abi,
|
|
33
|
+
'pure' | 'view'
|
|
34
|
+
> = ContractFunctionName<abi, 'pure' | 'view'>,
|
|
35
|
+
args extends ContractFunctionArgs<
|
|
36
|
+
abi,
|
|
37
|
+
'pure' | 'view',
|
|
38
|
+
functionName
|
|
39
|
+
> = ContractFunctionArgs<abi, 'pure' | 'view', functionName>,
|
|
40
|
+
config extends Config = Config,
|
|
41
|
+
selectData = ReadContractData<abi, functionName, args>,
|
|
42
|
+
> = UnionEvaluate<
|
|
43
|
+
DeepMaybeRef<
|
|
44
|
+
ReadContractOptions<abi, functionName, args, config> &
|
|
45
|
+
ConfigParameter<config> &
|
|
46
|
+
QueryParameter<
|
|
47
|
+
ReadContractQueryFnData<abi, functionName, args>,
|
|
48
|
+
ReadContractErrorType,
|
|
49
|
+
selectData,
|
|
50
|
+
ReadContractQueryKey<abi, functionName, args, config>
|
|
51
|
+
>
|
|
52
|
+
>
|
|
53
|
+
>
|
|
54
|
+
|
|
55
|
+
export type UseReadContractReturnType<
|
|
56
|
+
abi extends Abi | readonly unknown[] = Abi,
|
|
57
|
+
functionName extends ContractFunctionName<
|
|
58
|
+
abi,
|
|
59
|
+
'pure' | 'view'
|
|
60
|
+
> = ContractFunctionName<abi, 'pure' | 'view'>,
|
|
61
|
+
args extends ContractFunctionArgs<
|
|
62
|
+
abi,
|
|
63
|
+
'pure' | 'view',
|
|
64
|
+
functionName
|
|
65
|
+
> = ContractFunctionArgs<abi, 'pure' | 'view', functionName>,
|
|
66
|
+
selectData = ReadContractData<abi, functionName, args>,
|
|
67
|
+
> = UseQueryReturnType<selectData, ReadContractErrorType>
|
|
68
|
+
|
|
69
|
+
/** https://wagmi.sh/vue/api/hooks/useReadContract */
|
|
70
|
+
export function useReadContract<
|
|
71
|
+
const abi extends Abi | readonly unknown[],
|
|
72
|
+
functionName extends ContractFunctionName<abi, 'pure' | 'view'>,
|
|
73
|
+
args extends ContractFunctionArgs<abi, 'pure' | 'view', functionName>,
|
|
74
|
+
config extends Config = ResolvedRegister['config'],
|
|
75
|
+
selectData = ReadContractData<abi, functionName, args>,
|
|
76
|
+
>(
|
|
77
|
+
parameters_: UseReadContractParameters<
|
|
78
|
+
abi,
|
|
79
|
+
functionName,
|
|
80
|
+
args,
|
|
81
|
+
config,
|
|
82
|
+
selectData
|
|
83
|
+
> = {} as any,
|
|
84
|
+
): UseReadContractReturnType<abi, functionName, args, selectData> {
|
|
85
|
+
const parameters = computed(() =>
|
|
86
|
+
deepUnref(parameters_),
|
|
87
|
+
) as UseReadContractParameters
|
|
88
|
+
|
|
89
|
+
const config = useConfig(parameters)
|
|
90
|
+
const configChainId = useChainId({ config })
|
|
91
|
+
|
|
92
|
+
const queryOptions = computed(() => {
|
|
93
|
+
const {
|
|
94
|
+
abi,
|
|
95
|
+
address,
|
|
96
|
+
chainId = configChainId.value,
|
|
97
|
+
functionName,
|
|
98
|
+
query = {},
|
|
99
|
+
} = parameters.value as any
|
|
100
|
+
const options = readContractQueryOptions<config, abi, functionName, args>(
|
|
101
|
+
config as config,
|
|
102
|
+
{ ...(parameters.value as any), chainId },
|
|
103
|
+
)
|
|
104
|
+
const enabled = Boolean(
|
|
105
|
+
address && abi && functionName && (query.enabled ?? true),
|
|
106
|
+
)
|
|
107
|
+
return {
|
|
108
|
+
...query,
|
|
109
|
+
...options,
|
|
110
|
+
enabled,
|
|
111
|
+
structuralSharing: query.structuralSharing ?? structuralSharing,
|
|
112
|
+
}
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
return useQuery(queryOptions) as UseReadContractReturnType<
|
|
116
|
+
abi,
|
|
117
|
+
functionName,
|
|
118
|
+
args,
|
|
119
|
+
selectData
|
|
120
|
+
>
|
|
121
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { useMutation } from '@tanstack/vue-query'
|
|
2
|
+
import { type Connector, type ReconnectErrorType } from '@wagmi/core'
|
|
3
|
+
import type { Evaluate } from '@wagmi/core/internal'
|
|
4
|
+
import {
|
|
5
|
+
type ReconnectData,
|
|
6
|
+
type ReconnectMutate,
|
|
7
|
+
type ReconnectMutateAsync,
|
|
8
|
+
type ReconnectVariables,
|
|
9
|
+
reconnectMutationOptions,
|
|
10
|
+
} from '@wagmi/core/query'
|
|
11
|
+
|
|
12
|
+
import type { ConfigParameter } from '../types/properties.js'
|
|
13
|
+
import type {
|
|
14
|
+
UseMutationParameters,
|
|
15
|
+
UseMutationReturnType,
|
|
16
|
+
} from '../utils/query.js'
|
|
17
|
+
import { useConfig } from './useConfig.js'
|
|
18
|
+
|
|
19
|
+
export type UseReconnectParameters<context = unknown> = Evaluate<
|
|
20
|
+
ConfigParameter & {
|
|
21
|
+
mutation?:
|
|
22
|
+
| UseMutationParameters<
|
|
23
|
+
ReconnectData,
|
|
24
|
+
ReconnectErrorType,
|
|
25
|
+
ReconnectVariables,
|
|
26
|
+
context
|
|
27
|
+
>
|
|
28
|
+
| undefined
|
|
29
|
+
}
|
|
30
|
+
>
|
|
31
|
+
|
|
32
|
+
export type UseReconnectReturnType<context = unknown> = Evaluate<
|
|
33
|
+
UseMutationReturnType<
|
|
34
|
+
ReconnectData,
|
|
35
|
+
ReconnectErrorType,
|
|
36
|
+
ReconnectVariables,
|
|
37
|
+
context
|
|
38
|
+
> & {
|
|
39
|
+
connectors: readonly Connector[]
|
|
40
|
+
reconnect: ReconnectMutate<context>
|
|
41
|
+
reconnectAsync: ReconnectMutateAsync<context>
|
|
42
|
+
}
|
|
43
|
+
>
|
|
44
|
+
|
|
45
|
+
/** https://wagmi.sh/vue/api/composables/useReconnect */
|
|
46
|
+
export function useReconnect<context = unknown>(
|
|
47
|
+
parameters: UseReconnectParameters<context> = {},
|
|
48
|
+
): UseReconnectReturnType<context> {
|
|
49
|
+
const { mutation } = parameters
|
|
50
|
+
|
|
51
|
+
const config = useConfig(parameters)
|
|
52
|
+
|
|
53
|
+
const mutationOptions = reconnectMutationOptions(config)
|
|
54
|
+
const { mutate, mutateAsync, ...result } = useMutation({
|
|
55
|
+
...mutation,
|
|
56
|
+
...mutationOptions,
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
...result,
|
|
61
|
+
connectors: config.connectors,
|
|
62
|
+
reconnect: mutate,
|
|
63
|
+
reconnectAsync: mutateAsync,
|
|
64
|
+
}
|
|
65
|
+
}
|