@wagmi/vue 0.4.12 → 0.4.14
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/useConnect.js +6 -11
- package/dist/esm/composables/useConnect.js.map +1 -1
- package/dist/esm/composables/useDisconnect.js +2 -2
- package/dist/esm/composables/useDisconnect.js.map +1 -1
- package/dist/esm/composables/useReconnect.js +3 -3
- package/dist/esm/composables/useReconnect.js.map +1 -1
- package/dist/esm/composables/useSendTransaction.js +2 -2
- package/dist/esm/composables/useSendTransaction.js.map +1 -1
- package/dist/esm/composables/useSignMessage.js +3 -3
- package/dist/esm/composables/useSignMessage.js.map +1 -1
- package/dist/esm/composables/useSignTypedData.js +3 -5
- package/dist/esm/composables/useSignTypedData.js.map +1 -1
- package/dist/esm/composables/useSwitchChain.js +3 -5
- package/dist/esm/composables/useSwitchChain.js.map +1 -1
- package/dist/esm/composables/useSwitchConnection.js +3 -5
- package/dist/esm/composables/useSwitchConnection.js.map +1 -1
- package/dist/esm/composables/useWriteContract.js +2 -4
- package/dist/esm/composables/useWriteContract.js.map +1 -1
- package/dist/esm/errors/plugin.js +2 -2
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/utils/query.js +1 -55
- package/dist/esm/utils/query.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/types/composables/useConnect.d.ts +3 -5
- package/dist/types/composables/useConnect.d.ts.map +1 -1
- package/dist/types/composables/useDisconnect.d.ts +4 -8
- package/dist/types/composables/useDisconnect.d.ts.map +1 -1
- package/dist/types/composables/useReconnect.d.ts +3 -5
- package/dist/types/composables/useReconnect.d.ts.map +1 -1
- package/dist/types/composables/useSendTransaction.d.ts +4 -8
- package/dist/types/composables/useSendTransaction.d.ts.map +1 -1
- package/dist/types/composables/useSignMessage.d.ts +4 -8
- package/dist/types/composables/useSignMessage.d.ts.map +1 -1
- package/dist/types/composables/useSignTypedData.d.ts +4 -8
- package/dist/types/composables/useSignTypedData.d.ts.map +1 -1
- package/dist/types/composables/useSwitchChain.d.ts +3 -5
- package/dist/types/composables/useSwitchChain.d.ts.map +1 -1
- package/dist/types/composables/useSwitchConnection.d.ts +3 -5
- package/dist/types/composables/useSwitchConnection.d.ts.map +1 -1
- package/dist/types/composables/useWriteContract.d.ts +4 -8
- package/dist/types/composables/useWriteContract.d.ts.map +1 -1
- package/dist/types/utils/query.d.ts +9 -6
- package/dist/types/utils/query.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +3 -3
- package/src/composables/useConnect.ts +9 -29
- package/src/composables/useDisconnect.ts +12 -23
- package/src/composables/useReconnect.ts +9 -21
- package/src/composables/useSendTransaction.ts +9 -23
- package/src/composables/useSignMessage.ts +12 -24
- package/src/composables/useSignTypedData.ts +9 -24
- package/src/composables/useSwitchChain.ts +5 -22
- package/src/composables/useSwitchConnection.ts +11 -26
- package/src/composables/useWriteContract.ts +8 -28
- package/src/errors/plugin.ts +2 -2
- package/src/utils/query.ts +28 -81
- package/src/version.ts +1 -1
|
@@ -1,32 +1,19 @@
|
|
|
1
|
-
import { useMutation } from '@tanstack/vue-query'
|
|
2
1
|
import type { Connector, ReconnectErrorType } from '@wagmi/core'
|
|
3
2
|
import type { Compute } from '@wagmi/core/internal'
|
|
4
3
|
import {
|
|
5
4
|
type ReconnectData,
|
|
6
5
|
type ReconnectMutate,
|
|
7
6
|
type ReconnectMutateAsync,
|
|
7
|
+
type ReconnectOptions,
|
|
8
8
|
type ReconnectVariables,
|
|
9
9
|
reconnectMutationOptions,
|
|
10
10
|
} from '@wagmi/core/query'
|
|
11
|
-
|
|
12
11
|
import type { ConfigParameter } from '../types/properties.js'
|
|
13
|
-
import type
|
|
14
|
-
UseMutationParameters,
|
|
15
|
-
UseMutationReturnType,
|
|
16
|
-
} from '../utils/query.js'
|
|
12
|
+
import { type UseMutationReturnType, useMutation } from '../utils/query.js'
|
|
17
13
|
import { useConfig } from './useConfig.js'
|
|
18
14
|
|
|
19
15
|
export type UseReconnectParameters<context = unknown> = Compute<
|
|
20
|
-
ConfigParameter &
|
|
21
|
-
mutation?:
|
|
22
|
-
| UseMutationParameters<
|
|
23
|
-
ReconnectData,
|
|
24
|
-
ReconnectErrorType,
|
|
25
|
-
ReconnectVariables,
|
|
26
|
-
context
|
|
27
|
-
>
|
|
28
|
-
| undefined
|
|
29
|
-
}
|
|
16
|
+
ConfigParameter & ReconnectOptions<context>
|
|
30
17
|
>
|
|
31
18
|
|
|
32
19
|
export type UseReconnectReturnType<context = unknown> = Compute<
|
|
@@ -51,12 +38,13 @@ export function useReconnect<context = unknown>(
|
|
|
51
38
|
parameters: UseReconnectParameters<context> = {},
|
|
52
39
|
): UseReconnectReturnType<context> {
|
|
53
40
|
const config = useConfig(parameters)
|
|
54
|
-
const
|
|
55
|
-
const mutation = useMutation(
|
|
41
|
+
const options = reconnectMutationOptions(config, parameters as any)
|
|
42
|
+
const mutation = useMutation(options)
|
|
43
|
+
type Return = UseReconnectReturnType<context>
|
|
56
44
|
return {
|
|
57
|
-
...mutation,
|
|
45
|
+
...(mutation as Return),
|
|
58
46
|
connectors: config.connectors,
|
|
59
|
-
reconnect: mutation.mutate,
|
|
60
|
-
reconnectAsync: mutation.mutateAsync,
|
|
47
|
+
reconnect: mutation.mutate as Return['mutate'],
|
|
48
|
+
reconnectAsync: mutation.mutateAsync as Return['mutateAsync'],
|
|
61
49
|
}
|
|
62
50
|
}
|
|
@@ -9,32 +9,18 @@ import {
|
|
|
9
9
|
type SendTransactionData,
|
|
10
10
|
type SendTransactionMutate,
|
|
11
11
|
type SendTransactionMutateAsync,
|
|
12
|
+
type SendTransactionOptions,
|
|
12
13
|
type SendTransactionVariables,
|
|
13
14
|
sendTransactionMutationOptions,
|
|
14
15
|
} from '@wagmi/core/query'
|
|
15
|
-
|
|
16
16
|
import type { ConfigParameter } from '../types/properties.js'
|
|
17
|
-
import type {
|
|
18
|
-
UseMutationParameters,
|
|
19
|
-
UseMutationReturnType,
|
|
20
|
-
} from '../utils/query.js'
|
|
17
|
+
import type { UseMutationReturnType } from '../utils/query.js'
|
|
21
18
|
import { useConfig } from './useConfig.js'
|
|
22
19
|
|
|
23
20
|
export type UseSendTransactionParameters<
|
|
24
21
|
config extends Config = Config,
|
|
25
22
|
context = unknown,
|
|
26
|
-
> = Compute<
|
|
27
|
-
ConfigParameter<config> & {
|
|
28
|
-
mutation?:
|
|
29
|
-
| UseMutationParameters<
|
|
30
|
-
SendTransactionData,
|
|
31
|
-
SendTransactionErrorType,
|
|
32
|
-
SendTransactionVariables<config, config['chains'][number]['id']>,
|
|
33
|
-
context
|
|
34
|
-
>
|
|
35
|
-
| undefined
|
|
36
|
-
}
|
|
37
|
-
>
|
|
23
|
+
> = Compute<ConfigParameter<config> & SendTransactionOptions<config, context>>
|
|
38
24
|
|
|
39
25
|
export type UseSendTransactionReturnType<
|
|
40
26
|
config extends Config = Config,
|
|
@@ -44,10 +30,10 @@ export type UseSendTransactionReturnType<
|
|
|
44
30
|
SendTransactionData,
|
|
45
31
|
SendTransactionErrorType,
|
|
46
32
|
SendTransactionVariables<config, config['chains'][number]['id']>,
|
|
47
|
-
context
|
|
33
|
+
context,
|
|
34
|
+
SendTransactionMutate<config, context>,
|
|
35
|
+
SendTransactionMutateAsync<config, context>
|
|
48
36
|
> & {
|
|
49
|
-
mutate: SendTransactionMutate<config, context>
|
|
50
|
-
mutateAsync: SendTransactionMutateAsync<config, context>
|
|
51
37
|
/** @deprecated use `mutate` instead */
|
|
52
38
|
sendTransaction: SendTransactionMutate<config, context>
|
|
53
39
|
/** @deprecated use `mutateAsync` instead */
|
|
@@ -63,11 +49,11 @@ export function useSendTransaction<
|
|
|
63
49
|
parameters: UseSendTransactionParameters<config, context> = {},
|
|
64
50
|
): UseSendTransactionReturnType<config, context> {
|
|
65
51
|
const config = useConfig(parameters)
|
|
66
|
-
const
|
|
67
|
-
const mutation = useMutation(
|
|
52
|
+
const options = sendTransactionMutationOptions(config, parameters)
|
|
53
|
+
const mutation = useMutation(options)
|
|
68
54
|
type Return = UseSendTransactionReturnType<config, context>
|
|
69
55
|
return {
|
|
70
|
-
...mutation,
|
|
56
|
+
...(mutation as Return),
|
|
71
57
|
sendTransaction: mutation.mutate as Return['mutate'],
|
|
72
58
|
sendTransactionAsync: mutation.mutateAsync as Return['mutateAsync'],
|
|
73
59
|
}
|
|
@@ -4,29 +4,16 @@ import {
|
|
|
4
4
|
type SignMessageData,
|
|
5
5
|
type SignMessageMutate,
|
|
6
6
|
type SignMessageMutateAsync,
|
|
7
|
+
type SignMessageOptions,
|
|
7
8
|
type SignMessageVariables,
|
|
8
9
|
signMessageMutationOptions,
|
|
9
10
|
} from '@wagmi/core/query'
|
|
10
|
-
|
|
11
11
|
import type { ConfigParameter } from '../types/properties.js'
|
|
12
|
-
import {
|
|
13
|
-
type UseMutationParameters,
|
|
14
|
-
type UseMutationReturnType,
|
|
15
|
-
useMutation,
|
|
16
|
-
} from '../utils/query.js'
|
|
12
|
+
import { type UseMutationReturnType, useMutation } from '../utils/query.js'
|
|
17
13
|
import { useConfig } from './useConfig.js'
|
|
18
14
|
|
|
19
15
|
export type UseSignMessageParameters<context = unknown> = Compute<
|
|
20
|
-
ConfigParameter &
|
|
21
|
-
mutation?:
|
|
22
|
-
| UseMutationParameters<
|
|
23
|
-
SignMessageData,
|
|
24
|
-
SignMessageErrorType,
|
|
25
|
-
SignMessageVariables,
|
|
26
|
-
context
|
|
27
|
-
>
|
|
28
|
-
| undefined
|
|
29
|
-
}
|
|
16
|
+
ConfigParameter & SignMessageOptions<context>
|
|
30
17
|
>
|
|
31
18
|
|
|
32
19
|
export type UseSignMessageReturnType<context = unknown> = Compute<
|
|
@@ -34,10 +21,10 @@ export type UseSignMessageReturnType<context = unknown> = Compute<
|
|
|
34
21
|
SignMessageData,
|
|
35
22
|
SignMessageErrorType,
|
|
36
23
|
SignMessageVariables,
|
|
37
|
-
context
|
|
24
|
+
context,
|
|
25
|
+
SignMessageMutate<context>,
|
|
26
|
+
SignMessageMutateAsync<context>
|
|
38
27
|
> & {
|
|
39
|
-
mutate: SignMessageMutate<context>
|
|
40
|
-
mutateAsync: SignMessageMutateAsync<context>
|
|
41
28
|
/** @deprecated use `mutate` instead */
|
|
42
29
|
signMessage: SignMessageMutate<context>
|
|
43
30
|
/** @deprecated use `mutateAsync` instead */
|
|
@@ -50,11 +37,12 @@ export function useSignMessage<context = unknown>(
|
|
|
50
37
|
parameters: UseSignMessageParameters<context> = {},
|
|
51
38
|
): UseSignMessageReturnType<context> {
|
|
52
39
|
const config = useConfig(parameters)
|
|
53
|
-
const
|
|
54
|
-
const mutation = useMutation(
|
|
40
|
+
const options = signMessageMutationOptions(config, parameters)
|
|
41
|
+
const mutation = useMutation(options)
|
|
42
|
+
type Return = UseSignMessageReturnType<context>
|
|
55
43
|
return {
|
|
56
|
-
...mutation,
|
|
57
|
-
signMessage: mutation.mutate,
|
|
58
|
-
signMessageAsync: mutation.mutateAsync,
|
|
44
|
+
...(mutation as Return),
|
|
45
|
+
signMessage: mutation.mutate as Return['mutate'],
|
|
46
|
+
signMessageAsync: mutation.mutateAsync as Return['mutateAsync'],
|
|
59
47
|
}
|
|
60
48
|
}
|
|
@@ -4,29 +4,16 @@ import {
|
|
|
4
4
|
type SignTypedDataData,
|
|
5
5
|
type SignTypedDataMutate,
|
|
6
6
|
type SignTypedDataMutateAsync,
|
|
7
|
+
type SignTypedDataOptions,
|
|
7
8
|
type SignTypedDataVariables,
|
|
8
9
|
signTypedDataMutationOptions,
|
|
9
10
|
} from '@wagmi/core/query'
|
|
10
|
-
|
|
11
11
|
import type { ConfigParameter } from '../types/properties.js'
|
|
12
|
-
import {
|
|
13
|
-
type UseMutationParameters,
|
|
14
|
-
type UseMutationReturnType,
|
|
15
|
-
useMutation,
|
|
16
|
-
} from '../utils/query.js'
|
|
12
|
+
import { type UseMutationReturnType, useMutation } from '../utils/query.js'
|
|
17
13
|
import { useConfig } from './useConfig.js'
|
|
18
14
|
|
|
19
15
|
export type UseSignTypedDataParameters<context = unknown> = Compute<
|
|
20
|
-
ConfigParameter &
|
|
21
|
-
mutation?:
|
|
22
|
-
| UseMutationParameters<
|
|
23
|
-
SignTypedDataData,
|
|
24
|
-
SignTypedDataErrorType,
|
|
25
|
-
SignTypedDataVariables,
|
|
26
|
-
context
|
|
27
|
-
>
|
|
28
|
-
| undefined
|
|
29
|
-
}
|
|
16
|
+
ConfigParameter & SignTypedDataOptions<context>
|
|
30
17
|
>
|
|
31
18
|
|
|
32
19
|
export type UseSignTypedDataReturnType<context = unknown> = Compute<
|
|
@@ -34,10 +21,10 @@ export type UseSignTypedDataReturnType<context = unknown> = Compute<
|
|
|
34
21
|
SignTypedDataData,
|
|
35
22
|
SignTypedDataErrorType,
|
|
36
23
|
SignTypedDataVariables,
|
|
37
|
-
context
|
|
24
|
+
context,
|
|
25
|
+
SignTypedDataMutate<context>,
|
|
26
|
+
SignTypedDataMutateAsync<context>
|
|
38
27
|
> & {
|
|
39
|
-
mutate: SignTypedDataMutate<context>
|
|
40
|
-
mutateAsync: SignTypedDataMutateAsync<context>
|
|
41
28
|
/** @deprecated use `mutate` instead */
|
|
42
29
|
signTypedData: SignTypedDataMutate<context>
|
|
43
30
|
/** @deprecated use `mutateAsync` instead */
|
|
@@ -50,13 +37,11 @@ export function useSignTypedData<context = unknown>(
|
|
|
50
37
|
parameters: UseSignTypedDataParameters<context> = {},
|
|
51
38
|
): UseSignTypedDataReturnType<context> {
|
|
52
39
|
const config = useConfig(parameters)
|
|
53
|
-
const
|
|
54
|
-
const mutation = useMutation(
|
|
40
|
+
const options = signTypedDataMutationOptions(config, parameters)
|
|
41
|
+
const mutation = useMutation(options)
|
|
55
42
|
type Return = UseSignTypedDataReturnType<context>
|
|
56
43
|
return {
|
|
57
|
-
...mutation,
|
|
58
|
-
mutate: mutation.mutate as Return['mutate'],
|
|
59
|
-
mutateAsync: mutation.mutateAsync as Return['mutateAsync'],
|
|
44
|
+
...(mutation as Return),
|
|
60
45
|
signTypedData: mutation.mutate as Return['mutate'],
|
|
61
46
|
signTypedDataAsync: mutation.mutateAsync as Return['mutateAsync'],
|
|
62
47
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { useMutation } from '@tanstack/vue-query'
|
|
2
1
|
import type {
|
|
3
2
|
Config,
|
|
4
3
|
ResolvedRegister,
|
|
@@ -9,34 +8,20 @@ import {
|
|
|
9
8
|
type SwitchChainData,
|
|
10
9
|
type SwitchChainMutate,
|
|
11
10
|
type SwitchChainMutateAsync,
|
|
11
|
+
type SwitchChainOptions,
|
|
12
12
|
type SwitchChainVariables,
|
|
13
13
|
switchChainMutationOptions,
|
|
14
14
|
} from '@wagmi/core/query'
|
|
15
15
|
import type { Ref } from 'vue'
|
|
16
|
-
|
|
17
16
|
import type { ConfigParameter } from '../types/properties.js'
|
|
18
|
-
import type
|
|
19
|
-
UseMutationParameters,
|
|
20
|
-
UseMutationReturnType,
|
|
21
|
-
} from '../utils/query.js'
|
|
17
|
+
import { type UseMutationReturnType, useMutation } from '../utils/query.js'
|
|
22
18
|
import { useChains } from './useChains.js'
|
|
23
19
|
import { useConfig } from './useConfig.js'
|
|
24
20
|
|
|
25
21
|
export type UseSwitchChainParameters<
|
|
26
22
|
config extends Config = Config,
|
|
27
23
|
context = unknown,
|
|
28
|
-
> = Compute<
|
|
29
|
-
ConfigParameter<config> & {
|
|
30
|
-
mutation?:
|
|
31
|
-
| UseMutationParameters<
|
|
32
|
-
SwitchChainData<config, config['chains'][number]['id']>,
|
|
33
|
-
SwitchChainErrorType,
|
|
34
|
-
SwitchChainVariables<config, config['chains'][number]['id']>,
|
|
35
|
-
context
|
|
36
|
-
>
|
|
37
|
-
| undefined
|
|
38
|
-
}
|
|
39
|
-
>
|
|
24
|
+
> = Compute<ConfigParameter<config> & SwitchChainOptions<config, context>>
|
|
40
25
|
|
|
41
26
|
export type UseSwitchChainReturnType<
|
|
42
27
|
config extends Config = Config,
|
|
@@ -67,14 +52,12 @@ export function useSwitchChain<
|
|
|
67
52
|
parameters: UseSwitchChainParameters<config, context> = {},
|
|
68
53
|
): UseSwitchChainReturnType<config, context> {
|
|
69
54
|
const config = useConfig(parameters)
|
|
70
|
-
const
|
|
71
|
-
const mutation = useMutation(
|
|
55
|
+
const options = switchChainMutationOptions(config, parameters as any)
|
|
56
|
+
const mutation = useMutation(options)
|
|
72
57
|
type Return = UseSwitchChainReturnType<config, context>
|
|
73
58
|
return {
|
|
74
59
|
...(mutation as unknown as Return),
|
|
75
60
|
chains: useChains({ config }) as unknown as Ref<config['chains']>,
|
|
76
|
-
mutate: mutation.mutate as Return['mutate'],
|
|
77
|
-
mutateAsync: mutation.mutateAsync as Return['mutateAsync'],
|
|
78
61
|
switchChain: mutation.mutate as Return['mutate'],
|
|
79
62
|
switchChainAsync: mutation.mutateAsync as Return['mutateAsync'],
|
|
80
63
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { useMutation } from '@tanstack/vue-query'
|
|
2
1
|
import type {
|
|
3
2
|
Config,
|
|
4
3
|
Connector,
|
|
@@ -10,34 +9,21 @@ import {
|
|
|
10
9
|
type SwitchConnectionData,
|
|
11
10
|
type SwitchConnectionMutate,
|
|
12
11
|
type SwitchConnectionMutateAsync,
|
|
12
|
+
type SwitchConnectionOptions,
|
|
13
13
|
type SwitchConnectionVariables,
|
|
14
14
|
switchConnectionMutationOptions,
|
|
15
15
|
} from '@wagmi/core/query'
|
|
16
16
|
import { computed, type Ref } from 'vue'
|
|
17
17
|
|
|
18
18
|
import type { ConfigParameter } from '../types/properties.js'
|
|
19
|
-
import type
|
|
20
|
-
UseMutationParameters,
|
|
21
|
-
UseMutationReturnType,
|
|
22
|
-
} from '../utils/query.js'
|
|
19
|
+
import { type UseMutationReturnType, useMutation } from '../utils/query.js'
|
|
23
20
|
import { useConfig } from './useConfig.js'
|
|
24
21
|
import { useConnections } from './useConnections.js'
|
|
25
22
|
|
|
26
23
|
export type UseSwitchConnectionParameters<
|
|
27
24
|
config extends Config = Config,
|
|
28
25
|
context = unknown,
|
|
29
|
-
> = Compute<
|
|
30
|
-
ConfigParameter<config> & {
|
|
31
|
-
mutation?:
|
|
32
|
-
| UseMutationParameters<
|
|
33
|
-
SwitchConnectionData<config>,
|
|
34
|
-
SwitchConnectionErrorType,
|
|
35
|
-
SwitchConnectionVariables,
|
|
36
|
-
context
|
|
37
|
-
>
|
|
38
|
-
| undefined
|
|
39
|
-
}
|
|
40
|
-
>
|
|
26
|
+
> = Compute<ConfigParameter<config> & SwitchConnectionOptions<config, context>>
|
|
41
27
|
|
|
42
28
|
export type UseSwitchConnectionReturnType<
|
|
43
29
|
config extends Config = Config,
|
|
@@ -73,18 +59,17 @@ export function useSwitchConnection<
|
|
|
73
59
|
): UseSwitchConnectionReturnType<config, context> {
|
|
74
60
|
const config = useConfig(parameters)
|
|
75
61
|
const connections = useConnections({ config })
|
|
76
|
-
const
|
|
77
|
-
const mutation = useMutation(
|
|
62
|
+
const options = switchConnectionMutationOptions(config, parameters as any)
|
|
63
|
+
const mutation = useMutation(options)
|
|
64
|
+
type Return = UseSwitchConnectionReturnType<config, context>
|
|
78
65
|
return {
|
|
79
|
-
...mutation,
|
|
66
|
+
...(mutation as Return),
|
|
80
67
|
connectors: computed(() =>
|
|
81
68
|
connections.value.map((connection) => connection.connector),
|
|
82
69
|
),
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
switchConnection: mutation.mutate,
|
|
88
|
-
switchConnectionAsync: mutation.mutateAsync,
|
|
70
|
+
switchAccount: mutation.mutate as Return['mutate'],
|
|
71
|
+
switchAccountAsync: mutation.mutateAsync as Return['mutateAsync'],
|
|
72
|
+
switchConnection: mutation.mutate as Return['mutate'],
|
|
73
|
+
switchConnectionAsync: mutation.mutateAsync as Return['mutateAsync'],
|
|
89
74
|
}
|
|
90
75
|
}
|
|
@@ -8,37 +8,19 @@ import {
|
|
|
8
8
|
type WriteContractData,
|
|
9
9
|
type WriteContractMutate,
|
|
10
10
|
type WriteContractMutateAsync,
|
|
11
|
+
type WriteContractOptions,
|
|
11
12
|
type WriteContractVariables,
|
|
12
13
|
writeContractMutationOptions,
|
|
13
14
|
} from '@wagmi/core/query'
|
|
14
15
|
import type { Abi } from 'viem'
|
|
15
|
-
|
|
16
16
|
import type { ConfigParameter } from '../types/properties.js'
|
|
17
|
-
import type {
|
|
18
|
-
UseMutationParameters,
|
|
19
|
-
UseMutationReturnType,
|
|
20
|
-
} from '../utils/query.js'
|
|
17
|
+
import type { UseMutationReturnType } from '../utils/query.js'
|
|
21
18
|
import { useConfig } from './useConfig.js'
|
|
22
19
|
|
|
23
20
|
export type UseWriteContractParameters<
|
|
24
21
|
config extends Config = Config,
|
|
25
22
|
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
|
-
}
|
|
23
|
+
> = ConfigParameter<config> & WriteContractOptions<config, context>
|
|
42
24
|
|
|
43
25
|
export type UseWriteContractReturnType<
|
|
44
26
|
config extends Config = Config,
|
|
@@ -53,10 +35,10 @@ export type UseWriteContractReturnType<
|
|
|
53
35
|
config,
|
|
54
36
|
config['chains'][number]['id']
|
|
55
37
|
>,
|
|
56
|
-
context
|
|
38
|
+
context,
|
|
39
|
+
WriteContractMutate<config, context>,
|
|
40
|
+
WriteContractMutateAsync<config, context>
|
|
57
41
|
> & {
|
|
58
|
-
mutate: WriteContractMutate<config, context>
|
|
59
|
-
mutateAsync: WriteContractMutateAsync<config, context>
|
|
60
42
|
/** @deprecated use `mutate` instead */
|
|
61
43
|
writeContract: WriteContractMutate<config, context>
|
|
62
44
|
/** @deprecated use `mutateAsync` instead */
|
|
@@ -71,13 +53,11 @@ export function useWriteContract<
|
|
|
71
53
|
parameters: UseWriteContractParameters<config, context> = {},
|
|
72
54
|
): UseWriteContractReturnType<config, context> {
|
|
73
55
|
const config = useConfig(parameters)
|
|
74
|
-
const
|
|
75
|
-
const mutation = useMutation(
|
|
56
|
+
const options = writeContractMutationOptions(config, parameters)
|
|
57
|
+
const mutation = useMutation(options)
|
|
76
58
|
type Return = UseWriteContractReturnType<config, context>
|
|
77
59
|
return {
|
|
78
60
|
...(mutation as Return),
|
|
79
|
-
mutate: mutation.mutate as Return['mutate'],
|
|
80
|
-
mutateAsync: mutation.mutateAsync as Return['mutateAsync'],
|
|
81
61
|
writeContract: mutation.mutate as Return['mutate'],
|
|
82
62
|
writeContractAsync: mutation.mutateAsync as Return['mutateAsync'],
|
|
83
63
|
}
|
package/src/errors/plugin.ts
CHANGED
|
@@ -9,7 +9,7 @@ export class WagmiPluginNotFoundError extends BaseError {
|
|
|
9
9
|
super(
|
|
10
10
|
'No `config` found in Vue context, use `WagmiPlugin` to properly initialize the library.',
|
|
11
11
|
{
|
|
12
|
-
docsPath: '/api/
|
|
12
|
+
docsPath: '/api/Nuxt',
|
|
13
13
|
},
|
|
14
14
|
)
|
|
15
15
|
}
|
|
@@ -24,7 +24,7 @@ export class WagmiInjectionContextError extends BaseError {
|
|
|
24
24
|
super(
|
|
25
25
|
'Wagmi composables can only be used inside `setup()` function or functions that support injection context.',
|
|
26
26
|
{
|
|
27
|
-
docsPath: '/api/
|
|
27
|
+
docsPath: '/api/Nuxt',
|
|
28
28
|
},
|
|
29
29
|
)
|
|
30
30
|
}
|
package/src/utils/query.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type DefaultError,
|
|
3
|
+
type MutateFunction,
|
|
3
4
|
type MutationObserverOptions,
|
|
4
5
|
type QueryKey,
|
|
5
6
|
type UseMutationReturnType as tanstack_UseMutationReturnType,
|
|
@@ -19,6 +20,8 @@ import { computed, type MaybeRef, unref } from 'vue'
|
|
|
19
20
|
|
|
20
21
|
import type { DeepMaybeRef, DeepUnwrapRef } from '../types/ref.js'
|
|
21
22
|
|
|
23
|
+
export { useMutation }
|
|
24
|
+
|
|
22
25
|
export type UseMutationParameters<
|
|
23
26
|
data = unknown,
|
|
24
27
|
error = Error,
|
|
@@ -40,17 +43,39 @@ export type UseMutationReturnType<
|
|
|
40
43
|
error = Error,
|
|
41
44
|
variables = void,
|
|
42
45
|
context = unknown,
|
|
46
|
+
mutate = MutateFunction,
|
|
47
|
+
mutateAsync = MutateFunction,
|
|
43
48
|
> = Compute<
|
|
44
49
|
UnionStrictOmit<
|
|
45
50
|
tanstack_UseMutationReturnType<data, error, variables, context>,
|
|
46
51
|
'mutate' | 'mutateAsync'
|
|
47
|
-
>
|
|
52
|
+
> & {
|
|
53
|
+
mutate: mutate
|
|
54
|
+
mutateAsync: mutateAsync
|
|
55
|
+
}
|
|
48
56
|
>
|
|
49
57
|
|
|
50
|
-
export { useMutation }
|
|
51
|
-
|
|
52
58
|
////////////////////////////////////////////////////////////////////////////////
|
|
53
59
|
|
|
60
|
+
// Adding some basic customization.
|
|
61
|
+
// Ideally we don't have this function, but `import('@tanstack/vue-query').useQuery` currently has some quirks where it is super hard to
|
|
62
|
+
// pass down the inferred `initialData` type because of it's discriminated overload in the on `useQuery`.
|
|
63
|
+
export function useQuery<queryFnData, error, data, queryKey extends QueryKey>(
|
|
64
|
+
parameters: MaybeRef<
|
|
65
|
+
UseQueryParameters<queryFnData, error, data, queryKey> & {
|
|
66
|
+
queryKey: QueryKey
|
|
67
|
+
}
|
|
68
|
+
>,
|
|
69
|
+
): UseQueryReturnType<data, error> {
|
|
70
|
+
const options = computed(() => ({
|
|
71
|
+
...(unref(parameters) as any),
|
|
72
|
+
queryKeyHashFn: hashFn,
|
|
73
|
+
}))
|
|
74
|
+
const result = tanstack_useQuery(options) as UseQueryReturnType<data, error>
|
|
75
|
+
result.queryKey = unref(options).queryKey as QueryKey
|
|
76
|
+
return result
|
|
77
|
+
}
|
|
78
|
+
|
|
54
79
|
export type UseQueryParameters<
|
|
55
80
|
queryFnData = unknown,
|
|
56
81
|
error = DefaultError,
|
|
@@ -81,81 +106,3 @@ export type UseQueryReturnType<data = unknown, error = DefaultError> = Compute<
|
|
|
81
106
|
queryKey: QueryKey
|
|
82
107
|
}
|
|
83
108
|
>
|
|
84
|
-
|
|
85
|
-
// Adding some basic customization.
|
|
86
|
-
// Ideally we don't have this function, but `import('@tanstack/vue-query').useQuery` currently has some quirks where it is super hard to
|
|
87
|
-
// pass down the inferred `initialData` type because of it's discriminated overload in the on `useQuery`.
|
|
88
|
-
export function useQuery<queryFnData, error, data, queryKey extends QueryKey>(
|
|
89
|
-
parameters: MaybeRef<
|
|
90
|
-
UseQueryParameters<queryFnData, error, data, queryKey> & {
|
|
91
|
-
queryKey: QueryKey
|
|
92
|
-
}
|
|
93
|
-
>,
|
|
94
|
-
): UseQueryReturnType<data, error> {
|
|
95
|
-
const options = computed(() => ({
|
|
96
|
-
...(unref(parameters) as any),
|
|
97
|
-
queryKeyHashFn: hashFn,
|
|
98
|
-
}))
|
|
99
|
-
const result = tanstack_useQuery(options) as UseQueryReturnType<data, error>
|
|
100
|
-
result.queryKey = unref(options).queryKey as QueryKey
|
|
101
|
-
return result
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
////////////////////////////////////////////////////////////////////////////////
|
|
105
|
-
|
|
106
|
-
// export type UseInfiniteQueryParameters<
|
|
107
|
-
// queryFnData = unknown,
|
|
108
|
-
// error = DefaultError,
|
|
109
|
-
// data = queryFnData,
|
|
110
|
-
// queryData = queryFnData,
|
|
111
|
-
// queryKey extends QueryKey = QueryKey,
|
|
112
|
-
// pageParam = unknown,
|
|
113
|
-
// > = Compute<
|
|
114
|
-
// Omit<
|
|
115
|
-
// UseInfiniteQueryOptions<
|
|
116
|
-
// queryFnData,
|
|
117
|
-
// error,
|
|
118
|
-
// data,
|
|
119
|
-
// queryData,
|
|
120
|
-
// queryKey,
|
|
121
|
-
// pageParam
|
|
122
|
-
// >,
|
|
123
|
-
// 'initialData'
|
|
124
|
-
// > & {
|
|
125
|
-
// // Fix `initialData` type
|
|
126
|
-
// initialData?:
|
|
127
|
-
// | UseInfiniteQueryOptions<
|
|
128
|
-
// queryFnData,
|
|
129
|
-
// error,
|
|
130
|
-
// data,
|
|
131
|
-
// queryKey
|
|
132
|
-
// >['initialData']
|
|
133
|
-
// | undefined
|
|
134
|
-
// }
|
|
135
|
-
// >
|
|
136
|
-
|
|
137
|
-
// export type UseInfiniteQueryReturnType<
|
|
138
|
-
// data = unknown,
|
|
139
|
-
// error = DefaultError,
|
|
140
|
-
// > = import('@tanstack/vue-query').UseInfiniteQueryReturnType<data, error> & {
|
|
141
|
-
// queryKey: QueryKey
|
|
142
|
-
// }
|
|
143
|
-
|
|
144
|
-
// // Adding some basic customization.
|
|
145
|
-
// export function useInfiniteQuery<
|
|
146
|
-
// queryFnData,
|
|
147
|
-
// error,
|
|
148
|
-
// data,
|
|
149
|
-
// queryKey extends QueryKey,
|
|
150
|
-
// >(
|
|
151
|
-
// parameters: UseInfiniteQueryParameters<queryFnData, error, data, queryKey> & {
|
|
152
|
-
// queryKey: QueryKey
|
|
153
|
-
// },
|
|
154
|
-
// ): UseInfiniteQueryReturnType<data, error> {
|
|
155
|
-
// const result = tanstack_useInfiniteQuery({
|
|
156
|
-
// ...(parameters as any),
|
|
157
|
-
// queryKeyHashFn: hashFn, // for bigint support
|
|
158
|
-
// }) as UseInfiniteQueryReturnType<data, error>
|
|
159
|
-
// result.queryKey = parameters.queryKey
|
|
160
|
-
// return result
|
|
161
|
-
// }
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '0.4.
|
|
1
|
+
export const version = '0.4.14'
|