@wagmi/core 2.1.2 → 2.2.0

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 (70) hide show
  1. package/dist/esm/actions/getBytecode.js +11 -0
  2. package/dist/esm/actions/getBytecode.js.map +1 -0
  3. package/dist/esm/actions/getProof.js +11 -0
  4. package/dist/esm/actions/getProof.js.map +1 -0
  5. package/dist/esm/actions/getStorageAt.js +11 -0
  6. package/dist/esm/actions/getStorageAt.js.map +1 -0
  7. package/dist/esm/actions/getTransactionReceipt.js +12 -0
  8. package/dist/esm/actions/getTransactionReceipt.js.map +1 -0
  9. package/dist/esm/exports/actions.js +4 -0
  10. package/dist/esm/exports/actions.js.map +1 -1
  11. package/dist/esm/exports/index.js +4 -0
  12. package/dist/esm/exports/index.js.map +1 -1
  13. package/dist/esm/exports/query.js +4 -0
  14. package/dist/esm/exports/query.js.map +1 -1
  15. package/dist/esm/query/getBytecode.js +22 -0
  16. package/dist/esm/query/getBytecode.js.map +1 -0
  17. package/dist/esm/query/getProof.js +21 -0
  18. package/dist/esm/query/getProof.js.map +1 -0
  19. package/dist/esm/query/getStorageAt.js +19 -0
  20. package/dist/esm/query/getStorageAt.js.map +1 -0
  21. package/dist/esm/query/getTransactionReceipt.js +22 -0
  22. package/dist/esm/query/getTransactionReceipt.js.map +1 -0
  23. package/dist/esm/query/verifyTypedData.js +1 -1
  24. package/dist/esm/query/verifyTypedData.js.map +1 -1
  25. package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
  26. package/dist/esm/version.js +1 -1
  27. package/dist/types/actions/getBytecode.d.ts +10 -0
  28. package/dist/types/actions/getBytecode.d.ts.map +1 -0
  29. package/dist/types/actions/getProof.d.ts +10 -0
  30. package/dist/types/actions/getProof.d.ts.map +1 -0
  31. package/dist/types/actions/getStorageAt.d.ts +10 -0
  32. package/dist/types/actions/getStorageAt.d.ts.map +1 -0
  33. package/dist/types/actions/getTransactionReceipt.d.ts +16 -0
  34. package/dist/types/actions/getTransactionReceipt.d.ts.map +1 -0
  35. package/dist/types/exports/actions.d.ts +4 -0
  36. package/dist/types/exports/actions.d.ts.map +1 -1
  37. package/dist/types/exports/index.d.ts +4 -0
  38. package/dist/types/exports/index.d.ts.map +1 -1
  39. package/dist/types/exports/query.d.ts +4 -0
  40. package/dist/types/exports/query.d.ts.map +1 -1
  41. package/dist/types/query/call.d.ts +2 -2
  42. package/dist/types/query/call.d.ts.map +1 -1
  43. package/dist/types/query/getBytecode.d.ts +18 -0
  44. package/dist/types/query/getBytecode.d.ts.map +1 -0
  45. package/dist/types/query/getProof.d.ts +18 -0
  46. package/dist/types/query/getProof.d.ts.map +1 -0
  47. package/dist/types/query/getStorageAt.d.ts +18 -0
  48. package/dist/types/query/getStorageAt.d.ts.map +1 -0
  49. package/dist/types/query/getTransactionReceipt.d.ts +35 -0
  50. package/dist/types/query/getTransactionReceipt.d.ts.map +1 -0
  51. package/dist/types/query/verifyMessage.d.ts +3 -3
  52. package/dist/types/query/verifyMessage.d.ts.map +1 -1
  53. package/dist/types/query/verifyTypedData.d.ts.map +1 -1
  54. package/dist/types/version.d.ts +1 -1
  55. package/package.json +1 -1
  56. package/src/actions/getBytecode.ts +28 -0
  57. package/src/actions/getProof.ts +28 -0
  58. package/src/actions/getStorageAt.ts +28 -0
  59. package/src/actions/getTransactionReceipt.ts +47 -0
  60. package/src/exports/actions.ts +28 -0
  61. package/src/exports/index.ts +28 -0
  62. package/src/exports/query.ts +36 -0
  63. package/src/query/call.ts +4 -2
  64. package/src/query/getBytecode.ts +49 -0
  65. package/src/query/getProof.ts +50 -0
  66. package/src/query/getStorageAt.ts +49 -0
  67. package/src/query/getTransactionReceipt.ts +60 -0
  68. package/src/query/verifyMessage.ts +4 -2
  69. package/src/query/verifyTypedData.ts +2 -1
  70. package/src/version.ts +1 -1
@@ -81,6 +81,13 @@ export {
81
81
  getBlockTransactionCount,
82
82
  } from '../actions/getBlockTransactionCount.js'
83
83
 
84
+ export {
85
+ type GetBytecodeErrorType,
86
+ type GetBytecodeParameters,
87
+ type GetBytecodeReturnType,
88
+ getBytecode,
89
+ } from '../actions/getBytecode.js'
90
+
84
91
  export {
85
92
  type GetChainIdReturnType,
86
93
  getChainId,
@@ -159,12 +166,26 @@ export {
159
166
  getGasPrice,
160
167
  } from '../actions/getGasPrice.js'
161
168
 
169
+ export {
170
+ type GetProofErrorType,
171
+ type GetProofParameters,
172
+ type GetProofReturnType,
173
+ getProof,
174
+ } from '../actions/getProof.js'
175
+
162
176
  export {
163
177
  type GetPublicClientParameters,
164
178
  type GetPublicClientReturnType,
165
179
  getPublicClient,
166
180
  } from '../actions/getPublicClient.js'
167
181
 
182
+ export {
183
+ type GetStorageAtErrorType,
184
+ type GetStorageAtParameters,
185
+ type GetStorageAtReturnType,
186
+ getStorageAt,
187
+ } from '../actions/getStorageAt.js'
188
+
168
189
  export {
169
190
  type GetTokenErrorType,
170
191
  type GetTokenParameters,
@@ -190,6 +211,13 @@ export {
190
211
  getTransactionCount,
191
212
  } from '../actions/getTransactionCount.js'
192
213
 
214
+ export {
215
+ type GetTransactionReceiptErrorType,
216
+ type GetTransactionReceiptParameters,
217
+ type GetTransactionReceiptReturnType,
218
+ getTransactionReceipt,
219
+ } from '../actions/getTransactionReceipt.js'
220
+
193
221
  export {
194
222
  type GetWalletClientErrorType,
195
223
  type GetWalletClientParameters,
@@ -81,6 +81,13 @@ export {
81
81
  getBlockTransactionCount,
82
82
  } from '../actions/getBlockTransactionCount.js'
83
83
 
84
+ export {
85
+ type GetBytecodeErrorType,
86
+ type GetBytecodeParameters,
87
+ type GetBytecodeReturnType,
88
+ getBytecode,
89
+ } from '../actions/getBytecode.js'
90
+
84
91
  export {
85
92
  type GetChainIdReturnType,
86
93
  getChainId,
@@ -159,12 +166,26 @@ export {
159
166
  getGasPrice,
160
167
  } from '../actions/getGasPrice.js'
161
168
 
169
+ export {
170
+ type GetProofErrorType,
171
+ type GetProofParameters,
172
+ type GetProofReturnType,
173
+ getProof,
174
+ } from '../actions/getProof.js'
175
+
162
176
  export {
163
177
  type GetPublicClientParameters,
164
178
  type GetPublicClientReturnType,
165
179
  getPublicClient,
166
180
  } from '../actions/getPublicClient.js'
167
181
 
182
+ export {
183
+ type GetStorageAtErrorType,
184
+ type GetStorageAtParameters,
185
+ type GetStorageAtReturnType,
186
+ getStorageAt,
187
+ } from '../actions/getStorageAt.js'
188
+
168
189
  export {
169
190
  type GetTokenErrorType,
170
191
  type GetTokenParameters,
@@ -190,6 +211,13 @@ export {
190
211
  getTransactionCount,
191
212
  } from '../actions/getTransactionCount.js'
192
213
 
214
+ export {
215
+ type GetTransactionReceiptErrorType,
216
+ type GetTransactionReceiptParameters,
217
+ type GetTransactionReceiptReturnType,
218
+ getTransactionReceipt,
219
+ } from '../actions/getTransactionReceipt.js'
220
+
193
221
  export {
194
222
  type GetWalletClientErrorType,
195
223
  type GetWalletClientParameters,
@@ -90,6 +90,15 @@ export {
90
90
  getBlockTransactionCountQueryOptions,
91
91
  } from '../query/getBlockTransactionCount.js'
92
92
 
93
+ export {
94
+ type GetBytecodeData,
95
+ type GetBytecodeOptions,
96
+ type GetBytecodeQueryFnData,
97
+ type GetBytecodeQueryKey,
98
+ getBytecodeQueryKey,
99
+ getBytecodeQueryOptions,
100
+ } from '../query/getBytecode.js'
101
+
93
102
  export {
94
103
  type GetConnectorClientData,
95
104
  type GetConnectorClientOptions,
@@ -153,6 +162,24 @@ export {
153
162
  getGasPriceQueryOptions,
154
163
  } from '../query/getGasPrice.js'
155
164
 
165
+ export {
166
+ type GetProofData,
167
+ type GetProofOptions,
168
+ type GetProofQueryFnData,
169
+ type GetProofQueryKey,
170
+ getProofQueryKey,
171
+ getProofQueryOptions,
172
+ } from '../query/getProof.js'
173
+
174
+ export {
175
+ type GetStorageAtData,
176
+ type GetStorageAtOptions,
177
+ type GetStorageAtQueryFnData,
178
+ type GetStorageAtQueryKey,
179
+ getStorageAtQueryKey,
180
+ getStorageAtQueryOptions,
181
+ } from '../query/getStorageAt.js'
182
+
156
183
  export {
157
184
  type GetTokenData,
158
185
  type GetTokenOptions,
@@ -180,6 +207,15 @@ export {
180
207
  getTransactionCountQueryOptions,
181
208
  } from '../query/getTransactionCount.js'
182
209
 
210
+ export {
211
+ type GetTransactionReceiptData,
212
+ type GetTransactionReceiptOptions,
213
+ type GetTransactionReceiptQueryFnData,
214
+ type GetTransactionReceiptQueryKey,
215
+ getTransactionReceiptQueryKey,
216
+ getTransactionReceiptQueryOptions,
217
+ } from '../query/getTransactionReceipt.js'
218
+
183
219
  export {
184
220
  type GetWalletClientData,
185
221
  type GetWalletClientOptions,
package/src/query/call.ts CHANGED
@@ -32,7 +32,7 @@ export function callQueryOptions<config extends Config>(
32
32
  CallQueryFnData,
33
33
  CallErrorType,
34
34
  CallData,
35
- CallQueryKey
35
+ CallQueryKey<config>
36
36
  >
37
37
  }
38
38
 
@@ -46,4 +46,6 @@ export function callQueryKey<config extends Config>(
46
46
  return ['call', filterQueryOptions(options)] as const
47
47
  }
48
48
 
49
- export type CallQueryKey = ReturnType<typeof callQueryKey>
49
+ export type CallQueryKey<config extends Config> = ReturnType<
50
+ typeof callQueryKey<config>
51
+ >
@@ -0,0 +1,49 @@
1
+ import { type QueryOptions } from '@tanstack/query-core'
2
+
3
+ import {
4
+ type GetBytecodeErrorType,
5
+ type GetBytecodeParameters,
6
+ type GetBytecodeReturnType,
7
+ getBytecode,
8
+ } from '../actions/getBytecode.js'
9
+ import { type Config } from '../createConfig.js'
10
+ import { type ScopeKeyParameter } from '../types/properties.js'
11
+ import { type Evaluate, type ExactPartial } from '../types/utils.js'
12
+ import { filterQueryOptions } from './utils.js'
13
+
14
+ export type GetBytecodeOptions<config extends Config> = Evaluate<
15
+ ExactPartial<GetBytecodeParameters<config>> & ScopeKeyParameter
16
+ >
17
+
18
+ export function getBytecodeQueryOptions<config extends Config>(
19
+ config: config,
20
+ options: GetBytecodeOptions<config> = {},
21
+ ) {
22
+ return {
23
+ async queryFn({ queryKey }) {
24
+ const { address, scopeKey: _, ...parameters } = queryKey[1]
25
+ if (!address) throw new Error('address is required')
26
+ const bytecode = await getBytecode(config, { ...parameters, address })
27
+ return (bytecode ?? null) as any
28
+ },
29
+ queryKey: getBytecodeQueryKey(options),
30
+ } as const satisfies QueryOptions<
31
+ GetBytecodeQueryFnData,
32
+ GetBytecodeErrorType,
33
+ GetBytecodeData,
34
+ GetBytecodeQueryKey<config>
35
+ >
36
+ }
37
+ export type GetBytecodeQueryFnData = GetBytecodeReturnType
38
+
39
+ export type GetBytecodeData = GetBytecodeQueryFnData
40
+
41
+ export function getBytecodeQueryKey<config extends Config>(
42
+ options: GetBytecodeOptions<config>,
43
+ ) {
44
+ return ['getBytecode', filterQueryOptions(options)] as const
45
+ }
46
+
47
+ export type GetBytecodeQueryKey<config extends Config> = ReturnType<
48
+ typeof getBytecodeQueryKey<config>
49
+ >
@@ -0,0 +1,50 @@
1
+ import { type QueryOptions } from '@tanstack/query-core'
2
+
3
+ import {
4
+ type GetProofErrorType,
5
+ type GetProofParameters,
6
+ type GetProofReturnType,
7
+ getProof,
8
+ } from '../actions/getProof.js'
9
+ import { type Config } from '../createConfig.js'
10
+ import { type ScopeKeyParameter } from '../types/properties.js'
11
+ import { type Evaluate, type ExactPartial } from '../types/utils.js'
12
+ import { filterQueryOptions } from './utils.js'
13
+
14
+ export type GetProofOptions<config extends Config> = Evaluate<
15
+ ExactPartial<GetProofParameters<config>> & ScopeKeyParameter
16
+ >
17
+
18
+ export function getProofQueryOptions<config extends Config>(
19
+ config: config,
20
+ options: GetProofOptions<config> = {},
21
+ ) {
22
+ return {
23
+ async queryFn({ queryKey }) {
24
+ const { address, scopeKey: _, storageKeys, ...parameters } = queryKey[1]
25
+ if (!address || !storageKeys)
26
+ throw new Error('address and storageKeys are required')
27
+ return getProof(config, { ...parameters, address, storageKeys })
28
+ },
29
+ queryKey: getProofQueryKey(options),
30
+ } as const satisfies QueryOptions<
31
+ GetProofQueryFnData,
32
+ GetProofErrorType,
33
+ GetProofData,
34
+ GetProofQueryKey<config>
35
+ >
36
+ }
37
+
38
+ export type GetProofQueryFnData = GetProofReturnType
39
+
40
+ export type GetProofData = GetProofQueryFnData
41
+
42
+ export function getProofQueryKey<config extends Config>(
43
+ options: GetProofOptions<config>,
44
+ ) {
45
+ return ['getProof', filterQueryOptions(options)] as const
46
+ }
47
+
48
+ export type GetProofQueryKey<config extends Config> = ReturnType<
49
+ typeof getProofQueryKey<config>
50
+ >
@@ -0,0 +1,49 @@
1
+ import { type QueryOptions } from '@tanstack/query-core'
2
+
3
+ import {
4
+ type GetStorageAtErrorType,
5
+ type GetStorageAtParameters,
6
+ type GetStorageAtReturnType,
7
+ getStorageAt,
8
+ } from '../actions/getStorageAt.js'
9
+ import { type Config } from '../createConfig.js'
10
+ import type { ScopeKeyParameter } from '../types/properties.js'
11
+ import type { Evaluate, ExactPartial } from '../types/utils.js'
12
+ import { filterQueryOptions } from './utils.js'
13
+
14
+ export type GetStorageAtOptions<config extends Config> = Evaluate<
15
+ ExactPartial<GetStorageAtParameters<config>> & ScopeKeyParameter
16
+ >
17
+
18
+ export function getStorageAtQueryOptions<config extends Config>(
19
+ config: config,
20
+ options: GetStorageAtOptions<config> = {},
21
+ ) {
22
+ return {
23
+ queryFn({ queryKey }) {
24
+ const { address, slot, scopeKey: _, ...parameters } = queryKey[1]
25
+ if (!address || !slot) throw new Error('address and slot are required')
26
+ return getStorageAt(config, { ...parameters, address, slot })
27
+ },
28
+ queryKey: getStorageAtQueryKey(options),
29
+ } as const satisfies QueryOptions<
30
+ GetStorageAtQueryFnData,
31
+ GetStorageAtErrorType,
32
+ GetStorageAtData,
33
+ GetStorageAtQueryKey<config>
34
+ >
35
+ }
36
+
37
+ export type GetStorageAtQueryFnData = GetStorageAtReturnType
38
+
39
+ export type GetStorageAtData = GetStorageAtQueryFnData
40
+
41
+ export function getStorageAtQueryKey<config extends Config>(
42
+ options: GetStorageAtOptions<config>,
43
+ ) {
44
+ return ['getStorageAt', filterQueryOptions(options)] as const
45
+ }
46
+
47
+ export type GetStorageAtQueryKey<config extends Config> = ReturnType<
48
+ typeof getStorageAtQueryKey<config>
49
+ >
@@ -0,0 +1,60 @@
1
+ import { type QueryOptions } from '@tanstack/query-core'
2
+
3
+ import {
4
+ type GetTransactionReceiptErrorType,
5
+ type GetTransactionReceiptParameters,
6
+ getTransactionReceipt,
7
+ } from '../actions/getTransactionReceipt.js'
8
+ import { type GetTransactionReceiptReturnType } from '../actions/getTransactionReceipt.js'
9
+ import { type Config } from '../createConfig.js'
10
+ import { type ScopeKeyParameter } from '../types/properties.js'
11
+ import { type Evaluate, type ExactPartial } from '../types/utils.js'
12
+ import { filterQueryOptions } from './utils.js'
13
+
14
+ export type GetTransactionReceiptOptions<
15
+ config extends Config,
16
+ chainId extends config['chains'][number]['id'],
17
+ > = Evaluate<
18
+ ExactPartial<GetTransactionReceiptParameters<config, chainId>> &
19
+ ScopeKeyParameter
20
+ >
21
+
22
+ export function getTransactionReceiptQueryOptions<
23
+ config extends Config,
24
+ chainId extends config['chains'][number]['id'],
25
+ >(config: config, options: GetTransactionReceiptOptions<config, chainId> = {}) {
26
+ return {
27
+ queryFn({ queryKey }) {
28
+ const { hash, scopeKey: _, ...parameters } = queryKey[1]
29
+ if (!hash) throw new Error('hash is required')
30
+ return getTransactionReceipt(config, { ...parameters, hash })
31
+ },
32
+ queryKey: getTransactionReceiptQueryKey(options),
33
+ } as const satisfies QueryOptions<
34
+ GetTransactionReceiptQueryFnData<config, chainId>,
35
+ GetTransactionReceiptErrorType,
36
+ GetTransactionReceiptData<config, chainId>,
37
+ GetTransactionReceiptQueryKey<config, chainId>
38
+ >
39
+ }
40
+ export type GetTransactionReceiptQueryFnData<
41
+ config extends Config,
42
+ chainId extends config['chains'][number]['id'],
43
+ > = GetTransactionReceiptReturnType<config, chainId>
44
+
45
+ export type GetTransactionReceiptData<
46
+ config extends Config,
47
+ chainId extends config['chains'][number]['id'],
48
+ > = GetTransactionReceiptQueryFnData<config, chainId>
49
+
50
+ export function getTransactionReceiptQueryKey<
51
+ config extends Config,
52
+ chainId extends config['chains'][number]['id'],
53
+ >(options: GetTransactionReceiptOptions<config, chainId>) {
54
+ return ['getTransactionReceipt', filterQueryOptions(options)] as const
55
+ }
56
+
57
+ export type GetTransactionReceiptQueryKey<
58
+ config extends Config,
59
+ chainId extends config['chains'][number]['id'],
60
+ > = ReturnType<typeof getTransactionReceiptQueryKey<config, chainId>>
@@ -38,7 +38,7 @@ export function verifyMessageQueryOptions<config extends Config>(
38
38
  VerifyMessageQueryFnData,
39
39
  VerifyMessageErrorType,
40
40
  VerifyMessageData,
41
- VerifyMessageQueryKey
41
+ VerifyMessageQueryKey<config>
42
42
  >
43
43
  }
44
44
  export type VerifyMessageQueryFnData = VerifyMessageReturnType
@@ -51,4 +51,6 @@ export function verifyMessageQueryKey<config extends Config>(
51
51
  return ['verifyMessage', filterQueryOptions(options)] as const
52
52
  }
53
53
 
54
- export type VerifyMessageQueryKey = ReturnType<typeof verifyMessageQueryKey>
54
+ export type VerifyMessageQueryKey<config extends Config> = ReturnType<
55
+ typeof verifyMessageQueryKey<config>
56
+ >
@@ -45,12 +45,12 @@ export function verifyTypedDataQueryOptions<
45
45
  if (!types) throw new Error('types is required')
46
46
 
47
47
  const verified = await verifyTypedData(config, {
48
+ ...parameters,
48
49
  address,
49
50
  message,
50
51
  primaryType,
51
52
  signature,
52
53
  types,
53
- ...parameters,
54
54
  })
55
55
  return verified ?? null
56
56
  },
@@ -62,6 +62,7 @@ export function verifyTypedDataQueryOptions<
62
62
  VerifyTypedDataQueryKey<typedData, primaryType, config>
63
63
  >
64
64
  }
65
+
65
66
  export type VerifyTypedDataQueryFnData = VerifyTypedDataReturnType
66
67
 
67
68
  export type VerifyTypedDataData = VerifyTypedDataQueryFnData
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '2.1.2'
1
+ export const version = '2.2.0'