viem 2.49.3 → 2.50.3

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 (241) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/_cjs/actions/ens/getEnsAddress.js +21 -6
  3. package/_cjs/actions/ens/getEnsAddress.js.map +1 -1
  4. package/_cjs/actions/public/call.js +76 -41
  5. package/_cjs/actions/public/call.js.map +1 -1
  6. package/_cjs/actions/public/getBalance.js +11 -4
  7. package/_cjs/actions/public/getBalance.js.map +1 -1
  8. package/_cjs/actions/public/getCode.js +12 -5
  9. package/_cjs/actions/public/getCode.js.map +1 -1
  10. package/_cjs/actions/public/getProof.js +9 -5
  11. package/_cjs/actions/public/getProof.js.map +1 -1
  12. package/_cjs/actions/public/getStorageAt.js +9 -4
  13. package/_cjs/actions/public/getStorageAt.js.map +1 -1
  14. package/_cjs/actions/public/getTransactionCount.js +10 -7
  15. package/_cjs/actions/public/getTransactionCount.js.map +1 -1
  16. package/_cjs/actions/public/multicall.js +3 -1
  17. package/_cjs/actions/public/multicall.js.map +1 -1
  18. package/_cjs/actions/public/readContract.js.map +1 -1
  19. package/_cjs/actions/wallet/prepareTransactionRequest.js.map +1 -1
  20. package/_cjs/actions/wallet/sendTransaction.js +14 -0
  21. package/_cjs/actions/wallet/sendTransaction.js.map +1 -1
  22. package/_cjs/actions/wallet/sendTransactionSync.js +15 -0
  23. package/_cjs/actions/wallet/sendTransactionSync.js.map +1 -1
  24. package/_cjs/chains/definitions/mizuhikiTestnetAwaji.js +29 -0
  25. package/_cjs/chains/definitions/mizuhikiTestnetAwaji.js.map +1 -0
  26. package/_cjs/chains/definitions/morphHolesky.js +1 -1
  27. package/_cjs/chains/definitions/morphHolesky.js.map +1 -1
  28. package/_cjs/chains/definitions/sentrix.js +29 -0
  29. package/_cjs/chains/definitions/sentrix.js.map +1 -0
  30. package/_cjs/chains/definitions/sentrixTestnet.js +30 -0
  31. package/_cjs/chains/definitions/sentrixTestnet.js.map +1 -0
  32. package/_cjs/chains/definitions/sova.js +1 -1
  33. package/_cjs/chains/definitions/sova.js.map +1 -1
  34. package/_cjs/chains/index.js +13 -7
  35. package/_cjs/chains/index.js.map +1 -1
  36. package/_cjs/constants/solidity.js.map +1 -1
  37. package/_cjs/errors/version.js +1 -1
  38. package/_cjs/index.js +5 -3
  39. package/_cjs/index.js.map +1 -1
  40. package/_cjs/tempo/Chain.js +19 -0
  41. package/_cjs/tempo/Chain.js.map +1 -0
  42. package/_cjs/tempo/Decorator.js +1 -0
  43. package/_cjs/tempo/Decorator.js.map +1 -1
  44. package/_cjs/tempo/actions/fee.js +61 -0
  45. package/_cjs/tempo/actions/fee.js.map +1 -1
  46. package/_cjs/tempo/chainConfig.js +16 -6
  47. package/_cjs/tempo/chainConfig.js.map +1 -1
  48. package/_cjs/tempo/chains/index.js +11 -0
  49. package/_cjs/tempo/chains/index.js.map +1 -0
  50. package/_cjs/tempo/errors.js +58 -0
  51. package/_cjs/tempo/errors.js.map +1 -0
  52. package/_cjs/tempo/index.js +17 -1
  53. package/_cjs/tempo/index.js.map +1 -1
  54. package/_cjs/utils/abi/encodeEventTopics.js +4 -2
  55. package/_cjs/utils/abi/encodeEventTopics.js.map +1 -1
  56. package/_cjs/utils/block/formatBlockParameter.js +16 -0
  57. package/_cjs/utils/block/formatBlockParameter.js.map +1 -0
  58. package/_cjs/utils/ccipTunnel.js +65 -0
  59. package/_cjs/utils/ccipTunnel.js.map +1 -0
  60. package/_cjs/utils/index.js +6 -4
  61. package/_cjs/utils/index.js.map +1 -1
  62. package/_cjs/utils/nonceManager.js +7 -3
  63. package/_cjs/utils/nonceManager.js.map +1 -1
  64. package/_cjs/utils/observe.js +7 -1
  65. package/_cjs/utils/observe.js.map +1 -1
  66. package/_cjs/utils/rpc/socket.js +19 -2
  67. package/_cjs/utils/rpc/socket.js.map +1 -1
  68. package/_esm/actions/ens/getEnsAddress.js +21 -6
  69. package/_esm/actions/ens/getEnsAddress.js.map +1 -1
  70. package/_esm/actions/public/call.js +76 -41
  71. package/_esm/actions/public/call.js.map +1 -1
  72. package/_esm/actions/public/getBalance.js +11 -4
  73. package/_esm/actions/public/getBalance.js.map +1 -1
  74. package/_esm/actions/public/getCode.js +12 -5
  75. package/_esm/actions/public/getCode.js.map +1 -1
  76. package/_esm/actions/public/getProof.js +9 -5
  77. package/_esm/actions/public/getProof.js.map +1 -1
  78. package/_esm/actions/public/getStorageAt.js +9 -4
  79. package/_esm/actions/public/getStorageAt.js.map +1 -1
  80. package/_esm/actions/public/getTransactionCount.js +10 -7
  81. package/_esm/actions/public/getTransactionCount.js.map +1 -1
  82. package/_esm/actions/public/multicall.js +3 -1
  83. package/_esm/actions/public/multicall.js.map +1 -1
  84. package/_esm/actions/public/readContract.js.map +1 -1
  85. package/_esm/actions/wallet/prepareTransactionRequest.js.map +1 -1
  86. package/_esm/actions/wallet/sendTransaction.js +14 -0
  87. package/_esm/actions/wallet/sendTransaction.js.map +1 -1
  88. package/_esm/actions/wallet/sendTransactionSync.js +15 -0
  89. package/_esm/actions/wallet/sendTransactionSync.js.map +1 -1
  90. package/_esm/chains/definitions/mizuhikiTestnetAwaji.js +26 -0
  91. package/_esm/chains/definitions/mizuhikiTestnetAwaji.js.map +1 -0
  92. package/_esm/chains/definitions/morphHolesky.js +1 -1
  93. package/_esm/chains/definitions/morphHolesky.js.map +1 -1
  94. package/_esm/chains/definitions/sentrix.js +26 -0
  95. package/_esm/chains/definitions/sentrix.js.map +1 -0
  96. package/_esm/chains/definitions/sentrixTestnet.js +27 -0
  97. package/_esm/chains/definitions/sentrixTestnet.js.map +1 -0
  98. package/_esm/chains/definitions/sova.js +1 -1
  99. package/_esm/chains/definitions/sova.js.map +1 -1
  100. package/_esm/chains/index.js +3 -0
  101. package/_esm/chains/index.js.map +1 -1
  102. package/_esm/constants/solidity.js.map +1 -1
  103. package/_esm/errors/version.js +1 -1
  104. package/_esm/index.js +1 -0
  105. package/_esm/index.js.map +1 -1
  106. package/_esm/tempo/Chain.js +6 -0
  107. package/_esm/tempo/Chain.js.map +1 -0
  108. package/_esm/tempo/Decorator.js +1 -0
  109. package/_esm/tempo/Decorator.js.map +1 -1
  110. package/_esm/tempo/actions/fee.js +83 -0
  111. package/_esm/tempo/actions/fee.js.map +1 -1
  112. package/_esm/tempo/actions/wallet.js +2 -2
  113. package/_esm/tempo/chainConfig.js +18 -8
  114. package/_esm/tempo/chainConfig.js.map +1 -1
  115. package/_esm/tempo/chains/index.js +3 -0
  116. package/_esm/tempo/chains/index.js.map +1 -0
  117. package/_esm/tempo/errors.js +51 -0
  118. package/_esm/tempo/errors.js.map +1 -0
  119. package/_esm/tempo/index.js +2 -0
  120. package/_esm/tempo/index.js.map +1 -1
  121. package/_esm/utils/abi/encodeEventTopics.js +6 -2
  122. package/_esm/utils/abi/encodeEventTopics.js.map +1 -1
  123. package/_esm/utils/block/formatBlockParameter.js +39 -0
  124. package/_esm/utils/block/formatBlockParameter.js.map +1 -0
  125. package/_esm/utils/ccipTunnel.js +62 -0
  126. package/_esm/utils/ccipTunnel.js.map +1 -0
  127. package/_esm/utils/index.js +1 -0
  128. package/_esm/utils/index.js.map +1 -1
  129. package/_esm/utils/nonceManager.js +7 -3
  130. package/_esm/utils/nonceManager.js.map +1 -1
  131. package/_esm/utils/observe.js +7 -1
  132. package/_esm/utils/observe.js.map +1 -1
  133. package/_esm/utils/rpc/socket.js +20 -2
  134. package/_esm/utils/rpc/socket.js.map +1 -1
  135. package/_types/actions/ens/getEnsAddress.d.ts +3 -1
  136. package/_types/actions/ens/getEnsAddress.d.ts.map +1 -1
  137. package/_types/actions/public/call.d.ts +17 -6
  138. package/_types/actions/public/call.d.ts.map +1 -1
  139. package/_types/actions/public/getBalance.d.ts +15 -3
  140. package/_types/actions/public/getBalance.d.ts.map +1 -1
  141. package/_types/actions/public/getCode.d.ts +15 -4
  142. package/_types/actions/public/getCode.d.ts.map +1 -1
  143. package/_types/actions/public/getProof.d.ts +14 -3
  144. package/_types/actions/public/getProof.d.ts.map +1 -1
  145. package/_types/actions/public/getStorageAt.d.ts +15 -4
  146. package/_types/actions/public/getStorageAt.d.ts.map +1 -1
  147. package/_types/actions/public/getTransactionCount.d.ts +15 -3
  148. package/_types/actions/public/getTransactionCount.d.ts.map +1 -1
  149. package/_types/actions/public/multicall.d.ts +1 -1
  150. package/_types/actions/public/multicall.d.ts.map +1 -1
  151. package/_types/actions/public/readContract.d.ts +1 -1
  152. package/_types/actions/public/readContract.d.ts.map +1 -1
  153. package/_types/actions/wallet/prepareTransactionRequest.d.ts +4 -2
  154. package/_types/actions/wallet/prepareTransactionRequest.d.ts.map +1 -1
  155. package/_types/actions/wallet/sendTransaction.d.ts.map +1 -1
  156. package/_types/actions/wallet/sendTransactionSync.d.ts.map +1 -1
  157. package/_types/chains/definitions/mizuhikiTestnetAwaji.d.ts +46 -0
  158. package/_types/chains/definitions/mizuhikiTestnetAwaji.d.ts.map +1 -0
  159. package/_types/chains/definitions/morphHolesky.d.ts +1 -1
  160. package/_types/chains/definitions/sentrix.d.ts +46 -0
  161. package/_types/chains/definitions/sentrix.d.ts.map +1 -0
  162. package/_types/chains/definitions/sentrixTestnet.d.ts +46 -0
  163. package/_types/chains/definitions/sentrixTestnet.d.ts.map +1 -0
  164. package/_types/chains/definitions/sova.d.ts +1 -1
  165. package/_types/chains/index.d.ts +3 -0
  166. package/_types/chains/index.d.ts.map +1 -1
  167. package/_types/constants/solidity.d.ts +16 -3
  168. package/_types/constants/solidity.d.ts.map +1 -1
  169. package/_types/errors/version.d.ts +1 -1
  170. package/_types/index.d.ts +1 -0
  171. package/_types/index.d.ts.map +1 -1
  172. package/_types/tempo/Chain.d.ts +5 -0
  173. package/_types/tempo/Chain.d.ts.map +1 -0
  174. package/_types/tempo/Decorator.d.ts +23 -0
  175. package/_types/tempo/Decorator.d.ts.map +1 -1
  176. package/_types/tempo/actions/fee.d.ts +38 -0
  177. package/_types/tempo/actions/fee.d.ts.map +1 -1
  178. package/_types/tempo/actions/wallet.d.ts +9 -6
  179. package/_types/tempo/actions/wallet.d.ts.map +1 -1
  180. package/_types/tempo/chainConfig.d.ts.map +1 -1
  181. package/_types/tempo/chains/index.d.ts +2 -0
  182. package/_types/tempo/chains/index.d.ts.map +1 -0
  183. package/_types/tempo/errors.d.ts +36 -0
  184. package/_types/tempo/errors.d.ts.map +1 -0
  185. package/_types/tempo/index.d.ts +2 -0
  186. package/_types/tempo/index.d.ts.map +1 -1
  187. package/_types/types/block.d.ts +3 -4
  188. package/_types/types/block.d.ts.map +1 -1
  189. package/_types/types/eip1193.d.ts +1 -1
  190. package/_types/types/eip1193.d.ts.map +1 -1
  191. package/_types/utils/abi/encodeEventTopics.d.ts +6 -2
  192. package/_types/utils/abi/encodeEventTopics.d.ts.map +1 -1
  193. package/_types/utils/block/formatBlockParameter.d.ts +45 -0
  194. package/_types/utils/block/formatBlockParameter.d.ts.map +1 -0
  195. package/_types/utils/ccipTunnel.d.ts +9 -0
  196. package/_types/utils/ccipTunnel.d.ts.map +1 -0
  197. package/_types/utils/index.d.ts +1 -0
  198. package/_types/utils/index.d.ts.map +1 -1
  199. package/_types/utils/nonceManager.d.ts.map +1 -1
  200. package/_types/utils/observe.d.ts.map +1 -1
  201. package/_types/utils/rpc/socket.d.ts.map +1 -1
  202. package/actions/ens/getEnsAddress.ts +34 -6
  203. package/actions/public/call.ts +125 -51
  204. package/actions/public/getBalance.ts +30 -9
  205. package/actions/public/getCode.ts +35 -11
  206. package/actions/public/getProof.ts +27 -11
  207. package/actions/public/getStorageAt.ts +33 -10
  208. package/actions/public/getTransactionCount.ts +33 -11
  209. package/actions/public/multicall.ts +6 -0
  210. package/actions/public/readContract.ts +2 -0
  211. package/actions/wallet/prepareTransactionRequest.ts +11 -15
  212. package/actions/wallet/sendTransaction.ts +13 -0
  213. package/actions/wallet/sendTransactionSync.ts +16 -0
  214. package/chains/definitions/mizuhikiTestnetAwaji.ts +26 -0
  215. package/chains/definitions/morphHolesky.ts +1 -1
  216. package/chains/definitions/sentrix.ts +26 -0
  217. package/chains/definitions/sentrixTestnet.ts +27 -0
  218. package/chains/definitions/sova.ts +1 -1
  219. package/chains/index.ts +3 -0
  220. package/constants/solidity.ts +4 -4
  221. package/errors/version.ts +1 -1
  222. package/index.ts +4 -0
  223. package/package.json +11 -3
  224. package/tempo/Chain.ts +20 -0
  225. package/tempo/Decorator.ts +27 -0
  226. package/tempo/actions/fee.ts +117 -1
  227. package/tempo/actions/wallet.ts +9 -6
  228. package/tempo/chainConfig.ts +18 -12
  229. package/tempo/chains/index.ts +9 -0
  230. package/tempo/chains/package.json +6 -0
  231. package/tempo/errors.ts +78 -0
  232. package/tempo/index.ts +2 -0
  233. package/types/block.ts +3 -5
  234. package/types/eip1193.ts +1 -1
  235. package/utils/abi/encodeEventTopics.ts +25 -6
  236. package/utils/block/formatBlockParameter.ts +63 -0
  237. package/utils/ccipTunnel.ts +67 -0
  238. package/utils/index.ts +4 -0
  239. package/utils/nonceManager.ts +7 -3
  240. package/utils/observe.ts +7 -4
  241. package/utils/rpc/socket.ts +21 -2
@@ -6,15 +6,16 @@ import type { Transport } from '../../clients/transports/createTransport.js'
6
6
  import type { ErrorType } from '../../errors/utils.js'
7
7
  import type { BlockTag } from '../../types/block.js'
8
8
  import type { Chain } from '../../types/chain.js'
9
+ import type { Hash } from '../../types/misc.js'
10
+ import {
11
+ type FormatBlockParameterErrorType,
12
+ formatBlockParameter,
13
+ } from '../../utils/block/formatBlockParameter.js'
9
14
  import type { RequestErrorType } from '../../utils/buildRequest.js'
10
15
  import {
11
16
  type HexToNumberErrorType,
12
17
  hexToNumber,
13
18
  } from '../../utils/encoding/fromHex.js'
14
- import {
15
- type NumberToHexErrorType,
16
- numberToHex,
17
- } from '../../utils/encoding/toHex.js'
18
19
 
19
20
  export type GetTransactionCountParameters = {
20
21
  /** The account address. */
@@ -24,18 +25,30 @@ export type GetTransactionCountParameters = {
24
25
  /** The block number. */
25
26
  blockNumber?: bigint | undefined
26
27
  blockTag?: undefined
28
+ blockHash?: undefined
29
+ requireCanonical?: undefined
27
30
  }
28
31
  | {
29
32
  blockNumber?: undefined
30
33
  /** The block tag. Defaults to 'latest'. */
31
34
  blockTag?: BlockTag | undefined
35
+ blockHash?: undefined
36
+ requireCanonical?: undefined
37
+ }
38
+ | {
39
+ blockNumber?: undefined
40
+ blockTag?: undefined
41
+ /** The transaction count at a block specified by block hash. */
42
+ blockHash: Hash
43
+ /** Whether or not to throw an error if the block is not in the canonical chain. Only allowed in conjunction with `blockHash`. */
44
+ requireCanonical?: boolean | undefined
32
45
  }
33
46
  )
34
47
  export type GetTransactionCountReturnType = number
35
48
 
36
49
  export type GetTransactionCountErrorType =
37
50
  | RequestErrorType
38
- | NumberToHexErrorType
51
+ | FormatBlockParameterErrorType
39
52
  | HexToNumberErrorType
40
53
  | ErrorType
41
54
 
@@ -67,18 +80,27 @@ export async function getTransactionCount<
67
80
  account extends Account | undefined,
68
81
  >(
69
82
  client: Client<Transport, chain, account>,
70
- { address, blockTag = 'latest', blockNumber }: GetTransactionCountParameters,
83
+ {
84
+ address,
85
+ blockHash,
86
+ blockNumber,
87
+ blockTag = 'latest',
88
+ requireCanonical,
89
+ }: GetTransactionCountParameters,
71
90
  ): Promise<GetTransactionCountReturnType> {
91
+ const block = formatBlockParameter({
92
+ blockHash,
93
+ blockNumber,
94
+ blockTag,
95
+ requireCanonical,
96
+ })
72
97
  const count = await client.request(
73
98
  {
74
99
  method: 'eth_getTransactionCount',
75
- params: [
76
- address,
77
- typeof blockNumber === 'bigint' ? numberToHex(blockNumber) : blockTag,
78
- ],
100
+ params: [address, block],
79
101
  },
80
102
  {
81
- dedupe: Boolean(blockNumber),
103
+ dedupe: typeof blockNumber === 'bigint' || blockHash !== undefined,
82
104
  },
83
105
  )
84
106
  return hexToNumber(count)
@@ -45,9 +45,11 @@ export type MulticallParameters<
45
45
  > = Pick<
46
46
  CallParameters,
47
47
  | 'authorizationList'
48
+ | 'blockHash'
48
49
  | 'blockNumber'
49
50
  | 'blockOverrides'
50
51
  | 'blockTag'
52
+ | 'requireCanonical'
51
53
  | 'stateOverride'
52
54
  > & {
53
55
  /** The account to use for the multicall. */
@@ -138,9 +140,11 @@ export async function multicall<
138
140
  account,
139
141
  authorizationList,
140
142
  allowFailure = true,
143
+ blockHash,
141
144
  blockNumber,
142
145
  blockOverrides,
143
146
  blockTag,
147
+ requireCanonical,
144
148
  stateOverride,
145
149
  } = parameters
146
150
  const contracts = parameters.contracts as ContractFunctionParameters[]
@@ -237,10 +241,12 @@ export async function multicall<
237
241
  account,
238
242
  args: [calls],
239
243
  authorizationList,
244
+ blockHash,
240
245
  blockNumber,
241
246
  blockOverrides,
242
247
  blockTag,
243
248
  functionName: 'aggregate3',
249
+ requireCanonical,
244
250
  stateOverride,
245
251
  }),
246
252
  ),
@@ -44,11 +44,13 @@ export type ReadContractParameters<
44
44
  CallParameters,
45
45
  | 'account'
46
46
  | 'authorizationList'
47
+ | 'blockHash'
47
48
  | 'blockNumber'
48
49
  | 'blockOverrides'
49
50
  | 'blockTag'
50
51
  | 'factory'
51
52
  | 'factoryData'
53
+ | 'requireCanonical'
52
54
  | 'stateOverride'
53
55
  >
54
56
  > &
@@ -38,15 +38,7 @@ import type {
38
38
  GetChainParameter,
39
39
  } from '../../types/chain.js'
40
40
  import type { GetTransactionRequestKzgParameter } from '../../types/kzg.js'
41
- import type {
42
- TransactionRequest,
43
- TransactionRequestEIP1559,
44
- TransactionRequestEIP2930,
45
- TransactionRequestEIP4844,
46
- TransactionRequestEIP7702,
47
- TransactionRequestLegacy,
48
- TransactionSerializable,
49
- } from '../../types/transaction.js'
41
+ import type { TransactionSerializable } from '../../types/transaction.js'
50
42
  import type {
51
43
  ExactPartial,
52
44
  IsNever,
@@ -106,6 +98,12 @@ type ParameterTypeToParameters<
106
98
  > = parameterType extends 'fees'
107
99
  ? 'maxFeePerGas' | 'maxPriorityFeePerGas' | 'gasPrice'
108
100
  : parameterType
101
+ type ExtractTransactionRequest<transactionRequest, transactionType> =
102
+ transactionRequest extends { type?: infer type | undefined }
103
+ ? Extract<transactionType, type> extends never
104
+ ? never
105
+ : transactionRequest
106
+ : never
109
107
 
110
108
  export type PrepareTransactionRequestRequest<
111
109
  chain extends Chain | undefined = Chain | undefined,
@@ -166,12 +164,10 @@ export type PrepareTransactionRequestReturnType<
166
164
  : GetTransactionType<request> extends 'legacy'
167
165
  ? unknown
168
166
  : GetTransactionType<request>,
169
- _transactionRequest extends TransactionRequest =
170
- | (_transactionType extends 'legacy' ? TransactionRequestLegacy : never)
171
- | (_transactionType extends 'eip1559' ? TransactionRequestEIP1559 : never)
172
- | (_transactionType extends 'eip2930' ? TransactionRequestEIP2930 : never)
173
- | (_transactionType extends 'eip4844' ? TransactionRequestEIP4844 : never)
174
- | (_transactionType extends 'eip7702' ? TransactionRequestEIP7702 : never),
167
+ _transactionRequest = ExtractTransactionRequest<
168
+ UnionOmit<FormattedTransactionRequest<_derivedChain>, 'from'>,
169
+ _transactionType
170
+ >,
175
171
  > = Prettify<
176
172
  UnionRequiredBy<
177
173
  Extract<
@@ -190,6 +190,7 @@ export async function sendTransaction<
190
190
  docsPath: '/docs/actions/wallet/sendTransaction',
191
191
  })
192
192
  const account = account_ ? parseAccount(account_) : null
193
+ let nonceManagerParameters: { address: Address; chainId: number } | undefined
193
194
 
194
195
  try {
195
196
  assertRequest(parameters as AssertRequestParameters)
@@ -309,6 +310,16 @@ export async function sendTransaction<
309
310
  }
310
311
 
311
312
  if (account?.type === 'local') {
313
+ if (account.nonceManager && typeof nonce === 'undefined') {
314
+ const requestChainId = (rest as unknown as { chainId?: number }).chainId
315
+ const chainId = await (async () => {
316
+ if (typeof requestChainId === 'number') return requestChainId
317
+ if (chain) return chain.id
318
+ return getAction(client, getChainId, 'getChainId')({})
319
+ })()
320
+ nonceManagerParameters = { address: account.address, chainId }
321
+ }
322
+
312
323
  // Prepare the request for signing (assign appropriate fees, etc.)
313
324
  const request = await getAction(
314
325
  client,
@@ -366,6 +377,8 @@ export async function sendTransaction<
366
377
  })
367
378
  } catch (err) {
368
379
  if (err instanceof AccountTypeNotSupportedError) throw err
380
+ if (nonceManagerParameters)
381
+ account?.nonceManager?.reset(nonceManagerParameters)
369
382
  throw getTransactionError(err as BaseError, {
370
383
  ...parameters,
371
384
  account,
@@ -213,6 +213,7 @@ export async function sendTransactionSync<
213
213
  docsPath: '/docs/actions/wallet/sendTransactionSync',
214
214
  })
215
215
  const account = account_ ? parseAccount(account_) : null
216
+ let nonceManagerParameters: { address: Address; chainId: number } | undefined
216
217
 
217
218
  try {
218
219
  assertRequest(parameters as AssertRequestParameters)
@@ -348,6 +349,16 @@ export async function sendTransactionSync<
348
349
  }
349
350
 
350
351
  if (account?.type === 'local') {
352
+ if (account.nonceManager && typeof nonce === 'undefined') {
353
+ const requestChainId = (rest as unknown as { chainId?: number }).chainId
354
+ const chainId = await (async () => {
355
+ if (typeof requestChainId === 'number') return requestChainId
356
+ if (chain) return chain.id
357
+ return getAction(client, getChainId, 'getChainId')({})
358
+ })()
359
+ nonceManagerParameters = { address: account.address, chainId }
360
+ }
361
+
351
362
  // Prepare the request for signing (assign appropriate fees, etc.)
352
363
  const request = await getAction(
353
364
  client,
@@ -407,6 +418,11 @@ export async function sendTransactionSync<
407
418
  })
408
419
  } catch (err) {
409
420
  if (err instanceof AccountTypeNotSupportedError) throw err
421
+ if (
422
+ nonceManagerParameters &&
423
+ !(err instanceof TransactionReceiptRevertedError)
424
+ )
425
+ account?.nonceManager?.reset(nonceManagerParameters)
410
426
  throw getTransactionError(err as BaseError, {
411
427
  ...parameters,
412
428
  account,
@@ -0,0 +1,26 @@
1
+ import { defineChain } from '../../utils/chain/defineChain.js'
2
+
3
+ export const mizuhikiTestnetAwaji = /*#__PURE__*/ defineChain({
4
+ id: 6497,
5
+ name: 'MIZUHIKI Testnet Awaji',
6
+ nativeCurrency: { name: 'MIZU', symbol: 'MIZU', decimals: 18 },
7
+ rpcUrls: {
8
+ default: {
9
+ http: ['https://rpc.awaji.mizuhiki.io'],
10
+ },
11
+ },
12
+ blockExplorers: {
13
+ default: {
14
+ name: 'Blockscout',
15
+ url: 'https://awaji.blockscout.com',
16
+ apiUrl: 'https://awaji.blockscout.com/api',
17
+ },
18
+ },
19
+ contracts: {
20
+ multicall3: {
21
+ address: '0xca11bde05977b3631167028862be2a173976ca11',
22
+ blockCreated: 0,
23
+ },
24
+ },
25
+ testnet: true,
26
+ })
@@ -14,7 +14,7 @@ export const morphHolesky = /*#__PURE__*/ defineChain({
14
14
  default: {
15
15
  name: 'Morph Holesky Explorer',
16
16
  url: 'https://explorer-holesky.morphl2.io',
17
- apiUrl: 'https://explorer-api-holesky.morphl2.io/api?',
17
+ apiUrl: 'https://explorer-api-holesky.morphl2.io/api',
18
18
  },
19
19
  },
20
20
  testnet: true,
@@ -0,0 +1,26 @@
1
+ import { defineChain } from '../../utils/chain/defineChain.js'
2
+
3
+ export const sentrix = /*#__PURE__*/ defineChain({
4
+ id: 7119,
5
+ name: 'Sentrix Chain',
6
+ nativeCurrency: { name: 'Sentrix', symbol: 'SRX', decimals: 18 },
7
+ blockTime: 1_000,
8
+ rpcUrls: {
9
+ default: {
10
+ http: ['https://rpc.sentrixchain.com'],
11
+ webSocket: ['wss://rpc.sentrixchain.com/ws'],
12
+ },
13
+ },
14
+ blockExplorers: {
15
+ default: {
16
+ name: 'SentrixScan',
17
+ url: 'https://scan.sentrixchain.com',
18
+ },
19
+ },
20
+ contracts: {
21
+ multicall3: {
22
+ address: '0xFd4b34b5763f54a580a0d9f7997A2A993ef9ceE9',
23
+ blockCreated: 717_078,
24
+ },
25
+ },
26
+ })
@@ -0,0 +1,27 @@
1
+ import { defineChain } from '../../utils/chain/defineChain.js'
2
+
3
+ export const sentrixTestnet = /*#__PURE__*/ defineChain({
4
+ id: 7120,
5
+ name: 'Sentrix Testnet',
6
+ nativeCurrency: { name: 'Sentrix', symbol: 'SRX', decimals: 18 },
7
+ blockTime: 1_000,
8
+ rpcUrls: {
9
+ default: {
10
+ http: ['https://testnet-rpc.sentrixchain.com'],
11
+ webSocket: ['wss://testnet-rpc.sentrixchain.com/ws'],
12
+ },
13
+ },
14
+ blockExplorers: {
15
+ default: {
16
+ name: 'SentrixScan Testnet',
17
+ url: 'https://scan-testnet.sentrixchain.com',
18
+ },
19
+ },
20
+ contracts: {
21
+ multicall3: {
22
+ address: '0x7900826De548425c6BE56caEbD4760AB0155Cd54',
23
+ blockCreated: 723_191,
24
+ },
25
+ },
26
+ testnet: true,
27
+ })
@@ -16,7 +16,7 @@ export const sova = /*#__PURE__*/ defineChain({
16
16
  blockExplorers: {
17
17
  default: {
18
18
  name: 'Sova Block Explorer',
19
- url: 'hhttps://explorer.sova.io',
19
+ url: 'https://explorer.sova.io',
20
20
  },
21
21
  },
22
22
  testnet: false,
package/chains/index.ts CHANGED
@@ -415,6 +415,7 @@ export { mezoTestnet } from './definitions/mezoTestnet.js'
415
415
  export { mint } from './definitions/mint.js'
416
416
  export { mintSepoliaTestnet } from './definitions/mintSepoliaTestnet.js'
417
417
  export { mitosisTestnet } from './definitions/mitosisTestnet.js'
418
+ export { mizuhikiTestnetAwaji } from './definitions/mizuhikiTestnetAwaji.js'
418
419
  export { mode } from './definitions/mode.js'
419
420
  export { modeTestnet } from './definitions/modeTestnet.js'
420
421
  export { monad } from './definitions/monad.js'
@@ -539,6 +540,8 @@ export { scrollSepolia } from './definitions/scrollSepolia.js'
539
540
  export { sei } from './definitions/sei.js'
540
541
  export { seismicDevnet } from './definitions/seismicDevnet.js'
541
542
  export { seiTestnet } from './definitions/seiTestnet.js'
543
+ export { sentrix } from './definitions/sentrix.js'
544
+ export { sentrixTestnet } from './definitions/sentrixTestnet.js'
542
545
  export { sepolia } from './definitions/sepolia.js'
543
546
  export { shape } from './definitions/shape.js'
544
547
  export { shapeSepolia } from './definitions/shapeSepolia.js'
@@ -13,7 +13,7 @@ export const panicReasons = {
13
13
  81: 'Attempted to call a zero-initialized variable of internal function type.',
14
14
  } as const
15
15
 
16
- export const solidityError: AbiError = {
16
+ export const solidityError = {
17
17
  inputs: [
18
18
  {
19
19
  name: 'message',
@@ -22,8 +22,8 @@ export const solidityError: AbiError = {
22
22
  ],
23
23
  name: 'Error',
24
24
  type: 'error',
25
- }
26
- export const solidityPanic: AbiError = {
25
+ } as const satisfies AbiError
26
+ export const solidityPanic = {
27
27
  inputs: [
28
28
  {
29
29
  name: 'reason',
@@ -32,4 +32,4 @@ export const solidityPanic: AbiError = {
32
32
  ],
33
33
  name: 'Panic',
34
34
  type: 'error',
35
- }
35
+ } as const satisfies AbiError
package/errors/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '2.49.3'
1
+ export const version = '2.50.3'
package/index.ts CHANGED
@@ -1465,6 +1465,10 @@ export {
1465
1465
  offchainLookupAbiItem,
1466
1466
  offchainLookupSignature,
1467
1467
  } from './utils/ccip.js'
1468
+ export {
1469
+ type CcipReadTunnelParameters,
1470
+ ccipReadTunnel,
1471
+ } from './utils/ccipTunnel.js'
1468
1472
  export {
1469
1473
  type AssertCurrentChainErrorType,
1470
1474
  type AssertCurrentChainParameters,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "viem",
3
3
  "description": "TypeScript Interface for Ethereum",
4
- "version": "2.49.3",
4
+ "version": "2.50.3",
5
5
  "main": "./_cjs/index.js",
6
6
  "module": "./_esm/index.js",
7
7
  "types": "./_types/index.d.ts",
@@ -124,6 +124,11 @@
124
124
  "import": "./_esm/tempo/actions/index.js",
125
125
  "default": "./_cjs/tempo/actions/index.js"
126
126
  },
127
+ "./tempo/chains": {
128
+ "types": "./_types/tempo/chains/index.d.ts",
129
+ "import": "./_esm/tempo/chains/index.js",
130
+ "default": "./_cjs/tempo/chains/index.js"
131
+ },
127
132
  "./tempo/zones": {
128
133
  "types": "./_types/tempo/zones/index.d.ts",
129
134
  "import": "./_esm/tempo/zones/index.js",
@@ -196,6 +201,9 @@
196
201
  "tempo/actions": [
197
202
  "./_types/tempo/actions/index.d.ts"
198
203
  ],
204
+ "tempo/chains": [
205
+ "./_types/tempo/chains/index.d.ts"
206
+ ],
199
207
  "utils": [
200
208
  "./_types/utils/index.d.ts"
201
209
  ],
@@ -222,8 +230,8 @@
222
230
  "@scure/bip39": "1.6.0",
223
231
  "abitype": "1.2.3",
224
232
  "isows": "1.0.7",
225
- "ox": "0.14.20",
226
- "ws": "8.18.3"
233
+ "ox": "0.14.22",
234
+ "ws": "8.20.1"
227
235
  },
228
236
  "license": "MIT",
229
237
  "homepage": "https://viem.sh",
package/tempo/Chain.ts ADDED
@@ -0,0 +1,20 @@
1
+ // biome-ignore lint/performance/noBarrelFile: namespace module
2
+ export {
3
+ tempo,
4
+ tempo as mainnet,
5
+ tempo as tempoMainnet,
6
+ } from '../chains/definitions/tempo.js'
7
+ export {
8
+ tempoDevnet,
9
+ tempoDevnet as devnet,
10
+ } from '../chains/definitions/tempoDevnet.js'
11
+ export {
12
+ tempoLocalnet,
13
+ tempoLocalnet as localnet,
14
+ } from '../chains/definitions/tempoLocalnet.js'
15
+ export {
16
+ tempoModerato,
17
+ tempoModerato as moderato,
18
+ tempoModerato as tempoTestnet,
19
+ tempoModerato as testnet,
20
+ } from '../chains/definitions/tempoModerato.js'
@@ -1389,6 +1389,31 @@ export type Decorator<
1389
1389
  ) => () => void
1390
1390
  }
1391
1391
  fee: {
1392
+ /**
1393
+ * Validates that a token can be used as a Tempo fee token.
1394
+ *
1395
+ * @example
1396
+ * ```ts
1397
+ * import { createClient, http } from 'viem'
1398
+ * import { tempo } from 'viem/chains'
1399
+ * import { tempoActions } from 'viem/tempo'
1400
+ *
1401
+ * const client = createClient({
1402
+ * chain: tempo
1403
+ * transport: http(),
1404
+ * }).extend(tempoActions())
1405
+ *
1406
+ * const { address } = await client.fee.validateToken({
1407
+ * token: '0x20c0000000000000000000000000000000000001',
1408
+ * })
1409
+ * ```
1410
+ *
1411
+ * @param parameters - Parameters.
1412
+ * @returns The fee token address, ID, and metadata.
1413
+ */
1414
+ validateToken: (
1415
+ parameters: feeActions.validateToken.Parameters,
1416
+ ) => Promise<feeActions.validateToken.ReturnValue>
1392
1417
  /**
1393
1418
  * Gets the user's default fee token.
1394
1419
  *
@@ -4321,6 +4346,8 @@ export function decorator() {
4321
4346
  nonceActions.watchNonceIncremented(client, parameters),
4322
4347
  },
4323
4348
  fee: {
4349
+ validateToken: (parameters) =>
4350
+ feeActions.validateToken(client, parameters),
4324
4351
  // @ts-expect-error
4325
4352
  getUserToken: (parameters) =>
4326
4353
  // @ts-expect-error
@@ -11,7 +11,7 @@ import { writeContractSync } from '../../actions/wallet/writeContractSync.js'
11
11
  import type { Client } from '../../clients/createClient.js'
12
12
  import type { Transport } from '../../clients/transports/createTransport.js'
13
13
  import { zeroAddress } from '../../constants/address.js'
14
- import type { BaseErrorType } from '../../errors/base.js'
14
+ import type { BaseError, BaseErrorType } from '../../errors/base.js'
15
15
  import type { Chain } from '../../types/chain.js'
16
16
  import type { ExtractAbiItem, GetEventArgs } from '../../types/contract.js'
17
17
  import type { Log, Log as viem_Log } from '../../types/log.js'
@@ -19,6 +19,12 @@ import type { Compute, UnionOmit } from '../../types/utils.js'
19
19
  import { parseEventLogs } from '../../utils/abi/parseEventLogs.js'
20
20
  import * as Abis from '../Abis.js'
21
21
  import * as Addresses from '../Addresses.js'
22
+ import {
23
+ FeeTokenNotTip20Error,
24
+ FeeTokenNotUsdError,
25
+ FeeTokenPausedError,
26
+ InvalidFeeTokenError,
27
+ } from '../errors.js'
22
28
  import type {
23
29
  GetAccountParameter,
24
30
  ReadParameters,
@@ -26,6 +32,116 @@ import type {
26
32
  } from '../internal/types.js'
27
33
  import { defineCall } from '../internal/utils.js'
28
34
  import type { TransactionReceipt } from '../Transaction.js'
35
+ import * as tokenActions from './token.js'
36
+
37
+ const tip20AddressPrefix = '0x20c0'
38
+
39
+ /**
40
+ * Validates that a token can be used as a Tempo fee token.
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * import { createClient, http } from 'viem'
45
+ * import { tempo } from 'viem/chains'
46
+ * import { Actions } from 'viem/tempo'
47
+ *
48
+ * const client = createClient({
49
+ * chain: tempo,
50
+ * transport: http(),
51
+ * })
52
+ *
53
+ * const { address, metadata } = await Actions.fee.validateToken(client, {
54
+ * token: '0x20c0000000000000000000000000000000000001',
55
+ * })
56
+ * ```
57
+ *
58
+ * @param client - Client.
59
+ * @param parameters - Parameters.
60
+ * @returns The fee token address, ID, and metadata.
61
+ */
62
+ export async function validateToken<chain extends Chain | undefined>(
63
+ client: Client<Transport, chain>,
64
+ parameters: validateToken.Parameters,
65
+ ): Promise<validateToken.ReturnValue> {
66
+ const { token, ...rest } = parameters
67
+ const token_ = String(token)
68
+ const address = (() => {
69
+ try {
70
+ return TokenId.toAddress(token)
71
+ } catch (cause) {
72
+ throw new InvalidFeeTokenError({
73
+ cause: cause as BaseError | Error,
74
+ token: token_,
75
+ })
76
+ }
77
+ })()
78
+
79
+ if (!address.toLowerCase().startsWith(tip20AddressPrefix))
80
+ throw new FeeTokenNotTip20Error({ token: address })
81
+
82
+ const isPathUsd = address.toLowerCase() === Addresses.pathUsd.toLowerCase()
83
+ if (!isPathUsd) {
84
+ const isTip20 = await readContract(client, {
85
+ ...rest,
86
+ address: Addresses.tip20Factory,
87
+ abi: Abis.tip20Factory,
88
+ functionName: 'isTIP20',
89
+ args: [address],
90
+ }).catch((cause) => {
91
+ throw new InvalidFeeTokenError({
92
+ cause: cause as BaseError | Error,
93
+ token: address,
94
+ })
95
+ })
96
+ if (!isTip20) throw new FeeTokenNotTip20Error({ token: address })
97
+ }
98
+
99
+ const metadata = await tokenActions
100
+ .getMetadata(client, {
101
+ ...rest,
102
+ token: address,
103
+ })
104
+ .catch((cause) => {
105
+ throw new InvalidFeeTokenError({
106
+ cause: cause as BaseError | Error,
107
+ token: address,
108
+ })
109
+ })
110
+
111
+ if (metadata.currency !== 'USD')
112
+ throw new FeeTokenNotUsdError({
113
+ currency: metadata.currency,
114
+ token: address,
115
+ })
116
+ if (metadata.paused === true)
117
+ throw new FeeTokenPausedError({ token: address })
118
+
119
+ return {
120
+ address,
121
+ id: TokenId.fromAddress(address),
122
+ metadata,
123
+ }
124
+ }
125
+
126
+ export declare namespace validateToken {
127
+ export type Parameters = ReadParameters & {
128
+ /** Address or ID of the TIP20 token. */
129
+ token: TokenId.TokenIdOrAddress
130
+ }
131
+
132
+ export type ReturnValue = Compute<{
133
+ address: Address
134
+ id: bigint
135
+ metadata: tokenActions.getMetadata.ReturnValue
136
+ }>
137
+
138
+ export type ErrorType =
139
+ | FeeTokenNotTip20Error
140
+ | FeeTokenNotUsdError
141
+ | FeeTokenPausedError
142
+ | InvalidFeeTokenError
143
+ | BaseErrorType
144
+ }
29
145
 
30
146
  /**
31
147
  * Gets the user's default fee token.