gate-evm-tools 1.0.26 → 1.0.27

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 (323) hide show
  1. package/README.md +14 -0
  2. package/bin/workflow.cjs +19 -0
  3. package/dist/core/BytecodeChecker.d.ts.map +1 -1
  4. package/dist/core/BytecodeChecker.js +16 -1
  5. package/dist/core/BytecodeChecker.js.map +1 -1
  6. package/dist/core/legacyProxyArtifact.d.ts +6 -0
  7. package/dist/core/legacyProxyArtifact.d.ts.map +1 -0
  8. package/dist/core/legacyProxyArtifact.js +36 -0
  9. package/dist/core/legacyProxyArtifact.js.map +1 -0
  10. package/dist-runtime/config/hardhatAdapters.d.ts +5 -0
  11. package/dist-runtime/config/hardhatAdapters.js +53 -0
  12. package/dist-runtime/config/hardhatAdapters.js.map +1 -0
  13. package/dist-runtime/config/networks.d.ts +8 -0
  14. package/dist-runtime/config/networks.js +269 -0
  15. package/dist-runtime/config/networks.js.map +1 -0
  16. package/dist-runtime/config/openzeppelin.d.ts +28 -0
  17. package/dist-runtime/config/openzeppelin.js +144 -0
  18. package/dist-runtime/config/openzeppelin.js.map +1 -0
  19. package/dist-runtime/config/rpc.d.ts +7 -0
  20. package/dist-runtime/config/rpc.js +19 -0
  21. package/dist-runtime/config/rpc.js.map +1 -0
  22. package/dist-runtime/config/zksyncSolcPath.d.ts +1 -0
  23. package/dist-runtime/config/zksyncSolcPath.js +61 -0
  24. package/dist-runtime/config/zksyncSolcPath.js.map +1 -0
  25. package/dist-runtime/migrate.d.ts +13 -0
  26. package/dist-runtime/migrate.js +208 -0
  27. package/dist-runtime/migrate.js.map +1 -0
  28. package/dist-runtime/package.json +1 -0
  29. package/dist-runtime/projectHardhat.d.ts +4 -0
  30. package/dist-runtime/projectHardhat.js +16 -0
  31. package/dist-runtime/projectHardhat.js.map +1 -0
  32. package/dist-runtime/runtime-identity.json +4 -0
  33. package/dist-runtime/template-migration.json +293 -0
  34. package/dist-runtime/workflow/checkCode.d.ts +1 -0
  35. package/dist-runtime/workflow/checkCode.js +16 -0
  36. package/dist-runtime/workflow/checkCode.js.map +1 -0
  37. package/dist-runtime/workflow/checkCodeFinalize.d.ts +1 -0
  38. package/dist-runtime/workflow/checkCodeFinalize.js +11 -0
  39. package/dist-runtime/workflow/checkCodeFinalize.js.map +1 -0
  40. package/dist-runtime/workflow/checkCodePlan.d.ts +1 -0
  41. package/dist-runtime/workflow/checkCodePlan.js +11 -0
  42. package/dist-runtime/workflow/checkCodePlan.js.map +1 -0
  43. package/dist-runtime/workflow/cli.d.ts +1 -0
  44. package/dist-runtime/workflow/cli.js +302 -0
  45. package/dist-runtime/workflow/cli.js.map +1 -0
  46. package/dist-runtime/workflow/commitContractInfo.d.ts +1 -0
  47. package/dist-runtime/workflow/commitContractInfo.js +64 -0
  48. package/dist-runtime/workflow/commitContractInfo.js.map +1 -0
  49. package/dist-runtime/workflow/create2Hashes.d.ts +1 -0
  50. package/dist-runtime/workflow/create2Hashes.js +76 -0
  51. package/dist-runtime/workflow/create2Hashes.js.map +1 -0
  52. package/dist-runtime/workflow/forkSourceProxy.d.ts +1 -0
  53. package/dist-runtime/workflow/forkSourceProxy.js +151 -0
  54. package/dist-runtime/workflow/forkSourceProxy.js.map +1 -0
  55. package/dist-runtime/workflow/importState.d.ts +1 -0
  56. package/dist-runtime/workflow/importState.js +193 -0
  57. package/dist-runtime/workflow/importState.js.map +1 -0
  58. package/dist-runtime/workflow/lib/authority.d.ts +28 -0
  59. package/dist-runtime/workflow/lib/authority.js +122 -0
  60. package/dist-runtime/workflow/lib/authority.js.map +1 -0
  61. package/dist-runtime/workflow/lib/calldata.d.ts +2 -0
  62. package/dist-runtime/workflow/lib/calldata.js +8 -0
  63. package/dist-runtime/workflow/lib/calldata.js.map +1 -0
  64. package/dist-runtime/workflow/lib/calls.d.ts +23 -0
  65. package/dist-runtime/workflow/lib/calls.js +316 -0
  66. package/dist-runtime/workflow/lib/calls.js.map +1 -0
  67. package/dist-runtime/workflow/lib/checkCode/args.d.ts +2 -0
  68. package/dist-runtime/workflow/lib/checkCode/args.js +68 -0
  69. package/dist-runtime/workflow/lib/checkCode/args.js.map +1 -0
  70. package/dist-runtime/workflow/lib/checkCode/command.d.ts +5 -0
  71. package/dist-runtime/workflow/lib/checkCode/command.js +35 -0
  72. package/dist-runtime/workflow/lib/checkCode/command.js.map +1 -0
  73. package/dist-runtime/workflow/lib/checkCode/dependencies.d.ts +6 -0
  74. package/dist-runtime/workflow/lib/checkCode/dependencies.js +125 -0
  75. package/dist-runtime/workflow/lib/checkCode/dependencies.js.map +1 -0
  76. package/dist-runtime/workflow/lib/checkCode/finalize.d.ts +17 -0
  77. package/dist-runtime/workflow/lib/checkCode/finalize.js +174 -0
  78. package/dist-runtime/workflow/lib/checkCode/finalize.js.map +1 -0
  79. package/dist-runtime/workflow/lib/checkCode/index.d.ts +3 -0
  80. package/dist-runtime/workflow/lib/checkCode/index.js +20 -0
  81. package/dist-runtime/workflow/lib/checkCode/index.js.map +1 -0
  82. package/dist-runtime/workflow/lib/checkCode/plan.d.ts +22 -0
  83. package/dist-runtime/workflow/lib/checkCode/plan.js +145 -0
  84. package/dist-runtime/workflow/lib/checkCode/plan.js.map +1 -0
  85. package/dist-runtime/workflow/lib/checkCodeReport.d.ts +25 -0
  86. package/dist-runtime/workflow/lib/checkCodeReport.js +102 -0
  87. package/dist-runtime/workflow/lib/checkCodeReport.js.map +1 -0
  88. package/dist-runtime/workflow/lib/checkCodeRunner.d.ts +87 -0
  89. package/dist-runtime/workflow/lib/checkCodeRunner.js +964 -0
  90. package/dist-runtime/workflow/lib/checkCodeRunner.js.map +1 -0
  91. package/dist-runtime/workflow/lib/cliTool.d.ts +10 -0
  92. package/dist-runtime/workflow/lib/cliTool.js +25 -0
  93. package/dist-runtime/workflow/lib/cliTool.js.map +1 -0
  94. package/dist-runtime/workflow/lib/config.d.ts +33 -0
  95. package/dist-runtime/workflow/lib/config.js +100 -0
  96. package/dist-runtime/workflow/lib/config.js.map +1 -0
  97. package/dist-runtime/workflow/lib/contractInfoCandidates.d.ts +82 -0
  98. package/dist-runtime/workflow/lib/contractInfoCandidates.js +441 -0
  99. package/dist-runtime/workflow/lib/contractInfoCandidates.js.map +1 -0
  100. package/dist-runtime/workflow/lib/create2.d.ts +49 -0
  101. package/dist-runtime/workflow/lib/create2.js +194 -0
  102. package/dist-runtime/workflow/lib/create2.js.map +1 -0
  103. package/dist-runtime/workflow/lib/create2Hashes.d.ts +22 -0
  104. package/dist-runtime/workflow/lib/create2Hashes.js +57 -0
  105. package/dist-runtime/workflow/lib/create2Hashes.js.map +1 -0
  106. package/dist-runtime/workflow/lib/deploymentInfo.d.ts +40 -0
  107. package/dist-runtime/workflow/lib/deploymentInfo.js +240 -0
  108. package/dist-runtime/workflow/lib/deploymentInfo.js.map +1 -0
  109. package/dist-runtime/workflow/lib/deploymentRecords.d.ts +137 -0
  110. package/dist-runtime/workflow/lib/deploymentRecords.js +374 -0
  111. package/dist-runtime/workflow/lib/deploymentRecords.js.map +1 -0
  112. package/dist-runtime/workflow/lib/deployments.d.ts +21 -0
  113. package/dist-runtime/workflow/lib/deployments.js +240 -0
  114. package/dist-runtime/workflow/lib/deployments.js.map +1 -0
  115. package/dist-runtime/workflow/lib/erc1967.d.ts +5 -0
  116. package/dist-runtime/workflow/lib/erc1967.js +29 -0
  117. package/dist-runtime/workflow/lib/erc1967.js.map +1 -0
  118. package/dist-runtime/workflow/lib/errors.d.ts +6 -0
  119. package/dist-runtime/workflow/lib/errors.js +77 -0
  120. package/dist-runtime/workflow/lib/errors.js.map +1 -0
  121. package/dist-runtime/workflow/lib/executionId.d.ts +7 -0
  122. package/dist-runtime/workflow/lib/executionId.js +26 -0
  123. package/dist-runtime/workflow/lib/executionId.js.map +1 -0
  124. package/dist-runtime/workflow/lib/executionPlan.d.ts +85 -0
  125. package/dist-runtime/workflow/lib/executionPlan.js +450 -0
  126. package/dist-runtime/workflow/lib/executionPlan.js.map +1 -0
  127. package/dist-runtime/workflow/lib/executionProgress.d.ts +5 -0
  128. package/dist-runtime/workflow/lib/executionProgress.js +100 -0
  129. package/dist-runtime/workflow/lib/executionProgress.js.map +1 -0
  130. package/dist-runtime/workflow/lib/external.d.ts +62 -0
  131. package/dist-runtime/workflow/lib/external.js +282 -0
  132. package/dist-runtime/workflow/lib/external.js.map +1 -0
  133. package/dist-runtime/workflow/lib/externalExecutionScanner.d.ts +64 -0
  134. package/dist-runtime/workflow/lib/externalExecutionScanner.js +638 -0
  135. package/dist-runtime/workflow/lib/externalExecutionScanner.js.map +1 -0
  136. package/dist-runtime/workflow/lib/forkSnapshot.d.ts +34 -0
  137. package/dist-runtime/workflow/lib/forkSnapshot.js +167 -0
  138. package/dist-runtime/workflow/lib/forkSnapshot.js.map +1 -0
  139. package/dist-runtime/workflow/lib/gateTool.d.ts +16 -0
  140. package/dist-runtime/workflow/lib/gateTool.js +177 -0
  141. package/dist-runtime/workflow/lib/gateTool.js.map +1 -0
  142. package/dist-runtime/workflow/lib/gateToolSync.d.ts +22 -0
  143. package/dist-runtime/workflow/lib/gateToolSync.js +253 -0
  144. package/dist-runtime/workflow/lib/gateToolSync.js.map +1 -0
  145. package/dist-runtime/workflow/lib/lock.d.ts +52 -0
  146. package/dist-runtime/workflow/lib/lock.js +269 -0
  147. package/dist-runtime/workflow/lib/lock.js.map +1 -0
  148. package/dist-runtime/workflow/lib/migrationState.d.ts +103 -0
  149. package/dist-runtime/workflow/lib/migrationState.js +920 -0
  150. package/dist-runtime/workflow/lib/migrationState.js.map +1 -0
  151. package/dist-runtime/workflow/lib/operatorExecution.d.ts +28 -0
  152. package/dist-runtime/workflow/lib/operatorExecution.js +134 -0
  153. package/dist-runtime/workflow/lib/operatorExecution.js.map +1 -0
  154. package/dist-runtime/workflow/lib/parameters.d.ts +58 -0
  155. package/dist-runtime/workflow/lib/parameters.js +322 -0
  156. package/dist-runtime/workflow/lib/parameters.js.map +1 -0
  157. package/dist-runtime/workflow/lib/pendingDeploymentReuse.d.ts +29 -0
  158. package/dist-runtime/workflow/lib/pendingDeploymentReuse.js +277 -0
  159. package/dist-runtime/workflow/lib/pendingDeploymentReuse.js.map +1 -0
  160. package/dist-runtime/workflow/lib/proxy.d.ts +18 -0
  161. package/dist-runtime/workflow/lib/proxy.js +19 -0
  162. package/dist-runtime/workflow/lib/proxy.js.map +1 -0
  163. package/dist-runtime/workflow/lib/registryCommit.d.ts +33 -0
  164. package/dist-runtime/workflow/lib/registryCommit.js +319 -0
  165. package/dist-runtime/workflow/lib/registryCommit.js.map +1 -0
  166. package/dist-runtime/workflow/lib/release.d.ts +57 -0
  167. package/dist-runtime/workflow/lib/release.js +256 -0
  168. package/dist-runtime/workflow/lib/release.js.map +1 -0
  169. package/dist-runtime/workflow/lib/releaseFinalize.d.ts +14 -0
  170. package/dist-runtime/workflow/lib/releaseFinalize.js +571 -0
  171. package/dist-runtime/workflow/lib/releaseFinalize.js.map +1 -0
  172. package/dist-runtime/workflow/lib/releaseParameters.d.ts +43 -0
  173. package/dist-runtime/workflow/lib/releaseParameters.js +184 -0
  174. package/dist-runtime/workflow/lib/releaseParameters.js.map +1 -0
  175. package/dist-runtime/workflow/lib/reporter.d.ts +39 -0
  176. package/dist-runtime/workflow/lib/reporter.js +452 -0
  177. package/dist-runtime/workflow/lib/reporter.js.map +1 -0
  178. package/dist-runtime/workflow/lib/resultPaths.d.ts +17 -0
  179. package/dist-runtime/workflow/lib/resultPaths.js +29 -0
  180. package/dist-runtime/workflow/lib/resultPaths.js.map +1 -0
  181. package/dist-runtime/workflow/lib/runtimeVersion.d.ts +10 -0
  182. package/dist-runtime/workflow/lib/runtimeVersion.js +46 -0
  183. package/dist-runtime/workflow/lib/runtimeVersion.js.map +1 -0
  184. package/dist-runtime/workflow/lib/signer.d.ts +10 -0
  185. package/dist-runtime/workflow/lib/signer.js +105 -0
  186. package/dist-runtime/workflow/lib/signer.js.map +1 -0
  187. package/dist-runtime/workflow/lib/signerIdentity.d.ts +1 -0
  188. package/dist-runtime/workflow/lib/signerIdentity.js +23 -0
  189. package/dist-runtime/workflow/lib/signerIdentity.js.map +1 -0
  190. package/dist-runtime/workflow/lib/simulation.d.ts +35 -0
  191. package/dist-runtime/workflow/lib/simulation.js +282 -0
  192. package/dist-runtime/workflow/lib/simulation.js.map +1 -0
  193. package/dist-runtime/workflow/lib/simulationCallers.d.ts +44 -0
  194. package/dist-runtime/workflow/lib/simulationCallers.js +260 -0
  195. package/dist-runtime/workflow/lib/simulationCallers.js.map +1 -0
  196. package/dist-runtime/workflow/lib/sourceRpcPolicy.d.ts +1 -0
  197. package/dist-runtime/workflow/lib/sourceRpcPolicy.js +43 -0
  198. package/dist-runtime/workflow/lib/sourceRpcPolicy.js.map +1 -0
  199. package/dist-runtime/workflow/lib/state.d.ts +6 -0
  200. package/dist-runtime/workflow/lib/state.js +25 -0
  201. package/dist-runtime/workflow/lib/state.js.map +1 -0
  202. package/dist-runtime/workflow/lib/staticValidation.d.ts +22 -0
  203. package/dist-runtime/workflow/lib/staticValidation.js +124 -0
  204. package/dist-runtime/workflow/lib/staticValidation.js.map +1 -0
  205. package/dist-runtime/workflow/lib/zksyncForkCapability.d.ts +27 -0
  206. package/dist-runtime/workflow/lib/zksyncForkCapability.js +52 -0
  207. package/dist-runtime/workflow/lib/zksyncForkCapability.js.map +1 -0
  208. package/dist-runtime/workflow/lib/zksyncForkRunner.d.ts +57 -0
  209. package/dist-runtime/workflow/lib/zksyncForkRunner.js +344 -0
  210. package/dist-runtime/workflow/lib/zksyncForkRunner.js.map +1 -0
  211. package/dist-runtime/workflow/reconcileExternal.d.ts +1 -0
  212. package/dist-runtime/workflow/reconcileExternal.js +87 -0
  213. package/dist-runtime/workflow/reconcileExternal.js.map +1 -0
  214. package/dist-runtime/workflow/reconcileExternalRun.d.ts +1 -0
  215. package/dist-runtime/workflow/reconcileExternalRun.js +77 -0
  216. package/dist-runtime/workflow/reconcileExternalRun.js.map +1 -0
  217. package/dist-runtime/workflow/releaseFinalize.d.ts +1 -0
  218. package/dist-runtime/workflow/releaseFinalize.js +11 -0
  219. package/dist-runtime/workflow/releaseFinalize.js.map +1 -0
  220. package/dist-runtime/workflow/run.d.ts +40 -0
  221. package/dist-runtime/workflow/run.js +858 -0
  222. package/dist-runtime/workflow/run.js.map +1 -0
  223. package/dist-runtime/workflow/staticValidate.d.ts +1 -0
  224. package/dist-runtime/workflow/staticValidate.js +26 -0
  225. package/dist-runtime/workflow/staticValidate.js.map +1 -0
  226. package/dist-runtime/workflow/steps/call.d.ts +3 -0
  227. package/dist-runtime/workflow/steps/call.js +9 -0
  228. package/dist-runtime/workflow/steps/call.js.map +1 -0
  229. package/dist-runtime/workflow/steps/check.d.ts +3 -0
  230. package/dist-runtime/workflow/steps/check.js +9 -0
  231. package/dist-runtime/workflow/steps/check.js.map +1 -0
  232. package/dist-runtime/workflow/steps/custom.d.ts +3 -0
  233. package/dist-runtime/workflow/steps/custom.js +33 -0
  234. package/dist-runtime/workflow/steps/custom.js.map +1 -0
  235. package/dist-runtime/workflow/steps/deploy.d.ts +3 -0
  236. package/dist-runtime/workflow/steps/deploy.js +595 -0
  237. package/dist-runtime/workflow/steps/deploy.js.map +1 -0
  238. package/dist-runtime/workflow/steps/upgrade.d.ts +3 -0
  239. package/dist-runtime/workflow/steps/upgrade.js +465 -0
  240. package/dist-runtime/workflow/steps/upgrade.js.map +1 -0
  241. package/dist-runtime/workflow/steps/view.d.ts +3 -0
  242. package/dist-runtime/workflow/steps/view.js +9 -0
  243. package/dist-runtime/workflow/steps/view.js.map +1 -0
  244. package/package.json +25 -5
  245. package/runtime/config/hardhatAdapters.ts +50 -0
  246. package/runtime/config/networks.ts +296 -0
  247. package/runtime/config/openzeppelin.ts +173 -0
  248. package/runtime/config/rpc.ts +27 -0
  249. package/runtime/config/zksyncSolcPath.ts +59 -0
  250. package/runtime/hardhat-types.d.ts +2 -0
  251. package/runtime/migrate.ts +154 -0
  252. package/runtime/projectHardhat.ts +10 -0
  253. package/runtime/template-migration.json +293 -0
  254. package/runtime/workflow/checkCode.ts +13 -0
  255. package/runtime/workflow/checkCodeFinalize.ts +8 -0
  256. package/runtime/workflow/checkCodePlan.ts +8 -0
  257. package/runtime/workflow/cli.ts +356 -0
  258. package/runtime/workflow/commitContractInfo.ts +63 -0
  259. package/runtime/workflow/create2Hashes.ts +79 -0
  260. package/runtime/workflow/forkSourceProxy.ts +193 -0
  261. package/runtime/workflow/importState.ts +190 -0
  262. package/runtime/workflow/lib/authority.ts +170 -0
  263. package/runtime/workflow/lib/calldata.ts +9 -0
  264. package/runtime/workflow/lib/calls.ts +407 -0
  265. package/runtime/workflow/lib/checkCode/args.ts +76 -0
  266. package/runtime/workflow/lib/checkCode/command.ts +36 -0
  267. package/runtime/workflow/lib/checkCode/dependencies.ts +112 -0
  268. package/runtime/workflow/lib/checkCode/finalize.ts +198 -0
  269. package/runtime/workflow/lib/checkCode/index.ts +18 -0
  270. package/runtime/workflow/lib/checkCode/plan.ts +163 -0
  271. package/runtime/workflow/lib/checkCodeReport.ts +133 -0
  272. package/runtime/workflow/lib/checkCodeRunner.ts +1225 -0
  273. package/runtime/workflow/lib/cliTool.ts +31 -0
  274. package/runtime/workflow/lib/config.ts +130 -0
  275. package/runtime/workflow/lib/contractInfoCandidates.ts +690 -0
  276. package/runtime/workflow/lib/create2.ts +278 -0
  277. package/runtime/workflow/lib/create2Hashes.ts +83 -0
  278. package/runtime/workflow/lib/deploymentInfo.ts +286 -0
  279. package/runtime/workflow/lib/deploymentRecords.ts +576 -0
  280. package/runtime/workflow/lib/deployments.ts +276 -0
  281. package/runtime/workflow/lib/erc1967.ts +57 -0
  282. package/runtime/workflow/lib/errors.ts +95 -0
  283. package/runtime/workflow/lib/executionId.ts +35 -0
  284. package/runtime/workflow/lib/executionPlan.ts +550 -0
  285. package/runtime/workflow/lib/executionProgress.ts +127 -0
  286. package/runtime/workflow/lib/external.ts +372 -0
  287. package/runtime/workflow/lib/externalExecutionScanner.ts +892 -0
  288. package/runtime/workflow/lib/forkSnapshot.ts +231 -0
  289. package/runtime/workflow/lib/gateTool.ts +261 -0
  290. package/runtime/workflow/lib/gateToolSync.ts +398 -0
  291. package/runtime/workflow/lib/lock.ts +388 -0
  292. package/runtime/workflow/lib/migrationState.ts +1246 -0
  293. package/runtime/workflow/lib/operatorExecution.ts +174 -0
  294. package/runtime/workflow/lib/parameters.ts +437 -0
  295. package/runtime/workflow/lib/pendingDeploymentReuse.ts +428 -0
  296. package/runtime/workflow/lib/proxy.ts +45 -0
  297. package/runtime/workflow/lib/registryCommit.ts +455 -0
  298. package/runtime/workflow/lib/release.ts +329 -0
  299. package/runtime/workflow/lib/releaseFinalize.ts +711 -0
  300. package/runtime/workflow/lib/releaseParameters.ts +248 -0
  301. package/runtime/workflow/lib/reporter.ts +502 -0
  302. package/runtime/workflow/lib/resultPaths.ts +49 -0
  303. package/runtime/workflow/lib/runtimeVersion.ts +28 -0
  304. package/runtime/workflow/lib/signer.ts +124 -0
  305. package/runtime/workflow/lib/signerIdentity.ts +22 -0
  306. package/runtime/workflow/lib/simulation.ts +415 -0
  307. package/runtime/workflow/lib/simulationCallers.ts +335 -0
  308. package/runtime/workflow/lib/sourceRpcPolicy.ts +41 -0
  309. package/runtime/workflow/lib/state.ts +25 -0
  310. package/runtime/workflow/lib/staticValidation.ts +142 -0
  311. package/runtime/workflow/lib/zksyncForkCapability.ts +80 -0
  312. package/runtime/workflow/lib/zksyncForkRunner.ts +505 -0
  313. package/runtime/workflow/reconcileExternal.ts +86 -0
  314. package/runtime/workflow/reconcileExternalRun.ts +88 -0
  315. package/runtime/workflow/releaseFinalize.ts +8 -0
  316. package/runtime/workflow/run.ts +1072 -0
  317. package/runtime/workflow/staticValidate.ts +23 -0
  318. package/runtime/workflow/steps/call.ts +10 -0
  319. package/runtime/workflow/steps/check.ts +10 -0
  320. package/runtime/workflow/steps/custom.ts +43 -0
  321. package/runtime/workflow/steps/deploy.ts +771 -0
  322. package/runtime/workflow/steps/upgrade.ts +598 -0
  323. package/runtime/workflow/steps/view.ts +10 -0
@@ -0,0 +1,771 @@
1
+ import path from "path";
2
+ import { ethers, network } from "../../projectHardhat";
3
+ import type {
4
+ GateToolDeploymentPlan,
5
+ GateToolPreparationPlanV1,
6
+ GateToolPreparationRequestV1,
7
+ GateToolTransactionPlan,
8
+ } from "gate-evm-tools/workflow";
9
+ import type { WorkflowContext } from "../run";
10
+ import {
11
+ requireExistingDeploymentPolicy,
12
+ resolveExistingDeploymentPolicyAction,
13
+ resolveValue,
14
+ WorkflowStep,
15
+ } from "../lib/parameters";
16
+ import {
17
+ actualContractName,
18
+ contractInfoKey,
19
+ findDeploymentAddress,
20
+ } from "../lib/deployments";
21
+ import type { DeploymentChange } from "../lib/deploymentRecords";
22
+ import {
23
+ assertCreate2AddressPolicy,
24
+ Create2Options,
25
+ prepareControlledMulticallTransaction,
26
+ resolveCreate2Options,
27
+ sendPreparedControlledMulticallTransaction,
28
+ } from "../lib/create2";
29
+ import { assertReusableDeployment } from "../lib/checkCodeReport";
30
+ import { getERC1967Implementation } from "../lib/erc1967";
31
+ import { recordParameterLockImplementationSalts } from "../lib/lock";
32
+ import {
33
+ deriveImplementationSalt,
34
+ FirstUpgradeOptions,
35
+ ProxyOptions,
36
+ } from "../lib/proxy";
37
+ import { decideControlledMulticallAuthority } from "../lib/authority";
38
+ import { impersonateWorkflowSimulationSigner } from "../lib/signer";
39
+ import { prepareGateToolWorkflow } from "../lib/gateTool";
40
+ import { syncGateToolUups } from "../lib/gateToolSync";
41
+ import { resolvePendingUupsReuse } from "../lib/pendingDeploymentReuse";
42
+
43
+ const resolveInContext = (
44
+ context: WorkflowContext,
45
+ value: unknown,
46
+ ): unknown => resolveValue(value, {
47
+ targetId: context.targetId,
48
+ target: context.target,
49
+ params: context.targetParams,
50
+ state: context.state,
51
+ });
52
+
53
+ const resolveArray = (
54
+ context: WorkflowContext,
55
+ value: unknown,
56
+ label: string,
57
+ ): unknown[] => {
58
+ const resolved = resolveInContext(context, value || []);
59
+ if (!Array.isArray(resolved)) throw new Error(`${label} must resolve to an array`);
60
+ return resolved;
61
+ };
62
+
63
+ const resolveObject = (
64
+ context: WorkflowContext,
65
+ value: unknown,
66
+ ): Record<string, unknown> => {
67
+ const resolved = resolveInContext(context, value || {});
68
+ if (!resolved || typeof resolved !== "object" || Array.isArray(resolved)) return {};
69
+ return resolved as Record<string, unknown>;
70
+ };
71
+
72
+ const resolveProxyOptions = (
73
+ context: WorkflowContext,
74
+ step: WorkflowStep,
75
+ ): { options: ProxyOptions } | undefined => {
76
+ if (step.proxy === undefined) return undefined;
77
+ const proxy = resolveObject(context, step.proxy);
78
+ const initializer = proxy.initializer === false
79
+ ? false
80
+ : typeof proxy.initializer === "string"
81
+ ? proxy.initializer
82
+ : undefined;
83
+ return {
84
+ options: {
85
+ kind: typeof proxy.kind === "string" ? proxy.kind : undefined,
86
+ initializer,
87
+ unsafeAllow: Array.isArray(proxy.unsafeAllow)
88
+ ? proxy.unsafeAllow.map((item) => String(item))
89
+ : undefined,
90
+ constructorArgs: proxy.constructorArgs === undefined
91
+ ? undefined
92
+ : resolveArray(context, proxy.constructorArgs, `Step ${step.id} proxy.constructorArgs`),
93
+ },
94
+ };
95
+ };
96
+
97
+ const assertCreate2Options = (
98
+ step: WorkflowStep,
99
+ options: Create2Options | undefined,
100
+ ): Create2Options => {
101
+ if (!options) throw new Error(`Deploy step ${step.id} requires strategy: create2`);
102
+ return options;
103
+ };
104
+
105
+ const setDeploymentState = (
106
+ context: WorkflowContext,
107
+ names: string[],
108
+ value: Record<string, unknown>,
109
+ ): void => {
110
+ for (const name of new Set(names)) context.state.set(name, value);
111
+ };
112
+
113
+ const stringObjectField = (
114
+ source: Record<string, unknown>,
115
+ key: string,
116
+ ): string | undefined => {
117
+ const value = source[key];
118
+ return typeof value === "string" && value.trim() ? value.trim() : undefined;
119
+ };
120
+
121
+ const resolveFirstUpgradeOptions = (
122
+ context: WorkflowContext,
123
+ step: WorkflowStep,
124
+ ): FirstUpgradeOptions | undefined => {
125
+ if (step.firstUpgrade === undefined) return undefined;
126
+ const firstUpgrade = resolveObject(context, step.firstUpgrade);
127
+ const contractName = stringObjectField(firstUpgrade, "contract");
128
+ if (!contractName) throw new Error(`Deploy step ${step.id} firstUpgrade requires contract`);
129
+ const callObject = resolveObject(context, firstUpgrade.call);
130
+ const fn = stringObjectField(callObject, "fn") || stringObjectField(callObject, "method");
131
+ return {
132
+ contractName,
133
+ call: fn
134
+ ? {
135
+ fn,
136
+ args: resolveArray(
137
+ context,
138
+ callObject.args || [],
139
+ `Step ${step.id} firstUpgrade.call.args`,
140
+ ),
141
+ }
142
+ : undefined,
143
+ constructorArgs: resolveArray(
144
+ context,
145
+ firstUpgrade.constructorArgs || [],
146
+ `Step ${step.id} firstUpgrade.constructorArgs`,
147
+ ),
148
+ unsafeAllow: Array.isArray(firstUpgrade.unsafeAllow)
149
+ ? firstUpgrade.unsafeAllow.map((item) => String(item))
150
+ : undefined,
151
+ };
152
+ };
153
+
154
+ const applyExistingDeploymentPolicy = async (
155
+ context: WorkflowContext,
156
+ step: WorkflowStep,
157
+ saveAs: string,
158
+ preparedChange: DeploymentChange,
159
+ create2Options: Create2Options,
160
+ declaredUpgradeable: boolean,
161
+ ): Promise<{
162
+ completed: boolean;
163
+ create2Options: Create2Options;
164
+ existingAddress?: string;
165
+ redeployReason?: string;
166
+ }> => {
167
+ const existing = findDeploymentAddress(context.root, context.config, context.targetId, saveAs);
168
+ if (!existing) return { completed: false, create2Options };
169
+ const policy = requireExistingDeploymentPolicy(context.existingDeploymentPolicies, saveAs);
170
+ const implementationAddress = await getERC1967Implementation(ethers.provider, existing);
171
+ const action = resolveExistingDeploymentPolicyAction(policy, {
172
+ instanceId: saveAs,
173
+ existingAddress: existing,
174
+ currentSalt: create2Options.salt,
175
+ upgradeable: declaredUpgradeable || implementationAddress !== undefined,
176
+ });
177
+ if (action.mode === "reuse") {
178
+ if (!context.releaseArtifactHash) {
179
+ throw new Error(
180
+ `Deploy step ${step.id} cannot reuse ${context.targetId}.${saveAs} without an execution artifactHash`,
181
+ );
182
+ }
183
+ const evidence = assertReusableDeployment(context.root, {
184
+ network: context.targetId,
185
+ scheme: create2Options.scheme,
186
+ instanceId: saveAs,
187
+ address: existing,
188
+ artifactHash: context.releaseArtifactHash,
189
+ });
190
+ context.deploymentRecorder?.prepare(preparedChange);
191
+ context.deploymentRecorder?.apply({
192
+ ...preparedChange,
193
+ address: existing,
194
+ proxyAddress: implementationAddress ? existing : undefined,
195
+ implementationAddress,
196
+ reused: true,
197
+ alreadyDeployed: true,
198
+ gateTool: {
199
+ outputPath: "scripts/checkcode/index.json",
200
+ data: { runId: evidence.runId, artifactHash: evidence.artifactHash },
201
+ },
202
+ });
203
+ setDeploymentState(context, [saveAs], {
204
+ address: existing,
205
+ implementationAddress,
206
+ reused: true,
207
+ alreadyDeployed: true,
208
+ });
209
+ context.reporter.result("execution", {
210
+ stepId: step.id,
211
+ kind: step.kind,
212
+ contract: preparedChange.actualContract,
213
+ saveAs,
214
+ strategy: "reuse",
215
+ address: existing,
216
+ implementationAddress,
217
+ checkCodeRunId: evidence.runId,
218
+ reused: true,
219
+ alreadyDeployed: true,
220
+ });
221
+ return { completed: true, create2Options, existingAddress: existing };
222
+ }
223
+ return {
224
+ completed: false,
225
+ existingAddress: existing,
226
+ redeployReason: action.reason,
227
+ create2Options: {
228
+ ...create2Options,
229
+ salt: action.salt,
230
+ expectedAddress: action.expectedAddress,
231
+ },
232
+ };
233
+ };
234
+
235
+ const deploymentForRole = (
236
+ plan: GateToolPreparationPlanV1,
237
+ role: GateToolDeploymentPlan["role"],
238
+ ): GateToolDeploymentPlan => {
239
+ const deployment = plan.deployments.find((entry) => entry.role === role);
240
+ if (!deployment) throw new Error(`GateTool plan is missing ${role} deployment evidence`);
241
+ return deployment;
242
+ };
243
+
244
+ const assertDeployedCode = async (
245
+ label: string,
246
+ address: string,
247
+ ): Promise<void> => {
248
+ const code = await ethers.provider.getCode(address);
249
+ if (!code || code === "0x") {
250
+ throw new Error(`${label} is missing deployed code at ${address}`);
251
+ }
252
+ };
253
+
254
+ const gateToolEvidenceDir = (context: WorkflowContext): string => path.join(
255
+ context.taskDir,
256
+ "results",
257
+ context.targetId,
258
+ context.executionId,
259
+ "gate-tool",
260
+ context.mode,
261
+ );
262
+
263
+ const runGateToolControlledMulticall = async (
264
+ context: WorkflowContext,
265
+ step: WorkflowStep,
266
+ create2: Create2Options,
267
+ transactions: GateToolTransactionPlan[],
268
+ ): Promise<{ external: boolean; transactionId?: string; txHash?: string }> => {
269
+ if (transactions.length === 0) return { external: false };
270
+ if (!create2.controlledMulticall) {
271
+ throw new Error(`Deploy step ${step.id} requires controlledMulticall`);
272
+ }
273
+ if (!context.signer || !context.signerAddress) {
274
+ throw new Error(`Deploy step ${step.id} requires a signer`);
275
+ }
276
+ const prepared = prepareControlledMulticallTransaction(
277
+ create2.controlledMulticall,
278
+ transactions.map((transaction) => ({
279
+ target: transaction.to,
280
+ value: transaction.value,
281
+ data: transaction.data,
282
+ ...(transaction.factoryDeps === undefined
283
+ ? {}
284
+ : { factoryDeps: transaction.factoryDeps }),
285
+ })),
286
+ create2.scheme,
287
+ );
288
+ const multicall = await ethers.getContractAt(
289
+ "Multicall3",
290
+ create2.controlledMulticall,
291
+ context.signer,
292
+ );
293
+ const authority = await decideControlledMulticallAuthority(
294
+ multicall as unknown as {
295
+ callers: (caller: string) => Promise<boolean>;
296
+ factoryCallers: (factoryAddress: string, caller: string) => Promise<boolean>;
297
+ owner?: () => Promise<unknown>;
298
+ },
299
+ create2.factory,
300
+ context.target,
301
+ context.signerAddress,
302
+ );
303
+ const executor = authority.mode === "execute" ? context.signerAddress : authority.executor;
304
+ if (!executor) throw new Error(`Deploy step ${step.id} cannot resolve its required executor`);
305
+ if (create2.scheme === "zksync-eravm" && authority.mode !== "execute") {
306
+ throw new Error(
307
+ `Deploy step ${step.id} requires unsupported zkSync external Admin execution`,
308
+ );
309
+ }
310
+
311
+ if (!context.executionPlanner) {
312
+ if (authority.mode !== "execute") {
313
+ throw new Error(`Deploy step ${step.id} requires a locked mixed-authority execution plan`);
314
+ }
315
+ const transaction = await sendPreparedControlledMulticallTransaction(prepared, context.signer);
316
+ return { external: false, txHash: transaction.hash };
317
+ }
318
+
319
+ const planned = context.executionPlanner.add({
320
+ stepId: step.id,
321
+ executor,
322
+ to: prepared.target,
323
+ value: prepared.value,
324
+ data: prepared.data,
325
+ operation: 0,
326
+ ...(prepared.scheme === undefined ? {} : { scheme: prepared.scheme }),
327
+ ...(prepared.factoryDeps === undefined ? {} : { factoryDeps: prepared.factoryDeps }),
328
+ });
329
+ if (planned.executionAction === "replay") {
330
+ return {
331
+ external: planned.route === "external",
332
+ transactionId: planned.transactionId,
333
+ txHash: planned.transactionHash,
334
+ };
335
+ }
336
+ if (planned.route === "external" && context.mode !== "simulate") {
337
+ context.externalCalls.push({
338
+ transactionId: planned.transactionId,
339
+ stepId: planned.stepId,
340
+ to: planned.to,
341
+ value: planned.value,
342
+ data: planned.data,
343
+ operation: planned.operation,
344
+ method: prepared.method,
345
+ args: prepared.calls,
346
+ executor: planned.executor,
347
+ reason: authority.reason,
348
+ });
349
+ return { external: true, transactionId: planned.transactionId };
350
+ }
351
+ const selectedSigner = planned.route === "external"
352
+ ? await impersonateWorkflowSimulationSigner(planned.executor)
353
+ : context.signer;
354
+ const transaction = await sendPreparedControlledMulticallTransaction(prepared, selectedSigner);
355
+ if (context.mode === "execute" && planned.route === "operator") {
356
+ context.operatorReceipts.push({
357
+ transactionId: planned.transactionId,
358
+ transactionHash: transaction.hash,
359
+ });
360
+ }
361
+ return {
362
+ external: false,
363
+ transactionId: planned.transactionId,
364
+ txHash: transaction.hash,
365
+ };
366
+ };
367
+
368
+ const addressPolicy = (options: Create2Options) => (
369
+ options.expectedAddress === undefined && options.leadingZeroBytes === undefined
370
+ ? undefined
371
+ : {
372
+ ...(options.expectedAddress === undefined
373
+ ? {}
374
+ : { expectedAddress: options.expectedAddress }),
375
+ ...(options.leadingZeroBytes === undefined
376
+ ? {}
377
+ : { leadingZeroBytes: options.leadingZeroBytes }),
378
+ }
379
+ );
380
+
381
+ const gateToolChange = (
382
+ context: WorkflowContext,
383
+ planPath: string,
384
+ plan: GateToolPreparationPlanV1,
385
+ ) => ({
386
+ outputPath: path.relative(context.root, planPath).split(path.sep).join("/"),
387
+ data: plan as unknown as Record<string, unknown>,
388
+ });
389
+
390
+ export const runDeployStep = async (
391
+ context: WorkflowContext,
392
+ step: WorkflowStep,
393
+ ): Promise<void> => {
394
+ const contractName = String(step.contract);
395
+ const saveAs = typeof step.saveAs === "string" ? step.saveAs.trim() : "";
396
+ if (!saveAs) throw new Error(`Deploy step ${step.id} requires saveAs`);
397
+ const create2Options = assertCreate2Options(step, resolveCreate2Options(context, step));
398
+ const proxy = resolveProxyOptions(context, step);
399
+ const recorder = context.mode === "execute" ? context.deploymentRecorder : undefined;
400
+ if (context.mode === "execute" && !recorder) {
401
+ throw new Error(`Deploy step ${step.id} requires an execution deployment recorder`);
402
+ }
403
+
404
+ if (proxy) {
405
+ const firstUpgrade = resolveFirstUpgradeOptions(context, step);
406
+ if (step.upgradeableStrategy !== "uups-placeholder-proxy" || !firstUpgrade) {
407
+ throw new Error(`Deploy step ${step.id} requires firstUpgrade for uups-placeholder-proxy`);
408
+ }
409
+ if ((proxy.options.kind || "uups") !== "uups") {
410
+ throw new Error(`Deploy step ${step.id} only supports UUPS placeholder proxies`);
411
+ }
412
+ if (proxy.options.initializer !== false) {
413
+ throw new Error(
414
+ `Deploy step ${step.id} must use proxy.initializer: false for uups-placeholder-proxy`,
415
+ );
416
+ }
417
+ if (!create2Options.controlledMulticall) {
418
+ throw new Error(`Deploy step ${step.id} requires controlledMulticall for atomic firstUpgrade`);
419
+ }
420
+ if (!create2Options.uupsPlaceholderImplementation) {
421
+ throw new Error(`Deploy step ${step.id} requires target.uups.placeholderImplementation`);
422
+ }
423
+
424
+ const actualContract = actualContractName(firstUpgrade.contractName);
425
+ const registryKey = contractInfoKey(saveAs, firstUpgrade.contractName);
426
+ const preparedChange: DeploymentChange = {
427
+ stepId: step.id,
428
+ kind: "deploy",
429
+ instanceId: saveAs,
430
+ actualContract,
431
+ contractInfoKey: registryKey,
432
+ strategy: "create2",
433
+ proxyKind: "uups",
434
+ factory: create2Options.factory,
435
+ multicall: create2Options.controlledMulticall,
436
+ salt: create2Options.salt,
437
+ expectedAddress: create2Options.expectedAddress,
438
+ leadingZeroBytes: create2Options.leadingZeroBytes,
439
+ placeholderImplementationAddress: create2Options.uupsPlaceholderImplementation,
440
+ };
441
+ const existingResolution = await applyExistingDeploymentPolicy(
442
+ context,
443
+ step,
444
+ saveAs,
445
+ preparedChange,
446
+ create2Options,
447
+ true,
448
+ );
449
+ if (existingResolution.completed) return;
450
+ const effectiveCreate2 = existingResolution.create2Options;
451
+ const pendingReuse = context.parameterLockExecutionId
452
+ ? await resolvePendingUupsReuse({
453
+ root: context.root,
454
+ taskDir: context.taskDir,
455
+ taskId: context.taskId,
456
+ currentExecutionId: context.parameterLockExecutionId,
457
+ network: context.targetId,
458
+ stepId: step.id,
459
+ instanceId: saveAs,
460
+ actualContract,
461
+ contractInfoKey: registryKey,
462
+ scheme: effectiveCreate2.scheme,
463
+ factory: effectiveCreate2.factory,
464
+ multicall: effectiveCreate2.controlledMulticall!,
465
+ proxySalt: effectiveCreate2.salt,
466
+ expectedAddress: effectiveCreate2.expectedAddress,
467
+ placeholderImplementationAddress: effectiveCreate2.uupsPlaceholderImplementation!,
468
+ provider: ethers.provider,
469
+ blockTag: context.mode === "simulate"
470
+ ? context.simulation.snapshot?.blockNumber
471
+ : undefined,
472
+ })
473
+ : undefined;
474
+ const implementationSalt = pendingReuse?.implementationSalt ?? deriveImplementationSalt(
475
+ context.executionId,
476
+ firstUpgrade.contractName,
477
+ effectiveCreate2.salt,
478
+ );
479
+ const request: GateToolPreparationRequestV1 = {
480
+ version: 1,
481
+ kind: "uups-placeholder-deploy",
482
+ scheme: effectiveCreate2.scheme,
483
+ network: network.name,
484
+ target: context.targetId,
485
+ contract: firstUpgrade.contractName,
486
+ constructorArgs: firstUpgrade.constructorArgs || [],
487
+ factory: effectiveCreate2.factory,
488
+ proxyKind: "uups",
489
+ implementationSalt,
490
+ proxySalt: effectiveCreate2.salt,
491
+ placeholderImplementation: effectiveCreate2.uupsPlaceholderImplementation!,
492
+ ...(firstUpgrade.unsafeAllow || proxy.options.unsafeAllow
493
+ ? { unsafeAllow: firstUpgrade.unsafeAllow || proxy.options.unsafeAllow }
494
+ : {}),
495
+ ...(addressPolicy(effectiveCreate2)
496
+ ? { proxyAddressPolicy: addressPolicy(effectiveCreate2) }
497
+ : {}),
498
+ ...(firstUpgrade.call
499
+ ? { call: { method: firstUpgrade.call.fn, args: firstUpgrade.call.args } }
500
+ : {}),
501
+ };
502
+ const prepared = await prepareGateToolWorkflow({
503
+ root: context.root,
504
+ evidenceDir: gateToolEvidenceDir(context),
505
+ evidenceName: step.id,
506
+ request,
507
+ readBlockTag: context.mode === "simulate"
508
+ ? context.simulation.snapshot?.blockNumber
509
+ : undefined,
510
+ });
511
+ const implementation = deploymentForRole(prepared.plan, "implementation");
512
+ const proxyDeployment = deploymentForRole(prepared.plan, "proxy");
513
+ if (pendingReuse && (
514
+ prepared.plan.transactions.length !== 0
515
+ || prepared.plan.artifact.digest !== pendingReuse.evidence.artifactDigest
516
+ || implementation.address.toLowerCase() !== pendingReuse.implementationAddress.toLowerCase()
517
+ || proxyDeployment.address.toLowerCase() !== pendingReuse.proxyAddress.toLowerCase()
518
+ )) {
519
+ throw new Error(
520
+ `Deploy step ${step.id} current GateTool plan does not match trusted pending reuse evidence`,
521
+ );
522
+ }
523
+ assertCreate2AddressPolicy(
524
+ `${firstUpgrade.contractName} proxy`,
525
+ proxyDeployment.address,
526
+ effectiveCreate2,
527
+ );
528
+ if (
529
+ existingResolution.existingAddress
530
+ && proxyDeployment.address.toLowerCase() === existingResolution.existingAddress.toLowerCase()
531
+ ) {
532
+ throw new Error(`Deploy step ${step.id} redeploy predicted the existing address`);
533
+ }
534
+ const gateTool = gateToolChange(context, prepared.planPath, prepared.plan);
535
+ const plannedChange: DeploymentChange = {
536
+ ...preparedChange,
537
+ salt: effectiveCreate2.salt,
538
+ previousAddress: existingResolution.existingAddress,
539
+ redeployReason: existingResolution.redeployReason,
540
+ implementationAddress: implementation.address,
541
+ implementationSalt,
542
+ constructorArgs: firstUpgrade.constructorArgs || [],
543
+ predictedAddress: proxyDeployment.address,
544
+ gateTool,
545
+ ...(pendingReuse ? { pendingReuse: pendingReuse.evidence } : {}),
546
+ };
547
+ if (context.parameterLockExecutionId) {
548
+ recordParameterLockImplementationSalts(
549
+ context.taskDir,
550
+ context.parameterLockExecutionId,
551
+ { [`${step.id}.implementation`]: implementationSalt },
552
+ );
553
+ }
554
+ recorder?.prepare(plannedChange);
555
+ if (context.mode === "execute") {
556
+ recorder?.stageAddressCandidate(plannedChange, proxyDeployment.address);
557
+ }
558
+ const execution = await runGateToolControlledMulticall(
559
+ context,
560
+ step,
561
+ effectiveCreate2,
562
+ prepared.plan.transactions,
563
+ );
564
+ if (context.mode === "execute" && execution.transactionId) {
565
+ recorder?.bindProxyTransaction(step.id, execution.transactionId);
566
+ }
567
+ if (!execution.external) {
568
+ await assertDeployedCode(
569
+ `${firstUpgrade.contractName} implementation`,
570
+ implementation.address,
571
+ );
572
+ await assertDeployedCode("ERC1967Proxy", proxyDeployment.address);
573
+ const currentImplementation = await getERC1967Implementation(
574
+ ethers.provider,
575
+ proxyDeployment.address,
576
+ );
577
+ if (
578
+ !currentImplementation
579
+ || currentImplementation.toLowerCase() !== implementation.address.toLowerCase()
580
+ ) {
581
+ throw new Error(
582
+ `ERC1967Proxy ${proxyDeployment.address} does not point to GateTool implementation ${implementation.address}`,
583
+ );
584
+ }
585
+ }
586
+ const gateToolSync = context.mode === "execute"
587
+ && !execution.external
588
+ && proxyDeployment.status !== "reused"
589
+ ? await syncGateToolUups({
590
+ root: context.root,
591
+ evidenceDir: gateToolEvidenceDir(context),
592
+ evidenceName: step.id,
593
+ scheme: prepared.plan.scheme,
594
+ network: network.name,
595
+ target: context.targetId,
596
+ manifestDir: context.target.openzeppelin.manifestDir,
597
+ proxy: proxyDeployment.address,
598
+ implementation: implementation.address,
599
+ contract: actualContract,
600
+ constructorArgs: firstUpgrade.constructorArgs || [],
601
+ transactionHash: execution.txHash || "",
602
+ })
603
+ : undefined;
604
+ if (context.mode === "execute" && !execution.external) {
605
+ recorder?.applyAddress({
606
+ ...plannedChange,
607
+ address: proxyDeployment.address,
608
+ proxyAddress: proxyDeployment.address,
609
+ txHash: execution.txHash,
610
+ gateToolSync,
611
+ reused: proxyDeployment.status === "reused",
612
+ alreadyDeployed: proxyDeployment.status === "reused",
613
+ }, proxyDeployment.address);
614
+ }
615
+ setDeploymentState(context, [saveAs], {
616
+ address: proxyDeployment.address,
617
+ proxyAddress: proxyDeployment.address,
618
+ implementationAddress: implementation.address,
619
+ implementationSalt,
620
+ placeholderImplementationAddress: effectiveCreate2.uupsPlaceholderImplementation,
621
+ txHash: execution.txHash,
622
+ external: execution.external,
623
+ });
624
+ context.reporter.result("execution", {
625
+ stepId: step.id,
626
+ kind: step.kind,
627
+ mode: execution.external ? "external" : context.mode,
628
+ transactionId: execution.transactionId,
629
+ contract: contractName,
630
+ actualContract,
631
+ saveAs,
632
+ contractInfoKey: registryKey,
633
+ strategy: "create2",
634
+ scheme: prepared.plan.scheme,
635
+ proxy: "uups",
636
+ address: proxyDeployment.address,
637
+ implementationAddress: implementation.address,
638
+ firstUpgradeImplementationAddress: implementation.address,
639
+ placeholderImplementationAddress: effectiveCreate2.uupsPlaceholderImplementation,
640
+ predictedAddress: proxyDeployment.address,
641
+ reused: proxyDeployment.status === "reused",
642
+ alreadyDeployed: proxyDeployment.status === "reused",
643
+ txHash: execution.txHash,
644
+ gateToolPlan: gateTool.outputPath,
645
+ gateToolSync: gateToolSync?.outputPath,
646
+ pendingReuse: pendingReuse?.evidence,
647
+ });
648
+ return;
649
+ }
650
+
651
+ const args = resolveArray(context, step.args || [], `Step ${step.id} args`);
652
+ const actualContract = actualContractName(contractName);
653
+ const registryKey = contractInfoKey(saveAs, contractName);
654
+ let preparedChange: DeploymentChange = {
655
+ stepId: step.id,
656
+ kind: "deploy",
657
+ instanceId: saveAs,
658
+ actualContract,
659
+ contractInfoKey: registryKey,
660
+ strategy: "create2",
661
+ factory: create2Options.factory,
662
+ multicall: create2Options.controlledMulticall,
663
+ salt: create2Options.salt,
664
+ expectedAddress: create2Options.expectedAddress,
665
+ leadingZeroBytes: create2Options.leadingZeroBytes,
666
+ };
667
+ const existingResolution = await applyExistingDeploymentPolicy(
668
+ context,
669
+ step,
670
+ saveAs,
671
+ preparedChange,
672
+ create2Options,
673
+ false,
674
+ );
675
+ if (existingResolution.completed) return;
676
+ const effectiveCreate2 = existingResolution.create2Options;
677
+ const request: GateToolPreparationRequestV1 = {
678
+ version: 1,
679
+ kind: "create2-deploy",
680
+ scheme: effectiveCreate2.scheme,
681
+ network: network.name,
682
+ target: context.targetId,
683
+ contract: contractName,
684
+ constructorArgs: args,
685
+ factory: effectiveCreate2.factory,
686
+ salt: effectiveCreate2.salt,
687
+ ...(effectiveCreate2.create2ForwardValue === undefined
688
+ ? {}
689
+ : { create2ForwardValue: effectiveCreate2.create2ForwardValue }),
690
+ ...(effectiveCreate2.callForwardValue === undefined
691
+ ? {}
692
+ : { callForwardValue: effectiveCreate2.callForwardValue }),
693
+ ...(addressPolicy(effectiveCreate2)
694
+ ? { addressPolicy: addressPolicy(effectiveCreate2) }
695
+ : {}),
696
+ };
697
+ const prepared = await prepareGateToolWorkflow({
698
+ root: context.root,
699
+ evidenceDir: gateToolEvidenceDir(context),
700
+ evidenceName: step.id,
701
+ request,
702
+ readBlockTag: context.mode === "simulate"
703
+ ? context.simulation.snapshot?.blockNumber
704
+ : undefined,
705
+ });
706
+ const deployment = deploymentForRole(prepared.plan, "contract");
707
+ assertCreate2AddressPolicy(contractName, deployment.address, effectiveCreate2);
708
+ if (
709
+ existingResolution.existingAddress
710
+ && deployment.address.toLowerCase() === existingResolution.existingAddress.toLowerCase()
711
+ ) {
712
+ throw new Error(`Deploy step ${step.id} redeploy predicted the existing address`);
713
+ }
714
+ const gateTool = gateToolChange(context, prepared.planPath, prepared.plan);
715
+ preparedChange = {
716
+ ...preparedChange,
717
+ salt: effectiveCreate2.salt,
718
+ expectedAddress: effectiveCreate2.expectedAddress,
719
+ previousAddress: existingResolution.existingAddress,
720
+ redeployReason: existingResolution.redeployReason,
721
+ predictedAddress: deployment.address,
722
+ gateTool,
723
+ };
724
+ recorder?.prepare(preparedChange);
725
+ if (context.mode === "execute") {
726
+ recorder?.stageAddressCandidate(preparedChange, deployment.address);
727
+ }
728
+ const execution = await runGateToolControlledMulticall(
729
+ context,
730
+ step,
731
+ effectiveCreate2,
732
+ prepared.plan.transactions,
733
+ );
734
+ if (!execution.external) {
735
+ await assertDeployedCode(contractName, deployment.address);
736
+ }
737
+ if (context.mode === "execute" && !execution.external) {
738
+ recorder?.applyAddress({
739
+ ...preparedChange,
740
+ address: deployment.address,
741
+ txHash: execution.txHash,
742
+ reused: deployment.status === "reused",
743
+ alreadyDeployed: deployment.status === "reused",
744
+ }, deployment.address);
745
+ }
746
+ context.state.set(saveAs, {
747
+ address: deployment.address,
748
+ predictedAddress: deployment.address,
749
+ txHash: execution.txHash,
750
+ external: execution.external,
751
+ alreadyDeployed: deployment.status === "reused",
752
+ });
753
+ context.reporter.result("execution", {
754
+ stepId: step.id,
755
+ kind: step.kind,
756
+ mode: execution.external ? "external" : context.mode,
757
+ transactionId: execution.transactionId,
758
+ contract: contractName,
759
+ actualContract,
760
+ saveAs,
761
+ contractInfoKey: registryKey,
762
+ strategy: "create2",
763
+ scheme: prepared.plan.scheme,
764
+ address: deployment.address,
765
+ predictedAddress: deployment.address,
766
+ reused: deployment.status === "reused",
767
+ alreadyDeployed: deployment.status === "reused",
768
+ txHash: execution.txHash,
769
+ gateToolPlan: gateTool.outputPath,
770
+ });
771
+ };