gate-evm-tools 1.0.25 → 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 (352) hide show
  1. package/README.md +33 -11
  2. package/bin/workflow.cjs +19 -0
  3. package/dist/commands/check.d.ts.map +1 -1
  4. package/dist/commands/check.js +21 -57
  5. package/dist/commands/check.js.map +1 -1
  6. package/dist/commands/checkBatch.d.ts +4 -0
  7. package/dist/commands/checkBatch.d.ts.map +1 -0
  8. package/dist/commands/checkBatch.js +57 -0
  9. package/dist/commands/checkBatch.js.map +1 -0
  10. package/dist/commands/checkOptions.d.ts +3 -0
  11. package/dist/commands/checkOptions.d.ts.map +1 -1
  12. package/dist/commands/checkOptions.js +10 -1
  13. package/dist/commands/checkOptions.js.map +1 -1
  14. package/dist/commands/prepare.d.ts +1 -2
  15. package/dist/commands/prepare.d.ts.map +1 -1
  16. package/dist/commands/prepare.js +2 -17
  17. package/dist/commands/prepare.js.map +1 -1
  18. package/dist/commands/sync.d.ts.map +1 -1
  19. package/dist/commands/sync.js +2 -17
  20. package/dist/commands/sync.js.map +1 -1
  21. package/dist/commands/validate.d.ts.map +1 -1
  22. package/dist/commands/validate.js +2 -17
  23. package/dist/commands/validate.js.map +1 -1
  24. package/dist/core/BytecodeChecker.d.ts.map +1 -1
  25. package/dist/core/BytecodeChecker.js +16 -1
  26. package/dist/core/BytecodeChecker.js.map +1 -1
  27. package/dist/core/legacyProxyArtifact.d.ts +6 -0
  28. package/dist/core/legacyProxyArtifact.d.ts.map +1 -0
  29. package/dist/core/legacyProxyArtifact.js +36 -0
  30. package/dist/core/legacyProxyArtifact.js.map +1 -0
  31. package/dist/index.js +3 -3
  32. package/dist/index.js.map +1 -1
  33. package/dist/types.d.ts +2 -2
  34. package/dist/types.d.ts.map +1 -1
  35. package/dist/utils/hardhat.d.ts +4 -0
  36. package/dist/utils/hardhat.d.ts.map +1 -0
  37. package/dist/utils/hardhat.js +9 -0
  38. package/dist/utils/hardhat.js.map +1 -0
  39. package/dist-runtime/config/hardhatAdapters.d.ts +5 -0
  40. package/dist-runtime/config/hardhatAdapters.js +53 -0
  41. package/dist-runtime/config/hardhatAdapters.js.map +1 -0
  42. package/dist-runtime/config/networks.d.ts +8 -0
  43. package/dist-runtime/config/networks.js +269 -0
  44. package/dist-runtime/config/networks.js.map +1 -0
  45. package/dist-runtime/config/openzeppelin.d.ts +28 -0
  46. package/dist-runtime/config/openzeppelin.js +144 -0
  47. package/dist-runtime/config/openzeppelin.js.map +1 -0
  48. package/dist-runtime/config/rpc.d.ts +7 -0
  49. package/dist-runtime/config/rpc.js +19 -0
  50. package/dist-runtime/config/rpc.js.map +1 -0
  51. package/dist-runtime/config/zksyncSolcPath.d.ts +1 -0
  52. package/dist-runtime/config/zksyncSolcPath.js +61 -0
  53. package/dist-runtime/config/zksyncSolcPath.js.map +1 -0
  54. package/dist-runtime/migrate.d.ts +13 -0
  55. package/dist-runtime/migrate.js +208 -0
  56. package/dist-runtime/migrate.js.map +1 -0
  57. package/dist-runtime/package.json +1 -0
  58. package/dist-runtime/projectHardhat.d.ts +4 -0
  59. package/dist-runtime/projectHardhat.js +16 -0
  60. package/dist-runtime/projectHardhat.js.map +1 -0
  61. package/dist-runtime/runtime-identity.json +4 -0
  62. package/dist-runtime/template-migration.json +293 -0
  63. package/dist-runtime/workflow/checkCode.d.ts +1 -0
  64. package/dist-runtime/workflow/checkCode.js +16 -0
  65. package/dist-runtime/workflow/checkCode.js.map +1 -0
  66. package/dist-runtime/workflow/checkCodeFinalize.d.ts +1 -0
  67. package/dist-runtime/workflow/checkCodeFinalize.js +11 -0
  68. package/dist-runtime/workflow/checkCodeFinalize.js.map +1 -0
  69. package/dist-runtime/workflow/checkCodePlan.d.ts +1 -0
  70. package/dist-runtime/workflow/checkCodePlan.js +11 -0
  71. package/dist-runtime/workflow/checkCodePlan.js.map +1 -0
  72. package/dist-runtime/workflow/cli.d.ts +1 -0
  73. package/dist-runtime/workflow/cli.js +302 -0
  74. package/dist-runtime/workflow/cli.js.map +1 -0
  75. package/dist-runtime/workflow/commitContractInfo.d.ts +1 -0
  76. package/dist-runtime/workflow/commitContractInfo.js +64 -0
  77. package/dist-runtime/workflow/commitContractInfo.js.map +1 -0
  78. package/dist-runtime/workflow/create2Hashes.d.ts +1 -0
  79. package/dist-runtime/workflow/create2Hashes.js +76 -0
  80. package/dist-runtime/workflow/create2Hashes.js.map +1 -0
  81. package/dist-runtime/workflow/forkSourceProxy.d.ts +1 -0
  82. package/dist-runtime/workflow/forkSourceProxy.js +151 -0
  83. package/dist-runtime/workflow/forkSourceProxy.js.map +1 -0
  84. package/dist-runtime/workflow/importState.d.ts +1 -0
  85. package/dist-runtime/workflow/importState.js +193 -0
  86. package/dist-runtime/workflow/importState.js.map +1 -0
  87. package/dist-runtime/workflow/lib/authority.d.ts +28 -0
  88. package/dist-runtime/workflow/lib/authority.js +122 -0
  89. package/dist-runtime/workflow/lib/authority.js.map +1 -0
  90. package/dist-runtime/workflow/lib/calldata.d.ts +2 -0
  91. package/dist-runtime/workflow/lib/calldata.js +8 -0
  92. package/dist-runtime/workflow/lib/calldata.js.map +1 -0
  93. package/dist-runtime/workflow/lib/calls.d.ts +23 -0
  94. package/dist-runtime/workflow/lib/calls.js +316 -0
  95. package/dist-runtime/workflow/lib/calls.js.map +1 -0
  96. package/dist-runtime/workflow/lib/checkCode/args.d.ts +2 -0
  97. package/dist-runtime/workflow/lib/checkCode/args.js +68 -0
  98. package/dist-runtime/workflow/lib/checkCode/args.js.map +1 -0
  99. package/dist-runtime/workflow/lib/checkCode/command.d.ts +5 -0
  100. package/dist-runtime/workflow/lib/checkCode/command.js +35 -0
  101. package/dist-runtime/workflow/lib/checkCode/command.js.map +1 -0
  102. package/dist-runtime/workflow/lib/checkCode/dependencies.d.ts +6 -0
  103. package/dist-runtime/workflow/lib/checkCode/dependencies.js +125 -0
  104. package/dist-runtime/workflow/lib/checkCode/dependencies.js.map +1 -0
  105. package/dist-runtime/workflow/lib/checkCode/finalize.d.ts +17 -0
  106. package/dist-runtime/workflow/lib/checkCode/finalize.js +174 -0
  107. package/dist-runtime/workflow/lib/checkCode/finalize.js.map +1 -0
  108. package/dist-runtime/workflow/lib/checkCode/index.d.ts +3 -0
  109. package/dist-runtime/workflow/lib/checkCode/index.js +20 -0
  110. package/dist-runtime/workflow/lib/checkCode/index.js.map +1 -0
  111. package/dist-runtime/workflow/lib/checkCode/plan.d.ts +22 -0
  112. package/dist-runtime/workflow/lib/checkCode/plan.js +145 -0
  113. package/dist-runtime/workflow/lib/checkCode/plan.js.map +1 -0
  114. package/dist-runtime/workflow/lib/checkCodeReport.d.ts +25 -0
  115. package/dist-runtime/workflow/lib/checkCodeReport.js +102 -0
  116. package/dist-runtime/workflow/lib/checkCodeReport.js.map +1 -0
  117. package/dist-runtime/workflow/lib/checkCodeRunner.d.ts +87 -0
  118. package/dist-runtime/workflow/lib/checkCodeRunner.js +964 -0
  119. package/dist-runtime/workflow/lib/checkCodeRunner.js.map +1 -0
  120. package/dist-runtime/workflow/lib/cliTool.d.ts +10 -0
  121. package/dist-runtime/workflow/lib/cliTool.js +25 -0
  122. package/dist-runtime/workflow/lib/cliTool.js.map +1 -0
  123. package/dist-runtime/workflow/lib/config.d.ts +33 -0
  124. package/dist-runtime/workflow/lib/config.js +100 -0
  125. package/dist-runtime/workflow/lib/config.js.map +1 -0
  126. package/dist-runtime/workflow/lib/contractInfoCandidates.d.ts +82 -0
  127. package/dist-runtime/workflow/lib/contractInfoCandidates.js +441 -0
  128. package/dist-runtime/workflow/lib/contractInfoCandidates.js.map +1 -0
  129. package/dist-runtime/workflow/lib/create2.d.ts +49 -0
  130. package/dist-runtime/workflow/lib/create2.js +194 -0
  131. package/dist-runtime/workflow/lib/create2.js.map +1 -0
  132. package/dist-runtime/workflow/lib/create2Hashes.d.ts +22 -0
  133. package/dist-runtime/workflow/lib/create2Hashes.js +57 -0
  134. package/dist-runtime/workflow/lib/create2Hashes.js.map +1 -0
  135. package/dist-runtime/workflow/lib/deploymentInfo.d.ts +40 -0
  136. package/dist-runtime/workflow/lib/deploymentInfo.js +240 -0
  137. package/dist-runtime/workflow/lib/deploymentInfo.js.map +1 -0
  138. package/dist-runtime/workflow/lib/deploymentRecords.d.ts +137 -0
  139. package/dist-runtime/workflow/lib/deploymentRecords.js +374 -0
  140. package/dist-runtime/workflow/lib/deploymentRecords.js.map +1 -0
  141. package/dist-runtime/workflow/lib/deployments.d.ts +21 -0
  142. package/dist-runtime/workflow/lib/deployments.js +240 -0
  143. package/dist-runtime/workflow/lib/deployments.js.map +1 -0
  144. package/dist-runtime/workflow/lib/erc1967.d.ts +5 -0
  145. package/dist-runtime/workflow/lib/erc1967.js +29 -0
  146. package/dist-runtime/workflow/lib/erc1967.js.map +1 -0
  147. package/dist-runtime/workflow/lib/errors.d.ts +6 -0
  148. package/dist-runtime/workflow/lib/errors.js +77 -0
  149. package/dist-runtime/workflow/lib/errors.js.map +1 -0
  150. package/dist-runtime/workflow/lib/executionId.d.ts +7 -0
  151. package/dist-runtime/workflow/lib/executionId.js +26 -0
  152. package/dist-runtime/workflow/lib/executionId.js.map +1 -0
  153. package/dist-runtime/workflow/lib/executionPlan.d.ts +85 -0
  154. package/dist-runtime/workflow/lib/executionPlan.js +450 -0
  155. package/dist-runtime/workflow/lib/executionPlan.js.map +1 -0
  156. package/dist-runtime/workflow/lib/executionProgress.d.ts +5 -0
  157. package/dist-runtime/workflow/lib/executionProgress.js +100 -0
  158. package/dist-runtime/workflow/lib/executionProgress.js.map +1 -0
  159. package/dist-runtime/workflow/lib/external.d.ts +62 -0
  160. package/dist-runtime/workflow/lib/external.js +282 -0
  161. package/dist-runtime/workflow/lib/external.js.map +1 -0
  162. package/dist-runtime/workflow/lib/externalExecutionScanner.d.ts +64 -0
  163. package/dist-runtime/workflow/lib/externalExecutionScanner.js +638 -0
  164. package/dist-runtime/workflow/lib/externalExecutionScanner.js.map +1 -0
  165. package/dist-runtime/workflow/lib/forkSnapshot.d.ts +34 -0
  166. package/dist-runtime/workflow/lib/forkSnapshot.js +167 -0
  167. package/dist-runtime/workflow/lib/forkSnapshot.js.map +1 -0
  168. package/dist-runtime/workflow/lib/gateTool.d.ts +16 -0
  169. package/dist-runtime/workflow/lib/gateTool.js +177 -0
  170. package/dist-runtime/workflow/lib/gateTool.js.map +1 -0
  171. package/dist-runtime/workflow/lib/gateToolSync.d.ts +22 -0
  172. package/dist-runtime/workflow/lib/gateToolSync.js +253 -0
  173. package/dist-runtime/workflow/lib/gateToolSync.js.map +1 -0
  174. package/dist-runtime/workflow/lib/lock.d.ts +52 -0
  175. package/dist-runtime/workflow/lib/lock.js +269 -0
  176. package/dist-runtime/workflow/lib/lock.js.map +1 -0
  177. package/dist-runtime/workflow/lib/migrationState.d.ts +103 -0
  178. package/dist-runtime/workflow/lib/migrationState.js +920 -0
  179. package/dist-runtime/workflow/lib/migrationState.js.map +1 -0
  180. package/dist-runtime/workflow/lib/operatorExecution.d.ts +28 -0
  181. package/dist-runtime/workflow/lib/operatorExecution.js +134 -0
  182. package/dist-runtime/workflow/lib/operatorExecution.js.map +1 -0
  183. package/dist-runtime/workflow/lib/parameters.d.ts +58 -0
  184. package/dist-runtime/workflow/lib/parameters.js +322 -0
  185. package/dist-runtime/workflow/lib/parameters.js.map +1 -0
  186. package/dist-runtime/workflow/lib/pendingDeploymentReuse.d.ts +29 -0
  187. package/dist-runtime/workflow/lib/pendingDeploymentReuse.js +277 -0
  188. package/dist-runtime/workflow/lib/pendingDeploymentReuse.js.map +1 -0
  189. package/dist-runtime/workflow/lib/proxy.d.ts +18 -0
  190. package/dist-runtime/workflow/lib/proxy.js +19 -0
  191. package/dist-runtime/workflow/lib/proxy.js.map +1 -0
  192. package/dist-runtime/workflow/lib/registryCommit.d.ts +33 -0
  193. package/dist-runtime/workflow/lib/registryCommit.js +319 -0
  194. package/dist-runtime/workflow/lib/registryCommit.js.map +1 -0
  195. package/dist-runtime/workflow/lib/release.d.ts +57 -0
  196. package/dist-runtime/workflow/lib/release.js +256 -0
  197. package/dist-runtime/workflow/lib/release.js.map +1 -0
  198. package/dist-runtime/workflow/lib/releaseFinalize.d.ts +14 -0
  199. package/dist-runtime/workflow/lib/releaseFinalize.js +571 -0
  200. package/dist-runtime/workflow/lib/releaseFinalize.js.map +1 -0
  201. package/dist-runtime/workflow/lib/releaseParameters.d.ts +43 -0
  202. package/dist-runtime/workflow/lib/releaseParameters.js +184 -0
  203. package/dist-runtime/workflow/lib/releaseParameters.js.map +1 -0
  204. package/dist-runtime/workflow/lib/reporter.d.ts +39 -0
  205. package/dist-runtime/workflow/lib/reporter.js +452 -0
  206. package/dist-runtime/workflow/lib/reporter.js.map +1 -0
  207. package/dist-runtime/workflow/lib/resultPaths.d.ts +17 -0
  208. package/dist-runtime/workflow/lib/resultPaths.js +29 -0
  209. package/dist-runtime/workflow/lib/resultPaths.js.map +1 -0
  210. package/dist-runtime/workflow/lib/runtimeVersion.d.ts +10 -0
  211. package/dist-runtime/workflow/lib/runtimeVersion.js +46 -0
  212. package/dist-runtime/workflow/lib/runtimeVersion.js.map +1 -0
  213. package/dist-runtime/workflow/lib/signer.d.ts +10 -0
  214. package/dist-runtime/workflow/lib/signer.js +105 -0
  215. package/dist-runtime/workflow/lib/signer.js.map +1 -0
  216. package/dist-runtime/workflow/lib/signerIdentity.d.ts +1 -0
  217. package/dist-runtime/workflow/lib/signerIdentity.js +23 -0
  218. package/dist-runtime/workflow/lib/signerIdentity.js.map +1 -0
  219. package/dist-runtime/workflow/lib/simulation.d.ts +35 -0
  220. package/dist-runtime/workflow/lib/simulation.js +282 -0
  221. package/dist-runtime/workflow/lib/simulation.js.map +1 -0
  222. package/dist-runtime/workflow/lib/simulationCallers.d.ts +44 -0
  223. package/dist-runtime/workflow/lib/simulationCallers.js +260 -0
  224. package/dist-runtime/workflow/lib/simulationCallers.js.map +1 -0
  225. package/dist-runtime/workflow/lib/sourceRpcPolicy.d.ts +1 -0
  226. package/dist-runtime/workflow/lib/sourceRpcPolicy.js +43 -0
  227. package/dist-runtime/workflow/lib/sourceRpcPolicy.js.map +1 -0
  228. package/dist-runtime/workflow/lib/state.d.ts +6 -0
  229. package/dist-runtime/workflow/lib/state.js +25 -0
  230. package/dist-runtime/workflow/lib/state.js.map +1 -0
  231. package/dist-runtime/workflow/lib/staticValidation.d.ts +22 -0
  232. package/dist-runtime/workflow/lib/staticValidation.js +124 -0
  233. package/dist-runtime/workflow/lib/staticValidation.js.map +1 -0
  234. package/dist-runtime/workflow/lib/zksyncForkCapability.d.ts +27 -0
  235. package/dist-runtime/workflow/lib/zksyncForkCapability.js +52 -0
  236. package/dist-runtime/workflow/lib/zksyncForkCapability.js.map +1 -0
  237. package/dist-runtime/workflow/lib/zksyncForkRunner.d.ts +57 -0
  238. package/dist-runtime/workflow/lib/zksyncForkRunner.js +344 -0
  239. package/dist-runtime/workflow/lib/zksyncForkRunner.js.map +1 -0
  240. package/dist-runtime/workflow/reconcileExternal.d.ts +1 -0
  241. package/dist-runtime/workflow/reconcileExternal.js +87 -0
  242. package/dist-runtime/workflow/reconcileExternal.js.map +1 -0
  243. package/dist-runtime/workflow/reconcileExternalRun.d.ts +1 -0
  244. package/dist-runtime/workflow/reconcileExternalRun.js +77 -0
  245. package/dist-runtime/workflow/reconcileExternalRun.js.map +1 -0
  246. package/dist-runtime/workflow/releaseFinalize.d.ts +1 -0
  247. package/dist-runtime/workflow/releaseFinalize.js +11 -0
  248. package/dist-runtime/workflow/releaseFinalize.js.map +1 -0
  249. package/dist-runtime/workflow/run.d.ts +40 -0
  250. package/dist-runtime/workflow/run.js +858 -0
  251. package/dist-runtime/workflow/run.js.map +1 -0
  252. package/dist-runtime/workflow/staticValidate.d.ts +1 -0
  253. package/dist-runtime/workflow/staticValidate.js +26 -0
  254. package/dist-runtime/workflow/staticValidate.js.map +1 -0
  255. package/dist-runtime/workflow/steps/call.d.ts +3 -0
  256. package/dist-runtime/workflow/steps/call.js +9 -0
  257. package/dist-runtime/workflow/steps/call.js.map +1 -0
  258. package/dist-runtime/workflow/steps/check.d.ts +3 -0
  259. package/dist-runtime/workflow/steps/check.js +9 -0
  260. package/dist-runtime/workflow/steps/check.js.map +1 -0
  261. package/dist-runtime/workflow/steps/custom.d.ts +3 -0
  262. package/dist-runtime/workflow/steps/custom.js +33 -0
  263. package/dist-runtime/workflow/steps/custom.js.map +1 -0
  264. package/dist-runtime/workflow/steps/deploy.d.ts +3 -0
  265. package/dist-runtime/workflow/steps/deploy.js +595 -0
  266. package/dist-runtime/workflow/steps/deploy.js.map +1 -0
  267. package/dist-runtime/workflow/steps/upgrade.d.ts +3 -0
  268. package/dist-runtime/workflow/steps/upgrade.js +465 -0
  269. package/dist-runtime/workflow/steps/upgrade.js.map +1 -0
  270. package/dist-runtime/workflow/steps/view.d.ts +3 -0
  271. package/dist-runtime/workflow/steps/view.js +9 -0
  272. package/dist-runtime/workflow/steps/view.js.map +1 -0
  273. package/package.json +26 -5
  274. package/runtime/config/hardhatAdapters.ts +50 -0
  275. package/runtime/config/networks.ts +296 -0
  276. package/runtime/config/openzeppelin.ts +173 -0
  277. package/runtime/config/rpc.ts +27 -0
  278. package/runtime/config/zksyncSolcPath.ts +59 -0
  279. package/runtime/hardhat-types.d.ts +2 -0
  280. package/runtime/migrate.ts +154 -0
  281. package/runtime/projectHardhat.ts +10 -0
  282. package/runtime/template-migration.json +293 -0
  283. package/runtime/workflow/checkCode.ts +13 -0
  284. package/runtime/workflow/checkCodeFinalize.ts +8 -0
  285. package/runtime/workflow/checkCodePlan.ts +8 -0
  286. package/runtime/workflow/cli.ts +356 -0
  287. package/runtime/workflow/commitContractInfo.ts +63 -0
  288. package/runtime/workflow/create2Hashes.ts +79 -0
  289. package/runtime/workflow/forkSourceProxy.ts +193 -0
  290. package/runtime/workflow/importState.ts +190 -0
  291. package/runtime/workflow/lib/authority.ts +170 -0
  292. package/runtime/workflow/lib/calldata.ts +9 -0
  293. package/runtime/workflow/lib/calls.ts +407 -0
  294. package/runtime/workflow/lib/checkCode/args.ts +76 -0
  295. package/runtime/workflow/lib/checkCode/command.ts +36 -0
  296. package/runtime/workflow/lib/checkCode/dependencies.ts +112 -0
  297. package/runtime/workflow/lib/checkCode/finalize.ts +198 -0
  298. package/runtime/workflow/lib/checkCode/index.ts +18 -0
  299. package/runtime/workflow/lib/checkCode/plan.ts +163 -0
  300. package/runtime/workflow/lib/checkCodeReport.ts +133 -0
  301. package/runtime/workflow/lib/checkCodeRunner.ts +1225 -0
  302. package/runtime/workflow/lib/cliTool.ts +31 -0
  303. package/runtime/workflow/lib/config.ts +130 -0
  304. package/runtime/workflow/lib/contractInfoCandidates.ts +690 -0
  305. package/runtime/workflow/lib/create2.ts +278 -0
  306. package/runtime/workflow/lib/create2Hashes.ts +83 -0
  307. package/runtime/workflow/lib/deploymentInfo.ts +286 -0
  308. package/runtime/workflow/lib/deploymentRecords.ts +576 -0
  309. package/runtime/workflow/lib/deployments.ts +276 -0
  310. package/runtime/workflow/lib/erc1967.ts +57 -0
  311. package/runtime/workflow/lib/errors.ts +95 -0
  312. package/runtime/workflow/lib/executionId.ts +35 -0
  313. package/runtime/workflow/lib/executionPlan.ts +550 -0
  314. package/runtime/workflow/lib/executionProgress.ts +127 -0
  315. package/runtime/workflow/lib/external.ts +372 -0
  316. package/runtime/workflow/lib/externalExecutionScanner.ts +892 -0
  317. package/runtime/workflow/lib/forkSnapshot.ts +231 -0
  318. package/runtime/workflow/lib/gateTool.ts +261 -0
  319. package/runtime/workflow/lib/gateToolSync.ts +398 -0
  320. package/runtime/workflow/lib/lock.ts +388 -0
  321. package/runtime/workflow/lib/migrationState.ts +1246 -0
  322. package/runtime/workflow/lib/operatorExecution.ts +174 -0
  323. package/runtime/workflow/lib/parameters.ts +437 -0
  324. package/runtime/workflow/lib/pendingDeploymentReuse.ts +428 -0
  325. package/runtime/workflow/lib/proxy.ts +45 -0
  326. package/runtime/workflow/lib/registryCommit.ts +455 -0
  327. package/runtime/workflow/lib/release.ts +329 -0
  328. package/runtime/workflow/lib/releaseFinalize.ts +711 -0
  329. package/runtime/workflow/lib/releaseParameters.ts +248 -0
  330. package/runtime/workflow/lib/reporter.ts +502 -0
  331. package/runtime/workflow/lib/resultPaths.ts +49 -0
  332. package/runtime/workflow/lib/runtimeVersion.ts +28 -0
  333. package/runtime/workflow/lib/signer.ts +124 -0
  334. package/runtime/workflow/lib/signerIdentity.ts +22 -0
  335. package/runtime/workflow/lib/simulation.ts +415 -0
  336. package/runtime/workflow/lib/simulationCallers.ts +335 -0
  337. package/runtime/workflow/lib/sourceRpcPolicy.ts +41 -0
  338. package/runtime/workflow/lib/state.ts +25 -0
  339. package/runtime/workflow/lib/staticValidation.ts +142 -0
  340. package/runtime/workflow/lib/zksyncForkCapability.ts +80 -0
  341. package/runtime/workflow/lib/zksyncForkRunner.ts +505 -0
  342. package/runtime/workflow/reconcileExternal.ts +86 -0
  343. package/runtime/workflow/reconcileExternalRun.ts +88 -0
  344. package/runtime/workflow/releaseFinalize.ts +8 -0
  345. package/runtime/workflow/run.ts +1072 -0
  346. package/runtime/workflow/staticValidate.ts +23 -0
  347. package/runtime/workflow/steps/call.ts +10 -0
  348. package/runtime/workflow/steps/check.ts +10 -0
  349. package/runtime/workflow/steps/custom.ts +43 -0
  350. package/runtime/workflow/steps/deploy.ts +771 -0
  351. package/runtime/workflow/steps/upgrade.ts +598 -0
  352. package/runtime/workflow/steps/view.ts +10 -0
@@ -0,0 +1,858 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const runtimeVersion_1 = require("./lib/runtimeVersion");
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const projectHardhat_1 = require("../projectHardhat");
10
+ const config_1 = require("./lib/config");
11
+ const executionId_1 = require("./lib/executionId");
12
+ const lock_1 = require("./lib/lock");
13
+ const parameters_1 = require("./lib/parameters");
14
+ const deployments_1 = require("./lib/deployments");
15
+ const release_1 = require("./lib/release");
16
+ const releaseParameters_1 = require("./lib/releaseParameters");
17
+ const reporter_1 = require("./lib/reporter");
18
+ const external_1 = require("./lib/external");
19
+ const errors_1 = require("./lib/errors");
20
+ const simulation_1 = require("./lib/simulation");
21
+ const signer_1 = require("./lib/signer");
22
+ const simulationCallers_1 = require("./lib/simulationCallers");
23
+ const state_1 = require("./lib/state");
24
+ const deploymentRecords_1 = require("./lib/deploymentRecords");
25
+ const deploy_1 = require("./steps/deploy");
26
+ const call_1 = require("./steps/call");
27
+ const upgrade_1 = require("./steps/upgrade");
28
+ const view_1 = require("./steps/view");
29
+ const check_1 = require("./steps/check");
30
+ const custom_1 = require("./steps/custom");
31
+ const executionPlan_1 = require("./lib/executionPlan");
32
+ const operatorExecution_1 = require("./lib/operatorExecution");
33
+ const executionProgress_1 = require("./lib/executionProgress");
34
+ const parseArgs = (argv) => {
35
+ const args = {};
36
+ for (let index = 0; index < argv.length; index += 1) {
37
+ const item = argv[index];
38
+ if (!item.startsWith("--"))
39
+ continue;
40
+ const equalIndex = item.indexOf("=");
41
+ if (equalIndex > 2) {
42
+ args[item.slice(2, equalIndex)] = item.slice(equalIndex + 1);
43
+ continue;
44
+ }
45
+ const key = item.slice(2);
46
+ const next = argv[index + 1];
47
+ if (!next || next.startsWith("--")) {
48
+ args[key] = true;
49
+ }
50
+ else {
51
+ args[key] = next;
52
+ index += 1;
53
+ }
54
+ }
55
+ return args;
56
+ };
57
+ const parseEnvArgs = () => {
58
+ const raw = process.env.WORKFLOW_ARGS_JSON;
59
+ if (!raw)
60
+ return {};
61
+ let parsed;
62
+ try {
63
+ parsed = JSON.parse(raw);
64
+ }
65
+ catch (error) {
66
+ throw new Error(`WORKFLOW_ARGS_JSON must be valid JSON: ${error instanceof Error ? error.message : String(error)}`);
67
+ }
68
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
69
+ throw new Error("WORKFLOW_ARGS_JSON must be a JSON object");
70
+ }
71
+ const args = {};
72
+ for (const [key, value] of Object.entries(parsed)) {
73
+ if (typeof value !== "string" && typeof value !== "boolean") {
74
+ throw new Error(`WORKFLOW_ARGS_JSON.${key} must be a string or boolean`);
75
+ }
76
+ args[key] = value;
77
+ }
78
+ return args;
79
+ };
80
+ const assertWalletCredentialForExecution = (mode, targetId) => {
81
+ if (mode !== "execute")
82
+ return;
83
+ if (targetId === "hardhat" || targetId === "localhost")
84
+ return;
85
+ if (process.env.WALLET_CREDENTIAL?.trim())
86
+ return;
87
+ if (process.env.PRIVATE_KEY?.trim())
88
+ return;
89
+ throw new Error(`Missing wallet credential in project .env or process env. Execute mode on "${targetId}" requires a deployment signer.`);
90
+ };
91
+ const selectSteps = (steps, args) => {
92
+ if (typeof args.step === "string") {
93
+ return steps.filter((step) => step.id === args.step);
94
+ }
95
+ if (typeof args.from === "string") {
96
+ const index = steps.findIndex((step) => step.id === args.from);
97
+ if (index < 0)
98
+ throw new Error(`Unknown --from step: ${args.from}`);
99
+ return steps.slice(index);
100
+ }
101
+ return steps;
102
+ };
103
+ const runStep = async (context, step) => {
104
+ switch (step.kind) {
105
+ case "deploy":
106
+ await (0, deploy_1.runDeployStep)(context, step);
107
+ return;
108
+ case "call":
109
+ await (0, call_1.runCallStep)(context, step);
110
+ return;
111
+ case "upgrade":
112
+ await (0, upgrade_1.runUpgradeStep)(context, step);
113
+ return;
114
+ case "view":
115
+ await (0, view_1.runViewStep)(context, step);
116
+ return;
117
+ case "check":
118
+ await (0, check_1.runCheckStep)(context, step);
119
+ return;
120
+ case "custom":
121
+ await (0, custom_1.runCustomStep)(context, step);
122
+ return;
123
+ default:
124
+ throw new Error(`Unsupported step kind: ${step.kind}`);
125
+ }
126
+ };
127
+ const booleanArg = (args, key) => {
128
+ const value = args[key];
129
+ return value === true || value === "true";
130
+ };
131
+ const requiredStringArg = (args, key) => {
132
+ const value = args[key];
133
+ if (typeof value !== "string" || !value.trim()) {
134
+ throw new Error("Missing --" + key + " for release execution");
135
+ }
136
+ return value.trim();
137
+ };
138
+ const optionalStringArg = (args, key) => {
139
+ const value = args[key];
140
+ if (value === undefined)
141
+ return undefined;
142
+ if (typeof value !== "string" || !value.trim()) {
143
+ throw new Error("--" + key + " requires a non-empty value");
144
+ }
145
+ return value.trim();
146
+ };
147
+ const releaseKindArg = (args) => {
148
+ const value = requiredStringArg(args, "releaseKind");
149
+ if (value !== "development" && value !== "admin_release") {
150
+ throw new Error("--releaseKind must be development or admin_release");
151
+ }
152
+ return value;
153
+ };
154
+ const parseParameterOverrides = (args) => {
155
+ const value = args.parameterOverrides;
156
+ if (value === undefined)
157
+ return {};
158
+ if (typeof value !== "string") {
159
+ throw new Error("--parameterOverrides must be a JSON object");
160
+ }
161
+ let parsed;
162
+ try {
163
+ parsed = JSON.parse(value);
164
+ }
165
+ catch (error) {
166
+ throw new Error("--parameterOverrides must be valid JSON: "
167
+ + (error instanceof Error ? error.message : String(error)));
168
+ }
169
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
170
+ throw new Error("--parameterOverrides must be a JSON object");
171
+ }
172
+ return parsed;
173
+ };
174
+ const parseExistingDeploymentPolicies = (args) => {
175
+ const value = args.existingDeploymentPolicies;
176
+ if (value === undefined)
177
+ return {};
178
+ if (typeof value !== "string") {
179
+ throw new Error("--existingDeploymentPolicies must be a JSON object");
180
+ }
181
+ let parsed;
182
+ try {
183
+ parsed = JSON.parse(value);
184
+ }
185
+ catch (error) {
186
+ throw new Error("--existingDeploymentPolicies must be valid JSON: "
187
+ + (error instanceof Error ? error.message : String(error)));
188
+ }
189
+ return (0, parameters_1.validateExistingDeploymentPolicies)(parsed);
190
+ };
191
+ const manifestContractReferences = (steps) => {
192
+ const references = new Set();
193
+ for (const step of steps) {
194
+ if ((step.kind === "deploy" || step.kind === "upgrade") && typeof step.contract === "string") {
195
+ references.add(step.contract);
196
+ }
197
+ if (step.kind === "deploy" && step.firstUpgrade && typeof step.firstUpgrade === "object") {
198
+ const contract = step.firstUpgrade.contract;
199
+ if (typeof contract === "string")
200
+ references.add(contract);
201
+ }
202
+ if (step.kind === "deploy" && step.upgradeableStrategy === "uups-placeholder-proxy") {
203
+ references.add("@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol:ERC1967Proxy");
204
+ }
205
+ }
206
+ return [...references].sort();
207
+ };
208
+ const loadArtifactFingerprintInputs = async (manifest) => {
209
+ const inputs = [];
210
+ for (const contractReference of manifestContractReferences(manifest.steps)) {
211
+ const artifact = await projectHardhat_1.artifacts.readArtifact(contractReference);
212
+ const fullyQualifiedName = artifact.sourceName + ":" + artifact.contractName;
213
+ const buildInfo = await projectHardhat_1.artifacts.getBuildInfo(fullyQualifiedName);
214
+ if (!buildInfo) {
215
+ throw new Error("Missing Hardhat build info for " + fullyQualifiedName);
216
+ }
217
+ const settings = buildInfo.input.settings;
218
+ inputs.push({
219
+ contract: fullyQualifiedName,
220
+ bytecode: artifact.bytecode,
221
+ deployedBytecode: artifact.deployedBytecode,
222
+ linkReferences: artifact.linkReferences,
223
+ deployedLinkReferences: artifact.deployedLinkReferences,
224
+ solcVersion: buildInfo.solcVersion,
225
+ optimizer: settings.optimizer || {},
226
+ evmVersion: typeof settings.evmVersion === "string" ? settings.evmVersion : undefined,
227
+ });
228
+ }
229
+ return inputs;
230
+ };
231
+ const targetChainId = (targetId) => {
232
+ const networks = projectHardhat_1.config.networks;
233
+ return networks[targetId]?.chainId;
234
+ };
235
+ const equalStringArrays = (left, right) => {
236
+ return left.length === right.length && left.every((value, index) => value === right[index]);
237
+ };
238
+ const prepareReleaseExecution = async (args, mode, taskDir, targetId, target, manifest, existingDeploymentInstanceIds, parameters, executionId, selectedStepIds) => {
239
+ if (!booleanArg(args, "useLock"))
240
+ return undefined;
241
+ if (mode !== "simulate"
242
+ && mode !== "execute"
243
+ && mode !== "verify") {
244
+ throw new Error("--useLock only supports simulate, execute, and verify modes");
245
+ }
246
+ const release = (0, release_1.loadRelease)(taskDir);
247
+ const baselineParameters = (0, parameters_1.targetParams)(parameters, targetId);
248
+ const releaseFingerprint = (0, release_1.buildReleaseFingerprint)({
249
+ manifest: fs_1.default.readFileSync(path_1.default.join(taskDir, "manifest.yaml"), "utf8"),
250
+ artifacts: await loadArtifactFingerprintInputs(manifest),
251
+ parameters: baselineParameters,
252
+ network: targetId,
253
+ chainId: targetChainId(targetId),
254
+ target,
255
+ });
256
+ (0, release_1.assertReleaseNetworkReady)(release, targetId, releaseFingerprint);
257
+ if (mode === "execute" || mode === "verify") {
258
+ const lockedExecution = (0, lock_1.readParameterLockExecution)(taskDir, executionId);
259
+ if (lockedExecution.sourceSuperTaskId !== release.sourceSuperTaskId) {
260
+ throw new Error("Parameter lock sourceSuperTaskId does not match release.json");
261
+ }
262
+ const verifySelectionStart = mode === "verify"
263
+ ? lockedExecution.selectedStepIds.indexOf(selectedStepIds[0])
264
+ : -1;
265
+ const selectedStepsMatch = mode === "verify"
266
+ ? selectedStepIds.length > 0
267
+ && verifySelectionStart >= 0
268
+ && equalStringArrays(lockedExecution.selectedStepIds.slice(verifySelectionStart), selectedStepIds)
269
+ : equalStringArrays(lockedExecution.selectedStepIds, selectedStepIds);
270
+ if (!selectedStepsMatch) {
271
+ throw new Error("Parameter lock selectedStepIds do not match this execution");
272
+ }
273
+ (0, lock_1.assertParameterLockExecutable)(lockedExecution, targetId, releaseFingerprint);
274
+ const existingDeploymentPolicies = (0, parameters_1.validateExistingDeploymentPolicies)(lockedExecution.existingDeploymentPolicies);
275
+ (0, parameters_1.assertExistingDeploymentPoliciesMatchTarget)(existingDeploymentPolicies, targetId, existingDeploymentInstanceIds);
276
+ return {
277
+ sourceSuperTaskId: lockedExecution.sourceSuperTaskId,
278
+ mergeCommit: lockedExecution.mergeCommit,
279
+ baselineParameters: lockedExecution.baselineParameters,
280
+ overrides: lockedExecution.overrides,
281
+ resolvedParameters: lockedExecution.resolvedParameters,
282
+ releaseFingerprint,
283
+ existingDeploymentPolicies,
284
+ lockedExecution,
285
+ };
286
+ }
287
+ const sourceSuperTaskId = requiredStringArg(args, "sourceSuperTaskId");
288
+ if (sourceSuperTaskId !== release.sourceSuperTaskId) {
289
+ throw new Error("--sourceSuperTaskId does not match release.json");
290
+ }
291
+ const mergeCommit = requiredStringArg(args, "mergeCommit");
292
+ if (!/^[0-9a-fA-F]{40}$/.test(mergeCommit)) {
293
+ throw new Error("--mergeCommit must be a 40 character git commit");
294
+ }
295
+ const overrides = parseParameterOverrides(args);
296
+ const existingDeploymentPolicies = parseExistingDeploymentPolicies(args);
297
+ (0, parameters_1.assertExistingDeploymentPoliciesMatchTarget)(existingDeploymentPolicies, targetId, existingDeploymentInstanceIds);
298
+ const resolvedParameters = (0, releaseParameters_1.resolveExecutionParameters)(parameters, targetId, overrides, (0, parameters_1.loadParameterSchema)(taskDir));
299
+ return {
300
+ sourceSuperTaskId,
301
+ mergeCommit,
302
+ baselineParameters,
303
+ overrides,
304
+ resolvedParameters,
305
+ releaseFingerprint,
306
+ existingDeploymentPolicies,
307
+ };
308
+ };
309
+ async function main() {
310
+ const args = {
311
+ ...parseEnvArgs(),
312
+ ...parseArgs(process.argv.slice(2)),
313
+ };
314
+ const root = process.cwd();
315
+ const taskId = typeof args.task === "string" ? args.task : process.env.WORKFLOW_TASK;
316
+ if (!taskId) {
317
+ throw new Error("Missing task id. Pass --task <taskId> or set WORKFLOW_TASK=<taskId> before running workflow.");
318
+ }
319
+ const taskDir = (0, config_1.taskDir)(taskId, root);
320
+ const mode = (0, simulation_1.resolveWorkflowMode)(args);
321
+ const targetId = mode === "simulate"
322
+ ? typeof args.target === "string"
323
+ ? args.target
324
+ : ""
325
+ : projectHardhat_1.network.name;
326
+ if (!targetId) {
327
+ throw new Error("Missing target network. Run execute/plan with --network <network>, or simulate with --network hardhat --target <network>.");
328
+ }
329
+ const requestedReleaseKind = args.releaseKind === undefined
330
+ ? undefined
331
+ : releaseKindArg(args);
332
+ const gateFlowNodeKey = process.env.GATEFLOW_NODE_KEY?.trim();
333
+ if (gateFlowNodeKey === "DevelopmentDeployExecute" && mode !== "execute") {
334
+ throw new Error("GateFlow node DevelopmentDeployExecute only allows workflow --mode execute");
335
+ }
336
+ const gateFlowDevelopmentNode = gateFlowNodeKey === "DevelopmentDeploySimulate"
337
+ || gateFlowNodeKey === "DevelopmentDeployExecute";
338
+ if (gateFlowDevelopmentNode && requestedReleaseKind !== "development") {
339
+ throw new Error("GateFlow development deployment nodes require --releaseKind development");
340
+ }
341
+ if (gateFlowDevelopmentNode
342
+ && (typeof args.executionId !== "string" || !args.executionId.trim())) {
343
+ throw new Error("GateFlow development deployment nodes require an explicit --executionId reused across simulate and execute");
344
+ }
345
+ const executionId = (0, executionId_1.validateExecutionId)(args.executionId === undefined ? (0, executionId_1.buildExecutionId)(targetId) : args.executionId);
346
+ if (mode === "simulate" || mode === "execute")
347
+ (0, runtimeVersion_1.bindExecutionRuntime)({ taskDir, target: targetId, executionId });
348
+ const reporter = new reporter_1.WorkflowReporter(taskDir, taskId, executionId, targetId, mode);
349
+ reporter.initializeResults();
350
+ let contextForFailure;
351
+ try {
352
+ const config = (0, config_1.loadConfig)(root);
353
+ const manifest = (0, parameters_1.loadManifest)(taskDir);
354
+ const parameters = (0, parameters_1.loadParameters)(taskDir);
355
+ const taskMetadata = (0, parameters_1.loadTaskMetadata)(taskDir);
356
+ const target = (0, config_1.resolveTarget)(config, targetId);
357
+ if (mode === "execute"
358
+ && target.environment === "production"
359
+ && !booleanArg(args, "useLock")) {
360
+ throw new Error("Production execute requires --useLock and an immutable execution plan");
361
+ }
362
+ assertWalletCredentialForExecution(mode, targetId);
363
+ const steps = selectSteps(manifest.steps, args);
364
+ const existingDeploymentInstanceIds = manifest.steps
365
+ .filter((step) => step.kind === "deploy" && typeof step.saveAs === "string")
366
+ .map((step) => String(step.saveAs))
367
+ .filter((instanceId) => Boolean((0, deployments_1.findDeploymentAddress)(root, config, targetId, instanceId)));
368
+ const releaseTargetSimulation = mode === "simulate"
369
+ && (projectHardhat_1.network.name === "hardhat" || projectHardhat_1.network.name === "zkFork")
370
+ && typeof args.target === "string"
371
+ && (taskMetadata.releaseTargetNetworks ?? []).includes(targetId)
372
+ && !booleanArg(args, "useLock")
373
+ && requestedReleaseKind === undefined;
374
+ if (releaseTargetSimulation
375
+ && (args.step !== undefined || args.from !== undefined)) {
376
+ throw new Error("Full release-target simulation does not support partial --step or --from selection");
377
+ }
378
+ const simulationCallerBinding = releaseTargetSimulation
379
+ ? (0, simulationCallers_1.loadSimulationCallerNetwork)({
380
+ taskDir,
381
+ targetNetworks: taskMetadata.releaseTargetNetworks,
382
+ network: targetId,
383
+ manifestText: fs_1.default.readFileSync(path_1.default.join(taskDir, "manifest.yaml"), "utf8"),
384
+ manifestSteps: manifest.steps,
385
+ })
386
+ : undefined;
387
+ const releaseTargetFingerprint = releaseTargetSimulation
388
+ ? (0, release_1.buildReleaseFingerprint)({
389
+ manifest: fs_1.default.readFileSync(path_1.default.join(taskDir, "manifest.yaml"), "utf8"),
390
+ artifacts: await loadArtifactFingerprintInputs(manifest),
391
+ parameters: (0, parameters_1.targetParams)(parameters, targetId),
392
+ network: targetId,
393
+ chainId: targetChainId(targetId),
394
+ target,
395
+ })
396
+ : undefined;
397
+ if (mode === "simulate" && steps.length === 0) {
398
+ throw new Error("Simulation must select at least one workflow step");
399
+ }
400
+ if (mode === "verify") {
401
+ const unsupported = steps.find((step) => step.kind !== "view" && step.kind !== "check");
402
+ if (unsupported) {
403
+ throw new Error(`verify mode only supports view and check steps; ${unsupported.id} is ${unsupported.kind}`);
404
+ }
405
+ }
406
+ const releaseExecution = await prepareReleaseExecution(args, mode, taskDir, targetId, target, manifest, existingDeploymentInstanceIds, parameters, executionId, steps.map((step) => step.id));
407
+ if (!releaseExecution && requestedReleaseKind === "admin_release") {
408
+ throw new Error("admin_release execution requires --useLock");
409
+ }
410
+ const developmentPlanExecution = !releaseExecution
411
+ && requestedReleaseKind === "development";
412
+ if (developmentPlanExecution
413
+ && mode !== "simulate"
414
+ && mode !== "execute") {
415
+ throw new Error("development releaseKind only supports simulate and execute modes");
416
+ }
417
+ const lockedExecutionPlan = releaseExecution?.lockedExecution
418
+ ? (0, executionPlan_1.loadReleaseExecutionPlan)({
419
+ root,
420
+ taskDir,
421
+ target: targetId,
422
+ executionId,
423
+ expectedHash: releaseExecution.lockedExecution.finalSimulation.status === "succeeded"
424
+ ? releaseExecution.lockedExecution.finalSimulation.executionPlanHash
425
+ : undefined,
426
+ })
427
+ : developmentPlanExecution && mode === "execute"
428
+ ? (0, executionPlan_1.loadReleaseExecutionPlan)({
429
+ root,
430
+ taskDir,
431
+ target: targetId,
432
+ executionId,
433
+ })
434
+ : undefined;
435
+ const releaseKind = releaseExecution
436
+ ? mode === "simulate"
437
+ ? requestedReleaseKind
438
+ : lockedExecutionPlan?.releaseKind
439
+ : developmentPlanExecution
440
+ ? "development"
441
+ : undefined;
442
+ const completedExecutionPrefix = mode === "execute" && lockedExecutionPlan
443
+ ? (0, executionProgress_1.loadCompletedExecutionPrefix)({ taskDir, plan: lockedExecutionPlan })
444
+ : [];
445
+ const simulationSignerAddress = mode === "simulate"
446
+ ? simulationCallerBinding?.defaultAddress
447
+ ?? (0, signer_1.resolveSimulationSignerAddress)({
448
+ explicitAddress: optionalStringArg(args, "simulationSigner"),
449
+ taskAddress: taskMetadata.deploymentSignerAddress,
450
+ useLock: booleanArg(args, "useLock"),
451
+ })
452
+ : undefined;
453
+ const simulation = mode === "simulate" ? await (0, simulation_1.setupSimulationFork)(targetId) : {};
454
+ if (mode === "simulate") {
455
+ await (0, simulation_1.assertSimulationSourceInfrastructure)(targetId, target, simulation);
456
+ }
457
+ const signer = mode === "verify"
458
+ ? undefined
459
+ : mode === "simulate"
460
+ ? simulationCallerBinding
461
+ ? undefined
462
+ : await (0, signer_1.impersonateWorkflowSimulationSigner)(simulationSignerAddress)
463
+ : await (0, signer_1.resolveWorkflowSigner)(mode, {
464
+ taskAddress: taskMetadata.deploymentSignerAddress,
465
+ });
466
+ const signerAddress = simulationCallerBinding?.defaultAddress
467
+ ?? (signer ? await signer.getAddress() : undefined);
468
+ const resolvedTarget = {
469
+ id: targetId,
470
+ ...target,
471
+ ...(signerAddress
472
+ ? {
473
+ signer: signerAddress,
474
+ admin: (0, config_1.resolveAdmin)(target, signerAddress),
475
+ }
476
+ : {}),
477
+ };
478
+ if (lockedExecutionPlan
479
+ && mode === "execute"
480
+ && signerAddress
481
+ && lockedExecutionPlan.operator.toLowerCase() !== signerAddress.toLowerCase()) {
482
+ throw new Error("Execution plan operator does not match the execution signer");
483
+ }
484
+ if (releaseExecution && mode === "simulate") {
485
+ if (!signerAddress || !resolvedTarget.admin) {
486
+ throw new Error("Final simulation requires a resolved signer and admin");
487
+ }
488
+ const create2Config = resolvedTarget.create2 && typeof resolvedTarget.create2 === "object" && !Array.isArray(resolvedTarget.create2)
489
+ ? resolvedTarget.create2
490
+ : {};
491
+ const uupsConfig = resolvedTarget.uups && typeof resolvedTarget.uups === "object" && !Array.isArray(resolvedTarget.uups)
492
+ ? resolvedTarget.uups
493
+ : {};
494
+ const multicallConfig = resolvedTarget.multicall && typeof resolvedTarget.multicall === "object" && !Array.isArray(resolvedTarget.multicall)
495
+ ? resolvedTarget.multicall
496
+ : {};
497
+ (0, lock_1.writeParameterLock)({
498
+ taskDir,
499
+ deploymentId: taskId,
500
+ executionId,
501
+ sourceSuperTaskId: releaseExecution.sourceSuperTaskId,
502
+ mergeCommit: releaseExecution.mergeCommit,
503
+ selectedExecuteNetworks: [targetId],
504
+ selectedStepIds: steps.map((step) => step.id),
505
+ operator: signerAddress,
506
+ baselineParameters: releaseExecution.baselineParameters,
507
+ overrides: releaseExecution.overrides,
508
+ resolvedParameters: releaseExecution.resolvedParameters,
509
+ releaseFingerprint: releaseExecution.releaseFingerprint,
510
+ finalSimulation: { status: "pending" },
511
+ existingDeploymentPolicies: releaseExecution.existingDeploymentPolicies,
512
+ targetSnapshot: {
513
+ network: targetId,
514
+ signer: signerAddress,
515
+ admin: resolvedTarget.admin,
516
+ chainId: targetChainId(targetId),
517
+ create2Scheme: (0, release_1.normalizeCreate2Scheme)(create2Config.scheme),
518
+ create2Factory: typeof create2Config.factory === "string" ? create2Config.factory : undefined,
519
+ create2Caller: typeof create2Config.caller === "string" ? create2Config.caller : undefined,
520
+ controlledMulticall: typeof multicallConfig.controlledMulticall === "string"
521
+ ? multicallConfig.controlledMulticall
522
+ : undefined,
523
+ uupsPlaceholderImplementation: typeof uupsConfig.placeholderImplementation === "string"
524
+ ? uupsConfig.placeholderImplementation
525
+ : undefined,
526
+ leadingZeroBytes: typeof create2Config.leadingZeroBytes === "number"
527
+ ? create2Config.leadingZeroBytes
528
+ : undefined,
529
+ },
530
+ });
531
+ }
532
+ const context = {
533
+ root,
534
+ taskId,
535
+ executionId,
536
+ taskDir,
537
+ targetId,
538
+ target: resolvedTarget,
539
+ targetParams: releaseExecution?.resolvedParameters || (0, parameters_1.targetParams)(parameters, targetId),
540
+ existingDeploymentPolicies: releaseExecution
541
+ ? releaseExecution.existingDeploymentPolicies
542
+ : parseExistingDeploymentPolicies(args),
543
+ releaseArtifactHash: releaseExecution?.releaseFingerprint.artifactHash,
544
+ parameterLockExecutionId: releaseExecution ? executionId : undefined,
545
+ parameterLockOperator: releaseExecution?.lockedExecution?.operator,
546
+ config,
547
+ mode,
548
+ simulation,
549
+ signer,
550
+ signerAddress,
551
+ state: new state_1.WorkflowState(),
552
+ reporter,
553
+ executionPlanner: (releaseExecution || developmentPlanExecution)
554
+ && releaseKind
555
+ && (mode === "simulate" || mode === "execute")
556
+ ? new executionPlan_1.ReleaseExecutionPlanner({
557
+ taskId,
558
+ target: targetId,
559
+ executionId,
560
+ releaseKind,
561
+ operator: lockedExecutionPlan?.operator
562
+ || releaseExecution?.lockedExecution?.operator
563
+ || signerAddress,
564
+ expectedPlan: lockedExecutionPlan,
565
+ segmentedExecution: mode === "execute"
566
+ && lockedExecutionPlan?.releaseKind === "admin_release",
567
+ completedTransactions: completedExecutionPrefix,
568
+ })
569
+ : undefined,
570
+ lockedExecutionPlan,
571
+ externalCalls: [],
572
+ operatorReceipts: [],
573
+ };
574
+ contextForFailure = context;
575
+ reporter.status("running", { mode, stepCount: steps.length });
576
+ reporter.event("workflow.started", { mode, network: projectHardhat_1.network.name, target: targetId, steps: steps.map((step) => step.id) });
577
+ if (mode === "execute" &&
578
+ (Boolean(releaseExecution)
579
+ || steps.some((step) => step.kind === "deploy" || step.kind === "upgrade"))) {
580
+ context.deploymentRecorder = new deploymentRecords_1.DeploymentRecorder({
581
+ root,
582
+ taskDir,
583
+ config,
584
+ taskId,
585
+ executionId,
586
+ network: targetId,
587
+ awaitRegistryCommit: Boolean(releaseExecution || developmentPlanExecution),
588
+ resume: completedExecutionPrefix.length > 0,
589
+ });
590
+ }
591
+ let executionSegmentDeferred = false;
592
+ stepLoop: for (const step of steps) {
593
+ if (context.mode === "execute"
594
+ && context.externalCalls.length > 0
595
+ && (step.kind === "view" || step.kind === "check" || step.kind === "custom")) {
596
+ reporter.event("step.deferred_until_external_execution", {
597
+ stepId: step.id,
598
+ kind: step.kind,
599
+ });
600
+ break;
601
+ }
602
+ const configuredCaller = simulationCallerBinding?.resolved.find((entry) => entry.stepId === step.id);
603
+ const stepContext = configuredCaller
604
+ ? {
605
+ ...context,
606
+ signer: await (0, signer_1.impersonateWorkflowSimulationSigner)(configuredCaller.callerAddress),
607
+ signerAddress: configuredCaller.callerAddress,
608
+ configuredSimulationCaller: true,
609
+ }
610
+ : context;
611
+ if (configuredCaller) {
612
+ reporter.setSimulationCallerAddress(configuredCaller.callerAddress);
613
+ }
614
+ try {
615
+ reporter.event("step.started", { stepId: step.id, kind: step.kind });
616
+ try {
617
+ await runStep(stepContext, step);
618
+ }
619
+ catch (error) {
620
+ if (context.mode === "execute" && error instanceof executionPlan_1.ExecutionSegmentDeferred) {
621
+ executionSegmentDeferred = true;
622
+ reporter.event("execution.segment.deferred", {
623
+ transactionId: error.transactionId,
624
+ });
625
+ break stepLoop;
626
+ }
627
+ if (context.mode === "execute"
628
+ && error instanceof external_1.ExternalExecutionRequired) {
629
+ if (!context.executionPlanner) {
630
+ throw new Error("External execution requires a locked mixed-authority plan; run final simulation and execute mode");
631
+ }
632
+ for (const call of error.calls) {
633
+ let planned;
634
+ try {
635
+ planned = context.executionPlanner.add({
636
+ stepId: call.stepId,
637
+ executor: call.executor,
638
+ to: call.to,
639
+ value: call.value,
640
+ data: call.data,
641
+ operation: call.operation,
642
+ });
643
+ }
644
+ catch (planError) {
645
+ if (planError instanceof executionPlan_1.ExecutionSegmentDeferred) {
646
+ executionSegmentDeferred = true;
647
+ reporter.event("execution.segment.deferred", {
648
+ transactionId: planError.transactionId,
649
+ });
650
+ break;
651
+ }
652
+ throw planError;
653
+ }
654
+ if (planned.route !== "external") {
655
+ throw new Error(`Step ${call.stepId} requested external execution for an operator route`);
656
+ }
657
+ if (planned.executionAction !== "replay") {
658
+ context.externalCalls.push({
659
+ ...call,
660
+ transactionId: planned.transactionId,
661
+ stepId: planned.stepId,
662
+ executor: planned.executor,
663
+ to: planned.to,
664
+ value: planned.value,
665
+ data: planned.data,
666
+ operation: planned.operation,
667
+ });
668
+ }
669
+ }
670
+ if (executionSegmentDeferred)
671
+ break stepLoop;
672
+ continue;
673
+ }
674
+ throw error;
675
+ }
676
+ reporter.event("step.completed", { stepId: step.id, kind: step.kind });
677
+ }
678
+ finally {
679
+ if (configuredCaller)
680
+ reporter.clearSimulationCallerAddress();
681
+ }
682
+ }
683
+ const plannedBody = context.executionPlanner?.complete({
684
+ allowPartial: executionSegmentDeferred,
685
+ });
686
+ const completedPlan = mode === "simulate" && plannedBody
687
+ ? (0, executionPlan_1.writeReleaseExecutionPlan)({ root, taskDir, plan: plannedBody })
688
+ : lockedExecutionPlan;
689
+ if (mode === "simulate") {
690
+ await (0, simulation_1.verifySimulationForkSnapshot)(context.simulation);
691
+ }
692
+ if (completedPlan && mode === "execute") {
693
+ (0, operatorExecution_1.writeOperatorExecutionResult)({
694
+ taskDir,
695
+ plan: completedPlan,
696
+ receipts: context.operatorReceipts,
697
+ });
698
+ }
699
+ if (releaseExecution && mode === "simulate") {
700
+ if (!completedPlan)
701
+ throw new Error("Final simulation did not produce an execution plan");
702
+ reporter.result("execution", {
703
+ kind: "release-final-simulation",
704
+ status: "succeeded",
705
+ selectedStepIds: steps.map((step) => step.id),
706
+ releaseFingerprint: releaseExecution.releaseFingerprint,
707
+ releaseKind: completedPlan.releaseKind,
708
+ executionPlanHash: completedPlan.planHash,
709
+ executionPlanPath: (0, executionPlan_1.releaseExecutionPlanRelativePath)(taskDir, completedPlan),
710
+ });
711
+ }
712
+ let deploymentStatus;
713
+ if (mode === "execute"
714
+ && completedPlan
715
+ && context.externalCalls.length > 0) {
716
+ const externalPackage = (0, external_1.writeExternalExecutionPackage)({
717
+ taskDir,
718
+ plan: completedPlan,
719
+ handoffBlock: await projectHardhat_1.ethers.provider.getBlockNumber(),
720
+ calls: context.externalCalls,
721
+ });
722
+ const externalSegment = externalPackage.package.segments.at(-1);
723
+ context.deploymentRecorder?.markWaitingExternal({
724
+ packagePath: path_1.default.relative(root, externalPackage.filePath).split(path_1.default.sep).join("/"),
725
+ executionPlanHash: completedPlan.planHash,
726
+ handoffBlock: externalSegment.handoffBlock,
727
+ transactionIds: externalSegment.transactionIds,
728
+ });
729
+ deploymentStatus = "waiting_external";
730
+ }
731
+ else {
732
+ deploymentStatus = context.deploymentRecorder?.complete();
733
+ }
734
+ const finalStatus = deploymentStatus === "waiting_code_check"
735
+ ? "waiting_code_check"
736
+ : deploymentStatus === "waiting_external"
737
+ ? "waiting_external"
738
+ : deploymentStatus === "partial"
739
+ ? "partial"
740
+ : "completed";
741
+ if (mode !== "simulate") {
742
+ reporter.status(finalStatus, { mode, stepCount: steps.length });
743
+ }
744
+ reporter.report(mode === "simulate" ? "simulation-report.md" : "execution-report.md", [
745
+ `# Execution Report`,
746
+ ``,
747
+ `Task: ${taskId}`,
748
+ `Target: ${targetId}`,
749
+ `Network: ${projectHardhat_1.network.name}`,
750
+ `Mode: ${mode}`,
751
+ `Status: ${finalStatus}`,
752
+ ``,
753
+ `Steps:`,
754
+ ...steps.map((step) => `- ${step.id} (${step.kind})`),
755
+ ]);
756
+ if (mode === "simulate") {
757
+ if (!signerAddress) {
758
+ throw new Error("Simulation completed without a selected signer address");
759
+ }
760
+ const simulationCallers = simulationCallerBinding?.resolved.map((entry) => ({
761
+ stepId: entry.stepId,
762
+ callerAddress: entry.callerAddress,
763
+ }));
764
+ const fork = (0, simulation_1.simulationForkEvidence)(context.simulation);
765
+ const completionPlan = completedPlan
766
+ ? { executionPlanHash: completedPlan.planHash }
767
+ : {};
768
+ const completionFork = fork ? { fork } : {};
769
+ reporter.result("execution", simulationCallerBinding
770
+ ? {
771
+ kind: "workflow-simulation-completed",
772
+ status: "succeeded",
773
+ selectedStepIds: steps.map((step) => step.id),
774
+ simulationCallerNetworkHash: simulationCallerBinding.networkHash,
775
+ simulationCallers,
776
+ ...completionFork,
777
+ ...completionPlan,
778
+ }
779
+ : {
780
+ kind: "workflow-simulation-completed",
781
+ status: "succeeded",
782
+ selectedStepIds: steps.map((step) => step.id),
783
+ signerAddress,
784
+ ...completionFork,
785
+ ...completionPlan,
786
+ });
787
+ const simulationResult = simulationCallerBinding
788
+ ? reporter.simulationExecutionResultPath({
789
+ simulationCallerNetworkHash: simulationCallerBinding.networkHash,
790
+ simulationCallers: simulationCallers,
791
+ })
792
+ : reporter.simulationExecutionResultPath(signerAddress);
793
+ if (releaseTargetSimulation) {
794
+ if (!simulationCallerBinding || !releaseTargetFingerprint) {
795
+ throw new Error("Release target simulation evidence binding is missing");
796
+ }
797
+ (0, release_1.recordReleaseTargetSimulationSucceeded)({
798
+ taskDir,
799
+ network: targetId,
800
+ executionId,
801
+ simulationResult,
802
+ simulatedAt: new Date().toISOString(),
803
+ simulationCallerNetworkHash: simulationCallerBinding.networkHash,
804
+ fingerprint: releaseTargetFingerprint,
805
+ });
806
+ }
807
+ reporter.status(finalStatus, {
808
+ mode,
809
+ stepCount: steps.length,
810
+ simulationResult,
811
+ });
812
+ if (releaseExecution) {
813
+ if (!completedPlan)
814
+ throw new Error("Final simulation execution plan is missing");
815
+ (0, lock_1.markParameterLockSimulationSucceeded)(taskDir, executionId, simulationResult, new Date().toISOString(), signerAddress, completedPlan.planHash, (0, executionPlan_1.releaseExecutionPlanRelativePath)(taskDir, completedPlan));
816
+ }
817
+ }
818
+ }
819
+ catch (error) {
820
+ if (contextForFailure?.deploymentRecorder) {
821
+ try {
822
+ contextForFailure.deploymentRecorder.markPartial(error);
823
+ }
824
+ catch (recordError) {
825
+ reporter.event("deployment.record.failed", {
826
+ message: recordError instanceof Error ? recordError.message : String(recordError),
827
+ });
828
+ }
829
+ }
830
+ if (mode === "simulate") {
831
+ try {
832
+ reporter.clearSimulationCompletionEvidence();
833
+ }
834
+ catch {
835
+ // Preserve the original workflow failure if evidence cleanup also fails.
836
+ }
837
+ }
838
+ const classification = (0, errors_1.classifyWorkflowError)(error);
839
+ reporter.status("failed", {
840
+ mode,
841
+ errorType: classification.errorType,
842
+ retryable: classification.retryable,
843
+ message: error instanceof Error ? error.message : String(error),
844
+ });
845
+ reporter.event("workflow.failed", {
846
+ mode,
847
+ errorType: classification.errorType,
848
+ retryable: classification.retryable,
849
+ message: error instanceof Error ? error.message : String(error),
850
+ });
851
+ throw error;
852
+ }
853
+ }
854
+ main().catch((error) => {
855
+ console.error(error);
856
+ process.exitCode = 1;
857
+ });
858
+ //# sourceMappingURL=run.js.map