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,505 @@
1
+ import { createRequire } from "node:module";
2
+ import { execFile } from "node:child_process";
3
+ import { createHash } from "node:crypto";
4
+ import {
5
+ lstat,
6
+ mkdir,
7
+ mkdtemp,
8
+ readFile,
9
+ rm,
10
+ writeFile,
11
+ } from "node:fs/promises";
12
+ import { tmpdir } from "node:os";
13
+ import { basename, join } from "node:path";
14
+ import { promisify } from "node:util";
15
+ import type { ForkSnapshotV1 } from "./forkSnapshot";
16
+ import {
17
+ resolveZkSyncForkCapability,
18
+ resolveZkSyncForkRunnerArtifact,
19
+ ZKSYNC_FORK_RUNNER,
20
+ } from "./zksyncForkCapability";
21
+
22
+ export const ANVIL_ZKSYNC_SOURCE_PATH_SUFFIX = "/anvil-zksync";
23
+ const ANVIL_ZKSYNC_REPOSITORY = "https://github.com/matter-labs/anvil-zksync";
24
+ const MAX_ANVIL_ZKSYNC_ARCHIVE_BYTES = 128 * 1024 * 1024;
25
+ const execFileAsync = promisify(execFile);
26
+
27
+ interface RpcServer {
28
+ listen(args?: string[], blockProcess?: boolean): Promise<void>;
29
+ stop(): Promise<void>;
30
+ }
31
+
32
+ interface StartedServer {
33
+ port: number;
34
+ commandArgs: string[];
35
+ server: RpcServer;
36
+ }
37
+
38
+ interface StartServerInput {
39
+ version: string;
40
+ options: {
41
+ fork: string;
42
+ forkBlockNumber: number;
43
+ chainId: number;
44
+ protocolVersion: number;
45
+ host: "127.0.0.1";
46
+ autoImpersonate: boolean;
47
+ cache: "memory";
48
+ quiet: boolean;
49
+ };
50
+ }
51
+
52
+ interface PinnedAnvilZkSyncServerDependencies {
53
+ startServer(
54
+ version?: string,
55
+ binaryPath?: string,
56
+ force?: boolean,
57
+ options?: StartServerInput["options"],
58
+ ): Promise<StartedServer>;
59
+ downloadBinary(version: string): Promise<StagedAnvilZkSyncBinary>;
60
+ }
61
+
62
+ export interface StagedAnvilZkSyncBinary {
63
+ path: string;
64
+ cleanup(): Promise<void>;
65
+ }
66
+
67
+ export interface ZkSyncForkRunnerDependencies {
68
+ startServer(input: StartServerInput): Promise<StartedServer>;
69
+ waitForReady(port: number): Promise<void>;
70
+ rpcRequest(url: string, method: string, params: unknown[]): Promise<unknown>;
71
+ }
72
+
73
+ export interface RunningZkSyncFork {
74
+ rpcUrl: string;
75
+ version: string;
76
+ stop(): Promise<void>;
77
+ }
78
+
79
+ const loopbackUrl = (value: string, requireTokenPath: boolean): string => {
80
+ let parsed: URL;
81
+ try {
82
+ parsed = new URL(value);
83
+ } catch {
84
+ throw new Error("zkSync fork URL is invalid");
85
+ }
86
+ if (
87
+ parsed.protocol !== "http:"
88
+ || parsed.hostname !== "127.0.0.1"
89
+ || !parsed.port
90
+ || (requireTokenPath && parsed.pathname === "/")
91
+ || parsed.username
92
+ || parsed.password
93
+ || parsed.search
94
+ || parsed.hash
95
+ ) {
96
+ throw new Error("zkSync fork URL must be loopback-only");
97
+ }
98
+ return parsed.toString().replace(/\/$/, requireTokenPath ? "" : "");
99
+ };
100
+
101
+ export const zkSyncForkRunnerProtocolVersion = (
102
+ sourceProtocolVersion: number,
103
+ ): number => (
104
+ resolveZkSyncForkCapability(sourceProtocolVersion)?.runnerProtocolVersion
105
+ ?? sourceProtocolVersion
106
+ );
107
+
108
+ export const zkSyncForkRunnerSourceUrl = (
109
+ sourceProxyUrl: string,
110
+ sourceProtocolVersion: number,
111
+ ): string => {
112
+ const canonicalUrl = loopbackUrl(sourceProxyUrl, true);
113
+ if (zkSyncForkRunnerProtocolVersion(sourceProtocolVersion) === sourceProtocolVersion) {
114
+ return canonicalUrl;
115
+ }
116
+ const runnerUrl = new URL(canonicalUrl);
117
+ runnerUrl.pathname = `${runnerUrl.pathname}${ANVIL_ZKSYNC_SOURCE_PATH_SUFFIX}`;
118
+ return loopbackUrl(runnerUrl.toString(), true);
119
+ };
120
+
121
+ export const rewriteZkSyncForkRunnerRpcResult = (
122
+ method: string,
123
+ result: unknown,
124
+ sourceProtocolVersion: number,
125
+ ): unknown => {
126
+ const runnerProtocolVersion = zkSyncForkRunnerProtocolVersion(sourceProtocolVersion);
127
+ if (
128
+ method !== "zks_getBlockDetails"
129
+ || runnerProtocolVersion === sourceProtocolVersion
130
+ || result === null
131
+ || typeof result !== "object"
132
+ || Array.isArray(result)
133
+ ) {
134
+ return result;
135
+ }
136
+ return {
137
+ ...(result as Record<string, unknown>),
138
+ protocolVersion: `Version${runnerProtocolVersion}`,
139
+ };
140
+ };
141
+
142
+ const defaultRpcRequest = async (
143
+ url: string,
144
+ method: string,
145
+ params: unknown[],
146
+ ): Promise<unknown> => {
147
+ let response: Response;
148
+ try {
149
+ response = await fetch(url, {
150
+ method: "POST",
151
+ headers: { "content-type": "application/json" },
152
+ body: JSON.stringify({ jsonrpc: "2.0", id: 1, method, params }),
153
+ });
154
+ } catch {
155
+ throw new Error(`Local EraVM RPC ${method} request failed`);
156
+ }
157
+ if (!response.ok) throw new Error(`Local EraVM RPC ${method} request failed`);
158
+ const body = await response.json() as { result?: unknown; error?: unknown };
159
+ if (body.error !== undefined || body.result === undefined) {
160
+ throw new Error(`Local EraVM RPC ${method} failed`);
161
+ }
162
+ return body.result;
163
+ };
164
+
165
+ export const assertZkSyncForkArtifactDigest = (
166
+ bytes: Uint8Array,
167
+ expectedSha256: string,
168
+ label: string,
169
+ ): void => {
170
+ const actual = createHash("sha256").update(bytes).digest("hex");
171
+ if (actual !== expectedSha256) {
172
+ throw new Error(`${label} integrity verification failed`);
173
+ }
174
+ };
175
+
176
+ export const stageVerifiedAnvilZkSyncBinary = async (
177
+ sourcePath: string,
178
+ expectedSha256: string,
179
+ ): Promise<StagedAnvilZkSyncBinary> => {
180
+ const source = await lstat(sourcePath);
181
+ if (!source.isFile() || source.isSymbolicLink()) {
182
+ throw new Error("Cached anvil-zksync binary must be a regular file");
183
+ }
184
+ const bytes = await readFile(sourcePath);
185
+ assertZkSyncForkArtifactDigest(
186
+ bytes,
187
+ expectedSha256,
188
+ "Cached anvil-zksync binary",
189
+ );
190
+
191
+ const executionDirectory = await mkdtemp(join(tmpdir(), "gate-anvil-zksync-exec-"));
192
+ const executionPath = join(executionDirectory, "anvil-zksync");
193
+ let ready = false;
194
+ try {
195
+ await writeFile(executionPath, bytes, { flag: "wx", mode: 0o700 });
196
+ const staged = await lstat(executionPath);
197
+ if (!staged.isFile() || staged.isSymbolicLink()) {
198
+ throw new Error("Staged anvil-zksync binary must be a regular file");
199
+ }
200
+ assertZkSyncForkArtifactDigest(
201
+ await readFile(executionPath),
202
+ expectedSha256,
203
+ "Staged anvil-zksync binary",
204
+ );
205
+ ready = true;
206
+ let cleaned = false;
207
+ return {
208
+ path: executionPath,
209
+ cleanup: async () => {
210
+ if (cleaned) return;
211
+ await rm(executionDirectory, { recursive: true, force: true });
212
+ cleaned = true;
213
+ },
214
+ };
215
+ } finally {
216
+ if (!ready) {
217
+ await rm(executionDirectory, { recursive: true, force: true });
218
+ }
219
+ }
220
+ };
221
+
222
+ export const resolveZkSyncForkRunner = (
223
+ protocolVersion: number,
224
+ ): { kind: "anvil-zksync"; version: string } | undefined => (
225
+ resolveZkSyncForkCapability(protocolVersion)?.runner
226
+ );
227
+
228
+ const pinnedAnvilZkSyncBinary = async (
229
+ version: string,
230
+ ): Promise<StagedAnvilZkSyncBinary> => {
231
+ if (version !== ZKSYNC_FORK_RUNNER.version) {
232
+ throw new Error(`anvil-zksync fallback requires version ${ZKSYNC_FORK_RUNNER.version}`);
233
+ }
234
+ const artifact = resolveZkSyncForkRunnerArtifact();
235
+ if (!artifact) {
236
+ throw new Error("Pinned anvil-zksync is unavailable for this platform");
237
+ }
238
+ const utilities = createRequire(join(process.cwd(), "package.json"))("@matterlabs/hardhat-zksync-node/dist/utils") as {
239
+ getRPCServerBinariesDir(): Promise<string>;
240
+ getNodeUrl(repository: string, release: string): Promise<string>;
241
+ };
242
+ const binaryDirectory = await utilities.getRPCServerBinariesDir();
243
+ const binaryPath = join(binaryDirectory, version);
244
+ try {
245
+ return await stageVerifiedAnvilZkSyncBinary(binaryPath, artifact.binarySha256);
246
+ } catch (error) {
247
+ if (!error || typeof error !== "object" || (error as NodeJS.ErrnoException).code !== "ENOENT") {
248
+ throw error;
249
+ }
250
+ }
251
+
252
+ const assetUrl = await utilities.getNodeUrl(ANVIL_ZKSYNC_REPOSITORY, version);
253
+ const source = new URL(assetUrl);
254
+ if (
255
+ source.protocol !== "https:"
256
+ || source.hostname !== "github.com"
257
+ || source.pathname !== `/matter-labs/anvil-zksync/releases/download/v${version}/${artifact.assetName}`
258
+ ) {
259
+ throw new Error("Pinned anvil-zksync release URL is invalid for this platform");
260
+ }
261
+
262
+ const response = await fetch(source, { redirect: "follow" });
263
+ const finalUrl = new URL(response.url);
264
+ if (
265
+ !response.ok
266
+ || finalUrl.protocol !== "https:"
267
+ || !(
268
+ finalUrl.hostname === "github.com"
269
+ || finalUrl.hostname.endsWith(".githubusercontent.com")
270
+ )
271
+ ) {
272
+ throw new Error(`Pinned anvil-zksync ${version} download failed`);
273
+ }
274
+ const declaredLength = Number(response.headers.get("content-length"));
275
+ if (
276
+ Number.isFinite(declaredLength)
277
+ && (declaredLength < 1 || declaredLength > MAX_ANVIL_ZKSYNC_ARCHIVE_BYTES)
278
+ ) {
279
+ throw new Error("Pinned anvil-zksync archive size is invalid");
280
+ }
281
+ const archive = Buffer.from(await response.arrayBuffer());
282
+ if (archive.length < 1 || archive.length > MAX_ANVIL_ZKSYNC_ARCHIVE_BYTES) {
283
+ throw new Error("Pinned anvil-zksync archive size is invalid");
284
+ }
285
+ assertZkSyncForkArtifactDigest(
286
+ archive,
287
+ artifact.archiveSha256,
288
+ "Pinned anvil-zksync archive",
289
+ );
290
+
291
+ const temporaryDirectory = await mkdtemp(join(tmpdir(), "gate-anvil-zksync-"));
292
+ try {
293
+ const archivePath = join(temporaryDirectory, "anvil-zksync.tar.gz");
294
+ await writeFile(archivePath, archive, { mode: 0o600 });
295
+ const listing = await execFileAsync("tar", ["-tzf", archivePath], {
296
+ maxBuffer: 1024 * 1024,
297
+ });
298
+ const entries = String(listing.stdout)
299
+ .split(/\r?\n/)
300
+ .map((entry) => entry.replace(/^\.\//, "").trim())
301
+ .filter(Boolean);
302
+ if (
303
+ entries.length !== 1
304
+ || entries[0] !== basename(entries[0])
305
+ || entries[0] === "."
306
+ || entries[0] === ".."
307
+ ) {
308
+ throw new Error("Pinned anvil-zksync archive must contain one regular file");
309
+ }
310
+ const extractionDirectory = join(temporaryDirectory, "extract");
311
+ await mkdir(extractionDirectory, { recursive: true });
312
+ await execFileAsync("tar", ["-xzf", archivePath, "-C", extractionDirectory]);
313
+ const extractedPath = join(extractionDirectory, entries[0]);
314
+ const extracted = await lstat(extractedPath);
315
+ if (!extracted.isFile() || extracted.isSymbolicLink()) {
316
+ throw new Error("Pinned anvil-zksync archive must contain one regular file");
317
+ }
318
+ assertZkSyncForkArtifactDigest(
319
+ await readFile(extractedPath),
320
+ artifact.binarySha256,
321
+ "Extracted anvil-zksync binary",
322
+ );
323
+ return await stageVerifiedAnvilZkSyncBinary(extractedPath, artifact.binarySha256);
324
+ } finally {
325
+ await rm(temporaryDirectory, { recursive: true, force: true });
326
+ }
327
+ };
328
+
329
+ export const startPinnedAnvilZkSyncServer = async (
330
+ input: StartServerInput,
331
+ dependencies: PinnedAnvilZkSyncServerDependencies,
332
+ ): Promise<StartedServer> => {
333
+ if (input.version !== ZKSYNC_FORK_RUNNER.version) {
334
+ throw new Error(`Unsupported anvil-zksync runner version ${input.version}`);
335
+ }
336
+ const stagedBinary = await dependencies.downloadBinary(input.version);
337
+ let started: StartedServer;
338
+ try {
339
+ started = await dependencies.startServer(
340
+ input.version,
341
+ stagedBinary.path,
342
+ false,
343
+ input.options,
344
+ );
345
+ } catch (error) {
346
+ try {
347
+ await stagedBinary.cleanup();
348
+ } catch {
349
+ // Preserve the plugin construction error; the private directory is best-effort cleanup here.
350
+ }
351
+ throw error;
352
+ }
353
+
354
+ const server = started.server;
355
+ let cleanupPromise: Promise<void> | undefined;
356
+ const cleanup = (): Promise<void> => {
357
+ cleanupPromise ??= stagedBinary.cleanup();
358
+ return cleanupPromise;
359
+ };
360
+ return {
361
+ ...started,
362
+ server: {
363
+ listen: async (args, blockProcess) => {
364
+ try {
365
+ await server.listen(args, blockProcess);
366
+ } catch (error) {
367
+ try {
368
+ await cleanup();
369
+ } catch {
370
+ // Preserve the process startup error.
371
+ }
372
+ throw error;
373
+ }
374
+ },
375
+ stop: async () => {
376
+ try {
377
+ await server.stop();
378
+ } finally {
379
+ await cleanup();
380
+ }
381
+ },
382
+ },
383
+ };
384
+ };
385
+
386
+ const defaultDependencies = (): ZkSyncForkRunnerDependencies => {
387
+ const utilities = createRequire(join(process.cwd(), "package.json"))("@matterlabs/hardhat-zksync-node/dist/utils") as {
388
+ startServer(
389
+ version?: string,
390
+ binaryPath?: string,
391
+ force?: boolean,
392
+ options?: StartServerInput["options"],
393
+ ): Promise<StartedServer>;
394
+ waitForNodeToBeReady(port: number): Promise<void>;
395
+ };
396
+ return {
397
+ startServer: async (input) => startPinnedAnvilZkSyncServer(input, {
398
+ startServer: utilities.startServer,
399
+ downloadBinary: pinnedAnvilZkSyncBinary,
400
+ }),
401
+ waitForReady: (port) => utilities.waitForNodeToBeReady(port),
402
+ rpcRequest: defaultRpcRequest,
403
+ };
404
+ };
405
+
406
+ const blockTag = (blockNumber: number): string => `0x${blockNumber.toString(16)}`;
407
+
408
+ export const startZkSyncForkRunner = async (
409
+ input: {
410
+ sourceProxyUrl: string;
411
+ snapshot: ForkSnapshotV1;
412
+ },
413
+ dependencies: ZkSyncForkRunnerDependencies = defaultDependencies(),
414
+ ): Promise<RunningZkSyncFork> => {
415
+ if (
416
+ input.snapshot.runner.kind !== "anvil-zksync"
417
+ || !("protocolVersion" in input.snapshot)
418
+ || !Number.isSafeInteger(input.snapshot.protocolVersion)
419
+ ) {
420
+ throw new Error(
421
+ `zkSync fork snapshot must use an approved anvil-zksync runner`,
422
+ );
423
+ }
424
+ const approvedRunner = resolveZkSyncForkRunner(input.snapshot.protocolVersion);
425
+ if (!approvedRunner) {
426
+ throw new Error(
427
+ `zkSync protocol ${input.snapshot.protocolVersion} is unsupported by the approved anvil-zksync runners`,
428
+ );
429
+ }
430
+ if (input.snapshot.runner.version !== approvedRunner.version) {
431
+ throw new Error(
432
+ `zkSync protocol ${input.snapshot.protocolVersion} requires anvil-zksync ${approvedRunner.version}`,
433
+ );
434
+ }
435
+ const capability = resolveZkSyncForkCapability(input.snapshot.protocolVersion);
436
+ if (!capability) {
437
+ throw new Error(
438
+ `zkSync protocol ${input.snapshot.protocolVersion} is unsupported by the approved anvil-zksync runners`,
439
+ );
440
+ }
441
+ const sourceProxyUrl = zkSyncForkRunnerSourceUrl(
442
+ input.sourceProxyUrl,
443
+ input.snapshot.protocolVersion,
444
+ );
445
+ let started: StartedServer | undefined;
446
+ let stopped = false;
447
+ const stop = async (): Promise<void> => {
448
+ if (!started || stopped) return;
449
+ stopped = true;
450
+ await started.server.stop();
451
+ };
452
+ try {
453
+ started = await dependencies.startServer({
454
+ version: input.snapshot.runner.version,
455
+ options: {
456
+ fork: sourceProxyUrl,
457
+ forkBlockNumber: input.snapshot.blockNumber,
458
+ chainId: input.snapshot.chainId,
459
+ protocolVersion: capability.runnerProtocolVersion,
460
+ host: "127.0.0.1",
461
+ autoImpersonate: true,
462
+ cache: "memory",
463
+ quiet: true,
464
+ },
465
+ });
466
+ if (!Number.isSafeInteger(started.port) || started.port < 1 || started.port > 65_535) {
467
+ throw new Error("anvil-zksync selected an invalid local port");
468
+ }
469
+ await started.server.listen(started.commandArgs, false);
470
+ await dependencies.waitForReady(started.port);
471
+ const rpcUrl = loopbackUrl(`http://127.0.0.1:${started.port}`, false);
472
+ const [chainId, forkBlock] = await Promise.all([
473
+ dependencies.rpcRequest(rpcUrl, "eth_chainId", []),
474
+ dependencies.rpcRequest(
475
+ rpcUrl,
476
+ "eth_getBlockByNumber",
477
+ [blockTag(input.snapshot.blockNumber), false],
478
+ ),
479
+ ]);
480
+ if (
481
+ typeof chainId !== "string"
482
+ || !/^0x[0-9a-fA-F]+$/.test(chainId)
483
+ || BigInt(chainId) !== BigInt(input.snapshot.chainId)
484
+ ) {
485
+ throw new Error(`EraVM fork chainId does not match target chainId ${input.snapshot.chainId}`);
486
+ }
487
+ const hash = forkBlock && typeof forkBlock === "object" && !Array.isArray(forkBlock)
488
+ ? (forkBlock as { hash?: unknown }).hash
489
+ : undefined;
490
+ if (
491
+ typeof hash !== "string"
492
+ || hash.toLowerCase() !== input.snapshot.blockHash.toLowerCase()
493
+ ) {
494
+ throw new Error(`EraVM fork block hash mismatch at ${input.snapshot.blockNumber}`);
495
+ }
496
+ return {
497
+ rpcUrl,
498
+ version: input.snapshot.runner.version,
499
+ stop,
500
+ };
501
+ } catch (error) {
502
+ await stop();
503
+ throw error;
504
+ }
505
+ };
@@ -0,0 +1,86 @@
1
+ import { spawnSync } from "child_process";
2
+ import path from "path";
3
+ import { openZeppelinProcessEnvironment } from "../config/openzeppelin";
4
+ import { resolveCliTool } from "./lib/cliTool";
5
+ import { validateExecutionId } from "./lib/executionId";
6
+
7
+ const RECONCILIATION_INPUT_ENV = "WORKFLOW_RECONCILE_EXTERNAL_INPUT_JSON";
8
+
9
+ const parseArgs = (argv: string[]): Record<string, string> => {
10
+ const args: Record<string, string> = {};
11
+ for (let index = 0; index < argv.length; index += 1) {
12
+ const item = argv[index];
13
+ if (!item.startsWith("--")) continue;
14
+ const key = item.slice(2);
15
+ const value = argv[index + 1];
16
+ if (!value || value.startsWith("--")) throw new Error(`--${key} requires a value`);
17
+ if (args[key] !== undefined) throw new Error(`--${key} may be provided only once`);
18
+ args[key] = value;
19
+ index += 1;
20
+ }
21
+ return args;
22
+ };
23
+
24
+ const required = (args: Record<string, string>, key: string): string => {
25
+ const value = args[key]?.trim();
26
+ if (!value) throw new Error(`--${key} is required`);
27
+ return value;
28
+ };
29
+
30
+ const main = (): void => {
31
+ const args = parseArgs(process.argv.slice(2));
32
+ const root = path.resolve(args.root || process.cwd());
33
+ const network = required(args, "network");
34
+ const executionId = validateExecutionId(required(args, "executionId"));
35
+ const batchSize = args.batchSize === undefined ? undefined : Number(args.batchSize);
36
+ if (
37
+ batchSize !== undefined
38
+ && (!Number.isInteger(batchSize) || batchSize < 1 || batchSize > 1000)
39
+ ) {
40
+ throw new Error("--batchSize must be an integer between 1 and 1000");
41
+ }
42
+ const input = {
43
+ version: 1,
44
+ root,
45
+ taskId: required(args, "task"),
46
+ network,
47
+ executionId,
48
+ ...(batchSize === undefined ? {} : { batchSize }),
49
+ };
50
+ const manifestEnv = openZeppelinProcessEnvironment({
51
+ root,
52
+ network,
53
+ mode: "execute",
54
+ target: network,
55
+ env: process.env,
56
+ });
57
+ const hardhat = resolveCliTool({ root, binary: "hardhat" });
58
+ const result = spawnSync(
59
+ hardhat.command,
60
+ [
61
+ ...hardhat.argsPrefix,
62
+ "run",
63
+ path.join(__dirname, "reconcileExternalRun.js"),
64
+ "--network",
65
+ network,
66
+ "--no-compile",
67
+ ],
68
+ {
69
+ cwd: root,
70
+ env: {
71
+ ...manifestEnv,
72
+ [RECONCILIATION_INPUT_ENV]: JSON.stringify(input),
73
+ },
74
+ stdio: "inherit",
75
+ },
76
+ );
77
+ if (result.error) throw result.error;
78
+ process.exitCode = result.status ?? 1;
79
+ };
80
+
81
+ try {
82
+ main();
83
+ } catch (error) {
84
+ console.error(error instanceof Error ? error.message : String(error));
85
+ process.exitCode = 1;
86
+ }
@@ -0,0 +1,88 @@
1
+ import path from "path";
2
+ import hardhat from "../projectHardhat";
3
+ import type { JsonRpcProvider } from "ethers";
4
+ import { reconcileExternalExecution } from "./lib/externalExecutionScanner";
5
+
6
+ interface ReconciliationInput {
7
+ version: 1;
8
+ root: string;
9
+ taskId: string;
10
+ network: string;
11
+ executionId: string;
12
+ batchSize?: number;
13
+ }
14
+
15
+ const RECONCILIATION_INPUT_ENV = "WORKFLOW_RECONCILE_EXTERNAL_INPUT_JSON";
16
+
17
+ const nonEmptyString = (value: unknown, label: string): string => {
18
+ if (typeof value !== "string" || !value.trim()) {
19
+ throw new Error(`${label} must be a non-empty string`);
20
+ }
21
+ return value;
22
+ };
23
+
24
+ const loadInput = (): ReconciliationInput => {
25
+ const raw = process.env[RECONCILIATION_INPUT_ENV];
26
+ if (!raw) throw new Error(`${RECONCILIATION_INPUT_ENV} is required`);
27
+ let parsed: unknown;
28
+ try {
29
+ parsed = JSON.parse(raw) as unknown;
30
+ } catch (error) {
31
+ throw new Error(
32
+ `Cannot parse ${RECONCILIATION_INPUT_ENV}: ${error instanceof Error ? error.message : String(error)}`,
33
+ );
34
+ }
35
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
36
+ throw new Error(`${RECONCILIATION_INPUT_ENV} must contain an object`);
37
+ }
38
+ const input = parsed as Record<string, unknown>;
39
+ if (input.version !== 1) throw new Error("External reconciliation input version must be 1");
40
+ const batchSize = input.batchSize;
41
+ if (
42
+ batchSize !== undefined
43
+ && (!Number.isInteger(batchSize) || Number(batchSize) < 1 || Number(batchSize) > 1000)
44
+ ) {
45
+ throw new Error("External reconciliation batchSize must be between 1 and 1000");
46
+ }
47
+ return {
48
+ version: 1,
49
+ root: nonEmptyString(input.root, "External reconciliation root"),
50
+ taskId: nonEmptyString(input.taskId, "External reconciliation taskId"),
51
+ network: nonEmptyString(input.network, "External reconciliation network"),
52
+ executionId: nonEmptyString(input.executionId, "External reconciliation executionId"),
53
+ ...(batchSize === undefined ? {} : { batchSize: Number(batchSize) }),
54
+ };
55
+ };
56
+
57
+ const main = async (): Promise<void> => {
58
+ const input = loadInput();
59
+ if (hardhat.network.name !== input.network) {
60
+ throw new Error(
61
+ `External reconciliation target ${input.network} does not match Hardhat network ${hardhat.network.name}`,
62
+ );
63
+ }
64
+ if (path.resolve(hardhat.config.paths.root) !== path.resolve(input.root)) {
65
+ throw new Error("External reconciliation root does not match the Hardhat project root");
66
+ }
67
+ const report = await reconcileExternalExecution({
68
+ root: path.resolve(input.root),
69
+ taskId: input.taskId,
70
+ network: input.network,
71
+ executionId: input.executionId,
72
+ provider: hardhat.ethers.provider as unknown as JsonRpcProvider,
73
+ batchSize: input.batchSize,
74
+ gateToolSyncHre: hardhat,
75
+ });
76
+ console.log(JSON.stringify({
77
+ status: report.status,
78
+ reportPath: report.reportPath,
79
+ nextBlock: report.segments?.at(-1)?.nextBlock,
80
+ finalizedBlock: report.finalizedBlock,
81
+ }));
82
+ if (report.status === "failed") process.exitCode = 1;
83
+ };
84
+
85
+ void main().catch((error) => {
86
+ console.error(error instanceof Error ? error.message : String(error));
87
+ process.exitCode = 1;
88
+ });
@@ -0,0 +1,8 @@
1
+ import { runReleaseFinalizeCli } from "./lib/releaseFinalize";
2
+
3
+ try {
4
+ console.log(JSON.stringify(runReleaseFinalizeCli(process.argv.slice(2))));
5
+ } catch (error) {
6
+ console.error(error instanceof Error ? error.message : String(error));
7
+ process.exitCode = 1;
8
+ }