@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,81 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Config,
|
|
3
|
+
ResolvedRegister,
|
|
4
|
+
WaitForTransactionReceiptErrorType,
|
|
5
|
+
} from '@wagmi/core'
|
|
6
|
+
import { type Evaluate } from '@wagmi/core/internal'
|
|
7
|
+
import {
|
|
8
|
+
type WaitForTransactionReceiptData,
|
|
9
|
+
type WaitForTransactionReceiptOptions,
|
|
10
|
+
type WaitForTransactionReceiptQueryFnData,
|
|
11
|
+
type WaitForTransactionReceiptQueryKey,
|
|
12
|
+
waitForTransactionReceiptQueryOptions,
|
|
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 UseWaitForTransactionReceiptParameters<
|
|
24
|
+
config extends Config = Config,
|
|
25
|
+
chainId extends config['chains'][number]['id'] = config['chains'][number]['id'],
|
|
26
|
+
selectData = WaitForTransactionReceiptData<config, chainId>,
|
|
27
|
+
> = Evaluate<
|
|
28
|
+
DeepMaybeRef<
|
|
29
|
+
WaitForTransactionReceiptOptions<config, chainId> &
|
|
30
|
+
ConfigParameter<config> &
|
|
31
|
+
QueryParameter<
|
|
32
|
+
WaitForTransactionReceiptQueryFnData<config, chainId>,
|
|
33
|
+
WaitForTransactionReceiptErrorType,
|
|
34
|
+
selectData,
|
|
35
|
+
WaitForTransactionReceiptQueryKey<config, chainId>
|
|
36
|
+
>
|
|
37
|
+
>
|
|
38
|
+
>
|
|
39
|
+
|
|
40
|
+
export type UseWaitForTransactionReceiptReturnType<
|
|
41
|
+
config extends Config = Config,
|
|
42
|
+
chainId extends config['chains'][number]['id'] = config['chains'][number]['id'],
|
|
43
|
+
selectData = WaitForTransactionReceiptData<config, chainId>,
|
|
44
|
+
> = UseQueryReturnType<selectData, WaitForTransactionReceiptErrorType>
|
|
45
|
+
|
|
46
|
+
/** https://wagmi.sh/vue/api/composables/useWaitForTransactionReceipt */
|
|
47
|
+
export function useWaitForTransactionReceipt<
|
|
48
|
+
config extends Config = ResolvedRegister['config'],
|
|
49
|
+
chainId extends config['chains'][number]['id'] = config['chains'][number]['id'],
|
|
50
|
+
selectData = WaitForTransactionReceiptData<config, chainId>,
|
|
51
|
+
>(
|
|
52
|
+
parameters_: UseWaitForTransactionReceiptParameters<
|
|
53
|
+
config,
|
|
54
|
+
chainId,
|
|
55
|
+
selectData
|
|
56
|
+
> = {},
|
|
57
|
+
): UseWaitForTransactionReceiptReturnType<config, chainId, selectData> {
|
|
58
|
+
const parameters = computed(() => deepUnref(parameters_))
|
|
59
|
+
const config = useConfig(parameters_)
|
|
60
|
+
const configChainId = useChainId()
|
|
61
|
+
|
|
62
|
+
const queryOptions = computed(() => {
|
|
63
|
+
const { chainId = configChainId.value, hash, query = {} } = parameters.value
|
|
64
|
+
|
|
65
|
+
const options = waitForTransactionReceiptQueryOptions(config, {
|
|
66
|
+
...parameters.value,
|
|
67
|
+
chainId,
|
|
68
|
+
})
|
|
69
|
+
const enabled = Boolean(hash && (query.enabled ?? true))
|
|
70
|
+
|
|
71
|
+
return {
|
|
72
|
+
...query,
|
|
73
|
+
...options,
|
|
74
|
+
enabled,
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
return useQuery(
|
|
79
|
+
queryOptions as any,
|
|
80
|
+
) as UseWaitForTransactionReceiptReturnType<config, chainId, selectData>
|
|
81
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type Config,
|
|
3
|
+
type ResolvedRegister,
|
|
4
|
+
type WatchBlockNumberParameters,
|
|
5
|
+
watchBlockNumber,
|
|
6
|
+
} from '@wagmi/core'
|
|
7
|
+
import { type UnionEvaluate, type UnionPartial } from '@wagmi/core/internal'
|
|
8
|
+
import { computed, watchEffect } from 'vue'
|
|
9
|
+
|
|
10
|
+
import type { ConfigParameter, EnabledParameter } from '../types/properties.js'
|
|
11
|
+
import type { DeepMaybeRef } from '../types/ref.js'
|
|
12
|
+
import { deepUnref } from '../utils/cloneDeep.js'
|
|
13
|
+
import { useChainId } from './useChainId.js'
|
|
14
|
+
import { useConfig } from './useConfig.js'
|
|
15
|
+
|
|
16
|
+
export type UseWatchBlockNumberParameters<
|
|
17
|
+
config extends Config = Config,
|
|
18
|
+
chainId extends config['chains'][number]['id'] = config['chains'][number]['id'],
|
|
19
|
+
> = DeepMaybeRef<
|
|
20
|
+
UnionEvaluate<
|
|
21
|
+
UnionPartial<WatchBlockNumberParameters<config, chainId>> &
|
|
22
|
+
ConfigParameter<config> &
|
|
23
|
+
EnabledParameter
|
|
24
|
+
>
|
|
25
|
+
>
|
|
26
|
+
|
|
27
|
+
export type UseWatchBlockNumberReturnType = void
|
|
28
|
+
|
|
29
|
+
/** https://wagmi.sh/vue/api/composables/useWatchBlockNumber */
|
|
30
|
+
export function useWatchBlockNumber<
|
|
31
|
+
config extends Config = ResolvedRegister['config'],
|
|
32
|
+
chainId extends config['chains'][number]['id'] = config['chains'][number]['id'],
|
|
33
|
+
>(
|
|
34
|
+
parameters_: UseWatchBlockNumberParameters<config, chainId> = {} as any,
|
|
35
|
+
): UseWatchBlockNumberReturnType {
|
|
36
|
+
const parameters = computed(() => deepUnref(parameters_))
|
|
37
|
+
|
|
38
|
+
const config = useConfig(parameters)
|
|
39
|
+
const configChainId = useChainId({ config })
|
|
40
|
+
|
|
41
|
+
watchEffect((onCleanup) => {
|
|
42
|
+
const {
|
|
43
|
+
chainId = configChainId.value,
|
|
44
|
+
enabled = true,
|
|
45
|
+
onBlockNumber,
|
|
46
|
+
config: _,
|
|
47
|
+
...rest
|
|
48
|
+
} = parameters.value
|
|
49
|
+
|
|
50
|
+
if (!enabled) return
|
|
51
|
+
if (!onBlockNumber) return
|
|
52
|
+
|
|
53
|
+
const unwatch = watchBlockNumber(config, {
|
|
54
|
+
...(rest as any),
|
|
55
|
+
chainId,
|
|
56
|
+
onBlockNumber,
|
|
57
|
+
emitOnBegin: true,
|
|
58
|
+
})
|
|
59
|
+
onCleanup(unwatch)
|
|
60
|
+
})
|
|
61
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { useMutation } from '@tanstack/vue-query'
|
|
2
|
+
import type {
|
|
3
|
+
Config,
|
|
4
|
+
ResolvedRegister,
|
|
5
|
+
WriteContractErrorType,
|
|
6
|
+
} from '@wagmi/core'
|
|
7
|
+
import {
|
|
8
|
+
type WriteContractData,
|
|
9
|
+
type WriteContractMutate,
|
|
10
|
+
type WriteContractMutateAsync,
|
|
11
|
+
type WriteContractVariables,
|
|
12
|
+
writeContractMutationOptions,
|
|
13
|
+
} from '@wagmi/core/query'
|
|
14
|
+
import type { Abi } from 'viem'
|
|
15
|
+
|
|
16
|
+
import type { ConfigParameter } from '../types/properties.js'
|
|
17
|
+
import type {
|
|
18
|
+
UseMutationParameters,
|
|
19
|
+
UseMutationReturnType,
|
|
20
|
+
} from '../utils/query.js'
|
|
21
|
+
import { useConfig } from './useConfig.js'
|
|
22
|
+
|
|
23
|
+
export type UseWriteContractParameters<
|
|
24
|
+
config extends Config = Config,
|
|
25
|
+
context = unknown,
|
|
26
|
+
> = ConfigParameter<config> & {
|
|
27
|
+
mutation?:
|
|
28
|
+
| UseMutationParameters<
|
|
29
|
+
WriteContractData,
|
|
30
|
+
WriteContractErrorType,
|
|
31
|
+
WriteContractVariables<
|
|
32
|
+
Abi,
|
|
33
|
+
string,
|
|
34
|
+
readonly unknown[],
|
|
35
|
+
config,
|
|
36
|
+
config['chains'][number]['id']
|
|
37
|
+
>,
|
|
38
|
+
context
|
|
39
|
+
>
|
|
40
|
+
| undefined
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export type UseWriteContractReturnType<
|
|
44
|
+
config extends Config = Config,
|
|
45
|
+
context = unknown,
|
|
46
|
+
> = UseMutationReturnType<
|
|
47
|
+
WriteContractData,
|
|
48
|
+
WriteContractErrorType,
|
|
49
|
+
WriteContractVariables<
|
|
50
|
+
Abi,
|
|
51
|
+
string,
|
|
52
|
+
readonly unknown[],
|
|
53
|
+
config,
|
|
54
|
+
config['chains'][number]['id']
|
|
55
|
+
>,
|
|
56
|
+
context
|
|
57
|
+
> & {
|
|
58
|
+
writeContract: WriteContractMutate<config, context>
|
|
59
|
+
writeContractAsync: WriteContractMutateAsync<config, context>
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** https://wagmi.sh/vue/api/composables/useWriteContract */
|
|
63
|
+
export function useWriteContract<
|
|
64
|
+
config extends Config = ResolvedRegister['config'],
|
|
65
|
+
context = unknown,
|
|
66
|
+
>(
|
|
67
|
+
parameters: UseWriteContractParameters<config, context> = {},
|
|
68
|
+
): UseWriteContractReturnType<config, context> {
|
|
69
|
+
const { mutation } = parameters
|
|
70
|
+
|
|
71
|
+
const config = useConfig(parameters)
|
|
72
|
+
|
|
73
|
+
const mutationOptions = writeContractMutationOptions(config)
|
|
74
|
+
const { mutate, mutateAsync, ...result } = useMutation({
|
|
75
|
+
...mutation,
|
|
76
|
+
...mutationOptions,
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
type Return = UseWriteContractReturnType<config, context>
|
|
80
|
+
return {
|
|
81
|
+
...result,
|
|
82
|
+
writeContract: mutate as Return['writeContract'],
|
|
83
|
+
writeContractAsync: mutateAsync as Return['writeContractAsync'],
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BaseError as CoreError } from '@wagmi/core'
|
|
2
|
+
|
|
3
|
+
import { getVersion } from '../utils/getVersion.js'
|
|
4
|
+
|
|
5
|
+
export type BaseErrorType = BaseError & { name: 'WagmiError' }
|
|
6
|
+
export class BaseError extends CoreError {
|
|
7
|
+
override name = 'WagmiError'
|
|
8
|
+
override get docsBaseUrl() {
|
|
9
|
+
return 'https://wagmi.sh/vue'
|
|
10
|
+
}
|
|
11
|
+
override get version() {
|
|
12
|
+
return getVersion()
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { BaseError } from './base.js'
|
|
2
|
+
|
|
3
|
+
export type WagmiPluginNotFoundErrorType = WagmiPluginNotFoundError & {
|
|
4
|
+
name: 'WagmiPluginNotFoundError'
|
|
5
|
+
}
|
|
6
|
+
export class WagmiPluginNotFoundError extends BaseError {
|
|
7
|
+
override name = 'WagmiPluginNotFoundError'
|
|
8
|
+
constructor() {
|
|
9
|
+
super(
|
|
10
|
+
'No `config` found in Vue context, use `WagmiPlugin` to properly initialize the library.',
|
|
11
|
+
{
|
|
12
|
+
docsPath: '/api/TODO',
|
|
13
|
+
},
|
|
14
|
+
)
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type WagmiInjectionContextErrorType = WagmiInjectionContextError & {
|
|
19
|
+
name: 'WagmiInjectionContextError'
|
|
20
|
+
}
|
|
21
|
+
export class WagmiInjectionContextError extends BaseError {
|
|
22
|
+
override name = 'WagmiInjectionContextError'
|
|
23
|
+
constructor() {
|
|
24
|
+
super(
|
|
25
|
+
'Wagmi composables can only be used inside `setup()` function or functions that support injection context.',
|
|
26
|
+
{
|
|
27
|
+
docsPath: '/api/TODO',
|
|
28
|
+
},
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Plugin
|
|
3
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
4
|
+
|
|
5
|
+
export { configKey, type WagmiPluginOptions, WagmiPlugin } from '../plugin.js'
|
|
6
|
+
|
|
7
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
8
|
+
// Errors
|
|
9
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
10
|
+
|
|
11
|
+
export { type BaseErrorType, BaseError } from '../errors/base.js'
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
type WagmiPluginNotFoundErrorType,
|
|
15
|
+
WagmiPluginNotFoundError,
|
|
16
|
+
type WagmiInjectionContextErrorType,
|
|
17
|
+
WagmiInjectionContextError,
|
|
18
|
+
} from '../errors/plugin.js'
|
|
19
|
+
|
|
20
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
21
|
+
// Composables
|
|
22
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
23
|
+
|
|
24
|
+
export {
|
|
25
|
+
type UseAccountParameters,
|
|
26
|
+
type UseAccountReturnType,
|
|
27
|
+
useAccount,
|
|
28
|
+
} from '../composables/useAccount.js'
|
|
29
|
+
|
|
30
|
+
export {
|
|
31
|
+
type UseAccountEffectParameters,
|
|
32
|
+
useAccountEffect,
|
|
33
|
+
} from '../composables/useAccountEffect.js'
|
|
34
|
+
|
|
35
|
+
export {
|
|
36
|
+
type UseBalanceParameters,
|
|
37
|
+
type UseBalanceReturnType,
|
|
38
|
+
useBalance,
|
|
39
|
+
} from '../composables/useBalance.js'
|
|
40
|
+
|
|
41
|
+
export {
|
|
42
|
+
type UseBlockNumberParameters,
|
|
43
|
+
type UseBlockNumberReturnType,
|
|
44
|
+
useBlockNumber,
|
|
45
|
+
} from '../composables/useBlockNumber.js'
|
|
46
|
+
|
|
47
|
+
export {
|
|
48
|
+
type UseChainIdParameters,
|
|
49
|
+
type UseChainIdReturnType,
|
|
50
|
+
useChainId,
|
|
51
|
+
} from '../composables/useChainId.js'
|
|
52
|
+
|
|
53
|
+
export {
|
|
54
|
+
type UseClientParameters,
|
|
55
|
+
type UseClientReturnType,
|
|
56
|
+
useClient,
|
|
57
|
+
} from '../composables/useClient.js'
|
|
58
|
+
|
|
59
|
+
export {
|
|
60
|
+
type UseConnectorClientParameters,
|
|
61
|
+
type UseConnectorClientReturnType,
|
|
62
|
+
useConnectorClient,
|
|
63
|
+
} from '../composables/useConnectorClient.js'
|
|
64
|
+
|
|
65
|
+
export {
|
|
66
|
+
type UseChainsParameters,
|
|
67
|
+
type UseChainsReturnType,
|
|
68
|
+
useChains,
|
|
69
|
+
} from '../composables/useChains.js'
|
|
70
|
+
|
|
71
|
+
export {
|
|
72
|
+
type UseConfigParameters,
|
|
73
|
+
type UseConfigReturnType,
|
|
74
|
+
useConfig,
|
|
75
|
+
} from '../composables/useConfig.js'
|
|
76
|
+
|
|
77
|
+
export {
|
|
78
|
+
type UseConnectParameters,
|
|
79
|
+
type UseConnectReturnType,
|
|
80
|
+
useConnect,
|
|
81
|
+
} from '../composables/useConnect.js'
|
|
82
|
+
|
|
83
|
+
export {
|
|
84
|
+
type UseConnectionsParameters,
|
|
85
|
+
type UseConnectionsReturnType,
|
|
86
|
+
useConnections,
|
|
87
|
+
} from '../composables/useConnections.js'
|
|
88
|
+
|
|
89
|
+
export {
|
|
90
|
+
type UseConnectorsParameters,
|
|
91
|
+
type UseConnectorsReturnType,
|
|
92
|
+
useConnectors,
|
|
93
|
+
} from '../composables/useConnectors.js'
|
|
94
|
+
|
|
95
|
+
export {
|
|
96
|
+
type UseDisconnectParameters,
|
|
97
|
+
type UseDisconnectReturnType,
|
|
98
|
+
useDisconnect,
|
|
99
|
+
} from '../composables/useDisconnect.js'
|
|
100
|
+
|
|
101
|
+
export {
|
|
102
|
+
type UseEnsAddressParameters,
|
|
103
|
+
type UseEnsAddressReturnType,
|
|
104
|
+
useEnsAddress,
|
|
105
|
+
} from '../composables/useEnsAddress.js'
|
|
106
|
+
|
|
107
|
+
export {
|
|
108
|
+
type UseEnsAvatarParameters,
|
|
109
|
+
type UseEnsAvatarReturnType,
|
|
110
|
+
useEnsAvatar,
|
|
111
|
+
} from '../composables/useEnsAvatar.js'
|
|
112
|
+
|
|
113
|
+
export {
|
|
114
|
+
type UseEnsNameParameters,
|
|
115
|
+
type UseEnsNameReturnType,
|
|
116
|
+
useEnsName,
|
|
117
|
+
} from '../composables/useEnsName.js'
|
|
118
|
+
|
|
119
|
+
export {
|
|
120
|
+
type UseEstimateGasParameters,
|
|
121
|
+
type UseEstimateGasReturnType,
|
|
122
|
+
useEstimateGas,
|
|
123
|
+
} from '../composables/useEstimateGas.js'
|
|
124
|
+
|
|
125
|
+
export {
|
|
126
|
+
type UseReadContractParameters,
|
|
127
|
+
type UseReadContractReturnType,
|
|
128
|
+
useReadContract,
|
|
129
|
+
} from '../composables/useReadContract.js'
|
|
130
|
+
|
|
131
|
+
export {
|
|
132
|
+
type UseReconnectParameters,
|
|
133
|
+
type UseReconnectReturnType,
|
|
134
|
+
useReconnect,
|
|
135
|
+
} from '../composables/useReconnect.js'
|
|
136
|
+
|
|
137
|
+
export {
|
|
138
|
+
type UseSendTransactionParameters,
|
|
139
|
+
type UseSendTransactionReturnType,
|
|
140
|
+
useSendTransaction,
|
|
141
|
+
} from '../composables/useSendTransaction.js'
|
|
142
|
+
|
|
143
|
+
export {
|
|
144
|
+
type UseSignMessageParameters,
|
|
145
|
+
type UseSignMessageReturnType,
|
|
146
|
+
useSignMessage,
|
|
147
|
+
} from '../composables/useSignMessage.js'
|
|
148
|
+
|
|
149
|
+
export {
|
|
150
|
+
type UseSignTypedDataParameters,
|
|
151
|
+
type UseSignTypedDataReturnType,
|
|
152
|
+
useSignTypedData,
|
|
153
|
+
} from '../composables/useSignTypedData.js'
|
|
154
|
+
|
|
155
|
+
export {
|
|
156
|
+
type UseSimulateContractParameters,
|
|
157
|
+
type UseSimulateContractReturnType,
|
|
158
|
+
useSimulateContract,
|
|
159
|
+
} from '../composables/useSimulateContract.js'
|
|
160
|
+
|
|
161
|
+
export {
|
|
162
|
+
type UseSwitchAccountParameters,
|
|
163
|
+
type UseSwitchAccountReturnType,
|
|
164
|
+
useSwitchAccount,
|
|
165
|
+
} from '../composables/useSwitchAccount.js'
|
|
166
|
+
|
|
167
|
+
export {
|
|
168
|
+
type UseSwitchChainParameters,
|
|
169
|
+
type UseSwitchChainReturnType,
|
|
170
|
+
useSwitchChain,
|
|
171
|
+
} from '../composables/useSwitchChain.js'
|
|
172
|
+
|
|
173
|
+
export {
|
|
174
|
+
type UseTransactionParameters,
|
|
175
|
+
type UseTransactionReturnType,
|
|
176
|
+
useTransaction,
|
|
177
|
+
} from '../composables/useTransaction.js'
|
|
178
|
+
|
|
179
|
+
export {
|
|
180
|
+
type UseTransactionReceiptParameters,
|
|
181
|
+
type UseTransactionReceiptReturnType,
|
|
182
|
+
useTransactionReceipt,
|
|
183
|
+
} from '../composables/useTransactionReceipt.js'
|
|
184
|
+
|
|
185
|
+
export {
|
|
186
|
+
type UseWatchBlockNumberParameters,
|
|
187
|
+
type UseWatchBlockNumberReturnType,
|
|
188
|
+
useWatchBlockNumber,
|
|
189
|
+
} from '../composables/useWatchBlockNumber.js'
|
|
190
|
+
|
|
191
|
+
export {
|
|
192
|
+
type UseWaitForTransactionReceiptParameters,
|
|
193
|
+
type UseWaitForTransactionReceiptReturnType,
|
|
194
|
+
useWaitForTransactionReceipt,
|
|
195
|
+
} from '../composables/useWaitForTransactionReceipt.js'
|
|
196
|
+
|
|
197
|
+
export {
|
|
198
|
+
type UseWriteContractParameters,
|
|
199
|
+
type UseWriteContractReturnType,
|
|
200
|
+
useWriteContract,
|
|
201
|
+
} from '../composables/useWriteContract.js'
|
|
202
|
+
|
|
203
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
204
|
+
// @wagmi/core
|
|
205
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
206
|
+
|
|
207
|
+
export {
|
|
208
|
+
// Config
|
|
209
|
+
type Connection,
|
|
210
|
+
type Connector,
|
|
211
|
+
type Config,
|
|
212
|
+
type CreateConfigParameters,
|
|
213
|
+
type State,
|
|
214
|
+
createConfig,
|
|
215
|
+
// Connector
|
|
216
|
+
type ConnectorEventMap,
|
|
217
|
+
type CreateConnectorFn,
|
|
218
|
+
createConnector,
|
|
219
|
+
// Errors
|
|
220
|
+
type ChainNotConfiguredErrorType,
|
|
221
|
+
ChainNotConfiguredError,
|
|
222
|
+
type ConnectorAlreadyConnectedErrorType,
|
|
223
|
+
ConnectorAlreadyConnectedError,
|
|
224
|
+
type ConnectorNotFoundErrorType,
|
|
225
|
+
ConnectorNotFoundError,
|
|
226
|
+
type ConnectorAccountNotFoundErrorType,
|
|
227
|
+
ConnectorAccountNotFoundError,
|
|
228
|
+
type ProviderNotFoundErrorType,
|
|
229
|
+
ProviderNotFoundError,
|
|
230
|
+
type SwitchChainNotSupportedErrorType,
|
|
231
|
+
SwitchChainNotSupportedError,
|
|
232
|
+
// Storage
|
|
233
|
+
type CreateStorageParameters,
|
|
234
|
+
type Storage,
|
|
235
|
+
createStorage,
|
|
236
|
+
noopStorage,
|
|
237
|
+
// Transports
|
|
238
|
+
custom,
|
|
239
|
+
fallback,
|
|
240
|
+
http,
|
|
241
|
+
webSocket,
|
|
242
|
+
unstable_connector,
|
|
243
|
+
// Types
|
|
244
|
+
type Register,
|
|
245
|
+
type ResolvedRegister,
|
|
246
|
+
// Utilities
|
|
247
|
+
cookieStorage,
|
|
248
|
+
cookieToInitialState,
|
|
249
|
+
deepEqual,
|
|
250
|
+
deserialize,
|
|
251
|
+
normalizeChainId,
|
|
252
|
+
parseCookie,
|
|
253
|
+
serialize,
|
|
254
|
+
} from '@wagmi/core'
|
|
255
|
+
|
|
256
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
257
|
+
// Version
|
|
258
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
259
|
+
|
|
260
|
+
export { version } from '../version.js'
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// @wagmi/core/query
|
|
3
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
4
|
+
|
|
5
|
+
export * from '@wagmi/core/query'
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
type UseMutationParameters,
|
|
9
|
+
type UseMutationReturnType,
|
|
10
|
+
useMutation,
|
|
11
|
+
} from '../utils/query.js'
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
type UseQueryParameters,
|
|
15
|
+
type UseQueryReturnType,
|
|
16
|
+
useQuery,
|
|
17
|
+
} from '../utils/query.js'
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { NuxtModule } from '@nuxt/schema'
|
|
2
|
+
import { addImports, createResolver, defineNuxtModule } from 'nuxt/kit'
|
|
3
|
+
|
|
4
|
+
export type WagmiModuleOptions = {}
|
|
5
|
+
|
|
6
|
+
export const wagmiModule: NuxtModule<WagmiModuleOptions> =
|
|
7
|
+
defineNuxtModule<WagmiModuleOptions>({
|
|
8
|
+
meta: {
|
|
9
|
+
name: '@wagmi/vue',
|
|
10
|
+
configKey: 'wagmi',
|
|
11
|
+
compatibility: {
|
|
12
|
+
nuxt: '^3.0.0',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
setup(_options, nuxt) {
|
|
16
|
+
const { resolve } = createResolver(import.meta.url)
|
|
17
|
+
|
|
18
|
+
// Add types
|
|
19
|
+
nuxt.hook('prepare:types', ({ references }) => {
|
|
20
|
+
references.push({ types: '@wagmi/vue/nuxt' })
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
// Add auto imports
|
|
24
|
+
const composables = resolve('./runtime/composables')
|
|
25
|
+
const names = [
|
|
26
|
+
'useAccount',
|
|
27
|
+
'useAccountEffect',
|
|
28
|
+
'useBalance',
|
|
29
|
+
'useBlockNumber',
|
|
30
|
+
'useChainId',
|
|
31
|
+
'useChains',
|
|
32
|
+
'useClient',
|
|
33
|
+
'useConfig',
|
|
34
|
+
'useConnect',
|
|
35
|
+
'useConnections',
|
|
36
|
+
'useConnectorClient',
|
|
37
|
+
'useConnectors',
|
|
38
|
+
'useDisconnect',
|
|
39
|
+
'useEnsAddress',
|
|
40
|
+
'useEnsAvatar',
|
|
41
|
+
'useEnsName',
|
|
42
|
+
'useEstimateGas',
|
|
43
|
+
'useReadContract',
|
|
44
|
+
'useReconnect',
|
|
45
|
+
'useSendTransaction',
|
|
46
|
+
'useSignMessage',
|
|
47
|
+
'useSignTypedData',
|
|
48
|
+
'useSimulateContract',
|
|
49
|
+
'useSwitchAccount',
|
|
50
|
+
'useSwitchChain',
|
|
51
|
+
'useTransaction',
|
|
52
|
+
'useTransactionReceipt',
|
|
53
|
+
'useWaitForTransactionReceipt',
|
|
54
|
+
'useWatchBlockNumber',
|
|
55
|
+
'useWriteContract',
|
|
56
|
+
]
|
|
57
|
+
addImports(names.map((name) => ({ from: composables, name })))
|
|
58
|
+
},
|
|
59
|
+
})
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../exports/index.js'
|
package/src/plugin.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type ResolvedRegister, type State, hydrate } from '@wagmi/core'
|
|
2
|
+
import type { Plugin } from 'vue'
|
|
3
|
+
|
|
4
|
+
export const configKey = Symbol()
|
|
5
|
+
|
|
6
|
+
export type WagmiPluginOptions = {
|
|
7
|
+
config: ResolvedRegister['config']
|
|
8
|
+
initialState?: State | undefined
|
|
9
|
+
reconnectOnMount?: boolean | undefined
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const WagmiPlugin = {
|
|
13
|
+
install(app, options) {
|
|
14
|
+
const { config, reconnectOnMount = true } = options
|
|
15
|
+
app.provide(configKey, config)
|
|
16
|
+
// TODO: check this works in SSR env.
|
|
17
|
+
// - reconnect on mount.
|
|
18
|
+
// - hydrate initial state.
|
|
19
|
+
const { onMount } = hydrate(config, { ...options, reconnectOnMount })
|
|
20
|
+
onMount()
|
|
21
|
+
},
|
|
22
|
+
} satisfies Plugin<WagmiPluginOptions>
|