@wagmi/vue 0.4.10 → 0.4.12
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/composables/useBalance.js +10 -14
- package/dist/esm/composables/useBalance.js.map +1 -1
- package/dist/esm/composables/useBlockNumber.js +17 -22
- package/dist/esm/composables/useBlockNumber.js.map +1 -1
- package/dist/esm/composables/useBytecode.js +10 -14
- package/dist/esm/composables/useBytecode.js.map +1 -1
- package/dist/esm/composables/useConnectorClient.js +16 -30
- package/dist/esm/composables/useConnectorClient.js.map +1 -1
- package/dist/esm/composables/useEnsAddress.js +10 -14
- package/dist/esm/composables/useEnsAddress.js.map +1 -1
- package/dist/esm/composables/useEnsAvatar.js +10 -14
- package/dist/esm/composables/useEnsAvatar.js.map +1 -1
- package/dist/esm/composables/useEnsName.js +11 -14
- package/dist/esm/composables/useEnsName.js.map +1 -1
- package/dist/esm/composables/useEstimateGas.js +14 -21
- package/dist/esm/composables/useEstimateGas.js.map +1 -1
- package/dist/esm/composables/useReadContract.js +11 -18
- package/dist/esm/composables/useReadContract.js.map +1 -1
- package/dist/esm/composables/useSimulateContract.js +14 -24
- package/dist/esm/composables/useSimulateContract.js.map +1 -1
- package/dist/esm/composables/useTransaction.js +10 -19
- package/dist/esm/composables/useTransaction.js.map +1 -1
- package/dist/esm/composables/useTransactionReceipt.js +10 -18
- package/dist/esm/composables/useTransactionReceipt.js.map +1 -1
- package/dist/esm/composables/useWaitForTransactionReceipt.js +10 -18
- package/dist/esm/composables/useWaitForTransactionReceipt.js.map +1 -1
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/types/composables/useBalance.d.ts +4 -5
- package/dist/types/composables/useBalance.d.ts.map +1 -1
- package/dist/types/composables/useBlockNumber.d.ts +4 -4
- package/dist/types/composables/useBlockNumber.d.ts.map +1 -1
- package/dist/types/composables/useBytecode.d.ts +4 -5
- package/dist/types/composables/useBytecode.d.ts.map +1 -1
- package/dist/types/composables/useConnectorClient.d.ts +6 -8
- package/dist/types/composables/useConnectorClient.d.ts.map +1 -1
- package/dist/types/composables/useEnsAddress.d.ts +4 -4
- package/dist/types/composables/useEnsAddress.d.ts.map +1 -1
- package/dist/types/composables/useEnsAvatar.d.ts +4 -4
- package/dist/types/composables/useEnsAvatar.d.ts.map +1 -1
- package/dist/types/composables/useEnsName.d.ts +4 -4
- package/dist/types/composables/useEnsName.d.ts.map +1 -1
- package/dist/types/composables/useEstimateGas.d.ts +3 -3
- package/dist/types/composables/useEstimateGas.d.ts.map +1 -1
- package/dist/types/composables/useReadContract.d.ts +8 -4
- package/dist/types/composables/useReadContract.d.ts.map +1 -1
- package/dist/types/composables/useSimulateContract.d.ts +4 -4
- package/dist/types/composables/useSimulateContract.d.ts.map +1 -1
- package/dist/types/composables/useTransaction.d.ts +4 -4
- package/dist/types/composables/useTransaction.d.ts.map +1 -1
- package/dist/types/composables/useTransactionReceipt.d.ts +4 -5
- package/dist/types/composables/useTransactionReceipt.d.ts.map +1 -1
- package/dist/types/composables/useWaitForTransactionReceipt.d.ts +4 -4
- package/dist/types/composables/useWaitForTransactionReceipt.d.ts.map +1 -1
- package/dist/types/exports/internal.d.ts +1 -1
- package/dist/types/exports/internal.d.ts.map +1 -1
- package/dist/types/types/properties.d.ts +0 -6
- package/dist/types/types/properties.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +3 -3
- package/src/composables/useBalance.ts +14 -35
- package/src/composables/useBlockNumber.ts +22 -46
- package/src/composables/useBytecode.ts +14 -35
- package/src/composables/useConnectorClient.ts +22 -76
- package/src/composables/useEnsAddress.ts +14 -29
- package/src/composables/useEnsAvatar.ts +14 -29
- package/src/composables/useEnsName.ts +15 -35
- package/src/composables/useEstimateGas.ts +17 -43
- package/src/composables/useReadContract.ts +53 -51
- package/src/composables/useSimulateContract.ts +25 -61
- package/src/composables/useTransaction.ts +14 -47
- package/src/composables/useTransactionReceipt.ts +15 -41
- package/src/composables/useWaitForTransactionReceipt.ts +15 -36
- package/src/exports/internal.ts +1 -4
- package/src/types/properties.ts +0 -17
- package/src/version.ts +1 -1
|
@@ -12,13 +12,11 @@ import type {
|
|
|
12
12
|
import {
|
|
13
13
|
type GetBlockNumberData,
|
|
14
14
|
type GetBlockNumberOptions,
|
|
15
|
-
type GetBlockNumberQueryFnData,
|
|
16
|
-
type GetBlockNumberQueryKey,
|
|
17
15
|
getBlockNumberQueryOptions,
|
|
18
16
|
} from '@wagmi/core/query'
|
|
19
17
|
import { computed } from 'vue'
|
|
20
18
|
|
|
21
|
-
import type { ConfigParameter
|
|
19
|
+
import type { ConfigParameter } from '../types/properties.js'
|
|
22
20
|
import type { DeepMaybeRef, DeepUnwrapRef } from '../types/ref.js'
|
|
23
21
|
import { deepUnref } from '../utils/cloneDeep.js'
|
|
24
22
|
import { type UseQueryReturnType, useQuery } from '../utils/query.js'
|
|
@@ -36,14 +34,8 @@ export type UseBlockNumberParameters<
|
|
|
36
34
|
selectData = GetBlockNumberData,
|
|
37
35
|
> = Compute<
|
|
38
36
|
DeepMaybeRef<
|
|
39
|
-
GetBlockNumberOptions<config, chainId> &
|
|
40
|
-
ConfigParameter<config> &
|
|
41
|
-
QueryParameter<
|
|
42
|
-
GetBlockNumberQueryFnData,
|
|
43
|
-
GetBlockNumberErrorType,
|
|
44
|
-
selectData,
|
|
45
|
-
GetBlockNumberQueryKey<config, chainId>
|
|
46
|
-
> & {
|
|
37
|
+
GetBlockNumberOptions<config, chainId, selectData> &
|
|
38
|
+
ConfigParameter<config> & {
|
|
47
39
|
watch?:
|
|
48
40
|
| boolean
|
|
49
41
|
| UnionCompute<
|
|
@@ -67,54 +59,38 @@ export function useBlockNumber<
|
|
|
67
59
|
config['chains'][number]['id'] = config['chains'][number]['id'],
|
|
68
60
|
selectData = GetBlockNumberData,
|
|
69
61
|
>(
|
|
70
|
-
|
|
62
|
+
parameters: UseBlockNumberParameters<config, chainId, selectData> = {},
|
|
71
63
|
): UseBlockNumberReturnType<selectData> {
|
|
72
|
-
const
|
|
64
|
+
const params = computed(() => deepUnref(parameters))
|
|
65
|
+
const config = useConfig(params)
|
|
66
|
+
const chainId = useChainId({ config })
|
|
67
|
+
const options = computed(() =>
|
|
68
|
+
getBlockNumberQueryOptions(config as any, {
|
|
69
|
+
...params.value,
|
|
70
|
+
chainId: params.value.chainId ?? chainId.value,
|
|
71
|
+
query: params.value.query,
|
|
72
|
+
}),
|
|
73
|
+
)
|
|
73
74
|
|
|
74
|
-
const config = useConfig(parameters)
|
|
75
75
|
const queryClient = useQueryClient()
|
|
76
|
-
const configChainId = useChainId({ config })
|
|
77
|
-
|
|
78
|
-
const queryOptions = computed(() => {
|
|
79
|
-
const {
|
|
80
|
-
chainId = configChainId.value,
|
|
81
|
-
query = {},
|
|
82
|
-
watch: _,
|
|
83
|
-
...rest
|
|
84
|
-
} = parameters.value
|
|
85
|
-
const options = getBlockNumberQueryOptions(config, {
|
|
86
|
-
...deepUnref(rest),
|
|
87
|
-
chainId,
|
|
88
|
-
})
|
|
89
|
-
return {
|
|
90
|
-
...query,
|
|
91
|
-
...options,
|
|
92
|
-
}
|
|
93
|
-
})
|
|
94
|
-
|
|
95
76
|
const watchBlockNumberArgs = computed(() => {
|
|
96
|
-
const {
|
|
97
|
-
config,
|
|
98
|
-
chainId = configChainId.value,
|
|
99
|
-
query,
|
|
100
|
-
watch,
|
|
101
|
-
} = parameters.value
|
|
102
77
|
return {
|
|
103
78
|
...({
|
|
104
79
|
config,
|
|
105
|
-
chainId,
|
|
106
|
-
...(typeof watch === 'object' ? watch : {}),
|
|
80
|
+
chainId: params.value.chainId ?? chainId.value,
|
|
81
|
+
...(typeof params.value.watch === 'object' ? params.value.watch : {}),
|
|
107
82
|
} as UseWatchBlockNumberParameters),
|
|
108
83
|
enabled:
|
|
109
|
-
(query?.enabled ?? true) &&
|
|
110
|
-
(typeof watch === 'object'
|
|
84
|
+
(params.value.query?.enabled ?? true) &&
|
|
85
|
+
(typeof params.value.watch === 'object'
|
|
86
|
+
? params.value.watch.enabled
|
|
87
|
+
: params.value.watch),
|
|
111
88
|
onBlockNumber(blockNumber) {
|
|
112
|
-
queryClient.setQueryData(
|
|
89
|
+
queryClient.setQueryData(options.value.queryKey, blockNumber)
|
|
113
90
|
},
|
|
114
91
|
} satisfies UseWatchBlockNumberParameters
|
|
115
92
|
})
|
|
116
|
-
|
|
117
93
|
useWatchBlockNumber(watchBlockNumberArgs)
|
|
118
94
|
|
|
119
|
-
return useQuery(
|
|
95
|
+
return useQuery(options as any) as any
|
|
120
96
|
}
|
|
@@ -4,15 +4,13 @@ import type {
|
|
|
4
4
|
ResolvedRegister,
|
|
5
5
|
} from '@wagmi/core'
|
|
6
6
|
import type { Compute } from '@wagmi/core/internal'
|
|
7
|
-
import type { GetBytecodeQueryFnData } from '@wagmi/core/query'
|
|
8
7
|
import {
|
|
9
8
|
type GetBytecodeData,
|
|
10
9
|
type GetBytecodeOptions,
|
|
11
|
-
type GetBytecodeQueryKey,
|
|
12
10
|
getBytecodeQueryOptions,
|
|
13
11
|
} from '@wagmi/core/query'
|
|
14
12
|
import { computed } from 'vue'
|
|
15
|
-
import type { ConfigParameter
|
|
13
|
+
import type { ConfigParameter } from '../types/properties.js'
|
|
16
14
|
import type { DeepMaybeRef } from '../types/ref.js'
|
|
17
15
|
import { deepUnref } from '../utils/cloneDeep.js'
|
|
18
16
|
import { type UseQueryReturnType, useQuery } from '../utils/query.js'
|
|
@@ -23,16 +21,7 @@ export type UseBytecodeParameters<
|
|
|
23
21
|
config extends Config = Config,
|
|
24
22
|
selectData = GetBytecodeData,
|
|
25
23
|
> = Compute<
|
|
26
|
-
DeepMaybeRef<
|
|
27
|
-
GetBytecodeOptions<config> &
|
|
28
|
-
ConfigParameter<config> &
|
|
29
|
-
QueryParameter<
|
|
30
|
-
GetBytecodeQueryFnData,
|
|
31
|
-
GetBytecodeErrorType,
|
|
32
|
-
selectData,
|
|
33
|
-
GetBytecodeQueryKey<config>
|
|
34
|
-
>
|
|
35
|
-
>
|
|
24
|
+
DeepMaybeRef<GetBytecodeOptions<config, selectData> & ConfigParameter<config>>
|
|
36
25
|
>
|
|
37
26
|
|
|
38
27
|
export type UseBytecodeReturnType<selectData = GetBytecodeData> =
|
|
@@ -43,28 +32,18 @@ export function useBytecode<
|
|
|
43
32
|
config extends Config = ResolvedRegister['config'],
|
|
44
33
|
selectData = GetBytecodeData,
|
|
45
34
|
>(
|
|
46
|
-
|
|
35
|
+
parameters: UseBytecodeParameters<config, selectData> = {},
|
|
47
36
|
): UseBytecodeReturnType<selectData> {
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
const config = useConfig(parameters)
|
|
37
|
+
const params = computed(() => deepUnref(parameters))
|
|
38
|
+
const config = useConfig(params)
|
|
51
39
|
const chainId = useChainId({ config })
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
address:
|
|
56
|
-
chainId:
|
|
57
|
-
query
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
...parameters.value,
|
|
62
|
-
address: contractAddress,
|
|
63
|
-
chainId: parametersChainId ?? chainId.value,
|
|
64
|
-
})
|
|
65
|
-
const enabled = Boolean(contractAddress && (query.enabled ?? true))
|
|
66
|
-
return { ...query, ...options, enabled }
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
return useQuery(queryOptions as any) as UseBytecodeReturnType<selectData>
|
|
40
|
+
const options = computed(() =>
|
|
41
|
+
getBytecodeQueryOptions(config as any, {
|
|
42
|
+
...params.value,
|
|
43
|
+
address: params.value.address,
|
|
44
|
+
chainId: params.value.chainId ?? chainId.value,
|
|
45
|
+
query: params.value.query,
|
|
46
|
+
}),
|
|
47
|
+
)
|
|
48
|
+
return useQuery(options as any) as any
|
|
70
49
|
}
|
|
@@ -5,24 +5,17 @@ import type {
|
|
|
5
5
|
GetConnectorClientErrorType,
|
|
6
6
|
ResolvedRegister,
|
|
7
7
|
} from '@wagmi/core'
|
|
8
|
-
import type { Compute
|
|
8
|
+
import type { Compute } from '@wagmi/core/internal'
|
|
9
9
|
import {
|
|
10
10
|
type GetConnectorClientData,
|
|
11
11
|
type GetConnectorClientOptions,
|
|
12
|
-
type GetConnectorClientQueryFnData,
|
|
13
|
-
type GetConnectorClientQueryKey,
|
|
14
12
|
getConnectorClientQueryOptions,
|
|
15
13
|
} from '@wagmi/core/query'
|
|
16
14
|
import { computed, ref, watchEffect } from 'vue'
|
|
17
|
-
|
|
18
15
|
import type { ConfigParameter } from '../types/properties.js'
|
|
19
|
-
import type { DeepMaybeRef
|
|
16
|
+
import type { DeepMaybeRef } from '../types/ref.js'
|
|
20
17
|
import { deepUnref } from '../utils/cloneDeep.js'
|
|
21
|
-
import {
|
|
22
|
-
type UseQueryParameters,
|
|
23
|
-
type UseQueryReturnType,
|
|
24
|
-
useQuery,
|
|
25
|
-
} from '../utils/query.js'
|
|
18
|
+
import { type UseQueryReturnType, useQuery } from '../utils/query.js'
|
|
26
19
|
import { useChainId } from './useChainId.js'
|
|
27
20
|
import { useConfig } from './useConfig.js'
|
|
28
21
|
import { useConnection } from './useConnection.js'
|
|
@@ -34,24 +27,8 @@ export type UseConnectorClientParameters<
|
|
|
34
27
|
selectData = GetConnectorClientData<config, chainId>,
|
|
35
28
|
> = Compute<
|
|
36
29
|
DeepMaybeRef<
|
|
37
|
-
GetConnectorClientOptions<config, chainId> &
|
|
38
|
-
ConfigParameter<config>
|
|
39
|
-
query?:
|
|
40
|
-
| Compute<
|
|
41
|
-
Omit<
|
|
42
|
-
DeepUnwrapRef<
|
|
43
|
-
UseQueryParameters<
|
|
44
|
-
GetConnectorClientQueryFnData<config, chainId>,
|
|
45
|
-
GetConnectorClientErrorType,
|
|
46
|
-
selectData,
|
|
47
|
-
GetConnectorClientQueryKey<config, chainId>
|
|
48
|
-
>
|
|
49
|
-
>,
|
|
50
|
-
'gcTime' | 'staleTime'
|
|
51
|
-
>
|
|
52
|
-
>
|
|
53
|
-
| undefined
|
|
54
|
-
}
|
|
30
|
+
GetConnectorClientOptions<config, chainId, selectData> &
|
|
31
|
+
ConfigParameter<config>
|
|
55
32
|
>
|
|
56
33
|
>
|
|
57
34
|
|
|
@@ -69,64 +46,33 @@ export function useConnectorClient<
|
|
|
69
46
|
config['chains'][number]['id'] = config['chains'][number]['id'],
|
|
70
47
|
selectData = GetConnectorClientData<config, chainId>,
|
|
71
48
|
>(
|
|
72
|
-
|
|
49
|
+
parameters: UseConnectorClientParameters<config, chainId, selectData> = {},
|
|
73
50
|
): UseConnectorClientReturnType<config, chainId, selectData> {
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
const
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const {
|
|
87
|
-
chainId = configChainId.value,
|
|
88
|
-
connector = accountConnector.value,
|
|
89
|
-
query = {},
|
|
90
|
-
} = parameters.value
|
|
91
|
-
const { queryKey, ...options } = getConnectorClientQueryOptions<
|
|
92
|
-
config,
|
|
93
|
-
chainId
|
|
94
|
-
>(config as config, {
|
|
95
|
-
...deepUnref(parameters),
|
|
96
|
-
chainId: chainId as chainId,
|
|
97
|
-
connector: connector as Connector,
|
|
98
|
-
})
|
|
99
|
-
const enabled = Boolean(
|
|
100
|
-
(status.value === 'connected' ||
|
|
101
|
-
(status.value === 'reconnecting' && connector?.getProvider)) &&
|
|
102
|
-
(query.enabled ?? true),
|
|
103
|
-
)
|
|
104
|
-
return {
|
|
105
|
-
...query,
|
|
106
|
-
...options,
|
|
107
|
-
queryKey,
|
|
108
|
-
enabled,
|
|
109
|
-
staleTime: Number.POSITIVE_INFINITY,
|
|
110
|
-
}
|
|
111
|
-
})
|
|
51
|
+
const params = computed(() => deepUnref(parameters))
|
|
52
|
+
const config = useConfig(params)
|
|
53
|
+
const chainId = useChainId({ config })
|
|
54
|
+
const { address, connector } = useConnection({ config })
|
|
55
|
+
const options = computed(() =>
|
|
56
|
+
getConnectorClientQueryOptions(config as any, {
|
|
57
|
+
...params.value,
|
|
58
|
+
chainId: params.value.chainId ?? chainId.value,
|
|
59
|
+
connector: (params.value.connector ?? connector.value) as Connector,
|
|
60
|
+
query: params.value.query as any,
|
|
61
|
+
}),
|
|
62
|
+
)
|
|
112
63
|
|
|
113
64
|
const addressRef = ref(address)
|
|
65
|
+
const queryClient = useQueryClient()
|
|
114
66
|
watchEffect(() => {
|
|
115
67
|
const previousAddress = addressRef.value
|
|
116
68
|
if (!address && previousAddress) {
|
|
117
|
-
|
|
118
|
-
queryClient.removeQueries({ queryKey: queryOptions.value.queryKey })
|
|
69
|
+
queryClient.removeQueries({ queryKey: options.value.queryKey })
|
|
119
70
|
addressRef.value = undefined
|
|
120
71
|
} else if (address.value !== previousAddress) {
|
|
121
|
-
|
|
122
|
-
queryClient.invalidateQueries({ queryKey: queryOptions.value.queryKey })
|
|
72
|
+
queryClient.invalidateQueries({ queryKey: options.value.queryKey })
|
|
123
73
|
addressRef.value = address.value
|
|
124
74
|
}
|
|
125
75
|
})
|
|
126
76
|
|
|
127
|
-
return useQuery(
|
|
128
|
-
config,
|
|
129
|
-
chainId,
|
|
130
|
-
selectData
|
|
131
|
-
>
|
|
77
|
+
return useQuery(options as any) as any
|
|
132
78
|
}
|
|
@@ -7,13 +7,10 @@ import type { Compute } from '@wagmi/core/internal'
|
|
|
7
7
|
import {
|
|
8
8
|
type GetEnsAddressData,
|
|
9
9
|
type GetEnsAddressOptions,
|
|
10
|
-
type GetEnsAddressQueryFnData,
|
|
11
|
-
type GetEnsAddressQueryKey,
|
|
12
10
|
getEnsAddressQueryOptions,
|
|
13
11
|
} from '@wagmi/core/query'
|
|
14
12
|
import { computed } from 'vue'
|
|
15
|
-
|
|
16
|
-
import type { ConfigParameter, QueryParameter } from '../types/properties.js'
|
|
13
|
+
import type { ConfigParameter } from '../types/properties.js'
|
|
17
14
|
import type { DeepMaybeRef } from '../types/ref.js'
|
|
18
15
|
import { deepUnref } from '../utils/cloneDeep.js'
|
|
19
16
|
import { type UseQueryReturnType, useQuery } from '../utils/query.js'
|
|
@@ -25,14 +22,7 @@ export type UseEnsAddressParameters<
|
|
|
25
22
|
selectData = GetEnsAddressData,
|
|
26
23
|
> = Compute<
|
|
27
24
|
DeepMaybeRef<
|
|
28
|
-
GetEnsAddressOptions<config> &
|
|
29
|
-
ConfigParameter<config> &
|
|
30
|
-
QueryParameter<
|
|
31
|
-
GetEnsAddressQueryFnData,
|
|
32
|
-
GetEnsAddressErrorType,
|
|
33
|
-
selectData,
|
|
34
|
-
GetEnsAddressQueryKey<config>
|
|
35
|
-
>
|
|
25
|
+
GetEnsAddressOptions<config, selectData> & ConfigParameter<config>
|
|
36
26
|
>
|
|
37
27
|
>
|
|
38
28
|
|
|
@@ -44,22 +34,17 @@ export function useEnsAddress<
|
|
|
44
34
|
config extends Config = ResolvedRegister['config'],
|
|
45
35
|
selectData = GetEnsAddressData,
|
|
46
36
|
>(
|
|
47
|
-
|
|
37
|
+
parameters: UseEnsAddressParameters<config, selectData> = {},
|
|
48
38
|
): UseEnsAddressReturnType<selectData> {
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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>
|
|
39
|
+
const params = computed(() => deepUnref(parameters))
|
|
40
|
+
const config = useConfig(params)
|
|
41
|
+
const chainId = useChainId({ config })
|
|
42
|
+
const options = computed(() =>
|
|
43
|
+
getEnsAddressQueryOptions(config as any, {
|
|
44
|
+
...params.value,
|
|
45
|
+
chainId: params.value.chainId ?? chainId.value,
|
|
46
|
+
query: params.value.query,
|
|
47
|
+
}),
|
|
48
|
+
)
|
|
49
|
+
return useQuery(options as any) as any
|
|
65
50
|
}
|
|
@@ -7,13 +7,10 @@ import type { Compute } from '@wagmi/core/internal'
|
|
|
7
7
|
import {
|
|
8
8
|
type GetEnsAvatarData,
|
|
9
9
|
type GetEnsAvatarOptions,
|
|
10
|
-
type GetEnsAvatarQueryFnData,
|
|
11
|
-
type GetEnsAvatarQueryKey,
|
|
12
10
|
getEnsAvatarQueryOptions,
|
|
13
11
|
} from '@wagmi/core/query'
|
|
14
12
|
import { computed } from 'vue'
|
|
15
|
-
|
|
16
|
-
import type { ConfigParameter, QueryParameter } from '../types/properties.js'
|
|
13
|
+
import type { ConfigParameter } from '../types/properties.js'
|
|
17
14
|
import type { DeepMaybeRef } from '../types/ref.js'
|
|
18
15
|
import { deepUnref } from '../utils/cloneDeep.js'
|
|
19
16
|
import { type UseQueryReturnType, useQuery } from '../utils/query.js'
|
|
@@ -25,14 +22,7 @@ export type UseEnsAvatarParameters<
|
|
|
25
22
|
selectData = GetEnsAvatarData,
|
|
26
23
|
> = Compute<
|
|
27
24
|
DeepMaybeRef<
|
|
28
|
-
GetEnsAvatarOptions<config> &
|
|
29
|
-
ConfigParameter<config> &
|
|
30
|
-
QueryParameter<
|
|
31
|
-
GetEnsAvatarQueryFnData,
|
|
32
|
-
GetEnsAvatarErrorType,
|
|
33
|
-
selectData,
|
|
34
|
-
GetEnsAvatarQueryKey<config>
|
|
35
|
-
>
|
|
25
|
+
GetEnsAvatarOptions<config, selectData> & ConfigParameter<config>
|
|
36
26
|
>
|
|
37
27
|
>
|
|
38
28
|
|
|
@@ -44,22 +34,17 @@ export function useEnsAvatar<
|
|
|
44
34
|
config extends Config = ResolvedRegister['config'],
|
|
45
35
|
selectData = GetEnsAvatarData,
|
|
46
36
|
>(
|
|
47
|
-
|
|
37
|
+
parameters: UseEnsAvatarParameters<config, selectData> = {},
|
|
48
38
|
): UseEnsAvatarReturnType<selectData> {
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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>
|
|
39
|
+
const params = computed(() => deepUnref(parameters))
|
|
40
|
+
const config = useConfig(params)
|
|
41
|
+
const chainId = useChainId({ config })
|
|
42
|
+
const options = computed(() =>
|
|
43
|
+
getEnsAvatarQueryOptions(config as any, {
|
|
44
|
+
...params.value,
|
|
45
|
+
chainId: params.value.chainId ?? chainId.value,
|
|
46
|
+
query: params.value.query,
|
|
47
|
+
}),
|
|
48
|
+
)
|
|
49
|
+
return useQuery(options as any) as any
|
|
65
50
|
}
|
|
@@ -3,13 +3,10 @@ import type { Compute } from '@wagmi/core/internal'
|
|
|
3
3
|
import {
|
|
4
4
|
type GetEnsNameData,
|
|
5
5
|
type GetEnsNameOptions,
|
|
6
|
-
type GetEnsNameQueryFnData,
|
|
7
|
-
type GetEnsNameQueryKey,
|
|
8
6
|
getEnsNameQueryOptions,
|
|
9
7
|
} from '@wagmi/core/query'
|
|
10
|
-
|
|
11
8
|
import { computed } from 'vue'
|
|
12
|
-
import type { ConfigParameter
|
|
9
|
+
import type { ConfigParameter } from '../types/properties.js'
|
|
13
10
|
import type { DeepMaybeRef } from '../types/ref.js'
|
|
14
11
|
import { deepUnref } from '../utils/cloneDeep.js'
|
|
15
12
|
import { type UseQueryReturnType, useQuery } from '../utils/query.js'
|
|
@@ -20,16 +17,7 @@ export type UseEnsNameParameters<
|
|
|
20
17
|
config extends Config = Config,
|
|
21
18
|
selectData = GetEnsNameData,
|
|
22
19
|
> = Compute<
|
|
23
|
-
DeepMaybeRef<
|
|
24
|
-
GetEnsNameOptions<config> &
|
|
25
|
-
ConfigParameter<config> &
|
|
26
|
-
QueryParameter<
|
|
27
|
-
GetEnsNameQueryFnData,
|
|
28
|
-
GetEnsNameErrorType,
|
|
29
|
-
selectData,
|
|
30
|
-
GetEnsNameQueryKey<config>
|
|
31
|
-
>
|
|
32
|
-
>
|
|
20
|
+
DeepMaybeRef<GetEnsNameOptions<config, selectData> & ConfigParameter<config>>
|
|
33
21
|
>
|
|
34
22
|
|
|
35
23
|
export type UseEnsNameReturnType<selectData = GetEnsNameData> =
|
|
@@ -40,26 +28,18 @@ export function useEnsName<
|
|
|
40
28
|
config extends Config = ResolvedRegister['config'],
|
|
41
29
|
selectData = GetEnsNameData,
|
|
42
30
|
>(
|
|
43
|
-
|
|
31
|
+
parameters: UseEnsNameParameters<config, selectData> = {},
|
|
44
32
|
): UseEnsNameReturnType<selectData> {
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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>
|
|
33
|
+
const params = computed(() => deepUnref(parameters))
|
|
34
|
+
const config = useConfig(params)
|
|
35
|
+
const chainId = useChainId({ config })
|
|
36
|
+
const options = computed(() =>
|
|
37
|
+
getEnsNameQueryOptions(config as any, {
|
|
38
|
+
...params.value,
|
|
39
|
+
address: params.value.address,
|
|
40
|
+
chainId: params.value.chainId ?? chainId.value,
|
|
41
|
+
query: params.value.query,
|
|
42
|
+
}),
|
|
43
|
+
)
|
|
44
|
+
return useQuery(options as any) as any
|
|
65
45
|
}
|
|
@@ -6,33 +6,23 @@ import type {
|
|
|
6
6
|
import {
|
|
7
7
|
type EstimateGasData,
|
|
8
8
|
type EstimateGasOptions,
|
|
9
|
-
type EstimateGasQueryFnData,
|
|
10
|
-
type EstimateGasQueryKey,
|
|
11
9
|
estimateGasQueryOptions,
|
|
12
10
|
} from '@wagmi/core/query'
|
|
13
11
|
import { computed } from 'vue'
|
|
14
|
-
|
|
15
|
-
import type { ConfigParameter, QueryParameter } from '../types/properties.js'
|
|
12
|
+
import type { ConfigParameter } from '../types/properties.js'
|
|
16
13
|
import type { DeepMaybeRef } from '../types/ref.js'
|
|
17
14
|
import { deepUnref } from '../utils/cloneDeep.js'
|
|
18
15
|
import { type UseQueryReturnType, useQuery } from '../utils/query.js'
|
|
19
16
|
import { useChainId } from './useChainId.js'
|
|
20
17
|
import { useConfig } from './useConfig.js'
|
|
21
|
-
import {
|
|
18
|
+
import { useConnection } from './useConnection.js'
|
|
22
19
|
|
|
23
20
|
export type UseEstimateGasParameters<
|
|
24
21
|
config extends Config = Config,
|
|
25
22
|
chainId extends config['chains'][number]['id'] | undefined = undefined,
|
|
26
23
|
selectData = EstimateGasData,
|
|
27
24
|
> = DeepMaybeRef<
|
|
28
|
-
EstimateGasOptions<config, chainId> &
|
|
29
|
-
ConfigParameter<config> &
|
|
30
|
-
QueryParameter<
|
|
31
|
-
EstimateGasQueryFnData,
|
|
32
|
-
EstimateGasErrorType,
|
|
33
|
-
selectData,
|
|
34
|
-
EstimateGasQueryKey<config, chainId>
|
|
35
|
-
>
|
|
25
|
+
EstimateGasOptions<config, chainId, selectData> & ConfigParameter<config>
|
|
36
26
|
>
|
|
37
27
|
|
|
38
28
|
export type UseEstimateGasReturnType<selectData = EstimateGasData> =
|
|
@@ -48,36 +38,20 @@ export function useEstimateGas<
|
|
|
48
38
|
): UseEstimateGasReturnType<selectData>
|
|
49
39
|
|
|
50
40
|
export function useEstimateGas(
|
|
51
|
-
|
|
41
|
+
parameters: UseEstimateGasParameters = {},
|
|
52
42
|
): UseEstimateGasReturnType {
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
const {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
43
|
+
const params = computed(() => deepUnref(parameters))
|
|
44
|
+
const config = useConfig(params)
|
|
45
|
+
const { address, connector } = useConnection({ config })
|
|
46
|
+
const chainId = useChainId({ config })
|
|
47
|
+
const options = computed(() =>
|
|
48
|
+
estimateGasQueryOptions(config as any, {
|
|
49
|
+
...params.value,
|
|
50
|
+
account: params.value.account ?? address.value,
|
|
51
|
+
chainId: params.value.chainId ?? chainId.value,
|
|
52
|
+
connector: params.value.connector ?? connector.value,
|
|
53
|
+
query: params.value.query,
|
|
54
|
+
}),
|
|
61
55
|
)
|
|
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)
|
|
56
|
+
return useQuery(options as any) as any
|
|
83
57
|
}
|