gate-evm-tools 1.0.27 → 1.0.31

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 (641) hide show
  1. package/README.md +16 -1
  2. package/bin/cli.js +3 -0
  3. package/bin/delivery.cjs +51 -0
  4. package/bin/manifest-bootstrap.js +4 -15
  5. package/bin/workflow.cjs +1 -1
  6. package/dist/commands/plan/file-store.d.ts.map +1 -0
  7. package/dist/commands/plan/generate-deployment.d.ts +48 -0
  8. package/dist/commands/plan/generate-deployment.d.ts.map +1 -0
  9. package/dist/commands/plan/generate-deployment.js +211 -0
  10. package/dist/commands/plan/generate-deployment.js.map +1 -0
  11. package/dist/commands/plan/helpers.d.ts.map +1 -0
  12. package/dist/commands/plan/index.d.ts +3 -0
  13. package/dist/commands/plan/index.d.ts.map +1 -0
  14. package/dist/commands/plan/index.js +88 -0
  15. package/dist/commands/plan/index.js.map +1 -0
  16. package/dist/commands/sync.js +1 -1
  17. package/dist/commands/sync.js.map +1 -1
  18. package/dist/core/BytecodeChecker.d.ts.map +1 -1
  19. package/dist/core/BytecodeChecker.js +27 -8
  20. package/dist/core/BytecodeChecker.js.map +1 -1
  21. package/dist/core/preparation/artifacts.d.ts +2 -0
  22. package/dist/core/preparation/artifacts.d.ts.map +1 -1
  23. package/dist/core/preparation/artifacts.js +9 -3
  24. package/dist/core/preparation/artifacts.js.map +1 -1
  25. package/dist/core/preparation/evm.d.ts +38 -2
  26. package/dist/core/preparation/evm.d.ts.map +1 -1
  27. package/dist/core/preparation/evm.js +104 -32
  28. package/dist/core/preparation/evm.js.map +1 -1
  29. package/dist/core/preparation/evmManifestSync.d.ts +63 -0
  30. package/dist/core/preparation/evmManifestSync.d.ts.map +1 -0
  31. package/dist/core/preparation/evmManifestSync.js +146 -0
  32. package/dist/core/preparation/evmManifestSync.js.map +1 -0
  33. package/dist/core/preparation/index.d.ts +40 -2
  34. package/dist/core/preparation/index.d.ts.map +1 -1
  35. package/dist/core/preparation/index.js +3 -3
  36. package/dist/core/preparation/index.js.map +1 -1
  37. package/dist/core/preparation/manifest.d.ts +15 -3
  38. package/dist/core/preparation/manifest.d.ts.map +1 -1
  39. package/dist/core/preparation/manifest.js +21 -26
  40. package/dist/core/preparation/manifest.js.map +1 -1
  41. package/dist/core/preparation/normalize.d.ts.map +1 -1
  42. package/dist/core/preparation/normalize.js +14 -9
  43. package/dist/core/preparation/normalize.js.map +1 -1
  44. package/dist/core/preparation/types.d.ts +7 -2
  45. package/dist/core/preparation/types.d.ts.map +1 -1
  46. package/dist/custody/hardhat-runtime.d.ts.map +1 -1
  47. package/dist/custody/hardhat-runtime.js +2 -0
  48. package/dist/custody/hardhat-runtime.js.map +1 -1
  49. package/dist/custody/hardhat.d.ts +1 -0
  50. package/dist/custody/hardhat.d.ts.map +1 -1
  51. package/dist/custody/hardhat.js +1 -0
  52. package/dist/custody/hardhat.js.map +1 -1
  53. package/dist/custody/index.d.ts +1 -0
  54. package/dist/custody/index.d.ts.map +1 -1
  55. package/dist/custody/index.js +1 -0
  56. package/dist/custody/index.js.map +1 -1
  57. package/dist/custody/provider-wait.d.ts +13 -0
  58. package/dist/custody/provider-wait.d.ts.map +1 -0
  59. package/dist/custody/provider-wait.js +78 -0
  60. package/dist/custody/provider-wait.js.map +1 -0
  61. package/dist/delivery/policy.d.ts +6 -0
  62. package/dist/delivery/policy.d.ts.map +1 -0
  63. package/dist/delivery/policy.js +24 -0
  64. package/dist/delivery/policy.js.map +1 -0
  65. package/dist/index.d.ts.map +1 -1
  66. package/dist/index.js +5 -0
  67. package/dist/index.js.map +1 -1
  68. package/dist/sync/index.d.ts +15 -0
  69. package/dist/sync/index.d.ts.map +1 -1
  70. package/dist/sync/index.js +8 -0
  71. package/dist/sync/index.js.map +1 -1
  72. package/dist/workflow/index.d.ts +6 -1
  73. package/dist/workflow/index.d.ts.map +1 -1
  74. package/dist/workflow/index.js +4 -0
  75. package/dist/workflow/index.js.map +1 -1
  76. package/dist-cjs/core/BytecodeChecker.js +526 -0
  77. package/dist-cjs/core/BytecodeChecker.js.map +1 -0
  78. package/dist-cjs/core/legacyProxyArtifact.js +42 -0
  79. package/dist-cjs/core/legacyProxyArtifact.js.map +1 -0
  80. package/dist-cjs/core/preparation/artifacts.js +11 -4
  81. package/dist-cjs/core/preparation/artifacts.js.map +1 -1
  82. package/dist-cjs/core/preparation/evm.js +105 -32
  83. package/dist-cjs/core/preparation/evm.js.map +1 -1
  84. package/dist-cjs/core/preparation/evmManifestSync.js +155 -0
  85. package/dist-cjs/core/preparation/evmManifestSync.js.map +1 -0
  86. package/dist-cjs/core/preparation/index.js +3 -3
  87. package/dist-cjs/core/preparation/index.js.map +1 -1
  88. package/dist-cjs/core/preparation/manifest.js +23 -28
  89. package/dist-cjs/core/preparation/manifest.js.map +1 -1
  90. package/dist-cjs/core/preparation/normalize.js +14 -9
  91. package/dist-cjs/core/preparation/normalize.js.map +1 -1
  92. package/dist-cjs/custody/hardhat-runtime.js +2 -0
  93. package/dist-cjs/custody/hardhat-runtime.js.map +1 -1
  94. package/dist-cjs/custody/hardhat.js +3 -1
  95. package/dist-cjs/custody/hardhat.js.map +1 -1
  96. package/dist-cjs/custody/index.js +3 -1
  97. package/dist-cjs/custody/index.js.map +1 -1
  98. package/dist-cjs/custody/provider-wait.js +81 -0
  99. package/dist-cjs/custody/provider-wait.js.map +1 -0
  100. package/dist-cjs/delivery/policy.js +29 -0
  101. package/dist-cjs/delivery/policy.js.map +1 -0
  102. package/dist-cjs/sync/index.js +8 -0
  103. package/dist-cjs/sync/index.js.map +1 -1
  104. package/dist-cjs/workflow/index.js +12 -1
  105. package/dist-cjs/workflow/index.js.map +1 -1
  106. package/dist-runtime/config/hardhatAdapters.d.ts +2 -0
  107. package/dist-runtime/config/hardhatAdapters.js +8 -0
  108. package/dist-runtime/config/hardhatAdapters.js.map +1 -1
  109. package/dist-runtime/config/networks.d.ts +25 -1
  110. package/dist-runtime/config/networks.js +8 -2
  111. package/dist-runtime/config/networks.js.map +1 -1
  112. package/dist-runtime/config/openzeppelin.d.ts +2 -1
  113. package/dist-runtime/config/openzeppelin.js +2 -19
  114. package/dist-runtime/config/openzeppelin.js.map +1 -1
  115. package/dist-runtime/delivery/abi.d.ts +14 -0
  116. package/dist-runtime/delivery/abi.js +161 -0
  117. package/dist-runtime/delivery/abi.js.map +1 -0
  118. package/dist-runtime/delivery/aggregate-bootstrap.d.ts +12 -0
  119. package/dist-runtime/delivery/aggregate-bootstrap.js +40 -0
  120. package/dist-runtime/delivery/aggregate-bootstrap.js.map +1 -0
  121. package/dist-runtime/delivery/aggregate-channel.d.ts +28 -0
  122. package/dist-runtime/delivery/aggregate-channel.js +155 -0
  123. package/dist-runtime/delivery/aggregate-channel.js.map +1 -0
  124. package/dist-runtime/delivery/aggregate-inputs.d.ts +168 -0
  125. package/dist-runtime/delivery/aggregate-inputs.js +57 -0
  126. package/dist-runtime/delivery/aggregate-inputs.js.map +1 -0
  127. package/dist-runtime/delivery/aggregate-source.d.ts +25 -0
  128. package/dist-runtime/delivery/aggregate-source.js +79 -0
  129. package/dist-runtime/delivery/aggregate-source.js.map +1 -0
  130. package/dist-runtime/delivery/aggregate-worker.d.ts +1 -0
  131. package/dist-runtime/delivery/aggregate-worker.js +191 -0
  132. package/dist-runtime/delivery/aggregate-worker.js.map +1 -0
  133. package/dist-runtime/delivery/aggregate.d.ts +51 -0
  134. package/dist-runtime/delivery/aggregate.js +190 -0
  135. package/dist-runtime/delivery/aggregate.js.map +1 -0
  136. package/dist-runtime/delivery/bindings.d.ts +21 -0
  137. package/dist-runtime/delivery/bindings.js +53 -0
  138. package/dist-runtime/delivery/bindings.js.map +1 -0
  139. package/dist-runtime/delivery/check-code.d.ts +19 -0
  140. package/dist-runtime/delivery/check-code.js +63 -0
  141. package/dist-runtime/delivery/check-code.js.map +1 -0
  142. package/dist-runtime/delivery/closure-format.d.ts +77 -0
  143. package/dist-runtime/delivery/closure-format.js +225 -0
  144. package/dist-runtime/delivery/closure-format.js.map +1 -0
  145. package/dist-runtime/delivery/codec-pin.d.ts +2 -0
  146. package/dist-runtime/delivery/codec-pin.js +7 -0
  147. package/dist-runtime/delivery/codec-pin.js.map +1 -0
  148. package/dist-runtime/delivery/codec.d.ts +19 -0
  149. package/dist-runtime/delivery/codec.js +73 -0
  150. package/dist-runtime/delivery/codec.js.map +1 -0
  151. package/dist-runtime/delivery/compiler-dependency-pins.d.ts +7 -0
  152. package/dist-runtime/delivery/compiler-dependency-pins.js +1689 -0
  153. package/dist-runtime/delivery/compiler-dependency-pins.js.map +1 -0
  154. package/dist-runtime/delivery/compiler-files.d.ts +40 -0
  155. package/dist-runtime/delivery/compiler-files.js +220 -0
  156. package/dist-runtime/delivery/compiler-files.js.map +1 -0
  157. package/dist-runtime/delivery/compiler-io.d.ts +2 -0
  158. package/dist-runtime/delivery/compiler-io.js +13 -0
  159. package/dist-runtime/delivery/compiler-io.js.map +1 -0
  160. package/dist-runtime/delivery/compiler-pins.d.ts +10 -0
  161. package/dist-runtime/delivery/compiler-pins.js +147 -0
  162. package/dist-runtime/delivery/compiler-pins.js.map +1 -0
  163. package/dist-runtime/delivery/compiler.d.ts +188 -0
  164. package/dist-runtime/delivery/compiler.js +850 -0
  165. package/dist-runtime/delivery/compiler.js.map +1 -0
  166. package/dist-runtime/delivery/config.d.ts +48 -0
  167. package/dist-runtime/delivery/config.js +99 -0
  168. package/dist-runtime/delivery/config.js.map +1 -0
  169. package/dist-runtime/delivery/configuration-definition.d.ts +22 -0
  170. package/dist-runtime/delivery/configuration-definition.js +316 -0
  171. package/dist-runtime/delivery/configuration-definition.js.map +1 -0
  172. package/dist-runtime/delivery/configuration-hre.d.ts +17 -0
  173. package/dist-runtime/delivery/configuration-hre.js +198 -0
  174. package/dist-runtime/delivery/configuration-hre.js.map +1 -0
  175. package/dist-runtime/delivery/configuration-runtime.d.ts +36 -0
  176. package/dist-runtime/delivery/configuration-runtime.js +248 -0
  177. package/dist-runtime/delivery/configuration-runtime.js.map +1 -0
  178. package/dist-runtime/delivery/configuration.d.ts +35 -0
  179. package/dist-runtime/delivery/configuration.js +83 -0
  180. package/dist-runtime/delivery/configuration.js.map +1 -0
  181. package/dist-runtime/delivery/create2.d.ts +3 -0
  182. package/dist-runtime/delivery/create2.js +48 -0
  183. package/dist-runtime/delivery/create2.js.map +1 -0
  184. package/dist-runtime/delivery/custom-closure.d.ts +27 -0
  185. package/dist-runtime/delivery/custom-closure.js +818 -0
  186. package/dist-runtime/delivery/custom-closure.js.map +1 -0
  187. package/dist-runtime/delivery/custom-format.d.ts +35 -0
  188. package/dist-runtime/delivery/custom-format.js +383 -0
  189. package/dist-runtime/delivery/custom-format.js.map +1 -0
  190. package/dist-runtime/delivery/custom.d.ts +32 -0
  191. package/dist-runtime/delivery/custom.js +158 -0
  192. package/dist-runtime/delivery/custom.js.map +1 -0
  193. package/dist-runtime/delivery/data.d.ts +7 -0
  194. package/dist-runtime/delivery/data.js +86 -0
  195. package/dist-runtime/delivery/data.js.map +1 -0
  196. package/dist-runtime/delivery/development.d.ts +91 -0
  197. package/dist-runtime/delivery/development.js +395 -0
  198. package/dist-runtime/delivery/development.js.map +1 -0
  199. package/dist-runtime/delivery/engine.d.ts +9 -0
  200. package/dist-runtime/delivery/engine.js +23 -0
  201. package/dist-runtime/delivery/engine.js.map +1 -0
  202. package/dist-runtime/delivery/eoa-observation.d.ts +43 -0
  203. package/dist-runtime/delivery/eoa-observation.js +145 -0
  204. package/dist-runtime/delivery/eoa-observation.js.map +1 -0
  205. package/dist-runtime/delivery/eoa-signed.d.ts +2 -0
  206. package/dist-runtime/delivery/eoa-signed.js +74 -0
  207. package/dist-runtime/delivery/eoa-signed.js.map +1 -0
  208. package/dist-runtime/delivery/eoa.d.ts +81 -0
  209. package/dist-runtime/delivery/eoa.js +274 -0
  210. package/dist-runtime/delivery/eoa.js.map +1 -0
  211. package/dist-runtime/delivery/execution-db.d.ts +20 -0
  212. package/dist-runtime/delivery/execution-db.js +153 -0
  213. package/dist-runtime/delivery/execution-db.js.map +1 -0
  214. package/dist-runtime/delivery/execution-files.d.ts +9 -0
  215. package/dist-runtime/delivery/execution-files.js +138 -0
  216. package/dist-runtime/delivery/execution-files.js.map +1 -0
  217. package/dist-runtime/delivery/execution-model.d.ts +56 -0
  218. package/dist-runtime/delivery/execution-model.js +66 -0
  219. package/dist-runtime/delivery/execution-model.js.map +1 -0
  220. package/dist-runtime/delivery/execution-store.d.ts +48 -0
  221. package/dist-runtime/delivery/execution-store.js +361 -0
  222. package/dist-runtime/delivery/execution-store.js.map +1 -0
  223. package/dist-runtime/delivery/existing-code.d.ts +37 -0
  224. package/dist-runtime/delivery/existing-code.js +75 -0
  225. package/dist-runtime/delivery/existing-code.js.map +1 -0
  226. package/dist-runtime/delivery/export.d.ts +51 -0
  227. package/dist-runtime/delivery/export.js +69 -0
  228. package/dist-runtime/delivery/export.js.map +1 -0
  229. package/dist-runtime/delivery/forkAudit.d.ts +119 -0
  230. package/dist-runtime/delivery/forkAudit.js +473 -0
  231. package/dist-runtime/delivery/forkAudit.js.map +1 -0
  232. package/dist-runtime/delivery/hardhat.d.ts +3 -0
  233. package/dist-runtime/delivery/hardhat.js +45 -0
  234. package/dist-runtime/delivery/hardhat.js.map +1 -0
  235. package/dist-runtime/delivery/history-registration.d.ts +2 -0
  236. package/dist-runtime/delivery/history-registration.js +17 -0
  237. package/dist-runtime/delivery/history-registration.js.map +1 -0
  238. package/dist-runtime/delivery/identities.d.ts +22 -0
  239. package/dist-runtime/delivery/identities.js +97 -0
  240. package/dist-runtime/delivery/identities.js.map +1 -0
  241. package/dist-runtime/delivery/input-files.d.ts +5 -0
  242. package/dist-runtime/delivery/input-files.js +70 -0
  243. package/dist-runtime/delivery/input-files.js.map +1 -0
  244. package/dist-runtime/delivery/inputs.d.ts +62 -0
  245. package/dist-runtime/delivery/inputs.js +187 -0
  246. package/dist-runtime/delivery/inputs.js.map +1 -0
  247. package/dist-runtime/delivery/journal.d.ts +35 -0
  248. package/dist-runtime/delivery/journal.js +270 -0
  249. package/dist-runtime/delivery/journal.js.map +1 -0
  250. package/dist-runtime/delivery/manifest.d.ts +14 -0
  251. package/dist-runtime/delivery/manifest.js +68 -0
  252. package/dist-runtime/delivery/manifest.js.map +1 -0
  253. package/dist-runtime/delivery/materialization.d.ts +20 -0
  254. package/dist-runtime/delivery/materialization.js +138 -0
  255. package/dist-runtime/delivery/materialization.js.map +1 -0
  256. package/dist-runtime/delivery/observations.d.ts +31 -0
  257. package/dist-runtime/delivery/observations.js +38 -0
  258. package/dist-runtime/delivery/observations.js.map +1 -0
  259. package/dist-runtime/delivery/parameters.d.ts +53 -0
  260. package/dist-runtime/delivery/parameters.js +257 -0
  261. package/dist-runtime/delivery/parameters.js.map +1 -0
  262. package/dist-runtime/delivery/pending.d.ts +70 -0
  263. package/dist-runtime/delivery/pending.js +99 -0
  264. package/dist-runtime/delivery/pending.js.map +1 -0
  265. package/dist-runtime/delivery/plan.d.ts +50 -0
  266. package/dist-runtime/delivery/plan.js +209 -0
  267. package/dist-runtime/delivery/plan.js.map +1 -0
  268. package/dist-runtime/delivery/planning.d.ts +81 -0
  269. package/dist-runtime/delivery/planning.js +302 -0
  270. package/dist-runtime/delivery/planning.js.map +1 -0
  271. package/dist-runtime/delivery/policy.d.ts +4 -0
  272. package/dist-runtime/delivery/policy.js +9 -0
  273. package/dist-runtime/delivery/policy.js.map +1 -0
  274. package/dist-runtime/delivery/preparation.d.ts +6 -0
  275. package/dist-runtime/delivery/preparation.js +158 -0
  276. package/dist-runtime/delivery/preparation.js.map +1 -0
  277. package/dist-runtime/delivery/production-environment.d.ts +2 -0
  278. package/dist-runtime/delivery/production-environment.js +12 -0
  279. package/dist-runtime/delivery/production-environment.js.map +1 -0
  280. package/dist-runtime/delivery/production-finalization.d.ts +86 -0
  281. package/dist-runtime/delivery/production-finalization.js +278 -0
  282. package/dist-runtime/delivery/production-finalization.js.map +1 -0
  283. package/dist-runtime/delivery/production.d.ts +461 -0
  284. package/dist-runtime/delivery/production.js +396 -0
  285. package/dist-runtime/delivery/production.js.map +1 -0
  286. package/dist-runtime/delivery/project-files.d.ts +8 -0
  287. package/dist-runtime/delivery/project-files.js +82 -0
  288. package/dist-runtime/delivery/project-files.js.map +1 -0
  289. package/dist-runtime/delivery/project.d.ts +15 -0
  290. package/dist-runtime/delivery/project.js +157 -0
  291. package/dist-runtime/delivery/project.js.map +1 -0
  292. package/dist-runtime/delivery/protocol.d.ts +49 -0
  293. package/dist-runtime/delivery/protocol.js +112 -0
  294. package/dist-runtime/delivery/protocol.js.map +1 -0
  295. package/dist-runtime/delivery/references.d.ts +19 -0
  296. package/dist-runtime/delivery/references.js +84 -0
  297. package/dist-runtime/delivery/references.js.map +1 -0
  298. package/dist-runtime/delivery/release-graph.d.ts +93 -0
  299. package/dist-runtime/delivery/release-graph.js +106 -0
  300. package/dist-runtime/delivery/release-graph.js.map +1 -0
  301. package/dist-runtime/delivery/release-history-capture.d.ts +7 -0
  302. package/dist-runtime/delivery/release-history-capture.js +76 -0
  303. package/dist-runtime/delivery/release-history-capture.js.map +1 -0
  304. package/dist-runtime/delivery/release-history.d.ts +43 -0
  305. package/dist-runtime/delivery/release-history.js +246 -0
  306. package/dist-runtime/delivery/release-history.js.map +1 -0
  307. package/dist-runtime/delivery/release.d.ts +172 -0
  308. package/dist-runtime/delivery/release.js +209 -0
  309. package/dist-runtime/delivery/release.js.map +1 -0
  310. package/dist-runtime/delivery/safe-manifest.d.ts +9 -0
  311. package/dist-runtime/delivery/safe-manifest.js +13 -0
  312. package/dist-runtime/delivery/safe-manifest.js.map +1 -0
  313. package/dist-runtime/delivery/safe-observation.d.ts +30 -0
  314. package/dist-runtime/delivery/safe-observation.js +487 -0
  315. package/dist-runtime/delivery/safe-observation.js.map +1 -0
  316. package/dist-runtime/delivery/safe-prepare.d.ts +13 -0
  317. package/dist-runtime/delivery/safe-prepare.js +81 -0
  318. package/dist-runtime/delivery/safe-prepare.js.map +1 -0
  319. package/dist-runtime/delivery/safe.d.ts +91 -0
  320. package/dist-runtime/delivery/safe.js +243 -0
  321. package/dist-runtime/delivery/safe.js.map +1 -0
  322. package/dist-runtime/delivery/same-fork-baseline.d.ts +8 -0
  323. package/dist-runtime/delivery/same-fork-baseline.js +20 -0
  324. package/dist-runtime/delivery/same-fork-baseline.js.map +1 -0
  325. package/dist-runtime/delivery/setup.d.ts +31 -0
  326. package/dist-runtime/delivery/setup.js +215 -0
  327. package/dist-runtime/delivery/setup.js.map +1 -0
  328. package/dist-runtime/delivery/source.d.ts +41 -0
  329. package/dist-runtime/delivery/source.js +137 -0
  330. package/dist-runtime/delivery/source.js.map +1 -0
  331. package/dist-runtime/delivery/target-fields.d.ts +2 -0
  332. package/dist-runtime/delivery/target-fields.js +11 -0
  333. package/dist-runtime/delivery/target-fields.js.map +1 -0
  334. package/dist-runtime/delivery/validation.d.ts +9 -0
  335. package/dist-runtime/delivery/validation.js +150 -0
  336. package/dist-runtime/delivery/validation.js.map +1 -0
  337. package/dist-runtime/delivery/verification.d.ts +16 -0
  338. package/dist-runtime/delivery/verification.js +65 -0
  339. package/dist-runtime/delivery/verification.js.map +1 -0
  340. package/dist-runtime/migrate.js +1 -0
  341. package/dist-runtime/migrate.js.map +1 -1
  342. package/dist-runtime/miner/binary.d.ts +2 -0
  343. package/dist-runtime/miner/binary.js +54 -0
  344. package/dist-runtime/miner/binary.js.map +1 -0
  345. package/dist-runtime/miner/cli.d.ts +1 -0
  346. package/dist-runtime/miner/cli.js +131 -0
  347. package/dist-runtime/miner/cli.js.map +1 -0
  348. package/dist-runtime/miner/index.d.ts +5 -0
  349. package/dist-runtime/miner/index.js +13 -0
  350. package/dist-runtime/miner/index.js.map +1 -0
  351. package/dist-runtime/miner/request.d.ts +7 -0
  352. package/dist-runtime/miner/request.js +73 -0
  353. package/dist-runtime/miner/request.js.map +1 -0
  354. package/dist-runtime/miner/runner.d.ts +2 -0
  355. package/dist-runtime/miner/runner.js +131 -0
  356. package/dist-runtime/miner/runner.js.map +1 -0
  357. package/dist-runtime/miner/types.d.ts +89 -0
  358. package/dist-runtime/miner/types.js +3 -0
  359. package/dist-runtime/miner/types.js.map +1 -0
  360. package/dist-runtime/miner/verify.d.ts +2 -0
  361. package/dist-runtime/miner/verify.js +75 -0
  362. package/dist-runtime/miner/verify.js.map +1 -0
  363. package/dist-runtime/runtime-identity.json +2 -2
  364. package/dist-runtime/vendor/plan-codec/index.cjs +820 -0
  365. package/dist-runtime/vendor/plan-codec/index.d.cts +32 -0
  366. package/dist-runtime/vendor/plan-codec/provenance.json +24 -0
  367. package/dist-runtime/workflow/engine.d.ts +14 -0
  368. package/dist-runtime/workflow/engine.js +160 -0
  369. package/dist-runtime/workflow/engine.js.map +1 -0
  370. package/dist-runtime/workflow/lib/authority.d.ts +6 -3
  371. package/dist-runtime/workflow/lib/authority.js.map +1 -1
  372. package/dist-runtime/workflow/lib/calls.d.ts +1 -1
  373. package/dist-runtime/workflow/lib/calls.js +43 -34
  374. package/dist-runtime/workflow/lib/calls.js.map +1 -1
  375. package/dist-runtime/workflow/lib/canonicalData.d.ts +8 -0
  376. package/dist-runtime/workflow/lib/canonicalData.js +68 -0
  377. package/dist-runtime/workflow/lib/canonicalData.js.map +1 -0
  378. package/dist-runtime/workflow/lib/config.d.ts +3 -1
  379. package/dist-runtime/workflow/lib/config.js.map +1 -1
  380. package/dist-runtime/workflow/lib/context.d.ts +76 -0
  381. package/dist-runtime/workflow/lib/context.js +3 -0
  382. package/dist-runtime/workflow/lib/context.js.map +1 -0
  383. package/dist-runtime/workflow/lib/controlledMulticallAbi.d.ts +2 -0
  384. package/dist-runtime/workflow/lib/controlledMulticallAbi.js +10 -0
  385. package/dist-runtime/workflow/lib/controlledMulticallAbi.js.map +1 -0
  386. package/dist-runtime/workflow/lib/create2.d.ts +1 -1
  387. package/dist-runtime/workflow/lib/create2.js +9 -12
  388. package/dist-runtime/workflow/lib/create2.js.map +1 -1
  389. package/dist-runtime/workflow/lib/deployments.d.ts +5 -5
  390. package/dist-runtime/workflow/lib/deployments.js +5 -13
  391. package/dist-runtime/workflow/lib/deployments.js.map +1 -1
  392. package/dist-runtime/workflow/lib/evidencePorts.d.ts +55 -0
  393. package/dist-runtime/workflow/lib/evidencePorts.js +3 -0
  394. package/dist-runtime/workflow/lib/evidencePorts.js.map +1 -0
  395. package/dist-runtime/workflow/lib/executionPlan.d.ts +4 -42
  396. package/dist-runtime/workflow/lib/executionPlan.js +15 -210
  397. package/dist-runtime/workflow/lib/executionPlan.js.map +1 -1
  398. package/dist-runtime/workflow/lib/gateTool.d.ts +6 -2
  399. package/dist-runtime/workflow/lib/gateTool.js +20 -10
  400. package/dist-runtime/workflow/lib/gateTool.js.map +1 -1
  401. package/dist-runtime/workflow/lib/gateToolSync.d.ts +1 -1
  402. package/dist-runtime/workflow/lib/gateToolSync.js +3 -2
  403. package/dist-runtime/workflow/lib/gateToolSync.js.map +1 -1
  404. package/dist-runtime/workflow/lib/operationNames.d.ts +3 -0
  405. package/dist-runtime/workflow/lib/operationNames.js +34 -0
  406. package/dist-runtime/workflow/lib/operationNames.js.map +1 -0
  407. package/dist-runtime/workflow/lib/parameters.d.ts +1 -1
  408. package/dist-runtime/workflow/lib/parameters.js +9 -24
  409. package/dist-runtime/workflow/lib/parameters.js.map +1 -1
  410. package/dist-runtime/workflow/lib/pendingDeploymentReuse.js +18 -52
  411. package/dist-runtime/workflow/lib/pendingDeploymentReuse.js.map +1 -1
  412. package/dist-runtime/workflow/lib/pendingUupsBinding.d.ts +42 -0
  413. package/dist-runtime/workflow/lib/pendingUupsBinding.js +39 -0
  414. package/dist-runtime/workflow/lib/pendingUupsBinding.js.map +1 -0
  415. package/dist-runtime/workflow/lib/plan.d.ts +55 -0
  416. package/dist-runtime/workflow/lib/plan.js +324 -0
  417. package/dist-runtime/workflow/lib/plan.js.map +1 -0
  418. package/dist-runtime/workflow/lib/planCli.d.ts +14 -0
  419. package/dist-runtime/workflow/lib/planCli.js +279 -0
  420. package/dist-runtime/workflow/lib/planCli.js.map +1 -0
  421. package/dist-runtime/workflow/lib/preparationEvidence.d.ts +4 -0
  422. package/dist-runtime/workflow/lib/preparationEvidence.js +19 -0
  423. package/dist-runtime/workflow/lib/preparationEvidence.js.map +1 -0
  424. package/dist-runtime/workflow/lib/proxy.d.ts +3 -2
  425. package/dist-runtime/workflow/lib/proxy.js +3 -4
  426. package/dist-runtime/workflow/lib/proxy.js.map +1 -1
  427. package/dist-runtime/workflow/lib/runtime.d.ts +6 -0
  428. package/dist-runtime/workflow/lib/runtime.js +48 -0
  429. package/dist-runtime/workflow/lib/runtime.js.map +1 -0
  430. package/dist-runtime/workflow/lib/signer.d.ts +3 -2
  431. package/dist-runtime/workflow/lib/signer.js +18 -18
  432. package/dist-runtime/workflow/lib/signer.js.map +1 -1
  433. package/dist-runtime/workflow/lib/simulation.d.ts +13 -6
  434. package/dist-runtime/workflow/lib/simulation.js +39 -31
  435. package/dist-runtime/workflow/lib/simulation.js.map +1 -1
  436. package/dist-runtime/workflow/lib/state.js +3 -3
  437. package/dist-runtime/workflow/lib/state.js.map +1 -1
  438. package/dist-runtime/workflow/lib/staticValidation.d.ts +28 -0
  439. package/dist-runtime/workflow/lib/staticValidation.js +54 -10
  440. package/dist-runtime/workflow/lib/staticValidation.js.map +1 -1
  441. package/dist-runtime/workflow/lib/transactionPlanner.d.ts +62 -0
  442. package/dist-runtime/workflow/lib/transactionPlanner.js +258 -0
  443. package/dist-runtime/workflow/lib/transactionPlanner.js.map +1 -0
  444. package/dist-runtime/workflow/lib/typedValue.d.ts +3 -0
  445. package/dist-runtime/workflow/lib/typedValue.js +76 -0
  446. package/dist-runtime/workflow/lib/typedValue.js.map +1 -0
  447. package/dist-runtime/workflow/lib/validation.d.ts +23 -0
  448. package/dist-runtime/workflow/lib/validation.js +15 -0
  449. package/dist-runtime/workflow/lib/validation.js.map +1 -0
  450. package/dist-runtime/workflow/planAdd.d.ts +1 -0
  451. package/dist-runtime/workflow/planAdd.js +11 -0
  452. package/dist-runtime/workflow/planAdd.js.map +1 -0
  453. package/dist-runtime/workflow/planRead.d.ts +1 -0
  454. package/dist-runtime/workflow/planRead.js +11 -0
  455. package/dist-runtime/workflow/planRead.js.map +1 -0
  456. package/dist-runtime/workflow/planStatus.d.ts +1 -0
  457. package/dist-runtime/workflow/planStatus.js +11 -0
  458. package/dist-runtime/workflow/planStatus.js.map +1 -0
  459. package/dist-runtime/workflow/planWrite.d.ts +1 -0
  460. package/dist-runtime/workflow/planWrite.js +11 -0
  461. package/dist-runtime/workflow/planWrite.js.map +1 -0
  462. package/dist-runtime/workflow/run.d.ts +1 -40
  463. package/dist-runtime/workflow/run.js +68 -136
  464. package/dist-runtime/workflow/run.js.map +1 -1
  465. package/dist-runtime/workflow/staticValidate.js +8 -3
  466. package/dist-runtime/workflow/staticValidate.js.map +1 -1
  467. package/dist-runtime/workflow/steps/call.d.ts +1 -1
  468. package/dist-runtime/workflow/steps/check.d.ts +1 -1
  469. package/dist-runtime/workflow/steps/custom.d.ts +1 -1
  470. package/dist-runtime/workflow/steps/deploy.d.ts +1 -1
  471. package/dist-runtime/workflow/steps/deploy.js +58 -55
  472. package/dist-runtime/workflow/steps/deploy.js.map +1 -1
  473. package/dist-runtime/workflow/steps/upgrade.d.ts +1 -1
  474. package/dist-runtime/workflow/steps/upgrade.js +63 -41
  475. package/dist-runtime/workflow/steps/upgrade.js.map +1 -1
  476. package/dist-runtime/workflow/steps/view.d.ts +1 -1
  477. package/docs/compiler-qualification.md +32 -0
  478. package/docs/configuration-runtime-observation.md +29 -0
  479. package/docs/create2-miner.md +100 -0
  480. package/docs/delivery-aggregate.md +27 -0
  481. package/docs/delivery-custom-input-closure.md +51 -0
  482. package/docs/delivery-development.md +32 -0
  483. package/docs/delivery-eoa.md +46 -0
  484. package/docs/delivery-evm-manifest.md +20 -0
  485. package/docs/delivery-execution-store.md +33 -0
  486. package/docs/delivery-inputs.md +46 -0
  487. package/docs/delivery-parameters.md +65 -0
  488. package/docs/delivery-planning.md +140 -0
  489. package/docs/delivery-release.md +65 -0
  490. package/docs/delivery-safe.md +72 -0
  491. package/docs/delivery-setup.md +146 -0
  492. package/docs/delivery-source.md +67 -0
  493. package/docs/direct-package-acceptance.md +20 -0
  494. package/docs/external-infrastructure-acceptance.md +33 -0
  495. package/docs/network-runtime-acceptance.md +18 -0
  496. package/docs/plans/2026-09-09-workflow-extraction.md +16 -0
  497. package/docs/superpowers/plans/2026-07-22-manifest-bootstrap-transaction.md +50 -0
  498. package/docs/superpowers/plans/2026-07-22-manifest-review-remediation.md +49 -0
  499. package/docs/superpowers/plans/2026-08-17-custody-hardhat-signers.md +227 -0
  500. package/docs/superpowers/plans/2026-09-09-remove-template-infrastructure-contracts.md +11 -0
  501. package/docs/superpowers/plans/2026-09-24-scheme-aware-static-validation.md +193 -0
  502. package/docs/superpowers/plans/2026-10-28-create2-miner.md +82 -0
  503. package/docs/workflow-reference.md +1181 -0
  504. package/docs/workflow-runtime-acceptance.md +17 -0
  505. package/docs/workflow-runtime.md +56 -0
  506. package/package.json +134 -9
  507. package/resources/create2/LICENSE +21 -0
  508. package/resources/create2/README.md +9 -0
  509. package/resources/create2/darwin-arm64/smartflow_miner +0 -0
  510. package/resources/create2/darwin-x64/smartflow_miner +0 -0
  511. package/resources/create2/manifest.json +27 -0
  512. package/runtime/config/hardhatAdapters.ts +8 -0
  513. package/runtime/config/networks.ts +20 -11
  514. package/runtime/config/openzeppelin.ts +3 -21
  515. package/runtime/delivery/abi.ts +225 -0
  516. package/runtime/delivery/aggregate-bootstrap.ts +29 -0
  517. package/runtime/delivery/aggregate-channel.ts +85 -0
  518. package/runtime/delivery/aggregate-inputs.ts +39 -0
  519. package/runtime/delivery/aggregate-source.ts +53 -0
  520. package/runtime/delivery/aggregate-worker.ts +133 -0
  521. package/runtime/delivery/aggregate.ts +139 -0
  522. package/runtime/delivery/bindings.ts +37 -0
  523. package/runtime/delivery/check-code.ts +38 -0
  524. package/runtime/delivery/closure-format.ts +350 -0
  525. package/runtime/delivery/codec-pin.ts +3 -0
  526. package/runtime/delivery/codec.ts +50 -0
  527. package/runtime/delivery/compiler-dependency-pins.ts +1685 -0
  528. package/runtime/delivery/compiler-files.ts +179 -0
  529. package/runtime/delivery/compiler-io.ts +10 -0
  530. package/runtime/delivery/compiler-pins.ts +143 -0
  531. package/runtime/delivery/compiler.ts +700 -0
  532. package/runtime/delivery/config.ts +93 -0
  533. package/runtime/delivery/configuration-definition.ts +133 -0
  534. package/runtime/delivery/configuration-hre.ts +130 -0
  535. package/runtime/delivery/configuration-runtime.ts +163 -0
  536. package/runtime/delivery/configuration.ts +64 -0
  537. package/runtime/delivery/create2.ts +57 -0
  538. package/runtime/delivery/custom-closure.ts +993 -0
  539. package/runtime/delivery/custom-format.ts +464 -0
  540. package/runtime/delivery/custom.ts +219 -0
  541. package/runtime/delivery/data.ts +94 -0
  542. package/runtime/delivery/development.ts +262 -0
  543. package/runtime/delivery/engine.ts +29 -0
  544. package/runtime/delivery/eoa-observation.ts +106 -0
  545. package/runtime/delivery/eoa-signed.ts +55 -0
  546. package/runtime/delivery/eoa.ts +288 -0
  547. package/runtime/delivery/execution-db.ts +131 -0
  548. package/runtime/delivery/execution-files.ts +135 -0
  549. package/runtime/delivery/execution-model.ts +102 -0
  550. package/runtime/delivery/execution-store.ts +411 -0
  551. package/runtime/delivery/existing-code.ts +44 -0
  552. package/runtime/delivery/export.ts +99 -0
  553. package/runtime/delivery/forkAudit.ts +620 -0
  554. package/runtime/delivery/hardhat.ts +38 -0
  555. package/runtime/delivery/history-registration.ts +10 -0
  556. package/runtime/delivery/identities.ts +132 -0
  557. package/runtime/delivery/input-files.ts +46 -0
  558. package/runtime/delivery/inputs.ts +197 -0
  559. package/runtime/delivery/journal.ts +201 -0
  560. package/runtime/delivery/manifest.ts +54 -0
  561. package/runtime/delivery/materialization.ts +53 -0
  562. package/runtime/delivery/observations.ts +60 -0
  563. package/runtime/delivery/parameters.ts +349 -0
  564. package/runtime/delivery/pending.ts +98 -0
  565. package/runtime/delivery/plan.ts +337 -0
  566. package/runtime/delivery/planning.ts +397 -0
  567. package/runtime/delivery/policy.ts +9 -0
  568. package/runtime/delivery/preparation.ts +224 -0
  569. package/runtime/delivery/production-environment.ts +6 -0
  570. package/runtime/delivery/production-finalization.ts +172 -0
  571. package/runtime/delivery/production.ts +375 -0
  572. package/runtime/delivery/project-files.ts +58 -0
  573. package/runtime/delivery/project.ts +117 -0
  574. package/runtime/delivery/protocol.ts +94 -0
  575. package/runtime/delivery/references.ts +106 -0
  576. package/runtime/delivery/release-graph.ts +49 -0
  577. package/runtime/delivery/release-history-capture.ts +32 -0
  578. package/runtime/delivery/release-history.ts +120 -0
  579. package/runtime/delivery/release.ts +128 -0
  580. package/runtime/delivery/safe-manifest.ts +11 -0
  581. package/runtime/delivery/safe-observation.ts +626 -0
  582. package/runtime/delivery/safe-prepare.ts +101 -0
  583. package/runtime/delivery/safe.ts +344 -0
  584. package/runtime/delivery/same-fork-baseline.ts +16 -0
  585. package/runtime/delivery/setup.ts +172 -0
  586. package/runtime/delivery/source.ts +130 -0
  587. package/runtime/delivery/target-fields.ts +7 -0
  588. package/runtime/delivery/validation.ts +247 -0
  589. package/runtime/delivery/verification.ts +47 -0
  590. package/runtime/migrate.ts +1 -0
  591. package/runtime/miner/binary.ts +41 -0
  592. package/runtime/miner/cli.ts +87 -0
  593. package/runtime/miner/index.ts +5 -0
  594. package/runtime/miner/request.ts +54 -0
  595. package/runtime/miner/runner.ts +90 -0
  596. package/runtime/miner/types.ts +71 -0
  597. package/runtime/miner/verify.ts +61 -0
  598. package/runtime/vendor/plan-codec/index.cjs +820 -0
  599. package/runtime/vendor/plan-codec/index.d.cts +32 -0
  600. package/runtime/vendor/plan-codec/provenance.json +24 -0
  601. package/runtime/workflow/engine.ts +174 -0
  602. package/runtime/workflow/lib/authority.ts +3 -3
  603. package/runtime/workflow/lib/calls.ts +46 -37
  604. package/runtime/workflow/lib/canonicalData.ts +45 -0
  605. package/runtime/workflow/lib/config.ts +1 -1
  606. package/runtime/workflow/lib/context.ts +76 -0
  607. package/runtime/workflow/lib/controlledMulticallAbi.ts +6 -0
  608. package/runtime/workflow/lib/create2.ts +10 -12
  609. package/runtime/workflow/lib/deployments.ts +6 -14
  610. package/runtime/workflow/lib/evidencePorts.ts +20 -0
  611. package/runtime/workflow/lib/executionPlan.ts +17 -268
  612. package/runtime/workflow/lib/gateTool.ts +20 -8
  613. package/runtime/workflow/lib/gateToolSync.ts +3 -3
  614. package/runtime/workflow/lib/operationNames.ts +32 -0
  615. package/runtime/workflow/lib/parameters.ts +7 -23
  616. package/runtime/workflow/lib/pendingDeploymentReuse.ts +4 -56
  617. package/runtime/workflow/lib/pendingUupsBinding.ts +43 -0
  618. package/runtime/workflow/lib/plan.ts +334 -0
  619. package/runtime/workflow/lib/planCli.ts +279 -0
  620. package/runtime/workflow/lib/preparationEvidence.ts +14 -0
  621. package/runtime/workflow/lib/proxy.ts +5 -3
  622. package/runtime/workflow/lib/runtime.ts +46 -0
  623. package/runtime/workflow/lib/signer.ts +8 -5
  624. package/runtime/workflow/lib/simulation.ts +41 -17
  625. package/runtime/workflow/lib/state.ts +3 -3
  626. package/runtime/workflow/lib/staticValidation.ts +92 -11
  627. package/runtime/workflow/lib/transactionPlanner.ts +314 -0
  628. package/runtime/workflow/lib/typedValue.ts +46 -0
  629. package/runtime/workflow/lib/validation.ts +50 -0
  630. package/runtime/workflow/planAdd.ts +8 -0
  631. package/runtime/workflow/planRead.ts +8 -0
  632. package/runtime/workflow/planStatus.ts +8 -0
  633. package/runtime/workflow/planWrite.ts +8 -0
  634. package/runtime/workflow/run.ts +41 -174
  635. package/runtime/workflow/staticValidate.ts +8 -3
  636. package/runtime/workflow/steps/call.ts +1 -1
  637. package/runtime/workflow/steps/check.ts +1 -1
  638. package/runtime/workflow/steps/custom.ts +1 -1
  639. package/runtime/workflow/steps/deploy.ts +59 -59
  640. package/runtime/workflow/steps/upgrade.ts +71 -47
  641. package/runtime/workflow/steps/view.ts +1 -1
@@ -0,0 +1,130 @@
1
+ /** Actual-file source binding only. This API grants no host approval or execution authority. */
2
+ import fs from 'node:fs';
3
+ import { createHash } from 'node:crypto';
4
+ import { coreMarker, projectRoot, confinedFile } from './project-files';
5
+ import { object, parseDeliveryRequest, validateDeliveryRpc, type DeliveryRequest, type ChainIdProvider, type ProjectNetworkSnapshot } from './protocol';
6
+ import { loadPlanCodec } from './codec';
7
+ import type { Plan, PlanTask, DefinitionSelection, DefinitionSnapshot, DeepReadonly } from '../vendor/plan-codec/index.cjs';
8
+ export type { DefinitionSelection, DefinitionSnapshot, DeepReadonly } from '../vendor/plan-codec/index.cjs';
9
+
10
+ export interface DeliverySourceOptions {
11
+ workspaceRoot: string;
12
+ /** Workspace-relative path or '.'. */
13
+ projectRoot: string;
14
+ request: unknown;
15
+ /** Explicit upstream roots, independent of the invocation sourceRef task. */
16
+ sourceRoots: string[];
17
+ }
18
+ export interface DeliverySourceBinding {
19
+ request: DeliveryRequest;
20
+ workspaceRoot: string;
21
+ projectRoot: string;
22
+ observation: { path: string; sha256: string };
23
+ invocation: { lane: string; task: PlanTask };
24
+ sourceDefinition: DefinitionSnapshot;
25
+ sourceDefinitionBytes: string;
26
+ sourceDefinitionHash: string;
27
+ prodTaskGraph?: DefinitionSnapshot;
28
+ prodTaskGraphBytes?: string;
29
+ prodTaskGraphHash?: string;
30
+ }
31
+ const sha256 = (bytes: string | Buffer): string => createHash('sha256').update(bytes).digest('hex');
32
+ function freeze<T>(value: T): DeepReadonly<T> {
33
+ if (value && typeof value === 'object') { Object.values(value).forEach(freeze); Object.freeze(value); }
34
+ return value as DeepReadonly<T>;
35
+ }
36
+ export function parseCanonicalPlan(text: string): Plan { return loadPlanCodec().parsePlan(text); }
37
+ export function projectCanonicalDefinitions(text: string, selection: DefinitionSelection): ReturnType<ReturnType<typeof loadPlanCodec>['projectDefinitions']> {
38
+ return loadPlanCodec().projectDefinitions(text, selection);
39
+ }
40
+ const purposeSteps = {
41
+ 'dev-execution': ['deploy', 'check-code'],
42
+ 'prod-qualification': ['deploy-test'],
43
+ 'prod-execution': ['release-prepare', 'release-execute', 'release-verify'],
44
+ };
45
+ function sameRelease(actual: unknown, expected: DeliveryRequest['releaseRef']): boolean {
46
+ if (expected === undefined) return actual === undefined;
47
+ if (!actual || typeof actual !== 'object' || Array.isArray(actual)) return false;
48
+ const ref = actual as Record<string, unknown>;
49
+ return Object.keys(ref).length === 3 && ref.path === expected.path && ref.releaseId === expected.releaseId && ref.inputsHash === expected.inputsHash;
50
+ }
51
+ function actualSource(workspace: string, relative: string): Buffer {
52
+ const file = confinedFile(workspace, relative);
53
+ const fd = fs.openSync(file, fs.constants.O_RDONLY | fs.constants.O_NOFOLLOW);
54
+ try {
55
+ const before = fs.fstatSync(fd);
56
+ if (!before.isFile() || before.nlink !== 1) throw new Error('Unsafe handoff file type');
57
+ const bytes = fs.readFileSync(fd);
58
+ const after = fs.fstatSync(fd);
59
+ // Fail if the observed file was replaced or changed during reading.
60
+ confinedFile(workspace, relative);
61
+ const current = fs.lstatSync(file);
62
+ if (before.dev !== current.dev || before.ino !== current.ino || before.size !== after.size
63
+ || before.mtimeMs !== after.mtimeMs || before.ctimeMs !== after.ctimeMs) throw new Error('Handoff changed while reading');
64
+ return bytes;
65
+ } finally { fs.closeSync(fd); }
66
+ }
67
+ /** Read one confined handoff snapshot and bind the current invocation to it before any RPC work. */
68
+ export function readDeliverySource(input: DeliverySourceOptions): DeepReadonly<DeliverySourceBinding> {
69
+ object(input, 'source options', ['workspaceRoot', 'projectRoot', 'request', 'sourceRoots']);
70
+ return readSource(input);
71
+ }
72
+ /** Owned business selection derives upstream roots from the same actual invocation bytes. */
73
+ export function readOwnedDeliverySource(input: Omit<DeliverySourceOptions, 'sourceRoots'>): DeepReadonly<DeliverySourceBinding> {
74
+ object(input, 'owned source options', ['workspaceRoot', 'projectRoot', 'request']);
75
+ return readSource(input);
76
+ }
77
+ function readSource(input: Omit<DeliverySourceOptions, 'sourceRoots'> & { sourceRoots?: string[] }): DeepReadonly<DeliverySourceBinding> {
78
+ const request = parseDeliveryRequest(input.request);
79
+ const workspace = projectRoot(input.workspaceRoot, '.');
80
+ const root = projectRoot(workspace, input.projectRoot);
81
+ coreMarker(root);
82
+ const bytes = actualSource(workspace, request.sourceRef.path);
83
+ const text = new TextDecoder('utf-8', { fatal: true }).decode(bytes);
84
+ if (input.sourceRoots === undefined) (require('./input-files') as typeof import('./input-files')).assertUnambiguousHandoff(text);
85
+ const codec = loadPlanCodec();
86
+ const plan = codec.parsePlan(text);
87
+ if (plan.taskId !== request.sourceRef.taskId) throw new Error('sourceRef.taskId does not match actual handoff');
88
+ const entries = Object.entries(plan.tasks).flatMap(([lane, tasks]) => tasks.map(task => ({ lane, task })));
89
+ const invocation = entries.find(({ task }) => task.planKey === request.sourceRef.planKey);
90
+ if (!invocation || invocation.task.rev !== request.sourceRef.rev) throw new Error('sourceRef planKey/rev does not match actual handoff');
91
+ if (plan.lanes[invocation.lane].state !== 'enabled' || invocation.task.status === 'cancelled') throw new Error('Invocation task is disabled or cancelled');
92
+ const deployment = object(invocation.task.scope?.deployment, 'invocation scope.deployment');
93
+ if (deployment.projectRoot !== input.projectRoot) throw new Error('Invocation projectRoot mismatch');
94
+ if (deployment.chainFamily !== 'evm' || deployment.framework !== 'hardhat2') throw new Error('Invocation requires an EVM Hardhat2 deployment');
95
+ if (!purposeSteps[request.purpose].includes(invocation.task.step ?? '')) throw new Error('Invocation purpose/step mismatch');
96
+ if (deployment.environment !== request.environment || deployment.targetNetwork !== request.network) throw new Error('Invocation environment/targetNetwork mismatch');
97
+ if (!Array.isArray(deployment.allowedActions) || !deployment.allowedActions.includes(request.mode)) throw new Error('Invocation mode is not in allowedActions');
98
+ if (!sameRelease(deployment.releaseRef, request.releaseRef)) throw new Error('Invocation releaseRef mismatch');
99
+ const sourceRoots = input.sourceRoots ?? (request.purpose === 'prod-execution'
100
+ ? entries.filter(({ task }) => task.step === 'deploy-test'
101
+ && (task.scope?.deployment as Record<string, unknown> | undefined)?.projectRoot === input.projectRoot
102
+ && (task.scope?.deployment as Record<string, unknown> | undefined)?.deploymentId === deployment.deploymentId).map(({ task }) => task.planKey)
103
+ : [invocation.task.planKey]);
104
+ if (!sourceRoots.length) throw new Error('Owned source requires an upstream qualification definition');
105
+ const source = codec.projectDefinitions(text, { roots: sourceRoots, mode: 'upstream' });
106
+ for (const task of source.snapshot.tasks) {
107
+ const selectedDeployment = task.scope?.deployment as Readonly<Record<string, unknown>> | undefined;
108
+ if (selectedDeployment && selectedDeployment.projectRoot !== input.projectRoot) throw new Error(`Selected upstream deployment projectRoot mismatch: ${task.planKey}`);
109
+ }
110
+ let production: ReturnType<typeof codec.projectDefinitions> | undefined;
111
+ if (request.purpose === 'prod-execution') {
112
+ const roots = entries.filter(({ task }) => purposeSteps['prod-execution'].includes(task.step ?? '')
113
+ && task.scope?.deployment && (task.scope.deployment as Record<string, unknown>).projectRoot === input.projectRoot
114
+ && sameRelease((task.scope.deployment as Record<string, unknown>).releaseRef, request.releaseRef)).map(({ task }) => task.planKey);
115
+ production = codec.projectDefinitions(text, { roots, mode: 'full' });
116
+ }
117
+ // All values came from detached request parsing and actual handoff text; freeze before exposing.
118
+ return freeze({ request, workspaceRoot: workspace, projectRoot: root, observation: { path: request.sourceRef.path, sha256: sha256(bytes) },
119
+ invocation, sourceDefinition: source.snapshot, sourceDefinitionBytes: source.bytes, sourceDefinitionHash: sha256(source.bytes),
120
+ ...(production ? { prodTaskGraph: production.snapshot, prodTaskGraphBytes: production.bytes, prodTaskGraphHash: sha256(production.bytes) } : {}),
121
+ }) as DeepReadonly<DeliverySourceBinding>;
122
+ }
123
+ /** Read/validate actual source before a provider can be loaded; still not host authorization. */
124
+ export async function validateDeliverySourceRpc(input: DeliverySourceOptions, snapshot: ProjectNetworkSnapshot,
125
+ loadProvider: (snapshot: ProjectNetworkSnapshot) => Promise<ChainIdProvider>,
126
+ ): Promise<DeepReadonly<DeliverySourceBinding & { chainId: number }>> {
127
+ const binding = readDeliverySource(input);
128
+ const { chainId } = await validateDeliveryRpc(binding.request, snapshot, loadProvider);
129
+ return freeze({ ...binding, chainId }) as DeepReadonly<DeliverySourceBinding & { chainId: number }>;
130
+ }
@@ -0,0 +1,7 @@
1
+ /** Complete scalar public target boundary shared by native references and custom ports. */
2
+ export const PUBLIC_TARGET_FIELDS = new Set([
3
+ 'version', 'id', 'network', 'environment', 'chainId', 'admin',
4
+ 'finality.confirmations', 'openzeppelin.manifestDir',
5
+ 'create2.scheme', 'create2.factory', 'create2.leadingZeroBytes', 'create2.caller',
6
+ 'uups.placeholderImplementation', 'multicall.controlledMulticall',
7
+ ]);
@@ -0,0 +1,247 @@
1
+ import { validateCreate2Fields } from "./create2";
2
+ import { canonicalCreate2Hashes } from "../workflow/lib/create2Hashes";
3
+ import { ParamType, getCreate2Address } from "ethers";
4
+ import type { WorkflowContext } from "../workflow/lib/context";
5
+ import type { WorkflowStep } from "../workflow/lib/parameters";
6
+ import type { WorkflowValidationPort } from "../workflow/lib/validation";
7
+ import { strictData } from "./data";
8
+ import {
9
+ resolveBusinessValue,
10
+ containsDeferred,
11
+ type ReferenceObservation,
12
+ } from "./references";
13
+ import {
14
+ validateAbiArguments,
15
+ validateAbiValue,
16
+ validateTransactionValue,
17
+ validateAbiResult,
18
+ compareAbiResults,
19
+ stringifyRuntimeValue,
20
+ } from "./abi";
21
+ import {
22
+ deliveryArtifact,
23
+ deliveryPreparationData,
24
+ validatePreparationSemantics,
25
+ ERC1967_PROXY,
26
+ } from "./preparation";
27
+ import { parseNativeOperation } from "./custom";
28
+ import { deepFreeze } from "../workflow/lib/canonicalData";
29
+ import { ownedDeliveryCompiler, compilerPreparationHooks, validateCompilerPreparationPlan, verifyCompilerSameForkUpgrade } from './compiler';
30
+
31
+ export interface DeliveryValidation extends WorkflowValidationPort {
32
+ preflight(steps: readonly WorkflowStep[]): Promise<void>;
33
+ observations(): readonly ReferenceObservation[];
34
+ }
35
+ export function createDeliveryValidation(
36
+ context: WorkflowContext,
37
+ ): DeliveryValidation {
38
+ if (context.target.create2?.scheme && context.target.create2.scheme !== "evm")
39
+ throw new Error("Delivery validation requires EVM");
40
+ const observations: ReferenceObservation[] = [];
41
+ const compiler = ownedDeliveryCompiler(context.runtime.hre);
42
+ const params = deepFreeze(strictData(context.targetParams));
43
+ const resolve = (value: unknown, deferState = false): unknown => {
44
+ const result = resolveBusinessValue(
45
+ value,
46
+ { params, target: context.target, state: () => context.state.snapshot() },
47
+ { deferState },
48
+ );
49
+ observations.push(...result.observations);
50
+ return result.value;
51
+ };
52
+ // Artifact reader is an explicit runtime capability, never an address/contract resolver.
53
+ const read = async (name: string) => {
54
+ if (!context.runtime.hre.artifacts?.readArtifact)
55
+ throw new Error(
56
+ "Delivery validation requires explicit runtime artifact reader",
57
+ );
58
+ return deliveryArtifact(
59
+ await context.runtime.hre.artifacts.readArtifact(name),
60
+ );
61
+ };
62
+ const argumentsFor = async (
63
+ name: string,
64
+ method: string | null,
65
+ args: unknown,
66
+ deferState = false,
67
+ ) =>
68
+ validateAbiArguments(
69
+ (await read(name)).abi,
70
+ method,
71
+ resolve(args, deferState),
72
+ { allowDeferred: deferState },
73
+ );
74
+ const call = async (
75
+ name: string,
76
+ method: string,
77
+ args: unknown,
78
+ value?: unknown,
79
+ ) => {
80
+ validateAbiArguments((await read(name)).abi, method, args);
81
+ if (value !== undefined) validateTransactionValue(value);
82
+ };
83
+ const preflight = async (steps: readonly WorkflowStep[]) => {
84
+ const data = strictData(steps);
85
+ for (const step of data) {
86
+ // Internal operation IDs can exceed the source parser's 200-character limit.
87
+ parseNativeOperation({ ...step, id: "validation" });
88
+ resolve(step, true); // Parse every reference without reading future state.
89
+ if (step.address !== undefined)
90
+ validateAbiValue(
91
+ ParamType.from("address"),
92
+ resolve(step.address, true),
93
+ "operation address",
94
+ true,
95
+ );
96
+ if (["call", "view", "check"].includes(step.kind)) {
97
+ for (const c of step.calls as Array<Record<string, unknown>>) {
98
+ await argumentsFor(
99
+ String(step.abi ?? step.contract),
100
+ c.method as string,
101
+ c.args === undefined ? [] : c.args,
102
+ true,
103
+ );
104
+ if (step.kind === "check")
105
+ validateAbiResult(
106
+ (await read(String(step.abi ?? step.contract))).abi,
107
+ c.method as string,
108
+ resolve(c.expect, true),
109
+ true,
110
+ );
111
+ if (c.value !== undefined)
112
+ validateTransactionValue(resolve(c.value, true), true);
113
+ }
114
+ } else {
115
+ const first = step.firstUpgrade as Record<string, unknown> | undefined;
116
+ const proxy = step.proxy as Record<string, unknown> | undefined;
117
+ const name = first?.contract ?? step.contract;
118
+ const args = first
119
+ ? (first.constructorArgs ?? [])
120
+ : step.kind === "deploy"
121
+ ? (step.args ?? [])
122
+ : (step.constructorArgs ??
123
+ (typeof proxy === "object"
124
+ ? proxy?.constructorArgs
125
+ : undefined) ??
126
+ []);
127
+ await argumentsFor(name as string, null, args, true);
128
+ const init = (first?.call ?? step.call) as
129
+ | Record<string, unknown>
130
+ | undefined;
131
+ if (init)
132
+ await argumentsFor(
133
+ name as string,
134
+ (init.method ?? init.fn) as string,
135
+ init.args ?? [],
136
+ true,
137
+ );
138
+ if (first)
139
+ await argumentsFor(
140
+ ERC1967_PROXY,
141
+ null,
142
+ [context.target.uups?.placeholderImplementation, "0x"],
143
+ true,
144
+ );
145
+ const fields = (value: unknown, kind: Parameters<typeof validateCreate2Fields>[1]) =>
146
+ validateCreate2Fields(resolve(value === undefined ? {} : value, true), kind, true);
147
+ const targetCreate2 = fields(context.target.create2, "target");
148
+ fields(context.target.uups, "uups");
149
+ const targetMulticall = fields(context.target.multicall, "multicall");
150
+ if (
151
+ step.kind === "upgrade" &&
152
+ (targetCreate2.factory === undefined || targetMulticall.controlledMulticall === undefined)
153
+ )
154
+ throw new Error(`Upgrade step ${step.id} requires target create2 factory and controlledMulticall`);
155
+ const declaredCreate2 = step.create2 === undefined
156
+ ? undefined
157
+ : fields(step.create2, "step");
158
+ const policy =
159
+ context.existingDeploymentPolicies?.[String(step.saveAs)];
160
+ const create2 =
161
+ declaredCreate2 && policy?.mode === "redeploy"
162
+ ? validateCreate2Fields(
163
+ {
164
+ ...declaredCreate2,
165
+ salt: policy.salt,
166
+ expectedAddress: policy.expectedAddress,
167
+ },
168
+ "step",
169
+ true,
170
+ )
171
+ : declaredCreate2;
172
+ if (step.kind === "deploy" && create2) {
173
+ const a = await read(first ? ERC1967_PROXY : (name as string));
174
+ const constructor = resolve(
175
+ first
176
+ ? [context.target.uups?.placeholderImplementation, "0x"]
177
+ : args,
178
+ true,
179
+ );
180
+ const factory = create2.factory ?? targetCreate2.factory,
181
+ salt = create2.salt;
182
+ if (factory === undefined)
183
+ throw new Error("CREATE2 requires a factory address");
184
+ if (!containsDeferred([constructor, factory, salt])) {
185
+ const hashes = canonicalCreate2Hashes({
186
+ scheme: "evm",
187
+ artifact: a,
188
+ args: constructor as unknown[],
189
+ });
190
+ if (hashes.scheme !== "evm")
191
+ throw new Error("Invalid CREATE2 scheme");
192
+ const predicted = getCreate2Address(
193
+ factory as string,
194
+ salt as string,
195
+ hashes.initCodeHash,
196
+ ).toLowerCase();
197
+ if (create2.expectedAddress !== undefined) {
198
+ const expected = create2.expectedAddress;
199
+ if (
200
+ !containsDeferred(expected) &&
201
+ (typeof expected !== "string" ||
202
+ predicted !== expected.toLowerCase())
203
+ )
204
+ throw new Error(
205
+ "Actual CREATE2 predicted address differs from expectedAddress",
206
+ );
207
+ }
208
+ const zeroes =
209
+ create2.leadingZeroBytes ??
210
+ targetCreate2.leadingZeroBytes;
211
+ if (
212
+ zeroes !== undefined &&
213
+ !containsDeferred(zeroes) &&
214
+ !predicted.slice(2).startsWith("00".repeat(Number(zeroes)))
215
+ )
216
+ throw new Error("Actual CREATE2 violates leadingZeroBytes");
217
+ }
218
+ }
219
+ }
220
+ }
221
+ };
222
+ return {
223
+ resolve,
224
+ create2Fields: validateCreate2Fields,
225
+ call,
226
+ address: (value) =>
227
+ validateAbiValue(ParamType.from("address"), value, "operation address"),
228
+ callInterface: validateAbiArguments,
229
+ check: validateAbiResult,
230
+ compare: compareAbiResults,
231
+ stringify: stringifyRuntimeValue,
232
+ preparation: {
233
+ data: deliveryPreparationData,
234
+ artifact: (name, raw) => deepFreeze(deliveryArtifact(compiler ? compiler.artifact(name, raw) : raw)),
235
+ arguments: (artifact, method, args) =>
236
+ validateAbiArguments(artifact.abi, method, args),
237
+ ...compilerPreparationHooks(context.runtime.hre),
238
+ },
239
+ preparationPlan: async (request, plan) => {
240
+ await validatePreparationSemantics(request, plan, read);
241
+ await validateCompilerPreparationPlan(context.runtime.hre,request,plan);
242
+ },
243
+ sameForkUpgrade: proxy => verifyCompilerSameForkUpgrade(context.runtime.hre,context.targetId,proxy,context.simulation.snapshot?.blockNumber),
244
+ preflight,
245
+ observations: () => deepFreeze(strictData(observations)),
246
+ };
247
+ }
@@ -0,0 +1,47 @@
1
+ import { canonicalData, canonicalJson, deepFreeze, exactObject, nonempty } from '../workflow/lib/canonicalData';
2
+ import { parseTypedValue } from '../workflow/lib/typedValue';
3
+ import type { VerificationObservation, VerificationSink } from '../workflow/lib/evidencePorts';
4
+ export interface ExpectedAssertion { stepId: string; callIndex: number; assertionId: string }
5
+ export function parseVerificationObservation(raw: unknown): VerificationObservation {
6
+ const v = exactObject(raw, ['stepId', 'callIndex', 'assertionId', 'contract', 'abiName', 'abi', 'address', 'method', 'args', 'definition', 'actual', 'expected'], 'verification observation');
7
+ for (const key of ['stepId', 'assertionId', 'contract', 'abiName', 'method']) nonempty(v[key], key);
8
+ if (!Number.isSafeInteger(v.callIndex) || (v.callIndex as number) < 0 || v.assertionId !== `${v.stepId}:${v.callIndex}`) throw new Error('Invalid assertion identity');
9
+ if (typeof v.address !== 'string' || !/^0x[\da-fA-F]{40}$/.test(v.address)) throw new Error('Invalid verification address');
10
+ if (!Array.isArray(v.abi) || v.abi.length === 0 || v.abi.some(item => typeof item !== 'string' || !item)) throw new Error('Invalid verification ABI');
11
+ const definition = exactObject(v.definition, ['method', 'args', 'expect'], 'check definition');
12
+ nonempty(definition.method, 'definition method');
13
+ if (definition.method !== v.method) throw new Error('Check definition method mismatch');
14
+ parseTypedValue(definition.args); parseTypedValue(definition.expect);
15
+ parseTypedValue(v.args); parseTypedValue(v.actual); parseTypedValue(v.expected);
16
+ return deepFreeze(canonicalData(v) as unknown as VerificationObservation);
17
+ }
18
+ export class VerificationJournal implements VerificationSink {
19
+ private readonly expected: ExpectedAssertion[];
20
+ private readonly observations: VerificationObservation[] = [];
21
+ private sealed = false;
22
+ constructor(expected: readonly ExpectedAssertion[]) {
23
+ this.expected = [];
24
+ this.declare(expected);
25
+ }
26
+ declare(expected: readonly ExpectedAssertion[]): void {
27
+ if (this.sealed) throw new Error("verification journal sealed");
28
+ this.expected.push(...deepFreeze(canonicalData(expected) as ExpectedAssertion[]));
29
+ if (new Set(this.expected.map(e => e.assertionId)).size !== this.expected.length) throw new Error('Duplicate expected assertion');
30
+ for (const e of this.expected) {
31
+ exactObject(e, ['stepId', 'callIndex', 'assertionId'], 'expected assertion');
32
+ if (!Number.isSafeInteger(e.callIndex) || e.callIndex < 0 || e.assertionId !== `${e.stepId}:${e.callIndex}`) throw new Error('Invalid expected assertion');
33
+ }
34
+ }
35
+ record(raw: VerificationObservation): void {
36
+ if (this.sealed) throw new Error('verification journal sealed');
37
+ const observation = parseVerificationObservation(raw), expected = this.expected[this.observations.length];
38
+ if (!expected || canonicalJson(expected) !== canonicalJson({ stepId: observation.stepId, callIndex: observation.callIndex, assertionId: observation.assertionId })) throw new Error('Unexpected verification step/call mapping');
39
+ this.observations.push(observation);
40
+ }
41
+ seal(): VerificationObservation[] {
42
+ if (this.expected.length !== this.observations.length) throw new Error('missing expected verification observations');
43
+ this.sealed = true;
44
+ // Empty is valid collection, never business acceptance or qualification authority.
45
+ return deepFreeze([...this.observations]);
46
+ }
47
+ }
@@ -12,6 +12,7 @@ const commands: Record<string, string> = {
12
12
  create2Hashes: 'create2-hashes', releaseFinalize: 'release-finalize',
13
13
  importState: 'import-state', reconcileExternal: 'reconcile-external',
14
14
  commitContractInfo: 'commit-contract-info',
15
+ planRead: 'plan-read', planWrite: 'plan-write', planAdd: 'plan-add', planStatus: 'plan-status',
15
16
  };
16
17
 
17
18
  /** Plan first; preserve custom files/state. Only known sources/shims are removable. */
@@ -0,0 +1,41 @@
1
+ import { createHash } from "node:crypto";
2
+ import { accessSync, constants, readFileSync, statSync } from "node:fs";
3
+ import { resolve } from "node:path";
4
+ import type { Create2MinerBinaryOptions } from "./types";
5
+
6
+ // These trusted pins are compiled into the runtime. A mutable manifest alone is not a trust anchor.
7
+ const bundled: Record<string, { sha256: string; bytes: number }> = {
8
+ "darwin-arm64": { sha256: "9611c1ca900c24f9b14924a144b7a3ab431111b855e676f2e145e7ab8c05f954", bytes: 1297616 },
9
+ "darwin-x64": { sha256: "a38279143658a8849db484e248c62af6ae2db78de4251021f195efd9bf987d82", bytes: 1306112 },
10
+ };
11
+ function executable(file: string): void {
12
+ try {
13
+ if (!statSync(file).isFile()) throw new Error("not a regular file");
14
+ accessSync(file, constants.X_OK);
15
+ if (process.platform !== "win32" && (statSync(file).mode & 0o111) === 0) throw new Error("missing executable permission");
16
+ } catch (cause) {
17
+ throw new Error(`CREATE2 miner is not an executable file: ${file}`, { cause });
18
+ }
19
+ }
20
+ export function resolveCreate2MinerBinary(options: Create2MinerBinaryOptions = {}): string {
21
+ const override = options.binaryPath !== undefined ? options.binaryPath : process.env.GATE_TOOL_CREATE2_MINER_BIN;
22
+ if (override !== undefined) {
23
+ if (typeof override !== "string" || override.trim().length === 0) throw new Error("CREATE2 miner binaryPath override must be a non-empty path");
24
+ const file = resolve(override);
25
+ executable(file);
26
+ return file;
27
+ }
28
+ const host = `${process.platform}-${process.arch}`;
29
+ const pin = bundled[host];
30
+ if (!pin) throw new Error(`No bundled CREATE2 miner for ${host}. Build a compatible smartflow_miner and set GATE_TOOL_CREATE2_MINER_BIN or binaryPath to its executable path.`);
31
+ const directory = resolve(__dirname, "../../resources/create2");
32
+ const file = resolve(directory, host, "smartflow_miner");
33
+ executable(file);
34
+ const bytes = readFileSync(file);
35
+ if (bytes.length !== pin.bytes || createHash("sha256").update(bytes).digest("hex") !== pin.sha256) throw new Error(`Bundled CREATE2 miner SHA-256 mismatch: ${file}; reinstall the package or supply a trusted binaryPath`);
36
+ let entry: { sha256?: unknown; bytes?: unknown } | undefined;
37
+ try { entry = JSON.parse(readFileSync(resolve(directory, "manifest.json"), "utf8")).binaries?.[host]; }
38
+ catch (cause) { throw new Error("Bundled CREATE2 miner manifest is invalid", { cause }); }
39
+ if (!entry || entry.sha256 !== pin.sha256 || entry.bytes !== pin.bytes) throw new Error(`Bundled CREATE2 miner manifest mismatch for ${host}`);
40
+ return file;
41
+ }
@@ -0,0 +1,87 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { readFile, realpath, rename, stat, unlink, writeFile } from "node:fs/promises";
3
+ import { basename, dirname, join, resolve } from "node:path";
4
+ import { mineCreate2 } from "./runner";
5
+ import { normalizeCreate2MinerRequest } from "./request";
6
+
7
+ const help = `Usage: gate-tool miner --request request.json [--output result.json] [--binary /absolute/path] [--timeout-ms N]
8
+
9
+ Prepare and verify CREATE2 salts locally; no RPC, signing or deployment.
10
+ --request <path> Request JSON file, or - to read stdin (required)
11
+ --output <path> Atomically save verified result JSON after success
12
+ --binary <path> Trusted native executable override
13
+ --timeout-ms <N> Positive integer milliseconds (default: 300000)
14
+ -h, --help Show this help
15
+
16
+ Requires ethers v6. See docs/create2-miner.md for schemes and backend limits.
17
+ `;
18
+ async function sameFile(input: string, output: string): Promise<boolean> {
19
+ if (resolve(input) === resolve(output)) return true;
20
+ try {
21
+ const [a, b] = await Promise.all([stat(input), stat(output)]);
22
+ return a.dev === b.dev && a.ino === b.ino;
23
+ } catch (error) { if ((error as NodeJS.ErrnoException).code !== "ENOENT") throw error; return false; }
24
+ }
25
+ async function stdinJson(signal: AbortSignal): Promise<string> {
26
+ return new Promise((resolveInput, reject) => {
27
+ const chunks: Buffer[] = []; let size = 0;
28
+ const cleanup = (): void => { process.stdin.off("data", data); process.stdin.off("end", end); process.stdin.off("error", fail); signal.removeEventListener("abort", abort); process.stdin.pause(); };
29
+ const fail = (error: Error): void => { cleanup(); reject(error); };
30
+ const abort = (): void => fail(new Error("CREATE2 mining aborted while reading stdin"));
31
+ const data = (chunk: Buffer): void => { size += chunk.length; if (size > 1024 * 1024) fail(new Error("request stdin exceeds 1 MiB limit")); else chunks.push(chunk); };
32
+ const end = (): void => { cleanup(); resolveInput(Buffer.concat(chunks).toString("utf8")); };
33
+ process.stdin.on("data", data); process.stdin.once("end", end); process.stdin.once("error", fail); signal.addEventListener("abort", abort, { once: true });
34
+ if (signal.aborted) abort();
35
+ });
36
+ }
37
+ function checkCancellation(signal: AbortSignal): void {
38
+ if (signal.aborted) throw new Error("CREATE2 mining aborted");
39
+ }
40
+ async function atomicOutput(file: string, content: string, signal: AbortSignal): Promise<void> {
41
+ // Resolve the parent, not the target: rename replaces a symlink rather than following it.
42
+ const parent = await realpath(dirname(resolve(file)));
43
+ const target = join(parent, basename(file));
44
+ const temporary = join(parent, `.${basename(file)}.${randomUUID()}.tmp`);
45
+ try {
46
+ checkCancellation(signal);
47
+ await writeFile(temporary, content, { flag: "wx", mode: 0o600, signal });
48
+ checkCancellation(signal);
49
+ await rename(temporary, target);
50
+ // A signal during rename cannot undo its atomic commit, but must suppress success reporting.
51
+ checkCancellation(signal);
52
+ }
53
+ finally { await unlink(temporary).catch(error => { if (error.code !== "ENOENT") throw error; }); }
54
+ }
55
+ export async function runCreate2MinerCli(args: string[] = process.argv.slice(3)): Promise<void> {
56
+ const controller = new AbortController();
57
+ const interrupt = (): void => { controller.abort(); };
58
+ process.on("SIGINT", interrupt); process.on("SIGTERM", interrupt);
59
+ try {
60
+ if (args.length === 1 && (args[0] === "--help" || args[0] === "-h")) { process.stdout.write(help); return; }
61
+ const values: Record<string, string> = {};
62
+ for (let index = 0; index < args.length; index += 2) {
63
+ const flag = args[index]; const value = args[index + 1];
64
+ if (!["--request", "--output", "--binary", "--timeout-ms"].includes(flag)) throw new Error(`Unknown miner option ${flag}; use miner --help`);
65
+ if (flag in values) throw new Error(`Duplicate miner option ${flag}`);
66
+ if (!value || value.startsWith("--")) throw new Error(`${flag} requires a value`);
67
+ values[flag] = value;
68
+ }
69
+ if (!values["--request"]) throw new Error("--request is required; use miner --help");
70
+ const input = values["--request"]; const output = values["--output"];
71
+ if (input !== "-" && output && await sameFile(input, output)) throw new Error("--output must not be the request file");
72
+ const timeout = values["--timeout-ms"];
73
+ if (timeout !== undefined && !/^[0-9]+$/.test(timeout)) throw new Error("--timeout-ms must be a positive integer");
74
+ const content = input === "-" ? await stdinJson(controller.signal) : await readFile(input, { encoding: "utf8", signal: controller.signal });
75
+ let request: unknown;
76
+ try { request = JSON.parse(content); } catch (cause) { throw new Error("Request is not valid JSON", { cause }); }
77
+ const result = await mineCreate2(normalizeCreate2MinerRequest(request), { binaryPath: values["--binary"], timeoutMs: timeout === undefined ? undefined : Number(timeout), signal: controller.signal });
78
+ const json = JSON.stringify(result, null, 2) + "\n";
79
+ checkCancellation(controller.signal);
80
+ if (output) await atomicOutput(output, json, controller.signal);
81
+ checkCancellation(controller.signal);
82
+ process.stdout.write(json);
83
+ } catch (error) {
84
+ process.stderr.write(`CREATE2 miner: ${error instanceof Error ? error.message : String(error)}\n`);
85
+ process.exitCode = 1;
86
+ } finally { process.off("SIGINT", interrupt); process.off("SIGTERM", interrupt); }
87
+ }
@@ -0,0 +1,5 @@
1
+ export type * from "./types";
2
+ export { normalizeCreate2MinerRequest, create2MinerRequestFromArtifact } from "./request";
3
+ export { verifyCreate2MinerResponse } from "./verify";
4
+ export { resolveCreate2MinerBinary } from "./binary";
5
+ export { mineCreate2 } from "./runner";
@@ -0,0 +1,54 @@
1
+ import { canonicalCreate2Hashes } from "../workflow/lib/create2Hashes";
2
+ import type { Create2MinerActualBackend, Create2MinerArtifactInput, Create2MinerBackend, NormalizedCreate2MinerRequest } from "./types";
3
+
4
+ export function record(value: unknown, label: string): Record<string, unknown> {
5
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error(`${label} must be an object`);
6
+ return value as Record<string, unknown>;
7
+ }
8
+ export function onlyKeys(value: Record<string, unknown>, keys: readonly string[], label: string): void {
9
+ for (const key of Object.keys(value)) if (!keys.includes(key)) throw new Error(`${label}: unsupported field ${key}`);
10
+ }
11
+ export function fixedHex(value: unknown, bytes: number, label: string): string {
12
+ if (typeof value !== "string" || !new RegExp(`^0x[0-9a-fA-F]{${bytes * 2}}$`).test(value)) throw new Error(`${label} must be a 0x-prefixed ${bytes}-byte hex value`);
13
+ return value.toLowerCase();
14
+ }
15
+ function integer(value: unknown, fallback: number, min: number, max: number, label: string): number {
16
+ const number = value === undefined ? fallback : value;
17
+ if (typeof number !== "number" || !Number.isInteger(number) || number < min || number > max) throw new Error(`${label} must be an integer from ${min} to ${max}`);
18
+ return number;
19
+ }
20
+ export function actualBackend(backend: Create2MinerBackend): Create2MinerActualBackend {
21
+ return backend === "auto" || backend === "gpu" ? (process.platform === "darwin" ? "metal" : "opencl") : backend;
22
+ }
23
+ const controls = ["factory", "caller", "leadingZeroBytes", "leadingPattern", "targetCount", "backend"];
24
+ export function normalizeCreate2MinerRequest(input: unknown): NormalizedCreate2MinerRequest {
25
+ const value = record(input, "request");
26
+ const scheme = value.scheme === undefined ? "evm" : value.scheme;
27
+ if (scheme !== "evm" && scheme !== "zksync-eravm") throw new Error("scheme must be evm or zksync-eravm");
28
+ onlyKeys(value, [...controls, "scheme", ...(scheme === "evm" ? ["initCodeHash"] : ["bytecodeHash", "constructorInputHash"])], "request");
29
+ const backend = value.backend === undefined ? "auto" : value.backend;
30
+ if (backend !== "auto" && backend !== "cpu" && backend !== "gpu" && backend !== "metal" && backend !== "opencl") throw new Error("backend must be auto, cpu, gpu, metal or opencl");
31
+ const leadingPattern = integer(value.leadingPattern, 0, 0, 255, "leadingPattern");
32
+ if (backend !== "cpu" && (leadingPattern & 15) !== (leadingPattern >> 4)) throw new Error("GPU leadingPattern requires a repeated-nibble byte (0x00, 0x11, …, 0xff); use backend cpu for other patterns");
33
+ if (backend === "metal" && process.platform !== "darwin") throw new Error("Metal backend requires macOS; use cpu or opencl on this platform");
34
+ const common = {
35
+ factory: fixedHex(value.factory, 20, "factory"), caller: fixedHex(value.caller, 20, "caller"),
36
+ leadingZeroBytes: integer(value.leadingZeroBytes, 0, 0, 20, "leadingZeroBytes"), leadingPattern,
37
+ targetCount: integer(value.targetCount, 1, 1, 100, "targetCount"), backend: backend as Create2MinerBackend,
38
+ };
39
+ return scheme === "evm"
40
+ ? { ...common, scheme, initCodeHash: fixedHex(value.initCodeHash, 32, "initCodeHash") }
41
+ : { ...common, scheme, bytecodeHash: fixedHex(value.bytecodeHash, 32, "bytecodeHash"), constructorInputHash: fixedHex(value.constructorInputHash, 32, "constructorInputHash") };
42
+ }
43
+ export function create2MinerRequestFromArtifact(input: Create2MinerArtifactInput): NormalizedCreate2MinerRequest {
44
+ const value = record(input, "artifact request");
45
+ onlyKeys(value, [...controls, "scheme", "artifact", "args"], "artifact request");
46
+ const artifact = record(value.artifact, "artifact");
47
+ if (typeof artifact.bytecode !== "string" || !/^0x(?:[0-9a-fA-F]{2})+$/.test(artifact.bytecode)) throw new Error("artifact bytecode must be non-empty, linked, byte-aligned hex");
48
+ if (!Array.isArray(value.args)) throw new Error("artifact args must be an array");
49
+ // Validate format and hash constructor arguments through the workflow's canonical implementation.
50
+ if (value.scheme !== undefined && value.scheme !== "evm" && value.scheme !== "zksync-eravm") throw new Error("scheme must be evm or zksync-eravm");
51
+ const { artifact: _artifact, args: _args, scheme: _scheme, ...rest } = value;
52
+ const hashes = canonicalCreate2Hashes(input);
53
+ return normalizeCreate2MinerRequest({ ...rest, ...hashes });
54
+ }