viem 0.0.0-main.20230814T205407 → 0.0.0-main.20230814T211804

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 (160) hide show
  1. package/dist/cjs/actions/getContract.js.map +1 -1
  2. package/dist/cjs/actions/public/multicall.js +6 -5
  3. package/dist/cjs/actions/public/multicall.js.map +1 -1
  4. package/dist/cjs/clients/decorators/public.js.map +1 -1
  5. package/dist/cjs/errors/version.js +1 -1
  6. package/dist/cjs/index.js.map +1 -1
  7. package/dist/cjs/utils/abi/decodeAbiParameters.js.map +1 -1
  8. package/dist/cjs/utils/abi/decodeDeployData.js.map +1 -1
  9. package/dist/cjs/utils/abi/decodeErrorResult.js.map +1 -1
  10. package/dist/cjs/utils/abi/decodeFunctionResult.js.map +1 -1
  11. package/dist/cjs/utils/abi/encodeAbiParameters.js.map +1 -1
  12. package/dist/cjs/utils/abi/encodeDeployData.js.map +1 -1
  13. package/dist/cjs/utils/abi/encodeEventTopics.js.map +1 -1
  14. package/dist/cjs/utils/abi/encodePacked.js.map +1 -1
  15. package/dist/cjs/utils/poll.js +1 -1
  16. package/dist/cjs/utils/poll.js.map +1 -1
  17. package/dist/cjs/utils/typedData.js +2 -2
  18. package/dist/cjs/utils/typedData.js.map +1 -1
  19. package/dist/esm/actions/getContract.js.map +1 -1
  20. package/dist/esm/actions/public/multicall.js +7 -5
  21. package/dist/esm/actions/public/multicall.js.map +1 -1
  22. package/dist/esm/clients/decorators/public.js.map +1 -1
  23. package/dist/esm/errors/version.js +1 -1
  24. package/dist/esm/index.js.map +1 -1
  25. package/dist/esm/utils/abi/decodeAbiParameters.js.map +1 -1
  26. package/dist/esm/utils/abi/decodeDeployData.js.map +1 -1
  27. package/dist/esm/utils/abi/decodeErrorResult.js.map +1 -1
  28. package/dist/esm/utils/abi/decodeFunctionResult.js.map +1 -1
  29. package/dist/esm/utils/abi/encodeAbiParameters.js.map +1 -1
  30. package/dist/esm/utils/abi/encodeDeployData.js.map +1 -1
  31. package/dist/esm/utils/abi/encodeEventTopics.js.map +1 -1
  32. package/dist/esm/utils/abi/encodePacked.js.map +1 -1
  33. package/dist/esm/utils/poll.js +1 -1
  34. package/dist/esm/utils/poll.js.map +1 -1
  35. package/dist/esm/utils/typedData.js +2 -2
  36. package/dist/esm/utils/typedData.js.map +1 -1
  37. package/dist/types/accounts/types.d.ts +1 -1
  38. package/dist/types/accounts/types.d.ts.map +1 -1
  39. package/dist/types/accounts/utils/signTypedData.d.ts +1 -1
  40. package/dist/types/accounts/utils/signTypedData.d.ts.map +1 -1
  41. package/dist/types/actions/getContract.d.ts +5 -5
  42. package/dist/types/actions/getContract.d.ts.map +1 -1
  43. package/dist/types/actions/public/createContractEventFilter.d.ts +3 -3
  44. package/dist/types/actions/public/createContractEventFilter.d.ts.map +1 -1
  45. package/dist/types/actions/public/createEventFilter.d.ts +5 -5
  46. package/dist/types/actions/public/createEventFilter.d.ts.map +1 -1
  47. package/dist/types/actions/public/estimateContractGas.d.ts +1 -1
  48. package/dist/types/actions/public/estimateContractGas.d.ts.map +1 -1
  49. package/dist/types/actions/public/getFilterChanges.d.ts +1 -1
  50. package/dist/types/actions/public/getFilterChanges.d.ts.map +1 -1
  51. package/dist/types/actions/public/getFilterLogs.d.ts +1 -1
  52. package/dist/types/actions/public/getFilterLogs.d.ts.map +1 -1
  53. package/dist/types/actions/public/getLogs.d.ts +4 -4
  54. package/dist/types/actions/public/getLogs.d.ts.map +1 -1
  55. package/dist/types/actions/public/multicall.d.ts +6 -6
  56. package/dist/types/actions/public/multicall.d.ts.map +1 -1
  57. package/dist/types/actions/public/readContract.d.ts +1 -1
  58. package/dist/types/actions/public/readContract.d.ts.map +1 -1
  59. package/dist/types/actions/public/simulateContract.d.ts +1 -1
  60. package/dist/types/actions/public/simulateContract.d.ts.map +1 -1
  61. package/dist/types/actions/public/watchContractEvent.d.ts +3 -3
  62. package/dist/types/actions/public/watchContractEvent.d.ts.map +1 -1
  63. package/dist/types/actions/public/watchEvent.d.ts +4 -4
  64. package/dist/types/actions/public/watchEvent.d.ts.map +1 -1
  65. package/dist/types/actions/wallet/deployContract.d.ts +3 -3
  66. package/dist/types/actions/wallet/deployContract.d.ts.map +1 -1
  67. package/dist/types/actions/wallet/signTypedData.d.ts +1 -1
  68. package/dist/types/actions/wallet/signTypedData.d.ts.map +1 -1
  69. package/dist/types/actions/wallet/writeContract.d.ts +1 -1
  70. package/dist/types/actions/wallet/writeContract.d.ts.map +1 -1
  71. package/dist/types/clients/decorators/public.d.ts +11 -11
  72. package/dist/types/clients/decorators/public.d.ts.map +1 -1
  73. package/dist/types/clients/decorators/wallet.d.ts +3 -3
  74. package/dist/types/clients/decorators/wallet.d.ts.map +1 -1
  75. package/dist/types/errors/version.d.ts +1 -1
  76. package/dist/types/index.d.ts +1 -1
  77. package/dist/types/index.d.ts.map +1 -1
  78. package/dist/types/types/contract.d.ts +2 -2
  79. package/dist/types/types/contract.d.ts.map +1 -1
  80. package/dist/types/types/multicall.d.ts +8 -8
  81. package/dist/types/types/multicall.d.ts.map +1 -1
  82. package/dist/types/types/typedData.d.ts +3 -3
  83. package/dist/types/types/typedData.d.ts.map +1 -1
  84. package/dist/types/utils/abi/decodeAbiParameters.d.ts +2 -2
  85. package/dist/types/utils/abi/decodeAbiParameters.d.ts.map +1 -1
  86. package/dist/types/utils/abi/decodeDeployData.d.ts +3 -3
  87. package/dist/types/utils/abi/decodeDeployData.d.ts.map +1 -1
  88. package/dist/types/utils/abi/decodeErrorResult.d.ts +3 -3
  89. package/dist/types/utils/abi/decodeErrorResult.d.ts.map +1 -1
  90. package/dist/types/utils/abi/decodeEventLog.d.ts +3 -3
  91. package/dist/types/utils/abi/decodeEventLog.d.ts.map +1 -1
  92. package/dist/types/utils/abi/decodeFunctionResult.d.ts +4 -4
  93. package/dist/types/utils/abi/decodeFunctionResult.d.ts.map +1 -1
  94. package/dist/types/utils/abi/encodeAbiParameters.d.ts +2 -2
  95. package/dist/types/utils/abi/encodeAbiParameters.d.ts.map +1 -1
  96. package/dist/types/utils/abi/encodeDeployData.d.ts +3 -3
  97. package/dist/types/utils/abi/encodeDeployData.d.ts.map +1 -1
  98. package/dist/types/utils/abi/encodeErrorResult.d.ts +4 -4
  99. package/dist/types/utils/abi/encodeErrorResult.d.ts.map +1 -1
  100. package/dist/types/utils/abi/encodeEventTopics.d.ts +4 -4
  101. package/dist/types/utils/abi/encodeEventTopics.d.ts.map +1 -1
  102. package/dist/types/utils/abi/encodeFunctionData.d.ts +4 -4
  103. package/dist/types/utils/abi/encodeFunctionData.d.ts.map +1 -1
  104. package/dist/types/utils/abi/encodeFunctionResult.d.ts +4 -4
  105. package/dist/types/utils/abi/encodeFunctionResult.d.ts.map +1 -1
  106. package/dist/types/utils/abi/encodePacked.d.ts +3 -3
  107. package/dist/types/utils/abi/encodePacked.d.ts.map +1 -1
  108. package/dist/types/utils/abi/getAbiItem.d.ts +3 -3
  109. package/dist/types/utils/abi/getAbiItem.d.ts.map +1 -1
  110. package/dist/types/utils/signature/hashTypedData.d.ts +1 -1
  111. package/dist/types/utils/signature/hashTypedData.d.ts.map +1 -1
  112. package/dist/types/utils/signature/recoverTypedDataAddress.d.ts +1 -1
  113. package/dist/types/utils/signature/recoverTypedDataAddress.d.ts.map +1 -1
  114. package/dist/types/utils/signature/verifyTypedData.d.ts +1 -1
  115. package/dist/types/utils/signature/verifyTypedData.d.ts.map +1 -1
  116. package/dist/types/utils/typedData.d.ts +1 -1
  117. package/dist/types/utils/typedData.d.ts.map +1 -1
  118. package/package.json +1 -1
  119. package/src/accounts/types.ts +1 -1
  120. package/src/accounts/utils/signTypedData.ts +1 -1
  121. package/src/actions/getContract.ts +5 -6
  122. package/src/actions/public/createContractEventFilter.ts +3 -3
  123. package/src/actions/public/createEventFilter.ts +6 -6
  124. package/src/actions/public/estimateContractGas.ts +1 -1
  125. package/src/actions/public/getFilterChanges.ts +1 -1
  126. package/src/actions/public/getFilterLogs.ts +1 -1
  127. package/src/actions/public/getLogs.ts +5 -5
  128. package/src/actions/public/multicall.ts +14 -17
  129. package/src/actions/public/readContract.ts +1 -1
  130. package/src/actions/public/simulateContract.ts +1 -1
  131. package/src/actions/public/watchContractEvent.ts +3 -3
  132. package/src/actions/public/watchEvent.ts +5 -5
  133. package/src/actions/wallet/deployContract.ts +3 -3
  134. package/src/actions/wallet/signTypedData.ts +1 -1
  135. package/src/actions/wallet/writeContract.ts +1 -1
  136. package/src/clients/decorators/public.ts +15 -20
  137. package/src/clients/decorators/wallet.ts +3 -3
  138. package/src/errors/version.ts +1 -1
  139. package/src/index.ts +0 -1
  140. package/src/types/contract.ts +2 -1
  141. package/src/types/multicall.ts +11 -14
  142. package/src/types/typedData.ts +3 -2
  143. package/src/utils/abi/decodeAbiParameters.ts +8 -7
  144. package/src/utils/abi/decodeDeployData.ts +3 -3
  145. package/src/utils/abi/decodeErrorResult.ts +8 -3
  146. package/src/utils/abi/decodeEventLog.ts +3 -3
  147. package/src/utils/abi/decodeFunctionResult.ts +6 -4
  148. package/src/utils/abi/encodeAbiParameters.ts +9 -8
  149. package/src/utils/abi/encodeDeployData.ts +3 -3
  150. package/src/utils/abi/encodeErrorResult.ts +4 -4
  151. package/src/utils/abi/encodeEventTopics.ts +9 -4
  152. package/src/utils/abi/encodeFunctionData.ts +4 -4
  153. package/src/utils/abi/encodeFunctionResult.ts +4 -4
  154. package/src/utils/abi/encodePacked.ts +8 -6
  155. package/src/utils/abi/getAbiItem.ts +3 -3
  156. package/src/utils/poll.ts +1 -1
  157. package/src/utils/signature/hashTypedData.ts +1 -1
  158. package/src/utils/signature/recoverTypedDataAddress.ts +1 -1
  159. package/src/utils/signature/verifyTypedData.ts +1 -1
  160. package/src/utils/typedData.ts +3 -2
@@ -138,7 +138,7 @@ export async function getFilterChanges<
138
138
  TTransport extends Transport,
139
139
  TChain extends Chain | undefined,
140
140
  TFilterType extends FilterType,
141
- const TAbi extends Abi | readonly unknown[] | undefined,
141
+ TAbi extends Abi | readonly unknown[] | undefined,
142
142
  TEventName extends string | undefined,
143
143
  TStrict extends boolean | undefined = undefined,
144
144
  TFromBlock extends BlockNumber | BlockTag | undefined = undefined,
@@ -67,7 +67,7 @@ export type GetFilterLogsReturnType<
67
67
  */
68
68
  export async function getFilterLogs<
69
69
  TChain extends Chain | undefined,
70
- const TAbi extends Abi | readonly unknown[] | undefined,
70
+ TAbi extends Abi | readonly unknown[] | undefined,
71
71
  TEventName extends string | undefined,
72
72
  TStrict extends boolean | undefined = undefined,
73
73
  TFromBlock extends BlockNumber | BlockTag | undefined = undefined,
@@ -1,4 +1,4 @@
1
- import type { Abi, AbiEvent, Address } from 'abitype'
1
+ import type { Abi, AbiEvent, Address, Narrow } from 'abitype'
2
2
 
3
3
  import type { Client } from '../../clients/createClient.js'
4
4
  import type { Transport } from '../../clients/transports/createTransport.js'
@@ -38,7 +38,7 @@ export type GetLogsParameters<
38
38
  address?: Address | Address[]
39
39
  } & (
40
40
  | {
41
- event: TAbiEvent
41
+ event: Narrow<TAbiEvent>
42
42
  events?: never
43
43
  args?: MaybeExtractEventArgsFromAbi<TAbiEvents, _EventName>
44
44
  /**
@@ -49,7 +49,7 @@ export type GetLogsParameters<
49
49
  }
50
50
  | {
51
51
  event?: never
52
- events: TAbiEvents
52
+ events: Narrow<TAbiEvents>
53
53
  args?: never
54
54
  /**
55
55
  * Whether or not the logs must match the indexed/non-indexed arguments on `event`.
@@ -119,8 +119,8 @@ export type GetLogsReturnType<
119
119
  */
120
120
  export async function getLogs<
121
121
  TChain extends Chain | undefined,
122
- const TAbiEvent extends AbiEvent | undefined = undefined,
123
- const TAbiEvents extends
122
+ TAbiEvent extends AbiEvent | undefined = undefined,
123
+ TAbiEvents extends
124
124
  | readonly AbiEvent[]
125
125
  | readonly unknown[]
126
126
  | undefined = TAbiEvent extends AbiEvent ? [TAbiEvent] : undefined,
@@ -1,4 +1,4 @@
1
- import type { Abi, Address } from 'abitype'
1
+ import type { Address, Narrow } from 'abitype'
2
2
 
3
3
  import type { Client } from '../../clients/createClient.js'
4
4
  import type { Transport } from '../../clients/transports/createTransport.js'
@@ -10,7 +10,6 @@ import type { Chain } from '../../types/chain.js'
10
10
  import type { ContractFunctionConfig } from '../../types/contract.js'
11
11
  import type { Hex } from '../../types/misc.js'
12
12
  import type {
13
- MulticallContract,
14
13
  MulticallContracts,
15
14
  MulticallResults,
16
15
  } from '../../types/multicall.js'
@@ -26,18 +25,18 @@ import type { CallParameters } from './call.js'
26
25
  import { readContract } from './readContract.js'
27
26
 
28
27
  export type MulticallParameters<
29
- TContracts extends readonly MulticallContract[] = readonly MulticallContract[],
28
+ TContracts extends ContractFunctionConfig[] = ContractFunctionConfig[],
30
29
  TAllowFailure extends boolean = true,
31
30
  > = Pick<CallParameters, 'blockNumber' | 'blockTag'> & {
32
31
  allowFailure?: TAllowFailure
33
32
  /** The maximum size (in bytes) for each calldata chunk. Set to `0` to disable the size limit. @default 1_024 */
34
33
  batchSize?: number
35
- contracts: readonly [...MulticallContracts<TContracts>]
34
+ contracts: Narrow<readonly [...MulticallContracts<TContracts>]>
36
35
  multicallAddress?: Address
37
36
  }
38
37
 
39
38
  export type MulticallReturnType<
40
- TContracts extends readonly MulticallContract[] = readonly MulticallContract[],
39
+ TContracts extends ContractFunctionConfig[] = ContractFunctionConfig[],
41
40
  TAllowFailure extends boolean = true,
42
41
  > = MulticallResults<TContracts, TAllowFailure>
43
42
 
@@ -81,13 +80,8 @@ export type MulticallReturnType<
81
80
  * // [{ result: 424122n, status: 'success' }, { result: 1000000n, status: 'success' }]
82
81
  */
83
82
  export async function multicall<
84
- const TAbi extends Abi | readonly unknown[],
85
- TFunctionName extends string,
86
- const TContracts extends readonly ContractFunctionConfig<
87
- TAbi,
88
- TFunctionName
89
- >[],
90
83
  TChain extends Chain | undefined,
84
+ TContracts extends ContractFunctionConfig[],
91
85
  TAllowFailure extends boolean = true,
92
86
  >(
93
87
  client: Client<Transport, TChain>,
@@ -98,7 +92,7 @@ export async function multicall<
98
92
  batchSize: batchSize_,
99
93
  blockNumber,
100
94
  blockTag,
101
- contracts,
95
+ contracts: contracts_,
102
96
  multicallAddress: multicallAddress_,
103
97
  } = args
104
98
 
@@ -108,6 +102,9 @@ export async function multicall<
108
102
  client.batch.multicall.batchSize) ||
109
103
  1_024)
110
104
 
105
+ // Fix type cast from `Narrow` in type definition.
106
+ const contracts = contracts_ as readonly [...MulticallContracts<TContracts>]
107
+
111
108
  let multicallAddress = multicallAddress_
112
109
  if (!multicallAddress) {
113
110
  if (!client.chain)
@@ -157,7 +154,7 @@ export async function multicall<
157
154
  ]
158
155
  } catch (err) {
159
156
  const error = getContractError(err as BaseError, {
160
- abi: abi as Abi,
157
+ abi,
161
158
  address,
162
159
  args,
163
160
  docsPath: '/docs/contract/multicall',
@@ -196,15 +193,15 @@ export async function multicall<
196
193
  if (callData === '0x') throw new AbiDecodingZeroDataError()
197
194
  if (!success) throw new RawContractError({ data: returnData })
198
195
  const result = decodeFunctionResult({
199
- abi: abi as Abi,
200
- args: args as readonly unknown[],
196
+ abi,
197
+ args,
201
198
  data: returnData,
202
- functionName: functionName as string,
199
+ functionName: functionName,
203
200
  })
204
201
  return allowFailure ? { result, status: 'success' } : result
205
202
  } catch (err) {
206
203
  const error = getContractError(err as BaseError, {
207
- abi: abi as Abi,
204
+ abi,
208
205
  address,
209
206
  args,
210
207
  docsPath: '/docs/contract/multicall',
@@ -64,7 +64,7 @@ export type ReadContractReturnType<
64
64
  */
65
65
  export async function readContract<
66
66
  TChain extends Chain | undefined,
67
- const TAbi extends Abi | readonly unknown[],
67
+ TAbi extends Abi | readonly unknown[],
68
68
  TFunctionName extends string,
69
69
  >(
70
70
  client: Client<Transport, TChain>,
@@ -102,7 +102,7 @@ export type SimulateContractReturnType<
102
102
  */
103
103
  export async function simulateContract<
104
104
  TChain extends Chain | undefined,
105
- const TAbi extends Abi | readonly unknown[],
105
+ TAbi extends Abi | readonly unknown[],
106
106
  TFunctionName extends string,
107
107
  TChainOverride extends Chain | undefined,
108
108
  >(
@@ -1,4 +1,4 @@
1
- import type { Abi, AbiEvent, Address, ExtractAbiEvent } from 'abitype'
1
+ import type { Abi, AbiEvent, Address, ExtractAbiEvent, Narrow } from 'abitype'
2
2
 
3
3
  import type { Client } from '../../clients/createClient.js'
4
4
  import type { Transport } from '../../clients/transports/createTransport.js'
@@ -68,7 +68,7 @@ export type WatchContractEventParameters<
68
68
  /** The address of the contract. */
69
69
  address?: Address | Address[]
70
70
  /** Contract ABI. */
71
- abi: TAbi
71
+ abi: Narrow<TAbi>
72
72
  args?: GetEventArgs<TAbi, TEventName>
73
73
  /** Contract event. */
74
74
  eventName?: InferEventName<TAbi, TEventName>
@@ -137,7 +137,7 @@ export type WatchContractEventReturnType = () => void
137
137
  */
138
138
  export function watchContractEvent<
139
139
  TChain extends Chain | undefined,
140
- const TAbi extends Abi | readonly unknown[],
140
+ TAbi extends Abi | readonly unknown[],
141
141
  TEventName extends string,
142
142
  TStrict extends boolean | undefined = undefined,
143
143
  >(
@@ -1,4 +1,4 @@
1
- import type { Abi, AbiEvent, Address } from 'abitype'
1
+ import type { Abi, AbiEvent, Address, Narrow } from 'abitype'
2
2
 
3
3
  import type { Client } from '../../clients/createClient.js'
4
4
  import type { Transport } from '../../clients/transports/createTransport.js'
@@ -107,7 +107,7 @@ export type WatchEventParameters<
107
107
  }) &
108
108
  (
109
109
  | {
110
- event: TAbiEvent
110
+ event: Narrow<TAbiEvent>
111
111
  events?: never
112
112
  args?: MaybeExtractEventArgsFromAbi<TAbiEvents, _EventName>
113
113
  /**
@@ -118,7 +118,7 @@ export type WatchEventParameters<
118
118
  }
119
119
  | {
120
120
  event?: never
121
- events?: TAbiEvents
121
+ events?: Narrow<TAbiEvents>
122
122
  args?: never
123
123
  /**
124
124
  * Whether or not the logs must match the indexed/non-indexed arguments on `event`.
@@ -170,8 +170,8 @@ export type WatchEventReturnType = () => void
170
170
  */
171
171
  export function watchEvent<
172
172
  TChain extends Chain | undefined,
173
- const TAbiEvent extends AbiEvent | undefined = undefined,
174
- const TAbiEvents extends
173
+ TAbiEvent extends AbiEvent | undefined = undefined,
174
+ TAbiEvents extends
175
175
  | readonly AbiEvent[]
176
176
  | readonly unknown[]
177
177
  | undefined = TAbiEvent extends AbiEvent ? [TAbiEvent] : undefined,
@@ -1,4 +1,4 @@
1
- import type { Abi } from 'abitype'
1
+ import type { Abi, Narrow } from 'abitype'
2
2
 
3
3
  import type { Account } from '../../accounts/types.js'
4
4
  import type { Client } from '../../clients/createClient.js'
@@ -24,7 +24,7 @@ export type DeployContractParameters<
24
24
  SendTransactionParameters<TChain, TAccount, TChainOverride>,
25
25
  'accessList' | 'chain' | 'to' | 'data'
26
26
  > & {
27
- abi: TAbi
27
+ abi: Narrow<TAbi>
28
28
  bytecode: Hex
29
29
  } & GetChain<TChain, TChainOverride> &
30
30
  GetConstructorArgs<TAbi>
@@ -59,7 +59,7 @@ export type DeployContractReturnType = SendTransactionReturnType
59
59
  * })
60
60
  */
61
61
  export function deployContract<
62
- const TAbi extends Abi | readonly unknown[],
62
+ TAbi extends Abi | readonly unknown[],
63
63
  TChain extends Chain | undefined,
64
64
  TAccount extends Account | undefined,
65
65
  TChainOverride extends Chain | undefined,
@@ -121,7 +121,7 @@ export type SignTypedDataReturnType = Hex
121
121
  * })
122
122
  */
123
123
  export async function signTypedData<
124
- const TTypedData extends TypedData | { [key: string]: unknown },
124
+ TTypedData extends TypedData | { [key: string]: unknown },
125
125
  TPrimaryType extends string,
126
126
  TChain extends Chain | undefined,
127
127
  TAccount extends Account | undefined,
@@ -104,7 +104,7 @@ export type WriteContractReturnType = SendTransactionReturnType
104
104
  export async function writeContract<
105
105
  TChain extends Chain | undefined,
106
106
  TAccount extends Account | undefined,
107
- const TAbi extends Abi | readonly unknown[],
107
+ TAbi extends Abi | readonly unknown[],
108
108
  TFunctionName extends string,
109
109
  TChainOverride extends Chain | undefined,
110
110
  >(
@@ -278,7 +278,7 @@ export type PublicActions<
278
278
  * })
279
279
  */
280
280
  createContractEventFilter: <
281
- const TAbi extends Abi | readonly unknown[],
281
+ TAbi extends Abi | readonly unknown[],
282
282
  TEventName extends string | undefined,
283
283
  TArgs extends MaybeExtractEventArgsFromAbi<TAbi, TEventName> | undefined,
284
284
  TStrict extends boolean | undefined = undefined,
@@ -325,8 +325,8 @@ export type PublicActions<
325
325
  * })
326
326
  */
327
327
  createEventFilter: <
328
- const TAbiEvent extends AbiEvent | undefined = undefined,
329
- const TAbiEvents extends
328
+ TAbiEvent extends AbiEvent | undefined = undefined,
329
+ TAbiEvents extends
330
330
  | readonly AbiEvent[]
331
331
  | readonly unknown[]
332
332
  | undefined = TAbiEvent extends AbiEvent ? [TAbiEvent] : undefined,
@@ -406,7 +406,7 @@ export type PublicActions<
406
406
  */
407
407
  estimateContractGas: <
408
408
  TChain extends Chain | undefined,
409
- const TAbi extends Abi | readonly unknown[],
409
+ TAbi extends Abi | readonly unknown[],
410
410
  TFunctionName extends string,
411
411
  >(
412
412
  args: EstimateContractGasParameters<TAbi, TFunctionName, TChain, TAccount>,
@@ -844,7 +844,7 @@ export type PublicActions<
844
844
  */
845
845
  getFilterChanges: <
846
846
  TFilterType extends FilterType,
847
- const TAbi extends Abi | readonly unknown[] | undefined,
847
+ TAbi extends Abi | readonly unknown[] | undefined,
848
848
  TEventName extends string | undefined,
849
849
  TStrict extends boolean | undefined = undefined,
850
850
  TFromBlock extends BlockNumber | BlockTag | undefined = undefined,
@@ -895,7 +895,7 @@ export type PublicActions<
895
895
  * const logs = await client.getFilterLogs({ filter })
896
896
  */
897
897
  getFilterLogs: <
898
- const TAbi extends Abi | readonly unknown[] | undefined,
898
+ TAbi extends Abi | readonly unknown[] | undefined,
899
899
  TEventName extends string | undefined,
900
900
  TStrict extends boolean | undefined = undefined,
901
901
  TFromBlock extends BlockNumber | BlockTag | undefined = undefined,
@@ -951,8 +951,8 @@ export type PublicActions<
951
951
  * const logs = await client.getLogs()
952
952
  */
953
953
  getLogs: <
954
- const TAbiEvent extends AbiEvent | undefined = undefined,
955
- const TAbiEvents extends
954
+ TAbiEvent extends AbiEvent | undefined = undefined,
955
+ TAbiEvents extends
956
956
  | readonly AbiEvent[]
957
957
  | readonly unknown[]
958
958
  | undefined = TAbiEvent extends AbiEvent ? [TAbiEvent] : undefined,
@@ -1133,12 +1133,7 @@ export type PublicActions<
1133
1133
  * // [{ result: 424122n, status: 'success' }, { result: 1000000n, status: 'success' }]
1134
1134
  */
1135
1135
  multicall: <
1136
- const TAbi extends Abi | readonly unknown[],
1137
- TFunctionName extends string,
1138
- const TContracts extends readonly ContractFunctionConfig<
1139
- TAbi,
1140
- TFunctionName
1141
- >[],
1136
+ TContracts extends ContractFunctionConfig[],
1142
1137
  TAllowFailure extends boolean = true,
1143
1138
  >(
1144
1139
  args: MulticallParameters<TContracts, TAllowFailure>,
@@ -1175,7 +1170,7 @@ export type PublicActions<
1175
1170
  * // 424122n
1176
1171
  */
1177
1172
  readContract: <
1178
- const TAbi extends Abi | readonly unknown[],
1173
+ TAbi extends Abi | readonly unknown[],
1179
1174
  TFunctionName extends string,
1180
1175
  >(
1181
1176
  args: ReadContractParameters<TAbi, TFunctionName>,
@@ -1211,7 +1206,7 @@ export type PublicActions<
1211
1206
  * })
1212
1207
  */
1213
1208
  simulateContract: <
1214
- const TAbi extends Abi | readonly unknown[],
1209
+ TAbi extends Abi | readonly unknown[],
1215
1210
  TFunctionName extends string,
1216
1211
  TChainOverride extends Chain | undefined,
1217
1212
  >(
@@ -1388,7 +1383,7 @@ export type PublicActions<
1388
1383
  * })
1389
1384
  */
1390
1385
  watchContractEvent: <
1391
- const TAbi extends Abi | readonly unknown[],
1386
+ TAbi extends Abi | readonly unknown[],
1392
1387
  TEventName extends string,
1393
1388
  TStrict extends boolean | undefined = undefined,
1394
1389
  >(
@@ -1426,8 +1421,8 @@ export type PublicActions<
1426
1421
  * })
1427
1422
  */
1428
1423
  watchEvent: <
1429
- const TAbiEvent extends AbiEvent | undefined = undefined,
1430
- const TAbiEvents extends
1424
+ TAbiEvent extends AbiEvent | undefined = undefined,
1425
+ TAbiEvents extends
1431
1426
  | readonly AbiEvent[]
1432
1427
  | readonly unknown[]
1433
1428
  | undefined = TAbiEvent extends AbiEvent ? [TAbiEvent] : undefined,
@@ -1507,7 +1502,7 @@ export function publicActions<
1507
1502
  getTransactionConfirmations(client, args),
1508
1503
  getTransactionCount: (args) => getTransactionCount(client, args),
1509
1504
  getTransactionReceipt: (args) => getTransactionReceipt(client, args),
1510
- multicall: (args) => multicall(client, args as any) as any,
1505
+ multicall: (args) => multicall(client, args),
1511
1506
  readContract: (args) => readContract(client, args),
1512
1507
  simulateContract: (args) => simulateContract(client, args),
1513
1508
  verifyMessage: (args) => verifyMessage(client, args),
@@ -112,7 +112,7 @@ export type WalletActions<
112
112
  * })
113
113
  */
114
114
  deployContract: <
115
- const TAbi extends Abi | readonly unknown[],
115
+ TAbi extends Abi | readonly unknown[],
116
116
  TChainOverride extends Chain | undefined,
117
117
  >(
118
118
  args: DeployContractParameters<TAbi, TChain, TAccount, TChainOverride>,
@@ -410,7 +410,7 @@ export type WalletActions<
410
410
  * })
411
411
  */
412
412
  signTypedData: <
413
- const TTypedData extends TypedData | { [key: string]: unknown },
413
+ TTypedData extends TypedData | { [key: string]: unknown },
414
414
  TPrimaryType extends string,
415
415
  >(
416
416
  args: SignTypedDataParameters<TTypedData, TPrimaryType, TAccount>,
@@ -509,7 +509,7 @@ export type WalletActions<
509
509
  * const hash = await client.writeContract(request)
510
510
  */
511
511
  writeContract: <
512
- const TAbi extends Abi | readonly unknown[],
512
+ TAbi extends Abi | readonly unknown[],
513
513
  TFunctionName extends string,
514
514
  TChainOverride extends Chain | undefined,
515
515
  >(
@@ -1 +1 @@
1
- export const version = '0.0.0-main.20230814T205407'
1
+ export const version = '0.0.0-main.20230814T211804'
package/src/index.ts CHANGED
@@ -633,7 +633,6 @@ export type { GetTransportConfig } from './types/transport.js'
633
633
  export type { HDKey } from '@scure/bip32'
634
634
  export type { Log } from './types/log.js'
635
635
  export type {
636
- MulticallContract,
637
636
  MulticallContracts,
638
637
  MulticallResult,
639
638
  MulticallResults,
@@ -15,6 +15,7 @@ import type {
15
15
  ExtractAbiEventNames,
16
16
  ExtractAbiFunction,
17
17
  ExtractAbiFunctionNames,
18
+ Narrow,
18
19
  } from 'abitype'
19
20
 
20
21
  import type { Hex, LogTopic } from './misc.js'
@@ -37,7 +38,7 @@ export type ContractFunctionConfig<
37
38
  TAbiStateMutability extends AbiStateMutability = AbiStateMutability,
38
39
  > = {
39
40
  /** Contract ABI */
40
- abi: TAbi
41
+ abi: Narrow<TAbi>
41
42
  /** Contract address */
42
43
  address: Address
43
44
  /** Function to invoke on the contract */
@@ -1,4 +1,4 @@
1
- import type { Abi, ExtractAbiFunctionNames } from 'abitype'
1
+ import type { Abi } from 'abitype'
2
2
 
3
3
  import type {
4
4
  ContractFunctionConfig,
@@ -7,16 +7,13 @@ import type {
7
7
 
8
8
  type MAXIMUM_DEPTH = 20
9
9
 
10
- export type MulticallContract<
10
+ export type Contract<
11
11
  TAbi extends Abi | readonly unknown[] = Abi | readonly unknown[],
12
- TFunctionName extends ExtractAbiFunctionNames<
13
- TAbi extends Abi ? TAbi : Abi,
14
- 'pure' | 'view'
15
- > = string,
12
+ TFunctionName extends string = string,
16
13
  > = { abi: TAbi; functionName: TFunctionName }
17
14
 
18
15
  export type MulticallContracts<
19
- TContracts extends readonly MulticallContract[],
16
+ TContracts extends Contract[],
20
17
  TProperties extends Record<string, any> = object,
21
18
  Result extends any[] = [],
22
19
  Depth extends readonly number[] = [],
@@ -24,14 +21,14 @@ export type MulticallContracts<
24
21
  ? (ContractFunctionConfig & TProperties)[]
25
22
  : TContracts extends []
26
23
  ? []
27
- : TContracts extends [infer Head extends MulticallContract]
24
+ : TContracts extends [infer Head extends Contract]
28
25
  ? [
29
26
  ...Result,
30
27
  ContractFunctionConfig<Head['abi'], Head['functionName']> & TProperties,
31
28
  ]
32
29
  : TContracts extends [
33
- infer Head extends MulticallContract,
34
- ...infer Tail extends readonly MulticallContract[],
30
+ infer Head extends Contract,
31
+ ...infer Tail extends Contract[],
35
32
  ]
36
33
  ? MulticallContracts<
37
34
  [...Tail],
@@ -68,7 +65,7 @@ export type MulticallResult<
68
65
  : Result
69
66
 
70
67
  export type MulticallResults<
71
- TContracts extends readonly MulticallContract[],
68
+ TContracts extends Contract[],
72
69
  TAllowFailure extends boolean = true,
73
70
  Result extends any[] = [],
74
71
  Depth extends readonly number[] = [],
@@ -76,7 +73,7 @@ export type MulticallResults<
76
73
  ? MulticallResult<ContractFunctionResult, TAllowFailure>[]
77
74
  : TContracts extends []
78
75
  ? []
79
- : TContracts extends [infer Head extends MulticallContract]
76
+ : TContracts extends [infer Head extends Contract]
80
77
  ? [
81
78
  ...Result,
82
79
  MulticallResult<
@@ -85,8 +82,8 @@ export type MulticallResults<
85
82
  >,
86
83
  ]
87
84
  : TContracts extends [
88
- infer Head extends MulticallContract,
89
- ...infer Tail extends readonly MulticallContract[],
85
+ infer Head extends Contract,
86
+ ...infer Tail extends Contract[],
90
87
  ]
91
88
  ? MulticallResults<
92
89
  [...Tail],
@@ -1,4 +1,5 @@
1
1
  import type {
2
+ Narrow,
2
3
  TypedData,
3
4
  TypedDataDomain,
4
5
  TypedDataToPrimitiveTypes,
@@ -73,8 +74,8 @@ export type GetTypedDataTypes<
73
74
  TPrimaryType extends string = string,
74
75
  > = TPrimaryType extends 'EIP712Domain'
75
76
  ? {
76
- types?: TTypedData
77
+ types?: Narrow<TTypedData>
77
78
  }
78
79
  : {
79
- types: TTypedData
80
+ types: Narrow<TTypedData>
80
81
  }
@@ -2,6 +2,7 @@ import type {
2
2
  AbiParameter,
3
3
  AbiParameterToPrimitiveType,
4
4
  AbiParametersToPrimitiveTypes,
5
+ Narrow,
5
6
  } from 'abitype'
6
7
 
7
8
  import {
@@ -32,8 +33,8 @@ export type DecodeAbiParametersReturnType<
32
33
  >
33
34
 
34
35
  export function decodeAbiParameters<
35
- const TParams extends readonly AbiParameter[] | readonly unknown[],
36
- >(params: TParams, data: Hex): DecodeAbiParametersReturnType<TParams> {
36
+ TParams extends readonly AbiParameter[] | readonly unknown[],
37
+ >(params: Narrow<TParams>, data: Hex): DecodeAbiParametersReturnType<TParams> {
37
38
  if (data === '0x' && (params as unknown[]).length > 0)
38
39
  throw new AbiDecodingZeroDataError()
39
40
  if (size(data) && size(data) < 32)
@@ -52,7 +53,7 @@ export function decodeAbiParameters<
52
53
 
53
54
  type TupleAbiParameter = AbiParameter & { components: readonly AbiParameter[] }
54
55
 
55
- function decodeParams<const TParams extends readonly AbiParameter[]>({
56
+ function decodeParams<TParams extends readonly AbiParameter[]>({
56
57
  data,
57
58
  params,
58
59
  }: { data: Hex; params: TParams }) {
@@ -125,7 +126,7 @@ function decodeAddress(value: Hex) {
125
126
  return { consumed: 32, value: checksumAddress(slice(value, -20)) }
126
127
  }
127
128
 
128
- function decodeArray<const TParam extends AbiParameter>(
129
+ function decodeArray<TParam extends AbiParameter>(
129
130
  data: Hex,
130
131
  {
131
132
  param,
@@ -210,7 +211,7 @@ function decodeBool(value: Hex) {
210
211
  return { consumed: 32, value: hexToBool(value) }
211
212
  }
212
213
 
213
- function decodeBytes<const TParam extends AbiParameter>(
214
+ function decodeBytes<TParam extends AbiParameter>(
214
215
  data: Hex,
215
216
  { param, position }: { param: TParam; position: number },
216
217
  ) {
@@ -238,7 +239,7 @@ function decodeBytes<const TParam extends AbiParameter>(
238
239
  return { consumed: 32, value }
239
240
  }
240
241
 
241
- function decodeNumber<const TParam extends AbiParameter>(
242
+ function decodeNumber<TParam extends AbiParameter>(
242
243
  value: Hex,
243
244
  { param }: { param: TParam },
244
245
  ) {
@@ -267,7 +268,7 @@ function decodeString(data: Hex, { position }: { position: number }) {
267
268
  }
268
269
 
269
270
  function decodeTuple<
270
- const TParam extends AbiParameter & { components: readonly AbiParameter[] },
271
+ TParam extends AbiParameter & { components: readonly AbiParameter[] },
271
272
  >(data: Hex, { param, position }: { param: TParam; position: number }) {
272
273
  // Tuples can have unnamed components (i.e. they are arrays), so we must
273
274
  // determine whether the tuple is named or unnamed. In the case of a named
@@ -1,4 +1,4 @@
1
- import type { Abi } from 'abitype'
1
+ import type { Abi, Narrow } from 'abitype'
2
2
 
3
3
  import {
4
4
  AbiConstructorNotFoundError,
@@ -14,7 +14,7 @@ const docsPath = '/docs/contract/decodeDeployData'
14
14
  export type DecodeDeployDataParameters<
15
15
  TAbi extends Abi | readonly unknown[] = Abi,
16
16
  > = {
17
- abi: TAbi
17
+ abi: Narrow<TAbi>
18
18
  bytecode: Hex
19
19
  data: Hex
20
20
  }
@@ -24,7 +24,7 @@ export type DecodeDeployDataReturnType<
24
24
  bytecode: Hex
25
25
  } & GetConstructorArgs<TAbi>
26
26
 
27
- export function decodeDeployData<const TAbi extends Abi | readonly unknown[]>({
27
+ export function decodeDeployData<TAbi extends Abi | readonly unknown[]>({
28
28
  abi,
29
29
  bytecode,
30
30
  data,
@@ -1,4 +1,9 @@
1
- import type { Abi, ExtractAbiError, ExtractAbiErrorNames } from 'abitype'
1
+ import type {
2
+ Abi,
3
+ ExtractAbiError,
4
+ ExtractAbiErrorNames,
5
+ Narrow,
6
+ } from 'abitype'
2
7
 
3
8
  import { solidityError, solidityPanic } from '../../constants/solidity.js'
4
9
  import {
@@ -15,7 +20,7 @@ import { formatAbiItem } from './formatAbiItem.js'
15
20
 
16
21
  export type DecodeErrorResultParameters<
17
22
  TAbi extends Abi | readonly unknown[] = Abi,
18
- > = { abi?: TAbi; data: Hex }
23
+ > = { abi?: Narrow<TAbi>; data: Hex }
19
24
 
20
25
  export type DecodeErrorResultReturnType<
21
26
  TAbi extends Abi | readonly unknown[] = Abi,
@@ -32,7 +37,7 @@ export type DecodeErrorResultReturnType<
32
37
  }
33
38
  }[_ErrorNames]
34
39
 
35
- export function decodeErrorResult<const TAbi extends Abi | readonly unknown[]>({
40
+ export function decodeErrorResult<TAbi extends Abi | readonly unknown[]>({
36
41
  abi,
37
42
  data,
38
43
  }: DecodeErrorResultParameters<TAbi>): DecodeErrorResultReturnType<TAbi> {