viem 0.0.0-main.20240322T015814 → 0.0.0-main.20240324T211636

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 (222) hide show
  1. package/_cjs/chains/definitions/optimismSepolia.js +5 -0
  2. package/_cjs/chains/definitions/optimismSepolia.js.map +1 -1
  3. package/_cjs/chains/opStack/abis.js +1070 -1
  4. package/_cjs/chains/opStack/abis.js.map +1 -1
  5. package/_cjs/chains/opStack/actions/buildProveWithdrawal.js +3 -3
  6. package/_cjs/chains/opStack/actions/buildProveWithdrawal.js.map +1 -1
  7. package/_cjs/chains/opStack/actions/getGame.js +20 -0
  8. package/_cjs/chains/opStack/actions/getGame.js.map +1 -0
  9. package/_cjs/chains/opStack/actions/getGames.js +56 -0
  10. package/_cjs/chains/opStack/actions/getGames.js.map +1 -0
  11. package/_cjs/chains/opStack/actions/getL2Output.js +12 -0
  12. package/_cjs/chains/opStack/actions/getL2Output.js.map +1 -1
  13. package/_cjs/chains/opStack/actions/getPortalVersion.js +25 -0
  14. package/_cjs/chains/opStack/actions/getPortalVersion.js.map +1 -0
  15. package/_cjs/chains/opStack/actions/getTimeToFinalize.js +52 -26
  16. package/_cjs/chains/opStack/actions/getTimeToFinalize.js.map +1 -1
  17. package/_cjs/chains/opStack/actions/getTimeToNextGame.js +45 -0
  18. package/_cjs/chains/opStack/actions/getTimeToNextGame.js.map +1 -0
  19. package/_cjs/chains/opStack/actions/getTimeToProve.js +9 -1
  20. package/_cjs/chains/opStack/actions/getTimeToProve.js.map +1 -1
  21. package/_cjs/chains/opStack/actions/getWithdrawalStatus.js +79 -28
  22. package/_cjs/chains/opStack/actions/getWithdrawalStatus.js.map +1 -1
  23. package/_cjs/chains/opStack/actions/proveWithdrawal.js +1 -1
  24. package/_cjs/chains/opStack/actions/proveWithdrawal.js.map +1 -1
  25. package/_cjs/chains/opStack/actions/waitForNextGame.js +35 -0
  26. package/_cjs/chains/opStack/actions/waitForNextGame.js.map +1 -0
  27. package/_cjs/chains/opStack/actions/waitForNextL2Output.js.map +1 -1
  28. package/_cjs/chains/opStack/actions/waitToProve.js +34 -3
  29. package/_cjs/chains/opStack/actions/waitToProve.js.map +1 -1
  30. package/_cjs/chains/opStack/decorators/publicL1.js +10 -0
  31. package/_cjs/chains/opStack/decorators/publicL1.js.map +1 -1
  32. package/_cjs/chains/opStack/errors/withdrawal.js +13 -1
  33. package/_cjs/chains/opStack/errors/withdrawal.js.map +1 -1
  34. package/_cjs/chains/opStack/index.js +11 -1
  35. package/_cjs/chains/opStack/index.js.map +1 -1
  36. package/_cjs/chains/zksync/actions/deployContract.js +26 -0
  37. package/_cjs/chains/zksync/actions/deployContract.js.map +1 -0
  38. package/_cjs/chains/zksync/constants/abis.js +427 -0
  39. package/_cjs/chains/zksync/constants/abis.js.map +1 -0
  40. package/_cjs/chains/zksync/constants/address.js +5 -0
  41. package/_cjs/chains/zksync/constants/address.js.map +1 -0
  42. package/_cjs/chains/zksync/constants/contract.js +6 -0
  43. package/_cjs/chains/zksync/constants/contract.js.map +1 -0
  44. package/_cjs/chains/zksync/constants/number.js +6 -0
  45. package/_cjs/chains/zksync/constants/number.js.map +1 -0
  46. package/_cjs/chains/zksync/decorators/eip712.js +2 -0
  47. package/_cjs/chains/zksync/decorators/eip712.js.map +1 -1
  48. package/_cjs/chains/zksync/errors/bytecode.js +41 -0
  49. package/_cjs/chains/zksync/errors/bytecode.js.map +1 -0
  50. package/_cjs/chains/zksync/formatters.js +5 -1
  51. package/_cjs/chains/zksync/formatters.js.map +1 -1
  52. package/_cjs/chains/zksync/index.js +3 -1
  53. package/_cjs/chains/zksync/index.js.map +1 -1
  54. package/_cjs/chains/zksync/types/contract.js +3 -0
  55. package/_cjs/chains/zksync/types/contract.js.map +1 -0
  56. package/_cjs/chains/zksync/utils/abi/encodeDeployData.js +68 -0
  57. package/_cjs/chains/zksync/utils/abi/encodeDeployData.js.map +1 -0
  58. package/_cjs/chains/zksync/utils/getEip712Domain.js +4 -2
  59. package/_cjs/chains/zksync/utils/getEip712Domain.js.map +1 -1
  60. package/_cjs/chains/zksync/utils/hashBytecode.js +36 -0
  61. package/_cjs/chains/zksync/utils/hashBytecode.js.map +1 -0
  62. package/_cjs/errors/version.js +1 -1
  63. package/_esm/chains/definitions/optimismSepolia.js +5 -0
  64. package/_esm/chains/definitions/optimismSepolia.js.map +1 -1
  65. package/_esm/chains/opStack/abis.js +1069 -0
  66. package/_esm/chains/opStack/abis.js.map +1 -1
  67. package/_esm/chains/opStack/actions/buildProveWithdrawal.js +4 -3
  68. package/_esm/chains/opStack/actions/buildProveWithdrawal.js.map +1 -1
  69. package/_esm/chains/opStack/actions/getGame.js +40 -0
  70. package/_esm/chains/opStack/actions/getGame.js.map +1 -0
  71. package/_esm/chains/opStack/actions/getGames.js +75 -0
  72. package/_esm/chains/opStack/actions/getGames.js.map +1 -0
  73. package/_esm/chains/opStack/actions/getL2Output.js +12 -0
  74. package/_esm/chains/opStack/actions/getL2Output.js.map +1 -1
  75. package/_esm/chains/opStack/actions/getPortalVersion.js +48 -0
  76. package/_esm/chains/opStack/actions/getPortalVersion.js.map +1 -0
  77. package/_esm/chains/opStack/actions/getTimeToFinalize.js +54 -27
  78. package/_esm/chains/opStack/actions/getTimeToFinalize.js.map +1 -1
  79. package/_esm/chains/opStack/actions/getTimeToNextGame.js +71 -0
  80. package/_esm/chains/opStack/actions/getTimeToNextGame.js.map +1 -0
  81. package/_esm/chains/opStack/actions/getTimeToProve.js +10 -1
  82. package/_esm/chains/opStack/actions/getTimeToProve.js.map +1 -1
  83. package/_esm/chains/opStack/actions/getWithdrawalStatus.js +84 -32
  84. package/_esm/chains/opStack/actions/getWithdrawalStatus.js.map +1 -1
  85. package/_esm/chains/opStack/actions/proveWithdrawal.js +1 -1
  86. package/_esm/chains/opStack/actions/proveWithdrawal.js.map +1 -1
  87. package/_esm/chains/opStack/actions/waitForNextGame.js +61 -0
  88. package/_esm/chains/opStack/actions/waitForNextGame.js.map +1 -0
  89. package/_esm/chains/opStack/actions/waitForNextL2Output.js.map +1 -1
  90. package/_esm/chains/opStack/actions/waitToProve.js +35 -3
  91. package/_esm/chains/opStack/actions/waitToProve.js.map +1 -1
  92. package/_esm/chains/opStack/decorators/publicL1.js +10 -0
  93. package/_esm/chains/opStack/decorators/publicL1.js.map +1 -1
  94. package/_esm/chains/opStack/errors/withdrawal.js +11 -0
  95. package/_esm/chains/opStack/errors/withdrawal.js.map +1 -1
  96. package/_esm/chains/opStack/index.js +5 -0
  97. package/_esm/chains/opStack/index.js.map +1 -1
  98. package/_esm/chains/zksync/actions/deployContract.js +52 -0
  99. package/_esm/chains/zksync/actions/deployContract.js.map +1 -0
  100. package/_esm/chains/zksync/constants/abis.js +425 -0
  101. package/_esm/chains/zksync/constants/abis.js.map +1 -0
  102. package/_esm/chains/zksync/constants/address.js +2 -0
  103. package/_esm/chains/zksync/constants/address.js.map +1 -0
  104. package/_esm/chains/zksync/constants/contract.js +3 -0
  105. package/_esm/chains/zksync/constants/contract.js.map +1 -0
  106. package/_esm/chains/zksync/constants/number.js +3 -0
  107. package/_esm/chains/zksync/constants/number.js.map +1 -0
  108. package/_esm/chains/zksync/decorators/eip712.js +2 -0
  109. package/_esm/chains/zksync/decorators/eip712.js.map +1 -1
  110. package/_esm/chains/zksync/errors/bytecode.js +35 -0
  111. package/_esm/chains/zksync/errors/bytecode.js.map +1 -0
  112. package/_esm/chains/zksync/formatters.js +5 -1
  113. package/_esm/chains/zksync/formatters.js.map +1 -1
  114. package/_esm/chains/zksync/index.js +1 -0
  115. package/_esm/chains/zksync/index.js.map +1 -1
  116. package/_esm/chains/zksync/types/contract.js +2 -0
  117. package/_esm/chains/zksync/types/contract.js.map +1 -0
  118. package/_esm/chains/zksync/utils/abi/encodeDeployData.js +65 -0
  119. package/_esm/chains/zksync/utils/abi/encodeDeployData.js.map +1 -0
  120. package/_esm/chains/zksync/utils/getEip712Domain.js +4 -2
  121. package/_esm/chains/zksync/utils/getEip712Domain.js.map +1 -1
  122. package/_esm/chains/zksync/utils/hashBytecode.js +36 -0
  123. package/_esm/chains/zksync/utils/hashBytecode.js.map +1 -0
  124. package/_esm/errors/version.js +1 -1
  125. package/_types/chains/definitions/optimismSepolia.d.ts +5 -0
  126. package/_types/chains/definitions/optimismSepolia.d.ts.map +1 -1
  127. package/_types/chains/opStack/abis.d.ts +824 -0
  128. package/_types/chains/opStack/abis.d.ts.map +1 -1
  129. package/_types/chains/opStack/actions/buildProveWithdrawal.d.ts +6 -2
  130. package/_types/chains/opStack/actions/buildProveWithdrawal.d.ts.map +1 -1
  131. package/_types/chains/opStack/actions/getGame.d.ts +57 -0
  132. package/_types/chains/opStack/actions/getGame.d.ts.map +1 -0
  133. package/_types/chains/opStack/actions/getGames.d.ts +48 -0
  134. package/_types/chains/opStack/actions/getGames.d.ts.map +1 -0
  135. package/_types/chains/opStack/actions/getL2Output.d.ts +8 -1
  136. package/_types/chains/opStack/actions/getL2Output.d.ts.map +1 -1
  137. package/_types/chains/opStack/actions/getPortalVersion.d.ts +46 -0
  138. package/_types/chains/opStack/actions/getPortalVersion.d.ts.map +1 -0
  139. package/_types/chains/opStack/actions/getTimeToFinalize.d.ts.map +1 -1
  140. package/_types/chains/opStack/actions/getTimeToNextGame.d.ts +61 -0
  141. package/_types/chains/opStack/actions/getTimeToNextGame.d.ts.map +1 -0
  142. package/_types/chains/opStack/actions/getTimeToProve.d.ts +6 -3
  143. package/_types/chains/opStack/actions/getTimeToProve.d.ts.map +1 -1
  144. package/_types/chains/opStack/actions/getWithdrawalStatus.d.ts +7 -1
  145. package/_types/chains/opStack/actions/getWithdrawalStatus.d.ts.map +1 -1
  146. package/_types/chains/opStack/actions/proveWithdrawal.d.ts +1 -1
  147. package/_types/chains/opStack/actions/proveWithdrawal.d.ts.map +1 -1
  148. package/_types/chains/opStack/actions/waitForNextGame.d.ts +60 -0
  149. package/_types/chains/opStack/actions/waitForNextGame.d.ts.map +1 -0
  150. package/_types/chains/opStack/actions/waitForNextL2Output.d.ts.map +1 -1
  151. package/_types/chains/opStack/actions/waitToProve.d.ts +10 -2
  152. package/_types/chains/opStack/actions/waitToProve.d.ts.map +1 -1
  153. package/_types/chains/opStack/decorators/publicL1.d.ts +129 -0
  154. package/_types/chains/opStack/decorators/publicL1.d.ts.map +1 -1
  155. package/_types/chains/opStack/errors/withdrawal.d.ts +7 -0
  156. package/_types/chains/opStack/errors/withdrawal.d.ts.map +1 -1
  157. package/_types/chains/opStack/index.d.ts +5 -0
  158. package/_types/chains/opStack/index.d.ts.map +1 -1
  159. package/_types/chains/opStack/types/chain.d.ts +1 -1
  160. package/_types/chains/opStack/types/chain.d.ts.map +1 -1
  161. package/_types/chains/opStack/types/withdrawal.d.ts +7 -0
  162. package/_types/chains/opStack/types/withdrawal.d.ts.map +1 -1
  163. package/_types/chains/zksync/actions/deployContract.d.ts +49 -0
  164. package/_types/chains/zksync/actions/deployContract.d.ts.map +1 -0
  165. package/_types/chains/zksync/constants/abis.d.ts +70 -0
  166. package/_types/chains/zksync/constants/abis.d.ts.map +1 -0
  167. package/_types/chains/zksync/constants/address.d.ts +2 -0
  168. package/_types/chains/zksync/constants/address.d.ts.map +1 -0
  169. package/_types/chains/zksync/constants/contract.d.ts +3 -0
  170. package/_types/chains/zksync/constants/contract.d.ts.map +1 -0
  171. package/_types/chains/zksync/constants/number.d.ts +2 -0
  172. package/_types/chains/zksync/constants/number.d.ts.map +1 -0
  173. package/_types/chains/zksync/decorators/eip712.d.ts +32 -0
  174. package/_types/chains/zksync/decorators/eip712.d.ts.map +1 -1
  175. package/_types/chains/zksync/errors/bytecode.d.ts +30 -0
  176. package/_types/chains/zksync/errors/bytecode.d.ts.map +1 -0
  177. package/_types/chains/zksync/formatters.d.ts.map +1 -1
  178. package/_types/chains/zksync/index.d.ts +1 -0
  179. package/_types/chains/zksync/index.d.ts.map +1 -1
  180. package/_types/chains/zksync/types/contract.d.ts +2 -0
  181. package/_types/chains/zksync/types/contract.d.ts.map +1 -0
  182. package/_types/chains/zksync/utils/abi/encodeDeployData.d.ts +13 -0
  183. package/_types/chains/zksync/utils/abi/encodeDeployData.d.ts.map +1 -0
  184. package/_types/chains/zksync/utils/getEip712Domain.d.ts.map +1 -1
  185. package/_types/chains/zksync/utils/hashBytecode.d.ts +3 -0
  186. package/_types/chains/zksync/utils/hashBytecode.d.ts.map +1 -0
  187. package/_types/errors/version.d.ts +1 -1
  188. package/chains/definitions/optimismSepolia.ts +5 -0
  189. package/chains/opStack/abis.ts +1071 -0
  190. package/chains/opStack/actions/buildProveWithdrawal.ts +7 -6
  191. package/chains/opStack/actions/getGame.ts +99 -0
  192. package/chains/opStack/actions/getGames.ts +133 -0
  193. package/chains/opStack/actions/getL2Output.ts +44 -3
  194. package/chains/opStack/actions/getPortalVersion.ts +87 -0
  195. package/chains/opStack/actions/getTimeToFinalize.ts +64 -27
  196. package/chains/opStack/actions/getTimeToNextGame.ts +143 -0
  197. package/chains/opStack/actions/getTimeToProve.ts +43 -5
  198. package/chains/opStack/actions/getWithdrawalStatus.ts +130 -38
  199. package/chains/opStack/actions/proveWithdrawal.ts +3 -1
  200. package/chains/opStack/actions/waitForNextGame.ts +122 -0
  201. package/chains/opStack/actions/waitForNextL2Output.ts +5 -1
  202. package/chains/opStack/actions/waitToProve.ts +65 -7
  203. package/chains/opStack/decorators/publicL1.ts +164 -0
  204. package/chains/opStack/errors/withdrawal.ts +10 -0
  205. package/chains/opStack/index.ts +30 -0
  206. package/chains/opStack/types/chain.ts +4 -1
  207. package/chains/opStack/types/withdrawal.ts +8 -0
  208. package/chains/zksync/actions/deployContract.ts +100 -0
  209. package/chains/zksync/constants/abis.ts +424 -0
  210. package/chains/zksync/constants/address.ts +2 -0
  211. package/chains/zksync/constants/contract.ts +2 -0
  212. package/chains/zksync/constants/number.ts +3 -0
  213. package/chains/zksync/decorators/eip712.ts +47 -0
  214. package/chains/zksync/errors/bytecode.ts +46 -0
  215. package/chains/zksync/formatters.ts +7 -1
  216. package/chains/zksync/index.ts +6 -0
  217. package/chains/zksync/types/contract.ts +6 -0
  218. package/chains/zksync/utils/abi/encodeDeployData.ts +120 -0
  219. package/chains/zksync/utils/getEip712Domain.ts +4 -2
  220. package/chains/zksync/utils/hashBytecode.ts +48 -0
  221. package/errors/version.ts +1 -1
  222. package/package.json +1 -1
@@ -0,0 +1,424 @@
1
+ /* [ContractDeployer](https://github.com/matter-labs/era-system-contracts/blob/main/contracts/ContractDeployer.sol) */
2
+ export const contractDeployerAbi = [
3
+ {
4
+ anonymous: false,
5
+ inputs: [
6
+ {
7
+ indexed: true,
8
+ internalType: 'address',
9
+ name: 'accountAddress',
10
+ type: 'address',
11
+ },
12
+ {
13
+ indexed: false,
14
+ internalType: 'enum IContractDeployer.AccountNonceOrdering',
15
+ name: 'nonceOrdering',
16
+ type: 'uint8',
17
+ },
18
+ ],
19
+ name: 'AccountNonceOrderingUpdated',
20
+ type: 'event',
21
+ },
22
+ {
23
+ anonymous: false,
24
+ inputs: [
25
+ {
26
+ indexed: true,
27
+ internalType: 'address',
28
+ name: 'accountAddress',
29
+ type: 'address',
30
+ },
31
+ {
32
+ indexed: false,
33
+ internalType: 'enum IContractDeployer.AccountAbstractionVersion',
34
+ name: 'aaVersion',
35
+ type: 'uint8',
36
+ },
37
+ ],
38
+ name: 'AccountVersionUpdated',
39
+ type: 'event',
40
+ },
41
+ {
42
+ anonymous: false,
43
+ inputs: [
44
+ {
45
+ indexed: true,
46
+ internalType: 'address',
47
+ name: 'deployerAddress',
48
+ type: 'address',
49
+ },
50
+ {
51
+ indexed: true,
52
+ internalType: 'bytes32',
53
+ name: 'bytecodeHash',
54
+ type: 'bytes32',
55
+ },
56
+ {
57
+ indexed: true,
58
+ internalType: 'address',
59
+ name: 'contractAddress',
60
+ type: 'address',
61
+ },
62
+ ],
63
+ name: 'ContractDeployed',
64
+ type: 'event',
65
+ },
66
+ {
67
+ inputs: [
68
+ {
69
+ internalType: 'bytes32',
70
+ name: '_salt',
71
+ type: 'bytes32',
72
+ },
73
+ {
74
+ internalType: 'bytes32',
75
+ name: '_bytecodeHash',
76
+ type: 'bytes32',
77
+ },
78
+ {
79
+ internalType: 'bytes',
80
+ name: '_input',
81
+ type: 'bytes',
82
+ },
83
+ ],
84
+ name: 'create',
85
+ outputs: [
86
+ {
87
+ internalType: 'address',
88
+ name: '',
89
+ type: 'address',
90
+ },
91
+ ],
92
+ stateMutability: 'payable',
93
+ type: 'function',
94
+ },
95
+ {
96
+ inputs: [
97
+ {
98
+ internalType: 'bytes32',
99
+ name: '_salt',
100
+ type: 'bytes32',
101
+ },
102
+ {
103
+ internalType: 'bytes32',
104
+ name: '_bytecodeHash',
105
+ type: 'bytes32',
106
+ },
107
+ {
108
+ internalType: 'bytes',
109
+ name: '_input',
110
+ type: 'bytes',
111
+ },
112
+ ],
113
+ name: 'create2',
114
+ outputs: [
115
+ {
116
+ internalType: 'address',
117
+ name: '',
118
+ type: 'address',
119
+ },
120
+ ],
121
+ stateMutability: 'payable',
122
+ type: 'function',
123
+ },
124
+ {
125
+ inputs: [
126
+ {
127
+ internalType: 'bytes32',
128
+ name: '_salt',
129
+ type: 'bytes32',
130
+ },
131
+ {
132
+ internalType: 'bytes32',
133
+ name: '_bytecodeHash',
134
+ type: 'bytes32',
135
+ },
136
+ {
137
+ internalType: 'bytes',
138
+ name: '_input',
139
+ type: 'bytes',
140
+ },
141
+ {
142
+ internalType: 'enum IContractDeployer.AccountAbstractionVersion',
143
+ name: '_aaVersion',
144
+ type: 'uint8',
145
+ },
146
+ ],
147
+ name: 'create2Account',
148
+ outputs: [
149
+ {
150
+ internalType: 'address',
151
+ name: '',
152
+ type: 'address',
153
+ },
154
+ ],
155
+ stateMutability: 'payable',
156
+ type: 'function',
157
+ },
158
+ {
159
+ inputs: [
160
+ {
161
+ internalType: 'bytes32',
162
+ name: '',
163
+ type: 'bytes32',
164
+ },
165
+ {
166
+ internalType: 'bytes32',
167
+ name: '_bytecodeHash',
168
+ type: 'bytes32',
169
+ },
170
+ {
171
+ internalType: 'bytes',
172
+ name: '_input',
173
+ type: 'bytes',
174
+ },
175
+ {
176
+ internalType: 'enum IContractDeployer.AccountAbstractionVersion',
177
+ name: '_aaVersion',
178
+ type: 'uint8',
179
+ },
180
+ ],
181
+ name: 'createAccount',
182
+ outputs: [
183
+ {
184
+ internalType: 'address',
185
+ name: '',
186
+ type: 'address',
187
+ },
188
+ ],
189
+ stateMutability: 'payable',
190
+ type: 'function',
191
+ },
192
+ {
193
+ inputs: [
194
+ {
195
+ internalType: 'address',
196
+ name: '_address',
197
+ type: 'address',
198
+ },
199
+ ],
200
+ name: 'extendedAccountVersion',
201
+ outputs: [
202
+ {
203
+ internalType: 'enum IContractDeployer.AccountAbstractionVersion',
204
+ name: '',
205
+ type: 'uint8',
206
+ },
207
+ ],
208
+ stateMutability: 'view',
209
+ type: 'function',
210
+ },
211
+ {
212
+ inputs: [
213
+ {
214
+ internalType: 'bytes32',
215
+ name: '_keccak256BytecodeHash',
216
+ type: 'bytes32',
217
+ },
218
+ ],
219
+ name: 'forceDeployKeccak256',
220
+ outputs: [],
221
+ stateMutability: 'payable',
222
+ type: 'function',
223
+ },
224
+ {
225
+ inputs: [
226
+ {
227
+ components: [
228
+ {
229
+ internalType: 'bytes32',
230
+ name: 'bytecodeHash',
231
+ type: 'bytes32',
232
+ },
233
+ {
234
+ internalType: 'address',
235
+ name: 'newAddress',
236
+ type: 'address',
237
+ },
238
+ {
239
+ internalType: 'bool',
240
+ name: 'callConstructor',
241
+ type: 'bool',
242
+ },
243
+ {
244
+ internalType: 'uint256',
245
+ name: 'value',
246
+ type: 'uint256',
247
+ },
248
+ {
249
+ internalType: 'bytes',
250
+ name: 'input',
251
+ type: 'bytes',
252
+ },
253
+ ],
254
+ internalType: 'struct ContractDeployer.ForceDeployment',
255
+ name: '_deployment',
256
+ type: 'tuple',
257
+ },
258
+ {
259
+ internalType: 'address',
260
+ name: '_sender',
261
+ type: 'address',
262
+ },
263
+ ],
264
+ name: 'forceDeployOnAddress',
265
+ outputs: [],
266
+ stateMutability: 'payable',
267
+ type: 'function',
268
+ },
269
+ {
270
+ inputs: [
271
+ {
272
+ components: [
273
+ {
274
+ internalType: 'bytes32',
275
+ name: 'bytecodeHash',
276
+ type: 'bytes32',
277
+ },
278
+ {
279
+ internalType: 'address',
280
+ name: 'newAddress',
281
+ type: 'address',
282
+ },
283
+ {
284
+ internalType: 'bool',
285
+ name: 'callConstructor',
286
+ type: 'bool',
287
+ },
288
+ {
289
+ internalType: 'uint256',
290
+ name: 'value',
291
+ type: 'uint256',
292
+ },
293
+ {
294
+ internalType: 'bytes',
295
+ name: 'input',
296
+ type: 'bytes',
297
+ },
298
+ ],
299
+ internalType: 'struct ContractDeployer.ForceDeployment[]',
300
+ name: '_deployments',
301
+ type: 'tuple[]',
302
+ },
303
+ ],
304
+ name: 'forceDeployOnAddresses',
305
+ outputs: [],
306
+ stateMutability: 'payable',
307
+ type: 'function',
308
+ },
309
+ {
310
+ inputs: [
311
+ {
312
+ internalType: 'address',
313
+ name: '_address',
314
+ type: 'address',
315
+ },
316
+ ],
317
+ name: 'getAccountInfo',
318
+ outputs: [
319
+ {
320
+ components: [
321
+ {
322
+ internalType: 'enum IContractDeployer.AccountAbstractionVersion',
323
+ name: 'supportedAAVersion',
324
+ type: 'uint8',
325
+ },
326
+ {
327
+ internalType: 'enum IContractDeployer.AccountNonceOrdering',
328
+ name: 'nonceOrdering',
329
+ type: 'uint8',
330
+ },
331
+ ],
332
+ internalType: 'struct IContractDeployer.AccountInfo',
333
+ name: 'info',
334
+ type: 'tuple',
335
+ },
336
+ ],
337
+ stateMutability: 'view',
338
+ type: 'function',
339
+ },
340
+ {
341
+ inputs: [
342
+ {
343
+ internalType: 'address',
344
+ name: '_sender',
345
+ type: 'address',
346
+ },
347
+ {
348
+ internalType: 'uint256',
349
+ name: '_senderNonce',
350
+ type: 'uint256',
351
+ },
352
+ ],
353
+ name: 'getNewAddressCreate',
354
+ outputs: [
355
+ {
356
+ internalType: 'address',
357
+ name: 'newAddress',
358
+ type: 'address',
359
+ },
360
+ ],
361
+ stateMutability: 'pure',
362
+ type: 'function',
363
+ },
364
+ {
365
+ inputs: [
366
+ {
367
+ internalType: 'address',
368
+ name: '_sender',
369
+ type: 'address',
370
+ },
371
+ {
372
+ internalType: 'bytes32',
373
+ name: '_bytecodeHash',
374
+ type: 'bytes32',
375
+ },
376
+ {
377
+ internalType: 'bytes32',
378
+ name: '_salt',
379
+ type: 'bytes32',
380
+ },
381
+ {
382
+ internalType: 'bytes',
383
+ name: '_input',
384
+ type: 'bytes',
385
+ },
386
+ ],
387
+ name: 'getNewAddressCreate2',
388
+ outputs: [
389
+ {
390
+ internalType: 'address',
391
+ name: 'newAddress',
392
+ type: 'address',
393
+ },
394
+ ],
395
+ stateMutability: 'view',
396
+ type: 'function',
397
+ },
398
+ {
399
+ inputs: [
400
+ {
401
+ internalType: 'enum IContractDeployer.AccountAbstractionVersion',
402
+ name: '_version',
403
+ type: 'uint8',
404
+ },
405
+ ],
406
+ name: 'updateAccountVersion',
407
+ outputs: [],
408
+ stateMutability: 'nonpayable',
409
+ type: 'function',
410
+ },
411
+ {
412
+ inputs: [
413
+ {
414
+ internalType: 'enum IContractDeployer.AccountNonceOrdering',
415
+ name: '_nonceOrdering',
416
+ type: 'uint8',
417
+ },
418
+ ],
419
+ name: 'updateNonceOrdering',
420
+ outputs: [],
421
+ stateMutability: 'nonpayable',
422
+ type: 'function',
423
+ },
424
+ ]
@@ -0,0 +1,2 @@
1
+ export const contractDeployerAddress =
2
+ '0x0000000000000000000000000000000000008006' as const
@@ -0,0 +1,2 @@
1
+ export const accountAbstractionVersionNone = 0
2
+ export const accountAbstractionVersion1 = 1
@@ -0,0 +1,3 @@
1
+ import { maxUint16 } from '../../../constants/number.js'
2
+
3
+ export const maxBytecodeSize = maxUint16 * 32n
@@ -1,8 +1,14 @@
1
+ import type { Abi } from 'abitype'
1
2
  import { writeContract } from '../../../actions/wallet/writeContract.js'
2
3
  import type { Client } from '../../../clients/createClient.js'
3
4
  import type { WalletActions } from '../../../clients/decorators/wallet.js'
4
5
  import type { Transport } from '../../../clients/transports/createTransport.js'
5
6
  import type { Account } from '../../../types/account.js'
7
+ import {
8
+ type DeployContractParameters,
9
+ type DeployContractReturnType,
10
+ deployContract,
11
+ } from '../actions/deployContract.js'
6
12
  import {
7
13
  type SendTransactionParameters,
8
14
  type SendTransactionReturnType,
@@ -112,6 +118,46 @@ export type Eip712WalletActions<
112
118
  signTransaction: <chainOverride extends ChainEIP712 | undefined = undefined>(
113
119
  args: SignTransactionParameters<chain, account, chainOverride>,
114
120
  ) => Promise<SignTransactionReturnType>
121
+ /**
122
+ * Deploys a contract to the network, given bytecode and constructor arguments using EIP712 transaction.
123
+ *
124
+ * - Docs: https://viem.sh/docs/contract/deployContract
125
+ * - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/contracts/deploying-contracts
126
+ *
127
+ * @param args - {@link DeployContractParameters}
128
+ * @returns The [Transaction](https://viem.sh/docs/glossary/terms#transaction) hash. {@link DeployContractReturnType}
129
+ *
130
+ * @example
131
+ * import { createWalletClient, custom } from 'viem'
132
+ * import { privateKeyToAccount } from 'viem/accounts'
133
+ * import { zkSync } from 'viem/chains'
134
+ * import { deployContract } from 'viem/contract'
135
+ *
136
+ * const client = createWalletClient({
137
+ * account: privateKeyToAccount('0x…'),
138
+ * chain: zksync,
139
+ * transport: custom(provider),
140
+ * })
141
+ * const hash = await client.deployContract(client, {
142
+ * abi: [],
143
+ * account: '0x…,
144
+ * deploymentType: 'create',
145
+ * bytecode: '0x608060405260405161083e38038061083e833981016040819052610...',
146
+ * factoryDeps: ['0x608060405260405161083e38038061083e833981016040819052610...'],
147
+ * gasPerPubdata: 50000n
148
+ * })
149
+ */
150
+ deployContract: <
151
+ const abi extends Abi | readonly unknown[],
152
+ chainOverride extends ChainEIP712 | undefined,
153
+ >(
154
+ args: DeployContractParameters<
155
+ abi,
156
+ ChainEIP712 | undefined,
157
+ Account | undefined,
158
+ chainOverride
159
+ >,
160
+ ) => Promise<DeployContractReturnType>
115
161
  /**
116
162
  * Executes a write function on a contract.
117
163
  *
@@ -175,6 +221,7 @@ export function eip712WalletActions() {
175
221
  ): Eip712WalletActions<chain, account> => ({
176
222
  sendTransaction: (args) => sendTransaction(client, args),
177
223
  signTransaction: (args) => signTransaction(client, args),
224
+ deployContract: (args) => deployContract(client, args),
178
225
  writeContract: (args) =>
179
226
  writeContract(
180
227
  Object.assign(client, {
@@ -0,0 +1,46 @@
1
+ import { BaseError } from '../../../errors/base.js'
2
+
3
+ export type BytecodeLengthExceedsMaxSizeErrorType =
4
+ BytecodeLengthExceedsMaxSizeError & {
5
+ name: 'BytecodeLengthExceedsMaxSizeError'
6
+ }
7
+
8
+ export class BytecodeLengthExceedsMaxSizeError extends BaseError {
9
+ override name = 'BytecodeLengthExceedsMaxSizeError'
10
+ constructor({
11
+ givenLength,
12
+ maxBytecodeSize,
13
+ }: { givenLength: number; maxBytecodeSize: bigint }) {
14
+ super(
15
+ `Bytecode cannot be longer than ${maxBytecodeSize} bytes. Given length: ${givenLength}`,
16
+ )
17
+ }
18
+ }
19
+
20
+ export type BytecodeLengthInWordsMustBeOddErrorType =
21
+ BytecodeLengthInWordsMustBeOddError & {
22
+ name: 'BytecodeLengthInWordsMustBeOddError'
23
+ }
24
+
25
+ export class BytecodeLengthInWordsMustBeOddError extends BaseError {
26
+ override name = 'BytecodeLengthInWordsMustBeOddError'
27
+ constructor({ givenLengthInWords }: { givenLengthInWords: number }) {
28
+ super(
29
+ `Bytecode length in 32-byte words must be odd. Given length in words: ${givenLengthInWords}`,
30
+ )
31
+ }
32
+ }
33
+
34
+ export type BytecodeLengthMustBeDivisibleBy32ErrorType =
35
+ BytecodeLengthMustBeDivisibleBy32Error & {
36
+ name: 'BytecodeLengthMustBeDivisibleBy32Error'
37
+ }
38
+
39
+ export class BytecodeLengthMustBeDivisibleBy32Error extends BaseError {
40
+ override name = 'BytecodeLengthMustBeDivisibleBy32Error'
41
+ constructor({ givenLength }: { givenLength: number }) {
42
+ super(
43
+ `The bytecode length in bytes must be divisible by 32. Given length: ${givenLength}`,
44
+ )
45
+ }
46
+ }
@@ -134,7 +134,13 @@ export const formatters = {
134
134
  },
135
135
  }
136
136
  : {}),
137
- ...(args.factoryDeps ? { factoryDeps: args.factoryDeps } : {}),
137
+ ...(args.factoryDeps
138
+ ? {
139
+ factoryDeps: args.factoryDeps.map((dep) =>
140
+ Array.from(hexToBytes(dep)),
141
+ ),
142
+ }
143
+ : {}),
138
144
  ...(args.customSignature
139
145
  ? {
140
146
  customSignature: Array.from(hexToBytes(args.customSignature)),
@@ -22,6 +22,12 @@ export {
22
22
  type SignTransactionReturnType,
23
23
  signTransaction,
24
24
  } from './actions/signTransaction.js'
25
+ export {
26
+ type DeployContractErrorType,
27
+ type DeployContractParameters,
28
+ type DeployContractReturnType,
29
+ deployContract,
30
+ } from './actions/deployContract.js'
25
31
 
26
32
  export {
27
33
  zkSync,
@@ -0,0 +1,6 @@
1
+ export type ContractDeploymentType =
2
+ | 'create'
3
+ | 'create2'
4
+ | 'createAccount'
5
+ | 'create2Account'
6
+ | undefined
@@ -0,0 +1,120 @@
1
+ import type { Abi } from 'abitype'
2
+
3
+ import { zeroHash } from '../../../../constants/bytes.js'
4
+ import {
5
+ AbiConstructorNotFoundError,
6
+ AbiConstructorParamsNotFoundError,
7
+ } from '../../../../errors/abi.js'
8
+ import type { ContractConstructorArgs } from '../../../../types/contract.js'
9
+ import type { Hash } from '../../../../types/misc.js'
10
+ import type { Hex } from '../../../../types/misc.js'
11
+ import { encodeAbiParameters } from '../../../../utils/abi/encodeAbiParameters.js'
12
+ import {
13
+ type EncodeDeployDataParameters as EncodeDeployDataParameters_,
14
+ type EncodeDeployDataReturnType,
15
+ } from '../../../../utils/abi/encodeDeployData.js'
16
+ import { encodeFunctionData } from '../../../../utils/abi/encodeFunctionData.js'
17
+ import { toHex } from '../../../../utils/encoding/toHex.js'
18
+ import { contractDeployerAbi } from '../../constants/abis.js'
19
+ import { accountAbstractionVersion1 } from '../../constants/contract.js'
20
+ import type { ContractDeploymentType } from '../../types/contract.js'
21
+ import { hashBytecode } from '../hashBytecode.js'
22
+
23
+ const docsPath = '/docs/contract/encodeDeployData'
24
+
25
+ export type EncodeDeployDataParameters<
26
+ abi extends Abi | readonly unknown[] = Abi,
27
+ hasConstructor = abi extends Abi
28
+ ? Abi extends abi
29
+ ? true
30
+ : [Extract<abi[number], { type: 'constructor' }>] extends [never]
31
+ ? false
32
+ : true
33
+ : true,
34
+ allArgs = ContractConstructorArgs<abi>,
35
+ > = EncodeDeployDataParameters_<abi, hasConstructor, allArgs> & {
36
+ deploymentType?: ContractDeploymentType | undefined
37
+ salt?: Hash | undefined
38
+ }
39
+
40
+ export function encodeDeployData<const abi extends Abi | readonly unknown[]>(
41
+ parameters: EncodeDeployDataParameters<abi>,
42
+ ): EncodeDeployDataReturnType {
43
+ const { abi, args, bytecode, deploymentType, salt } =
44
+ parameters as EncodeDeployDataParameters
45
+
46
+ if (!args || args.length === 0) {
47
+ const { functionName, argsContractDeployer } = getDeploymentDetails(
48
+ deploymentType,
49
+ salt ?? zeroHash,
50
+ toHex(hashBytecode(bytecode)),
51
+ '0x',
52
+ )
53
+ return encodeFunctionData({
54
+ abi: contractDeployerAbi,
55
+ functionName,
56
+ args: argsContractDeployer,
57
+ })
58
+ }
59
+
60
+ const description = abi.find((x) => 'type' in x && x.type === 'constructor')
61
+ if (!description) throw new AbiConstructorNotFoundError({ docsPath })
62
+ if (!('inputs' in description))
63
+ throw new AbiConstructorParamsNotFoundError({ docsPath })
64
+ if (!description.inputs || description.inputs.length === 0)
65
+ throw new AbiConstructorParamsNotFoundError({ docsPath })
66
+
67
+ const data = encodeAbiParameters(description.inputs, args)
68
+ const { functionName, argsContractDeployer } = getDeploymentDetails(
69
+ deploymentType,
70
+ salt ?? zeroHash,
71
+ toHex(hashBytecode(bytecode)),
72
+ data,
73
+ )
74
+
75
+ return encodeFunctionData({
76
+ abi: contractDeployerAbi,
77
+ functionName,
78
+ args: argsContractDeployer,
79
+ })
80
+ }
81
+
82
+ function getDeploymentDetails(
83
+ deploymentType: ContractDeploymentType,
84
+ salt: Hash,
85
+ bytecodeHash: Hex,
86
+ data: Hex,
87
+ ): {
88
+ functionName: string
89
+ argsContractDeployer: readonly unknown[]
90
+ } {
91
+ const contractDeploymentArgs = [salt, bytecodeHash, data]
92
+
93
+ const deploymentOptions = {
94
+ create: {
95
+ functionName: 'create',
96
+ argsContractDeployer: contractDeploymentArgs,
97
+ },
98
+ create2: {
99
+ functionName: 'create2',
100
+ argsContractDeployer: contractDeploymentArgs,
101
+ },
102
+ createAccount: {
103
+ functionName: 'createAccount',
104
+ argsContractDeployer: [
105
+ ...contractDeploymentArgs,
106
+ accountAbstractionVersion1,
107
+ ],
108
+ },
109
+ create2Account: {
110
+ functionName: 'create2Account',
111
+ argsContractDeployer: [
112
+ ...contractDeploymentArgs,
113
+ accountAbstractionVersion1,
114
+ ],
115
+ },
116
+ }
117
+
118
+ const deploymentKey = deploymentType || 'create'
119
+ return deploymentOptions[deploymentKey]
120
+ }