@0xsequence/catapult 1.1.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 (393) hide show
  1. package/.eslintrc.json +29 -0
  2. package/.github/workflows/ci.yml +181 -0
  3. package/CONCEPT.md +24 -0
  4. package/README.md +772 -0
  5. package/contracts/checked-call.huff +65 -0
  6. package/dist/cli.d.ts +3 -0
  7. package/dist/cli.d.ts.map +1 -0
  8. package/dist/cli.js +16 -0
  9. package/dist/cli.js.map +1 -0
  10. package/dist/commands/common.d.ts +11 -0
  11. package/dist/commands/common.d.ts.map +1 -0
  12. package/dist/commands/common.js +73 -0
  13. package/dist/commands/common.js.map +1 -0
  14. package/dist/commands/dry.d.ts +3 -0
  15. package/dist/commands/dry.d.ts.map +1 -0
  16. package/dist/commands/dry.js +171 -0
  17. package/dist/commands/dry.js.map +1 -0
  18. package/dist/commands/etherscan.d.ts +3 -0
  19. package/dist/commands/etherscan.d.ts.map +1 -0
  20. package/dist/commands/etherscan.js +323 -0
  21. package/dist/commands/etherscan.js.map +1 -0
  22. package/dist/commands/index.d.ts +6 -0
  23. package/dist/commands/index.d.ts.map +1 -0
  24. package/dist/commands/index.js +22 -0
  25. package/dist/commands/index.js.map +1 -0
  26. package/dist/commands/list.d.ts +3 -0
  27. package/dist/commands/list.d.ts.map +1 -0
  28. package/dist/commands/list.js +259 -0
  29. package/dist/commands/list.js.map +1 -0
  30. package/dist/commands/run.d.ts +3 -0
  31. package/dist/commands/run.d.ts.map +1 -0
  32. package/dist/commands/run.js +96 -0
  33. package/dist/commands/run.js.map +1 -0
  34. package/dist/commands/utils.d.ts +3 -0
  35. package/dist/commands/utils.d.ts.map +1 -0
  36. package/dist/commands/utils.js +46 -0
  37. package/dist/commands/utils.js.map +1 -0
  38. package/dist/index.d.ts +4 -0
  39. package/dist/index.d.ts.map +1 -0
  40. package/dist/index.js +58 -0
  41. package/dist/index.js.map +1 -0
  42. package/dist/lib/__tests__/deployer-events.spec.d.ts +2 -0
  43. package/dist/lib/__tests__/deployer-events.spec.d.ts.map +1 -0
  44. package/dist/lib/__tests__/deployer-events.spec.js +260 -0
  45. package/dist/lib/__tests__/deployer-events.spec.js.map +1 -0
  46. package/dist/lib/__tests__/deployer.spec.d.ts +2 -0
  47. package/dist/lib/__tests__/deployer.spec.d.ts.map +1 -0
  48. package/dist/lib/__tests__/deployer.spec.js +884 -0
  49. package/dist/lib/__tests__/deployer.spec.js.map +1 -0
  50. package/dist/lib/__tests__/network-utils.spec.d.ts +2 -0
  51. package/dist/lib/__tests__/network-utils.spec.d.ts.map +1 -0
  52. package/dist/lib/__tests__/network-utils.spec.js +140 -0
  53. package/dist/lib/__tests__/network-utils.spec.js.map +1 -0
  54. package/dist/lib/contracts/__tests__/repository.spec.d.ts +2 -0
  55. package/dist/lib/contracts/__tests__/repository.spec.d.ts.map +1 -0
  56. package/dist/lib/contracts/__tests__/repository.spec.js +321 -0
  57. package/dist/lib/contracts/__tests__/repository.spec.js.map +1 -0
  58. package/dist/lib/contracts/repository.d.ts +27 -0
  59. package/dist/lib/contracts/repository.d.ts.map +1 -0
  60. package/dist/lib/contracts/repository.js +241 -0
  61. package/dist/lib/contracts/repository.js.map +1 -0
  62. package/dist/lib/core/__tests__/engine.spec.d.ts +2 -0
  63. package/dist/lib/core/__tests__/engine.spec.d.ts.map +1 -0
  64. package/dist/lib/core/__tests__/engine.spec.js +1212 -0
  65. package/dist/lib/core/__tests__/engine.spec.js.map +1 -0
  66. package/dist/lib/core/__tests__/graph.spec.d.ts +2 -0
  67. package/dist/lib/core/__tests__/graph.spec.d.ts.map +1 -0
  68. package/dist/lib/core/__tests__/graph.spec.js +116 -0
  69. package/dist/lib/core/__tests__/graph.spec.js.map +1 -0
  70. package/dist/lib/core/__tests__/json-integration.spec.d.ts +2 -0
  71. package/dist/lib/core/__tests__/json-integration.spec.d.ts.map +1 -0
  72. package/dist/lib/core/__tests__/json-integration.spec.js +300 -0
  73. package/dist/lib/core/__tests__/json-integration.spec.js.map +1 -0
  74. package/dist/lib/core/__tests__/loader.spec.d.ts +2 -0
  75. package/dist/lib/core/__tests__/loader.spec.d.ts.map +1 -0
  76. package/dist/lib/core/__tests__/loader.spec.js +288 -0
  77. package/dist/lib/core/__tests__/loader.spec.js.map +1 -0
  78. package/dist/lib/core/__tests__/multi-platform-verification.spec.d.ts +2 -0
  79. package/dist/lib/core/__tests__/multi-platform-verification.spec.d.ts.map +1 -0
  80. package/dist/lib/core/__tests__/multi-platform-verification.spec.js +342 -0
  81. package/dist/lib/core/__tests__/multi-platform-verification.spec.js.map +1 -0
  82. package/dist/lib/core/__tests__/resolver.spec.d.ts +2 -0
  83. package/dist/lib/core/__tests__/resolver.spec.d.ts.map +1 -0
  84. package/dist/lib/core/__tests__/resolver.spec.js +1367 -0
  85. package/dist/lib/core/__tests__/resolver.spec.js.map +1 -0
  86. package/dist/lib/core/__tests__/static-action.spec.d.ts +2 -0
  87. package/dist/lib/core/__tests__/static-action.spec.d.ts.map +1 -0
  88. package/dist/lib/core/__tests__/static-action.spec.js +136 -0
  89. package/dist/lib/core/__tests__/static-action.spec.js.map +1 -0
  90. package/dist/lib/core/context.d.ts +29 -0
  91. package/dist/lib/core/context.d.ts.map +1 -0
  92. package/dist/lib/core/context.js +88 -0
  93. package/dist/lib/core/context.js.map +1 -0
  94. package/dist/lib/core/engine.d.ts +25 -0
  95. package/dist/lib/core/engine.d.ts.map +1 -0
  96. package/dist/lib/core/engine.js +1191 -0
  97. package/dist/lib/core/engine.js.map +1 -0
  98. package/dist/lib/core/graph.d.ts +18 -0
  99. package/dist/lib/core/graph.d.ts.map +1 -0
  100. package/dist/lib/core/graph.js +158 -0
  101. package/dist/lib/core/graph.js.map +1 -0
  102. package/dist/lib/core/loader.d.ts +25 -0
  103. package/dist/lib/core/loader.d.ts.map +1 -0
  104. package/dist/lib/core/loader.js +248 -0
  105. package/dist/lib/core/loader.js.map +1 -0
  106. package/dist/lib/core/resolver.d.ts +20 -0
  107. package/dist/lib/core/resolver.d.ts.map +1 -0
  108. package/dist/lib/core/resolver.js +307 -0
  109. package/dist/lib/core/resolver.js.map +1 -0
  110. package/dist/lib/deployer.d.ts +39 -0
  111. package/dist/lib/deployer.d.ts.map +1 -0
  112. package/dist/lib/deployer.js +533 -0
  113. package/dist/lib/deployer.js.map +1 -0
  114. package/dist/lib/events/__tests__/event-system.spec.d.ts +2 -0
  115. package/dist/lib/events/__tests__/event-system.spec.d.ts.map +1 -0
  116. package/dist/lib/events/__tests__/event-system.spec.js +256 -0
  117. package/dist/lib/events/__tests__/event-system.spec.js.map +1 -0
  118. package/dist/lib/events/cli-adapter.d.ts +13 -0
  119. package/dist/lib/events/cli-adapter.d.ts.map +1 -0
  120. package/dist/lib/events/cli-adapter.js +244 -0
  121. package/dist/lib/events/cli-adapter.js.map +1 -0
  122. package/dist/lib/events/emitter.d.ts +11 -0
  123. package/dist/lib/events/emitter.d.ts.map +1 -0
  124. package/dist/lib/events/emitter.js +29 -0
  125. package/dist/lib/events/emitter.js.map +1 -0
  126. package/dist/lib/events/index.d.ts +4 -0
  127. package/dist/lib/events/index.d.ts.map +1 -0
  128. package/dist/lib/events/index.js +20 -0
  129. package/dist/lib/events/index.js.map +1 -0
  130. package/dist/lib/events/types.d.ts +368 -0
  131. package/dist/lib/events/types.d.ts.map +1 -0
  132. package/dist/lib/events/types.js +3 -0
  133. package/dist/lib/events/types.js.map +1 -0
  134. package/dist/lib/index.d.ts +5 -0
  135. package/dist/lib/index.d.ts.map +1 -0
  136. package/dist/lib/index.js +44 -0
  137. package/dist/lib/index.js.map +1 -0
  138. package/dist/lib/network-loader.d.ts +3 -0
  139. package/dist/lib/network-loader.d.ts.map +1 -0
  140. package/dist/lib/network-loader.js +80 -0
  141. package/dist/lib/network-loader.js.map +1 -0
  142. package/dist/lib/network-match.d.ts +3 -0
  143. package/dist/lib/network-match.d.ts.map +1 -0
  144. package/dist/lib/network-match.js +62 -0
  145. package/dist/lib/network-match.js.map +1 -0
  146. package/dist/lib/network-utils.d.ts +4 -0
  147. package/dist/lib/network-utils.d.ts.map +1 -0
  148. package/dist/lib/network-utils.js +39 -0
  149. package/dist/lib/network-utils.js.map +1 -0
  150. package/dist/lib/parsers/__tests__/buildinfo.spec.d.ts +2 -0
  151. package/dist/lib/parsers/__tests__/buildinfo.spec.d.ts.map +1 -0
  152. package/dist/lib/parsers/__tests__/buildinfo.spec.js +132 -0
  153. package/dist/lib/parsers/__tests__/buildinfo.spec.js.map +1 -0
  154. package/dist/lib/parsers/__tests__/job.spec.d.ts +2 -0
  155. package/dist/lib/parsers/__tests__/job.spec.d.ts.map +1 -0
  156. package/dist/lib/parsers/__tests__/job.spec.js +318 -0
  157. package/dist/lib/parsers/__tests__/job.spec.js.map +1 -0
  158. package/dist/lib/parsers/__tests__/template.spec.d.ts +2 -0
  159. package/dist/lib/parsers/__tests__/template.spec.d.ts.map +1 -0
  160. package/dist/lib/parsers/__tests__/template.spec.js +126 -0
  161. package/dist/lib/parsers/__tests__/template.spec.js.map +1 -0
  162. package/dist/lib/parsers/artifact/__tests__/artifact.spec.d.ts +2 -0
  163. package/dist/lib/parsers/artifact/__tests__/artifact.spec.d.ts.map +1 -0
  164. package/dist/lib/parsers/artifact/__tests__/artifact.spec.js +128 -0
  165. package/dist/lib/parsers/artifact/__tests__/artifact.spec.js.map +1 -0
  166. package/dist/lib/parsers/artifact/foundry-1.2.d.ts +3 -0
  167. package/dist/lib/parsers/artifact/foundry-1.2.d.ts.map +1 -0
  168. package/dist/lib/parsers/artifact/foundry-1.2.js +82 -0
  169. package/dist/lib/parsers/artifact/foundry-1.2.js.map +1 -0
  170. package/dist/lib/parsers/artifact/index.d.ts +3 -0
  171. package/dist/lib/parsers/artifact/index.d.ts.map +1 -0
  172. package/dist/lib/parsers/artifact/index.js +17 -0
  173. package/dist/lib/parsers/artifact/index.js.map +1 -0
  174. package/dist/lib/parsers/artifact/types.d.ts +3 -0
  175. package/dist/lib/parsers/artifact/types.d.ts.map +1 -0
  176. package/dist/lib/parsers/artifact/types.js +3 -0
  177. package/dist/lib/parsers/artifact/types.js.map +1 -0
  178. package/dist/lib/parsers/buildinfo.d.ts +5 -0
  179. package/dist/lib/parsers/buildinfo.d.ts.map +1 -0
  180. package/dist/lib/parsers/buildinfo.js +85 -0
  181. package/dist/lib/parsers/buildinfo.js.map +1 -0
  182. package/dist/lib/parsers/constants.d.ts +4 -0
  183. package/dist/lib/parsers/constants.d.ts.map +1 -0
  184. package/dist/lib/parsers/constants.js +45 -0
  185. package/dist/lib/parsers/constants.js.map +1 -0
  186. package/dist/lib/parsers/index.d.ts +5 -0
  187. package/dist/lib/parsers/index.d.ts.map +1 -0
  188. package/dist/lib/parsers/index.js +21 -0
  189. package/dist/lib/parsers/index.js.map +1 -0
  190. package/dist/lib/parsers/job.d.ts +3 -0
  191. package/dist/lib/parsers/job.d.ts.map +1 -0
  192. package/dist/lib/parsers/job.js +74 -0
  193. package/dist/lib/parsers/job.js.map +1 -0
  194. package/dist/lib/parsers/template.d.ts +3 -0
  195. package/dist/lib/parsers/template.d.ts.map +1 -0
  196. package/dist/lib/parsers/template.js +91 -0
  197. package/dist/lib/parsers/template.js.map +1 -0
  198. package/dist/lib/std/templates/assured-deployment.yaml +45 -0
  199. package/dist/lib/std/templates/erc-2470.yaml +67 -0
  200. package/dist/lib/std/templates/min-balance.yaml +32 -0
  201. package/dist/lib/std/templates/nano-universal-deployer.yaml +59 -0
  202. package/dist/lib/std/templates/raw-erc-2470.yaml +59 -0
  203. package/dist/lib/std/templates/raw-nano-universal-deployer.yaml +51 -0
  204. package/dist/lib/std/templates/raw-sequence-universal-deployer-2.yaml +48 -0
  205. package/dist/lib/std/templates/sequence-universal-deployer-2.yaml +57 -0
  206. package/dist/lib/types/__tests__/json-request-action.spec.d.ts +2 -0
  207. package/dist/lib/types/__tests__/json-request-action.spec.d.ts.map +1 -0
  208. package/dist/lib/types/__tests__/json-request-action.spec.js +219 -0
  209. package/dist/lib/types/__tests__/json-request-action.spec.js.map +1 -0
  210. package/dist/lib/types/__tests__/read-json-value.spec.d.ts +2 -0
  211. package/dist/lib/types/__tests__/read-json-value.spec.d.ts.map +1 -0
  212. package/dist/lib/types/__tests__/read-json-value.spec.js +233 -0
  213. package/dist/lib/types/__tests__/read-json-value.spec.js.map +1 -0
  214. package/dist/lib/types/actions.d.ts +74 -0
  215. package/dist/lib/types/actions.d.ts.map +1 -0
  216. package/dist/lib/types/actions.js +18 -0
  217. package/dist/lib/types/actions.js.map +1 -0
  218. package/dist/lib/types/artifacts.d.ts +15 -0
  219. package/dist/lib/types/artifacts.d.ts.map +1 -0
  220. package/dist/lib/types/artifacts.js +3 -0
  221. package/dist/lib/types/artifacts.js.map +1 -0
  222. package/dist/lib/types/buildinfo.d.ts +112 -0
  223. package/dist/lib/types/buildinfo.d.ts.map +1 -0
  224. package/dist/lib/types/buildinfo.js +3 -0
  225. package/dist/lib/types/buildinfo.js.map +1 -0
  226. package/dist/lib/types/conditions.d.ts +17 -0
  227. package/dist/lib/types/conditions.d.ts.map +1 -0
  228. package/dist/lib/types/conditions.js +21 -0
  229. package/dist/lib/types/conditions.js.map +1 -0
  230. package/dist/lib/types/contracts.d.ts +14 -0
  231. package/dist/lib/types/contracts.d.ts.map +1 -0
  232. package/dist/lib/types/contracts.js +3 -0
  233. package/dist/lib/types/contracts.js.map +1 -0
  234. package/dist/lib/types/definitions.d.ts +51 -0
  235. package/dist/lib/types/definitions.d.ts.map +1 -0
  236. package/dist/lib/types/definitions.js +3 -0
  237. package/dist/lib/types/definitions.js.map +1 -0
  238. package/dist/lib/types/index.d.ts +9 -0
  239. package/dist/lib/types/index.d.ts.map +1 -0
  240. package/dist/lib/types/index.js +25 -0
  241. package/dist/lib/types/index.js.map +1 -0
  242. package/dist/lib/types/network.d.ts +9 -0
  243. package/dist/lib/types/network.d.ts.map +1 -0
  244. package/dist/lib/types/network.js +3 -0
  245. package/dist/lib/types/network.js.map +1 -0
  246. package/dist/lib/types/project.d.ts +5 -0
  247. package/dist/lib/types/project.d.ts.map +1 -0
  248. package/dist/lib/types/project.js +3 -0
  249. package/dist/lib/types/project.js.map +1 -0
  250. package/dist/lib/types/task.d.ts +9 -0
  251. package/dist/lib/types/task.d.ts.map +1 -0
  252. package/dist/lib/types/task.js +3 -0
  253. package/dist/lib/types/task.js.map +1 -0
  254. package/dist/lib/types/values.d.ts +78 -0
  255. package/dist/lib/types/values.d.ts.map +1 -0
  256. package/dist/lib/types/values.js +3 -0
  257. package/dist/lib/types/values.js.map +1 -0
  258. package/dist/lib/utils/validation.d.ts +5 -0
  259. package/dist/lib/utils/validation.d.ts.map +1 -0
  260. package/dist/lib/utils/validation.js +77 -0
  261. package/dist/lib/utils/validation.js.map +1 -0
  262. package/dist/lib/validation/contract-references.d.ts +12 -0
  263. package/dist/lib/validation/contract-references.d.ts.map +1 -0
  264. package/dist/lib/validation/contract-references.js +112 -0
  265. package/dist/lib/validation/contract-references.js.map +1 -0
  266. package/dist/lib/validation/index.d.ts +1 -0
  267. package/dist/lib/validation/index.d.ts.map +1 -0
  268. package/dist/lib/validation/index.js +2 -0
  269. package/dist/lib/validation/index.js.map +1 -0
  270. package/dist/lib/verification/__tests__/etherscan.spec.d.ts +2 -0
  271. package/dist/lib/verification/__tests__/etherscan.spec.d.ts.map +1 -0
  272. package/dist/lib/verification/__tests__/etherscan.spec.js +565 -0
  273. package/dist/lib/verification/__tests__/etherscan.spec.js.map +1 -0
  274. package/dist/lib/verification/__tests__/sourcify.spec.d.ts +2 -0
  275. package/dist/lib/verification/__tests__/sourcify.spec.d.ts.map +1 -0
  276. package/dist/lib/verification/__tests__/sourcify.spec.js +212 -0
  277. package/dist/lib/verification/__tests__/sourcify.spec.js.map +1 -0
  278. package/dist/lib/verification/etherscan.d.ts +56 -0
  279. package/dist/lib/verification/etherscan.d.ts.map +1 -0
  280. package/dist/lib/verification/etherscan.js +340 -0
  281. package/dist/lib/verification/etherscan.js.map +1 -0
  282. package/dist/lib/verification/sourcify.d.ts +12 -0
  283. package/dist/lib/verification/sourcify.d.ts.map +1 -0
  284. package/dist/lib/verification/sourcify.js +227 -0
  285. package/dist/lib/verification/sourcify.js.map +1 -0
  286. package/eslint.config.js +48 -0
  287. package/examples/jobs/guards-v1.yaml +17 -0
  288. package/examples/jobs/sequence-seq-0001-patch.yaml +59 -0
  289. package/examples/jobs/sequence-v1.yaml +59 -0
  290. package/examples/templates/sequence-factory-v1.yaml +56 -0
  291. package/jest.config.js +25 -0
  292. package/package.json +68 -0
  293. package/src/cli.ts +17 -0
  294. package/src/commands/common.ts +61 -0
  295. package/src/commands/dry.ts +208 -0
  296. package/src/commands/etherscan.ts +360 -0
  297. package/src/commands/index.ts +5 -0
  298. package/src/commands/list.ts +249 -0
  299. package/src/commands/run.ts +136 -0
  300. package/src/commands/utils.ts +52 -0
  301. package/src/index.ts +67 -0
  302. package/src/lib/__tests__/deployer-events.spec.ts +338 -0
  303. package/src/lib/__tests__/deployer.spec.ts +1204 -0
  304. package/src/lib/__tests__/network-utils.spec.ts +181 -0
  305. package/src/lib/artifacts/__tests__/fixtures/contract1.json +19 -0
  306. package/src/lib/artifacts/__tests__/fixtures/contract2.json +19 -0
  307. package/src/lib/artifacts/__tests__/fixtures/duplicate-name.json +19 -0
  308. package/src/lib/artifacts/__tests__/fixtures/nested/nested-contract.json +18 -0
  309. package/src/lib/artifacts/__tests__/fixtures/not-an-artifact.json +8 -0
  310. package/src/lib/artifacts/__tests__/fixtures/readme.txt +2 -0
  311. package/src/lib/contracts/__tests__/repository.spec.ts +344 -0
  312. package/src/lib/contracts/repository.ts +313 -0
  313. package/src/lib/core/__tests__/engine.spec.ts +1514 -0
  314. package/src/lib/core/__tests__/graph.spec.ts +125 -0
  315. package/src/lib/core/__tests__/json-integration.spec.ts +360 -0
  316. package/src/lib/core/__tests__/loader.spec.ts +334 -0
  317. package/src/lib/core/__tests__/multi-platform-verification.spec.ts +406 -0
  318. package/src/lib/core/__tests__/resolver.spec.ts +1693 -0
  319. package/src/lib/core/__tests__/static-action.spec.ts +172 -0
  320. package/src/lib/core/context.ts +127 -0
  321. package/src/lib/core/engine.ts +1531 -0
  322. package/src/lib/core/graph.ts +252 -0
  323. package/src/lib/core/loader.ts +263 -0
  324. package/src/lib/core/resolver.ts +498 -0
  325. package/src/lib/deployer.ts +768 -0
  326. package/src/lib/events/__tests__/event-system.spec.ts +343 -0
  327. package/src/lib/events/cli-adapter.ts +325 -0
  328. package/src/lib/events/emitter.ts +62 -0
  329. package/src/lib/events/index.ts +3 -0
  330. package/src/lib/events/types.ts +469 -0
  331. package/src/lib/index.ts +14 -0
  332. package/src/lib/network-loader.ts +59 -0
  333. package/src/lib/network-utils.ts +64 -0
  334. package/src/lib/parsers/__tests__/buildinfo.spec.ts +122 -0
  335. package/src/lib/parsers/__tests__/fixtures/buildinfo/invalid-bytecode-buildinfo.json +62 -0
  336. package/src/lib/parsers/__tests__/fixtures/buildinfo/invalid-json.txt +2 -0
  337. package/src/lib/parsers/__tests__/fixtures/buildinfo/multi-contract-buildinfo.json +89 -0
  338. package/src/lib/parsers/__tests__/fixtures/buildinfo/no-contracts-buildinfo.json +17 -0
  339. package/src/lib/parsers/__tests__/fixtures/buildinfo/simple-buildinfo.json +63 -0
  340. package/src/lib/parsers/__tests__/fixtures/buildinfo/wrong-format.json +4 -0
  341. package/src/lib/parsers/__tests__/job.spec.ts +335 -0
  342. package/src/lib/parsers/__tests__/template.spec.ts +111 -0
  343. package/src/lib/parsers/artifact/__tests__/artifact.spec.ts +117 -0
  344. package/src/lib/parsers/artifact/__tests__/fixtures/empty-bytecode.json +5 -0
  345. package/src/lib/parsers/artifact/__tests__/fixtures/hardhat-artifact.json +67 -0
  346. package/src/lib/parsers/artifact/__tests__/fixtures/invalid-bytecode.json +5 -0
  347. package/src/lib/parsers/artifact/__tests__/fixtures/invalid-json.txt +11 -0
  348. package/src/lib/parsers/artifact/__tests__/fixtures/minimal-artifact.json +5 -0
  349. package/src/lib/parsers/artifact/__tests__/fixtures/missing-abi.json +4 -0
  350. package/src/lib/parsers/artifact/__tests__/fixtures/missing-bytecode.json +11 -0
  351. package/src/lib/parsers/artifact/__tests__/fixtures/missing-contract-name.json +11 -0
  352. package/src/lib/parsers/artifact/__tests__/fixtures/simple-artifact.json +40 -0
  353. package/src/lib/parsers/artifact/__tests__/fixtures/wrong-types.json +7 -0
  354. package/src/lib/parsers/artifact/foundry-1.2.ts +72 -0
  355. package/src/lib/parsers/artifact/index.ts +27 -0
  356. package/src/lib/parsers/artifact/types.ts +9 -0
  357. package/src/lib/parsers/buildinfo.ts +127 -0
  358. package/src/lib/parsers/constants.ts +56 -0
  359. package/src/lib/parsers/index.ts +5 -0
  360. package/src/lib/parsers/job.ts +101 -0
  361. package/src/lib/parsers/template.ts +131 -0
  362. package/src/lib/std/templates/assured-deployment.yaml +45 -0
  363. package/src/lib/std/templates/erc-2470.yaml +67 -0
  364. package/src/lib/std/templates/min-balance.yaml +32 -0
  365. package/src/lib/std/templates/nano-universal-deployer.yaml +59 -0
  366. package/src/lib/std/templates/raw-erc-2470.yaml +59 -0
  367. package/src/lib/std/templates/raw-nano-universal-deployer.yaml +51 -0
  368. package/src/lib/std/templates/raw-sequence-universal-deployer-2.yaml +48 -0
  369. package/src/lib/std/templates/sequence-universal-deployer-2.yaml +57 -0
  370. package/src/lib/types/__tests__/json-request-action.spec.ts +243 -0
  371. package/src/lib/types/__tests__/read-json-value.spec.ts +264 -0
  372. package/src/lib/types/actions.ts +127 -0
  373. package/src/lib/types/artifacts.ts +21 -0
  374. package/src/lib/types/buildinfo.ts +116 -0
  375. package/src/lib/types/conditions.ts +50 -0
  376. package/src/lib/types/contracts.ts +23 -0
  377. package/src/lib/types/definitions.ts +68 -0
  378. package/src/lib/types/index.ts +8 -0
  379. package/src/lib/types/network.ts +22 -0
  380. package/src/lib/types/project.ts +9 -0
  381. package/src/lib/types/task.ts +9 -0
  382. package/src/lib/types/values.ts +116 -0
  383. package/src/lib/utils/validation.ts +116 -0
  384. package/src/lib/validation/contract-references.ts +210 -0
  385. package/src/lib/validation/index.ts +1 -0
  386. package/src/lib/verification/__tests__/etherscan.spec.ts +710 -0
  387. package/src/lib/verification/__tests__/sourcify.spec.ts +288 -0
  388. package/src/lib/verification/etherscan.ts +546 -0
  389. package/src/lib/verification/sourcify.ts +248 -0
  390. package/test_validation/artifacts/TestContract.json +9 -0
  391. package/test_validation/jobs/test-missing.yaml +16 -0
  392. package/test_validation/networks.yaml +3 -0
  393. package/tsconfig.json +36 -0
@@ -0,0 +1,498 @@
1
+ import { ethers } from 'ethers'
2
+ import {
3
+ Value,
4
+ ValueResolver as ValueResolverObject,
5
+ AbiEncodeValue,
6
+ AbiPackValue,
7
+ ConstructorEncodeValue,
8
+ ComputeCreate2Value,
9
+ ReadBalanceValue,
10
+ BasicArithmeticValue,
11
+ CallValue,
12
+ ContractExistsCondition,
13
+ ContractExistsValue,
14
+ JobCompletedValue,
15
+ ReadJsonValue,
16
+ } from '../types'
17
+ import { ExecutionContext } from './context'
18
+
19
+ /**
20
+ * A scope for resolving local variables, such as template arguments.
21
+ * This allows a template to use placeholders like `{{my_arg}}` which are
22
+ * filled in by the job calling the template.
23
+ */
24
+ export type ResolutionScope = Map<string, any>
25
+
26
+ /**
27
+ * The ValueResolver is responsible for turning declarative `Value` types from
28
+ * the YAML files into concrete, usable data at runtime. It handles placeholders,
29
+ * on-chain data fetching, and dynamic computations like encoding and address calculation.
30
+ */
31
+ export class ValueResolver {
32
+ /**
33
+ * Resolves a `Value<any>` into its final, concrete form.
34
+ * This is the main entry point for the resolver.
35
+ *
36
+ * @param value The value to resolve. It can be a literal, a `{{...}}` reference string,
37
+ * or a `ValueResolver` object (e.g., `{ type: 'abi-encode', ... }`).
38
+ * @param context The execution context, providing access to the provider, signer, and outputs.
39
+ * @param scope The local resolution scope, used for template arguments.
40
+ * @returns A promise that resolves to the final concrete value.
41
+ */
42
+ public async resolve<T>(value: Value<any>, context: ExecutionContext, scope: ResolutionScope = new Map()): Promise<T> {
43
+ // 1. Handle literals (non-string, non-object) and null
44
+ if (typeof value !== 'string' && (typeof value !== 'object' || value === null)) {
45
+ return value as T
46
+ }
47
+
48
+ // 2. Handle string values
49
+ if (typeof value === 'string') {
50
+ const refMatch = value.match(/^{{(.*)}}$/)
51
+ if (refMatch) {
52
+ // It's a reference like `{{...}}`, resolve the expression inside
53
+ const expression = refMatch[1].trim()
54
+ return this.resolveExpression(expression, context, scope)
55
+ }
56
+ // It's a string literal
57
+ return value as T
58
+ }
59
+
60
+ // 3. Handle arrays
61
+ if (Array.isArray(value)) {
62
+ return Promise.all(value.map(item => this.resolve(item, context, scope))) as Promise<T>
63
+ }
64
+
65
+ // 4. Handle ValueResolver objects
66
+ if (typeof value === 'object' && 'type' in value) {
67
+ return this.resolveValueResolverObject(value as ValueResolverObject, context, scope)
68
+ }
69
+
70
+ // 5. Handle plain objects as literals (for JSON data)
71
+ if (typeof value === 'object') {
72
+ return value as T
73
+ }
74
+
75
+ // 6. If we get here, something unexpected happened
76
+ throw new Error(`Cannot resolve value: unexpected value type: ${typeof value}`)
77
+ }
78
+
79
+ /**
80
+ * Resolves an expression from inside a `{{...}}` placeholder.
81
+ * @private
82
+ */
83
+ private async resolveExpression(expression: string, context: ExecutionContext, scope: ResolutionScope): Promise<any> {
84
+ // Check for Contract(...) syntax with optional property access
85
+ const contractMatch = expression.match(/^Contract\((.*?)\)(\.\w+)?$/)
86
+ if (contractMatch) {
87
+ const [, reference, property] = contractMatch
88
+ const contractRef = reference.trim()
89
+
90
+ // Look up the contract with context path for relative artifact resolution
91
+ const contract = context.contractRepository.lookup(contractRef, context.getContextPath())
92
+ if (!contract) {
93
+ // Provide extra diagnostics to help users understand where lookup occurred
94
+ const ctx = context.getContextPath()
95
+ throw new Error(
96
+ `Artifact not found for reference: "${contractRef}" (resolved relative to: ${ctx ?? 'N/A'}). ` +
97
+ `Ensure the path and contract name are correct and that the build-info/artifact is discoverable.`
98
+ )
99
+ }
100
+
101
+ // If no property requested, return the entire Contract object
102
+ if (!property) {
103
+ return contract
104
+ }
105
+
106
+ // Extract the property name (remove the leading dot)
107
+ const propName = property.substring(1)
108
+
109
+ // Access the requested property
110
+ const value = (contract as any)[propName]
111
+ if (value === undefined) {
112
+ throw new Error(`Property "${propName}" does not exist on contract found for reference "${contractRef}"`)
113
+ }
114
+
115
+ return value
116
+ }
117
+
118
+ // Check scope for local variables (template arguments) first
119
+ if (scope.has(expression)) {
120
+ return scope.get(expression)
121
+ }
122
+
123
+ // Check constants (job-level then top-level)
124
+ const constantValue = (context as any).getConstant?.(expression)
125
+ if (constantValue !== undefined) {
126
+ return constantValue
127
+ }
128
+
129
+ // Check context for global outputs from other jobs/actions
130
+ try {
131
+ return context.getOutput(expression)
132
+ } catch (e) {
133
+ // Provide a more helpful error if an unresolved reference is found
134
+ throw new Error(`Failed to resolve expression "{{${expression}}}". It is not a valid Contract(...) reference, local scope variable, constant, or a known output.`)
135
+ }
136
+ }
137
+
138
+ /**
139
+ * Dispatches a `ValueResolver` object to its specific handler.
140
+ * @private
141
+ */
142
+ private async resolveValueResolverObject(
143
+ obj: ValueResolverObject,
144
+ context: ExecutionContext,
145
+ scope: ResolutionScope,
146
+ ): Promise<any> {
147
+ // Recursively resolve all arguments before processing the object itself
148
+ const resolvedArgs = await this.resolveArguments(obj.arguments, context, scope)
149
+
150
+ switch (obj.type) {
151
+ case 'abi-encode':
152
+ return this.resolveAbiEncode(resolvedArgs as AbiEncodeValue['arguments'])
153
+ case 'abi-pack':
154
+ return this.resolveAbiPack(resolvedArgs as AbiPackValue['arguments'])
155
+ case 'constructor-encode':
156
+ return this.resolveConstructorEncode(resolvedArgs as ConstructorEncodeValue['arguments'])
157
+ case 'compute-create2':
158
+ return this.resolveComputeCreate2(resolvedArgs as ComputeCreate2Value['arguments'])
159
+ case 'read-balance':
160
+ return this.resolveReadBalance(resolvedArgs as ReadBalanceValue['arguments'], context)
161
+ case 'basic-arithmetic':
162
+ return this.resolveBasicArithmetic(resolvedArgs as BasicArithmeticValue['arguments'])
163
+ case 'call':
164
+ return this.resolveCall(resolvedArgs as CallValue['arguments'], context)
165
+ case 'contract-exists':
166
+ return this.resolveContractExists(resolvedArgs as ContractExistsValue['arguments'], context)
167
+ case 'job-completed':
168
+ return this.resolveJobCompleted(resolvedArgs as JobCompletedValue['arguments'], context)
169
+ case 'read-json':
170
+ return this.resolveReadJson(resolvedArgs as ReadJsonValue['arguments'])
171
+ default:
172
+ throw new Error(`Unknown value resolver type: ${(obj as any).type}`)
173
+ }
174
+ }
175
+
176
+ // --- Specific Resolver Implementations ---
177
+
178
+ private resolveAbiEncode(args: AbiEncodeValue['arguments']): string {
179
+ const { signature, values } = args
180
+
181
+ // Validate that signature is provided
182
+ if (!signature) {
183
+ throw new Error('abi-encode: signature is required')
184
+ }
185
+
186
+ // Validate that values array is provided
187
+ if (!values) {
188
+ throw new Error('abi-encode: values array is required')
189
+ }
190
+
191
+ // At this point, signature should be resolved to a string
192
+ const signatureStr = signature as string
193
+ if (typeof signatureStr !== 'string') {
194
+ throw new Error('abi-encode: signature must be a string')
195
+ }
196
+
197
+ try {
198
+ // Create a temporary interface with just this function to encode the data
199
+ const iface = new ethers.Interface([`function ${signatureStr}`])
200
+
201
+ // Get the function name from the signature (everything before the first '(')
202
+ const functionName = signatureStr.split('(')[0]
203
+
204
+ // Encode the function call data
205
+ return iface.encodeFunctionData(functionName, values)
206
+ } catch (error) {
207
+ throw new Error(`abi-encode: Failed to encode function data: ${error instanceof Error ? error.message : String(error)}`)
208
+ }
209
+ }
210
+
211
+ private resolveAbiPack(args: AbiPackValue['arguments']): string {
212
+ const { types, values } = args
213
+
214
+ // Validate that types array is provided
215
+ if (!types) {
216
+ throw new Error('abi-pack: types array is required')
217
+ }
218
+
219
+ // Validate that values array is provided
220
+ if (!values) {
221
+ throw new Error('abi-pack: values array is required')
222
+ }
223
+
224
+ // Validate that types and values arrays have the same length
225
+ if (types.length !== values.length) {
226
+ throw new Error(`abi-pack: types array length (${types.length}) must match values array length (${values.length})`)
227
+ }
228
+
229
+ // At this point, types should be resolved to strings
230
+ const typesArray = types as string[]
231
+ if (!typesArray.every(type => typeof type === 'string')) {
232
+ throw new Error('abi-pack: all types must be strings')
233
+ }
234
+
235
+ try {
236
+ // Use ethers.js solidityPacked for packed encoding (no padding)
237
+ return ethers.solidityPacked(typesArray, values)
238
+ } catch (error) {
239
+ throw new Error(`abi-pack: Failed to pack values: ${error instanceof Error ? error.message : String(error)}`)
240
+ }
241
+ }
242
+
243
+ private resolveConstructorEncode(args: ConstructorEncodeValue['arguments']): string {
244
+ const { creationCode, types, values } = args
245
+
246
+ // Validate that types and values arrays have the same length
247
+ if (types && values && types.length !== values.length) {
248
+ throw new Error(`constructor-encode: types array length (${types.length}) must match values array length (${values.length})`)
249
+ }
250
+
251
+ // If no creationCode is provided, just do ABI encoding of constructor arguments
252
+ if (!creationCode) {
253
+ // If no constructor arguments either, return empty string
254
+ if (!types || !values || types.length === 0 || values.length === 0) {
255
+ return '0x'
256
+ }
257
+
258
+ // ABI encode the constructor arguments using the explicit types
259
+ return ethers.AbiCoder.defaultAbiCoder().encode(types as string[], values)
260
+ }
261
+
262
+ // Validate that creation code is valid bytecode
263
+ if (!ethers.isBytesLike(creationCode)) {
264
+ throw new Error(`Invalid creation code: ${creationCode}`)
265
+ }
266
+
267
+ // If no constructor arguments, return the creation code as-is
268
+ if (!types || !values || types.length === 0 || values.length === 0) {
269
+ return creationCode
270
+ }
271
+
272
+ // ABI encode the constructor arguments using the explicit types
273
+ const encodedArgs = ethers.AbiCoder.defaultAbiCoder().encode(types as string[], values)
274
+
275
+ // Concatenate creation code with encoded constructor arguments
276
+ // Remove '0x' prefix from encoded args if present
277
+ const cleanEncodedArgs = encodedArgs.startsWith('0x') ? encodedArgs.slice(2) : encodedArgs
278
+ const cleanCreationCode = creationCode.startsWith('0x') ? creationCode.slice(2) : creationCode
279
+
280
+ return '0x' + cleanCreationCode + cleanEncodedArgs
281
+ }
282
+
283
+ private resolveComputeCreate2(args: ComputeCreate2Value['arguments']): string {
284
+ const { deployerAddress, salt, initCode } = args
285
+ // Check if the deployer address is a valid address
286
+ if (!ethers.isAddress(deployerAddress)) {
287
+ throw new Error(`Invalid deployer address: ${deployerAddress}`)
288
+ }
289
+ // Check if the salt is a valid bytes value
290
+ if (!ethers.isBytesLike(salt)) {
291
+ throw new Error(`Invalid salt: ${salt}`)
292
+ }
293
+ // Check if the init code is a valid bytes value
294
+ if (!ethers.isBytesLike(initCode)) {
295
+ throw new Error(`Invalid init code: ${initCode}`)
296
+ }
297
+ // Hash the init code using Keccak256
298
+ const initCodeHash = ethers.keccak256(initCode)
299
+ // Create the create2 address
300
+ return ethers.getCreate2Address(deployerAddress, salt, initCodeHash)
301
+ }
302
+
303
+ private async resolveReadBalance(args: ReadBalanceValue['arguments'], context: ExecutionContext): Promise<string> {
304
+ // Check if the address is a valid address
305
+ const addressValue = args.address as any
306
+
307
+ if (!ethers.isAddress(addressValue)) {
308
+ throw new Error(`Invalid address: ${addressValue}`)
309
+ }
310
+
311
+ const balance = await context.provider.getBalance(addressValue)
312
+ return balance.toString()
313
+ }
314
+
315
+ private resolveBasicArithmetic(args: BasicArithmeticValue['arguments']): string | boolean {
316
+ if (!args.values || args.values.length < 2) {
317
+ throw new Error(`basic-arithmetic requires at least 2 values, got ${args.values?.length ?? 0}`)
318
+ }
319
+
320
+ const numbers = args.values.map(v => ethers.toBigInt(v))
321
+ const [a, b] = numbers
322
+
323
+ switch (args.operation) {
324
+ // Arithmetic (return string)
325
+ case 'add': return numbers.reduce((sum, current) => sum + current).toString()
326
+ case 'sub': return (a - b).toString()
327
+ case 'mul': return (a * b).toString()
328
+ case 'div': return (a / b).toString()
329
+
330
+ // Comparison (return boolean)
331
+ case 'eq': return a === b
332
+ case 'neq': return a !== b
333
+ case 'gt': return a > b
334
+ case 'lt': return a < b
335
+ case 'gte': return a >= b
336
+ case 'lte': return a <= b
337
+
338
+ default:
339
+ throw new Error(`Unsupported basic-arithmetic operation: ${args.operation}`)
340
+ }
341
+ }
342
+
343
+ private async resolveCall(args: CallValue['arguments'], context: ExecutionContext): Promise<any> {
344
+ const { to, signature, values } = args
345
+
346
+ // Validate that we have a target address
347
+ if (!to) {
348
+ throw new Error('call: target address (to) is required')
349
+ }
350
+
351
+ // Validate that the target address is a valid Ethereum address
352
+ if (!ethers.isAddress(to)) {
353
+ throw new Error(`call: invalid target address: ${to}`)
354
+ }
355
+
356
+ // Validate that signature is provided
357
+ if (!signature) {
358
+ throw new Error('call: function signature is required')
359
+ }
360
+
361
+ // Validate that values array is provided
362
+ if (!values) {
363
+ throw new Error('call: values array is required')
364
+ }
365
+
366
+ const signatureStr = signature as string
367
+ if (typeof signatureStr !== 'string') {
368
+ throw new Error('call: signature must be a string')
369
+ }
370
+
371
+ try {
372
+ // Create a temporary interface with just this function to encode the call data
373
+ const iface = new ethers.Interface([`function ${signatureStr}`])
374
+
375
+ // Get the function name from the signature (everything before the first '(')
376
+ const functionName = signatureStr.split('(')[0]
377
+
378
+ // Encode the function call data
379
+ const callData = iface.encodeFunctionData(functionName, values)
380
+
381
+ // Make the call using the provider
382
+ const result = await context.provider.call({
383
+ to: to,
384
+ data: callData
385
+ })
386
+
387
+ // If the result is '0x', it means the function doesn't return anything
388
+ if (result === '0x') {
389
+ return null
390
+ }
391
+
392
+ // Decode the result using the function's return type
393
+ const decodedResult = iface.decodeFunctionResult(functionName, result)
394
+
395
+ // If there's only one return value, return it directly
396
+ // Otherwise, return the array of values
397
+ if (decodedResult.length === 1) {
398
+ return decodedResult[0]
399
+ }
400
+
401
+ return decodedResult
402
+ } catch (error) {
403
+ throw new Error(`call: Failed to execute contract call: ${error instanceof Error ? error.message : String(error)}`)
404
+ }
405
+ }
406
+
407
+ private async resolveContractExists(args: ContractExistsValue['arguments'], context: ExecutionContext): Promise<boolean> {
408
+ const { address } = args
409
+
410
+ if (!ethers.isAddress(address)) {
411
+ throw new Error(`contract-exists: invalid address: ${address}`)
412
+ }
413
+
414
+ try {
415
+ const code = await context.provider.getCode(address)
416
+ // getCode returns '0x' if no contract exists at the address
417
+ return code !== '0x'
418
+ } catch (error) {
419
+ throw new Error(`contract-exists: Failed to check contract existence: ${error instanceof Error ? error.message : String(error)}`)
420
+ }
421
+ }
422
+
423
+ private async resolveJobCompleted(args: JobCompletedValue['arguments'], context: ExecutionContext): Promise<boolean> {
424
+ const { job: jobName } = args
425
+
426
+ // For now, we'll assume that if the job is being referenced, it has been completed.
427
+ // This is a simplification - in a more complete implementation, we might check
428
+ // the job's completion status from the deployer's results.
429
+ //
430
+ // Since the dependency graph already ensures jobs run in the correct order,
431
+ // and this condition is used in setup blocks to wait for dependencies,
432
+ // we can simply return true here.
433
+ return true
434
+ }
435
+
436
+ private resolveReadJson(args: ReadJsonValue['arguments']): any {
437
+ const { json, path } = args
438
+
439
+ if (json === undefined || json === null) {
440
+ throw new Error('read-json: json argument is required')
441
+ }
442
+
443
+ if (typeof path !== 'string') {
444
+ throw new Error('read-json: path must be a string')
445
+ }
446
+
447
+ // If path is empty, return the entire JSON object
448
+ if (path === '') {
449
+ return json
450
+ }
451
+
452
+ try {
453
+ // Split the path by dots to handle nested access
454
+ const pathParts = path.split('.')
455
+ let current = json
456
+
457
+ for (const part of pathParts) {
458
+ if (current === null || current === undefined) {
459
+ throw new Error(`Cannot access property "${part}" of ${current}`)
460
+ }
461
+
462
+ // Check if the part is a number (array index)
463
+ const index = parseInt(part, 10)
464
+ if (!isNaN(index) && Array.isArray(current)) {
465
+ current = current[index]
466
+ } else if (typeof current === 'object') {
467
+ current = current[part]
468
+ } else {
469
+ throw new Error(`Cannot access property "${part}" of non-object value`)
470
+ }
471
+ }
472
+
473
+ return current
474
+ } catch (error) {
475
+ throw new Error(`read-json: Failed to access path "${path}": ${error instanceof Error ? error.message : String(error)}`)
476
+ }
477
+ }
478
+
479
+ /**
480
+ * Helper to recursively resolve the `arguments` field of any `ValueResolver` object.
481
+ * @private
482
+ */
483
+ private async resolveArguments(args: any, context: ExecutionContext, scope: ResolutionScope): Promise<any> {
484
+ if (Array.isArray(args)) {
485
+ return Promise.all(args.map(arg => this.resolve(arg, context, scope)))
486
+ }
487
+ if (typeof args === 'object' && args !== null) {
488
+ const resolvedObject: { [key: string]: any } = {}
489
+ for (const key in args) {
490
+ if (Object.prototype.hasOwnProperty.call(args, key)) {
491
+ resolvedObject[key] = await this.resolve(args[key], context, scope)
492
+ }
493
+ }
494
+ return resolvedObject
495
+ }
496
+ return this.resolve(args, context, scope)
497
+ }
498
+ }