viem 2.10.11 → 2.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (276) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/_cjs/celo/formatters.js +1 -10
  3. package/_cjs/celo/formatters.js.map +1 -1
  4. package/_cjs/celo/serializers.js +0 -25
  5. package/_cjs/celo/serializers.js.map +1 -1
  6. package/_cjs/celo/utils.js +2 -15
  7. package/_cjs/celo/utils.js.map +1 -1
  8. package/_cjs/errors/version.js +1 -1
  9. package/_cjs/errors/version.js.map +1 -1
  10. package/_cjs/zksync/actions/estimateFee.js +26 -0
  11. package/_cjs/zksync/actions/estimateFee.js.map +1 -0
  12. package/_cjs/zksync/actions/estimateGasL1ToL2.js +20 -0
  13. package/_cjs/zksync/actions/estimateGasL1ToL2.js.map +1 -0
  14. package/_cjs/zksync/actions/getAllBalances.js +19 -0
  15. package/_cjs/zksync/actions/getAllBalances.js.map +1 -0
  16. package/_cjs/zksync/actions/getBaseTokenL1Address.js +9 -0
  17. package/_cjs/zksync/actions/getBaseTokenL1Address.js.map +1 -0
  18. package/_cjs/zksync/actions/getBlockDetails.js +12 -0
  19. package/_cjs/zksync/actions/getBlockDetails.js.map +1 -0
  20. package/_cjs/zksync/actions/getBridgehubContractAddress.js +9 -0
  21. package/_cjs/zksync/actions/getBridgehubContractAddress.js.map +1 -0
  22. package/_cjs/zksync/actions/getDefaultBridgeAddresses.js +13 -0
  23. package/_cjs/zksync/actions/getDefaultBridgeAddresses.js.map +1 -0
  24. package/_cjs/zksync/actions/getL1Allowance.js +19 -0
  25. package/_cjs/zksync/actions/getL1Allowance.js.map +1 -0
  26. package/_cjs/zksync/actions/getL1Balance.js +23 -0
  27. package/_cjs/zksync/actions/getL1Balance.js.map +1 -0
  28. package/_cjs/zksync/actions/getL1BatchBlockRange.js +13 -0
  29. package/_cjs/zksync/actions/getL1BatchBlockRange.js.map +1 -0
  30. package/_cjs/zksync/actions/getL1BatchDetails.js +12 -0
  31. package/_cjs/zksync/actions/getL1BatchDetails.js.map +1 -0
  32. package/_cjs/zksync/actions/getL1BatchNumber.js +9 -0
  33. package/_cjs/zksync/actions/getL1BatchNumber.js.map +1 -0
  34. package/_cjs/zksync/actions/getL1ChainId.js +9 -0
  35. package/_cjs/zksync/actions/getL1ChainId.js.map +1 -0
  36. package/_cjs/zksync/actions/getL1TokenBalance.js +24 -0
  37. package/_cjs/zksync/actions/getL1TokenBalance.js.map +1 -0
  38. package/_cjs/zksync/actions/getLogProof.js +12 -0
  39. package/_cjs/zksync/actions/getLogProof.js.map +1 -0
  40. package/_cjs/zksync/actions/getMainContractAddress.js +9 -0
  41. package/_cjs/zksync/actions/getMainContractAddress.js.map +1 -0
  42. package/_cjs/zksync/actions/getRawBlockTransactions.js +13 -0
  43. package/_cjs/zksync/actions/getRawBlockTransactions.js.map +1 -0
  44. package/_cjs/zksync/actions/getTestnetPaymasterAddress.js +9 -0
  45. package/_cjs/zksync/actions/getTestnetPaymasterAddress.js.map +1 -0
  46. package/_cjs/zksync/actions/getTransactionDetails.js +12 -0
  47. package/_cjs/zksync/actions/getTransactionDetails.js.map +1 -0
  48. package/_cjs/zksync/constants/address.js +4 -1
  49. package/_cjs/zksync/constants/address.js.map +1 -1
  50. package/_cjs/zksync/decorators/publicL1.js +15 -0
  51. package/_cjs/zksync/decorators/publicL1.js.map +1 -0
  52. package/_cjs/zksync/decorators/publicL2.js +43 -0
  53. package/_cjs/zksync/decorators/publicL2.js.map +1 -0
  54. package/_cjs/zksync/errors/token-is-eth.js +17 -0
  55. package/_cjs/zksync/errors/token-is-eth.js.map +1 -0
  56. package/_cjs/zksync/index.js +41 -3
  57. package/_cjs/zksync/index.js.map +1 -1
  58. package/_cjs/zksync/types/eip1193.js +3 -0
  59. package/_cjs/zksync/types/eip1193.js.map +1 -0
  60. package/_cjs/zksync/types/proof.js +3 -0
  61. package/_cjs/zksync/types/proof.js.map +1 -0
  62. package/_cjs/zksync/utils/camelCaseKeys.js +17 -0
  63. package/_cjs/zksync/utils/camelCaseKeys.js.map +1 -0
  64. package/_cjs/zksync/utils/isEth.js +17 -0
  65. package/_cjs/zksync/utils/isEth.js.map +1 -0
  66. package/_cjs/zksync/utils/paymaster/getApprovalBasedPaymasterInput.js +4 -3
  67. package/_cjs/zksync/utils/paymaster/getApprovalBasedPaymasterInput.js.map +1 -1
  68. package/_cjs/zksync/utils/paymaster/getGeneralPaymasterInput.js +4 -3
  69. package/_cjs/zksync/utils/paymaster/getGeneralPaymasterInput.js.map +1 -1
  70. package/_esm/celo/formatters.js +2 -11
  71. package/_esm/celo/formatters.js.map +1 -1
  72. package/_esm/celo/serializers.js +1 -29
  73. package/_esm/celo/serializers.js.map +1 -1
  74. package/_esm/celo/utils.js +1 -15
  75. package/_esm/celo/utils.js.map +1 -1
  76. package/_esm/errors/version.js +1 -1
  77. package/_esm/errors/version.js.map +1 -1
  78. package/_esm/zksync/actions/estimateFee.js +22 -0
  79. package/_esm/zksync/actions/estimateFee.js.map +1 -0
  80. package/_esm/zksync/actions/estimateGasL1ToL2.js +16 -0
  81. package/_esm/zksync/actions/estimateGasL1ToL2.js.map +1 -0
  82. package/_esm/zksync/actions/getAllBalances.js +15 -0
  83. package/_esm/zksync/actions/getAllBalances.js.map +1 -0
  84. package/_esm/zksync/actions/getBaseTokenL1Address.js +5 -0
  85. package/_esm/zksync/actions/getBaseTokenL1Address.js.map +1 -0
  86. package/_esm/zksync/actions/getBlockDetails.js +8 -0
  87. package/_esm/zksync/actions/getBlockDetails.js.map +1 -0
  88. package/_esm/zksync/actions/getBridgehubContractAddress.js +5 -0
  89. package/_esm/zksync/actions/getBridgehubContractAddress.js.map +1 -0
  90. package/_esm/zksync/actions/getDefaultBridgeAddresses.js +9 -0
  91. package/_esm/zksync/actions/getDefaultBridgeAddresses.js.map +1 -0
  92. package/_esm/zksync/actions/getL1Allowance.js +15 -0
  93. package/_esm/zksync/actions/getL1Allowance.js.map +1 -0
  94. package/_esm/zksync/actions/getL1Balance.js +19 -0
  95. package/_esm/zksync/actions/getL1Balance.js.map +1 -0
  96. package/_esm/zksync/actions/getL1BatchBlockRange.js +9 -0
  97. package/_esm/zksync/actions/getL1BatchBlockRange.js.map +1 -0
  98. package/_esm/zksync/actions/getL1BatchDetails.js +8 -0
  99. package/_esm/zksync/actions/getL1BatchDetails.js.map +1 -0
  100. package/_esm/zksync/actions/getL1BatchNumber.js +5 -0
  101. package/_esm/zksync/actions/getL1BatchNumber.js.map +1 -0
  102. package/_esm/zksync/actions/getL1ChainId.js +5 -0
  103. package/_esm/zksync/actions/getL1ChainId.js.map +1 -0
  104. package/_esm/zksync/actions/getL1TokenBalance.js +20 -0
  105. package/_esm/zksync/actions/getL1TokenBalance.js.map +1 -0
  106. package/_esm/zksync/actions/getLogProof.js +8 -0
  107. package/_esm/zksync/actions/getLogProof.js.map +1 -0
  108. package/_esm/zksync/actions/getMainContractAddress.js +5 -0
  109. package/_esm/zksync/actions/getMainContractAddress.js.map +1 -0
  110. package/_esm/zksync/actions/getRawBlockTransactions.js +9 -0
  111. package/_esm/zksync/actions/getRawBlockTransactions.js.map +1 -0
  112. package/_esm/zksync/actions/getTestnetPaymasterAddress.js +5 -0
  113. package/_esm/zksync/actions/getTestnetPaymasterAddress.js.map +1 -0
  114. package/_esm/zksync/actions/getTransactionDetails.js +8 -0
  115. package/_esm/zksync/actions/getTransactionDetails.js.map +1 -0
  116. package/_esm/zksync/constants/address.js +3 -0
  117. package/_esm/zksync/constants/address.js.map +1 -1
  118. package/_esm/zksync/decorators/publicL1.js +12 -0
  119. package/_esm/zksync/decorators/publicL1.js.map +1 -0
  120. package/_esm/zksync/decorators/publicL2.js +39 -0
  121. package/_esm/zksync/decorators/publicL2.js.map +1 -0
  122. package/_esm/zksync/errors/token-is-eth.js +13 -0
  123. package/_esm/zksync/errors/token-is-eth.js.map +1 -0
  124. package/_esm/zksync/index.js +20 -1
  125. package/_esm/zksync/index.js.map +1 -1
  126. package/_esm/zksync/types/eip1193.js +2 -0
  127. package/_esm/zksync/types/eip1193.js.map +1 -0
  128. package/_esm/zksync/types/proof.js +2 -0
  129. package/_esm/zksync/types/proof.js.map +1 -0
  130. package/_esm/zksync/utils/camelCaseKeys.js +13 -0
  131. package/_esm/zksync/utils/camelCaseKeys.js.map +1 -0
  132. package/_esm/zksync/utils/isEth.js +13 -0
  133. package/_esm/zksync/utils/isEth.js.map +1 -0
  134. package/_esm/zksync/utils/paymaster/getApprovalBasedPaymasterInput.js +2 -1
  135. package/_esm/zksync/utils/paymaster/getApprovalBasedPaymasterInput.js.map +1 -1
  136. package/_esm/zksync/utils/paymaster/getGeneralPaymasterInput.js +2 -1
  137. package/_esm/zksync/utils/paymaster/getGeneralPaymasterInput.js.map +1 -1
  138. package/_types/celo/chainConfig.d.ts +58 -526
  139. package/_types/celo/chainConfig.d.ts.map +1 -1
  140. package/_types/celo/formatters.d.ts +29 -263
  141. package/_types/celo/formatters.d.ts.map +1 -1
  142. package/_types/celo/index.d.ts +1 -1
  143. package/_types/celo/index.d.ts.map +1 -1
  144. package/_types/celo/serializers.d.ts +2 -3
  145. package/_types/celo/serializers.d.ts.map +1 -1
  146. package/_types/celo/types.d.ts +5 -29
  147. package/_types/celo/types.d.ts.map +1 -1
  148. package/_types/celo/utils.d.ts +1 -2
  149. package/_types/celo/utils.d.ts.map +1 -1
  150. package/_types/chains/definitions/celo.d.ts +58 -526
  151. package/_types/chains/definitions/celo.d.ts.map +1 -1
  152. package/_types/chains/definitions/celoAlfajores.d.ts +58 -526
  153. package/_types/chains/definitions/celoAlfajores.d.ts.map +1 -1
  154. package/_types/chains/definitions/lisk.d.ts +8 -8
  155. package/_types/chains/definitions/playfiAlbireo.d.ts +8 -8
  156. package/_types/chains/definitions/zkSync.d.ts +8 -8
  157. package/_types/chains/definitions/zkSyncInMemoryNode.d.ts +8 -8
  158. package/_types/chains/definitions/zkSyncLocalNode.d.ts +8 -8
  159. package/_types/chains/definitions/zkSyncSepoliaTestnet.d.ts +8 -8
  160. package/_types/chains/definitions/zkSyncTestnet.d.ts +8 -8
  161. package/_types/chains/index.d.ts +1 -1
  162. package/_types/chains/index.d.ts.map +1 -1
  163. package/_types/errors/version.d.ts +1 -1
  164. package/_types/errors/version.d.ts.map +1 -1
  165. package/_types/zksync/actions/estimateFee.d.ts +11 -0
  166. package/_types/zksync/actions/estimateFee.d.ts.map +1 -0
  167. package/_types/zksync/actions/estimateGasL1ToL2.d.ts +10 -0
  168. package/_types/zksync/actions/estimateGasL1ToL2.d.ts.map +1 -0
  169. package/_types/zksync/actions/getAllBalances.d.ts +12 -0
  170. package/_types/zksync/actions/getAllBalances.d.ts.map +1 -0
  171. package/_types/zksync/actions/getBaseTokenL1Address.d.ts +9 -0
  172. package/_types/zksync/actions/getBaseTokenL1Address.d.ts.map +1 -0
  173. package/_types/zksync/actions/getBlockDetails.d.ts +10 -0
  174. package/_types/zksync/actions/getBlockDetails.d.ts.map +1 -0
  175. package/_types/zksync/actions/getBridgehubContractAddress.d.ts +9 -0
  176. package/_types/zksync/actions/getBridgehubContractAddress.d.ts.map +1 -0
  177. package/_types/zksync/actions/getDefaultBridgeAddresses.d.ts +9 -0
  178. package/_types/zksync/actions/getDefaultBridgeAddresses.d.ts.map +1 -0
  179. package/_types/zksync/actions/getL1Allowance.d.ts +17 -0
  180. package/_types/zksync/actions/getL1Allowance.d.ts.map +1 -0
  181. package/_types/zksync/actions/getL1Balance.d.ts +23 -0
  182. package/_types/zksync/actions/getL1Balance.d.ts.map +1 -0
  183. package/_types/zksync/actions/getL1BatchBlockRange.d.ts +11 -0
  184. package/_types/zksync/actions/getL1BatchBlockRange.d.ts.map +1 -0
  185. package/_types/zksync/actions/getL1BatchDetails.d.ts +10 -0
  186. package/_types/zksync/actions/getL1BatchDetails.d.ts.map +1 -0
  187. package/_types/zksync/actions/getL1BatchNumber.d.ts +9 -0
  188. package/_types/zksync/actions/getL1BatchNumber.d.ts.map +1 -0
  189. package/_types/zksync/actions/getL1ChainId.d.ts +9 -0
  190. package/_types/zksync/actions/getL1ChainId.d.ts.map +1 -0
  191. package/_types/zksync/actions/getL1TokenBalance.d.ts +24 -0
  192. package/_types/zksync/actions/getL1TokenBalance.d.ts.map +1 -0
  193. package/_types/zksync/actions/getLogProof.d.ts +14 -0
  194. package/_types/zksync/actions/getLogProof.d.ts.map +1 -0
  195. package/_types/zksync/actions/getMainContractAddress.d.ts +9 -0
  196. package/_types/zksync/actions/getMainContractAddress.d.ts.map +1 -0
  197. package/_types/zksync/actions/getRawBlockTransactions.d.ts +11 -0
  198. package/_types/zksync/actions/getRawBlockTransactions.d.ts.map +1 -0
  199. package/_types/zksync/actions/getTestnetPaymasterAddress.d.ts +9 -0
  200. package/_types/zksync/actions/getTestnetPaymasterAddress.d.ts.map +1 -0
  201. package/_types/zksync/actions/getTransactionDetails.d.ts +13 -0
  202. package/_types/zksync/actions/getTransactionDetails.d.ts.map +1 -0
  203. package/_types/zksync/chainConfig.d.ts +8 -8
  204. package/_types/zksync/constants/address.d.ts +3 -0
  205. package/_types/zksync/constants/address.d.ts.map +1 -1
  206. package/_types/zksync/decorators/publicL1.d.ts +145 -0
  207. package/_types/zksync/decorators/publicL1.d.ts.map +1 -0
  208. package/_types/zksync/decorators/publicL2.d.ts +322 -0
  209. package/_types/zksync/decorators/publicL2.d.ts.map +1 -0
  210. package/_types/zksync/errors/token-is-eth.d.ts +9 -0
  211. package/_types/zksync/errors/token-is-eth.d.ts.map +1 -0
  212. package/_types/zksync/formatters.d.ts +8 -8
  213. package/_types/zksync/index.d.ts +21 -2
  214. package/_types/zksync/index.d.ts.map +1 -1
  215. package/_types/zksync/types/block.d.ts +30 -1
  216. package/_types/zksync/types/block.d.ts.map +1 -1
  217. package/_types/zksync/types/contract.d.ts +6 -0
  218. package/_types/zksync/types/contract.d.ts.map +1 -1
  219. package/_types/zksync/types/eip1193.d.ts +152 -0
  220. package/_types/zksync/types/eip1193.d.ts.map +1 -0
  221. package/_types/zksync/types/fee.d.ts +6 -0
  222. package/_types/zksync/types/fee.d.ts.map +1 -1
  223. package/_types/zksync/types/proof.d.ts +7 -0
  224. package/_types/zksync/types/proof.d.ts.map +1 -0
  225. package/_types/zksync/types/transaction.d.ts +65 -5
  226. package/_types/zksync/types/transaction.d.ts.map +1 -1
  227. package/_types/zksync/utils/camelCaseKeys.d.ts +2 -0
  228. package/_types/zksync/utils/camelCaseKeys.d.ts.map +1 -0
  229. package/_types/zksync/utils/isEth.d.ts +3 -0
  230. package/_types/zksync/utils/isEth.d.ts.map +1 -0
  231. package/_types/zksync/utils/paymaster/getApprovalBasedPaymasterInput.d.ts +1 -1
  232. package/_types/zksync/utils/paymaster/getApprovalBasedPaymasterInput.d.ts.map +1 -1
  233. package/_types/zksync/utils/paymaster/getGeneralPaymasterInput.d.ts +1 -1
  234. package/_types/zksync/utils/paymaster/getGeneralPaymasterInput.d.ts.map +1 -1
  235. package/celo/formatters.ts +3 -11
  236. package/celo/index.ts +0 -2
  237. package/celo/serializers.ts +2 -50
  238. package/celo/types.ts +3 -38
  239. package/celo/utils.ts +1 -24
  240. package/chains/index.ts +0 -2
  241. package/errors/version.ts +1 -1
  242. package/package.json +1 -1
  243. package/zksync/actions/estimateFee.ts +46 -0
  244. package/zksync/actions/estimateGasL1ToL2.ts +38 -0
  245. package/zksync/actions/getAllBalances.ts +33 -0
  246. package/zksync/actions/getBaseTokenL1Address.ts +18 -0
  247. package/zksync/actions/getBlockDetails.ts +27 -0
  248. package/zksync/actions/getBridgehubContractAddress.ts +18 -0
  249. package/zksync/actions/getDefaultBridgeAddresses.ts +22 -0
  250. package/zksync/actions/getL1Allowance.ts +43 -0
  251. package/zksync/actions/getL1Balance.ts +68 -0
  252. package/zksync/actions/getL1BatchBlockRange.ts +26 -0
  253. package/zksync/actions/getL1BatchDetails.ts +27 -0
  254. package/zksync/actions/getL1BatchNumber.ts +18 -0
  255. package/zksync/actions/getL1ChainId.ts +18 -0
  256. package/zksync/actions/getL1TokenBalance.ts +63 -0
  257. package/zksync/actions/getLogProof.ts +28 -0
  258. package/zksync/actions/getMainContractAddress.ts +18 -0
  259. package/zksync/actions/getRawBlockTransactions.ts +26 -0
  260. package/zksync/actions/getTestnetPaymasterAddress.ts +18 -0
  261. package/zksync/actions/getTransactionDetails.ts +27 -0
  262. package/zksync/constants/address.ts +9 -0
  263. package/zksync/decorators/publicL1.ts +180 -0
  264. package/zksync/decorators/publicL2.ts +443 -0
  265. package/zksync/errors/token-is-eth.ts +16 -0
  266. package/zksync/index.ts +85 -6
  267. package/zksync/types/block.ts +37 -1
  268. package/zksync/types/contract.ts +8 -0
  269. package/zksync/types/eip1193.ts +155 -0
  270. package/zksync/types/fee.ts +7 -0
  271. package/zksync/types/proof.ts +7 -0
  272. package/zksync/types/transaction.ts +84 -10
  273. package/zksync/utils/camelCaseKeys.ts +11 -0
  274. package/zksync/utils/isEth.ts +20 -0
  275. package/zksync/utils/paymaster/getApprovalBasedPaymasterInput.ts +5 -2
  276. package/zksync/utils/paymaster/getGeneralPaymasterInput.ts +5 -2
@@ -0,0 +1,443 @@
1
+ import type { Address } from 'abitype'
2
+ import type { Client } from '../../clients/createClient.js'
3
+ import type { Transport } from '../../clients/transports/createTransport.js'
4
+ import type { Account } from '../../types/account.js'
5
+ import { estimateFee } from '../actions/estimateFee.js'
6
+ import type {
7
+ EstimateFeeParameters,
8
+ EstimateFeeReturnType,
9
+ } from '../actions/estimateFee.js'
10
+ import {
11
+ type EstimateGasL1ToL2Parameters,
12
+ type EstimateGasL1ToL2ReturnType,
13
+ estimateGasL1ToL2,
14
+ } from '../actions/estimateGasL1ToL2.js'
15
+ import {
16
+ type GetAllBalancesParameters,
17
+ type GetAllBalancesReturnType,
18
+ getAllBalances,
19
+ } from '../actions/getAllBalances.js'
20
+ import {
21
+ type GetBaseTokenL1AddressReturnType,
22
+ getBaseTokenL1Address,
23
+ } from '../actions/getBaseTokenL1Address.js'
24
+ import {
25
+ type GetBlockDetailsParameters,
26
+ type GetBlockDetailsReturnType,
27
+ getBlockDetails,
28
+ } from '../actions/getBlockDetails.js'
29
+ import {
30
+ type GetBridgehubContractAddressReturnType,
31
+ getBridgehubContractAddress,
32
+ } from '../actions/getBridgehubContractAddress.js'
33
+ import {
34
+ type GetDefaultBridgeAddressesReturnType,
35
+ getDefaultBridgeAddresses,
36
+ } from '../actions/getDefaultBridgeAddresses.js'
37
+ import {
38
+ type GetL1BatchBlockRangeParameters,
39
+ type GetL1BatchBlockRangeReturnParameters,
40
+ getL1BatchBlockRange,
41
+ } from '../actions/getL1BatchBlockRange.js'
42
+ import {
43
+ type GetL1BatchDetailsParameters,
44
+ type GetL1BatchDetailsReturnType,
45
+ getL1BatchDetails,
46
+ } from '../actions/getL1BatchDetails.js'
47
+ import {
48
+ type GetL1BatchNumberReturnType,
49
+ getL1BatchNumber,
50
+ } from '../actions/getL1BatchNumber.js'
51
+ import {
52
+ type GetL1ChainIdReturnType,
53
+ getL1ChainId,
54
+ } from '../actions/getL1ChainId.js'
55
+ import {
56
+ type GetLogProofParameters,
57
+ type GetLogProofReturnType,
58
+ getLogProof,
59
+ } from '../actions/getLogProof.js'
60
+ import {
61
+ type GetMainContractAddressReturnType,
62
+ getMainContractAddress,
63
+ } from '../actions/getMainContractAddress.js'
64
+ import {
65
+ type GetRawBlockTransactionsParameters,
66
+ type GetRawBlockTransactionsReturnType,
67
+ getRawBlockTransactions,
68
+ } from '../actions/getRawBlockTransactions.js'
69
+ import {
70
+ type GetTestnetPaymasterAddressReturnType,
71
+ getTestnetPaymasterAddress,
72
+ } from '../actions/getTestnetPaymasterAddress.js'
73
+ import {
74
+ type GetTransactionDetailsParameters,
75
+ type GetTransactionDetailsReturnType,
76
+ getTransactionDetails,
77
+ } from '../actions/getTransactionDetails.js'
78
+ import type { ChainEIP712 } from '../types/chain.js'
79
+
80
+ export type PublicActionsL2<
81
+ TChain extends ChainEIP712 | undefined = ChainEIP712 | undefined,
82
+ TAccount extends Account | undefined = Account | undefined,
83
+ > = {
84
+ /**
85
+ * Returns the addresses of the default zkSync Era bridge contracts on both L1 and L2.
86
+ *
87
+ * @returns The Addresses of the default zkSync Era bridge contracts on both L1 and L2. {@link DefaultBridgeAddressesReturnType}
88
+ *
89
+ * @example
90
+ * import { createPublicClient, http } from 'viem'
91
+ * import { zkSyncLocalNode } from 'viem/chains'
92
+ * import { publicActionsL2 } from 'viem/zksync'
93
+ *
94
+ * const client = createPublicClient({
95
+ * chain: zkSyncLocalNode,
96
+ * transport: http(),
97
+ * }).extend(publicActionsL2())
98
+ *
99
+ * const addresses = await client.getDefaultBridgeAddresses();
100
+ */
101
+ getDefaultBridgeAddresses: () => Promise<GetDefaultBridgeAddressesReturnType>
102
+
103
+ /**
104
+ * Returns Testnet Paymaster Address.
105
+ *
106
+ * @returns The Address. {@link Address}
107
+ *
108
+ * @example
109
+ * import { createPublicClient, http } from 'viem'
110
+ * import { zkSyncLocalNode } from 'viem/chains'
111
+ * import { publicActionsL2 } from 'viem/zksync'
112
+ *
113
+ * const client = createPublicClient({
114
+ * chain: zkSyncLocalNode,
115
+ * transport: http(),
116
+ * }).extend(publicActionsL2())
117
+ *
118
+ * const address = await client.getTestnetPaymasterAddress();
119
+ */
120
+ getTestnetPaymasterAddress: () => Promise<GetTestnetPaymasterAddressReturnType>
121
+
122
+ /**
123
+ * Returns the Chain Id of underlying L1 network.
124
+ *
125
+ * @returns number
126
+ *
127
+ * @example
128
+ * import { createPublicClient, http } from 'viem'
129
+ * import { zkSyncLocalNode } from 'viem/chains'
130
+ * import { publicActionsL2 } from 'viem/zksync'
131
+ *
132
+ * const client = createPublicClient({
133
+ * chain: zkSyncLocalNode,
134
+ * transport: http(),
135
+ * }).extend(publicActionsL2())
136
+ *
137
+ * const chainId = await client.getL1ChainId();
138
+ */
139
+
140
+ getL1ChainId: () => Promise<GetL1ChainIdReturnType>
141
+
142
+ /**
143
+ * Returns the address of a Main zkSync Contract.
144
+ *
145
+ * @returns The Address. {@link Address}
146
+ *
147
+ * @example
148
+ * import { createPublicClient, http } from 'viem'
149
+ * import { zkSyncLocalNode } from 'viem/chains'
150
+ * import { publicActionsL2 } from 'viem/zksync'
151
+ *
152
+ * const client = createPublicClient({
153
+ * chain: zkSyncLocalNode,
154
+ * transport: http(),
155
+ * }).extend(publicActionsL2())
156
+ *
157
+ * const address = await client.getMainContractAddress();
158
+ */
159
+ getMainContractAddress: () => Promise<GetMainContractAddressReturnType>
160
+
161
+ /**
162
+ * Returns all known balances for a given account.
163
+ *
164
+ * @returns The balances for a given account. {@link GetAllBalancesReturnType}
165
+ * @param args - {@link GetAllBalancesParameters}
166
+ *
167
+ * @example
168
+ * import { createPublicClient, http } from 'viem'
169
+ * import { zkSyncLocalNode } from 'viem/chains'
170
+ * import { publicActionsL2 } from 'viem/zksync'
171
+ *
172
+ * const client = createPublicClient({
173
+ * chain: zkSyncLocalNode,
174
+ * transport: http(),
175
+ * }).extend(publicActionsL2())
176
+ *
177
+ * const balances = await client.getAllBalances({account: "0x36615Cf349d7F6344891B1e7CA7C72883F5dc049"});
178
+ */
179
+ getAllBalances: (
180
+ args: GetAllBalancesParameters,
181
+ ) => Promise<GetAllBalancesReturnType>
182
+
183
+ /**
184
+ * Returns data of transactions in a block.
185
+ *
186
+ * @returns data of transactions {@link RawBlockTransactions}
187
+ * @param args - {@link GetRawBlockTransactionsParameters}
188
+ *
189
+ * @example
190
+ * import { createPublicClient, http } from 'viem'
191
+ * import { zkSyncLocalNode } from 'viem/chains'
192
+ * import { publicActionsL2 } from 'viem/zksync'
193
+ *
194
+ * const client = createPublicClient({
195
+ * chain: zkSyncLocalNode,
196
+ * transport: http(),
197
+ * }).extend(publicActionsL2())
198
+ *
199
+ * const rawTx = await client.getRawBlockTransaction({number: 1});
200
+ */
201
+ getRawBlockTransaction: (
202
+ args: GetRawBlockTransactionsParameters,
203
+ ) => Promise<GetRawBlockTransactionsReturnType>
204
+
205
+ /**
206
+ * Returns additional zkSync-specific information about the L2 block.
207
+ *
208
+ * @returns zkSync-specific information about the L2 block {@link BaseBlockDetails}
209
+ * @param args - {@link GetBlockDetailsParameters}
210
+ *
211
+ * @example
212
+ * import { createPublicClient, http } from 'viem'
213
+ * import { zkSyncLocalNode } from 'viem/chains'
214
+ * import { publicActionsL2 } from 'viem/zksync'
215
+ *
216
+ * const client = createPublicClient({
217
+ * chain: zkSyncLocalNode,
218
+ * transport: http(),
219
+ * }).extend(publicActionsL2())
220
+ *
221
+ * const blockDetails = await client.getBlockDetails({number: 1});
222
+ */
223
+ getBlockDetails: (
224
+ args: GetBlockDetailsParameters,
225
+ ) => Promise<GetBlockDetailsReturnType>
226
+
227
+ /**
228
+ * Returns data pertaining to a given batch.
229
+ *
230
+ * @returns data pertaining to a given batch {@link BatchDetails}
231
+ * @param args - {@link GetL1BatchDetailsParameters}
232
+ *
233
+ * @example
234
+ * import { createPublicClient, http } from 'viem'
235
+ * import { zkSyncLocalNode } from 'viem/chains'
236
+ * import { publicActionsL2 } from 'viem/zksync'
237
+ *
238
+ * const client = createPublicClient({
239
+ * chain: zkSyncLocalNode,
240
+ * transport: http(),
241
+ * }).extend(publicActionsL2())
242
+ *
243
+ * const batchDetails = await client.getL1BatchDetails({number: 1});
244
+ */
245
+ getL1BatchDetails: (
246
+ args: GetL1BatchDetailsParameters,
247
+ ) => Promise<GetL1BatchDetailsReturnType>
248
+
249
+ /**
250
+ * Returns the range of blocks contained within a batch given by batch number.
251
+ *
252
+ * @returns range of blocks contained withing a batch {@link GetL1BatchBlockRangeReturnParameters}
253
+ * @param args - {@link GetL1BatchBlockRangeParameters}
254
+ *
255
+ * @example
256
+ * import { createPublicClient, http } from 'viem'
257
+ * import { zkSyncLocalNode } from 'viem/chains'
258
+ * import { publicActionsL2 } from 'viem/zksync'
259
+ *
260
+ * const client = createPublicClient({
261
+ * chain: zkSyncLocalNode,
262
+ * transport: http(),
263
+ * }).extend(publicActionsL2())
264
+ *
265
+ * const batchBlockRange = await client.getL1BatchBlockRange({number: 1});
266
+ */
267
+ getL1BatchBlockRange: (
268
+ args: GetL1BatchBlockRangeParameters,
269
+ ) => Promise<GetL1BatchBlockRangeReturnParameters>
270
+
271
+ /**
272
+ * Returns the latest L1 batch number
273
+ *
274
+ * @returns latest L1 batch number
275
+ *
276
+ * @example
277
+ * import { createPublicClient, http } from 'viem'
278
+ * import { zkSyncLocalNode } from 'viem/chains'
279
+ * import { publicActionsL2 } from 'viem/zksync'
280
+ *
281
+ * const client = createPublicClient({
282
+ * chain: zkSyncLocalNode,
283
+ * transport: http(),
284
+ * }).extend(publicActionsL2())
285
+ *
286
+ * const latestNumber = await client.getL1BatchNumber({number: 1});
287
+ */
288
+ getL1BatchNumber: () => Promise<GetL1BatchNumberReturnType>
289
+
290
+ /**
291
+ * Given a transaction hash, and an index of the L2 to L1 log produced within the transaction, it returns the proof for the corresponding L2 to L1 log.
292
+ *
293
+ * @returns the proof for the corresponding L2 to L1 log.
294
+ *
295
+ * @example
296
+ * import { createPublicClient, http } from 'viem'
297
+ * import { zkSyncLocalNode } from 'viem/chains'
298
+ * import { publicActionsL2 } from 'viem/zksync'
299
+ *
300
+ * const client = createPublicClient({
301
+ * chain: zkSyncLocalNode,
302
+ * transport: http(),
303
+ * }).extend(publicActionsL2())
304
+ *
305
+ * const proof = await client.getLogProof({txHash: "0x...",index:1});
306
+ */
307
+ getLogProof: (args: GetLogProofParameters) => Promise<GetLogProofReturnType>
308
+
309
+ /**
310
+ * Returns data from a specific transaction given by the transaction hash
311
+ *
312
+ * @returns data from a specific transaction given by the transaction hash
313
+ *
314
+ *
315
+ * @example
316
+ * import { createPublicClient, http } from 'viem'
317
+ * import { zkSyncLocalNode } from 'viem/chains'
318
+ * import { publicActionsL2 } from 'viem/zksync'
319
+ *
320
+ * const client = createPublicClient({
321
+ * chain: zkSyncLocalNode,
322
+ * transport: http(),
323
+ * }).extend(publicActionsL2())
324
+ *
325
+ * const details = await client.getTransactionDetails({txHash: "0x..."});
326
+ */
327
+ getTransactionDetails: (
328
+ args: GetTransactionDetailsParameters,
329
+ ) => Promise<GetTransactionDetailsReturnType>
330
+
331
+ /**
332
+ * Returns an estimated Fee for requested transaction.
333
+ *
334
+ * @returns an estimated {@link Fee} for requested transaction.
335
+ * @param args - {@link EstimateFeeParameters}
336
+ *
337
+ * @example
338
+ * import { createPublicClient, http } from 'viem'
339
+ * import { zkSyncLocalNode } from 'viem/chains'
340
+ * import { publicActionsL2 } from 'viem/zksync'
341
+ *
342
+ * const client = createPublicClient({
343
+ * chain: zkSyncLocalNode,
344
+ * transport: http(),
345
+ * }).extend(publicActionsL2())
346
+ *
347
+ * const details = await client.estimateFee({transactionRequest: {...}}});
348
+ */
349
+ estimateFee: (
350
+ args: EstimateFeeParameters<TChain, TAccount>,
351
+ ) => Promise<EstimateFeeReturnType>
352
+
353
+ /**
354
+ * Returns an estimated gas for L1 to L2 execution.
355
+ *
356
+ * @returns an estimated gas.
357
+ * @param args - {@link EstimateGasL1ToL2Parameters}
358
+ *
359
+ * @example
360
+ * import { createPublicClient, http } from 'viem'
361
+ * import { zkSyncLocalNode } from 'viem/chains'
362
+ * import { publicActionsL2 } from 'viem/zksync'
363
+ *
364
+ * const client = createPublicClient({
365
+ * chain: zkSyncLocalNode,
366
+ * transport: http(),
367
+ * }).extend(publicActionsL2())
368
+ *
369
+ * const details = await client.estimateGasL1ToL2({transactionRequest: {...}}});
370
+ */
371
+ estimateGasL1ToL2: (
372
+ args: EstimateGasL1ToL2Parameters<TChain, TAccount>,
373
+ ) => Promise<EstimateGasL1ToL2ReturnType>
374
+
375
+ /**
376
+ * Returns the Bridgehub smart contract address.
377
+ *
378
+ * @returns address of the Bridgehub smart contract address.
379
+ *
380
+ *
381
+ * @example
382
+ * import { createPublicClient, http } from 'viem'
383
+ * import { zkSyncLocalNode } from 'viem/chains'
384
+ * import { publicActionsL2 } from 'viem/zksync'
385
+ *
386
+ * const client = createPublicClient({
387
+ * chain: zkSyncLocalNode,
388
+ * transport: http(),
389
+ * }).extend(publicActionsL2())
390
+ *
391
+ * const address = await client.getBridgehubContractAddress();
392
+ */
393
+ getBridgehubContractAddress: () => Promise<GetBridgehubContractAddressReturnType>
394
+
395
+ /**
396
+ * Returns the address of the base L1 token.
397
+ *
398
+ * @returns address of the base L1 token.
399
+ *
400
+ *
401
+ * @example
402
+ * import { createPublicClient, http } from 'viem'
403
+ * import { zkSyncLocalNode } from 'viem/chains'
404
+ * import { publicActionsL2 } from 'viem/zksync'
405
+ *
406
+ * const client = createPublicClient({
407
+ * chain: zkSyncLocalNode,
408
+ * transport: http(),
409
+ * }).extend(publicActionsL2())
410
+ *
411
+ * const address = await client.getBaseTokenL1Address();
412
+ */
413
+ getBaseTokenL1Address: () => Promise<GetBaseTokenL1AddressReturnType>
414
+ }
415
+
416
+ export function publicActionsL2() {
417
+ return <
418
+ TTransport extends Transport = Transport,
419
+ TChain extends ChainEIP712 | undefined = ChainEIP712 | undefined,
420
+ TAccount extends Account | undefined = Account | undefined,
421
+ >(
422
+ client: Client<TTransport, TChain, TAccount>,
423
+ ): PublicActionsL2<TChain, TAccount> => {
424
+ return {
425
+ estimateGasL1ToL2: (args) => estimateGasL1ToL2(client, args),
426
+ getDefaultBridgeAddresses: () => getDefaultBridgeAddresses(client),
427
+ getTestnetPaymasterAddress: () => getTestnetPaymasterAddress(client),
428
+ getL1ChainId: () => getL1ChainId(client),
429
+ getMainContractAddress: () => getMainContractAddress(client),
430
+ getAllBalances: (args) => getAllBalances(client, args),
431
+ getRawBlockTransaction: (args) => getRawBlockTransactions(client, args),
432
+ getBlockDetails: (args) => getBlockDetails(client, args),
433
+ getL1BatchDetails: (args) => getL1BatchDetails(client, args),
434
+ getL1BatchBlockRange: (args) => getL1BatchBlockRange(client, args),
435
+ getL1BatchNumber: () => getL1BatchNumber(client),
436
+ getLogProof: (args) => getLogProof(client, args),
437
+ getTransactionDetails: (args) => getTransactionDetails(client, args),
438
+ estimateFee: (args) => estimateFee(client, args),
439
+ getBridgehubContractAddress: () => getBridgehubContractAddress(client),
440
+ getBaseTokenL1Address: () => getBaseTokenL1Address(client),
441
+ }
442
+ }
443
+ }
@@ -0,0 +1,16 @@
1
+ import { BaseError } from '../../errors/base.js'
2
+
3
+ export type TokenIsEthErrorType = TokenIsEthError & {
4
+ name: 'TokenIsEthError'
5
+ }
6
+ export class TokenIsEthError extends BaseError {
7
+ override name = 'TokenIsEthError'
8
+
9
+ constructor() {
10
+ super(
11
+ ['Token is an ETH token.', '', 'ETH token cannot be retrived.'].join(
12
+ '\n',
13
+ ),
14
+ )
15
+ }
16
+ }
package/zksync/index.ts CHANGED
@@ -1,3 +1,76 @@
1
+ export {
2
+ type DeployContractErrorType,
3
+ type DeployContractParameters,
4
+ type DeployContractReturnType,
5
+ deployContract,
6
+ } from './actions/deployContract.js'
7
+ export {
8
+ type EstimateFeeParameters,
9
+ type EstimateFeeReturnType,
10
+ estimateFee,
11
+ } from './actions/estimateFee.js'
12
+ export {
13
+ type GetAllBalancesParameters,
14
+ type GetAllBalancesReturnType,
15
+ getAllBalances,
16
+ } from './actions/getAllBalances.js'
17
+ export {
18
+ type GetBlockDetailsParameters,
19
+ type GetBlockDetailsReturnType,
20
+ getBlockDetails,
21
+ } from './actions/getBlockDetails.js'
22
+ export {
23
+ type GetDefaultBridgeAddressesReturnType,
24
+ getDefaultBridgeAddresses,
25
+ } from './actions/getDefaultBridgeAddresses.js'
26
+ export { getBridgehubContractAddress } from './actions/getBridgehubContractAddress.js'
27
+ export {
28
+ type GetL1AllowanceErrorType,
29
+ type GetL1AllowanceParameters,
30
+ type GetL1AllowanceReturnType,
31
+ getL1Allowance,
32
+ } from './actions/getL1Allowance.js'
33
+ export {
34
+ type GetL1BalanceErrorType,
35
+ type GetL1BalanceParameters,
36
+ type GetL1BalanceReturnType,
37
+ getL1Balance,
38
+ } from './actions/getL1Balance.js'
39
+ export {
40
+ type GetL1BatchBlockRangeParameters,
41
+ type GetL1BatchBlockRangeReturnParameters,
42
+ getL1BatchBlockRange,
43
+ } from './actions/getL1BatchBlockRange.js'
44
+ export {
45
+ type GetL1BatchDetailsParameters,
46
+ type GetL1BatchDetailsReturnType,
47
+ getL1BatchDetails,
48
+ } from './actions/getL1BatchDetails.js'
49
+ export { getL1BatchNumber } from './actions/getL1BatchNumber.js'
50
+ export { getL1ChainId } from './actions/getL1ChainId.js'
51
+ export {
52
+ type GetL1TokenBalanceErrorType,
53
+ type GetL1TokenBalanceParameters,
54
+ type GetL1TokenBalanceReturnType,
55
+ getL1TokenBalance,
56
+ } from './actions/getL1TokenBalance.js'
57
+ export {
58
+ type GetLogProofReturnType,
59
+ type GetLogProofParameters,
60
+ getLogProof,
61
+ } from './actions/getLogProof.js'
62
+ export { getMainContractAddress } from './actions/getMainContractAddress.js'
63
+ export {
64
+ type GetRawBlockTransactionsParameters,
65
+ type GetRawBlockTransactionsReturnType,
66
+ getRawBlockTransactions,
67
+ } from './actions/getRawBlockTransactions.js'
68
+ export { getTestnetPaymasterAddress } from './actions/getTestnetPaymasterAddress.js'
69
+ export {
70
+ type GetTransactionDetailsParameters,
71
+ type GetTransactionDetailsReturnType,
72
+ getTransactionDetails,
73
+ } from './actions/getTransactionDetails.js'
1
74
  export {
2
75
  type SendTransactionErrorType,
3
76
  type SendTransactionParameters,
@@ -22,12 +95,6 @@ export {
22
95
  type SignTransactionReturnType,
23
96
  signTransaction,
24
97
  } from './actions/signTransaction.js'
25
- export {
26
- type DeployContractErrorType,
27
- type DeployContractParameters,
28
- type DeployContractReturnType,
29
- deployContract,
30
- } from './actions/deployContract.js'
31
98
 
32
99
  export {
33
100
  zkSync,
@@ -42,6 +109,16 @@ export {
42
109
  type Eip712WalletActions,
43
110
  } from './decorators/eip712.js'
44
111
 
112
+ export {
113
+ publicActionsL1,
114
+ type PublicActionsL1,
115
+ } from './decorators/publicL1.js'
116
+
117
+ export {
118
+ publicActionsL2,
119
+ type PublicActionsL2,
120
+ } from './decorators/publicL2.js'
121
+
45
122
  export { serializeTransaction } from './serializers.js'
46
123
 
47
124
  export type {
@@ -66,6 +143,7 @@ export type {
66
143
  export type {
67
144
  TransactionRequestEIP712,
68
145
  ZkSyncEIP712TransactionSignable,
146
+ ZkSyncRawBlockTransactions,
69
147
  ZkSyncRpcTransaction,
70
148
  ZkSyncRpcTransactionEIP712,
71
149
  ZkSyncRpcTransactionPriority,
@@ -83,6 +161,7 @@ export type {
83
161
  ZkSyncTransactionSerialized,
84
162
  ZkSyncTransactionSerializedEIP712,
85
163
  ZkSyncTransactionType,
164
+ ZkSyncTransactionDetails,
86
165
  } from './types/transaction.js'
87
166
 
88
167
  export {
@@ -1,8 +1,17 @@
1
+ import type { Address } from 'abitype'
1
2
  import type { Block, BlockTag } from '../../types/block.js'
2
- import type { Hex } from '../../types/misc.js'
3
+ import type { Hash, Hex } from '../../types/misc.js'
3
4
  import type { RpcBlock } from '../../types/rpc.js'
4
5
  import type { ZkSyncRpcTransaction, ZkSyncTransaction } from './transaction.js'
5
6
 
7
+ export type ZkSyncBatchDetails = Omit<
8
+ ZkSyncBlockDetails,
9
+ 'operatorAddress' | 'protocolVersion'
10
+ > & {
11
+ l1GasPrice: number
12
+ l2FairGasPrice: number
13
+ }
14
+
6
15
  export type ZkSyncBlockOverrides = {
7
16
  l1BatchNumber: bigint | null
8
17
  l1BatchTimestamp: bigint | null
@@ -19,10 +28,33 @@ export type ZkSyncBlock<
19
28
  > &
20
29
  ZkSyncBlockOverrides
21
30
 
31
+ export type ZkSyncBlockDetails = {
32
+ number: number
33
+ timestamp: number
34
+ l1BatchNumber: number
35
+ l1TxCount: number
36
+ l2TxCount: number
37
+ rootHash?: Hash
38
+ status: string
39
+ commitTxHash?: Hash
40
+ committedAt?: Date
41
+ proveTxHash?: Hash
42
+ provenAt?: Date
43
+ executeTxHash?: Hash
44
+ executedAt?: Date
45
+ baseSystemContractsHashes: {
46
+ bootloader: Hash
47
+ default_aa: Hash
48
+ }
49
+ operatorAddress: Address
50
+ protocolVersion?: string
51
+ }
52
+
22
53
  export type ZkSyncRpcBlockOverrides = {
23
54
  l1BatchNumber: Hex | null
24
55
  l1BatchTimestamp: Hex | null
25
56
  }
57
+
26
58
  export type ZkSyncRpcBlock<
27
59
  TBlockTag extends BlockTag = BlockTag,
28
60
  TIncludeTransactions extends boolean = boolean,
@@ -32,3 +64,7 @@ export type ZkSyncRpcBlock<
32
64
  ZkSyncRpcTransaction<TBlockTag extends 'pending' ? true : false>
33
65
  > &
34
66
  ZkSyncRpcBlockOverrides
67
+
68
+ export type ZkSyncNumberParameter = {
69
+ number: number
70
+ }
@@ -1,3 +1,11 @@
1
+ import type { Address } from 'abitype'
2
+
3
+ export type BridgeContractAddresses = {
4
+ erc20L1: Address
5
+ sharedL1: Address
6
+ sharedL2: Address
7
+ }
8
+
1
9
  export type ContractDeploymentType =
2
10
  | 'create'
3
11
  | 'create2'