gate-evm-tools 1.0.28 → 1.2.0

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 (742) hide show
  1. package/README.md +47 -18
  2. package/bin/cli.js +6 -0
  3. package/bin/delivery.cjs +52 -0
  4. package/bin/manifest-bootstrap.js +4 -15
  5. package/dist/commands/check.d.ts.map +1 -1
  6. package/dist/commands/check.js +26 -2
  7. package/dist/commands/check.js.map +1 -1
  8. package/dist/commands/plan/file-store.d.ts.map +1 -0
  9. package/dist/commands/plan/generate-deployment.d.ts +48 -0
  10. package/dist/commands/plan/generate-deployment.d.ts.map +1 -0
  11. package/dist/commands/plan/generate-deployment.js +211 -0
  12. package/dist/commands/plan/generate-deployment.js.map +1 -0
  13. package/dist/commands/plan/helpers.d.ts.map +1 -0
  14. package/dist/commands/plan/index.d.ts +3 -0
  15. package/dist/commands/plan/index.d.ts.map +1 -0
  16. package/dist/commands/plan/index.js +88 -0
  17. package/dist/commands/plan/index.js.map +1 -0
  18. package/dist/commands/sync.js +1 -1
  19. package/dist/commands/sync.js.map +1 -1
  20. package/dist/core/BytecodeChecker.d.ts.map +1 -1
  21. package/dist/core/BytecodeChecker.js +27 -8
  22. package/dist/core/BytecodeChecker.js.map +1 -1
  23. package/dist/core/preparation/artifacts.d.ts +2 -0
  24. package/dist/core/preparation/artifacts.d.ts.map +1 -1
  25. package/dist/core/preparation/artifacts.js +9 -3
  26. package/dist/core/preparation/artifacts.js.map +1 -1
  27. package/dist/core/preparation/batch.d.ts +26 -0
  28. package/dist/core/preparation/batch.d.ts.map +1 -0
  29. package/dist/core/preparation/batch.js +72 -0
  30. package/dist/core/preparation/batch.js.map +1 -0
  31. package/dist/core/preparation/evm.d.ts +61 -6
  32. package/dist/core/preparation/evm.d.ts.map +1 -1
  33. package/dist/core/preparation/evm.js +122 -34
  34. package/dist/core/preparation/evm.js.map +1 -1
  35. package/dist/core/preparation/evmManifestSync.d.ts +68 -0
  36. package/dist/core/preparation/evmManifestSync.d.ts.map +1 -0
  37. package/dist/core/preparation/evmManifestSync.js +154 -0
  38. package/dist/core/preparation/evmManifestSync.js.map +1 -0
  39. package/dist/core/preparation/index.d.ts +40 -2
  40. package/dist/core/preparation/index.d.ts.map +1 -1
  41. package/dist/core/preparation/index.js +3 -3
  42. package/dist/core/preparation/index.js.map +1 -1
  43. package/dist/core/preparation/manifest.d.ts +17 -3
  44. package/dist/core/preparation/manifest.d.ts.map +1 -1
  45. package/dist/core/preparation/manifest.js +23 -28
  46. package/dist/core/preparation/manifest.js.map +1 -1
  47. package/dist/core/preparation/normalize.d.ts.map +1 -1
  48. package/dist/core/preparation/normalize.js +67 -20
  49. package/dist/core/preparation/normalize.js.map +1 -1
  50. package/dist/core/preparation/transparent.d.ts +23 -0
  51. package/dist/core/preparation/transparent.d.ts.map +1 -0
  52. package/dist/core/preparation/transparent.js +103 -0
  53. package/dist/core/preparation/transparent.js.map +1 -0
  54. package/dist/core/preparation/types.d.ts +54 -7
  55. package/dist/core/preparation/types.d.ts.map +1 -1
  56. package/dist/core/preparation/zksync.d.ts.map +1 -1
  57. package/dist/core/preparation/zksync.js +2 -0
  58. package/dist/core/preparation/zksync.js.map +1 -1
  59. package/dist/custody/credential.d.ts.map +1 -1
  60. package/dist/custody/credential.js +1 -6
  61. package/dist/custody/credential.js.map +1 -1
  62. package/dist/custody/hardhat-runtime.d.ts.map +1 -1
  63. package/dist/custody/hardhat-runtime.js +2 -0
  64. package/dist/custody/hardhat-runtime.js.map +1 -1
  65. package/dist/custody/hardhat.d.ts +1 -0
  66. package/dist/custody/hardhat.d.ts.map +1 -1
  67. package/dist/custody/hardhat.js +1 -0
  68. package/dist/custody/hardhat.js.map +1 -1
  69. package/dist/custody/index.d.ts +1 -0
  70. package/dist/custody/index.d.ts.map +1 -1
  71. package/dist/custody/index.js +1 -0
  72. package/dist/custody/index.js.map +1 -1
  73. package/dist/custody/provider-wait.d.ts +13 -0
  74. package/dist/custody/provider-wait.d.ts.map +1 -0
  75. package/dist/custody/provider-wait.js +78 -0
  76. package/dist/custody/provider-wait.js.map +1 -0
  77. package/dist/delivery/policy.d.ts +6 -0
  78. package/dist/delivery/policy.d.ts.map +1 -0
  79. package/dist/delivery/policy.js +24 -0
  80. package/dist/delivery/policy.js.map +1 -0
  81. package/dist/deployment-evm/index.d.ts +4 -0
  82. package/dist/deployment-evm/index.d.ts.map +1 -0
  83. package/dist/deployment-evm/index.js +3 -0
  84. package/dist/deployment-evm/index.js.map +1 -0
  85. package/dist/index.d.ts.map +1 -1
  86. package/dist/index.js +9 -0
  87. package/dist/index.js.map +1 -1
  88. package/dist/sync/index.d.ts +15 -0
  89. package/dist/sync/index.d.ts.map +1 -1
  90. package/dist/sync/index.js +13 -0
  91. package/dist/sync/index.js.map +1 -1
  92. package/dist/types.d.ts +3 -0
  93. package/dist/types.d.ts.map +1 -1
  94. package/dist/workflow/index.d.ts +10 -2
  95. package/dist/workflow/index.d.ts.map +1 -1
  96. package/dist/workflow/index.js +6 -0
  97. package/dist/workflow/index.js.map +1 -1
  98. package/dist-cjs/core/BytecodeChecker.js +526 -0
  99. package/dist-cjs/core/BytecodeChecker.js.map +1 -0
  100. package/dist-cjs/core/legacyProxyArtifact.js +42 -0
  101. package/dist-cjs/core/legacyProxyArtifact.js.map +1 -0
  102. package/dist-cjs/core/preparation/artifacts.js +11 -4
  103. package/dist-cjs/core/preparation/artifacts.js.map +1 -1
  104. package/dist-cjs/core/preparation/batch.js +76 -0
  105. package/dist-cjs/core/preparation/batch.js.map +1 -0
  106. package/dist-cjs/core/preparation/evm.js +128 -37
  107. package/dist-cjs/core/preparation/evm.js.map +1 -1
  108. package/dist-cjs/core/preparation/evmManifestSync.js +163 -0
  109. package/dist-cjs/core/preparation/evmManifestSync.js.map +1 -0
  110. package/dist-cjs/core/preparation/index.js +3 -3
  111. package/dist-cjs/core/preparation/index.js.map +1 -1
  112. package/dist-cjs/core/preparation/manifest.js +25 -30
  113. package/dist-cjs/core/preparation/manifest.js.map +1 -1
  114. package/dist-cjs/core/preparation/normalize.js +67 -20
  115. package/dist-cjs/core/preparation/normalize.js.map +1 -1
  116. package/dist-cjs/core/preparation/transparent.js +110 -0
  117. package/dist-cjs/core/preparation/transparent.js.map +1 -0
  118. package/dist-cjs/core/preparation/zksync.js +2 -0
  119. package/dist-cjs/core/preparation/zksync.js.map +1 -1
  120. package/dist-cjs/custody/credential.js +1 -6
  121. package/dist-cjs/custody/credential.js.map +1 -1
  122. package/dist-cjs/custody/hardhat-runtime.js +2 -0
  123. package/dist-cjs/custody/hardhat-runtime.js.map +1 -1
  124. package/dist-cjs/custody/hardhat.js +3 -1
  125. package/dist-cjs/custody/hardhat.js.map +1 -1
  126. package/dist-cjs/custody/index.js +3 -1
  127. package/dist-cjs/custody/index.js.map +1 -1
  128. package/dist-cjs/custody/provider-wait.js +81 -0
  129. package/dist-cjs/custody/provider-wait.js.map +1 -0
  130. package/dist-cjs/delivery/policy.js +29 -0
  131. package/dist-cjs/delivery/policy.js.map +1 -0
  132. package/dist-cjs/deployment-evm/index.js +10 -0
  133. package/dist-cjs/deployment-evm/index.js.map +1 -0
  134. package/dist-cjs/sync/index.js +13 -0
  135. package/dist-cjs/sync/index.js.map +1 -1
  136. package/dist-cjs/workflow/index.js +22 -1
  137. package/dist-cjs/workflow/index.js.map +1 -1
  138. package/dist-runtime/config/hardhatAdapters.js +2 -1
  139. package/dist-runtime/config/hardhatAdapters.js.map +1 -1
  140. package/dist-runtime/config/openzeppelin.d.ts +2 -1
  141. package/dist-runtime/config/openzeppelin.js +2 -19
  142. package/dist-runtime/config/openzeppelin.js.map +1 -1
  143. package/dist-runtime/delivery/abi.d.ts +14 -0
  144. package/dist-runtime/delivery/abi.js +161 -0
  145. package/dist-runtime/delivery/abi.js.map +1 -0
  146. package/dist-runtime/delivery/aggregate-bootstrap.d.ts +12 -0
  147. package/dist-runtime/delivery/aggregate-bootstrap.js +42 -0
  148. package/dist-runtime/delivery/aggregate-bootstrap.js.map +1 -0
  149. package/dist-runtime/delivery/aggregate-channel.d.ts +28 -0
  150. package/dist-runtime/delivery/aggregate-channel.js +159 -0
  151. package/dist-runtime/delivery/aggregate-channel.js.map +1 -0
  152. package/dist-runtime/delivery/aggregate-diagnostics.d.ts +14 -0
  153. package/dist-runtime/delivery/aggregate-diagnostics.js +73 -0
  154. package/dist-runtime/delivery/aggregate-diagnostics.js.map +1 -0
  155. package/dist-runtime/delivery/aggregate-inputs.d.ts +172 -0
  156. package/dist-runtime/delivery/aggregate-inputs.js +57 -0
  157. package/dist-runtime/delivery/aggregate-inputs.js.map +1 -0
  158. package/dist-runtime/delivery/aggregate-source.d.ts +25 -0
  159. package/dist-runtime/delivery/aggregate-source.js +87 -0
  160. package/dist-runtime/delivery/aggregate-source.js.map +1 -0
  161. package/dist-runtime/delivery/aggregate-worker.d.ts +1 -0
  162. package/dist-runtime/delivery/aggregate-worker.js +199 -0
  163. package/dist-runtime/delivery/aggregate-worker.js.map +1 -0
  164. package/dist-runtime/delivery/aggregate.d.ts +51 -0
  165. package/dist-runtime/delivery/aggregate.js +190 -0
  166. package/dist-runtime/delivery/aggregate.js.map +1 -0
  167. package/dist-runtime/delivery/bindings.d.ts +21 -0
  168. package/dist-runtime/delivery/bindings.js +53 -0
  169. package/dist-runtime/delivery/bindings.js.map +1 -0
  170. package/dist-runtime/delivery/business-extension.d.ts +10 -0
  171. package/dist-runtime/delivery/business-extension.js +38 -0
  172. package/dist-runtime/delivery/business-extension.js.map +1 -0
  173. package/dist-runtime/delivery/calldata-archive.d.ts +18 -0
  174. package/dist-runtime/delivery/calldata-archive.js +31 -0
  175. package/dist-runtime/delivery/calldata-archive.js.map +1 -0
  176. package/dist-runtime/delivery/calldata-details.d.ts +47 -0
  177. package/dist-runtime/delivery/calldata-details.js +94 -0
  178. package/dist-runtime/delivery/calldata-details.js.map +1 -0
  179. package/dist-runtime/delivery/calldata-format.d.ts +4 -0
  180. package/dist-runtime/delivery/calldata-format.js +17 -0
  181. package/dist-runtime/delivery/calldata-format.js.map +1 -0
  182. package/dist-runtime/delivery/calldata-preparations.d.ts +13 -0
  183. package/dist-runtime/delivery/calldata-preparations.js +85 -0
  184. package/dist-runtime/delivery/calldata-preparations.js.map +1 -0
  185. package/dist-runtime/delivery/calldata-review.d.ts +44 -0
  186. package/dist-runtime/delivery/calldata-review.js +131 -0
  187. package/dist-runtime/delivery/calldata-review.js.map +1 -0
  188. package/dist-runtime/delivery/check-code.d.ts +19 -0
  189. package/dist-runtime/delivery/check-code.js +63 -0
  190. package/dist-runtime/delivery/check-code.js.map +1 -0
  191. package/dist-runtime/delivery/closure-format.d.ts +77 -0
  192. package/dist-runtime/delivery/closure-format.js +225 -0
  193. package/dist-runtime/delivery/closure-format.js.map +1 -0
  194. package/dist-runtime/delivery/codec-pin.d.ts +2 -0
  195. package/dist-runtime/delivery/codec-pin.js +7 -0
  196. package/dist-runtime/delivery/codec-pin.js.map +1 -0
  197. package/dist-runtime/delivery/codec.d.ts +19 -0
  198. package/dist-runtime/delivery/codec.js +73 -0
  199. package/dist-runtime/delivery/codec.js.map +1 -0
  200. package/dist-runtime/delivery/compiler-dependency-pins.d.ts +7 -0
  201. package/dist-runtime/delivery/compiler-dependency-pins.js +1689 -0
  202. package/dist-runtime/delivery/compiler-dependency-pins.js.map +1 -0
  203. package/dist-runtime/delivery/compiler-files.d.ts +40 -0
  204. package/dist-runtime/delivery/compiler-files.js +222 -0
  205. package/dist-runtime/delivery/compiler-files.js.map +1 -0
  206. package/dist-runtime/delivery/compiler-io.d.ts +2 -0
  207. package/dist-runtime/delivery/compiler-io.js +13 -0
  208. package/dist-runtime/delivery/compiler-io.js.map +1 -0
  209. package/dist-runtime/delivery/compiler-pins.d.ts +10 -0
  210. package/dist-runtime/delivery/compiler-pins.js +147 -0
  211. package/dist-runtime/delivery/compiler-pins.js.map +1 -0
  212. package/dist-runtime/delivery/compiler.d.ts +188 -0
  213. package/dist-runtime/delivery/compiler.js +851 -0
  214. package/dist-runtime/delivery/compiler.js.map +1 -0
  215. package/dist-runtime/delivery/config.d.ts +48 -0
  216. package/dist-runtime/delivery/config.js +124 -0
  217. package/dist-runtime/delivery/config.js.map +1 -0
  218. package/dist-runtime/delivery/configuration-definition.d.ts +31 -0
  219. package/dist-runtime/delivery/configuration-definition.js +343 -0
  220. package/dist-runtime/delivery/configuration-definition.js.map +1 -0
  221. package/dist-runtime/delivery/configuration-hre.d.ts +17 -0
  222. package/dist-runtime/delivery/configuration-hre.js +198 -0
  223. package/dist-runtime/delivery/configuration-hre.js.map +1 -0
  224. package/dist-runtime/delivery/configuration-runtime.d.ts +36 -0
  225. package/dist-runtime/delivery/configuration-runtime.js +248 -0
  226. package/dist-runtime/delivery/configuration-runtime.js.map +1 -0
  227. package/dist-runtime/delivery/configuration.d.ts +35 -0
  228. package/dist-runtime/delivery/configuration.js +86 -0
  229. package/dist-runtime/delivery/configuration.js.map +1 -0
  230. package/dist-runtime/delivery/contract-source.d.ts +14 -0
  231. package/dist-runtime/delivery/contract-source.js +138 -0
  232. package/dist-runtime/delivery/contract-source.js.map +1 -0
  233. package/dist-runtime/delivery/create2.d.ts +3 -0
  234. package/dist-runtime/delivery/create2.js +48 -0
  235. package/dist-runtime/delivery/create2.js.map +1 -0
  236. package/dist-runtime/delivery/custom-closure.d.ts +27 -0
  237. package/dist-runtime/delivery/custom-closure.js +818 -0
  238. package/dist-runtime/delivery/custom-closure.js.map +1 -0
  239. package/dist-runtime/delivery/custom-format.d.ts +35 -0
  240. package/dist-runtime/delivery/custom-format.js +410 -0
  241. package/dist-runtime/delivery/custom-format.js.map +1 -0
  242. package/dist-runtime/delivery/custom.d.ts +32 -0
  243. package/dist-runtime/delivery/custom.js +158 -0
  244. package/dist-runtime/delivery/custom.js.map +1 -0
  245. package/dist-runtime/delivery/data.d.ts +7 -0
  246. package/dist-runtime/delivery/data.js +86 -0
  247. package/dist-runtime/delivery/data.js.map +1 -0
  248. package/dist-runtime/delivery/development.d.ts +92 -0
  249. package/dist-runtime/delivery/development.js +406 -0
  250. package/dist-runtime/delivery/development.js.map +1 -0
  251. package/dist-runtime/delivery/engine.d.ts +9 -0
  252. package/dist-runtime/delivery/engine.js +23 -0
  253. package/dist-runtime/delivery/engine.js.map +1 -0
  254. package/dist-runtime/delivery/eoa-observation.d.ts +43 -0
  255. package/dist-runtime/delivery/eoa-observation.js +145 -0
  256. package/dist-runtime/delivery/eoa-observation.js.map +1 -0
  257. package/dist-runtime/delivery/eoa-signed.d.ts +2 -0
  258. package/dist-runtime/delivery/eoa-signed.js +74 -0
  259. package/dist-runtime/delivery/eoa-signed.js.map +1 -0
  260. package/dist-runtime/delivery/eoa.d.ts +82 -0
  261. package/dist-runtime/delivery/eoa.js +274 -0
  262. package/dist-runtime/delivery/eoa.js.map +1 -0
  263. package/dist-runtime/delivery/execution-db.d.ts +20 -0
  264. package/dist-runtime/delivery/execution-db.js +153 -0
  265. package/dist-runtime/delivery/execution-db.js.map +1 -0
  266. package/dist-runtime/delivery/execution-files.d.ts +9 -0
  267. package/dist-runtime/delivery/execution-files.js +138 -0
  268. package/dist-runtime/delivery/execution-files.js.map +1 -0
  269. package/dist-runtime/delivery/execution-identity.d.ts +15 -0
  270. package/dist-runtime/delivery/execution-identity.js +33 -0
  271. package/dist-runtime/delivery/execution-identity.js.map +1 -0
  272. package/dist-runtime/delivery/execution-model.d.ts +56 -0
  273. package/dist-runtime/delivery/execution-model.js +66 -0
  274. package/dist-runtime/delivery/execution-model.js.map +1 -0
  275. package/dist-runtime/delivery/execution-store.d.ts +48 -0
  276. package/dist-runtime/delivery/execution-store.js +361 -0
  277. package/dist-runtime/delivery/execution-store.js.map +1 -0
  278. package/dist-runtime/delivery/existing-code.d.ts +37 -0
  279. package/dist-runtime/delivery/existing-code.js +83 -0
  280. package/dist-runtime/delivery/existing-code.js.map +1 -0
  281. package/dist-runtime/delivery/export.d.ts +51 -0
  282. package/dist-runtime/delivery/export.js +69 -0
  283. package/dist-runtime/delivery/export.js.map +1 -0
  284. package/dist-runtime/delivery/forkAudit.d.ts +119 -0
  285. package/dist-runtime/delivery/forkAudit.js +473 -0
  286. package/dist-runtime/delivery/forkAudit.js.map +1 -0
  287. package/dist-runtime/delivery/hardhat.d.ts +3 -0
  288. package/dist-runtime/delivery/hardhat.js +45 -0
  289. package/dist-runtime/delivery/hardhat.js.map +1 -0
  290. package/dist-runtime/delivery/history-registration.d.ts +2 -0
  291. package/dist-runtime/delivery/history-registration.js +17 -0
  292. package/dist-runtime/delivery/history-registration.js.map +1 -0
  293. package/dist-runtime/delivery/identities.d.ts +22 -0
  294. package/dist-runtime/delivery/identities.js +97 -0
  295. package/dist-runtime/delivery/identities.js.map +1 -0
  296. package/dist-runtime/delivery/input-files.d.ts +5 -0
  297. package/dist-runtime/delivery/input-files.js +70 -0
  298. package/dist-runtime/delivery/input-files.js.map +1 -0
  299. package/dist-runtime/delivery/inputs.d.ts +62 -0
  300. package/dist-runtime/delivery/inputs.js +194 -0
  301. package/dist-runtime/delivery/inputs.js.map +1 -0
  302. package/dist-runtime/delivery/journal.d.ts +35 -0
  303. package/dist-runtime/delivery/journal.js +278 -0
  304. package/dist-runtime/delivery/journal.js.map +1 -0
  305. package/dist-runtime/delivery/manifest.d.ts +14 -0
  306. package/dist-runtime/delivery/manifest.js +68 -0
  307. package/dist-runtime/delivery/manifest.js.map +1 -0
  308. package/dist-runtime/delivery/materialization.d.ts +20 -0
  309. package/dist-runtime/delivery/materialization.js +138 -0
  310. package/dist-runtime/delivery/materialization.js.map +1 -0
  311. package/dist-runtime/delivery/observations.d.ts +31 -0
  312. package/dist-runtime/delivery/observations.js +38 -0
  313. package/dist-runtime/delivery/observations.js.map +1 -0
  314. package/dist-runtime/delivery/parameter-defaults.d.ts +10 -0
  315. package/dist-runtime/delivery/parameter-defaults.js +86 -0
  316. package/dist-runtime/delivery/parameter-defaults.js.map +1 -0
  317. package/dist-runtime/delivery/parameters.d.ts +55 -0
  318. package/dist-runtime/delivery/parameters.js +279 -0
  319. package/dist-runtime/delivery/parameters.js.map +1 -0
  320. package/dist-runtime/delivery/pending.d.ts +70 -0
  321. package/dist-runtime/delivery/pending.js +99 -0
  322. package/dist-runtime/delivery/pending.js.map +1 -0
  323. package/dist-runtime/delivery/plan.d.ts +50 -0
  324. package/dist-runtime/delivery/plan.js +209 -0
  325. package/dist-runtime/delivery/plan.js.map +1 -0
  326. package/dist-runtime/delivery/planning.d.ts +84 -0
  327. package/dist-runtime/delivery/planning.js +318 -0
  328. package/dist-runtime/delivery/planning.js.map +1 -0
  329. package/dist-runtime/delivery/policy.d.ts +4 -0
  330. package/dist-runtime/delivery/policy.js +9 -0
  331. package/dist-runtime/delivery/policy.js.map +1 -0
  332. package/dist-runtime/delivery/preparation.d.ts +6 -0
  333. package/dist-runtime/delivery/preparation.js +178 -0
  334. package/dist-runtime/delivery/preparation.js.map +1 -0
  335. package/dist-runtime/delivery/production-environment.d.ts +2 -0
  336. package/dist-runtime/delivery/production-environment.js +13 -0
  337. package/dist-runtime/delivery/production-environment.js.map +1 -0
  338. package/dist-runtime/delivery/production-finalization.d.ts +86 -0
  339. package/dist-runtime/delivery/production-finalization.js +292 -0
  340. package/dist-runtime/delivery/production-finalization.js.map +1 -0
  341. package/dist-runtime/delivery/production-intent.d.ts +2 -0
  342. package/dist-runtime/delivery/production-intent.js +16 -0
  343. package/dist-runtime/delivery/production-intent.js.map +1 -0
  344. package/dist-runtime/delivery/production.d.ts +582 -0
  345. package/dist-runtime/delivery/production.js +445 -0
  346. package/dist-runtime/delivery/production.js.map +1 -0
  347. package/dist-runtime/delivery/project-files.d.ts +8 -0
  348. package/dist-runtime/delivery/project-files.js +87 -0
  349. package/dist-runtime/delivery/project-files.js.map +1 -0
  350. package/dist-runtime/delivery/project-rpc.d.ts +19 -0
  351. package/dist-runtime/delivery/project-rpc.js +138 -0
  352. package/dist-runtime/delivery/project-rpc.js.map +1 -0
  353. package/dist-runtime/delivery/project.d.ts +17 -0
  354. package/dist-runtime/delivery/project.js +170 -0
  355. package/dist-runtime/delivery/project.js.map +1 -0
  356. package/dist-runtime/delivery/protocol.d.ts +49 -0
  357. package/dist-runtime/delivery/protocol.js +112 -0
  358. package/dist-runtime/delivery/protocol.js.map +1 -0
  359. package/dist-runtime/delivery/public-calldata.d.ts +25 -0
  360. package/dist-runtime/delivery/public-calldata.js +97 -0
  361. package/dist-runtime/delivery/public-calldata.js.map +1 -0
  362. package/dist-runtime/delivery/references.d.ts +19 -0
  363. package/dist-runtime/delivery/references.js +84 -0
  364. package/dist-runtime/delivery/references.js.map +1 -0
  365. package/dist-runtime/delivery/release-graph.d.ts +97 -0
  366. package/dist-runtime/delivery/release-graph.js +139 -0
  367. package/dist-runtime/delivery/release-graph.js.map +1 -0
  368. package/dist-runtime/delivery/release-history-capture.d.ts +7 -0
  369. package/dist-runtime/delivery/release-history-capture.js +76 -0
  370. package/dist-runtime/delivery/release-history-capture.js.map +1 -0
  371. package/dist-runtime/delivery/release-history.d.ts +43 -0
  372. package/dist-runtime/delivery/release-history.js +322 -0
  373. package/dist-runtime/delivery/release-history.js.map +1 -0
  374. package/dist-runtime/delivery/release-inputs.d.ts +33 -0
  375. package/dist-runtime/delivery/release-inputs.js +129 -0
  376. package/dist-runtime/delivery/release-inputs.js.map +1 -0
  377. package/dist-runtime/delivery/release.d.ts +196 -0
  378. package/dist-runtime/delivery/release.js +261 -0
  379. package/dist-runtime/delivery/release.js.map +1 -0
  380. package/dist-runtime/delivery/safe-manifest.d.ts +9 -0
  381. package/dist-runtime/delivery/safe-manifest.js +13 -0
  382. package/dist-runtime/delivery/safe-manifest.js.map +1 -0
  383. package/dist-runtime/delivery/safe-observation.d.ts +30 -0
  384. package/dist-runtime/delivery/safe-observation.js +487 -0
  385. package/dist-runtime/delivery/safe-observation.js.map +1 -0
  386. package/dist-runtime/delivery/safe-prepare.d.ts +13 -0
  387. package/dist-runtime/delivery/safe-prepare.js +81 -0
  388. package/dist-runtime/delivery/safe-prepare.js.map +1 -0
  389. package/dist-runtime/delivery/safe.d.ts +92 -0
  390. package/dist-runtime/delivery/safe.js +254 -0
  391. package/dist-runtime/delivery/safe.js.map +1 -0
  392. package/dist-runtime/delivery/same-fork-baseline.d.ts +8 -0
  393. package/dist-runtime/delivery/same-fork-baseline.js +21 -0
  394. package/dist-runtime/delivery/same-fork-baseline.js.map +1 -0
  395. package/dist-runtime/delivery/setup.d.ts +31 -0
  396. package/dist-runtime/delivery/setup.js +230 -0
  397. package/dist-runtime/delivery/setup.js.map +1 -0
  398. package/dist-runtime/delivery/source.d.ts +42 -0
  399. package/dist-runtime/delivery/source.js +139 -0
  400. package/dist-runtime/delivery/source.js.map +1 -0
  401. package/dist-runtime/delivery/target-fields.d.ts +2 -0
  402. package/dist-runtime/delivery/target-fields.js +11 -0
  403. package/dist-runtime/delivery/target-fields.js.map +1 -0
  404. package/dist-runtime/delivery/task-identity.d.ts +23 -0
  405. package/dist-runtime/delivery/task-identity.js +109 -0
  406. package/dist-runtime/delivery/task-identity.js.map +1 -0
  407. package/dist-runtime/delivery/toolchain.d.ts +3 -0
  408. package/dist-runtime/delivery/toolchain.js +52 -0
  409. package/dist-runtime/delivery/toolchain.js.map +1 -0
  410. package/dist-runtime/delivery/validation.d.ts +9 -0
  411. package/dist-runtime/delivery/validation.js +155 -0
  412. package/dist-runtime/delivery/validation.js.map +1 -0
  413. package/dist-runtime/delivery/verification.d.ts +16 -0
  414. package/dist-runtime/delivery/verification.js +65 -0
  415. package/dist-runtime/delivery/verification.js.map +1 -0
  416. package/dist-runtime/migrate.js +1 -0
  417. package/dist-runtime/migrate.js.map +1 -1
  418. package/dist-runtime/miner/binary.d.ts +2 -0
  419. package/dist-runtime/miner/binary.js +54 -0
  420. package/dist-runtime/miner/binary.js.map +1 -0
  421. package/dist-runtime/miner/cli.d.ts +1 -0
  422. package/dist-runtime/miner/cli.js +131 -0
  423. package/dist-runtime/miner/cli.js.map +1 -0
  424. package/dist-runtime/miner/index.d.ts +5 -0
  425. package/dist-runtime/miner/index.js +13 -0
  426. package/dist-runtime/miner/index.js.map +1 -0
  427. package/dist-runtime/miner/request.d.ts +7 -0
  428. package/dist-runtime/miner/request.js +73 -0
  429. package/dist-runtime/miner/request.js.map +1 -0
  430. package/dist-runtime/miner/runner.d.ts +2 -0
  431. package/dist-runtime/miner/runner.js +131 -0
  432. package/dist-runtime/miner/runner.js.map +1 -0
  433. package/dist-runtime/miner/types.d.ts +89 -0
  434. package/dist-runtime/miner/types.js +3 -0
  435. package/dist-runtime/miner/types.js.map +1 -0
  436. package/dist-runtime/miner/verify.d.ts +2 -0
  437. package/dist-runtime/miner/verify.js +75 -0
  438. package/dist-runtime/miner/verify.js.map +1 -0
  439. package/dist-runtime/runtime-identity.json +2 -2
  440. package/dist-runtime/vendor/plan-codec/index.cjs +897 -0
  441. package/dist-runtime/vendor/plan-codec/index.d.cts +38 -0
  442. package/dist-runtime/vendor/plan-codec/provenance.json +25 -0
  443. package/dist-runtime/workflow/engine.d.ts +14 -0
  444. package/dist-runtime/workflow/engine.js +160 -0
  445. package/dist-runtime/workflow/engine.js.map +1 -0
  446. package/dist-runtime/workflow/lib/authority.d.ts +6 -3
  447. package/dist-runtime/workflow/lib/authority.js.map +1 -1
  448. package/dist-runtime/workflow/lib/calls.d.ts +1 -1
  449. package/dist-runtime/workflow/lib/calls.js +44 -34
  450. package/dist-runtime/workflow/lib/calls.js.map +1 -1
  451. package/dist-runtime/workflow/lib/canonicalData.d.ts +8 -0
  452. package/dist-runtime/workflow/lib/canonicalData.js +68 -0
  453. package/dist-runtime/workflow/lib/canonicalData.js.map +1 -0
  454. package/dist-runtime/workflow/lib/checkCodeRunner.js +7 -4
  455. package/dist-runtime/workflow/lib/checkCodeRunner.js.map +1 -1
  456. package/dist-runtime/workflow/lib/config.d.ts +3 -1
  457. package/dist-runtime/workflow/lib/config.js.map +1 -1
  458. package/dist-runtime/workflow/lib/context.d.ts +77 -0
  459. package/dist-runtime/workflow/lib/context.js +3 -0
  460. package/dist-runtime/workflow/lib/context.js.map +1 -0
  461. package/dist-runtime/workflow/lib/create2.d.ts +5 -27
  462. package/dist-runtime/workflow/lib/create2.js +11 -79
  463. package/dist-runtime/workflow/lib/create2.js.map +1 -1
  464. package/dist-runtime/workflow/lib/deploymentInfo.d.ts +2 -0
  465. package/dist-runtime/workflow/lib/deploymentInfo.js +6 -0
  466. package/dist-runtime/workflow/lib/deploymentInfo.js.map +1 -1
  467. package/dist-runtime/workflow/lib/deploymentRecords.d.ts +2 -0
  468. package/dist-runtime/workflow/lib/deploymentRecords.js +1 -1
  469. package/dist-runtime/workflow/lib/deploymentRecords.js.map +1 -1
  470. package/dist-runtime/workflow/lib/deployments.d.ts +5 -5
  471. package/dist-runtime/workflow/lib/deployments.js +5 -13
  472. package/dist-runtime/workflow/lib/deployments.js.map +1 -1
  473. package/dist-runtime/workflow/lib/evidencePorts.d.ts +55 -0
  474. package/dist-runtime/workflow/lib/evidencePorts.js +3 -0
  475. package/dist-runtime/workflow/lib/evidencePorts.js.map +1 -0
  476. package/dist-runtime/workflow/lib/executionPlan.d.ts +4 -42
  477. package/dist-runtime/workflow/lib/executionPlan.js +15 -210
  478. package/dist-runtime/workflow/lib/executionPlan.js.map +1 -1
  479. package/dist-runtime/workflow/lib/externalExecutionScanner.js +2 -1
  480. package/dist-runtime/workflow/lib/externalExecutionScanner.js.map +1 -1
  481. package/dist-runtime/workflow/lib/gateTool.d.ts +6 -2
  482. package/dist-runtime/workflow/lib/gateTool.js +22 -12
  483. package/dist-runtime/workflow/lib/gateTool.js.map +1 -1
  484. package/dist-runtime/workflow/lib/gateToolSync.d.ts +4 -1
  485. package/dist-runtime/workflow/lib/gateToolSync.js +8 -2
  486. package/dist-runtime/workflow/lib/gateToolSync.js.map +1 -1
  487. package/dist-runtime/workflow/lib/operationNames.d.ts +3 -0
  488. package/dist-runtime/workflow/lib/operationNames.js +34 -0
  489. package/dist-runtime/workflow/lib/operationNames.js.map +1 -0
  490. package/dist-runtime/workflow/lib/parameters.d.ts +1 -1
  491. package/dist-runtime/workflow/lib/parameters.js +11 -22
  492. package/dist-runtime/workflow/lib/parameters.js.map +1 -1
  493. package/dist-runtime/workflow/lib/pendingDeploymentReuse.js +18 -52
  494. package/dist-runtime/workflow/lib/pendingDeploymentReuse.js.map +1 -1
  495. package/dist-runtime/workflow/lib/pendingUupsBinding.d.ts +42 -0
  496. package/dist-runtime/workflow/lib/pendingUupsBinding.js +39 -0
  497. package/dist-runtime/workflow/lib/pendingUupsBinding.js.map +1 -0
  498. package/dist-runtime/workflow/lib/plan.d.ts +55 -0
  499. package/dist-runtime/workflow/lib/plan.js +324 -0
  500. package/dist-runtime/workflow/lib/plan.js.map +1 -0
  501. package/dist-runtime/workflow/lib/planCli.d.ts +14 -0
  502. package/dist-runtime/workflow/lib/planCli.js +279 -0
  503. package/dist-runtime/workflow/lib/planCli.js.map +1 -0
  504. package/dist-runtime/workflow/lib/preparationEvidence.d.ts +4 -0
  505. package/dist-runtime/workflow/lib/preparationEvidence.js +19 -0
  506. package/dist-runtime/workflow/lib/preparationEvidence.js.map +1 -0
  507. package/dist-runtime/workflow/lib/proxy.d.ts +4 -2
  508. package/dist-runtime/workflow/lib/proxy.js +3 -4
  509. package/dist-runtime/workflow/lib/proxy.js.map +1 -1
  510. package/dist-runtime/workflow/lib/runtime.d.ts +6 -0
  511. package/dist-runtime/workflow/lib/runtime.js +48 -0
  512. package/dist-runtime/workflow/lib/runtime.js.map +1 -0
  513. package/dist-runtime/workflow/lib/signer.d.ts +3 -2
  514. package/dist-runtime/workflow/lib/signer.js +18 -18
  515. package/dist-runtime/workflow/lib/signer.js.map +1 -1
  516. package/dist-runtime/workflow/lib/simulation.d.ts +13 -6
  517. package/dist-runtime/workflow/lib/simulation.js +39 -31
  518. package/dist-runtime/workflow/lib/simulation.js.map +1 -1
  519. package/dist-runtime/workflow/lib/state.js +3 -3
  520. package/dist-runtime/workflow/lib/state.js.map +1 -1
  521. package/dist-runtime/workflow/lib/staticValidation.d.ts +28 -0
  522. package/dist-runtime/workflow/lib/staticValidation.js +54 -10
  523. package/dist-runtime/workflow/lib/staticValidation.js.map +1 -1
  524. package/dist-runtime/workflow/lib/transactionPlanner.d.ts +62 -0
  525. package/dist-runtime/workflow/lib/transactionPlanner.js +258 -0
  526. package/dist-runtime/workflow/lib/transactionPlanner.js.map +1 -0
  527. package/dist-runtime/workflow/lib/typedValue.d.ts +3 -0
  528. package/dist-runtime/workflow/lib/typedValue.js +76 -0
  529. package/dist-runtime/workflow/lib/typedValue.js.map +1 -0
  530. package/dist-runtime/workflow/lib/validation.d.ts +23 -0
  531. package/dist-runtime/workflow/lib/validation.js +15 -0
  532. package/dist-runtime/workflow/lib/validation.js.map +1 -0
  533. package/dist-runtime/workflow/planAdd.d.ts +1 -0
  534. package/dist-runtime/workflow/planAdd.js +11 -0
  535. package/dist-runtime/workflow/planAdd.js.map +1 -0
  536. package/dist-runtime/workflow/planRead.d.ts +1 -0
  537. package/dist-runtime/workflow/planRead.js +11 -0
  538. package/dist-runtime/workflow/planRead.js.map +1 -0
  539. package/dist-runtime/workflow/planStatus.d.ts +1 -0
  540. package/dist-runtime/workflow/planStatus.js +11 -0
  541. package/dist-runtime/workflow/planStatus.js.map +1 -0
  542. package/dist-runtime/workflow/planWrite.d.ts +1 -0
  543. package/dist-runtime/workflow/planWrite.js +11 -0
  544. package/dist-runtime/workflow/planWrite.js.map +1 -0
  545. package/dist-runtime/workflow/run.d.ts +1 -40
  546. package/dist-runtime/workflow/run.js +69 -139
  547. package/dist-runtime/workflow/run.js.map +1 -1
  548. package/dist-runtime/workflow/staticValidate.js +8 -3
  549. package/dist-runtime/workflow/staticValidate.js.map +1 -1
  550. package/dist-runtime/workflow/steps/call.d.ts +1 -1
  551. package/dist-runtime/workflow/steps/check.d.ts +1 -1
  552. package/dist-runtime/workflow/steps/custom.d.ts +1 -1
  553. package/dist-runtime/workflow/steps/deploy.d.ts +1 -1
  554. package/dist-runtime/workflow/steps/deploy.js +110 -55
  555. package/dist-runtime/workflow/steps/deploy.js.map +1 -1
  556. package/dist-runtime/workflow/steps/upgrade.d.ts +1 -1
  557. package/dist-runtime/workflow/steps/upgrade.js +84 -49
  558. package/dist-runtime/workflow/steps/upgrade.js.map +1 -1
  559. package/dist-runtime/workflow/steps/view.d.ts +1 -1
  560. package/docs/compiler-qualification.md +38 -0
  561. package/docs/configuration-runtime-observation.md +29 -0
  562. package/docs/create2-miner.md +100 -0
  563. package/docs/delivery-aggregate.md +29 -0
  564. package/docs/delivery-calldata.md +27 -0
  565. package/docs/delivery-custom-input-closure.md +51 -0
  566. package/docs/delivery-development.md +38 -0
  567. package/docs/delivery-eoa.md +46 -0
  568. package/docs/delivery-evm-manifest.md +20 -0
  569. package/docs/delivery-execution-store.md +33 -0
  570. package/docs/delivery-inputs.md +95 -0
  571. package/docs/delivery-parameters.md +65 -0
  572. package/docs/delivery-planning.md +140 -0
  573. package/docs/delivery-release.md +119 -0
  574. package/docs/delivery-safe.md +75 -0
  575. package/docs/delivery-setup.md +198 -0
  576. package/docs/delivery-source.md +67 -0
  577. package/docs/direct-package-acceptance.md +2 -0
  578. package/docs/openzeppelin-acceptance.md +86 -0
  579. package/docs/openzeppelin-baseline.json +27 -0
  580. package/docs/openzeppelin-integration.md +115 -0
  581. package/docs/plans/2026-10-28-openzeppelin-toolkit-consolidation.md +396 -0
  582. package/docs/plans/2026-11-02-transparent-proxy-delivery.md +78 -0
  583. package/docs/superpowers/plans/2026-08-17-custody-hardhat-signers.md +1 -1
  584. package/docs/superpowers/plans/2026-09-24-scheme-aware-static-validation.md +193 -0
  585. package/docs/superpowers/plans/2026-10-28-create2-miner.md +82 -0
  586. package/docs/workflow-reference.md +12 -4
  587. package/docs/workflow-runtime.md +6 -0
  588. package/package.json +148 -10
  589. package/resources/create2/LICENSE +21 -0
  590. package/resources/create2/README.md +9 -0
  591. package/resources/create2/darwin-arm64/smartflow_miner +0 -0
  592. package/resources/create2/darwin-x64/smartflow_miner +0 -0
  593. package/resources/create2/manifest.json +27 -0
  594. package/runtime/config/hardhatAdapters.ts +2 -1
  595. package/runtime/config/openzeppelin.ts +3 -21
  596. package/runtime/delivery/abi.ts +225 -0
  597. package/runtime/delivery/aggregate-bootstrap.ts +31 -0
  598. package/runtime/delivery/aggregate-channel.ts +88 -0
  599. package/runtime/delivery/aggregate-diagnostics.ts +63 -0
  600. package/runtime/delivery/aggregate-inputs.ts +39 -0
  601. package/runtime/delivery/aggregate-source.ts +57 -0
  602. package/runtime/delivery/aggregate-worker.ts +143 -0
  603. package/runtime/delivery/aggregate.ts +139 -0
  604. package/runtime/delivery/bindings.ts +37 -0
  605. package/runtime/delivery/business-extension.ts +33 -0
  606. package/runtime/delivery/calldata-archive.ts +25 -0
  607. package/runtime/delivery/calldata-details.ts +90 -0
  608. package/runtime/delivery/calldata-format.ts +14 -0
  609. package/runtime/delivery/calldata-preparations.ts +76 -0
  610. package/runtime/delivery/calldata-review.ts +126 -0
  611. package/runtime/delivery/check-code.ts +38 -0
  612. package/runtime/delivery/closure-format.ts +350 -0
  613. package/runtime/delivery/codec-pin.ts +3 -0
  614. package/runtime/delivery/codec.ts +50 -0
  615. package/runtime/delivery/compiler-dependency-pins.ts +1685 -0
  616. package/runtime/delivery/compiler-files.ts +181 -0
  617. package/runtime/delivery/compiler-io.ts +10 -0
  618. package/runtime/delivery/compiler-pins.ts +143 -0
  619. package/runtime/delivery/compiler.ts +701 -0
  620. package/runtime/delivery/config.ts +116 -0
  621. package/runtime/delivery/configuration-definition.ts +160 -0
  622. package/runtime/delivery/configuration-hre.ts +130 -0
  623. package/runtime/delivery/configuration-runtime.ts +163 -0
  624. package/runtime/delivery/configuration.ts +67 -0
  625. package/runtime/delivery/contract-source.ts +112 -0
  626. package/runtime/delivery/create2.ts +57 -0
  627. package/runtime/delivery/custom-closure.ts +993 -0
  628. package/runtime/delivery/custom-format.ts +479 -0
  629. package/runtime/delivery/custom.ts +219 -0
  630. package/runtime/delivery/data.ts +94 -0
  631. package/runtime/delivery/development.ts +264 -0
  632. package/runtime/delivery/engine.ts +29 -0
  633. package/runtime/delivery/eoa-observation.ts +106 -0
  634. package/runtime/delivery/eoa-signed.ts +55 -0
  635. package/runtime/delivery/eoa.ts +288 -0
  636. package/runtime/delivery/execution-db.ts +131 -0
  637. package/runtime/delivery/execution-files.ts +135 -0
  638. package/runtime/delivery/execution-identity.ts +32 -0
  639. package/runtime/delivery/execution-model.ts +102 -0
  640. package/runtime/delivery/execution-store.ts +411 -0
  641. package/runtime/delivery/existing-code.ts +45 -0
  642. package/runtime/delivery/export.ts +99 -0
  643. package/runtime/delivery/forkAudit.ts +620 -0
  644. package/runtime/delivery/hardhat.ts +38 -0
  645. package/runtime/delivery/history-registration.ts +10 -0
  646. package/runtime/delivery/identities.ts +132 -0
  647. package/runtime/delivery/input-files.ts +46 -0
  648. package/runtime/delivery/inputs.ts +204 -0
  649. package/runtime/delivery/journal.ts +205 -0
  650. package/runtime/delivery/manifest.ts +54 -0
  651. package/runtime/delivery/materialization.ts +53 -0
  652. package/runtime/delivery/observations.ts +60 -0
  653. package/runtime/delivery/parameter-defaults.ts +75 -0
  654. package/runtime/delivery/parameters.ts +367 -0
  655. package/runtime/delivery/pending.ts +98 -0
  656. package/runtime/delivery/plan.ts +337 -0
  657. package/runtime/delivery/planning.ts +411 -0
  658. package/runtime/delivery/policy.ts +9 -0
  659. package/runtime/delivery/preparation.ts +240 -0
  660. package/runtime/delivery/production-environment.ts +7 -0
  661. package/runtime/delivery/production-finalization.ts +181 -0
  662. package/runtime/delivery/production-intent.ts +14 -0
  663. package/runtime/delivery/production.ts +415 -0
  664. package/runtime/delivery/project-files.ts +63 -0
  665. package/runtime/delivery/project-rpc.ts +116 -0
  666. package/runtime/delivery/project.ts +129 -0
  667. package/runtime/delivery/protocol.ts +94 -0
  668. package/runtime/delivery/public-calldata.ts +74 -0
  669. package/runtime/delivery/references.ts +106 -0
  670. package/runtime/delivery/release-graph.ts +79 -0
  671. package/runtime/delivery/release-history-capture.ts +32 -0
  672. package/runtime/delivery/release-history.ts +178 -0
  673. package/runtime/delivery/release-inputs.ts +107 -0
  674. package/runtime/delivery/release.ts +166 -0
  675. package/runtime/delivery/safe-manifest.ts +11 -0
  676. package/runtime/delivery/safe-observation.ts +626 -0
  677. package/runtime/delivery/safe-prepare.ts +101 -0
  678. package/runtime/delivery/safe.ts +355 -0
  679. package/runtime/delivery/same-fork-baseline.ts +17 -0
  680. package/runtime/delivery/setup.ts +184 -0
  681. package/runtime/delivery/source.ts +130 -0
  682. package/runtime/delivery/target-fields.ts +7 -0
  683. package/runtime/delivery/task-identity.ts +85 -0
  684. package/runtime/delivery/toolchain.ts +48 -0
  685. package/runtime/delivery/validation.ts +252 -0
  686. package/runtime/delivery/verification.ts +47 -0
  687. package/runtime/migrate.ts +1 -0
  688. package/runtime/miner/binary.ts +41 -0
  689. package/runtime/miner/cli.ts +87 -0
  690. package/runtime/miner/index.ts +5 -0
  691. package/runtime/miner/request.ts +54 -0
  692. package/runtime/miner/runner.ts +90 -0
  693. package/runtime/miner/types.ts +71 -0
  694. package/runtime/miner/verify.ts +61 -0
  695. package/runtime/vendor/plan-codec/index.cjs +897 -0
  696. package/runtime/vendor/plan-codec/index.d.cts +38 -0
  697. package/runtime/vendor/plan-codec/provenance.json +25 -0
  698. package/runtime/workflow/engine.ts +174 -0
  699. package/runtime/workflow/lib/authority.ts +3 -3
  700. package/runtime/workflow/lib/calls.ts +47 -37
  701. package/runtime/workflow/lib/canonicalData.ts +45 -0
  702. package/runtime/workflow/lib/checkCodeRunner.ts +7 -3
  703. package/runtime/workflow/lib/config.ts +1 -1
  704. package/runtime/workflow/lib/context.ts +77 -0
  705. package/runtime/workflow/lib/create2.ts +18 -121
  706. package/runtime/workflow/lib/deploymentInfo.ts +8 -0
  707. package/runtime/workflow/lib/deploymentRecords.ts +3 -1
  708. package/runtime/workflow/lib/deployments.ts +6 -14
  709. package/runtime/workflow/lib/evidencePorts.ts +20 -0
  710. package/runtime/workflow/lib/executionPlan.ts +17 -268
  711. package/runtime/workflow/lib/externalExecutionScanner.ts +2 -1
  712. package/runtime/workflow/lib/gateTool.ts +22 -10
  713. package/runtime/workflow/lib/gateToolSync.ts +11 -3
  714. package/runtime/workflow/lib/operationNames.ts +32 -0
  715. package/runtime/workflow/lib/parameters.ts +8 -21
  716. package/runtime/workflow/lib/pendingDeploymentReuse.ts +4 -56
  717. package/runtime/workflow/lib/pendingUupsBinding.ts +43 -0
  718. package/runtime/workflow/lib/plan.ts +334 -0
  719. package/runtime/workflow/lib/planCli.ts +279 -0
  720. package/runtime/workflow/lib/preparationEvidence.ts +14 -0
  721. package/runtime/workflow/lib/proxy.ts +6 -3
  722. package/runtime/workflow/lib/runtime.ts +46 -0
  723. package/runtime/workflow/lib/signer.ts +8 -5
  724. package/runtime/workflow/lib/simulation.ts +41 -17
  725. package/runtime/workflow/lib/state.ts +3 -3
  726. package/runtime/workflow/lib/staticValidation.ts +92 -11
  727. package/runtime/workflow/lib/transactionPlanner.ts +314 -0
  728. package/runtime/workflow/lib/typedValue.ts +46 -0
  729. package/runtime/workflow/lib/validation.ts +50 -0
  730. package/runtime/workflow/planAdd.ts +8 -0
  731. package/runtime/workflow/planRead.ts +8 -0
  732. package/runtime/workflow/planStatus.ts +8 -0
  733. package/runtime/workflow/planWrite.ts +8 -0
  734. package/runtime/workflow/run.ts +42 -176
  735. package/runtime/workflow/staticValidate.ts +8 -3
  736. package/runtime/workflow/steps/call.ts +1 -1
  737. package/runtime/workflow/steps/check.ts +1 -1
  738. package/runtime/workflow/steps/custom.ts +1 -1
  739. package/runtime/workflow/steps/deploy.ts +99 -58
  740. package/runtime/workflow/steps/upgrade.ts +88 -57
  741. package/runtime/workflow/steps/view.ts +1 -1
  742. package/bin/workflow.cjs +0 -19
@@ -0,0 +1,132 @@
1
+ import {
2
+ canonicalData,
3
+ deepFreeze,
4
+ exactObject,
5
+ nonempty,
6
+ semanticHash,
7
+ } from "../workflow/lib/canonicalData";
8
+ export interface OperationBinding {
9
+ stepId: string;
10
+ sourceStepId: string;
11
+ operationId: string | null;
12
+ kind: string;
13
+ }
14
+ const kinds = new Set(["deploy", "upgrade", "call", "view", "check"]);
15
+ const engineId = (source: string, operation: string | null) =>
16
+ `op-${semanticHash(["gate-delivery-operation", 1, source, operation])}`;
17
+ export function parseOperationBindings(raw: unknown): OperationBinding[] {
18
+ if (!Array.isArray(raw))
19
+ throw new Error("operation bindings must be an array");
20
+ const seen = new Set<string>();
21
+ return deepFreeze(
22
+ raw.map((item) => {
23
+ const v = exactObject(
24
+ item,
25
+ ["stepId", "sourceStepId", "operationId", "kind"],
26
+ "operation binding",
27
+ );
28
+ nonempty(v.sourceStepId, "sourceStepId");
29
+ if (v.operationId !== null) nonempty(v.operationId, "operationId");
30
+ if (
31
+ !kinds.has(String(v.kind)) ||
32
+ v.stepId !==
33
+ engineId(v.sourceStepId as string, v.operationId as string | null) ||
34
+ seen.has(String(v.stepId))
35
+ )
36
+ throw new Error("Invalid or duplicate operation identity");
37
+ seen.add(String(v.stepId));
38
+ return v as unknown as OperationBinding;
39
+ }),
40
+ );
41
+ }
42
+ /** Delivery only: the neutral/legacy planner's locked IDs are unchanged. */
43
+ export class DeliveryOperationIdentities {
44
+ private readonly bindings: OperationBinding[] = [];
45
+ register(
46
+ sourceStepId: string,
47
+ operationId: string | null,
48
+ kind: string,
49
+ ): string {
50
+ nonempty(sourceStepId, "source step");
51
+ if (operationId !== null) nonempty(operationId, "custom operation");
52
+ const stepId = engineId(sourceStepId, operationId);
53
+ if (!kinds.has(kind) || this.bindings.some((b) => b.stepId === stepId))
54
+ throw new Error("Duplicate operation identity or hash collision");
55
+ this.bindings.push({ stepId, sourceStepId, operationId, kind });
56
+ return stepId;
57
+ }
58
+ transactionStepId(stepId: string, role: "call", ordinal: number): string {
59
+ if (
60
+ !this.bindings.some((b) => b.stepId === stepId && b.kind === role) ||
61
+ !Number.isSafeInteger(ordinal) ||
62
+ ordinal < 0
63
+ )
64
+ throw new Error("Invalid delivery call identity");
65
+ return `${stepId}-call-${ordinal}`;
66
+ }
67
+ seal(): OperationBinding[] {
68
+ return parseOperationBindings(canonicalData(this.bindings));
69
+ }
70
+ }
71
+
72
+ export interface TransactionBinding {
73
+ transactionId: string;
74
+ stepId: string;
75
+ role: "call" | "deployment" | "implementation" | "upgrade";
76
+ callIndex: number | null;
77
+ }
78
+ /** Explicit reverse map: transaction -> operation/role -> source step/custom operation. */
79
+ export function bindDeliveryTransactions(
80
+ transactions: readonly import("../workflow/lib/transactionPlanner").ReleaseExecutionTransaction[],
81
+ operations: readonly OperationBinding[],
82
+ ): TransactionBinding[] {
83
+ let previousOperation = -1;
84
+ const callOrdinals = new Map<string, number>();
85
+ const roles = new Set<string>();
86
+ return deepFreeze(
87
+ transactions.map((tx) => {
88
+ const index = operations.findIndex(
89
+ (b) =>
90
+ tx.stepId === b.stepId ||
91
+ (b.kind === "upgrade" &&
92
+ tx.stepId === `${b.stepId}-implementation`) ||
93
+ (b.kind === "call" && tx.stepId.startsWith(`${b.stepId}-call-`)),
94
+ );
95
+ if (index < previousOperation || index < 0)
96
+ throw new Error("Unbound or unordered delivery transaction identity");
97
+ previousOperation = index;
98
+ const operation = operations[index];
99
+ if (operation.kind === "view" || operation.kind === "check")
100
+ throw new Error("Read operation cannot bind transaction");
101
+ let role: TransactionBinding["role"],
102
+ callIndex: number | null = null;
103
+ if (operation.kind === "call") {
104
+ callIndex = callOrdinals.get(operation.stepId) ?? 0;
105
+ if (tx.stepId !== `${operation.stepId}-call-${callIndex}`)
106
+ throw new Error("Invalid delivery call ordinal");
107
+ callOrdinals.set(operation.stepId, callIndex + 1);
108
+ role = "call";
109
+ } else
110
+ role =
111
+ operation.kind === "deploy"
112
+ ? "deployment"
113
+ : tx.stepId === operation.stepId
114
+ ? "upgrade"
115
+ : "implementation";
116
+ const key = JSON.stringify([operation.stepId, role, callIndex]);
117
+ if (
118
+ roles.has(key) ||
119
+ (role === "implementation" &&
120
+ roles.has(JSON.stringify([operation.stepId, "upgrade", null])))
121
+ )
122
+ throw new Error("Duplicate or unordered transaction role");
123
+ roles.add(key);
124
+ return {
125
+ transactionId: tx.transactionId,
126
+ stepId: operation.stepId,
127
+ role,
128
+ callIndex,
129
+ };
130
+ }),
131
+ );
132
+ }
@@ -0,0 +1,46 @@
1
+ /** Strict, confined business document reads. Errors never include document contents. */
2
+ import fs from 'node:fs';
3
+ import { createHash } from 'node:crypto';
4
+ import YAML from 'yaml';
5
+ import { strictData } from './data';
6
+ import { confinedFile } from './project-files';
7
+
8
+ export const inputDigest = (bytes: string | Buffer): string => createHash('sha256').update(bytes).digest('hex');
9
+ export function readInputBytes(root: string, relative: string): Buffer {
10
+ const file = confinedFile(root, relative);
11
+ const fd = fs.openSync(file, fs.constants.O_RDONLY | fs.constants.O_NOFOLLOW);
12
+ try {
13
+ const before = fs.fstatSync(fd);
14
+ if (!before.isFile() || before.nlink !== 1) throw new Error('Unsafe business input file');
15
+ const bytes = fs.readFileSync(fd), after = fs.fstatSync(fd);
16
+ confinedFile(root, relative);
17
+ const current = fs.lstatSync(file);
18
+ if (before.dev !== current.dev || before.ino !== current.ino || before.size !== after.size
19
+ || before.mtimeMs !== after.mtimeMs || before.ctimeMs !== after.ctimeMs) throw new Error('Business input changed while reading');
20
+ return bytes;
21
+ } finally { fs.closeSync(fd); }
22
+ }
23
+ export function parseInputDocument(bytes: Buffer | string, format: 'json' | 'yaml'): unknown {
24
+ try {
25
+ const text = typeof bytes === 'string' ? bytes : new TextDecoder('utf-8', { fatal: true }).decode(bytes);
26
+ // JSON.parse establishes JSON syntax; the YAML AST additionally preserves duplicate members.
27
+ if (format === 'json') JSON.parse(text);
28
+ const doc = YAML.parseDocument(text, { uniqueKeys: true, merge: false, prettyErrors: false });
29
+ if (doc.errors.length || doc.warnings.length) throw new Error();
30
+ YAML.visit(doc, {
31
+ Node(_key, node) {
32
+ if (YAML.isAlias(node) || ('anchor' in node && node.anchor) || node.tag) throw new Error();
33
+ },
34
+ Pair(_key, pair) {
35
+ if (!YAML.isScalar(pair.key) || typeof pair.key.value !== 'string' || pair.key.value === '<<') throw new Error();
36
+ },
37
+ });
38
+ return strictData(doc.toJS({ maxAliasCount: 0 }));
39
+ } catch { throw new Error('Invalid business document: duplicate members or unsafe non-JSON data'); }
40
+ }
41
+ /** The canonical codec remains the sole handoff interpreter; this only rejects ambiguous syntax. */
42
+ export function assertUnambiguousHandoff(text: string): void {
43
+ const frontmatter = /^(?:\uFEFF)?---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/.exec(text);
44
+ if (frontmatter) parseInputDocument(frontmatter[1], 'yaml');
45
+ for (const match of text.matchAll(/```gateflow-(?:task|progress)\r?\n([\s\S]*?)\r?\n```/g)) parseInputDocument(match[1], 'json');
46
+ }
@@ -0,0 +1,204 @@
1
+ /** Owned business input binding only. This is not an aggregate plan or release/execution authority. */
2
+ import { readOwnedDeliverySource, type DeliverySourceBinding } from './source';
3
+ import { strictData, ownPath } from './data';
4
+ import { readInputBytes, parseInputDocument, inputDigest } from './input-files';
5
+ import { object, safeId, portablePath, type DeliveryRequest } from './protocol';
6
+ import { parseDeliveryPublicTargets, type DeliveryPublicTarget } from './config';
7
+ import { confinedFile } from './project-files';
8
+ import { parseCustomStep, parseNativeOperation } from './custom';
9
+ import { CustomModuleClosure, type CustomInputClosure } from './custom-closure';
10
+ import { resolveDeliveryParameters, consumeDeliveryParameters, type ResolvedDeliveryParameters, type TrustedParameterProducer } from './parameters';
11
+ import { validateDeploySaveAs, type WorkflowStep } from '../workflow/lib/parameters';
12
+ import { canonicalJson, deepFreeze, semanticHash, exactObject, nonempty } from '../workflow/lib/canonicalData';
13
+ import type { DeepReadonly } from './source';
14
+ import { parseDeploymentRequirementRef } from './task-identity';
15
+ import { resolveParameterTargets } from './parameter-defaults';
16
+
17
+ export interface DeliveryInputOptions {
18
+ workspaceRoot: string;
19
+ projectRoot: string;
20
+ request: DeliveryRequest;
21
+ /** Data scope only; does not authorize invocation against any additional target. */
22
+ selection: 'development' | 'release' | 'all';
23
+ }
24
+ export interface DeliveryInputSnapshot {
25
+ version: 1;
26
+ deploymentId: string;
27
+ businessRoot: string;
28
+ sourceDefinitionHash: string;
29
+ sourceDefinition: DeliverySourceBinding['sourceDefinition'];
30
+ steps: readonly WorkflowStep[];
31
+ targets: DeliveryPublicTarget[];
32
+ files: Array<{ path: string; digest: string }>;
33
+ }
34
+ export interface DeliveryParameterReceipt { readonly version: 1; readonly target: string; readonly identity: string }
35
+ export interface DeliveryParameterEvidence {
36
+ target: string;
37
+ resolved: ResolvedDeliveryParameters;
38
+ producers: Array<{ id: string; version: string; module: string; moduleDigest: string }>;
39
+ closure: CustomInputClosure | null;
40
+ identity: string;
41
+ }
42
+ export interface DeliveryInputEvidence extends DeliveryInputSnapshot {
43
+ parameters: DeliveryParameterEvidence[];
44
+ /** Business-input identity only; never a final aggregate inputsHash. */
45
+ businessInputHash: string;
46
+ }
47
+ export interface DeliveryInputHandle {
48
+ readonly snapshot: DeepReadonly<DeliveryInputSnapshot>;
49
+ values(target: string): unknown;
50
+ parameters(target: string): DeliveryParameterReceipt;
51
+ /** Terminal reread only; no producer or custom execution. One shot, failure revokes all receipts. */
52
+ seal(): DeepReadonly<DeliveryInputEvidence>;
53
+ close(): void;
54
+ }
55
+ type State = { status: 'open' | 'sealed' | 'failed' | 'closed' };
56
+ const receipts = new WeakMap<object, { owner: State; evidence: DeliveryParameterEvidence }>();
57
+ /** Only a receipt issued by a successfully sealed owner can be consumed; JSON is never authority. */
58
+ export function consumeDeliveryInputParameters(receipt: DeliveryParameterReceipt): unknown {
59
+ const owned = receipt && typeof receipt === 'object' ? receipts.get(receipt) : undefined;
60
+ if (!owned || owned.owner.status !== 'sealed') throw new Error('Parameter receipt requires a sealed owned session (closed or failed receipts are invalid)');
61
+ return consumeDeliveryParameters(owned.evidence.resolved, owned.evidence.resolved.identity);
62
+ }
63
+ function same(a: unknown, b: unknown, label: string): void {
64
+ if (canonicalJson(a) !== canonicalJson(b)) throw new Error(`${label} drift or mismatch`);
65
+ }
66
+ function parseSteps(raw: unknown): readonly WorkflowStep[] {
67
+ if (!Array.isArray(raw) || !raw.length) throw new Error('Manifest steps must be a nonempty ordered array');
68
+ const steps = raw.map(step => object(step, 'manifest step').kind === 'custom' ? parseCustomStep(step) : parseNativeOperation(step));
69
+ if (new Set(steps.map(step => step.id)).size !== steps.length) throw new Error('Duplicate manifest step IDs');
70
+ validateDeploySaveAs(steps);
71
+ return deepFreeze(steps);
72
+ }
73
+ /** Read all structure before invoking any producer. Actual modules reuse the existing bounded loader. */
74
+ export function openDeliveryInputs(raw: DeliveryInputOptions): DeliveryInputHandle {
75
+ const input = strictData(raw);
76
+ exactObject(input, ['workspaceRoot', 'projectRoot', 'request', 'selection'], 'delivery input options');
77
+ if (!['development', 'release', 'all'].includes(input.selection)) throw new Error('Unsupported delivery input selection');
78
+ const sourceInput = { workspaceRoot: input.workspaceRoot, projectRoot: input.projectRoot, request: input.request };
79
+ const source = readOwnedDeliverySource(sourceInput);
80
+ const scope = object(source.invocation.task.scope?.deployment, 'deployment');
81
+ const deploymentId = safeId(scope.deploymentId, 'deploymentId'), businessRoot = `scripts/tasks/${deploymentId}`;
82
+ const files: DeliveryInputSnapshot['files'] = [];
83
+ const read = (name: string, format: 'json' | 'yaml') => {
84
+ const relative = `${businessRoot}/${name}`, bytes = readInputBytes(source.projectRoot, relative);
85
+ files.push({ path: relative, digest: inputDigest(bytes) });
86
+ return parseInputDocument(bytes, format);
87
+ };
88
+ const task = object(read('task.yaml', 'yaml'), 'task.yaml', ['version', 'id', 'developmentNetwork', 'releaseTargetNetworks', 'requirementRef', 'productionRequirementRef', 'referenceDeploymentId']);
89
+ if (task.version !== 1 || task.id !== deploymentId) throw new Error('Task version/deployment identity mismatch');
90
+ same(parseDeploymentRequirementRef(task.requirementRef), scope.requirementRef, 'Task requirementRef');
91
+ same(task.referenceDeploymentId ?? null, scope.referenceDeploymentId ?? null, 'Task referenceDeploymentId');
92
+ same(task.developmentNetwork, scope.developmentNetwork, 'Task developmentNetwork');
93
+ const release = task.releaseTargetNetworks as string[];
94
+ if (!Array.isArray(release) || new Set(release).size !== release.length) throw Error('Invalid task releaseTargetNetworks');
95
+ for (const network of release) if(typeof network !== 'string' || !/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(network) || ['__proto__','prototype','constructor'].includes(network)) throw Error('Invalid release target');
96
+ if (input.request.environment === 'dev') {
97
+ if (!(scope.releaseTargetNetworks as string[]).every(network => release.includes(network))) throw Error('Task removed a development-declared release target');
98
+ } else {
99
+ same(release, scope.releaseTargetNetworks, 'Task releaseTargetNetworks');
100
+ same(task.productionRequirementRef === undefined ? null : parseDeploymentRequirementRef(task.productionRequirementRef), scope.productionRequirementRef ?? null, 'Task productionRequirementRef');
101
+ }
102
+ const manifest = object(read('manifest.yaml', 'yaml'), 'manifest.yaml', ['id', 'description', 'steps']);
103
+ if (manifest.id !== deploymentId) throw new Error('Manifest deployment identity mismatch');
104
+ if (manifest.description !== undefined) nonempty(manifest.description, 'manifest description');
105
+ const steps = parseSteps(manifest.steps);
106
+ const schema = object(read('parameters.schema.json', 'json'), 'parameters schema');
107
+ const dev = scope.developmentNetwork as string;
108
+ const all = [dev, ...release];
109
+ const { params, observations, definitions } = resolveParameterTargets(
110
+ read('parameters.yaml', 'yaml'), read('parameters.provenance.json', 'json'), all);
111
+ for (const [id, raw] of Object.entries(definitions)) {
112
+ safeId(id, 'producer ID');
113
+ const definition = exactObject(raw, ['version', 'module'], 'producer');
114
+ nonempty(definition.version, 'producer version');
115
+ const module = portablePath(definition.module, 'producer module');
116
+ if (!module.startsWith(`${businessRoot}/`)) throw new Error('Producer module is outside deployment business root');
117
+ }
118
+ const selected = input.selection === 'development' ? [dev] : input.selection === 'release' ? release : all;
119
+ // Both the digest and every public projection use these exact buffers. Reopening
120
+ // for projection would permit an A→B→A edit to bind B's values to A's digest.
121
+ const configBytes = readInputBytes(source.projectRoot, 'config.yaml');
122
+ const projectConfigBytes = readInputBytes(source.projectRoot, 'hardhat.config.ts');
123
+ const targets = parseDeliveryPublicTargets(configBytes, projectConfigBytes,
124
+ selected.map(network => ({ network, environment: network === dev ? 'dev' : 'prod' })));
125
+ for (const target of targets) confinedFile(source.projectRoot, target.openzeppelin!.manifestDir, 'directory');
126
+ const configurationFiles = [{ path: 'config.yaml', digest: inputDigest(configBytes) },
127
+ { path: 'hardhat.config.ts', digest: inputDigest(projectConfigBytes) }];
128
+ for (const file of configurationFiles) {
129
+ files.push(file);
130
+ }
131
+ // Verify every selected envelope is present before the first producer runs.
132
+ for (const target of targets) {
133
+ ownPath(params, [target.id], 'selected target parameters');
134
+ ownPath(observations, [target.id], 'selected target provenance');
135
+ }
136
+ const snapshot = deepFreeze({ version: 1 as const, deploymentId, businessRoot, sourceDefinitionHash: source.sourceDefinitionHash,
137
+ sourceDefinition: source.sourceDefinition, steps, targets, files });
138
+ const state: State = { status: 'open' };
139
+ const resolved = new Map<string, { receipt: DeliveryParameterReceipt; evidence: DeliveryParameterEvidence; closure?: CustomModuleClosure }>();
140
+ const assertOpen = () => { if (state.status !== 'open') throw new Error('Business input session is closed'); };
141
+ try {
142
+ for (const target of targets) {
143
+ const observed = object(observations[target.id], 'target provenance');
144
+ const computed = object(observed.computed, 'computed observations');
145
+ object(observed.manual, 'manual observations');
146
+ let closure: CustomModuleClosure | undefined;
147
+ const producers: Record<string, TrustedParameterProducer> = Object.create(null);
148
+ const used: DeliveryParameterEvidence['producers'] = [];
149
+ for (const raw of Object.values(computed)) {
150
+ const observation = exactObject(raw, ['producer', 'version', 'inputs', 'output'], 'computed observation');
151
+ const id = safeId(observation.producer, 'producer ID');
152
+ if (Object.hasOwn(producers, id)) continue;
153
+ const definition = exactObject(ownPath(definitions, [id], 'producer definition'), ['version', 'module'], 'producer');
154
+ closure ??= new CustomModuleClosure(source.projectRoot);
155
+ const loaded = closure.load(definition.module as string);
156
+ if (!loaded.module || typeof loaded.module.produce !== 'function' || Object.keys(loaded.module).some(key => key !== 'produce')) throw new Error('Parameter module must only export synchronous produce(inputs)');
157
+ used.push({ id, version: definition.version as string, module: loaded.identity.path, moduleDigest: loaded.identity.digest });
158
+ const current = closure;
159
+ producers[id] = Object.freeze({ version: definition.version as string, produce: (inputs: unknown) => {
160
+ const result = current.normalize(loaded.module.produce(deepFreeze(strictData(inputs))));
161
+ current.assertUnchanged();
162
+ return result;
163
+ } });
164
+ }
165
+ const envelope = resolveDeliveryParameters({ schema, target: target.id, values: params[target.id], sources: params,
166
+ manual: observed.manual as ResolvedDeliveryParameters['manual'], computed: observed.computed as ResolvedDeliveryParameters['computed'], producers });
167
+ const body = { target: target.id, resolved: envelope, producers: used.sort((a,b) => a.id.localeCompare(b.id, 'en')), closure: closure?.seal() ?? null };
168
+ const evidence = deepFreeze({ ...body, identity: semanticHash({ version: 1, files, ...body }) });
169
+ const receipt = Object.freeze({ version: 1 as const, target: target.id, identity: evidence.identity });
170
+ receipts.set(receipt, { owner: state, evidence });
171
+ resolved.set(target.id, { receipt, evidence, closure });
172
+ }
173
+ } catch (error) { state.status = 'failed'; throw error; }
174
+ const get = (target: string) => {
175
+ assertOpen(); const result = resolved.get(target);
176
+ if (!result) throw new Error('Target is outside selected delivery inputs');
177
+ return result;
178
+ };
179
+ const handle: DeliveryInputHandle = {
180
+ snapshot,
181
+ values: target => get(target).evidence.resolved.values,
182
+ parameters: target => get(target).receipt,
183
+ close() { if (state.status !== 'failed') state.status = 'closed'; },
184
+ seal() {
185
+ assertOpen();
186
+ // Close evaluation/read ports before terminal verification. Failure is permanent.
187
+ state.status = 'failed';
188
+ for(const {closure} of resolved.values())closure?.closeReads();
189
+ const current = readOwnedDeliverySource(sourceInput);
190
+ same(current.sourceDefinitionHash, source.sourceDefinitionHash, 'Business source definition');
191
+ same(current.invocation.task.scope?.deployment, scope, 'Business invocation');
192
+ for (const file of files) if (inputDigest(readInputBytes(source.projectRoot, file.path)) !== file.digest) throw new Error('Business input file drift');
193
+ const parameters = [...resolved.values()].map(({ evidence, closure }) => {
194
+ same(closure?.seal() ?? null, evidence.closure, 'Parameter producer closure');
195
+ return evidence;
196
+ });
197
+ const body = { ...snapshot, parameters };
198
+ const evidence = deepFreeze({ ...body, businessInputHash: semanticHash(body) });
199
+ state.status = 'sealed';
200
+ return evidence;
201
+ },
202
+ };
203
+ return Object.freeze(handle);
204
+ }
@@ -0,0 +1,205 @@
1
+ import { contractInfoKey } from '../workflow/lib/deployments';
2
+ import { expectedTransactionPurposes } from "../workflow/lib/gateTool";
3
+ import { sameAddress } from "../workflow/lib/pendingUupsBinding";
4
+ import { normalizePreparationPlan, normalizePreparationRequest, hashPreparationRequest } from 'gate-evm-tools/workflow';
5
+ import type { GateToolAddressPolicy, GateToolPreparationRequestV1 } from 'gate-evm-tools/workflow';
6
+ import type { DeploymentChange } from '../workflow/lib/deploymentRecords';
7
+ import type { PreparedGateToolWorkflow } from '../workflow/lib/gateTool';
8
+ import type { PreparationInput, PreparationMapping, PreparationSink } from '../workflow/lib/evidencePorts';
9
+ import type { ReleaseExecutionTransaction } from '../workflow/lib/transactionPlanner';
10
+ import { canonicalData, canonicalJson, deepFreeze, digest, exactObject, nonempty, semanticHash } from '../workflow/lib/canonicalData';
11
+ import { assertCreate2AddressPolicy, prepareControlledMulticallTransaction } from '../workflow/lib/create2';
12
+ import { portablePath } from './protocol';
13
+ import type { DerivedBindings } from './bindings';
14
+ import { matchesSameForkInitial, sameForkBaselineDigest } from './same-fork-baseline';
15
+ export interface PreparationEntry extends PreparationInput { requestHash: string; gateToolPlanHash: string; mappings: PreparationMapping[]; preparationHash: string }
16
+ export interface JournalIdentity { target: string; chainId: string; expectedStepIds: readonly string[] }
17
+ const addressKeys = ['address', 'proxyAddress', 'proxyAdminAddress', 'proxyAdminOwner', 'implementationAddress', 'preparedImplementationAddress', 'placeholderImplementationAddress', 'factory', 'multicall', 'expectedAddress', 'predictedAddress', 'previousAddress'];
18
+ const stringKeys = ['stepId', 'instanceId', 'actualContract', 'contractInfoKey', 'strategy', 'proxyKind', 'implementationSalt', 'salt', 'redeployReason'];
19
+ // Prepared changes cannot carry runtime reuse observations, receipts, candidate lifecycle, sync or success markers.
20
+ const changeKeys = [...addressKeys, ...stringKeys, 'kind', 'constructorArgs', 'leadingZeroBytes', 'gateTool'];
21
+ function normalizeChange(raw: unknown): DeploymentChange {
22
+ const v = canonicalData(raw) as Record<string, unknown>;
23
+ if (!v || typeof v !== 'object' || Array.isArray(v) || Object.keys(v).some(k => !changeKeys.includes(k))) throw new Error('Unsupported prepared deployment change metadata');
24
+ for (const key of ['stepId', 'instanceId', 'actualContract', 'contractInfoKey']) nonempty(v[key], key);
25
+ if (v.kind !== 'deploy' && v.kind !== 'upgrade') throw new Error('Invalid prepared deployment kind');
26
+ for (const k of stringKeys) if (Object.hasOwn(v, k)) nonempty(v[k], k);
27
+ for (const k of addressKeys) if (Object.hasOwn(v, k) && (typeof v[k] !== 'string' || !/^0x[\da-fA-F]{40}$/.test(v[k] as string))) throw new Error(`Invalid prepared ${k}`);
28
+ for (const k of ['salt', 'implementationSalt']) if (Object.hasOwn(v, k) && !/^0x[\da-fA-F]{64}$/.test(v[k] as string)) throw new Error(`Invalid prepared ${k}`);
29
+ if (Object.hasOwn(v, 'constructorArgs') && !Array.isArray(v.constructorArgs)) throw new Error('Invalid constructorArgs');
30
+ if (Object.hasOwn(v, 'leadingZeroBytes') && (!Number.isInteger(v.leadingZeroBytes) || (v.leadingZeroBytes as number) < 0 || (v.leadingZeroBytes as number) > 20)) throw new Error('Invalid leadingZeroBytes');
31
+ exactObject(v.gateTool, ['outputPath', 'data'], 'GateTool evidence');
32
+ return v as unknown as DeploymentChange;
33
+ }
34
+ function normalizeInput(raw: unknown, identity: JournalIdentity): PreparationInput {
35
+ const v = exactObject(raw, ['stepId', 'change', 'prepared', 'derivedKeys'], 'preparation');
36
+ const stepId = nonempty(v.stepId, 'preparation stepId');
37
+ if (!identity.expectedStepIds.includes(stepId)) throw new Error('Unexpected preparation stepId');
38
+ const change = normalizeChange(v.change);
39
+ const p = exactObject(v.prepared, ['request', 'plan', 'requestPath', 'planPath'], 'prepared GateTool evidence');
40
+ const request = normalizePreparationRequest(p.request), plan = normalizePreparationPlan(p.plan);
41
+ const requestPath = portablePath(p.requestPath, 'request ref'), planPath = portablePath(p.planPath, 'plan ref');
42
+ if (!requestPath.endsWith(`/${stepId}-request.json`) || !planPath.endsWith(`/${stepId}-plan.json`)) throw new Error('Preparation step/ref mismatch');
43
+ if (request.scheme !== 'evm' || plan.scheme !== 'evm') throw new Error('Delivery preparation must use EVM');
44
+ if (plan.requestHash !== hashPreparationRequest(request) || plan.kind !== request.kind || plan.network !== request.network || plan.target !== request.target || plan.contract !== request.contract || plan.target !== identity.target || plan.chainId !== identity.chainId) throw new Error('Preparation request/plan identity mismatch');
45
+ if (change.stepId !== stepId || (change.kind === 'upgrade') !== (plan.kind === 'uups-upgrade' || plan.kind === 'transparent-upgrade') || change.actualContract !== plan.artifact.contractName || (plan.contract.includes(':') && plan.contract !== `${plan.artifact.sourceName}:${plan.artifact.contractName}`)) throw new Error('Preparation change/step/artifact identity mismatch');
46
+ if (canonicalJson(plan.transactions.map(t => t.purpose)) !== canonicalJson(expectedTransactionPurposes(plan))) throw new Error('Preparation transaction purposes/order mismatch');
47
+ if (!sameAddress(change.factory, request.factory) || change.contractInfoKey !== contractInfoKey(change.instanceId, change.actualContract)) throw new Error('Prepared factory/registry identity mismatch');
48
+ if (change.strategy !== ((plan.kind === 'uups-upgrade' || plan.kind === 'transparent-upgrade') ? 'gate-tool' : 'create2')) throw new Error('Invalid prepared strategy');
49
+ const role = (name: string) => { const matches = plan.deployments.filter(d => d.role === name); if (matches.length !== 1) throw new Error(`Missing/duplicate preparation ${name}`); return matches[0]; };
50
+ const optionalAddress = (key: keyof DeploymentChange, expected: string) => {
51
+ if (Object.hasOwn(change, key) && !sameAddress(change[key], expected)) throw new Error(`Prepared ${key} does not match its canonical address`);
52
+ };
53
+ const rejectFields = (...keys: (keyof DeploymentChange)[]) => {
54
+ for (const key of keys) if (Object.hasOwn(change, key)) throw new Error(`Prepared ${request.kind} cannot contain ${key}`);
55
+ };
56
+ const deploymentPolicy = (policy: GateToolAddressPolicy | undefined, deployedAddress: string) => {
57
+ assertCreate2AddressPolicy('Prepared deployment', deployedAddress, policy ?? {});
58
+ optionalAddress('expectedAddress', deployedAddress);
59
+ if (Object.hasOwn(change, 'leadingZeroBytes') && change.leadingZeroBytes !== policy?.leadingZeroBytes) throw new Error('Prepared leadingZeroBytes differs from request policy');
60
+ };
61
+ if (Object.hasOwn(change, 'constructorArgs') && canonicalJson(change.constructorArgs) !== canonicalJson(request.constructorArgs)) throw new Error('Prepared constructorArgs differ from canonical request');
62
+ if (request.kind === 'create2-deploy') {
63
+ const deployment = role('contract');
64
+ rejectFields('proxyAddress', 'implementationAddress', 'preparedImplementationAddress', 'placeholderImplementationAddress', 'implementationSalt', 'proxyAdminAddress', 'proxyAdminOwner');
65
+ if (change.proxyKind !== undefined || deployment.salt !== request.salt || change.salt !== request.salt || !sameAddress(change.predictedAddress, deployment.address)) throw new Error('Prepared CREATE2 request/deployment mismatch');
66
+ optionalAddress('address', deployment.address);
67
+ deploymentPolicy(request.addressPolicy, deployment.address);
68
+ } else {
69
+ const implementation = role('implementation');
70
+ if (change.proxyKind !== request.proxyKind || !sameAddress(change.implementationAddress, implementation.address) || implementation.salt !== request.implementationSalt) throw new Error('Prepared implementation mismatch');
71
+ optionalAddress('preparedImplementationAddress', implementation.address);
72
+ if(request.proxyKind==='transparent'){
73
+ if(!sameAddress(change.proxyAdminAddress,plan.proxyAdmin?.address)||!sameAddress(change.proxyAdminOwner,request.proxyAdminOwner)||!sameAddress(plan.proxyAdmin?.owner,request.proxyAdminOwner))throw Error('Prepared Transparent ProxyAdmin mismatch');
74
+ }else rejectFields('proxyAdminAddress','proxyAdminOwner');
75
+ if (request.kind === 'uups-placeholder-deploy' || request.kind === 'transparent-deploy') {
76
+ const proxy = role('proxy');
77
+ if (proxy.salt !== request.proxySalt || change.salt !== request.proxySalt || !sameAddress(change.predictedAddress, proxy.address) || (request.kind==='uups-placeholder-deploy'&&!sameAddress(change.placeholderImplementationAddress, request.placeholderImplementation))) throw new Error('Prepared proxy mismatch');
78
+ if(request.kind==='transparent-deploy')rejectFields('placeholderImplementationAddress');
79
+ optionalAddress('address', proxy.address);
80
+ optionalAddress('proxyAddress', proxy.address);
81
+ deploymentPolicy(request.proxyAddressPolicy, proxy.address);
82
+ } else {
83
+ // Deployment address-policy aliases describe a newly created contract/proxy,
84
+ // not the existing proxy or its separately named implementation upgrade.
85
+ rejectFields('salt', 'predictedAddress', 'expectedAddress', 'leadingZeroBytes', 'placeholderImplementationAddress', 'previousAddress', 'redeployReason');
86
+ if (!sameAddress(change.proxyAddress, request.proxy)) throw new Error('Prepared upgrade proxy mismatch');
87
+ optionalAddress('address', request.proxy);
88
+ assertCreate2AddressPolicy('Prepared implementation', implementation.address, request.implementationAddressPolicy ?? {});
89
+ }
90
+ }
91
+ if (change.gateTool?.outputPath !== planPath || canonicalJson(change.gateTool?.data) !== canonicalJson(plan)) throw new Error('Prepared embedded GateTool plan mismatch');
92
+ if (!Array.isArray(v.derivedKeys) || v.derivedKeys.some(k => typeof k !== 'string') || new Set(v.derivedKeys).size !== v.derivedKeys.length) throw new Error('Invalid derivedKeys');
93
+ const derivedKeys = v.derivedKeys as string[];
94
+ if (plan.kind !== 'create2-deploy' && (derivedKeys.length !== 1 || derivedKeys[0] !== `${stepId}.implementation` || change.implementationSalt !== (request as { implementationSalt: string }).implementationSalt)) throw new Error('Preparation derived binding mismatch');
95
+ if (plan.kind === 'create2-deploy' && derivedKeys.length) throw new Error('Unexpected derived bindings');
96
+ return deepFreeze({ stepId, change, prepared: { request, plan, requestPath, planPath }, derivedKeys });
97
+ }
98
+ function normalizeMapping(raw: unknown): PreparationMapping {
99
+ const m = exactObject(raw, ['transactionId', 'gateToolTransactionIds', 'kind'], 'preparation mapping');
100
+ nonempty(m.transactionId, 'mapping transactionId');
101
+ if (m.kind !== 'multicall' && m.kind !== 'direct') throw new Error('Invalid mapping kind');
102
+ if (!Array.isArray(m.gateToolTransactionIds) || !m.gateToolTransactionIds.length || m.gateToolTransactionIds.some(id => typeof id !== 'string') || new Set(m.gateToolTransactionIds).size !== m.gateToolTransactionIds.length) throw new Error('Invalid mapping GateTool IDs');
103
+ return m as unknown as PreparationMapping;
104
+ }
105
+ function entryBody(input: PreparationInput, mappings: PreparationMapping[]) {
106
+ return { ...input, requestHash: hashPreparationRequest(input.prepared.request), gateToolPlanHash: semanticHash(input.prepared.plan), mappings };
107
+ }
108
+ function validateMappings(entry: PreparationEntry, transactions: readonly ReleaseExecutionTransaction[], derived: DerivedBindings, used: Set<string>): void {
109
+ const innerIds = entry.mappings.flatMap(m => m.gateToolTransactionIds);
110
+ const expectedIds = entry.prepared.plan.transactions.map(t => t.id);
111
+ if (canonicalJson(innerIds) !== canonicalJson(expectedIds)) throw new Error('missing, extra, duplicate or out-of-order preparation mapping');
112
+ for (const key of entry.derivedKeys) if (!Object.hasOwn(derived.values, key) || derived.values[key] !== entry.change.implementationSalt) throw new Error('Preparation derived value mismatch');
113
+ let previousIndex = -1;
114
+ for (const m of entry.mappings) {
115
+ const tx = transactions.find(t => t.transactionId === m.transactionId);
116
+ if (!tx || used.has(m.transactionId) || (tx.stepId !== entry.stepId && tx.stepId !== `${entry.stepId}-implementation`) || tx.transactionIndex <= previousIndex) throw new Error('Invalid preparation transaction mapping');
117
+ used.add(m.transactionId); previousIndex = tx.transactionIndex;
118
+ const inner = m.gateToolTransactionIds.map(id => entry.prepared.plan.transactions.find(t => t.id === id)!);
119
+ if (m.kind === 'direct' && inner.length !== 1) throw new Error('Direct mapping must contain exactly one transaction');
120
+ if (m.kind === 'multicall' && !entry.change.multicall) throw new Error('Missing multicall address');
121
+ const envelope = m.kind === 'direct' ? { target: inner[0].to, value: inner[0].value, data: inner[0].data, operation: inner[0].operation }
122
+ : prepareControlledMulticallTransaction(entry.change.multicall!, inner.map(t => ({ target: t.to, value: t.value, data: t.data })));
123
+ if (tx.to.toLowerCase() !== envelope.target.toLowerCase() || tx.value !== envelope.value || tx.data !== envelope.data.toLowerCase() || tx.operation !== envelope.operation || tx.scheme !== undefined) throw new Error('Preparation transaction envelope mismatch');
124
+ }
125
+ }
126
+ export function parsePreparationJournal(raw: unknown, transactions: readonly ReleaseExecutionTransaction[], derived: DerivedBindings, identity: JournalIdentity): PreparationEntry[] {
127
+ if (!Array.isArray(raw)) throw new Error('Preparation journal must be an array');
128
+ const entries = raw.map(item => {
129
+ const v = exactObject(item, ['stepId', 'change', 'prepared', 'derivedKeys', 'requestHash', 'gateToolPlanHash', 'mappings', 'preparationHash'], 'preparation entry');
130
+ const input = normalizeInput({ stepId: v.stepId, change: v.change, prepared: v.prepared, derivedKeys: v.derivedKeys }, identity);
131
+ if (!Array.isArray(v.mappings)) throw new Error('Invalid mappings');
132
+ const body = entryBody(input, v.mappings.map(normalizeMapping));
133
+ if (digest(v.requestHash, 'requestHash') !== body.requestHash || digest(v.gateToolPlanHash, 'GateTool plan hash') !== body.gateToolPlanHash || digest(v.preparationHash, 'preparationHash') !== semanticHash(body)) throw new Error('Preparation content hash mismatch');
134
+ return { ...body, preparationHash: semanticHash(body) };
135
+ });
136
+ if (canonicalJson(entries.map(e => e.stepId)) !== canonicalJson(identity.expectedStepIds)) throw new Error('missing, extra or duplicate preparation steps');
137
+ for (const [index, entry] of entries.entries()) {
138
+ const {request,plan} = entry.prepared;
139
+ if ((request.kind === 'uups-upgrade' || request.kind === 'transparent-upgrade') && (plan.validation.kind === 'uups-upgrade' || plan.validation.kind === 'transparent-upgrade') && plan.validation.sameForkBaselineDigest !== undefined) {
140
+ const validation = plan.validation;
141
+ const prior = entries.slice(0,index).filter(e => matchesSameForkInitial(e.prepared,request.target,plan.chainId,request.proxy,validation.currentImplementation,request.proxyKind));
142
+ if (prior.length !== 1 || sameForkBaselineDigest(prior[0].prepared,validation.oldLayoutHash) !== validation.sameForkBaselineDigest) throw new Error('Same-fork upgrade requires its exact prior initial preparation');
143
+ }
144
+ }
145
+ const used = new Set<string>();
146
+ for (const entry of entries) validateMappings(entry, transactions, derived, used);
147
+ for (const tx of transactions) if (identity.expectedStepIds.some(id => tx.stepId === id || tx.stepId === `${id}-implementation`) && !used.has(tx.transactionId)) throw new Error('Unresolved expected preparation transaction');
148
+ return deepFreeze(canonicalData(entries) as PreparationEntry[]);
149
+ }
150
+ export class PreparationJournal implements PreparationSink {
151
+ private readonly identity: Omit<JournalIdentity, "expectedStepIds"> & { expectedStepIds: string[] };
152
+ private readonly inputs: PreparationInput[] = [];
153
+ private readonly mappings = new Map<string, PreparationMapping[]>();
154
+ private readonly prior: PreparationEntry[];
155
+ private sealed = false;
156
+ private readonly qualifiedSameFork?: (initial: PreparedGateToolWorkflow) => boolean;
157
+ constructor(input: JournalIdentity & { expected?: readonly PreparationEntry[]; qualifiedSameFork?: (initial: PreparedGateToolWorkflow) => boolean }) {
158
+ this.qualifiedSameFork = input.qualifiedSameFork;
159
+ this.identity = { target: input.target, chainId: input.chainId, expectedStepIds: [...input.expectedStepIds] };
160
+ if (new Set(input.expectedStepIds).size !== input.expectedStepIds.length) throw new Error('Duplicate preparation step');
161
+ // Full binding validation occurs against the sealed plan at the coordinator/parser boundary.
162
+ this.prior = deepFreeze(canonicalData(input.expected ?? []) as PreparationEntry[]);
163
+ }
164
+ declare(stepIds: readonly string[]): void {
165
+ if (this.sealed) throw new Error("Preparation journal sealed");
166
+ for (const id of stepIds) {
167
+ nonempty(id, "preparation step");
168
+ if (this.identity.expectedStepIds.includes(id)) throw new Error("Duplicate preparation step");
169
+ this.identity.expectedStepIds.push(id);
170
+ }
171
+ }
172
+ expected(stepId: string, request: GateToolPreparationRequestV1): PreparedGateToolWorkflow | undefined {
173
+ const entry = this.prior.find(e => e.stepId === stepId);
174
+ if (!entry) { if (this.prior.length) throw new Error('Missing expected preparation'); return undefined; }
175
+ const input = normalizeInput({ stepId: entry.stepId, change: entry.change, prepared: entry.prepared, derivedKeys: entry.derivedKeys }, this.identity);
176
+ exactObject(entry, ['stepId', 'change', 'prepared', 'derivedKeys', 'requestHash', 'gateToolPlanHash', 'mappings', 'preparationHash'], 'expected preparation');
177
+ if (entry.requestHash !== hashPreparationRequest(input.prepared.request) || entry.gateToolPlanHash !== semanticHash(input.prepared.plan) || semanticHash(entryBody(input, entry.mappings.map(normalizeMapping))) !== entry.preparationHash) throw new Error('Expected preparation hash mismatch');
178
+ if (canonicalJson(normalizePreparationRequest(request)) !== canonicalJson(input.prepared.request)) throw new Error('Expected preparation request mismatch');
179
+ return input.prepared;
180
+ }
181
+ prepare(raw: PreparationInput): void {
182
+ if (this.sealed) throw new Error('Preparation journal sealed');
183
+ const input = normalizeInput(raw, this.identity);
184
+ if (this.inputs.some(i => i.stepId === input.stepId)) throw new Error('Duplicate preparation');
185
+ this.inputs.push(input); this.mappings.set(input.stepId, []);
186
+ }
187
+ bind(stepId: string, raw: PreparationMapping): void {
188
+ if (this.sealed) throw new Error('Preparation journal sealed');
189
+ const mappings = this.mappings.get(stepId);
190
+ if (!mappings) throw new Error('Mapping has no prepared step');
191
+ mappings.push(normalizeMapping(raw));
192
+ }
193
+ assertUpgradeBaseline(proxy: string): boolean {
194
+ const matches = this.inputs.filter(i => matchesSameForkInitial(i.prepared,this.identity.target,this.identity.chainId,proxy));
195
+ if (!matches.length) return false;
196
+ if (matches.length !== 1 || !this.qualifiedSameFork?.(matches[0].prepared)) throw new Error('Same-fork proxy upgrade requires a complete validated immutable OZ layout baseline; unsupported without that evidence');
197
+ return true;
198
+ }
199
+ seal(transactions: readonly ReleaseExecutionTransaction[], derived: DerivedBindings): PreparationEntry[] {
200
+ const raw = this.inputs.map(input => { const body = entryBody(input, this.mappings.get(input.stepId)!); return { ...body, preparationHash: semanticHash(body) }; });
201
+ const entries = parsePreparationJournal(raw, transactions, derived, this.identity);
202
+ if (this.prior.length && canonicalJson(entries) !== canonicalJson(this.prior)) throw new Error('Preparation replay differs from sealed evidence');
203
+ this.sealed = true; return entries;
204
+ }
205
+ }