@wagmi/core 2.0.0-alpha.0 → 2.0.0-alpha.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 (74) hide show
  1. package/README.md +13 -0
  2. package/actions/package.json +5 -0
  3. package/chains/package.json +5 -0
  4. package/dist/esm/actions/getBlock.js +9 -0
  5. package/dist/esm/actions/getBlock.js.map +1 -0
  6. package/dist/esm/actions/getBlockNumber.js.map +1 -1
  7. package/dist/esm/actions/signTypedData.js.map +1 -1
  8. package/dist/esm/actions/watchBlocks.js +28 -0
  9. package/dist/esm/actions/watchBlocks.js.map +1 -0
  10. package/dist/esm/actions/writeContract.js.map +1 -1
  11. package/dist/esm/exports/index.js +2 -0
  12. package/dist/esm/exports/index.js.map +1 -1
  13. package/dist/esm/exports/internal.js.map +1 -1
  14. package/dist/esm/exports/query.js +1 -0
  15. package/dist/esm/exports/query.js.map +1 -1
  16. package/dist/esm/query/getBlock.js +17 -0
  17. package/dist/esm/query/getBlock.js.map +1 -0
  18. package/dist/esm/query/getBlockNumber.js.map +1 -1
  19. package/dist/esm/query/getConnectorClient.js +1 -0
  20. package/dist/esm/query/getConnectorClient.js.map +1 -1
  21. package/dist/esm/query/getWalletClient.js +1 -0
  22. package/dist/esm/query/getWalletClient.js.map +1 -1
  23. package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
  24. package/dist/esm/version.js +1 -1
  25. package/dist/types/actions/getBlock.d.ts +14 -0
  26. package/dist/types/actions/getBlock.d.ts.map +1 -0
  27. package/dist/types/actions/getBlockNumber.d.ts +2 -2
  28. package/dist/types/actions/getBlockNumber.d.ts.map +1 -1
  29. package/dist/types/actions/signTypedData.d.ts +1 -1
  30. package/dist/types/actions/signTypedData.d.ts.map +1 -1
  31. package/dist/types/actions/watchBlocks.d.ts +13 -0
  32. package/dist/types/actions/watchBlocks.d.ts.map +1 -0
  33. package/dist/types/actions/writeContract.d.ts +2 -2
  34. package/dist/types/actions/writeContract.d.ts.map +1 -1
  35. package/dist/types/exports/index.d.ts +2 -0
  36. package/dist/types/exports/index.d.ts.map +1 -1
  37. package/dist/types/exports/internal.d.ts +1 -1
  38. package/dist/types/exports/internal.d.ts.map +1 -1
  39. package/dist/types/exports/query.d.ts +1 -0
  40. package/dist/types/exports/query.d.ts.map +1 -1
  41. package/dist/types/query/getBlock.d.ts +111 -0
  42. package/dist/types/query/getBlock.d.ts.map +1 -0
  43. package/dist/types/query/getBlockNumber.d.ts +7 -7
  44. package/dist/types/query/getBlockNumber.d.ts.map +1 -1
  45. package/dist/types/query/getConnectorClient.d.ts +1 -0
  46. package/dist/types/query/getConnectorClient.d.ts.map +1 -1
  47. package/dist/types/query/getWalletClient.d.ts +1 -0
  48. package/dist/types/query/getWalletClient.d.ts.map +1 -1
  49. package/dist/types/query/signTypedData.d.ts +4 -4
  50. package/dist/types/query/signTypedData.d.ts.map +1 -1
  51. package/dist/types/query/writeContract.d.ts +4 -4
  52. package/dist/types/query/writeContract.d.ts.map +1 -1
  53. package/dist/types/types/utils.d.ts +9 -0
  54. package/dist/types/types/utils.d.ts.map +1 -1
  55. package/dist/types/version.d.ts +1 -1
  56. package/internal/package.json +5 -0
  57. package/package.json +10 -6
  58. package/query/package.json +5 -0
  59. package/src/actions/getBlock.ts +63 -0
  60. package/src/actions/getBlockNumber.ts +9 -5
  61. package/src/actions/signTypedData.ts +8 -1
  62. package/src/actions/watchBlocks.ts +90 -0
  63. package/src/actions/writeContract.ts +3 -1
  64. package/src/exports/index.ts +13 -0
  65. package/src/exports/internal.ts +1 -0
  66. package/src/exports/query.ts +9 -0
  67. package/src/query/getBlock.ts +80 -0
  68. package/src/query/getBlockNumber.ts +18 -13
  69. package/src/query/getConnectorClient.ts +1 -0
  70. package/src/query/getWalletClient.ts +1 -0
  71. package/src/query/signTypedData.ts +15 -3
  72. package/src/query/writeContract.ts +28 -3
  73. package/src/types/utils.ts +8 -0
  74. package/src/version.ts +1 -1
@@ -0,0 +1,5 @@
1
+ {
2
+ "type": "module",
3
+ "types": "../dist/types/exports/query.d.ts",
4
+ "main": "../dist/esm/exports/query.js"
5
+ }
@@ -0,0 +1,63 @@
1
+ import type { BlockTag, Chain } from 'viem'
2
+ import {
3
+ type GetBlockParameters as viem_GetBlockParameters,
4
+ type GetBlockReturnType as viem_GetBlockReturnType,
5
+ getBlock as viem_getBlock,
6
+ } from 'viem/actions'
7
+
8
+ import { type Config } from '../createConfig.js'
9
+ import type { SelectChains } from '../types/chain.js'
10
+ import type { ChainIdParameter } from '../types/properties.js'
11
+ import type { Evaluate } from '../types/utils.js'
12
+
13
+ export type GetBlockParameters<
14
+ includeTransactions extends boolean = false,
15
+ blockTag extends BlockTag = 'latest',
16
+ config extends Config = Config,
17
+ chainId extends
18
+ | config['chains'][number]['id'] = config['chains'][number]['id'],
19
+ > = Evaluate<
20
+ viem_GetBlockParameters<includeTransactions, blockTag> &
21
+ ChainIdParameter<config, chainId>
22
+ >
23
+
24
+ export type GetBlockReturnType<
25
+ includeTransactions extends boolean = false,
26
+ blockTag extends BlockTag = 'latest',
27
+ config extends Config = Config,
28
+ chainId extends config['chains'][number]['id'] = config['chains'][number]['id'],
29
+ ///
30
+ chains extends readonly Chain[] = SelectChains<config, chainId>,
31
+ > = Evaluate<
32
+ {
33
+ [key in keyof chains]: viem_GetBlockReturnType<
34
+ chains[key],
35
+ includeTransactions,
36
+ blockTag
37
+ >
38
+ }[number]
39
+ >
40
+
41
+ export type GetBlockError = Error
42
+
43
+ /** https://alpha.wagmi.sh/core/actions/getBlock */
44
+ export function getBlock<
45
+ config extends Config,
46
+ chainId extends config['chains'][number]['id'],
47
+ includeTransactions extends boolean = false,
48
+ blockTag extends BlockTag = 'latest',
49
+ >(
50
+ config: config,
51
+ parameters: GetBlockParameters<
52
+ includeTransactions,
53
+ blockTag,
54
+ config,
55
+ chainId
56
+ > = {},
57
+ ): Promise<GetBlockReturnType<includeTransactions, blockTag, config, chainId>> {
58
+ const { chainId } = parameters
59
+ const client = config.getClient({ chainId })
60
+ return viem_getBlock(client, parameters) as {} as Promise<
61
+ GetBlockReturnType<includeTransactions, blockTag, config, chainId>
62
+ >
63
+ }
@@ -8,18 +8,22 @@ import { type Config } from '../createConfig.js'
8
8
  import type { ChainIdParameter } from '../types/properties.js'
9
9
  import type { Evaluate } from '../types/utils.js'
10
10
 
11
- export type GetBlockNumberParameters<config extends Config = Config> = Evaluate<
12
- viem_GetBlockNumberParameters & ChainIdParameter<config>
13
- >
11
+ export type GetBlockNumberParameters<
12
+ config extends Config = Config,
13
+ chainId extends config['chains'][number]['id'] = config['chains'][number]['id'],
14
+ > = Evaluate<viem_GetBlockNumberParameters & ChainIdParameter<config, chainId>>
14
15
 
15
16
  export type GetBlockNumberReturnType = viem_GetBlockNumberReturnType
16
17
 
17
18
  export type GetBlockNumberError = Error
18
19
 
19
20
  /** https://alpha.wagmi.sh/core/api/actions/getBlockNumber */
20
- export function getBlockNumber<config extends Config>(
21
+ export function getBlockNumber<
22
+ config extends Config,
23
+ chainId extends config['chains'][number]['id'] = config['chains'][number]['id'],
24
+ >(
21
25
  config: config,
22
- parameters: GetBlockNumberParameters<config> = {},
26
+ parameters: GetBlockNumberParameters<config, chainId> = {},
23
27
  ): Promise<GetBlockNumberReturnType> {
24
28
  const { chainId } = parameters
25
29
  const client = config.getClient({ chainId })
@@ -12,7 +12,14 @@ import { getConnectorClient } from './getConnectorClient.js'
12
12
  export type SignTypedDataParameters<
13
13
  typedData extends TypedData | Record<string, unknown> = TypedData,
14
14
  primaryType extends keyof typedData | 'EIP712Domain' = keyof typedData,
15
- > = viem_SignTypedDataParameters<typedData, primaryType, Account> &
15
+ ///
16
+ primaryTypes = typedData extends TypedData ? keyof typedData : string,
17
+ > = viem_SignTypedDataParameters<
18
+ typedData,
19
+ primaryType,
20
+ Account,
21
+ primaryTypes
22
+ > &
16
23
  ConnectorParameter
17
24
 
18
25
  export type SignTypedDataReturnType = viem_SignTypedDataReturnType
@@ -0,0 +1,90 @@
1
+ import {
2
+ type WatchBlocksParameters as viem_WatchBlocksParameters,
3
+ type WatchBlocksReturnType as viem_WatchBlocksReturnType,
4
+ watchBlocks as viem_watchBlocks,
5
+ } from 'viem/actions'
6
+
7
+ import type { BlockTag, Chain, Transport, WebSocketTransport } from 'viem'
8
+ import { type Config } from '../createConfig.js'
9
+ import type { SelectChains } from '../types/chain.js'
10
+ import type {
11
+ ChainIdParameter,
12
+ SyncConnectedChainParameter,
13
+ } from '../types/properties.js'
14
+ import type { UnionEvaluate } from '../types/utils.js'
15
+
16
+ export type WatchBlocksParameters<
17
+ includeTransactions extends boolean = false,
18
+ blockTag extends BlockTag = 'latest',
19
+ config extends Config = Config,
20
+ chainId extends config['chains'][number]['id'] = config['chains'][number]['id'],
21
+ ///
22
+ chains extends readonly Chain[] = SelectChains<config, chainId>,
23
+ > = {
24
+ [key in keyof chains]: UnionEvaluate<
25
+ viem_WatchBlocksParameters<
26
+ config['_internal']['transports'][chains[key]['id']] extends infer transport extends Transport
27
+ ? Transport extends transport
28
+ ? WebSocketTransport
29
+ : transport
30
+ : WebSocketTransport,
31
+ chains[key],
32
+ includeTransactions,
33
+ blockTag
34
+ > &
35
+ ChainIdParameter<config, chainId> &
36
+ SyncConnectedChainParameter
37
+ >
38
+ }[number]
39
+
40
+ export type WatchBlocksReturnType = viem_WatchBlocksReturnType
41
+
42
+ // TODO: wrap in viem's `observe` to avoid duplicate invocations.
43
+ /** https://alpha.wagmi.sh/core/actions/watchBlocks */
44
+ export function watchBlocks<
45
+ config extends Config,
46
+ chainId extends config['chains'][number]['id'] = config['chains'][number]['id'],
47
+ includeTransactions extends boolean = false,
48
+ blockTag extends BlockTag = 'latest',
49
+ >(
50
+ config: config,
51
+ parameters: WatchBlocksParameters<
52
+ includeTransactions,
53
+ blockTag,
54
+ config,
55
+ chainId
56
+ >,
57
+ ): WatchBlocksReturnType {
58
+ const { syncConnectedChain = config._internal.syncConnectedChain, ...rest } =
59
+ parameters
60
+
61
+ let unwatch: WatchBlocksReturnType | undefined
62
+ const listener = (chainId: number | undefined) => {
63
+ if (unwatch) unwatch()
64
+
65
+ const client = config.getClient({ chainId })
66
+ unwatch = viem_watchBlocks(
67
+ client,
68
+ rest as unknown as viem_WatchBlocksParameters,
69
+ )
70
+ return unwatch
71
+ }
72
+
73
+ // set up listener for block number changes
74
+ const unlisten = listener(parameters.chainId)
75
+
76
+ // set up subscriber for connected chain changes
77
+ let unsubscribe: (() => void) | undefined
78
+ if (syncConnectedChain && !parameters.chainId)
79
+ unsubscribe = config.subscribe(
80
+ ({ chainId }) => chainId,
81
+ async (chainId) => {
82
+ return listener(chainId)
83
+ },
84
+ )
85
+
86
+ return () => {
87
+ unlisten?.()
88
+ unsubscribe?.()
89
+ }
90
+ }
@@ -37,6 +37,7 @@ export type WriteContractParameters<
37
37
  config extends Config = Config,
38
38
  chainId extends config['chains'][number]['id'] = config['chains'][number]['id'],
39
39
  ///
40
+ allFunctionNames = ContractFunctionName<abi, 'nonpayable' | 'payable'>,
40
41
  chains extends readonly Chain[] = SelectChains<config, chainId>,
41
42
  > = {
42
43
  [key in keyof chains]: UnionOmit<
@@ -46,7 +47,8 @@ export type WriteContractParameters<
46
47
  args,
47
48
  chains[key],
48
49
  Account,
49
- chains[key]
50
+ chains[key],
51
+ allFunctionNames
50
52
  >,
51
53
  'chain'
52
54
  >
@@ -52,6 +52,13 @@ export {
52
52
  getBalance,
53
53
  } from '../actions/getBalance.js'
54
54
 
55
+ export {
56
+ type GetBlockError,
57
+ type GetBlockParameters,
58
+ type GetBlockReturnType,
59
+ getBlock,
60
+ } from '../actions/getBlock.js'
61
+
55
62
  export {
56
63
  type GetBlockNumberError,
57
64
  type GetBlockNumberParameters,
@@ -212,6 +219,12 @@ export {
212
219
  watchAccount,
213
220
  } from '../actions/watchAccount.js'
214
221
 
222
+ export {
223
+ type WatchBlocksParameters,
224
+ type WatchBlocksReturnType,
225
+ watchBlocks,
226
+ } from '../actions/watchBlocks.js'
227
+
215
228
  export {
216
229
  type WatchBlockNumberParameters,
217
230
  type WatchBlockNumberReturnType,
@@ -17,6 +17,7 @@ export {
17
17
  type Omit,
18
18
  type OneOf,
19
19
  type UnionEvaluate,
20
+ type UnionOmit,
20
21
  type UnionPartial,
21
22
  } from '../types/utils.js'
22
23
 
@@ -44,6 +44,15 @@ export {
44
44
  getBalanceQueryOptions,
45
45
  } from '../query/getBalance.js'
46
46
 
47
+ export {
48
+ type GetBlockData,
49
+ type GetBlockOptions,
50
+ type GetBlockQueryFnData,
51
+ type GetBlockQueryKey,
52
+ getBlockQueryKey,
53
+ getBlockQueryOptions,
54
+ } from '../query/getBlock.js'
55
+
47
56
  export {
48
57
  type GetBlockNumberData,
49
58
  type GetBlockNumberOptions,
@@ -0,0 +1,80 @@
1
+ import { type QueryOptions } from '@tanstack/query-core'
2
+ import type { BlockTag } from 'viem'
3
+
4
+ import {
5
+ type GetBlockError,
6
+ type GetBlockParameters,
7
+ type GetBlockReturnType,
8
+ getBlock,
9
+ } from '../actions/getBlock.js'
10
+ import type { Config } from '../createConfig.js'
11
+ import type { Evaluate, ExactPartial } from '../types/utils.js'
12
+ import type { ScopeKeyParameter } from './types.js'
13
+ import { filterQueryOptions } from './utils.js'
14
+
15
+ export type GetBlockOptions<
16
+ includeTransactions extends boolean,
17
+ blockTag extends BlockTag,
18
+ config extends Config,
19
+ chainId extends
20
+ | config['chains'][number]['id'] = config['chains'][number]['id'],
21
+ > = Evaluate<
22
+ ExactPartial<
23
+ GetBlockParameters<includeTransactions, blockTag, config, chainId>
24
+ > &
25
+ ScopeKeyParameter
26
+ >
27
+
28
+ export function getBlockQueryOptions<
29
+ config extends Config,
30
+ chainId extends config['chains'][number]['id'],
31
+ includeTransactions extends boolean = false,
32
+ blockTag extends BlockTag = 'latest',
33
+ >(
34
+ config: config,
35
+ options: GetBlockOptions<includeTransactions, blockTag, config, chainId> = {},
36
+ ) {
37
+ return {
38
+ async queryFn({ queryKey }) {
39
+ const { scopeKey: _, ...parameters } = queryKey[1]
40
+ const block = await getBlock(config, parameters)
41
+ return block ?? null
42
+ },
43
+ queryKey: getBlockQueryKey(options),
44
+ } as const satisfies QueryOptions<
45
+ GetBlockQueryFnData,
46
+ GetBlockError,
47
+ GetBlockData,
48
+ GetBlockQueryKey<includeTransactions, blockTag, config, chainId>
49
+ >
50
+ }
51
+
52
+ export type GetBlockQueryFnData<
53
+ includeTransactions extends boolean = false,
54
+ blockTag extends BlockTag = 'latest',
55
+ > = GetBlockReturnType<includeTransactions, blockTag>
56
+
57
+ export type GetBlockData<
58
+ includeTransactions extends boolean = false,
59
+ blockTag extends BlockTag = 'latest',
60
+ > = GetBlockQueryFnData<includeTransactions, blockTag>
61
+
62
+ export function getBlockQueryKey<
63
+ config extends Config,
64
+ chainId extends config['chains'][number]['id'],
65
+ includeTransactions extends boolean = false,
66
+ blockTag extends BlockTag = 'latest',
67
+ >(
68
+ options: GetBlockOptions<includeTransactions, blockTag, config, chainId> = {},
69
+ ) {
70
+ return ['block', filterQueryOptions(options)] as const
71
+ }
72
+
73
+ export type GetBlockQueryKey<
74
+ includeTransactions extends boolean,
75
+ blockTag extends BlockTag,
76
+ config extends Config,
77
+ chainId extends config['chains'][number]['id'],
78
+ > = ReturnType<
79
+ typeof getBlockQueryKey<config, chainId, includeTransactions, blockTag>
80
+ >
@@ -11,14 +11,17 @@ import type { Evaluate, ExactPartial } from '../types/utils.js'
11
11
  import type { ScopeKeyParameter } from './types.js'
12
12
  import { filterQueryOptions } from './utils.js'
13
13
 
14
- export type GetBlockNumberOptions<config extends Config> = Evaluate<
15
- ExactPartial<GetBlockNumberParameters<config>> & ScopeKeyParameter
14
+ export type GetBlockNumberOptions<
15
+ config extends Config,
16
+ chainId extends config['chains'][number]['id'],
17
+ > = Evaluate<
18
+ ExactPartial<GetBlockNumberParameters<config, chainId>> & ScopeKeyParameter
16
19
  >
17
20
 
18
- export function getBlockNumberQueryOptions<config extends Config>(
19
- config: config,
20
- options: GetBlockNumberOptions<config> = {},
21
- ) {
21
+ export function getBlockNumberQueryOptions<
22
+ config extends Config,
23
+ chainId extends config['chains'][number]['id'],
24
+ >(config: config, options: GetBlockNumberOptions<config, chainId> = {}) {
22
25
  return {
23
26
  gcTime: 0,
24
27
  async queryFn({ queryKey }) {
@@ -31,7 +34,7 @@ export function getBlockNumberQueryOptions<config extends Config>(
31
34
  GetBlockNumberQueryFnData,
32
35
  GetBlockNumberError,
33
36
  GetBlockNumberData,
34
- GetBlockNumberQueryKey<config>
37
+ GetBlockNumberQueryKey<config, chainId>
35
38
  >
36
39
  }
37
40
 
@@ -39,12 +42,14 @@ export type GetBlockNumberQueryFnData = GetBlockNumberReturnType
39
42
 
40
43
  export type GetBlockNumberData = GetBlockNumberQueryFnData
41
44
 
42
- export function getBlockNumberQueryKey<config extends Config>(
43
- options: GetBlockNumberOptions<config> = {},
44
- ) {
45
+ export function getBlockNumberQueryKey<
46
+ config extends Config,
47
+ chainId extends config['chains'][number]['id'],
48
+ >(options: GetBlockNumberOptions<config, chainId> = {}) {
45
49
  return ['blockNumber', filterQueryOptions(options)] as const
46
50
  }
47
51
 
48
- export type GetBlockNumberQueryKey<config extends Config> = ReturnType<
49
- typeof getBlockNumberQueryKey<config>
50
- >
52
+ export type GetBlockNumberQueryKey<
53
+ config extends Config,
54
+ chainId extends config['chains'][number]['id'],
55
+ > = ReturnType<typeof getBlockNumberQueryKey<config, chainId>>
@@ -24,6 +24,7 @@ export function getConnectorClientQueryOptions<
24
24
  chainId extends config['chains'][number]['id'],
25
25
  >(config: config, options: GetConnectorClientOptions<config, chainId> = {}) {
26
26
  return {
27
+ gcTime: 0,
27
28
  async queryFn({ queryKey }) {
28
29
  const { connector } = options
29
30
  const { connectorUid: _, scopeKey: _s, ...parameters } = queryKey[1]
@@ -23,6 +23,7 @@ export function getWalletClientQueryOptions<
23
23
  chainId extends config['chains'][number]['id'],
24
24
  >(config: config, options: GetWalletClientOptions<config, chainId> = {}) {
25
25
  return {
26
+ gcTime: 0,
26
27
  async queryFn({ queryKey }) {
27
28
  const { connector } = options
28
29
  const { connectorUid: _, scopeKey: _s, ...parameters } = queryKey[1]
@@ -30,7 +30,9 @@ export type SignTypedDataData = Evaluate<SignTypedDataReturnType>
30
30
  export type SignTypedDataVariables<
31
31
  typedData extends TypedData | Record<string, unknown> = TypedData,
32
32
  primaryType extends keyof typedData | 'EIP712Domain' = keyof typedData,
33
- > = SignTypedDataParameters<typedData, primaryType>
33
+ ///
34
+ primaryTypes = typedData extends TypedData ? keyof typedData : string,
35
+ > = SignTypedDataParameters<typedData, primaryType, primaryTypes>
34
36
 
35
37
  export type SignTypedDataMutate<context = unknown> = <
36
38
  const typedData extends TypedData | Record<string, unknown>,
@@ -41,7 +43,12 @@ export type SignTypedDataMutate<context = unknown> = <
41
43
  | MutateOptions<
42
44
  SignTypedDataData,
43
45
  SignTypedDataError,
44
- SignTypedDataVariables<typedData, primaryType>,
46
+ SignTypedDataVariables<
47
+ typedData,
48
+ primaryType,
49
+ // use `primaryType` to make sure it's not union of all possible primary types
50
+ primaryType
51
+ >,
45
52
  context
46
53
  >
47
54
  | undefined,
@@ -56,7 +63,12 @@ export type SignTypedDataMutateAsync<context = unknown> = <
56
63
  | MutateOptions<
57
64
  SignTypedDataData,
58
65
  SignTypedDataError,
59
- SignTypedDataVariables<typedData, primaryType>,
66
+ SignTypedDataVariables<
67
+ typedData,
68
+ primaryType,
69
+ // use `primaryType` to make sure it's not union of all possible primary types
70
+ primaryType
71
+ >,
60
72
  context
61
73
  >
62
74
  | undefined,
@@ -43,7 +43,16 @@ export type WriteContractVariables<
43
43
  >,
44
44
  config extends Config,
45
45
  chainId extends config['chains'][number]['id'],
46
- > = WriteContractParameters<abi, functionName, args, config, chainId>
46
+ ///
47
+ allFunctionNames = ContractFunctionName<abi, 'nonpayable' | 'payable'>,
48
+ > = WriteContractParameters<
49
+ abi,
50
+ functionName,
51
+ args,
52
+ config,
53
+ chainId,
54
+ allFunctionNames
55
+ >
47
56
 
48
57
  export type WriteContractMutate<config extends Config, context = unknown> = <
49
58
  const abi extends Abi | readonly unknown[],
@@ -60,7 +69,15 @@ export type WriteContractMutate<config extends Config, context = unknown> = <
60
69
  | MutateOptions<
61
70
  WriteContractData,
62
71
  WriteContractError,
63
- WriteContractVariables<abi, functionName, args, config, chainId>,
72
+ WriteContractVariables<
73
+ abi,
74
+ functionName,
75
+ args,
76
+ config,
77
+ chainId,
78
+ // use `functionName` to make sure it's not union of all possible function names
79
+ functionName
80
+ >,
64
81
  context
65
82
  >
66
83
  | undefined,
@@ -84,7 +101,15 @@ export type WriteContractMutateAsync<
84
101
  | MutateOptions<
85
102
  WriteContractData,
86
103
  WriteContractError,
87
- WriteContractVariables<abi, functionName, args, config, chainId>,
104
+ WriteContractVariables<
105
+ abi,
106
+ functionName,
107
+ args,
108
+ config,
109
+ chainId,
110
+ // use `functionName` to make sure it's not union of all possible function names
111
+ functionName
112
+ >,
88
113
  context
89
114
  >
90
115
  | undefined,
@@ -37,6 +37,14 @@ export type Mutable<type extends object> = {
37
37
  -readonly [key in keyof type]: type[key]
38
38
  }
39
39
 
40
+ /**
41
+ * Use to prevent a usage of type from being inferred in other generics.
42
+
43
+ * @see https://github.com/pelotom/type-zoo/#noinfert
44
+ * @see https://github.com/Microsoft/TypeScript/issues/14829#issuecomment-322267089
45
+ */
46
+ export type NoInfer<type> = type & { [key in keyof type]: type[key] }
47
+
40
48
  /** Strict version of built-in Omit type */
41
49
  export type Omit<type, keys extends keyof type> = Pick<
42
50
  type,
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '2.0.0-alpha.0'
1
+ export const version = '2.0.0-alpha.1'