viem 0.0.0-main.20240519T155930 → 0.0.0-main.20240519T233212

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 (223) hide show
  1. package/_cjs/celo/formatters.js +1 -10
  2. package/_cjs/celo/formatters.js.map +1 -1
  3. package/_cjs/celo/serializers.js +0 -25
  4. package/_cjs/celo/serializers.js.map +1 -1
  5. package/_cjs/celo/utils.js +2 -15
  6. package/_cjs/celo/utils.js.map +1 -1
  7. package/_cjs/errors/version.js +1 -1
  8. package/_cjs/zksync/actions/estimateFee.js +26 -0
  9. package/_cjs/zksync/actions/estimateFee.js.map +1 -0
  10. package/_cjs/zksync/actions/estimateGasL1ToL2.js +20 -0
  11. package/_cjs/zksync/actions/estimateGasL1ToL2.js.map +1 -0
  12. package/_cjs/zksync/actions/getAllBalances.js +19 -0
  13. package/_cjs/zksync/actions/getAllBalances.js.map +1 -0
  14. package/_cjs/zksync/actions/getBaseTokenL1Address.js +9 -0
  15. package/_cjs/zksync/actions/getBaseTokenL1Address.js.map +1 -0
  16. package/_cjs/zksync/actions/getBlockDetails.js +12 -0
  17. package/_cjs/zksync/actions/getBlockDetails.js.map +1 -0
  18. package/_cjs/zksync/actions/getBridgehubContractAddress.js +9 -0
  19. package/_cjs/zksync/actions/getBridgehubContractAddress.js.map +1 -0
  20. package/_cjs/zksync/actions/getDefaultBridgeAddresses.js +13 -0
  21. package/_cjs/zksync/actions/getDefaultBridgeAddresses.js.map +1 -0
  22. package/_cjs/zksync/actions/getL1BatchBlockRange.js +13 -0
  23. package/_cjs/zksync/actions/getL1BatchBlockRange.js.map +1 -0
  24. package/_cjs/zksync/actions/getL1BatchDetails.js +12 -0
  25. package/_cjs/zksync/actions/getL1BatchDetails.js.map +1 -0
  26. package/_cjs/zksync/actions/getL1BatchNumber.js +9 -0
  27. package/_cjs/zksync/actions/getL1BatchNumber.js.map +1 -0
  28. package/_cjs/zksync/actions/getL1ChainId.js +9 -0
  29. package/_cjs/zksync/actions/getL1ChainId.js.map +1 -0
  30. package/_cjs/zksync/actions/getLogProof.js +12 -0
  31. package/_cjs/zksync/actions/getLogProof.js.map +1 -0
  32. package/_cjs/zksync/actions/getMainContractAddress.js +9 -0
  33. package/_cjs/zksync/actions/getMainContractAddress.js.map +1 -0
  34. package/_cjs/zksync/actions/getRawBlockTransaction.js +13 -0
  35. package/_cjs/zksync/actions/getRawBlockTransaction.js.map +1 -0
  36. package/_cjs/zksync/actions/getTestnetPaymasterAddress.js +9 -0
  37. package/_cjs/zksync/actions/getTestnetPaymasterAddress.js.map +1 -0
  38. package/_cjs/zksync/actions/getTransactionDetails.js +12 -0
  39. package/_cjs/zksync/actions/getTransactionDetails.js.map +1 -0
  40. package/_cjs/zksync/decorators/publicL2.js +43 -0
  41. package/_cjs/zksync/decorators/publicL2.js.map +1 -0
  42. package/_cjs/zksync/index.js +33 -3
  43. package/_cjs/zksync/index.js.map +1 -1
  44. package/_cjs/zksync/types/eip1193.js +3 -0
  45. package/_cjs/zksync/types/eip1193.js.map +1 -0
  46. package/_cjs/zksync/types/proof.js +3 -0
  47. package/_cjs/zksync/types/proof.js.map +1 -0
  48. package/_cjs/zksync/utils/camelCaseKeys.js +17 -0
  49. package/_cjs/zksync/utils/camelCaseKeys.js.map +1 -0
  50. package/_cjs/zksync/utils/paymaster/getApprovalBasedPaymasterInput.js +4 -3
  51. package/_cjs/zksync/utils/paymaster/getApprovalBasedPaymasterInput.js.map +1 -1
  52. package/_cjs/zksync/utils/paymaster/getGeneralPaymasterInput.js +4 -3
  53. package/_cjs/zksync/utils/paymaster/getGeneralPaymasterInput.js.map +1 -1
  54. package/_esm/celo/formatters.js +2 -11
  55. package/_esm/celo/formatters.js.map +1 -1
  56. package/_esm/celo/serializers.js +1 -29
  57. package/_esm/celo/serializers.js.map +1 -1
  58. package/_esm/celo/utils.js +1 -15
  59. package/_esm/celo/utils.js.map +1 -1
  60. package/_esm/errors/version.js +1 -1
  61. package/_esm/zksync/actions/estimateFee.js +22 -0
  62. package/_esm/zksync/actions/estimateFee.js.map +1 -0
  63. package/_esm/zksync/actions/estimateGasL1ToL2.js +16 -0
  64. package/_esm/zksync/actions/estimateGasL1ToL2.js.map +1 -0
  65. package/_esm/zksync/actions/getAllBalances.js +15 -0
  66. package/_esm/zksync/actions/getAllBalances.js.map +1 -0
  67. package/_esm/zksync/actions/getBaseTokenL1Address.js +5 -0
  68. package/_esm/zksync/actions/getBaseTokenL1Address.js.map +1 -0
  69. package/_esm/zksync/actions/getBlockDetails.js +8 -0
  70. package/_esm/zksync/actions/getBlockDetails.js.map +1 -0
  71. package/_esm/zksync/actions/getBridgehubContractAddress.js +5 -0
  72. package/_esm/zksync/actions/getBridgehubContractAddress.js.map +1 -0
  73. package/_esm/zksync/actions/getDefaultBridgeAddresses.js +9 -0
  74. package/_esm/zksync/actions/getDefaultBridgeAddresses.js.map +1 -0
  75. package/_esm/zksync/actions/getL1BatchBlockRange.js +9 -0
  76. package/_esm/zksync/actions/getL1BatchBlockRange.js.map +1 -0
  77. package/_esm/zksync/actions/getL1BatchDetails.js +8 -0
  78. package/_esm/zksync/actions/getL1BatchDetails.js.map +1 -0
  79. package/_esm/zksync/actions/getL1BatchNumber.js +5 -0
  80. package/_esm/zksync/actions/getL1BatchNumber.js.map +1 -0
  81. package/_esm/zksync/actions/getL1ChainId.js +5 -0
  82. package/_esm/zksync/actions/getL1ChainId.js.map +1 -0
  83. package/_esm/zksync/actions/getLogProof.js +8 -0
  84. package/_esm/zksync/actions/getLogProof.js.map +1 -0
  85. package/_esm/zksync/actions/getMainContractAddress.js +5 -0
  86. package/_esm/zksync/actions/getMainContractAddress.js.map +1 -0
  87. package/_esm/zksync/actions/getRawBlockTransaction.js +9 -0
  88. package/_esm/zksync/actions/getRawBlockTransaction.js.map +1 -0
  89. package/_esm/zksync/actions/getTestnetPaymasterAddress.js +5 -0
  90. package/_esm/zksync/actions/getTestnetPaymasterAddress.js.map +1 -0
  91. package/_esm/zksync/actions/getTransactionDetails.js +8 -0
  92. package/_esm/zksync/actions/getTransactionDetails.js.map +1 -0
  93. package/_esm/zksync/decorators/publicL2.js +39 -0
  94. package/_esm/zksync/decorators/publicL2.js.map +1 -0
  95. package/_esm/zksync/index.js +16 -1
  96. package/_esm/zksync/index.js.map +1 -1
  97. package/_esm/zksync/types/eip1193.js +2 -0
  98. package/_esm/zksync/types/eip1193.js.map +1 -0
  99. package/_esm/zksync/types/proof.js +2 -0
  100. package/_esm/zksync/types/proof.js.map +1 -0
  101. package/_esm/zksync/utils/camelCaseKeys.js +13 -0
  102. package/_esm/zksync/utils/camelCaseKeys.js.map +1 -0
  103. package/_esm/zksync/utils/paymaster/getApprovalBasedPaymasterInput.js +2 -1
  104. package/_esm/zksync/utils/paymaster/getApprovalBasedPaymasterInput.js.map +1 -1
  105. package/_esm/zksync/utils/paymaster/getGeneralPaymasterInput.js +2 -1
  106. package/_esm/zksync/utils/paymaster/getGeneralPaymasterInput.js.map +1 -1
  107. package/_types/celo/chainConfig.d.ts +58 -526
  108. package/_types/celo/chainConfig.d.ts.map +1 -1
  109. package/_types/celo/formatters.d.ts +29 -263
  110. package/_types/celo/formatters.d.ts.map +1 -1
  111. package/_types/celo/index.d.ts +1 -1
  112. package/_types/celo/index.d.ts.map +1 -1
  113. package/_types/celo/serializers.d.ts +2 -3
  114. package/_types/celo/serializers.d.ts.map +1 -1
  115. package/_types/celo/types.d.ts +5 -29
  116. package/_types/celo/types.d.ts.map +1 -1
  117. package/_types/celo/utils.d.ts +1 -2
  118. package/_types/celo/utils.d.ts.map +1 -1
  119. package/_types/chains/definitions/celo.d.ts +58 -526
  120. package/_types/chains/definitions/celo.d.ts.map +1 -1
  121. package/_types/chains/definitions/celoAlfajores.d.ts +58 -526
  122. package/_types/chains/definitions/celoAlfajores.d.ts.map +1 -1
  123. package/_types/chains/definitions/lisk.d.ts +8 -8
  124. package/_types/chains/definitions/playfiAlbireo.d.ts +8 -8
  125. package/_types/chains/definitions/zkSync.d.ts +8 -8
  126. package/_types/chains/definitions/zkSyncInMemoryNode.d.ts +8 -8
  127. package/_types/chains/definitions/zkSyncLocalNode.d.ts +8 -8
  128. package/_types/chains/definitions/zkSyncSepoliaTestnet.d.ts +8 -8
  129. package/_types/chains/definitions/zkSyncTestnet.d.ts +8 -8
  130. package/_types/chains/index.d.ts +1 -1
  131. package/_types/chains/index.d.ts.map +1 -1
  132. package/_types/errors/version.d.ts +1 -1
  133. package/_types/zksync/actions/estimateFee.d.ts +11 -0
  134. package/_types/zksync/actions/estimateFee.d.ts.map +1 -0
  135. package/_types/zksync/actions/estimateGasL1ToL2.d.ts +10 -0
  136. package/_types/zksync/actions/estimateGasL1ToL2.d.ts.map +1 -0
  137. package/_types/zksync/actions/getAllBalances.d.ts +12 -0
  138. package/_types/zksync/actions/getAllBalances.d.ts.map +1 -0
  139. package/_types/zksync/actions/getBaseTokenL1Address.d.ts +9 -0
  140. package/_types/zksync/actions/getBaseTokenL1Address.d.ts.map +1 -0
  141. package/_types/zksync/actions/getBlockDetails.d.ts +10 -0
  142. package/_types/zksync/actions/getBlockDetails.d.ts.map +1 -0
  143. package/_types/zksync/actions/getBridgehubContractAddress.d.ts +9 -0
  144. package/_types/zksync/actions/getBridgehubContractAddress.d.ts.map +1 -0
  145. package/_types/zksync/actions/getDefaultBridgeAddresses.d.ts +9 -0
  146. package/_types/zksync/actions/getDefaultBridgeAddresses.d.ts.map +1 -0
  147. package/_types/zksync/actions/getL1BatchBlockRange.d.ts +11 -0
  148. package/_types/zksync/actions/getL1BatchBlockRange.d.ts.map +1 -0
  149. package/_types/zksync/actions/getL1BatchDetails.d.ts +10 -0
  150. package/_types/zksync/actions/getL1BatchDetails.d.ts.map +1 -0
  151. package/_types/zksync/actions/getL1BatchNumber.d.ts +9 -0
  152. package/_types/zksync/actions/getL1BatchNumber.d.ts.map +1 -0
  153. package/_types/zksync/actions/getL1ChainId.d.ts +9 -0
  154. package/_types/zksync/actions/getL1ChainId.d.ts.map +1 -0
  155. package/_types/zksync/actions/getLogProof.d.ts +14 -0
  156. package/_types/zksync/actions/getLogProof.d.ts.map +1 -0
  157. package/_types/zksync/actions/getMainContractAddress.d.ts +9 -0
  158. package/_types/zksync/actions/getMainContractAddress.d.ts.map +1 -0
  159. package/_types/zksync/actions/getRawBlockTransaction.d.ts +11 -0
  160. package/_types/zksync/actions/getRawBlockTransaction.d.ts.map +1 -0
  161. package/_types/zksync/actions/getTestnetPaymasterAddress.d.ts +9 -0
  162. package/_types/zksync/actions/getTestnetPaymasterAddress.d.ts.map +1 -0
  163. package/_types/zksync/actions/getTransactionDetails.d.ts +13 -0
  164. package/_types/zksync/actions/getTransactionDetails.d.ts.map +1 -0
  165. package/_types/zksync/chainConfig.d.ts +8 -8
  166. package/_types/zksync/decorators/publicL2.d.ts +318 -0
  167. package/_types/zksync/decorators/publicL2.d.ts.map +1 -0
  168. package/_types/zksync/formatters.d.ts +8 -8
  169. package/_types/zksync/index.d.ts +17 -2
  170. package/_types/zksync/index.d.ts.map +1 -1
  171. package/_types/zksync/types/block.d.ts +30 -1
  172. package/_types/zksync/types/block.d.ts.map +1 -1
  173. package/_types/zksync/types/contract.d.ts +6 -0
  174. package/_types/zksync/types/contract.d.ts.map +1 -1
  175. package/_types/zksync/types/eip1193.d.ts +152 -0
  176. package/_types/zksync/types/eip1193.d.ts.map +1 -0
  177. package/_types/zksync/types/fee.d.ts +6 -0
  178. package/_types/zksync/types/fee.d.ts.map +1 -1
  179. package/_types/zksync/types/proof.d.ts +7 -0
  180. package/_types/zksync/types/proof.d.ts.map +1 -0
  181. package/_types/zksync/types/transaction.d.ts +65 -5
  182. package/_types/zksync/types/transaction.d.ts.map +1 -1
  183. package/_types/zksync/utils/camelCaseKeys.d.ts +2 -0
  184. package/_types/zksync/utils/camelCaseKeys.d.ts.map +1 -0
  185. package/_types/zksync/utils/paymaster/getApprovalBasedPaymasterInput.d.ts +1 -1
  186. package/_types/zksync/utils/paymaster/getApprovalBasedPaymasterInput.d.ts.map +1 -1
  187. package/_types/zksync/utils/paymaster/getGeneralPaymasterInput.d.ts +1 -1
  188. package/_types/zksync/utils/paymaster/getGeneralPaymasterInput.d.ts.map +1 -1
  189. package/celo/formatters.ts +3 -11
  190. package/celo/index.ts +0 -2
  191. package/celo/serializers.ts +2 -50
  192. package/celo/types.ts +3 -38
  193. package/celo/utils.ts +1 -24
  194. package/chains/index.ts +0 -2
  195. package/errors/version.ts +1 -1
  196. package/package.json +1 -1
  197. package/zksync/actions/estimateFee.ts +46 -0
  198. package/zksync/actions/estimateGasL1ToL2.ts +38 -0
  199. package/zksync/actions/getAllBalances.ts +33 -0
  200. package/zksync/actions/getBaseTokenL1Address.ts +18 -0
  201. package/zksync/actions/getBlockDetails.ts +27 -0
  202. package/zksync/actions/getBridgehubContractAddress.ts +18 -0
  203. package/zksync/actions/getDefaultBridgeAddresses.ts +22 -0
  204. package/zksync/actions/getL1BatchBlockRange.ts +26 -0
  205. package/zksync/actions/getL1BatchDetails.ts +27 -0
  206. package/zksync/actions/getL1BatchNumber.ts +18 -0
  207. package/zksync/actions/getL1ChainId.ts +18 -0
  208. package/zksync/actions/getLogProof.ts +28 -0
  209. package/zksync/actions/getMainContractAddress.ts +18 -0
  210. package/zksync/actions/getRawBlockTransaction.ts +26 -0
  211. package/zksync/actions/getTestnetPaymasterAddress.ts +18 -0
  212. package/zksync/actions/getTransactionDetails.ts +27 -0
  213. package/zksync/decorators/publicL2.ts +425 -0
  214. package/zksync/index.ts +62 -6
  215. package/zksync/types/block.ts +37 -1
  216. package/zksync/types/contract.ts +8 -0
  217. package/zksync/types/eip1193.ts +155 -0
  218. package/zksync/types/fee.ts +7 -0
  219. package/zksync/types/proof.ts +7 -0
  220. package/zksync/types/transaction.ts +84 -10
  221. package/zksync/utils/camelCaseKeys.ts +11 -0
  222. package/zksync/utils/paymaster/getApprovalBasedPaymasterInput.ts +5 -2
  223. package/zksync/utils/paymaster/getGeneralPaymasterInput.ts +5 -2
@@ -0,0 +1,46 @@
1
+ import { parseAccount } from '../../accounts/utils/parseAccount.js'
2
+ import type { SendTransactionParameters } from '../../actions/wallet/sendTransaction.js'
3
+ import type { Client } from '../../clients/createClient.js'
4
+ import type { Transport } from '../../clients/transports/createTransport.js'
5
+ import type { Account } from '../../types/account.js'
6
+ import { hexToBigInt } from '../../utils/encoding/fromHex.js'
7
+ import type { ChainEIP712 } from '../types/chain.js'
8
+ import type { PublicZkSyncRpcSchema } from '../types/eip1193.js'
9
+ import type { ZkSyncFee } from '../types/fee.js'
10
+
11
+ export type EstimateFeeParameters<
12
+ chain extends ChainEIP712 | undefined = ChainEIP712 | undefined,
13
+ account extends Account | undefined = Account | undefined,
14
+ chainOverride extends ChainEIP712 | undefined = ChainEIP712 | undefined,
15
+ > = SendTransactionParameters<chain, account, chainOverride>
16
+
17
+ export type EstimateFeeReturnType = ZkSyncFee
18
+
19
+ export async function estimateFee<
20
+ chain extends ChainEIP712 | undefined,
21
+ account extends Account | undefined,
22
+ >(
23
+ client: Client<Transport, chain, account, PublicZkSyncRpcSchema>,
24
+ parameters: EstimateFeeParameters<chain, account>,
25
+ ): Promise<EstimateFeeReturnType> {
26
+ const { account: account_, ...request } = parameters
27
+ const account = account_ ? parseAccount(account_) : client.account
28
+
29
+ const formatters = client.chain?.formatters
30
+ const formatted = formatters?.transactionRequest?.format({
31
+ ...request,
32
+ from: account?.address,
33
+ })
34
+
35
+ const result = await client.request({
36
+ method: 'zks_estimateFee',
37
+ params: [formatted],
38
+ })
39
+
40
+ return {
41
+ gasLimit: hexToBigInt(result.gas_limit),
42
+ gasPerPubdataLimit: hexToBigInt(result.gas_per_pubdata_limit),
43
+ maxPriorityFeePerGas: hexToBigInt(result.max_priority_fee_per_gas),
44
+ maxFeePerGas: hexToBigInt(result.max_fee_per_gas),
45
+ }
46
+ }
@@ -0,0 +1,38 @@
1
+ import type { SendTransactionParameters } from '../../actions/wallet/sendTransaction.js'
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 { parseAccount } from '../../utils/accounts.js'
6
+ import type { ChainEIP712 } from '../types/chain.js'
7
+ import type { PublicZkSyncRpcSchema } from '../types/eip1193.js'
8
+
9
+ export type EstimateGasL1ToL2Parameters<
10
+ chain extends ChainEIP712 | undefined = ChainEIP712 | undefined,
11
+ account extends Account | undefined = Account | undefined,
12
+ > = SendTransactionParameters<chain, account>
13
+
14
+ export type EstimateGasL1ToL2ReturnType = bigint
15
+
16
+ export async function estimateGasL1ToL2<
17
+ chain extends ChainEIP712 | undefined,
18
+ account extends Account | undefined,
19
+ >(
20
+ client: Client<Transport, chain, account, PublicZkSyncRpcSchema>,
21
+ parameters: EstimateGasL1ToL2Parameters<chain, account>,
22
+ ): Promise<EstimateGasL1ToL2ReturnType> {
23
+ const { account: account_, ...request } = parameters
24
+ const account = account_ ? parseAccount(account_) : client.account
25
+
26
+ const formatters = client.chain?.formatters
27
+ const formatted = formatters?.transactionRequest?.format({
28
+ ...request,
29
+ from: account?.address,
30
+ })
31
+
32
+ const result = await client.request({
33
+ method: 'zks_estimateGasL1ToL2',
34
+ params: [formatted],
35
+ })
36
+
37
+ return result
38
+ }
@@ -0,0 +1,33 @@
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, GetAccountParameter } from '../../types/account.js'
5
+ import type { Chain } from '../../types/chain.js'
6
+ import { parseAccount } from '../../utils/accounts.js'
7
+ import { hexToBigInt } from '../../utils/encoding/fromHex.js'
8
+ import type { PublicZkSyncRpcSchema } from '../types/eip1193.js'
9
+
10
+ export type GetAllBalancesParameters<
11
+ TAccount extends Account | undefined = Account | undefined,
12
+ > = GetAccountParameter<TAccount>
13
+
14
+ export type GetAllBalancesReturnType = { [key: Address]: bigint }
15
+
16
+ export async function getAllBalances<
17
+ TChain extends Chain | undefined,
18
+ TAccount extends Account | undefined,
19
+ >(
20
+ client: Client<Transport, TChain, TAccount, PublicZkSyncRpcSchema>,
21
+ parameters: GetAllBalancesParameters<TAccount>,
22
+ ): Promise<GetAllBalancesReturnType> {
23
+ const { account: account_ } = parameters
24
+ const account = account_ ? parseAccount(account_) : client.account
25
+ const balances = await client.request({
26
+ method: 'zks_getAllAccountBalances',
27
+ params: [account!.address],
28
+ })
29
+ const convertedBalances: GetAllBalancesReturnType = {}
30
+ for (const token in balances)
31
+ (convertedBalances as any)[token] = hexToBigInt((balances as any)[token])
32
+ return convertedBalances
33
+ }
@@ -0,0 +1,18 @@
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 type { Chain } from '../../types/chain.js'
6
+ import type { PublicZkSyncRpcSchema } from '../types/eip1193.js'
7
+
8
+ export type GetBaseTokenL1AddressReturnType = Address
9
+
10
+ export async function getBaseTokenL1Address<
11
+ TChain extends Chain | undefined,
12
+ TAccount extends Account | undefined,
13
+ >(
14
+ client: Client<Transport, TChain, TAccount, PublicZkSyncRpcSchema>,
15
+ ): Promise<GetBaseTokenL1AddressReturnType> {
16
+ const result = await client.request({ method: 'zks_getBaseTokenL1Address' })
17
+ return result
18
+ }
@@ -0,0 +1,27 @@
1
+ import type { Client } from '../../clients/createClient.js'
2
+ import type { Transport } from '../../clients/transports/createTransport.js'
3
+ import type { Account } from '../../types/account.js'
4
+ import type { Chain } from '../../types/chain.js'
5
+ import type {
6
+ ZkSyncBlockDetails,
7
+ ZkSyncNumberParameter,
8
+ } from '../types/block.js'
9
+ import type { PublicZkSyncRpcSchema } from '../types/eip1193.js'
10
+
11
+ export type GetBlockDetailsParameters = ZkSyncNumberParameter
12
+
13
+ export type GetBlockDetailsReturnType = ZkSyncBlockDetails
14
+
15
+ export async function getBlockDetails<
16
+ TChain extends Chain | undefined,
17
+ TAccount extends Account | undefined,
18
+ >(
19
+ client: Client<Transport, TChain, TAccount, PublicZkSyncRpcSchema>,
20
+ parameters: GetBlockDetailsParameters,
21
+ ): Promise<GetBlockDetailsReturnType> {
22
+ const result = await client.request({
23
+ method: 'zks_getBlockDetails',
24
+ params: [parameters.number],
25
+ })
26
+ return result
27
+ }
@@ -0,0 +1,18 @@
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 type { Chain } from '../../types/chain.js'
6
+ import type { PublicZkSyncRpcSchema } from '../types/eip1193.js'
7
+
8
+ export type GetBridgehubContractAddressReturnType = Address
9
+
10
+ export async function getBridgehubContractAddress<
11
+ TChain extends Chain | undefined,
12
+ TAccount extends Account | undefined,
13
+ >(
14
+ client: Client<Transport, TChain, TAccount, PublicZkSyncRpcSchema>,
15
+ ): Promise<GetBridgehubContractAddressReturnType> {
16
+ const result = await client.request({ method: 'zks_getBridgehubContract' })
17
+ return result
18
+ }
@@ -0,0 +1,22 @@
1
+ import type { Client } from '../../clients/createClient.js'
2
+ import type { Transport } from '../../clients/transports/createTransport.js'
3
+ import type { Account } from '../../types/account.js'
4
+ import type { Chain } from '../../types/chain.js'
5
+ import type { BridgeContractAddresses } from '../types/contract.js'
6
+ import type { PublicZkSyncRpcSchema } from '../types/eip1193.js'
7
+
8
+ export type GetDefaultBridgeAddressesReturnType = BridgeContractAddresses
9
+
10
+ export async function getDefaultBridgeAddresses<
11
+ TChain extends Chain | undefined,
12
+ TAccount extends Account | undefined,
13
+ >(
14
+ client: Client<Transport, TChain, TAccount, PublicZkSyncRpcSchema>,
15
+ ): Promise<GetDefaultBridgeAddressesReturnType> {
16
+ const addresses = await client.request({ method: 'zks_getBridgeContracts' })
17
+ return {
18
+ erc20L1: addresses.l1Erc20DefaultBridge,
19
+ sharedL1: addresses.l1SharedDefaultBridge,
20
+ sharedL2: addresses.l2SharedDefaultBridge,
21
+ }
22
+ }
@@ -0,0 +1,26 @@
1
+ import type { Client } from '../../clients/createClient.js'
2
+ import type { Transport } from '../../clients/transports/createTransport.js'
3
+ import type { Account } from '../../types/account.js'
4
+ import type { Chain } from '../../types/chain.js'
5
+ import { hexToNumber } from '../../utils/encoding/fromHex.js'
6
+ import type { PublicZkSyncRpcSchema } from '../types/eip1193.js'
7
+
8
+ export type GetL1BatchBlockRangeParameters = {
9
+ l1BatchNumber: number
10
+ }
11
+
12
+ export type GetL1BatchBlockRangeReturnParameters = [number, number]
13
+
14
+ export async function getL1BatchBlockRange<
15
+ TChain extends Chain | undefined,
16
+ TAccount extends Account | undefined,
17
+ >(
18
+ client: Client<Transport, TChain, TAccount, PublicZkSyncRpcSchema>,
19
+ parameters: GetL1BatchBlockRangeParameters,
20
+ ): Promise<GetL1BatchBlockRangeReturnParameters> {
21
+ const [number_1, number_2] = await client.request({
22
+ method: 'zks_getL1BatchBlockRange',
23
+ params: [parameters.l1BatchNumber],
24
+ })
25
+ return [hexToNumber(number_1), hexToNumber(number_2)]
26
+ }
@@ -0,0 +1,27 @@
1
+ import type { Client } from '../../clients/createClient.js'
2
+ import type { Transport } from '../../clients/transports/createTransport.js'
3
+ import type { Account } from '../../types/account.js'
4
+ import type { Chain } from '../../types/chain.js'
5
+ import type {
6
+ ZkSyncBatchDetails,
7
+ ZkSyncNumberParameter,
8
+ } from '../types/block.js'
9
+ import type { PublicZkSyncRpcSchema } from '../types/eip1193.js'
10
+
11
+ export type GetL1BatchDetailsParameters = ZkSyncNumberParameter
12
+
13
+ export type GetL1BatchDetailsReturnType = ZkSyncBatchDetails
14
+
15
+ export async function getL1BatchDetails<
16
+ TChain extends Chain | undefined,
17
+ TAccount extends Account | undefined,
18
+ >(
19
+ client: Client<Transport, TChain, TAccount, PublicZkSyncRpcSchema>,
20
+ parameters: GetL1BatchDetailsParameters,
21
+ ): Promise<GetL1BatchDetailsReturnType> {
22
+ const result = await client.request({
23
+ method: 'zks_getL1BatchDetails',
24
+ params: [parameters.number],
25
+ })
26
+ return result
27
+ }
@@ -0,0 +1,18 @@
1
+ import type { Client } from '../../clients/createClient.js'
2
+ import type { Transport } from '../../clients/transports/createTransport.js'
3
+ import type { Account } from '../../types/account.js'
4
+ import type { Chain } from '../../types/chain.js'
5
+ import type { Hex } from '../../types/misc.js'
6
+ import type { PublicZkSyncRpcSchema } from '../types/eip1193.js'
7
+
8
+ export type GetL1BatchNumberReturnType = Hex
9
+
10
+ export async function getL1BatchNumber<
11
+ TChain extends Chain | undefined,
12
+ TAccount extends Account | undefined,
13
+ >(
14
+ client: Client<Transport, TChain, TAccount, PublicZkSyncRpcSchema>,
15
+ ): Promise<GetL1BatchNumberReturnType> {
16
+ const result = await client.request({ method: 'zks_L1BatchNumber' })
17
+ return result
18
+ }
@@ -0,0 +1,18 @@
1
+ import type { Client } from '../../clients/createClient.js'
2
+ import type { Transport } from '../../clients/transports/createTransport.js'
3
+ import type { Account } from '../../types/account.js'
4
+ import type { Chain } from '../../types/chain.js'
5
+ import type { Hex } from '../../types/misc.js'
6
+ import type { PublicZkSyncRpcSchema } from '../types/eip1193.js'
7
+
8
+ export type GetL1ChainIdReturnType = Hex
9
+
10
+ export async function getL1ChainId<
11
+ TChain extends Chain | undefined,
12
+ TAccount extends Account | undefined,
13
+ >(
14
+ client: Client<Transport, TChain, TAccount, PublicZkSyncRpcSchema>,
15
+ ): Promise<GetL1ChainIdReturnType> {
16
+ const result = await client.request({ method: 'zks_L1ChainId' })
17
+ return result
18
+ }
@@ -0,0 +1,28 @@
1
+ import type { Client } from '../../clients/createClient.js'
2
+ import type { Transport } from '../../clients/transports/createTransport.js'
3
+ import type { Account } from '../../types/account.js'
4
+ import type { Chain } from '../../types/chain.js'
5
+ import type { Hash } from '../../types/misc.js'
6
+ import type { PublicZkSyncRpcSchema } from '../types/eip1193.js'
7
+ import type { MessageProof } from '../types/proof.js'
8
+
9
+ export type GetLogProofParameters = {
10
+ txHash: Hash
11
+ index?: number | undefined
12
+ }
13
+
14
+ export type GetLogProofReturnType = MessageProof | null
15
+
16
+ export async function getLogProof<
17
+ TChain extends Chain | undefined,
18
+ TAccount extends Account | undefined,
19
+ >(
20
+ client: Client<Transport, TChain, TAccount, PublicZkSyncRpcSchema>,
21
+ parameters: GetLogProofParameters,
22
+ ): Promise<MessageProof | null> {
23
+ const result = await client.request({
24
+ method: 'zks_getL2ToL1LogProof',
25
+ params: [parameters.txHash, parameters.index],
26
+ })
27
+ return result
28
+ }
@@ -0,0 +1,18 @@
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 type { Chain } from '../../types/chain.js'
6
+ import type { PublicZkSyncRpcSchema } from '../types/eip1193.js'
7
+
8
+ export type GetMainContractAddressReturnType = Address
9
+
10
+ export async function getMainContractAddress<
11
+ TChain extends Chain | undefined,
12
+ TAccount extends Account | undefined,
13
+ >(
14
+ client: Client<Transport, TChain, TAccount, PublicZkSyncRpcSchema>,
15
+ ): Promise<GetMainContractAddressReturnType> {
16
+ const address = await client.request({ method: 'zks_getMainContract' })
17
+ return address
18
+ }
@@ -0,0 +1,26 @@
1
+ import type { Client } from '../../clients/createClient.js'
2
+ import type { Transport } from '../../clients/transports/createTransport.js'
3
+ import type { Account } from '../../types/account.js'
4
+ import type { Chain } from '../../types/chain.js'
5
+ import type { ZkSyncNumberParameter } from '../types/block.js'
6
+ import type { PublicZkSyncRpcSchema } from '../types/eip1193.js'
7
+ import type { ZkSyncRawBlockTransactions } from '../types/transaction.js'
8
+ import { camelCaseKeys } from '../utils/camelCaseKeys.js'
9
+
10
+ export type GetRawBlockTransactionParameters = ZkSyncNumberParameter
11
+
12
+ export type GetRawBlockTransactionReturnType = ZkSyncRawBlockTransactions
13
+
14
+ export async function getRawBlockTransactions<
15
+ TChain extends Chain | undefined,
16
+ TAccount extends Account | undefined,
17
+ >(
18
+ client: Client<Transport, TChain, TAccount, PublicZkSyncRpcSchema>,
19
+ parameters: GetRawBlockTransactionParameters,
20
+ ): Promise<GetRawBlockTransactionReturnType> {
21
+ const result = await client.request({
22
+ method: 'zks_getRawBlockTransactions',
23
+ params: [parameters.number],
24
+ })
25
+ return camelCaseKeys(result) as GetRawBlockTransactionReturnType
26
+ }
@@ -0,0 +1,18 @@
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 type { Chain } from '../../types/chain.js'
6
+ import type { PublicZkSyncRpcSchema } from '../types/eip1193.js'
7
+
8
+ export type GetTestnetPaymasterAddressReturnType = Address | null
9
+
10
+ export async function getTestnetPaymasterAddress<
11
+ TChain extends Chain | undefined,
12
+ TAccount extends Account | undefined,
13
+ >(
14
+ client: Client<Transport, TChain, TAccount, PublicZkSyncRpcSchema>,
15
+ ): Promise<GetTestnetPaymasterAddressReturnType> {
16
+ const result = await client.request({ method: 'zks_getTestnetPaymaster' })
17
+ return result
18
+ }
@@ -0,0 +1,27 @@
1
+ import type { Client } from '../../clients/createClient.js'
2
+ import type { Transport } from '../../clients/transports/createTransport.js'
3
+ import type { Account } from '../../types/account.js'
4
+ import type { Chain } from '../../types/chain.js'
5
+ import type { Hash } from '../../types/misc.js'
6
+ import type { PublicZkSyncRpcSchema } from '../types/eip1193.js'
7
+ import type { ZkSyncTransactionDetails } from '../types/transaction.js'
8
+
9
+ export type GetTransactionDetailsParameters = {
10
+ txHash: Hash
11
+ }
12
+
13
+ export type GetTransactionDetailsReturnType = ZkSyncTransactionDetails
14
+
15
+ export async function getTransactionDetails<
16
+ TChain extends Chain | undefined,
17
+ TAccount extends Account | undefined,
18
+ >(
19
+ client: Client<Transport, TChain, TAccount, PublicZkSyncRpcSchema>,
20
+ parameters: GetTransactionDetailsParameters,
21
+ ): Promise<GetTransactionDetailsReturnType> {
22
+ const result = await client.request({
23
+ method: 'zks_getTransactionDetails',
24
+ params: [parameters.txHash],
25
+ })
26
+ return result
27
+ }