gate-evm-tools 1.0.26 → 1.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (323) hide show
  1. package/README.md +14 -0
  2. package/bin/workflow.cjs +19 -0
  3. package/dist/core/BytecodeChecker.d.ts.map +1 -1
  4. package/dist/core/BytecodeChecker.js +16 -1
  5. package/dist/core/BytecodeChecker.js.map +1 -1
  6. package/dist/core/legacyProxyArtifact.d.ts +6 -0
  7. package/dist/core/legacyProxyArtifact.d.ts.map +1 -0
  8. package/dist/core/legacyProxyArtifact.js +36 -0
  9. package/dist/core/legacyProxyArtifact.js.map +1 -0
  10. package/dist-runtime/config/hardhatAdapters.d.ts +5 -0
  11. package/dist-runtime/config/hardhatAdapters.js +53 -0
  12. package/dist-runtime/config/hardhatAdapters.js.map +1 -0
  13. package/dist-runtime/config/networks.d.ts +8 -0
  14. package/dist-runtime/config/networks.js +269 -0
  15. package/dist-runtime/config/networks.js.map +1 -0
  16. package/dist-runtime/config/openzeppelin.d.ts +28 -0
  17. package/dist-runtime/config/openzeppelin.js +144 -0
  18. package/dist-runtime/config/openzeppelin.js.map +1 -0
  19. package/dist-runtime/config/rpc.d.ts +7 -0
  20. package/dist-runtime/config/rpc.js +19 -0
  21. package/dist-runtime/config/rpc.js.map +1 -0
  22. package/dist-runtime/config/zksyncSolcPath.d.ts +1 -0
  23. package/dist-runtime/config/zksyncSolcPath.js +61 -0
  24. package/dist-runtime/config/zksyncSolcPath.js.map +1 -0
  25. package/dist-runtime/migrate.d.ts +13 -0
  26. package/dist-runtime/migrate.js +208 -0
  27. package/dist-runtime/migrate.js.map +1 -0
  28. package/dist-runtime/package.json +1 -0
  29. package/dist-runtime/projectHardhat.d.ts +4 -0
  30. package/dist-runtime/projectHardhat.js +16 -0
  31. package/dist-runtime/projectHardhat.js.map +1 -0
  32. package/dist-runtime/runtime-identity.json +4 -0
  33. package/dist-runtime/template-migration.json +293 -0
  34. package/dist-runtime/workflow/checkCode.d.ts +1 -0
  35. package/dist-runtime/workflow/checkCode.js +16 -0
  36. package/dist-runtime/workflow/checkCode.js.map +1 -0
  37. package/dist-runtime/workflow/checkCodeFinalize.d.ts +1 -0
  38. package/dist-runtime/workflow/checkCodeFinalize.js +11 -0
  39. package/dist-runtime/workflow/checkCodeFinalize.js.map +1 -0
  40. package/dist-runtime/workflow/checkCodePlan.d.ts +1 -0
  41. package/dist-runtime/workflow/checkCodePlan.js +11 -0
  42. package/dist-runtime/workflow/checkCodePlan.js.map +1 -0
  43. package/dist-runtime/workflow/cli.d.ts +1 -0
  44. package/dist-runtime/workflow/cli.js +302 -0
  45. package/dist-runtime/workflow/cli.js.map +1 -0
  46. package/dist-runtime/workflow/commitContractInfo.d.ts +1 -0
  47. package/dist-runtime/workflow/commitContractInfo.js +64 -0
  48. package/dist-runtime/workflow/commitContractInfo.js.map +1 -0
  49. package/dist-runtime/workflow/create2Hashes.d.ts +1 -0
  50. package/dist-runtime/workflow/create2Hashes.js +76 -0
  51. package/dist-runtime/workflow/create2Hashes.js.map +1 -0
  52. package/dist-runtime/workflow/forkSourceProxy.d.ts +1 -0
  53. package/dist-runtime/workflow/forkSourceProxy.js +151 -0
  54. package/dist-runtime/workflow/forkSourceProxy.js.map +1 -0
  55. package/dist-runtime/workflow/importState.d.ts +1 -0
  56. package/dist-runtime/workflow/importState.js +193 -0
  57. package/dist-runtime/workflow/importState.js.map +1 -0
  58. package/dist-runtime/workflow/lib/authority.d.ts +28 -0
  59. package/dist-runtime/workflow/lib/authority.js +122 -0
  60. package/dist-runtime/workflow/lib/authority.js.map +1 -0
  61. package/dist-runtime/workflow/lib/calldata.d.ts +2 -0
  62. package/dist-runtime/workflow/lib/calldata.js +8 -0
  63. package/dist-runtime/workflow/lib/calldata.js.map +1 -0
  64. package/dist-runtime/workflow/lib/calls.d.ts +23 -0
  65. package/dist-runtime/workflow/lib/calls.js +316 -0
  66. package/dist-runtime/workflow/lib/calls.js.map +1 -0
  67. package/dist-runtime/workflow/lib/checkCode/args.d.ts +2 -0
  68. package/dist-runtime/workflow/lib/checkCode/args.js +68 -0
  69. package/dist-runtime/workflow/lib/checkCode/args.js.map +1 -0
  70. package/dist-runtime/workflow/lib/checkCode/command.d.ts +5 -0
  71. package/dist-runtime/workflow/lib/checkCode/command.js +35 -0
  72. package/dist-runtime/workflow/lib/checkCode/command.js.map +1 -0
  73. package/dist-runtime/workflow/lib/checkCode/dependencies.d.ts +6 -0
  74. package/dist-runtime/workflow/lib/checkCode/dependencies.js +125 -0
  75. package/dist-runtime/workflow/lib/checkCode/dependencies.js.map +1 -0
  76. package/dist-runtime/workflow/lib/checkCode/finalize.d.ts +17 -0
  77. package/dist-runtime/workflow/lib/checkCode/finalize.js +174 -0
  78. package/dist-runtime/workflow/lib/checkCode/finalize.js.map +1 -0
  79. package/dist-runtime/workflow/lib/checkCode/index.d.ts +3 -0
  80. package/dist-runtime/workflow/lib/checkCode/index.js +20 -0
  81. package/dist-runtime/workflow/lib/checkCode/index.js.map +1 -0
  82. package/dist-runtime/workflow/lib/checkCode/plan.d.ts +22 -0
  83. package/dist-runtime/workflow/lib/checkCode/plan.js +145 -0
  84. package/dist-runtime/workflow/lib/checkCode/plan.js.map +1 -0
  85. package/dist-runtime/workflow/lib/checkCodeReport.d.ts +25 -0
  86. package/dist-runtime/workflow/lib/checkCodeReport.js +102 -0
  87. package/dist-runtime/workflow/lib/checkCodeReport.js.map +1 -0
  88. package/dist-runtime/workflow/lib/checkCodeRunner.d.ts +87 -0
  89. package/dist-runtime/workflow/lib/checkCodeRunner.js +964 -0
  90. package/dist-runtime/workflow/lib/checkCodeRunner.js.map +1 -0
  91. package/dist-runtime/workflow/lib/cliTool.d.ts +10 -0
  92. package/dist-runtime/workflow/lib/cliTool.js +25 -0
  93. package/dist-runtime/workflow/lib/cliTool.js.map +1 -0
  94. package/dist-runtime/workflow/lib/config.d.ts +33 -0
  95. package/dist-runtime/workflow/lib/config.js +100 -0
  96. package/dist-runtime/workflow/lib/config.js.map +1 -0
  97. package/dist-runtime/workflow/lib/contractInfoCandidates.d.ts +82 -0
  98. package/dist-runtime/workflow/lib/contractInfoCandidates.js +441 -0
  99. package/dist-runtime/workflow/lib/contractInfoCandidates.js.map +1 -0
  100. package/dist-runtime/workflow/lib/create2.d.ts +49 -0
  101. package/dist-runtime/workflow/lib/create2.js +194 -0
  102. package/dist-runtime/workflow/lib/create2.js.map +1 -0
  103. package/dist-runtime/workflow/lib/create2Hashes.d.ts +22 -0
  104. package/dist-runtime/workflow/lib/create2Hashes.js +57 -0
  105. package/dist-runtime/workflow/lib/create2Hashes.js.map +1 -0
  106. package/dist-runtime/workflow/lib/deploymentInfo.d.ts +40 -0
  107. package/dist-runtime/workflow/lib/deploymentInfo.js +240 -0
  108. package/dist-runtime/workflow/lib/deploymentInfo.js.map +1 -0
  109. package/dist-runtime/workflow/lib/deploymentRecords.d.ts +137 -0
  110. package/dist-runtime/workflow/lib/deploymentRecords.js +374 -0
  111. package/dist-runtime/workflow/lib/deploymentRecords.js.map +1 -0
  112. package/dist-runtime/workflow/lib/deployments.d.ts +21 -0
  113. package/dist-runtime/workflow/lib/deployments.js +240 -0
  114. package/dist-runtime/workflow/lib/deployments.js.map +1 -0
  115. package/dist-runtime/workflow/lib/erc1967.d.ts +5 -0
  116. package/dist-runtime/workflow/lib/erc1967.js +29 -0
  117. package/dist-runtime/workflow/lib/erc1967.js.map +1 -0
  118. package/dist-runtime/workflow/lib/errors.d.ts +6 -0
  119. package/dist-runtime/workflow/lib/errors.js +77 -0
  120. package/dist-runtime/workflow/lib/errors.js.map +1 -0
  121. package/dist-runtime/workflow/lib/executionId.d.ts +7 -0
  122. package/dist-runtime/workflow/lib/executionId.js +26 -0
  123. package/dist-runtime/workflow/lib/executionId.js.map +1 -0
  124. package/dist-runtime/workflow/lib/executionPlan.d.ts +85 -0
  125. package/dist-runtime/workflow/lib/executionPlan.js +450 -0
  126. package/dist-runtime/workflow/lib/executionPlan.js.map +1 -0
  127. package/dist-runtime/workflow/lib/executionProgress.d.ts +5 -0
  128. package/dist-runtime/workflow/lib/executionProgress.js +100 -0
  129. package/dist-runtime/workflow/lib/executionProgress.js.map +1 -0
  130. package/dist-runtime/workflow/lib/external.d.ts +62 -0
  131. package/dist-runtime/workflow/lib/external.js +282 -0
  132. package/dist-runtime/workflow/lib/external.js.map +1 -0
  133. package/dist-runtime/workflow/lib/externalExecutionScanner.d.ts +64 -0
  134. package/dist-runtime/workflow/lib/externalExecutionScanner.js +638 -0
  135. package/dist-runtime/workflow/lib/externalExecutionScanner.js.map +1 -0
  136. package/dist-runtime/workflow/lib/forkSnapshot.d.ts +34 -0
  137. package/dist-runtime/workflow/lib/forkSnapshot.js +167 -0
  138. package/dist-runtime/workflow/lib/forkSnapshot.js.map +1 -0
  139. package/dist-runtime/workflow/lib/gateTool.d.ts +16 -0
  140. package/dist-runtime/workflow/lib/gateTool.js +177 -0
  141. package/dist-runtime/workflow/lib/gateTool.js.map +1 -0
  142. package/dist-runtime/workflow/lib/gateToolSync.d.ts +22 -0
  143. package/dist-runtime/workflow/lib/gateToolSync.js +253 -0
  144. package/dist-runtime/workflow/lib/gateToolSync.js.map +1 -0
  145. package/dist-runtime/workflow/lib/lock.d.ts +52 -0
  146. package/dist-runtime/workflow/lib/lock.js +269 -0
  147. package/dist-runtime/workflow/lib/lock.js.map +1 -0
  148. package/dist-runtime/workflow/lib/migrationState.d.ts +103 -0
  149. package/dist-runtime/workflow/lib/migrationState.js +920 -0
  150. package/dist-runtime/workflow/lib/migrationState.js.map +1 -0
  151. package/dist-runtime/workflow/lib/operatorExecution.d.ts +28 -0
  152. package/dist-runtime/workflow/lib/operatorExecution.js +134 -0
  153. package/dist-runtime/workflow/lib/operatorExecution.js.map +1 -0
  154. package/dist-runtime/workflow/lib/parameters.d.ts +58 -0
  155. package/dist-runtime/workflow/lib/parameters.js +322 -0
  156. package/dist-runtime/workflow/lib/parameters.js.map +1 -0
  157. package/dist-runtime/workflow/lib/pendingDeploymentReuse.d.ts +29 -0
  158. package/dist-runtime/workflow/lib/pendingDeploymentReuse.js +277 -0
  159. package/dist-runtime/workflow/lib/pendingDeploymentReuse.js.map +1 -0
  160. package/dist-runtime/workflow/lib/proxy.d.ts +18 -0
  161. package/dist-runtime/workflow/lib/proxy.js +19 -0
  162. package/dist-runtime/workflow/lib/proxy.js.map +1 -0
  163. package/dist-runtime/workflow/lib/registryCommit.d.ts +33 -0
  164. package/dist-runtime/workflow/lib/registryCommit.js +319 -0
  165. package/dist-runtime/workflow/lib/registryCommit.js.map +1 -0
  166. package/dist-runtime/workflow/lib/release.d.ts +57 -0
  167. package/dist-runtime/workflow/lib/release.js +256 -0
  168. package/dist-runtime/workflow/lib/release.js.map +1 -0
  169. package/dist-runtime/workflow/lib/releaseFinalize.d.ts +14 -0
  170. package/dist-runtime/workflow/lib/releaseFinalize.js +571 -0
  171. package/dist-runtime/workflow/lib/releaseFinalize.js.map +1 -0
  172. package/dist-runtime/workflow/lib/releaseParameters.d.ts +43 -0
  173. package/dist-runtime/workflow/lib/releaseParameters.js +184 -0
  174. package/dist-runtime/workflow/lib/releaseParameters.js.map +1 -0
  175. package/dist-runtime/workflow/lib/reporter.d.ts +39 -0
  176. package/dist-runtime/workflow/lib/reporter.js +452 -0
  177. package/dist-runtime/workflow/lib/reporter.js.map +1 -0
  178. package/dist-runtime/workflow/lib/resultPaths.d.ts +17 -0
  179. package/dist-runtime/workflow/lib/resultPaths.js +29 -0
  180. package/dist-runtime/workflow/lib/resultPaths.js.map +1 -0
  181. package/dist-runtime/workflow/lib/runtimeVersion.d.ts +10 -0
  182. package/dist-runtime/workflow/lib/runtimeVersion.js +46 -0
  183. package/dist-runtime/workflow/lib/runtimeVersion.js.map +1 -0
  184. package/dist-runtime/workflow/lib/signer.d.ts +10 -0
  185. package/dist-runtime/workflow/lib/signer.js +105 -0
  186. package/dist-runtime/workflow/lib/signer.js.map +1 -0
  187. package/dist-runtime/workflow/lib/signerIdentity.d.ts +1 -0
  188. package/dist-runtime/workflow/lib/signerIdentity.js +23 -0
  189. package/dist-runtime/workflow/lib/signerIdentity.js.map +1 -0
  190. package/dist-runtime/workflow/lib/simulation.d.ts +35 -0
  191. package/dist-runtime/workflow/lib/simulation.js +282 -0
  192. package/dist-runtime/workflow/lib/simulation.js.map +1 -0
  193. package/dist-runtime/workflow/lib/simulationCallers.d.ts +44 -0
  194. package/dist-runtime/workflow/lib/simulationCallers.js +260 -0
  195. package/dist-runtime/workflow/lib/simulationCallers.js.map +1 -0
  196. package/dist-runtime/workflow/lib/sourceRpcPolicy.d.ts +1 -0
  197. package/dist-runtime/workflow/lib/sourceRpcPolicy.js +43 -0
  198. package/dist-runtime/workflow/lib/sourceRpcPolicy.js.map +1 -0
  199. package/dist-runtime/workflow/lib/state.d.ts +6 -0
  200. package/dist-runtime/workflow/lib/state.js +25 -0
  201. package/dist-runtime/workflow/lib/state.js.map +1 -0
  202. package/dist-runtime/workflow/lib/staticValidation.d.ts +22 -0
  203. package/dist-runtime/workflow/lib/staticValidation.js +124 -0
  204. package/dist-runtime/workflow/lib/staticValidation.js.map +1 -0
  205. package/dist-runtime/workflow/lib/zksyncForkCapability.d.ts +27 -0
  206. package/dist-runtime/workflow/lib/zksyncForkCapability.js +52 -0
  207. package/dist-runtime/workflow/lib/zksyncForkCapability.js.map +1 -0
  208. package/dist-runtime/workflow/lib/zksyncForkRunner.d.ts +57 -0
  209. package/dist-runtime/workflow/lib/zksyncForkRunner.js +344 -0
  210. package/dist-runtime/workflow/lib/zksyncForkRunner.js.map +1 -0
  211. package/dist-runtime/workflow/reconcileExternal.d.ts +1 -0
  212. package/dist-runtime/workflow/reconcileExternal.js +87 -0
  213. package/dist-runtime/workflow/reconcileExternal.js.map +1 -0
  214. package/dist-runtime/workflow/reconcileExternalRun.d.ts +1 -0
  215. package/dist-runtime/workflow/reconcileExternalRun.js +77 -0
  216. package/dist-runtime/workflow/reconcileExternalRun.js.map +1 -0
  217. package/dist-runtime/workflow/releaseFinalize.d.ts +1 -0
  218. package/dist-runtime/workflow/releaseFinalize.js +11 -0
  219. package/dist-runtime/workflow/releaseFinalize.js.map +1 -0
  220. package/dist-runtime/workflow/run.d.ts +40 -0
  221. package/dist-runtime/workflow/run.js +858 -0
  222. package/dist-runtime/workflow/run.js.map +1 -0
  223. package/dist-runtime/workflow/staticValidate.d.ts +1 -0
  224. package/dist-runtime/workflow/staticValidate.js +26 -0
  225. package/dist-runtime/workflow/staticValidate.js.map +1 -0
  226. package/dist-runtime/workflow/steps/call.d.ts +3 -0
  227. package/dist-runtime/workflow/steps/call.js +9 -0
  228. package/dist-runtime/workflow/steps/call.js.map +1 -0
  229. package/dist-runtime/workflow/steps/check.d.ts +3 -0
  230. package/dist-runtime/workflow/steps/check.js +9 -0
  231. package/dist-runtime/workflow/steps/check.js.map +1 -0
  232. package/dist-runtime/workflow/steps/custom.d.ts +3 -0
  233. package/dist-runtime/workflow/steps/custom.js +33 -0
  234. package/dist-runtime/workflow/steps/custom.js.map +1 -0
  235. package/dist-runtime/workflow/steps/deploy.d.ts +3 -0
  236. package/dist-runtime/workflow/steps/deploy.js +595 -0
  237. package/dist-runtime/workflow/steps/deploy.js.map +1 -0
  238. package/dist-runtime/workflow/steps/upgrade.d.ts +3 -0
  239. package/dist-runtime/workflow/steps/upgrade.js +465 -0
  240. package/dist-runtime/workflow/steps/upgrade.js.map +1 -0
  241. package/dist-runtime/workflow/steps/view.d.ts +3 -0
  242. package/dist-runtime/workflow/steps/view.js +9 -0
  243. package/dist-runtime/workflow/steps/view.js.map +1 -0
  244. package/package.json +25 -5
  245. package/runtime/config/hardhatAdapters.ts +50 -0
  246. package/runtime/config/networks.ts +296 -0
  247. package/runtime/config/openzeppelin.ts +173 -0
  248. package/runtime/config/rpc.ts +27 -0
  249. package/runtime/config/zksyncSolcPath.ts +59 -0
  250. package/runtime/hardhat-types.d.ts +2 -0
  251. package/runtime/migrate.ts +154 -0
  252. package/runtime/projectHardhat.ts +10 -0
  253. package/runtime/template-migration.json +293 -0
  254. package/runtime/workflow/checkCode.ts +13 -0
  255. package/runtime/workflow/checkCodeFinalize.ts +8 -0
  256. package/runtime/workflow/checkCodePlan.ts +8 -0
  257. package/runtime/workflow/cli.ts +356 -0
  258. package/runtime/workflow/commitContractInfo.ts +63 -0
  259. package/runtime/workflow/create2Hashes.ts +79 -0
  260. package/runtime/workflow/forkSourceProxy.ts +193 -0
  261. package/runtime/workflow/importState.ts +190 -0
  262. package/runtime/workflow/lib/authority.ts +170 -0
  263. package/runtime/workflow/lib/calldata.ts +9 -0
  264. package/runtime/workflow/lib/calls.ts +407 -0
  265. package/runtime/workflow/lib/checkCode/args.ts +76 -0
  266. package/runtime/workflow/lib/checkCode/command.ts +36 -0
  267. package/runtime/workflow/lib/checkCode/dependencies.ts +112 -0
  268. package/runtime/workflow/lib/checkCode/finalize.ts +198 -0
  269. package/runtime/workflow/lib/checkCode/index.ts +18 -0
  270. package/runtime/workflow/lib/checkCode/plan.ts +163 -0
  271. package/runtime/workflow/lib/checkCodeReport.ts +133 -0
  272. package/runtime/workflow/lib/checkCodeRunner.ts +1225 -0
  273. package/runtime/workflow/lib/cliTool.ts +31 -0
  274. package/runtime/workflow/lib/config.ts +130 -0
  275. package/runtime/workflow/lib/contractInfoCandidates.ts +690 -0
  276. package/runtime/workflow/lib/create2.ts +278 -0
  277. package/runtime/workflow/lib/create2Hashes.ts +83 -0
  278. package/runtime/workflow/lib/deploymentInfo.ts +286 -0
  279. package/runtime/workflow/lib/deploymentRecords.ts +576 -0
  280. package/runtime/workflow/lib/deployments.ts +276 -0
  281. package/runtime/workflow/lib/erc1967.ts +57 -0
  282. package/runtime/workflow/lib/errors.ts +95 -0
  283. package/runtime/workflow/lib/executionId.ts +35 -0
  284. package/runtime/workflow/lib/executionPlan.ts +550 -0
  285. package/runtime/workflow/lib/executionProgress.ts +127 -0
  286. package/runtime/workflow/lib/external.ts +372 -0
  287. package/runtime/workflow/lib/externalExecutionScanner.ts +892 -0
  288. package/runtime/workflow/lib/forkSnapshot.ts +231 -0
  289. package/runtime/workflow/lib/gateTool.ts +261 -0
  290. package/runtime/workflow/lib/gateToolSync.ts +398 -0
  291. package/runtime/workflow/lib/lock.ts +388 -0
  292. package/runtime/workflow/lib/migrationState.ts +1246 -0
  293. package/runtime/workflow/lib/operatorExecution.ts +174 -0
  294. package/runtime/workflow/lib/parameters.ts +437 -0
  295. package/runtime/workflow/lib/pendingDeploymentReuse.ts +428 -0
  296. package/runtime/workflow/lib/proxy.ts +45 -0
  297. package/runtime/workflow/lib/registryCommit.ts +455 -0
  298. package/runtime/workflow/lib/release.ts +329 -0
  299. package/runtime/workflow/lib/releaseFinalize.ts +711 -0
  300. package/runtime/workflow/lib/releaseParameters.ts +248 -0
  301. package/runtime/workflow/lib/reporter.ts +502 -0
  302. package/runtime/workflow/lib/resultPaths.ts +49 -0
  303. package/runtime/workflow/lib/runtimeVersion.ts +28 -0
  304. package/runtime/workflow/lib/signer.ts +124 -0
  305. package/runtime/workflow/lib/signerIdentity.ts +22 -0
  306. package/runtime/workflow/lib/simulation.ts +415 -0
  307. package/runtime/workflow/lib/simulationCallers.ts +335 -0
  308. package/runtime/workflow/lib/sourceRpcPolicy.ts +41 -0
  309. package/runtime/workflow/lib/state.ts +25 -0
  310. package/runtime/workflow/lib/staticValidation.ts +142 -0
  311. package/runtime/workflow/lib/zksyncForkCapability.ts +80 -0
  312. package/runtime/workflow/lib/zksyncForkRunner.ts +505 -0
  313. package/runtime/workflow/reconcileExternal.ts +86 -0
  314. package/runtime/workflow/reconcileExternalRun.ts +88 -0
  315. package/runtime/workflow/releaseFinalize.ts +8 -0
  316. package/runtime/workflow/run.ts +1072 -0
  317. package/runtime/workflow/staticValidate.ts +23 -0
  318. package/runtime/workflow/steps/call.ts +10 -0
  319. package/runtime/workflow/steps/check.ts +10 -0
  320. package/runtime/workflow/steps/custom.ts +43 -0
  321. package/runtime/workflow/steps/deploy.ts +771 -0
  322. package/runtime/workflow/steps/upgrade.ts +598 -0
  323. package/runtime/workflow/steps/view.ts +10 -0
@@ -0,0 +1,174 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import type { ReleaseExecutionPlan } from "./executionPlan";
4
+
5
+ export interface OperatorExecutionReceipt {
6
+ transactionId: string;
7
+ transactionHash: string;
8
+ }
9
+
10
+ export interface OperatorExecutionResult {
11
+ version: 1;
12
+ taskId: string;
13
+ target: string;
14
+ executionId: string;
15
+ executionPlanHash: string;
16
+ receipts: OperatorExecutionReceipt[];
17
+ createdAt: string;
18
+ updatedAt: string;
19
+ }
20
+
21
+ const resultPath = (
22
+ taskDir: string,
23
+ target: string,
24
+ executionId: string,
25
+ ): string => path.join(
26
+ taskDir,
27
+ "results",
28
+ target,
29
+ executionId,
30
+ "operator-execution.json",
31
+ );
32
+
33
+ const validate = (
34
+ value: unknown,
35
+ plan: ReleaseExecutionPlan,
36
+ ): OperatorExecutionResult => {
37
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
38
+ throw new Error("operator execution result must be an object");
39
+ }
40
+ const result = value as Record<string, unknown>;
41
+ const expectedKeys = [
42
+ "version",
43
+ "taskId",
44
+ "target",
45
+ "executionId",
46
+ "executionPlanHash",
47
+ "receipts",
48
+ "createdAt",
49
+ "updatedAt",
50
+ ].sort();
51
+ if (JSON.stringify(Object.keys(result).sort()) !== JSON.stringify(expectedKeys)) {
52
+ throw new Error("operator execution result contains unsupported or missing fields");
53
+ }
54
+ if (
55
+ result.version !== 1
56
+ || result.taskId !== plan.taskId
57
+ || result.target !== plan.target
58
+ || result.executionId !== plan.executionId
59
+ || result.executionPlanHash !== plan.planHash
60
+ || !Array.isArray(result.receipts)
61
+ ) {
62
+ throw new Error("operator execution result identity does not match the execution plan");
63
+ }
64
+ const expectedTransactions = plan.transactions.filter((transaction) => (
65
+ transaction.route === "operator"
66
+ ));
67
+ if (result.receipts.length > expectedTransactions.length) {
68
+ throw new Error("operator execution result contains too many receipts");
69
+ }
70
+ const receipts = result.receipts.map((raw, index): OperatorExecutionReceipt => {
71
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
72
+ throw new Error(`operator receipt ${index} must be an object`);
73
+ }
74
+ const receipt = raw as Record<string, unknown>;
75
+ if (JSON.stringify(Object.keys(receipt).sort()) !== JSON.stringify([
76
+ "transactionHash",
77
+ "transactionId",
78
+ ])) {
79
+ throw new Error(`operator receipt ${index} contains unsupported fields`);
80
+ }
81
+ if (
82
+ receipt.transactionId !== expectedTransactions[index].transactionId
83
+ || typeof receipt.transactionHash !== "string"
84
+ || !/^0x[0-9a-fA-F]{64}$/.test(receipt.transactionHash)
85
+ ) {
86
+ throw new Error(`operator receipt ${index} does not match the execution plan`);
87
+ }
88
+ return {
89
+ transactionId: receipt.transactionId,
90
+ transactionHash: receipt.transactionHash.toLowerCase(),
91
+ };
92
+ });
93
+ if (typeof result.createdAt !== "string" || !Number.isFinite(Date.parse(result.createdAt))) {
94
+ throw new Error("operator execution result createdAt is invalid");
95
+ }
96
+ if (typeof result.updatedAt !== "string" || !Number.isFinite(Date.parse(result.updatedAt))) {
97
+ throw new Error("operator execution result updatedAt is invalid");
98
+ }
99
+ return {
100
+ version: 1,
101
+ taskId: plan.taskId,
102
+ target: plan.target,
103
+ executionId: plan.executionId,
104
+ executionPlanHash: plan.planHash,
105
+ receipts,
106
+ createdAt: result.createdAt,
107
+ updatedAt: result.updatedAt,
108
+ };
109
+ };
110
+
111
+ export const writeOperatorExecutionResult = (input: {
112
+ taskDir: string;
113
+ plan: ReleaseExecutionPlan;
114
+ receipts: OperatorExecutionReceipt[];
115
+ now?: () => string;
116
+ }): { filePath: string; result: OperatorExecutionResult } => {
117
+ const filePath = resultPath(input.taskDir, input.plan.target, input.plan.executionId);
118
+ const existing = fs.existsSync(filePath)
119
+ ? loadOperatorExecutionResult({ taskDir: input.taskDir, plan: input.plan })
120
+ : undefined;
121
+ const expectedTransactions = input.plan.transactions.filter((transaction) => (
122
+ transaction.route === "operator"
123
+ ));
124
+ const offset = existing?.receipts.length ?? 0;
125
+ for (const [index, receipt] of input.receipts.entries()) {
126
+ if (receipt.transactionId !== expectedTransactions[offset + index]?.transactionId) {
127
+ throw new Error("operator receipt does not match the next operator transaction");
128
+ }
129
+ }
130
+ if (offset + input.receipts.length > expectedTransactions.length) {
131
+ throw new Error("operator execution result contains too many receipts");
132
+ }
133
+ if (existing && input.receipts.length === 0) {
134
+ return { filePath, result: existing };
135
+ }
136
+ const now = (input.now || (() => new Date().toISOString()))();
137
+ const result = validate({
138
+ version: 1,
139
+ taskId: input.plan.taskId,
140
+ target: input.plan.target,
141
+ executionId: input.plan.executionId,
142
+ executionPlanHash: input.plan.planHash,
143
+ receipts: [...(existing?.receipts ?? []), ...input.receipts],
144
+ createdAt: existing?.createdAt ?? now,
145
+ updatedAt: now,
146
+ }, input.plan);
147
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
148
+ const serialized = JSON.stringify(result, null, 2) + "\n";
149
+ const temporary = `${filePath}.${process.pid}.${Date.now()}.tmp`;
150
+ try {
151
+ fs.writeFileSync(temporary, serialized, { flag: "wx", mode: 0o600 });
152
+ fs.renameSync(temporary, filePath);
153
+ } catch (error) {
154
+ if (fs.existsSync(temporary)) fs.unlinkSync(temporary);
155
+ throw error;
156
+ }
157
+ return { filePath, result };
158
+ };
159
+
160
+ export const loadOperatorExecutionResult = (input: {
161
+ taskDir: string;
162
+ plan: ReleaseExecutionPlan;
163
+ }): OperatorExecutionResult => {
164
+ const filePath = resultPath(input.taskDir, input.plan.target, input.plan.executionId);
165
+ let parsed: unknown;
166
+ try {
167
+ parsed = JSON.parse(fs.readFileSync(filePath, "utf8"));
168
+ } catch (error) {
169
+ throw new Error(
170
+ `Cannot load operator execution result: ${error instanceof Error ? error.message : String(error)}`,
171
+ );
172
+ }
173
+ return validate(parsed, input.plan);
174
+ };
@@ -0,0 +1,437 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import YAML from "yaml";
4
+ import { WorkflowState } from "./state";
5
+ import type { ParameterSchema } from "./releaseParameters";
6
+
7
+ export interface WorkflowManifest {
8
+ id: string;
9
+ description?: string;
10
+ steps: WorkflowStep[];
11
+ }
12
+
13
+ export interface WorkflowStep {
14
+ id: string;
15
+ kind: string;
16
+ [key: string]: unknown;
17
+ }
18
+
19
+ const SUPPORTED_STEP_KINDS = new Set([
20
+ "deploy",
21
+ "call",
22
+ "upgrade",
23
+ "view",
24
+ "check",
25
+ "custom",
26
+ ]);
27
+
28
+ export interface TaskParameters {
29
+ run?: {
30
+ targets?: string[];
31
+ };
32
+ params?: Record<string, Record<string, unknown>>;
33
+ }
34
+
35
+ export interface WorkflowTaskMetadata {
36
+ deploymentSignerAddress?: string;
37
+ releaseTargetNetworks?: string[];
38
+ [key: string]: unknown;
39
+ }
40
+
41
+ export type ExistingDeploymentPolicy =
42
+ | { mode: "reuse" }
43
+ | {
44
+ mode: "redeploy";
45
+ salt: string;
46
+ expectedAddress: string;
47
+ reason: string;
48
+ };
49
+
50
+ export type ExistingDeploymentPolicies = Record<string, ExistingDeploymentPolicy>;
51
+
52
+ export interface ResolveContext {
53
+ targetId: string;
54
+ target: Record<string, unknown>;
55
+ params: Record<string, unknown>;
56
+ state: WorkflowState;
57
+ }
58
+
59
+ export const readYamlFile = <T>(filePath: string): T => {
60
+ return YAML.parse(fs.readFileSync(filePath, "utf8")) as T;
61
+ };
62
+
63
+ export const validateWorkflowStepIds = (steps: WorkflowStep[]): void => {
64
+ const seen = new Set<string>();
65
+ for (const [index, step] of steps.entries()) {
66
+ const stepId = typeof step.id === "string" ? step.id.trim() : "";
67
+ if (!stepId) {
68
+ throw new Error(`Workflow step at index ${index} requires id`);
69
+ }
70
+ if (step.id !== stepId) {
71
+ throw new Error(`Workflow step id "${step.id}" must not contain surrounding whitespace`);
72
+ }
73
+ if (seen.has(stepId)) {
74
+ throw new Error(`Duplicate workflow step id "${stepId}"`);
75
+ }
76
+ seen.add(stepId);
77
+ }
78
+ };
79
+
80
+ export const validateDeploySaveAs = (steps: WorkflowStep[]): void => {
81
+ const seen = new Set<string>();
82
+
83
+ for (const step of steps) {
84
+ if (step.kind !== "deploy") continue;
85
+
86
+ const saveAs = typeof step.saveAs === "string" ? step.saveAs.trim() : "";
87
+ if (!saveAs) {
88
+ throw new Error(`Deploy step ${step.id} requires saveAs`);
89
+ }
90
+ if (saveAs.includes(":")) {
91
+ throw new Error(`Deploy step ${step.id} saveAs "${saveAs}" must not contain ":"`);
92
+ }
93
+ if (seen.has(saveAs)) {
94
+ throw new Error(`Duplicate deploy saveAs "${saveAs}"`);
95
+ }
96
+ seen.add(saveAs);
97
+ }
98
+ };
99
+
100
+ export const validateWorkflowStepKinds = (steps: WorkflowStep[]): void => {
101
+ for (const step of steps) {
102
+ if (!SUPPORTED_STEP_KINDS.has(step.kind)) {
103
+ throw new Error(`Unsupported workflow step kind "${step.kind}" in step ${step.id}`);
104
+ }
105
+ }
106
+ };
107
+
108
+ const asObject = (value: unknown): Record<string, unknown> => {
109
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
110
+ return {};
111
+ }
112
+ return value as Record<string, unknown>;
113
+ };
114
+
115
+ const assertPolicyFields = (
116
+ instanceId: string,
117
+ policy: Record<string, unknown>,
118
+ allowedFields: string[],
119
+ ): void => {
120
+ const allowed = new Set(allowedFields);
121
+ const unsupported = Object.keys(policy).filter((field) => !allowed.has(field));
122
+ if (unsupported.length > 0) {
123
+ throw new Error(
124
+ "existingDeploymentPolicies." + instanceId
125
+ + " has unsupported field(s): " + unsupported.join(", "),
126
+ );
127
+ }
128
+ };
129
+
130
+ export const validateExistingDeploymentPolicies = (
131
+ value: unknown,
132
+ ): ExistingDeploymentPolicies => {
133
+ if (value === undefined) return {};
134
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
135
+ throw new Error("existingDeploymentPolicies must be an object keyed by deploy saveAs");
136
+ }
137
+
138
+ const policies: ExistingDeploymentPolicies = {};
139
+ for (const [instanceId, policyValue] of Object.entries(value)) {
140
+ if (!instanceId.trim() || instanceId !== instanceId.trim() || instanceId.includes(":")) {
141
+ throw new Error("existingDeploymentPolicies key must be a deploy saveAs without colons");
142
+ }
143
+ const policy = asObject(policyValue);
144
+ if (policy.mode === "reuse") {
145
+ assertPolicyFields(instanceId, policy, ["mode"]);
146
+ policies[instanceId] = { mode: "reuse" };
147
+ continue;
148
+ }
149
+ if (policy.mode !== "redeploy") {
150
+ throw new Error(
151
+ "existingDeploymentPolicies." + instanceId + " mode must be reuse or redeploy",
152
+ );
153
+ }
154
+ assertPolicyFields(instanceId, policy, ["mode", "salt", "expectedAddress", "reason"]);
155
+ if (typeof policy.salt !== "string" || !/^0x[0-9a-fA-F]{64}$/.test(policy.salt)) {
156
+ throw new Error(
157
+ "existingDeploymentPolicies." + instanceId + " redeploy salt must be bytes32",
158
+ );
159
+ }
160
+ if (
161
+ typeof policy.expectedAddress !== "string"
162
+ || !/^0x[0-9a-fA-F]{40}$/.test(policy.expectedAddress)
163
+ ) {
164
+ throw new Error(
165
+ "existingDeploymentPolicies." + instanceId + " redeploy expectedAddress must be an EVM address",
166
+ );
167
+ }
168
+ if (typeof policy.reason !== "string" || !policy.reason.trim()) {
169
+ throw new Error(
170
+ "existingDeploymentPolicies." + instanceId + " redeploy reason must be non-empty",
171
+ );
172
+ }
173
+ policies[instanceId] = {
174
+ mode: "redeploy",
175
+ salt: policy.salt,
176
+ expectedAddress: policy.expectedAddress,
177
+ reason: policy.reason.trim(),
178
+ };
179
+ }
180
+ return policies;
181
+ };
182
+
183
+ export const assertExistingDeploymentPoliciesMatchTarget = (
184
+ policies: ExistingDeploymentPolicies,
185
+ targetId: string,
186
+ existingInstanceIds: string[],
187
+ ): void => {
188
+ const existing = new Set(existingInstanceIds);
189
+ for (const instanceId of Object.keys(policies)) {
190
+ if (!existing.has(instanceId)) {
191
+ throw new Error(
192
+ `Unknown deployment policy instance for target ${targetId}: ${instanceId}`,
193
+ );
194
+ }
195
+ }
196
+ };
197
+
198
+ export const requireExistingDeploymentPolicy = (
199
+ policies: ExistingDeploymentPolicies,
200
+ instanceId: string,
201
+ ): ExistingDeploymentPolicy => {
202
+ const policy = policies[instanceId];
203
+ if (!policy) {
204
+ throw new Error(
205
+ "Existing deployment " + instanceId + " requires an explicit reuse or redeploy policy",
206
+ );
207
+ }
208
+ return policy;
209
+ };
210
+
211
+ export const resolveExistingDeploymentPolicyAction = (
212
+ policy: ExistingDeploymentPolicy,
213
+ context: {
214
+ instanceId: string;
215
+ existingAddress: string;
216
+ currentSalt: string;
217
+ upgradeable: boolean;
218
+ },
219
+ ): ExistingDeploymentPolicy => {
220
+ if (policy.mode === "reuse") return policy;
221
+ if (context.upgradeable) {
222
+ throw new Error(
223
+ "cannot redeploy UUPS proxy " + context.instanceId + "; use an upgrade step",
224
+ );
225
+ }
226
+ if (policy.salt.toLowerCase() === context.currentSalt.toLowerCase()) {
227
+ throw new Error("redeploy " + context.instanceId + " requires a new CREATE2 salt");
228
+ }
229
+ if (policy.expectedAddress.toLowerCase() === context.existingAddress.toLowerCase()) {
230
+ throw new Error(
231
+ "redeploy " + context.instanceId + " expectedAddress must differ from the existing address",
232
+ );
233
+ }
234
+ return policy;
235
+ };
236
+
237
+ const requireStringField = (
238
+ source: Record<string, unknown>,
239
+ key: string,
240
+ message: string,
241
+ ): string => {
242
+ const value = source[key];
243
+ if (typeof value !== "string" || !value.trim()) {
244
+ throw new Error(message);
245
+ }
246
+ return value.trim();
247
+ };
248
+
249
+ export const validateDeployCreate2Strategy = (steps: WorkflowStep[]): void => {
250
+ for (const step of steps) {
251
+ if (step.kind !== "deploy") continue;
252
+
253
+ if (step.strategy !== "create2") {
254
+ throw new Error(`Deploy step ${step.id} requires strategy: create2`);
255
+ }
256
+
257
+ const create2 = asObject(step.create2);
258
+ requireStringField(create2, "salt", `Deploy step ${step.id} requires create2.salt`);
259
+ if ("implSalt" in create2) {
260
+ throw new Error(
261
+ `Deploy step ${step.id} does not support create2.implSalt; UUPS placeholder CREATE2 options are managed by the workflow runtime`,
262
+ );
263
+ }
264
+
265
+ if (step.proxy !== undefined) {
266
+ if (step.upgradeableStrategy !== "uups-placeholder-proxy") {
267
+ throw new Error(`Deploy step ${step.id} requires upgradeableStrategy: uups-placeholder-proxy`);
268
+ }
269
+ if (String(step.contract) !== "contracts/workflow/UUPSPlaceholder.sol:UUPSPlaceholder") {
270
+ throw new Error(
271
+ `Deploy step ${step.id} must create UUPS proxies with contracts/workflow/UUPSPlaceholder.sol:UUPSPlaceholder`,
272
+ );
273
+ }
274
+ if (!asObject(step.firstUpgrade).contract) {
275
+ throw new Error(`Deploy step ${step.id} requires firstUpgrade.contract`);
276
+ }
277
+ }
278
+ }
279
+ };
280
+
281
+ export const loadManifest = (taskDir: string): WorkflowManifest => {
282
+ const manifest = readYamlFile<WorkflowManifest>(path.join(taskDir, "manifest.yaml"));
283
+ if (!manifest.steps || !Array.isArray(manifest.steps)) {
284
+ throw new Error("manifest.yaml must define a steps array");
285
+ }
286
+ validateWorkflowStepIds(manifest.steps);
287
+ validateWorkflowStepKinds(manifest.steps);
288
+ validateDeploySaveAs(manifest.steps);
289
+ validateDeployCreate2Strategy(manifest.steps);
290
+ return manifest;
291
+ };
292
+
293
+ export const loadParameters = (taskDir: string): TaskParameters => {
294
+ return readYamlFile<TaskParameters>(path.join(taskDir, "parameters.yaml"));
295
+ };
296
+
297
+ const isNonZeroEvmAddress = (value: string): boolean => {
298
+ return /^0x[0-9a-fA-F]{40}$/.test(value)
299
+ && value.toLowerCase() !== "0x0000000000000000000000000000000000000000";
300
+ };
301
+
302
+ const SAFE_RELEASE_TARGET_NETWORK = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
303
+ const UNSAFE_RELEASE_TARGET_NETWORKS = new Set(["__proto__", "prototype", "constructor"]);
304
+
305
+ const validateReleaseTargetNetworks = (value: unknown): string[] | undefined => {
306
+ if (value === undefined) return undefined;
307
+ if (!Array.isArray(value)) {
308
+ throw new Error("task.yaml releaseTargetNetworks must be an array of safe network ids");
309
+ }
310
+ const networks = value.map((network, index) => {
311
+ if (
312
+ typeof network !== "string"
313
+ || !network
314
+ || network !== network.trim()
315
+ || !SAFE_RELEASE_TARGET_NETWORK.test(network)
316
+ || UNSAFE_RELEASE_TARGET_NETWORKS.has(network)
317
+ ) {
318
+ throw new Error(
319
+ `task.yaml releaseTargetNetworks[${index}] must be a safe non-empty network id`,
320
+ );
321
+ }
322
+ return network;
323
+ });
324
+ if (new Set(networks).size !== networks.length) {
325
+ throw new Error("task.yaml releaseTargetNetworks must not contain duplicates");
326
+ }
327
+ return networks;
328
+ };
329
+
330
+ export const loadTaskMetadata = (taskDir: string): WorkflowTaskMetadata => {
331
+ const metadata = readYamlFile<WorkflowTaskMetadata>(path.join(taskDir, "task.yaml"));
332
+ const signer = metadata.deploymentSignerAddress;
333
+ if (signer !== undefined && (typeof signer !== "string" || !isNonZeroEvmAddress(signer.trim()))) {
334
+ throw new Error(
335
+ "task.yaml deploymentSignerAddress must be a valid non-zero EVM address",
336
+ );
337
+ }
338
+ const releaseTargetNetworks = validateReleaseTargetNetworks(metadata.releaseTargetNetworks);
339
+ return {
340
+ ...metadata,
341
+ ...(signer === undefined ? {} : { deploymentSignerAddress: signer.trim() }),
342
+ ...(releaseTargetNetworks === undefined ? {} : { releaseTargetNetworks }),
343
+ };
344
+ };
345
+
346
+ export const loadParameterSchema = (taskDir: string): ParameterSchema => {
347
+ const filePath = path.join(taskDir, "parameters.schema.json");
348
+ if (!fs.existsSync(filePath)) {
349
+ throw new Error("Missing parameters.schema.json for release execution");
350
+ }
351
+
352
+ let schema: unknown;
353
+ try {
354
+ schema = JSON.parse(fs.readFileSync(filePath, "utf8"));
355
+ } catch (error) {
356
+ throw new Error(
357
+ "parameters.schema.json must contain valid JSON: "
358
+ + (error instanceof Error ? error.message : String(error)),
359
+ );
360
+ }
361
+ if (!schema || typeof schema !== "object" || Array.isArray(schema)) {
362
+ throw new Error("parameters.schema.json must be an object");
363
+ }
364
+ return schema as ParameterSchema;
365
+ };
366
+
367
+ export const targetParams = (
368
+ parameters: TaskParameters,
369
+ targetId: string,
370
+ ): Record<string, unknown> => {
371
+ const allParams = parameters.params || {};
372
+ const globalParams = allParams.global || {};
373
+ const networkParams = allParams[targetId];
374
+ if (!networkParams) {
375
+ throw new Error(`Missing parameters for target "${targetId}"`);
376
+ }
377
+ return {
378
+ ...networkParams,
379
+ global: globalParams,
380
+ };
381
+ };
382
+
383
+ const readPath = (source: Record<string, unknown>, pathExpression: string): unknown => {
384
+ const parts = pathExpression.split(".");
385
+ let current: unknown = source;
386
+
387
+ for (const part of parts) {
388
+ if (typeof current !== "object" || current === null || !(part in current)) {
389
+ throw new Error(`Reference not found: ${pathExpression}`);
390
+ }
391
+ current = (current as Record<string, unknown>)[part];
392
+ }
393
+
394
+ return current;
395
+ };
396
+
397
+ export const resolveValue = (value: unknown, context: ResolveContext): unknown => {
398
+ if (typeof value === "string") {
399
+ if (value.startsWith("$param.")) {
400
+ return readPath(context.params, value.slice("$param.".length));
401
+ }
402
+ if (value.startsWith("$target.")) {
403
+ return readPath(context.target, value.slice("$target.".length));
404
+ }
405
+ return value;
406
+ }
407
+
408
+ if (Array.isArray(value)) {
409
+ return value.map((item) => resolveValue(item, context));
410
+ }
411
+
412
+ if (typeof value === "object" && value !== null) {
413
+ const objectValue = value as Record<string, unknown>;
414
+ if (typeof objectValue.$ref === "string") {
415
+ const ref = objectValue.$ref;
416
+ if (ref.startsWith("state.")) {
417
+ return context.state.get(ref.slice("state.".length));
418
+ }
419
+ if (ref.startsWith("target.")) {
420
+ return readPath(context.target, ref.slice("target.".length));
421
+ }
422
+ if (ref.startsWith("param.")) {
423
+ return readPath(context.params, ref.slice("param.".length));
424
+ }
425
+ throw new Error(`Unsupported reference: ${ref}`);
426
+ }
427
+
428
+ return Object.fromEntries(
429
+ Object.entries(objectValue).map(([key, nestedValue]) => [
430
+ key,
431
+ resolveValue(nestedValue, context),
432
+ ]),
433
+ );
434
+ }
435
+
436
+ return value;
437
+ };