@wagmi/core 3.2.3 → 3.3.1

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.
Files changed (151) hide show
  1. package/dist/esm/actions/getBlobBaseFee.js +10 -0
  2. package/dist/esm/actions/getBlobBaseFee.js.map +1 -0
  3. package/dist/esm/actions/getContractEvents.js +10 -0
  4. package/dist/esm/actions/getContractEvents.js.map +1 -0
  5. package/dist/esm/actions/writeContractSync.js +31 -0
  6. package/dist/esm/actions/writeContractSync.js.map +1 -0
  7. package/dist/esm/connectors/mock.js +2 -0
  8. package/dist/esm/connectors/mock.js.map +1 -1
  9. package/dist/esm/exports/actions.js +2 -0
  10. package/dist/esm/exports/actions.js.map +1 -1
  11. package/dist/esm/exports/index.js +3 -0
  12. package/dist/esm/exports/index.js.map +1 -1
  13. package/dist/esm/exports/query.js +3 -0
  14. package/dist/esm/exports/query.js.map +1 -1
  15. package/dist/esm/query/connect.js +3 -2
  16. package/dist/esm/query/connect.js.map +1 -1
  17. package/dist/esm/query/deployContract.js +2 -1
  18. package/dist/esm/query/deployContract.js.map +1 -1
  19. package/dist/esm/query/disconnect.js +3 -2
  20. package/dist/esm/query/disconnect.js.map +1 -1
  21. package/dist/esm/query/getBlobBaseFee.js +17 -0
  22. package/dist/esm/query/getBlobBaseFee.js.map +1 -0
  23. package/dist/esm/query/getContractEvents.js +24 -0
  24. package/dist/esm/query/getContractEvents.js.map +1 -0
  25. package/dist/esm/query/readContracts.js +13 -2
  26. package/dist/esm/query/readContracts.js.map +1 -1
  27. package/dist/esm/query/reconnect.js +2 -1
  28. package/dist/esm/query/reconnect.js.map +1 -1
  29. package/dist/esm/query/sendCalls.js +2 -1
  30. package/dist/esm/query/sendCalls.js.map +1 -1
  31. package/dist/esm/query/sendCallsSync.js +2 -1
  32. package/dist/esm/query/sendCallsSync.js.map +1 -1
  33. package/dist/esm/query/sendTransaction.js +2 -1
  34. package/dist/esm/query/sendTransaction.js.map +1 -1
  35. package/dist/esm/query/sendTransactionSync.js +2 -1
  36. package/dist/esm/query/sendTransactionSync.js.map +1 -1
  37. package/dist/esm/query/showCallsStatus.js +2 -1
  38. package/dist/esm/query/showCallsStatus.js.map +1 -1
  39. package/dist/esm/query/signMessage.js +2 -1
  40. package/dist/esm/query/signMessage.js.map +1 -1
  41. package/dist/esm/query/signTypedData.js +2 -1
  42. package/dist/esm/query/signTypedData.js.map +1 -1
  43. package/dist/esm/query/switchChain.js +2 -1
  44. package/dist/esm/query/switchChain.js.map +1 -1
  45. package/dist/esm/query/switchConnection.js +2 -1
  46. package/dist/esm/query/switchConnection.js.map +1 -1
  47. package/dist/esm/query/verifyTypedData.js.map +1 -1
  48. package/dist/esm/query/watchAsset.js +2 -1
  49. package/dist/esm/query/watchAsset.js.map +1 -1
  50. package/dist/esm/query/writeContract.js +2 -1
  51. package/dist/esm/query/writeContract.js.map +1 -1
  52. package/dist/esm/query/writeContractSync.js +11 -0
  53. package/dist/esm/query/writeContractSync.js.map +1 -0
  54. package/dist/esm/tempo/Connectors.js +6 -2
  55. package/dist/esm/tempo/Connectors.js.map +1 -1
  56. package/dist/esm/tempo/KeyManager.js +4 -4
  57. package/dist/esm/tempo/KeyManager.js.map +1 -1
  58. package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
  59. package/dist/esm/version.js +1 -1
  60. package/dist/types/actions/getBlobBaseFee.d.ts +10 -0
  61. package/dist/types/actions/getBlobBaseFee.d.ts.map +1 -0
  62. package/dist/types/actions/getContractEvents.d.ts +11 -0
  63. package/dist/types/actions/getContractEvents.d.ts.map +1 -0
  64. package/dist/types/actions/writeContractSync.d.ts +16 -0
  65. package/dist/types/actions/writeContractSync.d.ts.map +1 -0
  66. package/dist/types/connectors/mock.d.ts.map +1 -1
  67. package/dist/types/exports/actions.d.ts +2 -0
  68. package/dist/types/exports/actions.d.ts.map +1 -1
  69. package/dist/types/exports/index.d.ts +3 -0
  70. package/dist/types/exports/index.d.ts.map +1 -1
  71. package/dist/types/exports/query.d.ts +21 -14
  72. package/dist/types/exports/query.d.ts.map +1 -1
  73. package/dist/types/query/connect.d.ts +5 -5
  74. package/dist/types/query/connect.d.ts.map +1 -1
  75. package/dist/types/query/deployContract.d.ts +5 -5
  76. package/dist/types/query/deployContract.d.ts.map +1 -1
  77. package/dist/types/query/disconnect.d.ts +5 -4
  78. package/dist/types/query/disconnect.d.ts.map +1 -1
  79. package/dist/types/query/getBlobBaseFee.d.ts +16 -0
  80. package/dist/types/query/getBlobBaseFee.d.ts.map +1 -0
  81. package/dist/types/query/getContractEvents.d.ts +24 -0
  82. package/dist/types/query/getContractEvents.d.ts.map +1 -0
  83. package/dist/types/query/getEnsAddress.d.ts +1 -1
  84. package/dist/types/query/getEnsAvatar.d.ts +1 -1
  85. package/dist/types/query/getEnsName.d.ts +1 -1
  86. package/dist/types/query/getEnsText.d.ts +1 -1
  87. package/dist/types/query/readContracts.d.ts +1 -1
  88. package/dist/types/query/readContracts.d.ts.map +1 -1
  89. package/dist/types/query/reconnect.d.ts +5 -4
  90. package/dist/types/query/reconnect.d.ts.map +1 -1
  91. package/dist/types/query/sendCalls.d.ts +5 -10
  92. package/dist/types/query/sendCalls.d.ts.map +1 -1
  93. package/dist/types/query/sendCallsSync.d.ts +5 -18
  94. package/dist/types/query/sendCallsSync.d.ts.map +1 -1
  95. package/dist/types/query/sendTransaction.d.ts +5 -5
  96. package/dist/types/query/sendTransaction.d.ts.map +1 -1
  97. package/dist/types/query/sendTransactionSync.d.ts +5 -5
  98. package/dist/types/query/sendTransactionSync.d.ts.map +1 -1
  99. package/dist/types/query/showCallsStatus.d.ts +5 -5
  100. package/dist/types/query/showCallsStatus.d.ts.map +1 -1
  101. package/dist/types/query/signMessage.d.ts +5 -8
  102. package/dist/types/query/signMessage.d.ts.map +1 -1
  103. package/dist/types/query/signTypedData.d.ts +5 -223
  104. package/dist/types/query/signTypedData.d.ts.map +1 -1
  105. package/dist/types/query/switchChain.d.ts +5 -21
  106. package/dist/types/query/switchChain.d.ts.map +1 -1
  107. package/dist/types/query/switchConnection.d.ts +5 -6
  108. package/dist/types/query/switchConnection.d.ts.map +1 -1
  109. package/dist/types/query/verifyTypedData.d.ts.map +1 -1
  110. package/dist/types/query/watchAsset.d.ts +5 -13
  111. package/dist/types/query/watchAsset.d.ts.map +1 -1
  112. package/dist/types/query/writeContract.d.ts +5 -7
  113. package/dist/types/query/writeContract.d.ts.map +1 -1
  114. package/dist/types/query/writeContractSync.d.ts +14 -0
  115. package/dist/types/query/writeContractSync.d.ts.map +1 -0
  116. package/dist/types/tempo/Connectors.d.ts.map +1 -1
  117. package/dist/types/types/query.d.ts +4 -1
  118. package/dist/types/types/query.d.ts.map +1 -1
  119. package/dist/types/version.d.ts +1 -1
  120. package/package.json +1 -1
  121. package/src/actions/getBlobBaseFee.ts +35 -0
  122. package/src/actions/getContractEvents.ts +68 -0
  123. package/src/actions/writeContractSync.ts +120 -0
  124. package/src/connectors/mock.ts +1 -0
  125. package/src/exports/actions.ts +14 -0
  126. package/src/exports/index.ts +21 -0
  127. package/src/exports/query.ts +64 -0
  128. package/src/query/connect.ts +24 -8
  129. package/src/query/deployContract.ts +20 -5
  130. package/src/query/disconnect.ts +20 -9
  131. package/src/query/getBlobBaseFee.ts +75 -0
  132. package/src/query/getContractEvents.ts +214 -0
  133. package/src/query/readContracts.ts +12 -2
  134. package/src/query/reconnect.ts +20 -7
  135. package/src/query/sendCalls.ts +22 -8
  136. package/src/query/sendCallsSync.ts +20 -5
  137. package/src/query/sendTransaction.ts +20 -5
  138. package/src/query/sendTransactionSync.ts +23 -5
  139. package/src/query/showCallsStatus.ts +19 -8
  140. package/src/query/signMessage.ts +20 -7
  141. package/src/query/signTypedData.ts +19 -8
  142. package/src/query/switchChain.ts +22 -8
  143. package/src/query/switchConnection.ts +20 -5
  144. package/src/query/verifyTypedData.ts +0 -1
  145. package/src/query/watchAsset.ts +20 -7
  146. package/src/query/writeContract.ts +26 -5
  147. package/src/query/writeContractSync.ts +130 -0
  148. package/src/tempo/Connectors.ts +6 -2
  149. package/src/tempo/KeyManager.ts +6 -4
  150. package/src/types/query.ts +15 -1
  151. package/src/version.ts +1 -1
@@ -1,6 +1,5 @@
1
1
  import type { MutateOptions, MutationOptions } from '@tanstack/query-core'
2
2
  import type { Abi, ContractConstructorArgs } from 'viem'
3
-
4
3
  import {
5
4
  type DeployContractErrorType,
6
5
  type DeployContractParameters,
@@ -8,22 +7,38 @@ import {
8
7
  deployContract,
9
8
  } from '../actions/deployContract.js'
10
9
  import type { Config } from '../createConfig.js'
10
+ import type { MutationParameter } from '../types/query.js'
11
11
  import type { Compute } from '../types/utils.js'
12
12
 
13
- export function deployContractMutationOptions<config extends Config>(
13
+ export type DeployContractOptions<
14
+ config extends Config,
15
+ context = unknown,
16
+ > = MutationParameter<
17
+ DeployContractData,
18
+ DeployContractErrorType,
19
+ DeployContractVariables<Abi, config, config['chains'][number]['id']>,
20
+ context
21
+ >
22
+
23
+ export function deployContractMutationOptions<config extends Config, context>(
14
24
  config: config,
15
- ) {
25
+ options: DeployContractOptions<config, context> = {},
26
+ ): DeployContractMutationOptions<config> {
16
27
  return {
28
+ ...(options.mutation as any),
17
29
  mutationFn(variables) {
18
30
  return deployContract(config, variables)
19
31
  },
20
32
  mutationKey: ['deployContract'],
21
- } as const satisfies MutationOptions<
33
+ }
34
+ }
35
+
36
+ export type DeployContractMutationOptions<config extends Config> =
37
+ MutationOptions<
22
38
  DeployContractData,
23
39
  DeployContractErrorType,
24
40
  DeployContractVariables<Abi, config, config['chains'][number]['id']>
25
41
  >
26
- }
27
42
 
28
43
  export type DeployContractData = Compute<DeployContractReturnType>
29
44
 
@@ -1,5 +1,4 @@
1
1
  import type { MutationOptions } from '@tanstack/query-core'
2
-
3
2
  import {
4
3
  type DisconnectErrorType,
5
4
  type DisconnectParameters,
@@ -7,23 +6,35 @@ import {
7
6
  disconnect,
8
7
  } from '../actions/disconnect.js'
9
8
  import type { Config } from '../createConfig.js'
9
+ import type { MutationParameter } from '../types/query.js'
10
10
  import type { Mutate, MutateAsync } from './types.js'
11
11
 
12
- export function disconnectMutationOptions<config extends Config>(
12
+ export type DisconnectOptions<context = unknown> = MutationParameter<
13
+ DisconnectData,
14
+ DisconnectErrorType,
15
+ DisconnectVariables,
16
+ context
17
+ >
18
+
19
+ export function disconnectMutationOptions<config extends Config, context>(
13
20
  config: config,
14
- ) {
21
+ options: DisconnectOptions<context> = {},
22
+ ): DisconnectMutationOptions {
15
23
  return {
16
- mutationFn(variables) {
24
+ ...(options.mutation as any),
25
+ mutationFn: async (variables) => {
17
26
  return disconnect(config, variables)
18
27
  },
19
28
  mutationKey: ['disconnect'],
20
- } as const satisfies MutationOptions<
21
- DisconnectData,
22
- DisconnectErrorType,
23
- DisconnectVariables
24
- >
29
+ }
25
30
  }
26
31
 
32
+ export type DisconnectMutationOptions = MutationOptions<
33
+ DisconnectData,
34
+ DisconnectErrorType,
35
+ DisconnectVariables
36
+ >
37
+
27
38
  export type DisconnectData = DisconnectReturnType
28
39
 
29
40
  export type DisconnectVariables = DisconnectParameters | undefined
@@ -0,0 +1,75 @@
1
+ import {
2
+ type GetBlobBaseFeeErrorType,
3
+ type GetBlobBaseFeeParameters,
4
+ type GetBlobBaseFeeReturnType,
5
+ getBlobBaseFee,
6
+ } from '../actions/getBlobBaseFee.js'
7
+ import type { Config } from '../createConfig.js'
8
+ import type { ScopeKeyParameter } from '../types/properties.js'
9
+ import type { QueryOptions, QueryParameter } from '../types/query.js'
10
+ import type { Compute, ExactPartial } from '../types/utils.js'
11
+ import { filterQueryOptions } from './utils.js'
12
+
13
+ export type GetBlobBaseFeeOptions<
14
+ config extends Config,
15
+ chainId extends config['chains'][number]['id'],
16
+ selectData = GetBlobBaseFeeData,
17
+ > = Compute<
18
+ ExactPartial<GetBlobBaseFeeParameters<config, chainId>> & ScopeKeyParameter
19
+ > &
20
+ QueryParameter<
21
+ GetBlobBaseFeeQueryFnData,
22
+ GetBlobBaseFeeErrorType,
23
+ selectData,
24
+ GetBlobBaseFeeQueryKey<config, chainId>
25
+ >
26
+
27
+ export function getBlobBaseFeeQueryOptions<
28
+ config extends Config,
29
+ chainId extends config['chains'][number]['id'],
30
+ selectData = GetBlobBaseFeeData,
31
+ >(
32
+ config: config,
33
+ options: GetBlobBaseFeeOptions<config, chainId, selectData> = {},
34
+ ): GetBlobBaseFeeQueryOptions<config, chainId, selectData> {
35
+ return {
36
+ ...options.query,
37
+ queryFn: async (context) => {
38
+ const [, { scopeKey: _, ...parameters }] = context.queryKey
39
+ const blobBaseFee = await getBlobBaseFee(config, parameters)
40
+ return blobBaseFee ?? null
41
+ },
42
+ queryKey: getBlobBaseFeeQueryKey(options),
43
+ }
44
+ }
45
+
46
+ export type GetBlobBaseFeeQueryFnData = GetBlobBaseFeeReturnType
47
+
48
+ export type GetBlobBaseFeeData = GetBlobBaseFeeQueryFnData
49
+
50
+ export function getBlobBaseFeeQueryKey<
51
+ config extends Config,
52
+ chainId extends config['chains'][number]['id'],
53
+ >(
54
+ options: Compute<
55
+ ExactPartial<GetBlobBaseFeeParameters<config, chainId>> & ScopeKeyParameter
56
+ > = {},
57
+ ) {
58
+ return ['blobBaseFee', filterQueryOptions(options)] as const
59
+ }
60
+
61
+ export type GetBlobBaseFeeQueryKey<
62
+ config extends Config,
63
+ chainId extends config['chains'][number]['id'],
64
+ > = ReturnType<typeof getBlobBaseFeeQueryKey<config, chainId>>
65
+
66
+ export type GetBlobBaseFeeQueryOptions<
67
+ config extends Config,
68
+ chainId extends config['chains'][number]['id'],
69
+ selectData = GetBlobBaseFeeData,
70
+ > = QueryOptions<
71
+ GetBlobBaseFeeQueryFnData,
72
+ GetBlobBaseFeeErrorType,
73
+ selectData,
74
+ GetBlobBaseFeeQueryKey<config, chainId>
75
+ >
@@ -0,0 +1,214 @@
1
+ import type { Abi, BlockNumber, BlockTag, ContractEventName } from 'viem'
2
+ import {
3
+ type GetContractEventsErrorType,
4
+ type GetContractEventsParameters,
5
+ type GetContractEventsReturnType,
6
+ getContractEvents,
7
+ } from '../actions/getContractEvents.js'
8
+ import type { Config } from '../createConfig.js'
9
+ import type { ScopeKeyParameter } from '../types/properties.js'
10
+ import type { QueryOptions, QueryParameter } from '../types/query.js'
11
+ import type { UnionExactPartial } from '../types/utils.js'
12
+ import { filterQueryOptions, structuralSharing } from './utils.js'
13
+
14
+ export type GetContractEventsOptions<
15
+ abi extends Abi | readonly unknown[],
16
+ eventName extends ContractEventName<abi> | undefined,
17
+ strict extends boolean | undefined,
18
+ fromBlock extends BlockNumber | BlockTag | undefined,
19
+ toBlock extends BlockNumber | BlockTag | undefined,
20
+ config extends Config,
21
+ chainId extends config['chains'][number]['id'],
22
+ selectData = GetContractEventsData<
23
+ abi,
24
+ eventName,
25
+ strict,
26
+ fromBlock,
27
+ toBlock
28
+ >,
29
+ > = UnionExactPartial<
30
+ GetContractEventsParameters<
31
+ abi,
32
+ eventName,
33
+ strict,
34
+ fromBlock,
35
+ toBlock,
36
+ config,
37
+ chainId
38
+ >
39
+ > &
40
+ ScopeKeyParameter &
41
+ QueryParameter<
42
+ GetContractEventsQueryFnData<abi, eventName, strict, fromBlock, toBlock>,
43
+ GetContractEventsErrorType,
44
+ selectData,
45
+ GetContractEventsQueryKey<
46
+ config,
47
+ chainId,
48
+ abi,
49
+ eventName,
50
+ strict,
51
+ fromBlock,
52
+ toBlock
53
+ >
54
+ >
55
+
56
+ export function getContractEventsQueryOptions<
57
+ config extends Config,
58
+ chainId extends config['chains'][number]['id'],
59
+ const abi extends Abi | readonly unknown[],
60
+ eventName extends ContractEventName<abi> | undefined,
61
+ strict extends boolean | undefined = undefined,
62
+ fromBlock extends BlockNumber | BlockTag | undefined = undefined,
63
+ toBlock extends BlockNumber | BlockTag | undefined = undefined,
64
+ selectData = GetContractEventsData<
65
+ abi,
66
+ eventName,
67
+ strict,
68
+ fromBlock,
69
+ toBlock
70
+ >,
71
+ >(
72
+ config: config,
73
+ options: GetContractEventsOptions<
74
+ abi,
75
+ eventName,
76
+ strict,
77
+ fromBlock,
78
+ toBlock,
79
+ config,
80
+ chainId,
81
+ selectData
82
+ > = {} as any,
83
+ ): GetContractEventsQueryOptions<
84
+ abi,
85
+ eventName,
86
+ strict,
87
+ fromBlock,
88
+ toBlock,
89
+ config,
90
+ chainId,
91
+ selectData
92
+ > {
93
+ return {
94
+ ...options.query,
95
+ enabled: Boolean(options.abi && (options.query?.enabled ?? true)),
96
+ queryFn: async (context) => {
97
+ if (!options.abi) throw new Error('abi is required')
98
+ const [, { scopeKey: _, ...parameters }] = context.queryKey
99
+ const result = await getContractEvents(config, {
100
+ ...(parameters as any),
101
+ abi: options.abi,
102
+ })
103
+ return result as GetContractEventsData<
104
+ abi,
105
+ eventName,
106
+ strict,
107
+ fromBlock,
108
+ toBlock
109
+ >
110
+ },
111
+ queryKey: getContractEventsQueryKey(options as any) as any,
112
+ structuralSharing,
113
+ } as GetContractEventsQueryOptions<
114
+ abi,
115
+ eventName,
116
+ strict,
117
+ fromBlock,
118
+ toBlock,
119
+ config,
120
+ chainId,
121
+ selectData
122
+ >
123
+ }
124
+
125
+ export type GetContractEventsQueryFnData<
126
+ abi extends Abi | readonly unknown[],
127
+ eventName extends ContractEventName<abi> | undefined,
128
+ strict extends boolean | undefined,
129
+ fromBlock extends BlockNumber | BlockTag | undefined,
130
+ toBlock extends BlockNumber | BlockTag | undefined,
131
+ > = GetContractEventsReturnType<abi, eventName, strict, fromBlock, toBlock>
132
+
133
+ export type GetContractEventsData<
134
+ abi extends Abi | readonly unknown[],
135
+ eventName extends ContractEventName<abi> | undefined,
136
+ strict extends boolean | undefined,
137
+ fromBlock extends BlockNumber | BlockTag | undefined,
138
+ toBlock extends BlockNumber | BlockTag | undefined,
139
+ > = GetContractEventsQueryFnData<abi, eventName, strict, fromBlock, toBlock>
140
+
141
+ export function getContractEventsQueryKey<
142
+ config extends Config,
143
+ chainId extends config['chains'][number]['id'],
144
+ const abi extends Abi | readonly unknown[],
145
+ eventName extends ContractEventName<abi> | undefined,
146
+ strict extends boolean | undefined = undefined,
147
+ fromBlock extends BlockNumber | BlockTag | undefined = undefined,
148
+ toBlock extends BlockNumber | BlockTag | undefined = undefined,
149
+ >(
150
+ options: UnionExactPartial<
151
+ GetContractEventsParameters<
152
+ abi,
153
+ eventName,
154
+ strict,
155
+ fromBlock,
156
+ toBlock,
157
+ config,
158
+ chainId
159
+ >
160
+ > &
161
+ ScopeKeyParameter = {} as any,
162
+ ) {
163
+ return ['getContractEvents', filterQueryOptions(options)] as const
164
+ }
165
+
166
+ export type GetContractEventsQueryKey<
167
+ config extends Config,
168
+ chainId extends config['chains'][number]['id'],
169
+ abi extends Abi | readonly unknown[],
170
+ eventName extends ContractEventName<abi> | undefined,
171
+ strict extends boolean | undefined,
172
+ fromBlock extends BlockNumber | BlockTag | undefined,
173
+ toBlock extends BlockNumber | BlockTag | undefined,
174
+ > = ReturnType<
175
+ typeof getContractEventsQueryKey<
176
+ config,
177
+ chainId,
178
+ abi,
179
+ eventName,
180
+ strict,
181
+ fromBlock,
182
+ toBlock
183
+ >
184
+ >
185
+
186
+ export type GetContractEventsQueryOptions<
187
+ abi extends Abi | readonly unknown[],
188
+ eventName extends ContractEventName<abi> | undefined,
189
+ strict extends boolean | undefined,
190
+ fromBlock extends BlockNumber | BlockTag | undefined,
191
+ toBlock extends BlockNumber | BlockTag | undefined,
192
+ config extends Config,
193
+ chainId extends config['chains'][number]['id'],
194
+ selectData = GetContractEventsData<
195
+ abi,
196
+ eventName,
197
+ strict,
198
+ fromBlock,
199
+ toBlock
200
+ >,
201
+ > = QueryOptions<
202
+ GetContractEventsQueryFnData<abi, eventName, strict, fromBlock, toBlock>,
203
+ GetContractEventsErrorType,
204
+ selectData,
205
+ GetContractEventsQueryKey<
206
+ config,
207
+ chainId,
208
+ abi,
209
+ eventName,
210
+ strict,
211
+ fromBlock,
212
+ toBlock
213
+ >
214
+ >
@@ -92,14 +92,24 @@ export function readContractsQueryKey<
92
92
  ChainIdParameter<config> = {},
93
93
  ) {
94
94
  const contracts = []
95
+ let hasContractWithoutChainId = false
95
96
  for (const contract of (options.contracts ??
96
97
  []) as (ContractFunctionParameters & { chainId: number })[]) {
97
98
  const { abi: _, ...rest } = contract
98
- contracts.push({ ...rest, chainId: rest.chainId ?? options.chainId })
99
+ if (rest.chainId === undefined) hasContractWithoutChainId = true
100
+ const chainId = rest.chainId ?? options.chainId
101
+ contracts.push({ ...rest, ...(chainId ? { chainId } : {}) })
99
102
  }
103
+ const { chainId: _, ...rest } = options
100
104
  return [
101
105
  'readContracts',
102
- filterQueryOptions({ ...options, contracts }),
106
+ filterQueryOptions({
107
+ ...rest,
108
+ ...(hasContractWithoutChainId && options.chainId
109
+ ? { chainId: options.chainId }
110
+ : {}),
111
+ contracts,
112
+ }),
103
113
  ] as const
104
114
  }
105
115
 
@@ -1,5 +1,4 @@
1
1
  import type { MutationOptions } from '@tanstack/query-core'
2
-
3
2
  import {
4
3
  type ReconnectErrorType,
5
4
  type ReconnectParameters,
@@ -7,22 +6,36 @@ import {
7
6
  reconnect,
8
7
  } from '../actions/reconnect.js'
9
8
  import type { Config } from '../createConfig.js'
9
+ import type { MutationParameter } from '../types/query.js'
10
10
  import type { Compute } from '../types/utils.js'
11
11
  import type { Mutate, MutateAsync } from './types.js'
12
12
 
13
- export function reconnectMutationOptions(config: Config) {
13
+ export type ReconnectOptions<context = unknown> = MutationParameter<
14
+ ReconnectData,
15
+ ReconnectErrorType,
16
+ ReconnectVariables,
17
+ context
18
+ >
19
+
20
+ export function reconnectMutationOptions<context>(
21
+ config: Config,
22
+ options: ReconnectOptions<context> = {},
23
+ ): ReconnectMutationOptions {
14
24
  return {
25
+ ...(options.mutation as any),
15
26
  mutationFn(variables) {
16
27
  return reconnect(config, variables)
17
28
  },
18
29
  mutationKey: ['reconnect'],
19
- } as const satisfies MutationOptions<
20
- ReconnectData,
21
- ReconnectErrorType,
22
- ReconnectVariables
23
- >
30
+ }
24
31
  }
25
32
 
33
+ export type ReconnectMutationOptions = MutationOptions<
34
+ ReconnectData,
35
+ ReconnectErrorType,
36
+ ReconnectVariables
37
+ >
38
+
26
39
  export type ReconnectData = Compute<ReconnectReturnType>
27
40
 
28
41
  export type ReconnectVariables = ReconnectParameters | undefined
@@ -1,5 +1,4 @@
1
1
  import type { MutateOptions, MutationOptions } from '@tanstack/query-core'
2
-
3
2
  import {
4
3
  type SendCallsErrorType,
5
4
  type SendCallsParameters,
@@ -7,23 +6,38 @@ import {
7
6
  sendCalls,
8
7
  } from '../actions/sendCalls.js'
9
8
  import type { Config } from '../createConfig.js'
9
+ import type { MutationParameter } from '../types/query.js'
10
10
  import type { Compute } from '../types/utils.js'
11
11
 
12
- export function sendCallsMutationOptions<config extends Config>(
12
+ export type SendCallsOptions<
13
+ config extends Config,
14
+ context = unknown,
15
+ > = MutationParameter<
16
+ SendCallsData,
17
+ SendCallsErrorType,
18
+ SendCallsVariables<config, config['chains'][number]['id']>,
19
+ context
20
+ >
21
+
22
+ export function sendCallsMutationOptions<config extends Config, context>(
13
23
  config: config,
14
- ) {
24
+ options: SendCallsOptions<config, context> = {},
25
+ ): SendCallsMutationOptions<config> {
15
26
  return {
27
+ ...(options.mutation as any),
16
28
  mutationFn(variables) {
17
29
  return sendCalls(config, variables)
18
30
  },
19
31
  mutationKey: ['sendCalls'],
20
- } as const satisfies MutationOptions<
21
- SendCallsData,
22
- SendCallsErrorType,
23
- SendCallsVariables<config, config['chains'][number]['id']>
24
- >
32
+ }
25
33
  }
26
34
 
35
+ export type SendCallsMutationOptions<config extends Config> = MutationOptions<
36
+ SendCallsData,
37
+ SendCallsErrorType,
38
+ SendCallsVariables<config, config['chains'][number]['id']>
39
+ >
40
+
27
41
  export type SendCallsData = Compute<SendCallsReturnType>
28
42
 
29
43
  export type SendCallsVariables<
@@ -1,5 +1,4 @@
1
1
  import type { MutateOptions, MutationOptions } from '@tanstack/query-core'
2
-
3
2
  import {
4
3
  type SendCallsSyncErrorType,
5
4
  type SendCallsSyncParameters,
@@ -7,22 +6,38 @@ import {
7
6
  sendCallsSync,
8
7
  } from '../actions/sendCallsSync.js'
9
8
  import type { Config } from '../createConfig.js'
9
+ import type { MutationParameter } from '../types/query.js'
10
10
  import type { Compute } from '../types/utils.js'
11
11
 
12
- export function sendCallsSyncMutationOptions<config extends Config>(
12
+ export type SendCallsSyncOptions<
13
+ config extends Config,
14
+ context = unknown,
15
+ > = MutationParameter<
16
+ SendCallsSyncData,
17
+ SendCallsSyncErrorType,
18
+ SendCallsSyncVariables<config, config['chains'][number]['id']>,
19
+ context
20
+ >
21
+
22
+ export function sendCallsSyncMutationOptions<config extends Config, context>(
13
23
  config: config,
14
- ) {
24
+ options: SendCallsSyncOptions<config, context> = {},
25
+ ): SendCallsSyncMutationOptions<config> {
15
26
  return {
27
+ ...(options.mutation as any),
16
28
  mutationFn(variables) {
17
29
  return sendCallsSync(config, variables)
18
30
  },
19
31
  mutationKey: ['sendCallsSync'],
20
- } as const satisfies MutationOptions<
32
+ }
33
+ }
34
+
35
+ export type SendCallsSyncMutationOptions<config extends Config> =
36
+ MutationOptions<
21
37
  SendCallsSyncData,
22
38
  SendCallsSyncErrorType,
23
39
  SendCallsSyncVariables<config, config['chains'][number]['id']>
24
40
  >
25
- }
26
41
 
27
42
  export type SendCallsSyncData = Compute<SendCallsSyncReturnType>
28
43
 
@@ -1,5 +1,4 @@
1
1
  import type { MutateOptions, MutationOptions } from '@tanstack/query-core'
2
-
3
2
  import {
4
3
  type SendTransactionErrorType,
5
4
  type SendTransactionParameters,
@@ -7,22 +6,38 @@ import {
7
6
  sendTransaction,
8
7
  } from '../actions/sendTransaction.js'
9
8
  import type { Config } from '../createConfig.js'
9
+ import type { MutationParameter } from '../types/query.js'
10
10
  import type { Compute } from '../types/utils.js'
11
11
 
12
- export function sendTransactionMutationOptions<config extends Config>(
12
+ export type SendTransactionOptions<
13
+ config extends Config,
14
+ context = unknown,
15
+ > = MutationParameter<
16
+ SendTransactionData,
17
+ SendTransactionErrorType,
18
+ SendTransactionVariables<config, config['chains'][number]['id']>,
19
+ context
20
+ >
21
+
22
+ export function sendTransactionMutationOptions<config extends Config, context>(
13
23
  config: config,
14
- ) {
24
+ options: SendTransactionOptions<config, context> = {},
25
+ ): SendTransactionMutationOptions<config> {
15
26
  return {
27
+ ...(options.mutation as any),
16
28
  mutationFn(variables) {
17
29
  return sendTransaction(config, variables)
18
30
  },
19
31
  mutationKey: ['sendTransaction'],
20
- } as const satisfies MutationOptions<
32
+ }
33
+ }
34
+
35
+ export type SendTransactionMutationOptions<config extends Config> =
36
+ MutationOptions<
21
37
  SendTransactionData,
22
38
  SendTransactionErrorType,
23
39
  SendTransactionVariables<config, config['chains'][number]['id']>
24
40
  >
25
- }
26
41
 
27
42
  export type SendTransactionData = Compute<SendTransactionReturnType>
28
43
 
@@ -1,5 +1,4 @@
1
1
  import type { MutateOptions, MutationOptions } from '@tanstack/query-core'
2
-
3
2
  import {
4
3
  type SendTransactionSyncErrorType,
5
4
  type SendTransactionSyncParameters,
@@ -7,22 +6,41 @@ import {
7
6
  sendTransactionSync,
8
7
  } from '../actions/sendTransactionSync.js'
9
8
  import type { Config } from '../createConfig.js'
9
+ import type { MutationParameter } from '../types/query.js'
10
10
  import type { Compute } from '../types/utils.js'
11
11
 
12
- export function sendTransactionSyncMutationOptions<config extends Config>(
12
+ export type SendTransactionSyncOptions<
13
+ config extends Config,
14
+ context = unknown,
15
+ > = MutationParameter<
16
+ SendTransactionSyncData,
17
+ SendTransactionSyncErrorType,
18
+ SendTransactionSyncVariables<config, config['chains'][number]['id']>,
19
+ context
20
+ >
21
+
22
+ export function sendTransactionSyncMutationOptions<
23
+ config extends Config,
24
+ context,
25
+ >(
13
26
  config: config,
14
- ) {
27
+ options: SendTransactionSyncOptions<config, context> = {},
28
+ ): SendTransactionSyncMutationOptions<config> {
15
29
  return {
30
+ ...(options.mutation as any),
16
31
  mutationFn(variables) {
17
32
  return sendTransactionSync(config, variables)
18
33
  },
19
34
  mutationKey: ['sendTransactionSync'],
20
- } as const satisfies MutationOptions<
35
+ }
36
+ }
37
+
38
+ export type SendTransactionSyncMutationOptions<config extends Config> =
39
+ MutationOptions<
21
40
  SendTransactionSyncData,
22
41
  SendTransactionSyncErrorType,
23
42
  SendTransactionSyncVariables<config, config['chains'][number]['id']>
24
43
  >
25
- }
26
44
 
27
45
  export type SendTransactionSyncData = Compute<SendTransactionSyncReturnType>
28
46