@mysten-incubation/devstack 0.1.0 → 0.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 (858) hide show
  1. package/README.md +7 -4
  2. package/dashboard-ui/assets/grpc-a4usE3Nk.js +3 -0
  3. package/dashboard-ui/assets/index-B82Bh84P.css +1 -0
  4. package/dashboard-ui/assets/index-CRYJ4pru.js +1277 -0
  5. package/dashboard-ui/index.html +2 -2
  6. package/dist/api/define-capabilities.d.mts +1 -20
  7. package/dist/api/define-capabilities.mjs +15 -22
  8. package/dist/api/define-capabilities.mjs.map +1 -1
  9. package/dist/api/define-devstack-with.d.mts +7 -1
  10. package/dist/api/define-devstack-with.mjs.map +1 -1
  11. package/dist/api/define-devstack.mjs.map +1 -1
  12. package/dist/api/define-plugin.d.mts +2 -1
  13. package/dist/api/inference-network.d.mts +31 -17
  14. package/dist/api/inference-network.mjs +40 -43
  15. package/dist/api/inference-network.mjs.map +1 -1
  16. package/dist/api/load-config.mjs +88 -0
  17. package/dist/api/load-config.mjs.map +1 -0
  18. package/dist/api/mode-narrowed-factory.d.mts +1 -1
  19. package/dist/api/mode-narrowed-factory.mjs.map +1 -1
  20. package/dist/api/run-stack-internal.mjs +202 -0
  21. package/dist/api/run-stack-internal.mjs.map +1 -0
  22. package/dist/api/run-stack.d.mts +82 -31
  23. package/dist/api/run-stack.mjs +22 -141
  24. package/dist/api/run-stack.mjs.map +1 -1
  25. package/dist/build-integrations/dapp-kit/index.d.mts +61 -0
  26. package/dist/build-integrations/dapp-kit/index.mjs +58 -0
  27. package/dist/build-integrations/dapp-kit/index.mjs.map +1 -0
  28. package/dist/build-integrations/playwright/config.d.mts +1 -30
  29. package/dist/build-integrations/playwright/config.mjs +1 -27
  30. package/dist/build-integrations/playwright/config.mjs.map +1 -1
  31. package/dist/build-integrations/playwright/errors.d.mts +4 -7
  32. package/dist/build-integrations/playwright/errors.mjs.map +1 -1
  33. package/dist/build-integrations/playwright/global-setup.d.mts +42 -71
  34. package/dist/build-integrations/playwright/global-setup.mjs +142 -218
  35. package/dist/build-integrations/playwright/global-setup.mjs.map +1 -1
  36. package/dist/build-integrations/playwright/index.d.mts +2 -2
  37. package/dist/build-integrations/playwright/index.mjs +2 -2
  38. package/dist/build-integrations/playwright/stack-context.d.mts +3 -1
  39. package/dist/build-integrations/playwright/stack-context.mjs +4 -2
  40. package/dist/build-integrations/playwright/stack-context.mjs.map +1 -1
  41. package/dist/build-integrations/playwright/wallet-context.mjs +44 -19
  42. package/dist/build-integrations/playwright/wallet-context.mjs.map +1 -1
  43. package/dist/build-integrations/runtime/cold-start-url.mjs.map +1 -1
  44. package/dist/build-integrations/runtime/conventional-routes.mjs.map +1 -1
  45. package/dist/build-integrations/runtime/dapp-kit-slot.mjs.map +1 -1
  46. package/dist/build-integrations/runtime/discover.d.mts +6 -4
  47. package/dist/build-integrations/runtime/discover.mjs +15 -4
  48. package/dist/build-integrations/runtime/discover.mjs.map +1 -1
  49. package/dist/build-integrations/runtime/endpoint-registry.mjs.map +1 -1
  50. package/dist/build-integrations/runtime/errors.mjs.map +1 -1
  51. package/dist/build-integrations/runtime/read-stack-context.mjs +3 -3
  52. package/dist/build-integrations/runtime/read-stack-context.mjs.map +1 -1
  53. package/dist/build-integrations/runtime/resolve-discovery-env.d.mts +23 -7
  54. package/dist/build-integrations/runtime/resolve-discovery-env.mjs +25 -12
  55. package/dist/build-integrations/runtime/resolve-discovery-env.mjs.map +1 -1
  56. package/dist/build-integrations/runtime/stack-context.d.mts +2 -2
  57. package/dist/build-integrations/vite/index.d.mts +84 -19
  58. package/dist/build-integrations/vite/index.mjs +203 -28
  59. package/dist/build-integrations/vite/index.mjs.map +1 -1
  60. package/dist/build-integrations/vitest/config.d.mts +20 -2
  61. package/dist/build-integrations/vitest/config.mjs +16 -4
  62. package/dist/build-integrations/vitest/config.mjs.map +1 -1
  63. package/dist/build-integrations/vitest/env.d.mts +18 -10
  64. package/dist/build-integrations/vitest/env.mjs +11 -10
  65. package/dist/build-integrations/vitest/env.mjs.map +1 -1
  66. package/dist/build-integrations/vitest/errors.d.mts +7 -11
  67. package/dist/build-integrations/vitest/errors.mjs +3 -4
  68. package/dist/build-integrations/vitest/errors.mjs.map +1 -1
  69. package/dist/build-integrations/vitest/global-setup.d.mts +35 -0
  70. package/dist/build-integrations/vitest/global-setup.mjs +156 -0
  71. package/dist/build-integrations/vitest/global-setup.mjs.map +1 -0
  72. package/dist/build-integrations/vitest/index.d.mts +3 -2
  73. package/dist/build-integrations/vitest/index.mjs +3 -2
  74. package/dist/build-integrations/vitest/setup.mjs +2 -2
  75. package/dist/build-integrations/vitest/setup.mjs.map +1 -1
  76. package/dist/build-integrations/vitest/stack-context.d.mts +5 -3
  77. package/dist/build-integrations/vitest/stack-context.mjs +3 -2
  78. package/dist/build-integrations/vitest/stack-context.mjs.map +1 -1
  79. package/dist/cli/bail.mjs.map +1 -1
  80. package/dist/cli/doctor-probes.mjs +1 -3
  81. package/dist/cli/doctor-probes.mjs.map +1 -1
  82. package/dist/cli/main.d.mts +23 -1
  83. package/dist/cli/main.mjs +63 -8
  84. package/dist/cli/main.mjs.map +1 -1
  85. package/dist/cli/prune-direct.mjs.map +1 -1
  86. package/dist/cli/snapshot-reader.mjs.map +1 -1
  87. package/dist/cli/up-lifecycle.mjs.map +1 -1
  88. package/dist/cli/wirings/apply.mjs +28 -21
  89. package/dist/cli/wirings/apply.mjs.map +1 -1
  90. package/dist/cli/wirings/codegen.mjs +108 -0
  91. package/dist/cli/wirings/codegen.mjs.map +1 -0
  92. package/dist/cli/wirings/config-loader.mjs +12 -62
  93. package/dist/cli/wirings/config-loader.mjs.map +1 -1
  94. package/dist/cli/wirings/dump-ids.mjs +86 -0
  95. package/dist/cli/wirings/dump-ids.mjs.map +1 -0
  96. package/dist/cli/wirings/engine-command.mjs +1 -1
  97. package/dist/cli/wirings/engine-command.mjs.map +1 -1
  98. package/dist/cli/wirings/identity.mjs +2 -2
  99. package/dist/cli/wirings/identity.mjs.map +1 -1
  100. package/dist/cli/wirings/provide-file-system.mjs.map +1 -1
  101. package/dist/cli/wirings/read-devstack-version.mjs +17 -0
  102. package/dist/cli/wirings/read-devstack-version.mjs.map +1 -0
  103. package/dist/cli/wirings/snapshot.mjs +27 -34
  104. package/dist/cli/wirings/snapshot.mjs.map +1 -1
  105. package/dist/cli/wirings/up-ipc.mjs +147 -0
  106. package/dist/cli/wirings/up-ipc.mjs.map +1 -0
  107. package/dist/cli/wirings/up.mjs +218 -198
  108. package/dist/cli/wirings/up.mjs.map +1 -1
  109. package/dist/cli/wirings/wipe.mjs +1 -1
  110. package/dist/cli/wirings/wipe.mjs.map +1 -1
  111. package/dist/contracts/chain-probe.d.mts +1 -1
  112. package/dist/contracts/chain-probe.mjs +1 -1
  113. package/dist/contracts/chain-probe.mjs.map +1 -1
  114. package/dist/contracts/codegenable.d.mts +60 -6
  115. package/dist/contracts/codegenable.mjs +28 -0
  116. package/dist/contracts/codegenable.mjs.map +1 -0
  117. package/dist/contracts/config-bindings.mjs +162 -0
  118. package/dist/contracts/config-bindings.mjs.map +1 -0
  119. package/dist/contracts/container-runtime.d.mts +23 -17
  120. package/dist/contracts/plugin-expander.mjs.map +1 -1
  121. package/dist/contracts/snapshotable.d.mts +5 -7
  122. package/dist/contracts/wallet-protocol.d.mts +2 -5
  123. package/dist/contracts/wallet-protocol.mjs +2 -5
  124. package/dist/contracts/wallet-protocol.mjs.map +1 -1
  125. package/dist/index.d.mts +21 -26
  126. package/dist/index.mjs +8 -9
  127. package/dist/orchestrators/boot.d.mts +28 -0
  128. package/dist/orchestrators/boot.mjs +440 -0
  129. package/dist/orchestrators/boot.mjs.map +1 -0
  130. package/dist/orchestrators/codegen/bindings.d.mts +13 -1
  131. package/dist/orchestrators/codegen/bindings.mjs +23 -9
  132. package/dist/orchestrators/codegen/bindings.mjs.map +1 -1
  133. package/dist/orchestrators/codegen/config-runtime.mjs +208 -0
  134. package/dist/orchestrators/codegen/config-runtime.mjs.map +1 -0
  135. package/dist/orchestrators/codegen/emit.mjs +1 -1
  136. package/dist/orchestrators/codegen/emit.mjs.map +1 -1
  137. package/dist/orchestrators/codegen/errors.mjs +21 -1
  138. package/dist/orchestrators/codegen/errors.mjs.map +1 -1
  139. package/dist/orchestrators/codegen/format.mjs +2 -0
  140. package/dist/orchestrators/codegen/format.mjs.map +1 -1
  141. package/dist/orchestrators/codegen/gitignore.mjs +30 -11
  142. package/dist/orchestrators/codegen/gitignore.mjs.map +1 -1
  143. package/dist/orchestrators/codegen/id-config.mjs +107 -0
  144. package/dist/orchestrators/codegen/id-config.mjs.map +1 -0
  145. package/dist/orchestrators/codegen/output-location.mjs +23 -31
  146. package/dist/orchestrators/codegen/output-location.mjs.map +1 -1
  147. package/dist/orchestrators/codegen/paths.mjs +8 -1
  148. package/dist/orchestrators/codegen/paths.mjs.map +1 -1
  149. package/dist/orchestrators/codegen/permissions.mjs.map +1 -1
  150. package/dist/orchestrators/codegen/service.mjs +286 -58
  151. package/dist/orchestrators/codegen/service.mjs.map +1 -1
  152. package/dist/orchestrators/layers.mjs +31 -0
  153. package/dist/orchestrators/layers.mjs.map +1 -0
  154. package/dist/orchestrators/lifecycle-prune/errors.mjs.map +1 -1
  155. package/dist/orchestrators/lifecycle-prune/index.mjs +8 -10
  156. package/dist/orchestrators/lifecycle-prune/index.mjs.map +1 -1
  157. package/dist/orchestrators/network-options.d.mts +52 -0
  158. package/dist/orchestrators/network-options.mjs +43 -0
  159. package/dist/orchestrators/network-options.mjs.map +1 -0
  160. package/dist/orchestrators/router/cleanup.mjs.map +1 -1
  161. package/dist/orchestrators/router/cors.mjs.map +1 -1
  162. package/dist/orchestrators/router/entrypoints.mjs.map +1 -1
  163. package/dist/orchestrators/router/errors.mjs.map +1 -1
  164. package/dist/orchestrators/router/file-provider.mjs.map +1 -1
  165. package/dist/orchestrators/router/hostname.mjs.map +1 -1
  166. package/dist/orchestrators/router/profile.mjs +1 -1
  167. package/dist/orchestrators/router/profile.mjs.map +1 -1
  168. package/dist/orchestrators/router/service.d.mts +2 -2
  169. package/dist/orchestrators/router/service.mjs +12 -27
  170. package/dist/orchestrators/router/service.mjs.map +1 -1
  171. package/dist/orchestrators/router/traefik-container.mjs +1 -1
  172. package/dist/orchestrators/router/traefik-container.mjs.map +1 -1
  173. package/dist/orchestrators/snapshot/capture.mjs +171 -195
  174. package/dist/orchestrators/snapshot/capture.mjs.map +1 -1
  175. package/dist/orchestrators/snapshot/descriptor.d.mts +1 -1
  176. package/dist/orchestrators/snapshot/descriptor.mjs +53 -11
  177. package/dist/orchestrators/snapshot/descriptor.mjs.map +1 -1
  178. package/dist/orchestrators/snapshot/identity-guard.mjs +3 -5
  179. package/dist/orchestrators/snapshot/identity-guard.mjs.map +1 -1
  180. package/dist/orchestrators/snapshot/image-bundle-tags.mjs +32 -101
  181. package/dist/orchestrators/snapshot/image-bundle-tags.mjs.map +1 -1
  182. package/dist/orchestrators/snapshot/index.mjs +1 -4
  183. package/dist/orchestrators/snapshot/integrity.mjs.map +1 -1
  184. package/dist/orchestrators/snapshot/interrupted-restore.mjs +116 -0
  185. package/dist/orchestrators/snapshot/interrupted-restore.mjs.map +1 -0
  186. package/dist/orchestrators/snapshot/phase-error.mjs.map +1 -1
  187. package/dist/orchestrators/snapshot/prune.mjs +40 -31
  188. package/dist/orchestrators/snapshot/prune.mjs.map +1 -1
  189. package/dist/orchestrators/snapshot/restore.mjs +221 -196
  190. package/dist/orchestrators/snapshot/restore.mjs.map +1 -1
  191. package/dist/orchestrators/snapshot/service.mjs +72 -62
  192. package/dist/orchestrators/snapshot/service.mjs.map +1 -1
  193. package/dist/orchestrators/snapshot/wipe.mjs +67 -56
  194. package/dist/orchestrators/snapshot/wipe.mjs.map +1 -1
  195. package/dist/plugins/account/codegen.mjs +3 -0
  196. package/dist/plugins/account/codegen.mjs.map +1 -1
  197. package/dist/plugins/account/errors.d.mts +2 -2
  198. package/dist/plugins/account/errors.mjs +1 -4
  199. package/dist/plugins/account/errors.mjs.map +1 -1
  200. package/dist/plugins/account/funding.mjs +3 -27
  201. package/dist/plugins/account/funding.mjs.map +1 -1
  202. package/dist/plugins/account/index.d.mts +3 -8
  203. package/dist/plugins/account/index.mjs +71 -35
  204. package/dist/plugins/account/index.mjs.map +1 -1
  205. package/dist/plugins/account/keypair.d.mts +8 -7
  206. package/dist/plugins/account/keypair.mjs +5 -18
  207. package/dist/plugins/account/keypair.mjs.map +1 -1
  208. package/dist/plugins/account/lease.mjs.map +1 -1
  209. package/dist/plugins/account/registry.d.mts +1 -46
  210. package/dist/plugins/account/registry.mjs.map +1 -1
  211. package/dist/plugins/account/service.d.mts +43 -34
  212. package/dist/plugins/account/service.mjs +9 -54
  213. package/dist/plugins/account/service.mjs.map +1 -1
  214. package/dist/plugins/account/snapshot.mjs.map +1 -1
  215. package/dist/plugins/account/variants/ephemeral.mjs.map +1 -1
  216. package/dist/plugins/account/variants/impersonate.mjs.map +1 -1
  217. package/dist/plugins/account/variants/signer.mjs.map +1 -1
  218. package/dist/plugins/action/discriminator.mjs.map +1 -1
  219. package/dist/plugins/action/errors.mjs +1 -4
  220. package/dist/plugins/action/errors.mjs.map +1 -1
  221. package/dist/plugins/action/execute.mjs +3 -4
  222. package/dist/plugins/action/execute.mjs.map +1 -1
  223. package/dist/plugins/action/index.d.mts +2 -2
  224. package/dist/plugins/action/index.mjs +7 -11
  225. package/dist/plugins/action/index.mjs.map +1 -1
  226. package/dist/plugins/action/service.d.mts +5 -7
  227. package/dist/plugins/action/service.mjs +2 -16
  228. package/dist/plugins/action/service.mjs.map +1 -1
  229. package/dist/plugins/coin/address-resolution.mjs.map +1 -1
  230. package/dist/plugins/coin/codegen.mjs +97 -16
  231. package/dist/plugins/coin/codegen.mjs.map +1 -1
  232. package/dist/plugins/coin/discovery.mjs.map +1 -1
  233. package/dist/plugins/coin/errors.mjs +1 -4
  234. package/dist/plugins/coin/errors.mjs.map +1 -1
  235. package/dist/plugins/coin/index.d.mts +4 -34
  236. package/dist/plugins/coin/index.mjs +47 -28
  237. package/dist/plugins/coin/index.mjs.map +1 -1
  238. package/dist/plugins/coin/metadata.d.mts +1 -0
  239. package/dist/plugins/coin/metadata.mjs +8 -9
  240. package/dist/plugins/coin/metadata.mjs.map +1 -1
  241. package/dist/plugins/coin/mint.mjs +7 -21
  242. package/dist/plugins/coin/mint.mjs.map +1 -1
  243. package/dist/plugins/coin/registry.mjs +33 -20
  244. package/dist/plugins/coin/registry.mjs.map +1 -1
  245. package/dist/plugins/coin/service.d.mts +1 -1
  246. package/dist/plugins/coin/service.mjs +1 -8
  247. package/dist/plugins/coin/service.mjs.map +1 -1
  248. package/dist/plugins/coin/snapshot.mjs.map +1 -1
  249. package/dist/plugins/coin/type-strings.mjs.map +1 -1
  250. package/dist/plugins/dashboard/domain.mjs +106 -167
  251. package/dist/plugins/dashboard/domain.mjs.map +1 -1
  252. package/dist/plugins/dashboard/index.mjs +13 -13
  253. package/dist/plugins/dashboard/index.mjs.map +1 -1
  254. package/dist/plugins/dashboard/origin-policy.mjs +3 -3
  255. package/dist/plugins/dashboard/origin-policy.mjs.map +1 -1
  256. package/dist/plugins/dashboard/routable.mjs.map +1 -1
  257. package/dist/plugins/dashboard/schema/builder.mjs.map +1 -1
  258. package/dist/plugins/dashboard/schema/enums.mjs.map +1 -1
  259. package/dist/plugins/dashboard/schema/root.mjs +23 -44
  260. package/dist/plugins/dashboard/schema/root.mjs.map +1 -1
  261. package/dist/plugins/dashboard/schema/types.mjs +37 -91
  262. package/dist/plugins/dashboard/schema/types.mjs.map +1 -1
  263. package/dist/plugins/dashboard/schema.mjs.map +1 -1
  264. package/dist/plugins/dashboard/server.mjs.map +1 -1
  265. package/dist/plugins/deepbook/codegen.d.mts +12 -11
  266. package/dist/plugins/deepbook/codegen.mjs +108 -11
  267. package/dist/plugins/deepbook/codegen.mjs.map +1 -1
  268. package/dist/plugins/deepbook/deploy.mjs +7 -14
  269. package/dist/plugins/deepbook/deploy.mjs.map +1 -1
  270. package/dist/plugins/deepbook/errors.mjs +4 -2
  271. package/dist/plugins/deepbook/errors.mjs.map +1 -1
  272. package/dist/plugins/deepbook/faucet-strategy.mjs +4 -10
  273. package/dist/plugins/deepbook/faucet-strategy.mjs.map +1 -1
  274. package/dist/plugins/deepbook/hash.mjs.map +1 -1
  275. package/dist/plugins/deepbook/index.d.mts +38 -34
  276. package/dist/plugins/deepbook/index.mjs +133 -64
  277. package/dist/plugins/deepbook/index.mjs.map +1 -1
  278. package/dist/plugins/deepbook/plugin-key.mjs.map +1 -1
  279. package/dist/plugins/deepbook/pyth/index.mjs +4 -8
  280. package/dist/plugins/deepbook/pyth/index.mjs.map +1 -1
  281. package/dist/plugins/deepbook/snapshot.mjs +0 -1
  282. package/dist/plugins/deepbook/snapshot.mjs.map +1 -1
  283. package/dist/plugins/deepbook/type-strings.mjs.map +1 -1
  284. package/dist/plugins/deepbook/types.d.mts +2 -1
  285. package/dist/plugins/deepbook/types.mjs.map +1 -1
  286. package/dist/plugins/faucet/dispatcher.d.mts +3 -3
  287. package/dist/plugins/faucet/dispatcher.mjs.map +1 -1
  288. package/dist/plugins/faucet/errors.mjs.map +1 -1
  289. package/dist/plugins/faucet/http.mjs +2 -10
  290. package/dist/plugins/faucet/http.mjs.map +1 -1
  291. package/dist/plugins/faucet/index.mjs +0 -1
  292. package/dist/plugins/faucet/index.mjs.map +1 -1
  293. package/dist/plugins/host-service/errors.d.mts +1 -3
  294. package/dist/plugins/host-service/errors.mjs +1 -2
  295. package/dist/plugins/host-service/errors.mjs.map +1 -1
  296. package/dist/plugins/host-service/index.d.mts +1 -2
  297. package/dist/plugins/host-service/index.mjs +11 -11
  298. package/dist/plugins/host-service/index.mjs.map +1 -1
  299. package/dist/plugins/host-service/routable.mjs.map +1 -1
  300. package/dist/plugins/host-service/service.mjs +13 -13
  301. package/dist/plugins/host-service/service.mjs.map +1 -1
  302. package/dist/plugins/internal/acquire-on-chain-artifact.mjs.map +1 -1
  303. package/dist/plugins/internal/codegen-helpers.mjs +2 -0
  304. package/dist/plugins/internal/codegen-helpers.mjs.map +1 -1
  305. package/dist/plugins/internal/funding-failure-error.mjs.map +1 -1
  306. package/dist/plugins/{postgres → internal/postgres-sidecar}/connection.mjs +1 -1
  307. package/dist/plugins/internal/postgres-sidecar/connection.mjs.map +1 -0
  308. package/dist/plugins/{postgres → internal/postgres-sidecar}/db-ensure.mjs +30 -16
  309. package/dist/plugins/internal/postgres-sidecar/db-ensure.mjs.map +1 -0
  310. package/dist/plugins/internal/postgres-sidecar/errors.mjs +21 -0
  311. package/dist/plugins/internal/postgres-sidecar/errors.mjs.map +1 -0
  312. package/dist/{substrate/runtime/scoped-multimap → plugins/internal/postgres-sidecar}/index.mjs +1 -0
  313. package/dist/plugins/internal/postgres-sidecar/service.mjs +121 -0
  314. package/dist/plugins/internal/postgres-sidecar/service.mjs.map +1 -0
  315. package/dist/plugins/package/build.mjs +2 -2
  316. package/dist/plugins/package/build.mjs.map +1 -1
  317. package/dist/plugins/package/codegen.d.mts +7 -14
  318. package/dist/plugins/package/codegen.mjs +187 -59
  319. package/dist/plugins/package/codegen.mjs.map +1 -1
  320. package/dist/plugins/package/dep-resolution.mjs +51 -3
  321. package/dist/plugins/package/dep-resolution.mjs.map +1 -1
  322. package/dist/plugins/package/errors.mjs +1 -4
  323. package/dist/plugins/package/errors.mjs.map +1 -1
  324. package/dist/plugins/package/git-source.d.mts +18 -0
  325. package/dist/plugins/package/git-source.mjs +119 -0
  326. package/dist/plugins/package/git-source.mjs.map +1 -0
  327. package/dist/plugins/package/index.d.mts +28 -19
  328. package/dist/plugins/package/index.mjs +107 -32
  329. package/dist/plugins/package/index.mjs.map +1 -1
  330. package/dist/plugins/package/mode-known.mjs +2 -2
  331. package/dist/plugins/package/mode-known.mjs.map +1 -1
  332. package/dist/plugins/package/mode-local.mjs +18 -35
  333. package/dist/plugins/package/mode-local.mjs.map +1 -1
  334. package/dist/plugins/package/publish-executor.mjs +13 -8
  335. package/dist/plugins/package/publish-executor.mjs.map +1 -1
  336. package/dist/plugins/package/publish-output.d.mts +1 -11
  337. package/dist/plugins/package/publish-output.mjs +1 -9
  338. package/dist/plugins/package/publish-output.mjs.map +1 -1
  339. package/dist/plugins/package/registry.d.mts +1 -1
  340. package/dist/plugins/package/registry.mjs +26 -14
  341. package/dist/plugins/package/registry.mjs.map +1 -1
  342. package/dist/plugins/package/service.mjs.map +1 -1
  343. package/dist/plugins/package/snapshot.mjs.map +1 -1
  344. package/dist/plugins/router-entrypoints.mjs +1 -3
  345. package/dist/plugins/router-entrypoints.mjs.map +1 -1
  346. package/dist/plugins/seal/bootstrap-assets/cargo-image.mjs +1 -2
  347. package/dist/plugins/seal/bootstrap-assets/cargo-image.mjs.map +1 -1
  348. package/dist/plugins/seal/bootstrap-assets/source-fetch.mjs +1 -6
  349. package/dist/plugins/seal/bootstrap-assets/source-fetch.mjs.map +1 -1
  350. package/dist/plugins/seal/codegen.d.mts +1 -5
  351. package/dist/plugins/seal/codegen.mjs +83 -12
  352. package/dist/plugins/seal/codegen.mjs.map +1 -1
  353. package/dist/plugins/seal/config-render.mjs +2 -6
  354. package/dist/plugins/seal/config-render.mjs.map +1 -1
  355. package/dist/plugins/seal/deploy.mjs +18 -29
  356. package/dist/plugins/seal/deploy.mjs.map +1 -1
  357. package/dist/plugins/seal/errors.d.mts +4 -5
  358. package/dist/plugins/seal/errors.mjs +1 -8
  359. package/dist/plugins/seal/errors.mjs.map +1 -1
  360. package/dist/plugins/seal/index.d.mts +7 -28
  361. package/dist/plugins/seal/index.mjs +69 -47
  362. package/dist/plugins/seal/index.mjs.map +1 -1
  363. package/dist/plugins/seal/key-manager.mjs.map +1 -1
  364. package/dist/plugins/seal/key-server.mjs +1 -6
  365. package/dist/plugins/seal/key-server.mjs.map +1 -1
  366. package/dist/plugins/seal/keygen.mjs +2 -3
  367. package/dist/plugins/seal/keygen.mjs.map +1 -1
  368. package/dist/plugins/seal/mode/fork-known.mjs.map +1 -1
  369. package/dist/plugins/seal/mode/live.mjs +1 -1
  370. package/dist/plugins/seal/mode/live.mjs.map +1 -1
  371. package/dist/plugins/seal/mode/local-keygen.mjs +4 -10
  372. package/dist/plugins/seal/mode/local-keygen.mjs.map +1 -1
  373. package/dist/plugins/seal/plugin-key.mjs.map +1 -1
  374. package/dist/plugins/seal/registry-publish.mjs.map +1 -1
  375. package/dist/plugins/seal/routable.mjs.map +1 -1
  376. package/dist/plugins/seal/service.mjs.map +1 -1
  377. package/dist/plugins/seal/snapshot.mjs +1 -2
  378. package/dist/plugins/seal/snapshot.mjs.map +1 -1
  379. package/dist/plugins/sui/auto-tick.mjs +5 -5
  380. package/dist/plugins/sui/auto-tick.mjs.map +1 -1
  381. package/dist/plugins/sui/chain-build-container.mjs +2 -2
  382. package/dist/plugins/sui/chain-build-container.mjs.map +1 -1
  383. package/dist/plugins/sui/chain-probe.mjs +4 -4
  384. package/dist/plugins/sui/chain-probe.mjs.map +1 -1
  385. package/dist/plugins/sui/codegen.d.mts +9 -7
  386. package/dist/plugins/sui/codegen.mjs +49 -46
  387. package/dist/plugins/sui/codegen.mjs.map +1 -1
  388. package/dist/plugins/sui/errors.d.mts +1 -1
  389. package/dist/plugins/sui/errors.mjs +1 -9
  390. package/dist/plugins/sui/errors.mjs.map +1 -1
  391. package/dist/{substrate/runtime/sui-execute → plugins/sui/exec}/index.d.mts +1 -1
  392. package/dist/{substrate/runtime/sui-execute → plugins/sui/exec}/index.mjs +3 -7
  393. package/dist/plugins/sui/exec/index.mjs.map +1 -0
  394. package/dist/{substrate/runtime/sui-execute → plugins/sui/exec}/sign-and-dispatch.mjs +1 -1
  395. package/dist/plugins/sui/exec/sign-and-dispatch.mjs.map +1 -0
  396. package/dist/plugins/sui/fork-faucet-strategy.mjs +2 -6
  397. package/dist/plugins/sui/fork-faucet-strategy.mjs.map +1 -1
  398. package/dist/plugins/sui/fork-orchestration.mjs +13 -23
  399. package/dist/plugins/sui/fork-orchestration.mjs.map +1 -1
  400. package/dist/plugins/sui/fork-transaction.mjs.map +1 -1
  401. package/dist/plugins/sui/index.d.mts +34 -83
  402. package/dist/plugins/sui/index.mjs +200 -68
  403. package/dist/plugins/sui/index.mjs.map +1 -1
  404. package/dist/{substrate/runtime/sui-ledger → plugins/sui/ledger}/object-ref.mjs +1 -1
  405. package/dist/plugins/sui/ledger/object-ref.mjs.map +1 -0
  406. package/dist/plugins/sui/local-faucet-strategy.mjs +1 -5
  407. package/dist/plugins/sui/local-faucet-strategy.mjs.map +1 -1
  408. package/dist/plugins/sui/log-attrs.mjs +11 -0
  409. package/dist/plugins/sui/log-attrs.mjs.map +1 -0
  410. package/dist/plugins/sui/mode/external.mjs +4 -12
  411. package/dist/plugins/sui/mode/external.mjs.map +1 -1
  412. package/dist/plugins/sui/mode/fork.mjs +19 -16
  413. package/dist/plugins/sui/mode/fork.mjs.map +1 -1
  414. package/dist/plugins/sui/mode/live.mjs +4 -17
  415. package/dist/plugins/sui/mode/live.mjs.map +1 -1
  416. package/dist/plugins/sui/mode/local.d.mts +1 -0
  417. package/dist/plugins/sui/mode/local.mjs +203 -61
  418. package/dist/plugins/sui/mode/local.mjs.map +1 -1
  419. package/dist/plugins/sui/mode/shared-boot.mjs +18 -23
  420. package/dist/plugins/sui/mode/shared-boot.mjs.map +1 -1
  421. package/dist/plugins/sui/mode/shared.d.mts +6 -7
  422. package/dist/plugins/sui/mode/shared.mjs.map +1 -1
  423. package/dist/plugins/sui/mode/spec.d.mts +23 -6
  424. package/dist/{substrate/runtime/sui-move-build → plugins/sui/move}/index.mjs +28 -30
  425. package/dist/plugins/sui/move/index.mjs.map +1 -0
  426. package/dist/plugins/sui/move-summary-runner.mjs +8 -4
  427. package/dist/plugins/sui/move-summary-runner.mjs.map +1 -1
  428. package/dist/{substrate/network.d.mts → plugins/sui/network-config.d.mts} +11 -10
  429. package/dist/plugins/sui/network-resolver.d.mts +6 -6
  430. package/dist/plugins/sui/routable.mjs.map +1 -1
  431. package/dist/plugins/sui/service.mjs +10 -6
  432. package/dist/plugins/sui/service.mjs.map +1 -1
  433. package/dist/plugins/sui/snapshot.mjs +10 -5
  434. package/dist/plugins/sui/snapshot.mjs.map +1 -1
  435. package/dist/plugins/wallet/codegen.d.mts +8 -6
  436. package/dist/plugins/wallet/codegen.mjs +4 -10
  437. package/dist/plugins/wallet/codegen.mjs.map +1 -1
  438. package/dist/plugins/wallet/errors.mjs +1 -4
  439. package/dist/plugins/wallet/errors.mjs.map +1 -1
  440. package/dist/plugins/wallet/index.d.mts +3 -6
  441. package/dist/plugins/wallet/index.mjs +16 -21
  442. package/dist/plugins/wallet/index.mjs.map +1 -1
  443. package/dist/plugins/wallet/origin-policy.mjs +3 -3
  444. package/dist/plugins/wallet/origin-policy.mjs.map +1 -1
  445. package/dist/plugins/wallet/pairing.mjs +6 -24
  446. package/dist/plugins/wallet/pairing.mjs.map +1 -1
  447. package/dist/plugins/wallet/protocol.mjs.map +1 -1
  448. package/dist/plugins/wallet/routable.mjs.map +1 -1
  449. package/dist/plugins/wallet/server.mjs +17 -24
  450. package/dist/plugins/wallet/server.mjs.map +1 -1
  451. package/dist/plugins/wallet/service.d.mts +2 -2
  452. package/dist/plugins/wallet/service.mjs +4 -15
  453. package/dist/plugins/wallet/service.mjs.map +1 -1
  454. package/dist/plugins/wallet/snapshot.mjs.map +1 -1
  455. package/dist/plugins/walrus/bootstrap-assets/cargo-image.mjs +1 -5
  456. package/dist/plugins/walrus/bootstrap-assets/cargo-image.mjs.map +1 -1
  457. package/dist/plugins/walrus/codegen.d.mts +2 -13
  458. package/dist/plugins/walrus/codegen.mjs +93 -28
  459. package/dist/plugins/walrus/codegen.mjs.map +1 -1
  460. package/dist/plugins/walrus/deploy-paths.mjs +2 -3
  461. package/dist/plugins/walrus/deploy-paths.mjs.map +1 -1
  462. package/dist/plugins/walrus/deploy.mjs +26 -19
  463. package/dist/plugins/walrus/deploy.mjs.map +1 -1
  464. package/dist/plugins/walrus/errors.mjs +1 -8
  465. package/dist/plugins/walrus/errors.mjs.map +1 -1
  466. package/dist/plugins/walrus/faucet-strategy.mjs +15 -1
  467. package/dist/plugins/walrus/faucet-strategy.mjs.map +1 -1
  468. package/dist/plugins/walrus/index.d.mts +13 -44
  469. package/dist/plugins/walrus/index.mjs +119 -122
  470. package/dist/plugins/walrus/index.mjs.map +1 -1
  471. package/dist/plugins/walrus/mode/known-deploy.mjs +6 -6
  472. package/dist/plugins/walrus/mode/known-deploy.mjs.map +1 -1
  473. package/dist/plugins/walrus/mode/local-cluster.d.mts +2 -2
  474. package/dist/plugins/walrus/mode/local-cluster.mjs +2 -10
  475. package/dist/plugins/walrus/mode/local-cluster.mjs.map +1 -1
  476. package/dist/plugins/walrus/plugin-key.mjs.map +1 -1
  477. package/dist/plugins/walrus/registry-publish.mjs.map +1 -1
  478. package/dist/plugins/walrus/routable.mjs.map +1 -1
  479. package/dist/plugins/walrus/service.mjs.map +1 -1
  480. package/dist/plugins/walrus/snapshot.mjs +3 -3
  481. package/dist/plugins/walrus/snapshot.mjs.map +1 -1
  482. package/dist/plugins/walrus/storage-nodes.mjs +53 -14
  483. package/dist/plugins/walrus/storage-nodes.mjs.map +1 -1
  484. package/dist/plugins/walrus/wal-swap.mjs +4 -8
  485. package/dist/plugins/walrus/wal-swap.mjs.map +1 -1
  486. package/dist/primitives/artifact-publisher.mjs.map +1 -1
  487. package/dist/primitives/cache.d.mts +1 -1
  488. package/dist/runtime/docker/client.mjs +47 -3
  489. package/dist/runtime/docker/client.mjs.map +1 -1
  490. package/dist/runtime/docker/container.mjs +37 -57
  491. package/dist/runtime/docker/container.mjs.map +1 -1
  492. package/dist/runtime/docker/errors.mjs.map +1 -1
  493. package/dist/runtime/docker/exec.mjs +2 -2
  494. package/dist/runtime/docker/exec.mjs.map +1 -1
  495. package/dist/runtime/docker/image.mjs +10 -11
  496. package/dist/runtime/docker/image.mjs.map +1 -1
  497. package/dist/runtime/docker/index.mjs +0 -1
  498. package/dist/runtime/docker/inspect-and-decode.mjs.map +1 -1
  499. package/dist/runtime/docker/inventory.mjs +9 -9
  500. package/dist/runtime/docker/inventory.mjs.map +1 -1
  501. package/dist/runtime/docker/labels.mjs +12 -1
  502. package/dist/runtime/docker/labels.mjs.map +1 -1
  503. package/dist/runtime/docker/network.mjs +6 -6
  504. package/dist/runtime/docker/network.mjs.map +1 -1
  505. package/dist/runtime/docker/render-run-args.mjs.map +1 -1
  506. package/dist/runtime/docker/service.mjs +31 -45
  507. package/dist/runtime/docker/service.mjs.map +1 -1
  508. package/dist/runtime/docker/sweep.mjs +14 -64
  509. package/dist/runtime/docker/sweep.mjs.map +1 -1
  510. package/dist/runtime/docker/volume.mjs +1 -1
  511. package/dist/runtime/docker/volume.mjs.map +1 -1
  512. package/dist/runtime/docker/wrap.mjs +14 -2
  513. package/dist/runtime/docker/wrap.mjs.map +1 -1
  514. package/dist/substrate/brand.d.mts +2 -5
  515. package/dist/substrate/brand.mjs +3 -2
  516. package/dist/substrate/brand.mjs.map +1 -1
  517. package/dist/substrate/cross-process.mjs +2 -16
  518. package/dist/substrate/cross-process.mjs.map +1 -1
  519. package/dist/substrate/event-time.mjs +0 -2
  520. package/dist/substrate/event-time.mjs.map +1 -1
  521. package/dist/substrate/events.d.mts +46 -16
  522. package/dist/substrate/identity.d.mts +11 -5
  523. package/dist/substrate/manifest.d.mts +33 -26
  524. package/dist/substrate/manifest.mjs +8 -3
  525. package/dist/substrate/manifest.mjs.map +1 -1
  526. package/dist/substrate/options.d.mts +33 -4
  527. package/dist/substrate/plugin-ctx.d.mts +70 -0
  528. package/dist/substrate/plugin-ctx.mjs +66 -0
  529. package/dist/substrate/plugin-ctx.mjs.map +1 -0
  530. package/dist/substrate/plugin.d.mts +46 -38
  531. package/dist/substrate/plugin.mjs +13 -9
  532. package/dist/substrate/plugin.mjs.map +1 -1
  533. package/dist/substrate/projection.d.mts +1 -1
  534. package/dist/substrate/runtime/atomic-write.mjs +3 -4
  535. package/dist/substrate/runtime/atomic-write.mjs.map +1 -1
  536. package/dist/substrate/runtime/cache/schema.mjs.map +1 -1
  537. package/dist/substrate/runtime/cache/service.mjs +50 -20
  538. package/dist/substrate/runtime/cache/service.mjs.map +1 -1
  539. package/dist/substrate/runtime/config-validation.mjs.map +1 -1
  540. package/dist/substrate/runtime/control-plane/domain.mjs +34 -12
  541. package/dist/substrate/runtime/control-plane/domain.mjs.map +1 -1
  542. package/dist/substrate/runtime/control-plane/service.mjs.map +1 -1
  543. package/dist/substrate/runtime/cross-process/command-channel/channel.mjs +14 -17
  544. package/dist/substrate/runtime/cross-process/command-channel/channel.mjs.map +1 -1
  545. package/dist/substrate/runtime/cross-process/command-channel/file-channel.mjs.map +1 -1
  546. package/dist/substrate/runtime/cross-process/command-channel/protocol.mjs.map +1 -1
  547. package/dist/substrate/runtime/cross-process/command-channel/runtime-control-lock.mjs.map +1 -1
  548. package/dist/substrate/runtime/cross-process/index.mjs +0 -2
  549. package/dist/substrate/runtime/cross-process/live-clock.mjs +1 -1
  550. package/dist/substrate/runtime/cross-process/live-clock.mjs.map +1 -1
  551. package/dist/substrate/runtime/cross-process/liveness.mjs +11 -18
  552. package/dist/substrate/runtime/cross-process/liveness.mjs.map +1 -1
  553. package/dist/substrate/runtime/cross-process/reclaim-stale-file.mjs +2 -2
  554. package/dist/substrate/runtime/cross-process/reclaim-stale-file.mjs.map +1 -1
  555. package/dist/substrate/runtime/cross-process/roster.mjs +17 -127
  556. package/dist/substrate/runtime/cross-process/roster.mjs.map +1 -1
  557. package/dist/substrate/runtime/cross-process/self-pid.mjs.map +1 -1
  558. package/dist/substrate/runtime/cross-process/stack-lock.mjs +29 -28
  559. package/dist/substrate/runtime/cross-process/stack-lock.mjs.map +1 -1
  560. package/dist/substrate/runtime/current-plugin.mjs.map +1 -1
  561. package/dist/substrate/runtime/errors.mjs +1 -13
  562. package/dist/substrate/runtime/errors.mjs.map +1 -1
  563. package/dist/substrate/runtime/format-unknown-error.mjs.map +1 -1
  564. package/dist/substrate/runtime/host-bind-mount-owner.mjs.map +1 -1
  565. package/dist/substrate/runtime/host-gateway.mjs.map +1 -1
  566. package/dist/substrate/runtime/host-tree-tar/index.mjs +15 -163
  567. package/dist/substrate/runtime/host-tree-tar/index.mjs.map +1 -1
  568. package/dist/substrate/runtime/http-probe.d.mts +1 -3
  569. package/dist/substrate/runtime/http-probe.mjs.map +1 -1
  570. package/dist/substrate/runtime/index.mjs +1 -6
  571. package/dist/substrate/runtime/lease-broker/service.mjs +5 -23
  572. package/dist/substrate/runtime/lease-broker/service.mjs.map +1 -1
  573. package/dist/substrate/runtime/lifecycle/dep-graph.mjs +3 -3
  574. package/dist/substrate/runtime/lifecycle/dep-graph.mjs.map +1 -1
  575. package/dist/substrate/runtime/lifecycle/graph-input-id.d.mts +1 -0
  576. package/dist/substrate/runtime/lifecycle/graph-input-id.mjs +133 -0
  577. package/dist/substrate/runtime/lifecycle/graph-input-id.mjs.map +1 -0
  578. package/dist/substrate/runtime/lifecycle/index.mjs +2 -2
  579. package/dist/substrate/runtime/lifecycle/plugin-registry.d.mts +1 -1
  580. package/dist/substrate/runtime/lifecycle/plugin-registry.mjs +22 -1
  581. package/dist/substrate/runtime/lifecycle/plugin-registry.mjs.map +1 -1
  582. package/dist/substrate/runtime/lifecycle/ready-gate.mjs +2 -15
  583. package/dist/substrate/runtime/lifecycle/ready-gate.mjs.map +1 -1
  584. package/dist/substrate/runtime/lifecycle/selective-restart.mjs +29 -25
  585. package/dist/substrate/runtime/lifecycle/selective-restart.mjs.map +1 -1
  586. package/dist/substrate/runtime/lifecycle/signals.mjs +1 -1
  587. package/dist/substrate/runtime/lifecycle/signals.mjs.map +1 -1
  588. package/dist/substrate/runtime/lifecycle/state-machine.mjs.map +1 -1
  589. package/dist/substrate/runtime/lifecycle/watch-attribution.d.mts +1 -1
  590. package/dist/substrate/runtime/lifecycle/watch-attribution.mjs +0 -1
  591. package/dist/substrate/runtime/lifecycle/watch-attribution.mjs.map +1 -1
  592. package/dist/substrate/runtime/managed-container.d.mts +5 -1
  593. package/dist/substrate/runtime/managed-container.mjs +8 -10
  594. package/dist/substrate/runtime/managed-container.mjs.map +1 -1
  595. package/dist/substrate/runtime/manifest/manifest.mjs +8 -30
  596. package/dist/substrate/runtime/manifest/manifest.mjs.map +1 -1
  597. package/dist/substrate/runtime/mode-errors.d.mts +1 -2
  598. package/dist/substrate/runtime/mode-errors.mjs.map +1 -1
  599. package/dist/substrate/runtime/observability/cascade-formatter.mjs +1 -11
  600. package/dist/substrate/runtime/observability/cascade-formatter.mjs.map +1 -1
  601. package/dist/substrate/runtime/observability/ignore-with-log.mjs.map +1 -1
  602. package/dist/substrate/runtime/observability/index.d.mts +1 -1
  603. package/dist/substrate/runtime/observability/index.mjs +4 -6
  604. package/dist/substrate/runtime/observability/log-attrs.mjs +46 -0
  605. package/dist/substrate/runtime/observability/log-attrs.mjs.map +1 -0
  606. package/dist/substrate/runtime/observability/log-store.mjs.map +1 -1
  607. package/dist/substrate/runtime/observability/logger.mjs +3 -3
  608. package/dist/substrate/runtime/observability/logger.mjs.map +1 -1
  609. package/dist/substrate/runtime/observability/output-truncate.mjs.map +1 -1
  610. package/dist/substrate/runtime/observability/pretty-error.mjs.map +1 -1
  611. package/dist/substrate/runtime/observability/process-lines.mjs.map +1 -1
  612. package/dist/substrate/runtime/observability/redaction.mjs.map +1 -1
  613. package/dist/substrate/runtime/observability/subprocess-capture.mjs +2 -2
  614. package/dist/substrate/runtime/observability/subprocess-capture.mjs.map +1 -1
  615. package/dist/substrate/runtime/passthrough-or-wrap.mjs.map +1 -1
  616. package/dist/substrate/runtime/paths.mjs +27 -9
  617. package/dist/substrate/runtime/paths.mjs.map +1 -1
  618. package/dist/substrate/runtime/phase-preserving-produce.mjs.map +1 -1
  619. package/dist/substrate/runtime/port-broker/service.mjs +10 -27
  620. package/dist/substrate/runtime/port-broker/service.mjs.map +1 -1
  621. package/dist/substrate/runtime/post-acquire-tasks.mjs.map +1 -1
  622. package/dist/substrate/runtime/probes.d.mts +2 -3
  623. package/dist/substrate/runtime/probes.mjs.map +1 -1
  624. package/dist/substrate/runtime/process-supervisor.mjs.map +1 -1
  625. package/dist/substrate/runtime/projection/operational-endpoints.mjs.map +1 -1
  626. package/dist/substrate/runtime/projection/state-ref.mjs.map +1 -1
  627. package/dist/substrate/runtime/projection/update.mjs +87 -11
  628. package/dist/substrate/runtime/projection/update.mjs.map +1 -1
  629. package/dist/substrate/runtime/random-suffix.mjs.map +1 -1
  630. package/dist/substrate/runtime/reconcile/fs-plan.mjs +146 -0
  631. package/dist/substrate/runtime/reconcile/fs-plan.mjs.map +1 -0
  632. package/dist/substrate/runtime/reconcile/graph.mjs +19 -0
  633. package/dist/substrate/runtime/reconcile/graph.mjs.map +1 -0
  634. package/dist/substrate/runtime/reconcile/index.mjs +5 -0
  635. package/dist/substrate/runtime/reconcile/label.mjs +41 -0
  636. package/dist/substrate/runtime/reconcile/label.mjs.map +1 -0
  637. package/dist/substrate/runtime/reconcile/spec.mjs +15 -0
  638. package/dist/substrate/runtime/reconcile/spec.mjs.map +1 -0
  639. package/dist/substrate/runtime/retry-policy.d.mts +2 -3
  640. package/dist/substrate/runtime/retry-policy.mjs.map +1 -1
  641. package/dist/substrate/runtime/routed-url.mjs.map +1 -1
  642. package/dist/substrate/runtime/runtime-decode.mjs.map +1 -1
  643. package/dist/substrate/runtime/scoped-http-server.mjs.map +1 -1
  644. package/dist/substrate/runtime/stage-and-swap/index.mjs +49 -12
  645. package/dist/substrate/runtime/stage-and-swap/index.mjs.map +1 -1
  646. package/dist/substrate/runtime/strategy-registry/chain-keyed-strategy-for.mjs.map +1 -1
  647. package/dist/substrate/runtime/strategy-registry/chain-probe-for.mjs.map +1 -1
  648. package/dist/substrate/runtime/strategy-registry/service.mjs +29 -17
  649. package/dist/substrate/runtime/strategy-registry/service.mjs.map +1 -1
  650. package/dist/substrate/runtime/subnet-broker.mjs.map +1 -1
  651. package/dist/substrate/runtime/supervisor/acquire-node.mjs +188 -56
  652. package/dist/substrate/runtime/supervisor/acquire-node.mjs.map +1 -1
  653. package/dist/substrate/runtime/supervisor/background-tasks.mjs +79 -65
  654. package/dist/substrate/runtime/supervisor/background-tasks.mjs.map +1 -1
  655. package/dist/substrate/runtime/supervisor/command-loop.mjs +82 -23
  656. package/dist/substrate/runtime/supervisor/command-loop.mjs.map +1 -1
  657. package/dist/substrate/runtime/supervisor/contribution-dispatcher.mjs +16 -0
  658. package/dist/substrate/runtime/supervisor/contribution-dispatcher.mjs.map +1 -0
  659. package/dist/substrate/runtime/supervisor/errors.mjs +11 -2
  660. package/dist/substrate/runtime/supervisor/errors.mjs.map +1 -1
  661. package/dist/substrate/runtime/supervisor/index.mjs +2 -0
  662. package/dist/substrate/runtime/supervisor/shutdown.mjs +6 -6
  663. package/dist/substrate/runtime/supervisor/shutdown.mjs.map +1 -1
  664. package/dist/substrate/runtime/supervisor/start-supervisor.mjs +60 -70
  665. package/dist/substrate/runtime/supervisor/start-supervisor.mjs.map +1 -1
  666. package/dist/substrate/runtime/supervisor/state.d.mts +1 -1
  667. package/dist/substrate/runtime/supervisor/state.mjs +1 -1
  668. package/dist/substrate/runtime/supervisor/state.mjs.map +1 -1
  669. package/dist/substrate/runtime/supervisor/teardown.mjs +10 -9
  670. package/dist/substrate/runtime/supervisor/teardown.mjs.map +1 -1
  671. package/dist/substrate/runtime/supervisor/wiring.mjs +6 -20
  672. package/dist/substrate/runtime/supervisor/wiring.mjs.map +1 -1
  673. package/dist/substrate/runtime/tar/reader.mjs +216 -0
  674. package/dist/substrate/runtime/tar/reader.mjs.map +1 -0
  675. package/dist/substrate/runtime/typed-env.mjs.map +1 -1
  676. package/dist/substrate/versioned-doc-schema.mjs.map +1 -1
  677. package/dist/substrate/versioned-doc-sync.mjs +5 -5
  678. package/dist/substrate/versioned-doc-sync.mjs.map +1 -1
  679. package/dist/surfaces/cli/command-tree.mjs +49 -7
  680. package/dist/surfaces/cli/command-tree.mjs.map +1 -1
  681. package/dist/surfaces/cli/commands/config.mjs +1 -1
  682. package/dist/surfaces/cli/commands/config.mjs.map +1 -1
  683. package/dist/surfaces/cli/commands/confirm-node.mjs.map +1 -1
  684. package/dist/surfaces/cli/commands/confirm.mjs.map +1 -1
  685. package/dist/surfaces/cli/commands/doctor.mjs +1 -1
  686. package/dist/surfaces/cli/commands/doctor.mjs.map +1 -1
  687. package/dist/surfaces/cli/commands/prune-picker-entry.mjs.map +1 -1
  688. package/dist/surfaces/cli/commands/prune-picker.mjs.map +1 -1
  689. package/dist/surfaces/cli/commands/prune.mjs +1 -1
  690. package/dist/surfaces/cli/commands/prune.mjs.map +1 -1
  691. package/dist/surfaces/cli/commands/snapshot.mjs +1 -1
  692. package/dist/surfaces/cli/commands/snapshot.mjs.map +1 -1
  693. package/dist/surfaces/cli/commands/status.mjs +1 -1
  694. package/dist/surfaces/cli/commands/status.mjs.map +1 -1
  695. package/dist/surfaces/cli/commands/supervisor-presence.mjs.map +1 -1
  696. package/dist/surfaces/cli/commands/wipe.mjs +3 -4
  697. package/dist/surfaces/cli/commands/wipe.mjs.map +1 -1
  698. package/dist/surfaces/cli/envelope.mjs.map +1 -1
  699. package/dist/surfaces/cli/errors.mjs.map +1 -1
  700. package/dist/surfaces/cli/flags.mjs.map +1 -1
  701. package/dist/surfaces/cli/index.mjs +45 -14
  702. package/dist/surfaces/cli/index.mjs.map +1 -1
  703. package/dist/surfaces/cli/output.mjs.map +1 -1
  704. package/dist/surfaces/cli/sysexits.mjs.map +1 -1
  705. package/dist/surfaces/tui/app.mjs +0 -21
  706. package/dist/surfaces/tui/app.mjs.map +1 -1
  707. package/dist/surfaces/tui/dashboard.mjs +0 -48
  708. package/dist/surfaces/tui/dashboard.mjs.map +1 -1
  709. package/dist/surfaces/tui/display-derivation.mjs +80 -16
  710. package/dist/surfaces/tui/display-derivation.mjs.map +1 -1
  711. package/dist/surfaces/tui/errors.mjs.map +1 -1
  712. package/dist/surfaces/tui/event-log.mjs +0 -9
  713. package/dist/surfaces/tui/event-log.mjs.map +1 -1
  714. package/dist/surfaces/tui/heartbeat.mjs.map +1 -1
  715. package/dist/surfaces/tui/index.mjs +2 -2
  716. package/dist/surfaces/tui/index.mjs.map +1 -1
  717. package/dist/surfaces/tui/input.mjs.map +1 -1
  718. package/dist/surfaces/tui/mode-detect.mjs.map +1 -1
  719. package/dist/surfaces/tui/mount-ink.mjs.map +1 -1
  720. package/dist/surfaces/tui/plain-renderer.mjs +26 -19
  721. package/dist/surfaces/tui/plain-renderer.mjs.map +1 -1
  722. package/dist/surfaces/tui/resource-table.mjs +8 -10
  723. package/dist/surfaces/tui/resource-table.mjs.map +1 -1
  724. package/images/postgres/Dockerfile +0 -1
  725. package/images/sui/Dockerfile +27 -54
  726. package/images/sui/entrypoint.sh +17 -179
  727. package/package.json +23 -15
  728. package/dashboard-ui/assets/index-Bmi1UtAg.js +0 -1356
  729. package/dashboard-ui/assets/index-D5EShVt4.js +0 -3
  730. package/dashboard-ui/assets/index-Deml9drg.css +0 -1
  731. package/dist/api/plugin-errors.d.mts +0 -7
  732. package/dist/api/plugin-errors.mjs +0 -10
  733. package/dist/api/plugin-errors.mjs.map +0 -1
  734. package/dist/cli/wirings/build-verb-layers.mjs +0 -42
  735. package/dist/cli/wirings/build-verb-layers.mjs.map +0 -1
  736. package/dist/contracts/capability-decl.d.mts +0 -40
  737. package/dist/orchestrators/built-in-plugin-layers.mjs +0 -54
  738. package/dist/orchestrators/built-in-plugin-layers.mjs.map +0 -1
  739. package/dist/orchestrators/run.mjs +0 -91
  740. package/dist/orchestrators/run.mjs.map +0 -1
  741. package/dist/orchestrators/runtime-composition.d.mts +0 -10
  742. package/dist/orchestrators/runtime-composition.mjs +0 -252
  743. package/dist/orchestrators/runtime-composition.mjs.map +0 -1
  744. package/dist/orchestrators/snapshot/capture-command.d.mts +0 -1
  745. package/dist/orchestrators/snapshot/capture-command.mjs +0 -25
  746. package/dist/orchestrators/snapshot/capture-command.mjs.map +0 -1
  747. package/dist/orchestrators/snapshot/pending-marker.mjs +0 -99
  748. package/dist/orchestrators/snapshot/pending-marker.mjs.map +0 -1
  749. package/dist/orchestrators/snapshot/recover-pending.mjs +0 -223
  750. package/dist/orchestrators/snapshot/recover-pending.mjs.map +0 -1
  751. package/dist/orchestrators/snapshot/state-document.d.mts +0 -1
  752. package/dist/orchestrators/snapshot/state-document.mjs +0 -58
  753. package/dist/orchestrators/snapshot/state-document.mjs.map +0 -1
  754. package/dist/plugins/account/spans.mjs +0 -16
  755. package/dist/plugins/account/spans.mjs.map +0 -1
  756. package/dist/plugins/account/variants/env.mjs +0 -24
  757. package/dist/plugins/account/variants/env.mjs.map +0 -1
  758. package/dist/plugins/account/variants/inline.mjs +0 -13
  759. package/dist/plugins/account/variants/inline.mjs.map +0 -1
  760. package/dist/plugins/account/variants/keystore.mjs +0 -91
  761. package/dist/plugins/account/variants/keystore.mjs.map +0 -1
  762. package/dist/plugins/action/spans.mjs +0 -11
  763. package/dist/plugins/action/spans.mjs.map +0 -1
  764. package/dist/plugins/coin/spans.mjs +0 -20
  765. package/dist/plugins/coin/spans.mjs.map +0 -1
  766. package/dist/plugins/deepbook/spans.mjs +0 -18
  767. package/dist/plugins/deepbook/spans.mjs.map +0 -1
  768. package/dist/plugins/faucet/spans.mjs +0 -12
  769. package/dist/plugins/faucet/spans.mjs.map +0 -1
  770. package/dist/plugins/package/spans.mjs +0 -14
  771. package/dist/plugins/package/spans.mjs.map +0 -1
  772. package/dist/plugins/postgres/codegen.mjs +0 -42
  773. package/dist/plugins/postgres/codegen.mjs.map +0 -1
  774. package/dist/plugins/postgres/connection.d.mts +0 -33
  775. package/dist/plugins/postgres/connection.mjs.map +0 -1
  776. package/dist/plugins/postgres/db-ensure.mjs.map +0 -1
  777. package/dist/plugins/postgres/errors.d.mts +0 -60
  778. package/dist/plugins/postgres/errors.mjs +0 -29
  779. package/dist/plugins/postgres/errors.mjs.map +0 -1
  780. package/dist/plugins/postgres/index.d.mts +0 -37
  781. package/dist/plugins/postgres/index.mjs +0 -68
  782. package/dist/plugins/postgres/index.mjs.map +0 -1
  783. package/dist/plugins/postgres/routable.mjs +0 -33
  784. package/dist/plugins/postgres/routable.mjs.map +0 -1
  785. package/dist/plugins/postgres/service.d.mts +0 -50
  786. package/dist/plugins/postgres/service.mjs +0 -179
  787. package/dist/plugins/postgres/service.mjs.map +0 -1
  788. package/dist/plugins/postgres/snapshot.mjs +0 -32
  789. package/dist/plugins/postgres/snapshot.mjs.map +0 -1
  790. package/dist/plugins/postgres/spans.mjs +0 -11
  791. package/dist/plugins/postgres/spans.mjs.map +0 -1
  792. package/dist/plugins/seal/spans.mjs +0 -18
  793. package/dist/plugins/seal/spans.mjs.map +0 -1
  794. package/dist/plugins/sui/spans.mjs +0 -17
  795. package/dist/plugins/sui/spans.mjs.map +0 -1
  796. package/dist/plugins/wallet/spans.mjs +0 -22
  797. package/dist/plugins/wallet/spans.mjs.map +0 -1
  798. package/dist/plugins/walrus/registry-publish.d.mts +0 -24
  799. package/dist/plugins/walrus/spans.mjs +0 -18
  800. package/dist/plugins/walrus/spans.mjs.map +0 -1
  801. package/dist/runtime/docker/logs.d.mts +0 -1
  802. package/dist/runtime/docker/logs.mjs +0 -34
  803. package/dist/runtime/docker/logs.mjs.map +0 -1
  804. package/dist/substrate/runtime/artifact-publisher/index.mjs +0 -86
  805. package/dist/substrate/runtime/artifact-publisher/index.mjs.map +0 -1
  806. package/dist/substrate/runtime/capability-sinks/index.d.mts +0 -1
  807. package/dist/substrate/runtime/capability-sinks/index.mjs +0 -3
  808. package/dist/substrate/runtime/capability-sinks/layer.d.mts +0 -1
  809. package/dist/substrate/runtime/capability-sinks/layer.mjs +0 -31
  810. package/dist/substrate/runtime/capability-sinks/layer.mjs.map +0 -1
  811. package/dist/substrate/runtime/capability-sinks/service.d.mts +0 -95
  812. package/dist/substrate/runtime/capability-sinks/service.mjs +0 -69
  813. package/dist/substrate/runtime/capability-sinks/service.mjs.map +0 -1
  814. package/dist/substrate/runtime/cross-process/lock.d.mts +0 -1
  815. package/dist/substrate/runtime/cross-process/lock.mjs +0 -23
  816. package/dist/substrate/runtime/cross-process/lock.mjs.map +0 -1
  817. package/dist/substrate/runtime/cross-process/snapshot-reservation.mjs +0 -113
  818. package/dist/substrate/runtime/cross-process/snapshot-reservation.mjs.map +0 -1
  819. package/dist/substrate/runtime/lifecycle/lifecycle-fact.mjs +0 -31
  820. package/dist/substrate/runtime/lifecycle/lifecycle-fact.mjs.map +0 -1
  821. package/dist/substrate/runtime/observability/formatter-registry.d.mts +0 -1
  822. package/dist/substrate/runtime/observability/formatter-registry.mjs +0 -48
  823. package/dist/substrate/runtime/observability/formatter-registry.mjs.map +0 -1
  824. package/dist/substrate/runtime/observability/span-store.d.mts +0 -1
  825. package/dist/substrate/runtime/observability/span-store.mjs +0 -110
  826. package/dist/substrate/runtime/observability/span-store.mjs.map +0 -1
  827. package/dist/substrate/runtime/observability/spans.d.mts +0 -1
  828. package/dist/substrate/runtime/observability/spans.mjs +0 -87
  829. package/dist/substrate/runtime/observability/spans.mjs.map +0 -1
  830. package/dist/substrate/runtime/projection/index.mjs +0 -4
  831. package/dist/substrate/runtime/projection/persisted.mjs +0 -213
  832. package/dist/substrate/runtime/projection/persisted.mjs.map +0 -1
  833. package/dist/substrate/runtime/scoped-multimap/service.mjs +0 -52
  834. package/dist/substrate/runtime/scoped-multimap/service.mjs.map +0 -1
  835. package/dist/substrate/runtime/scoped-ref-map/index.mjs +0 -2
  836. package/dist/substrate/runtime/scoped-ref-map/service.mjs +0 -83
  837. package/dist/substrate/runtime/scoped-ref-map/service.mjs.map +0 -1
  838. package/dist/substrate/runtime/state-store/index.mjs +0 -3
  839. package/dist/substrate/runtime/state-store/schema.d.mts +0 -1
  840. package/dist/substrate/runtime/state-store/schema.mjs +0 -41
  841. package/dist/substrate/runtime/state-store/schema.mjs.map +0 -1
  842. package/dist/substrate/runtime/state-store/service.d.mts +0 -1
  843. package/dist/substrate/runtime/state-store/service.mjs +0 -145
  844. package/dist/substrate/runtime/state-store/service.mjs.map +0 -1
  845. package/dist/substrate/runtime/sui-execute/index.mjs.map +0 -1
  846. package/dist/substrate/runtime/sui-execute/sign-and-dispatch.mjs.map +0 -1
  847. package/dist/substrate/runtime/sui-ledger/object-ref.mjs.map +0 -1
  848. package/dist/substrate/runtime/sui-move-build/index.mjs.map +0 -1
  849. package/dist/substrate/runtime/supervisor/dispatch-contributions.mjs +0 -151
  850. package/dist/substrate/runtime/supervisor/dispatch-contributions.mjs.map +0 -1
  851. package/dist/substrate/state-store.d.mts +0 -1
  852. /package/dist/orchestrators/{snapshot/pending-marker.d.mts → codegen/id-config.d.mts} +0 -0
  853. /package/dist/orchestrators/snapshot/{recover-pending.d.mts → interrupted-restore.d.mts} +0 -0
  854. /package/dist/{substrate/runtime/sui-execute → plugins/sui/exec}/sign-and-dispatch.d.mts +0 -0
  855. /package/dist/plugins/{postgres/snapshot.d.mts → sui/ledger/object-ref.d.mts} +0 -0
  856. /package/dist/{substrate/runtime/sui-move-build → plugins/sui/move}/index.d.mts +0 -0
  857. /package/dist/substrate/runtime/{state-store/index.d.mts → reconcile/graph.d.mts} +0 -0
  858. /package/dist/substrate/runtime/{cross-process/snapshot-reservation.d.mts → supervisor/contribution-dispatcher.d.mts} +0 -0
@@ -1,22 +1,103 @@
1
- import { defineSimpleConstExport } from "../internal/codegen-helpers.mjs";
1
+ import { keyedBucketSpec, liveBucketCodegen, staticBucketCodegen } from "../../contracts/config-bindings.mjs";
2
2
  //#region src/plugins/coin/codegen.ts
3
- /** Construct the Codegenable contribution for one coin instance.
3
+ /** Build the coin's config-binding spec for symbol `key`. `symbol` and
4
+ * `source` are structural literals; the coin type, decimals, and on-chain
5
+ * object ids are runtime-resolved (`resolveValue`).
4
6
  *
5
- * Emitter name is literal `coin/${symbol}` so the orchestrator can
6
- * group them and folds them into a single `coins.ts` at staging
7
- * time. Mirrors `account/${name}` naming in the Account plugin. */
8
- const makeCoinCodegen = (parts) => defineSimpleConstExport({
9
- emitterName: `coin/${parts.symbol}`,
10
- outputPath: `coins/${parts.symbol}.ts`,
11
- exportName: parts.symbol,
12
- value: parts.resolved,
13
- aggregate: {
14
- kind: "coin",
15
- bucket: "coins.ts",
16
- project: (exported) => exported
7
+ * Field-set DETERMINISM. A committed `resolveValue(...)` call evaluates at
8
+ * module-load and THROWS when the id is absent, so the static stub must
9
+ * emit ONLY fields the injected ids will carry. `source` (known at factory
10
+ * time) decides this: a `'builtin'` coin (SUI) is fully protocol-defined —
11
+ * it carries NO package id and its coin type / decimals are constants, so
12
+ * it emits them as LITERALS (no `resolveValue` that would throw at load).
13
+ * A `'registry'` / `'on-chain'` coin carries a real `packageId`, so it
14
+ * emits `fullCoinType` / `decimals` / `packageId` as resolved. The OPTIONAL
15
+ * discovery-only ids (`treasuryCapId` / `metadataId` / `iconUrl` /
16
+ * `displayName`) are non-deterministic — the static stub omits them; the
17
+ * LIVE record emits whatever it actually surfaced (consumers read them
18
+ * through optional chaining). */
19
+ const coinBucketSpec = (key, structural, live) => {
20
+ const builtin = structural.source === "builtin";
21
+ const fields = [{
22
+ key: "symbol",
23
+ variant: "literal",
24
+ value: structural.symbol
25
+ }, {
26
+ key: "source",
27
+ variant: "literal",
28
+ value: structural.source
29
+ }];
30
+ const constants = structural.constants ?? (live !== null && builtin ? {
31
+ fullCoinType: live.fullCoinType,
32
+ decimals: live.decimals
33
+ } : void 0);
34
+ if (builtin && constants !== void 0) {
35
+ fields.push({
36
+ key: "fullCoinType",
37
+ variant: "literal",
38
+ value: constants.fullCoinType
39
+ });
40
+ fields.push({
41
+ key: "decimals",
42
+ variant: "literal",
43
+ value: constants.decimals
44
+ });
45
+ } else {
46
+ if (structural.knownCoinType !== void 0) fields.push({
47
+ key: "fullCoinType",
48
+ variant: "literal",
49
+ value: structural.knownCoinType
50
+ });
51
+ else fields.push({
52
+ key: "fullCoinType",
53
+ variant: "resolved",
54
+ tsType: "string",
55
+ live: (s) => s.fullCoinType
56
+ });
57
+ fields.push({
58
+ key: "decimals",
59
+ variant: "resolved",
60
+ tsType: "number",
61
+ live: (s) => s.decimals
62
+ });
63
+ fields.push({
64
+ key: "packageId",
65
+ variant: "resolved",
66
+ tsType: "string | null",
67
+ live: (s) => s.packageId ?? null
68
+ });
69
+ }
70
+ if (live !== null) {
71
+ for (const field of [
72
+ "displayName",
73
+ "iconUrl",
74
+ "treasuryCapId",
75
+ "metadataId"
76
+ ]) if (live[field] !== void 0) fields.push({
77
+ key: field,
78
+ variant: "resolved",
79
+ live: (s) => s[field] ?? null
80
+ });
17
81
  }
18
- });
82
+ return keyedBucketSpec({
83
+ bucket: "coins.ts",
84
+ kind: "coin",
85
+ key,
86
+ fields
87
+ });
88
+ };
89
+ /** Construct the LIVE Codegenable contribution for one coin instance.
90
+ * Bakes the resolved record + feeds the generic id-config `values` channel.
91
+ * Mirrors `account/${name}` naming. */
92
+ const makeCoinCodegen = (parts) => liveBucketCodegen(coinBucketSpec(parts.symbol, {
93
+ symbol: parts.resolved.symbol,
94
+ source: parts.resolved.source
95
+ }, parts.resolved), parts.resolved);
96
+ /** Construct the STATIC (stack-free) Codegenable contribution for one coin.
97
+ * Emits `resolveValue('coin:<symbol>', '<key>')` for runtime fields; the
98
+ * committed `coins.ts` carries no baked coin type / object id. */
99
+ const makeCoinStaticCodegen = (config) => staticBucketCodegen(coinBucketSpec(config.symbol, config, null));
19
100
  //#endregion
20
- export { makeCoinCodegen };
101
+ export { makeCoinCodegen, makeCoinStaticCodegen };
21
102
 
22
103
  //# sourceMappingURL=codegen.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"codegen.mjs","names":[],"sources":["../../../src/plugins/coin/codegen.ts"],"sourcesContent":["// Coin plugin — Codegenable contribution.\n//\n// Distilled-doc 13-coin.md §\"Files written\": the codegen orchestrator\n// projects the per-stack CoinRegistry into a generated `coins.ts`\n// table:\n//\n// export const coins = {\n// mUSDC: { type, decimals, sdkCoin, symbol, ... },\n// mWETH: { type, decimals, sdkCoin, symbol, ... },\n// } as const;\n// export type CoinName = keyof typeof coins;\n//\n// This file declares the SEAM the typed binding shape and the\n// per-coin contribution. The heavy lift (writing the bytes, merging\n// all coins into one file) happens in the codegen orchestrator\n// (plugin/codegen layer, NOT this plugin); it walks every member's\n// caps tuple, finds the Coin-emitted contributions, and emits ONE\n// `coins.ts` referencing every entry.\n//\n// Per-coin shape mirrors the v3 `CoinEntry` (manifest schema) sans\n// the `sdkCoin` runtime projection that lives in the SDK adapter\n// at codegen time, not in the binding shape.\n\nimport type { CodegenableDecl } from '../../contracts/codegenable.ts';\n\nimport { defineSimpleConstExport } from '../internal/codegen-helpers.ts';\n\n/** The typed shape per emitted coin record. */\nexport interface CoinBindings {\n\treadonly symbol: string;\n\treadonly fullCoinType: string;\n\treadonly decimals: number;\n\treadonly displayName?: string;\n\treadonly iconUrl?: string;\n\treadonly treasuryCapId?: string;\n\treadonly metadataId?: string;\n\treadonly packageId?: string;\n\treadonly source: 'registry' | 'on-chain' | 'builtin';\n}\n\n/** Construct the Codegenable contribution for one coin instance.\n *\n * Emitter name is literal `coin/${symbol}` so the orchestrator can\n * group them and folds them into a single `coins.ts` at staging\n * time. Mirrors `account/${name}` naming in the Account plugin. */\nexport const makeCoinCodegen = <Symbol extends string>(parts: {\n\treadonly symbol: Symbol;\n\treadonly resolved: CoinBindings;\n}): CodegenableDecl<`coin/${Symbol}`> =>\n\tdefineSimpleConstExport({\n\t\temitterName: `coin/${parts.symbol}` as `coin/${Symbol}`,\n\t\toutputPath: `coins/${parts.symbol}.ts`,\n\t\texportName: parts.symbol,\n\t\tvalue: parts.resolved,\n\t\taggregate: {\n\t\t\tkind: 'coin',\n\t\t\tbucket: 'coins.ts',\n\t\t\t// Pass-through: this decl's exported map already keys by\n\t\t\t// coin symbol, which is the aggregate's merge key.\n\t\t\tproject: (exported) => exported,\n\t\t},\n\t});\n"],"mappings":";;;;;;;AA6CA,MAAa,mBAA0C,UAItD,wBAAwB;CACvB,aAAa,QAAQ,MAAM;CAC3B,YAAY,SAAS,MAAM,OAAO;CAClC,YAAY,MAAM;CAClB,OAAO,MAAM;CACb,WAAW;EACV,MAAM;EACN,QAAQ;EAGR,UAAU,aAAa;EACvB;CACD,CAAC"}
1
+ {"version":3,"file":"codegen.mjs","names":[],"sources":["../../../src/plugins/coin/codegen.ts"],"sourcesContent":["// Coin plugin — Codegenable contribution, via the UNIFIED config-binding\n// declaration.\n//\n// Distilled-doc 13-coin.md §\"Files written\": the codegen orchestrator\n// projects the per-stack CoinRegistry into a generated `coins.ts` table:\n//\n// export const coins = {\n// mUSDC: { type, decimals, sdkCoin, symbol, ... },\n// mWETH: { type, decimals, sdkCoin, symbol, ... },\n// } as const;\n//\n// ONE declaration, TWO derivations. A coin declares its `coins.ts`\n// contribution ONCE as a `ConfigBindingSet` (rooted under its symbol key).\n// The framework derives both behaviors (see `contracts/config-bindings.ts`):\n// - LIVE (boot): bakes the resolved on-chain values (fullCoinType,\n// decimals, ids) AND feeds the generic id-config `values` channel.\n// - STATIC (committed tree): emits `resolveValue('coin:<symbol>', '<key>')`\n// so the committed `coins.ts` carries NO baked coin type / object id.\n//\n// STRUCTURAL fields (symbol, source) stay literals; the coin type, decimals,\n// icon URL, and on-chain object ids are RUNTIME (loaded config data),\n// resolved at app build/dev time via the injected `__DEVSTACK_IDS__` global.\n\nimport type { CodegenableDecl } from '../../contracts/codegenable.ts';\nimport {\n\tkeyedBucketSpec,\n\tliveBucketCodegen,\n\tstaticBucketCodegen,\n\ttype BucketField,\n\ttype SiblingBucketSpec,\n} from '../../contracts/config-bindings.ts';\nimport type { JsonValue } from '../../orchestrators/codegen/id-config.ts';\n\n/** The typed shape per emitted coin record. */\nexport interface CoinBindings {\n\treadonly symbol: string;\n\treadonly fullCoinType: string;\n\treadonly decimals: number;\n\treadonly displayName?: string;\n\treadonly iconUrl?: string;\n\treadonly treasuryCapId?: string;\n\treadonly metadataId?: string;\n\treadonly packageId?: string;\n\treadonly source: 'registry' | 'on-chain' | 'builtin';\n}\n\n/** Static-config shape a coin can describe BEFORE acquire — the fields the\n * stack-free `staticCodegen` hook needs to emit a deterministic committed\n * stub for this symbol. `source` is the address-form provenance (known at\n * factory time). `constants` is set ONLY for a `'builtin'` coin (SUI),\n * whose coin type + decimals are protocol-defined constants the stub bakes\n * as literals (no `resolveValue` that would throw at module load). */\nexport interface CoinStaticConfig {\n\treadonly symbol: string;\n\treadonly source: CoinBindings['source'];\n\treadonly constants?: { readonly fullCoinType: string; readonly decimals: number };\n\t/** A user-declared on-chain coin type (the `coin.known('0x…::m::W')`\n\t * argument). This is DECLARED config (not loaded-at-runtime data), so the\n\t * committed `coins.ts` bakes it as a LITERAL `fullCoinType`. `decimals` and\n\t * `packageId` still resolve at runtime (they come from `getCoinMetadata`,\n\t * genuinely only known after a live probe), so they stay `resolveValue`.\n\t * Absent for `fromPackage` (registry/local) coins whose type is dynamic. */\n\treadonly knownCoinType?: string;\n}\n\n/** The state the LIVE binding derivation reads — the resolved coin record. */\ntype CoinLiveState = CoinBindings;\n\n/** Build the coin's config-binding spec for symbol `key`. `symbol` and\n * `source` are structural literals; the coin type, decimals, and on-chain\n * object ids are runtime-resolved (`resolveValue`).\n *\n * Field-set DETERMINISM. A committed `resolveValue(...)` call evaluates at\n * module-load and THROWS when the id is absent, so the static stub must\n * emit ONLY fields the injected ids will carry. `source` (known at factory\n * time) decides this: a `'builtin'` coin (SUI) is fully protocol-defined —\n * it carries NO package id and its coin type / decimals are constants, so\n * it emits them as LITERALS (no `resolveValue` that would throw at load).\n * A `'registry'` / `'on-chain'` coin carries a real `packageId`, so it\n * emits `fullCoinType` / `decimals` / `packageId` as resolved. The OPTIONAL\n * discovery-only ids (`treasuryCapId` / `metadataId` / `iconUrl` /\n * `displayName`) are non-deterministic — the static stub omits them; the\n * LIVE record emits whatever it actually surfaced (consumers read them\n * through optional chaining). */\nconst coinBucketSpec = (\n\tkey: string,\n\tstructural: CoinStaticConfig,\n\tlive: CoinLiveState | null,\n): SiblingBucketSpec<CoinLiveState> => {\n\tconst builtin = structural.source === 'builtin';\n\tconst fields: Array<BucketField<CoinLiveState>> = [\n\t\t{ key: 'symbol', variant: 'literal', value: structural.symbol },\n\t\t{ key: 'source', variant: 'literal', value: structural.source },\n\t];\n\tconst constants =\n\t\tstructural.constants ??\n\t\t(live !== null && builtin\n\t\t\t? { fullCoinType: live.fullCoinType, decimals: live.decimals }\n\t\t\t: undefined);\n\tif (builtin && constants !== undefined) {\n\t\t// A builtin coin (SUI) is protocol-defined: bake its constants as\n\t\t// literals in BOTH paths (no `resolveValue` to throw at module load).\n\t\t// The coin type carries `::` so it is not a baked on-chain id.\n\t\tfields.push({ key: 'fullCoinType', variant: 'literal', value: constants.fullCoinType });\n\t\tfields.push({ key: 'decimals', variant: 'literal', value: constants.decimals });\n\t} else {\n\t\t// A package / on-chain coin: decimals + package id are LOADED CONFIG\n\t\t// DATA (from `getCoinMetadata`) — resolve at app build/dev time. The\n\t\t// `fullCoinType` is DECLARED config when the caller passed an explicit\n\t\t// `coin.known('0x…::m::W')` type (`knownCoinType`) — bake it as a\n\t\t// LITERAL; otherwise (`fromPackage`) it is dynamic, so resolve it.\n\t\tif (structural.knownCoinType !== undefined) {\n\t\t\tfields.push({ key: 'fullCoinType', variant: 'literal', value: structural.knownCoinType });\n\t\t} else {\n\t\t\tfields.push({\n\t\t\t\tkey: 'fullCoinType',\n\t\t\t\tvariant: 'resolved',\n\t\t\t\ttsType: 'string',\n\t\t\t\tlive: (s) => s.fullCoinType,\n\t\t\t});\n\t\t}\n\t\tfields.push({\n\t\t\tkey: 'decimals',\n\t\t\tvariant: 'resolved',\n\t\t\ttsType: 'number',\n\t\t\tlive: (s) => s.decimals,\n\t\t});\n\t\tfields.push({\n\t\t\tkey: 'packageId',\n\t\t\tvariant: 'resolved',\n\t\t\ttsType: 'string | null',\n\t\t\tlive: (s) => (s.packageId ?? null) as JsonValue,\n\t\t});\n\t}\n\t// Discovery-only optional ids — emitted ONLY on the LIVE path, and only\n\t// when the resolved record carries them (non-deterministic, so the\n\t// committed static stub omits them; consumers read via optional chaining).\n\tif (live !== null) {\n\t\tconst optional: ReadonlyArray<keyof CoinBindings> = [\n\t\t\t'displayName',\n\t\t\t'iconUrl',\n\t\t\t'treasuryCapId',\n\t\t\t'metadataId',\n\t\t];\n\t\tfor (const field of optional) {\n\t\t\tif (live[field] !== undefined) {\n\t\t\t\tfields.push({\n\t\t\t\t\tkey: field,\n\t\t\t\t\tvariant: 'resolved',\n\t\t\t\t\tlive: (s) => (s[field] ?? null) as JsonValue,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\treturn keyedBucketSpec({ bucket: 'coins.ts', kind: 'coin', key, fields });\n};\n\n/** Construct the LIVE Codegenable contribution for one coin instance.\n * Bakes the resolved record + feeds the generic id-config `values` channel.\n * Mirrors `account/${name}` naming. */\nexport const makeCoinCodegen = <Symbol extends string>(parts: {\n\treadonly symbol: Symbol;\n\treadonly resolved: CoinBindings;\n}): CodegenableDecl =>\n\tliveBucketCodegen(\n\t\tcoinBucketSpec(\n\t\t\tparts.symbol,\n\t\t\t{ symbol: parts.resolved.symbol, source: parts.resolved.source },\n\t\t\tparts.resolved,\n\t\t),\n\t\tparts.resolved,\n\t);\n\n/** Construct the STATIC (stack-free) Codegenable contribution for one coin.\n * Emits `resolveValue('coin:<symbol>', '<key>')` for runtime fields; the\n * committed `coins.ts` carries no baked coin type / object id. */\nexport const makeCoinStaticCodegen = (config: CoinStaticConfig): CodegenableDecl =>\n\tstaticBucketCodegen(coinBucketSpec(config.symbol, config, null));\n"],"mappings":";;;;;;;;;;;;;;;;;;AAoFA,MAAM,kBACL,KACA,YACA,SACsC;CACtC,MAAM,UAAU,WAAW,WAAW;CACtC,MAAM,SAA4C,CACjD;EAAE,KAAK;EAAU,SAAS;EAAW,OAAO,WAAW;CAAO,GAC9D;EAAE,KAAK;EAAU,SAAS;EAAW,OAAO,WAAW;CAAO,CAC/D;CACA,MAAM,YACL,WAAW,cACV,SAAS,QAAQ,UACf;EAAE,cAAc,KAAK;EAAc,UAAU,KAAK;CAAS,IAC3D,KAAA;CACJ,IAAI,WAAW,cAAc,KAAA,GAAW;EAIvC,OAAO,KAAK;GAAE,KAAK;GAAgB,SAAS;GAAW,OAAO,UAAU;EAAa,CAAC;EACtF,OAAO,KAAK;GAAE,KAAK;GAAY,SAAS;GAAW,OAAO,UAAU;EAAS,CAAC;CAC/E,OAAO;EAMN,IAAI,WAAW,kBAAkB,KAAA,GAChC,OAAO,KAAK;GAAE,KAAK;GAAgB,SAAS;GAAW,OAAO,WAAW;EAAc,CAAC;OAExF,OAAO,KAAK;GACX,KAAK;GACL,SAAS;GACT,QAAQ;GACR,OAAO,MAAM,EAAE;EAChB,CAAC;EAEF,OAAO,KAAK;GACX,KAAK;GACL,SAAS;GACT,QAAQ;GACR,OAAO,MAAM,EAAE;EAChB,CAAC;EACD,OAAO,KAAK;GACX,KAAK;GACL,SAAS;GACT,QAAQ;GACR,OAAO,MAAO,EAAE,aAAa;EAC9B,CAAC;CACF;CAIA,IAAI,SAAS;OAOP,MAAM,SAAS;GALnB;GACA;GACA;GACA;EAE0B,GAC1B,IAAI,KAAK,WAAW,KAAA,GACnB,OAAO,KAAK;GACX,KAAK;GACL,SAAS;GACT,OAAO,MAAO,EAAE,UAAU;EAC3B,CAAC;CAAA;CAIJ,OAAO,gBAAgB;EAAE,QAAQ;EAAY,MAAM;EAAQ;EAAK;CAAO,CAAC;AACzE;;;;AAKA,MAAa,mBAA0C,UAItD,kBACC,eACC,MAAM,QACN;CAAE,QAAQ,MAAM,SAAS;CAAQ,QAAQ,MAAM,SAAS;AAAO,GAC/D,MAAM,QACP,GACA,MAAM,QACP;;;;AAKD,MAAa,yBAAyB,WACrC,oBAAoB,eAAe,OAAO,QAAQ,QAAQ,IAAI,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"discovery.mjs","names":[],"sources":["../../../src/plugins/coin/discovery.ts"],"sourcesContent":["// Coin auto-discovery — pure projection over a `LocalPackagePublishOutput`.\n//\n// Distilled-doc 13-coin.md §\"Capabilities PRODUCED\" §\"Registry\n// entries\" + Invariant 6 + Invariant 7:\n//\n// - Iterate `output.objectChanges`,\n// - Find paired Sui-framework `coin::TreasuryCap<T>` +\n// `coin::CoinMetadata<T>`,\n// - Reject nested generics (`TreasuryCap<A<B>>` returns no record),\n// - Sort ascending by fullCoinType for deterministic order.\n//\n// This file is PURE — no Effect, no RPC. Metadata enrichment (the\n// `getCoinMetadata` RPC fold) lives in `metadata.ts`; we just emit\n// the raw discovered shape here. The input is structural so Coin does\n// not import Package internals.\n\nimport {\n\tpickSuiFrameworkInnerGeneric,\n\tpickSuiFrameworkInnerGenericFromModule,\n} from './type-strings.ts';\n\nexport interface CoinDiscoveryObjectChange {\n\treadonly type: 'created' | 'published' | 'mutated' | 'wrapped' | 'transferred';\n\treadonly objectId?: string;\n\treadonly objectType?: string;\n\treadonly owner?: unknown;\n\treadonly json?: unknown;\n}\n\nexport interface CoinDiscoveryPublishOutput {\n\treadonly publisher: string;\n\treadonly objectChanges: ReadonlyArray<CoinDiscoveryObjectChange>;\n}\n\n/** A discovered coin pulled out of a publish output. The downstream\n * metadata enricher in `metadata.ts` turns this into a full\n * `CoinRecord`. */\nexport interface DiscoveredCoin {\n\t/** `0xPKG::module::Witness`. */\n\treadonly fullCoinType: string;\n\t/** Lower-cased witness name. */\n\treadonly witness: string;\n\t/** Lower-cased module name. */\n\treadonly moduleName: string;\n\treadonly treasuryCapId?: string;\n\treadonly treasuryCapOwner?: string;\n\treadonly metadataId?: string;\n\treadonly decimals?: number;\n\treadonly symbol?: string;\n\treadonly displayName?: string;\n\treadonly iconUrl?: string;\n\t/** True when the cap is address-owned by the publisher at the\n\t * end of the publish tx. Distilled-doc invariant: the faucet's\n\t * treasury-cap-mint auto-registration is gated off this flag. */\n\treadonly publisherOwnsCap: boolean;\n}\n\ninterface DiscoveredMetadata {\n\treadonly id: string;\n\treadonly decimals?: number;\n\treadonly symbol?: string;\n\treadonly displayName?: string;\n\treadonly iconUrl?: string;\n}\n\n/** Extract module + witness from `0xPKG::module::Witness`. */\nconst splitCoinType = (\n\tfullCoinType: string,\n): { readonly moduleName: string; readonly witness: string } | null => {\n\tconst parts = fullCoinType.split('::');\n\tif (parts.length !== 3) return null;\n\tconst [, moduleName, witness] = parts;\n\tif (moduleName === undefined || witness === undefined) return null;\n\treturn { moduleName, witness };\n};\n\n/** Read the address owner from a package-publish-output change. Handles\n * the SDK's discriminated owner-shape; non-address owners surface as\n * `undefined`. The owner shape varies across SDK versions; this\n * helper covers the common surface and degrades gracefully. */\nconst pickAddressOwner = (change: CoinDiscoveryObjectChange): string | undefined => {\n\tconst owner = change.owner as\n\t\t| { readonly AddressOwner?: string; readonly $kind?: string }\n\t\t| string\n\t\t| undefined;\n\tif (owner === undefined || owner === null) return undefined;\n\tif (typeof owner === 'string') return owner; // some SDK projections flatten\n\tif (typeof owner === 'object' && 'AddressOwner' in owner) {\n\t\treturn owner.AddressOwner;\n\t}\n\treturn undefined;\n};\n\nconst pickString = (json: Record<string, unknown>, key: string): string | undefined => {\n\tconst value = json[key];\n\treturn typeof value === 'string' && value.length > 0 ? value : undefined;\n};\n\nconst pickNumber = (json: Record<string, unknown>, key: string): number | undefined => {\n\tconst value = json[key];\n\treturn typeof value === 'number' && Number.isFinite(value) ? value : undefined;\n};\n\n/** Project the `json` payload of a `created` object change into the\n * metadata fields the discovery aggregate consumes. Always returns a\n * `Partial<...>` (never `null`) — an empty object is the natural \"no\n * fields recognised\" outcome and lets callers spread unconditionally\n * without an `??` fallback. */\nconst pickMetadata = (\n\tchange: CoinDiscoveryObjectChange,\n): Partial<Omit<DiscoveredMetadata, 'id'>> => {\n\tconst json = change.json;\n\tif (json === null || typeof json !== 'object' || Array.isArray(json)) return {};\n\tconst record = json as Record<string, unknown>;\n\tconst decimals = pickNumber(record, 'decimals');\n\tconst symbol = pickString(record, 'symbol');\n\tconst displayName = pickString(record, 'name');\n\tconst iconUrl = pickString(record, 'iconUrl') ?? pickString(record, 'icon_url');\n\treturn {\n\t\t...(decimals === undefined ? {} : { decimals }),\n\t\t...(symbol === undefined ? {} : { symbol }),\n\t\t...(displayName === undefined ? {} : { displayName }),\n\t\t...(iconUrl === undefined ? {} : { iconUrl }),\n\t};\n};\n\n/** Walk a publish output for coin pairs.\n *\n * Sort ascending by fullCoinType — distilled-doc invariant 6 — so\n * the registry sees a stable order across re-runs of the same\n * publish.\n *\n * Pure. No Effect / RPC. */\nexport const discoverCoinsFromPublish = (\n\toutput: CoinDiscoveryPublishOutput,\n): ReadonlyArray<DiscoveredCoin> => {\n\tconst publisher = output.publisher;\n\t// Two passes over the changes: collect caps, collect metadata,\n\t// then JOIN on fullCoinType. The straightforward \"iterate once and\n\t// build per-coin records\" is harder to read when the two object\n\t// types interleave in the output.\n\tconst caps = new Map<string, { readonly id: string; readonly owner: string | undefined }>();\n\tconst metadata = new Map<string, DiscoveredMetadata>();\n\n\tfor (const change of output.objectChanges) {\n\t\tif (change.type !== 'created') continue;\n\t\tif (!change.objectType) continue;\n\t\tconst capInner = pickSuiFrameworkInnerGeneric(change.objectType, 'TreasuryCap');\n\t\tif (capInner !== null && change.objectId !== undefined) {\n\t\t\tcaps.set(capInner, {\n\t\t\t\tid: change.objectId,\n\t\t\t\towner: pickAddressOwner(change),\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tconst metaInner = pickSuiFrameworkInnerGeneric(change.objectType, 'CoinMetadata');\n\t\tif (metaInner !== null && change.objectId !== undefined) {\n\t\t\tmetadata.set(metaInner, {\n\t\t\t\tid: change.objectId,\n\t\t\t\t...pickMetadata(change),\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tconst currencyInner = pickSuiFrameworkInnerGenericFromModule(\n\t\t\tchange.objectType,\n\t\t\t'coin_registry',\n\t\t\t'Currency',\n\t\t);\n\t\tif (currencyInner !== null && change.objectId !== undefined) {\n\t\t\tmetadata.set(currencyInner, {\n\t\t\t\tid: change.objectId,\n\t\t\t\t...pickMetadata(change),\n\t\t\t});\n\t\t}\n\t}\n\n\t// Union the two sets of coin types — a coin with only a cap or\n\t// only metadata is still a coin (distilled-doc invariant: we\n\t// surface degraded records rather than drop them).\n\tconst allTypes = new Set<string>([...caps.keys(), ...metadata.keys()]);\n\tconst records: Array<DiscoveredCoin> = [];\n\tfor (const fullCoinType of allTypes) {\n\t\tconst parts = splitCoinType(fullCoinType);\n\t\tif (!parts) continue;\n\t\tconst cap = caps.get(fullCoinType);\n\t\tconst meta = metadata.get(fullCoinType);\n\t\tconst publisherOwnsCap = cap !== undefined && cap.owner === publisher;\n\t\trecords.push({\n\t\t\tfullCoinType,\n\t\t\twitness: parts.witness.toLowerCase(),\n\t\t\tmoduleName: parts.moduleName.toLowerCase(),\n\t\t\ttreasuryCapId: cap?.id,\n\t\t\ttreasuryCapOwner: cap?.owner,\n\t\t\tmetadataId: meta?.id,\n\t\t\t...(meta?.decimals === undefined ? {} : { decimals: meta.decimals }),\n\t\t\t...(meta?.symbol === undefined ? {} : { symbol: meta.symbol }),\n\t\t\t...(meta?.displayName === undefined ? {} : { displayName: meta.displayName }),\n\t\t\t...(meta?.iconUrl === undefined ? {} : { iconUrl: meta.iconUrl }),\n\t\t\tpublisherOwnsCap,\n\t\t});\n\t}\n\t// Distilled-doc invariant 6: ascending sort by fullCoinType. Stable\n\t// across re-runs so the \"first wins on collision\" tie-break is\n\t// deterministic.\n\trecords.sort((a, b) =>\n\t\ta.fullCoinType < b.fullCoinType ? -1 : a.fullCoinType > b.fullCoinType ? 1 : 0,\n\t);\n\treturn records;\n};\n"],"mappings":";;;AAkEA,MAAM,iBACL,iBACsE;CACtE,MAAM,QAAQ,aAAa,MAAM,KAAK;AACtC,KAAI,MAAM,WAAW,EAAG,QAAO;CAC/B,MAAM,GAAG,YAAY,WAAW;AAChC,KAAI,eAAe,KAAA,KAAa,YAAY,KAAA,EAAW,QAAO;AAC9D,QAAO;EAAE;EAAY;EAAS;;;;;;AAO/B,MAAM,oBAAoB,WAA0D;CACnF,MAAM,QAAQ,OAAO;AAIrB,KAAI,UAAU,KAAA,KAAa,UAAU,KAAM,QAAO,KAAA;AAClD,KAAI,OAAO,UAAU,SAA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EAAE,eAAe,EAAE,eAAe,KAAK,EAAE,eAAe,EAAE,eAAe,IAAI,EAC7E;AACD,QAAO"}
1
+ {"version":3,"file":"discovery.mjs","names":[],"sources":["../../../src/plugins/coin/discovery.ts"],"sourcesContent":["// Coin auto-discovery — pure projection over a `LocalPackagePublishOutput`.\n//\n// Distilled-doc 13-coin.md §\"Capabilities PRODUCED\" §\"Registry\n// entries\" + Invariant 6 + Invariant 7:\n//\n// - Iterate `output.objectChanges`,\n// - Find paired Sui-framework `coin::TreasuryCap<T>` +\n// `coin::CoinMetadata<T>`,\n// - Reject nested generics (`TreasuryCap<A<B>>` returns no record),\n// - Sort ascending by fullCoinType for deterministic order.\n//\n// This file is PURE — no Effect, no RPC. Metadata enrichment (the\n// `getCoinMetadata` RPC fold) lives in `metadata.ts`; we just emit\n// the raw discovered shape here. The input is structural so Coin does\n// not import Package internals.\n\nimport {\n\tpickSuiFrameworkInnerGeneric,\n\tpickSuiFrameworkInnerGenericFromModule,\n} from './type-strings.ts';\n\nexport interface CoinDiscoveryObjectChange {\n\treadonly type: 'created' | 'published' | 'mutated' | 'wrapped' | 'transferred';\n\treadonly objectId?: string;\n\treadonly objectType?: string;\n\treadonly owner?: unknown;\n\treadonly json?: unknown;\n}\n\nexport interface CoinDiscoveryPublishOutput {\n\treadonly publisher: string;\n\treadonly objectChanges: ReadonlyArray<CoinDiscoveryObjectChange>;\n}\n\n/** A discovered coin pulled out of a publish output. The downstream\n * metadata enricher in `metadata.ts` turns this into a full\n * `CoinRecord`. */\nexport interface DiscoveredCoin {\n\t/** `0xPKG::module::Witness`. */\n\treadonly fullCoinType: string;\n\t/** Lower-cased witness name. */\n\treadonly witness: string;\n\t/** Lower-cased module name. */\n\treadonly moduleName: string;\n\treadonly treasuryCapId?: string;\n\treadonly treasuryCapOwner?: string;\n\treadonly metadataId?: string;\n\treadonly decimals?: number;\n\treadonly symbol?: string;\n\treadonly displayName?: string;\n\treadonly iconUrl?: string;\n\t/** True when the cap is address-owned by the publisher at the\n\t * end of the publish tx. Distilled-doc invariant: the faucet's\n\t * treasury-cap-mint auto-registration is gated off this flag. */\n\treadonly publisherOwnsCap: boolean;\n}\n\ninterface DiscoveredMetadata {\n\treadonly id: string;\n\treadonly decimals?: number;\n\treadonly symbol?: string;\n\treadonly displayName?: string;\n\treadonly iconUrl?: string;\n}\n\n/** Extract module + witness from `0xPKG::module::Witness`. */\nconst splitCoinType = (\n\tfullCoinType: string,\n): { readonly moduleName: string; readonly witness: string } | null => {\n\tconst parts = fullCoinType.split('::');\n\tif (parts.length !== 3) return null;\n\tconst [, moduleName, witness] = parts;\n\tif (moduleName === undefined || witness === undefined) return null;\n\treturn { moduleName, witness };\n};\n\n/** Read the address owner from a package-publish-output change. Handles\n * the SDK's discriminated owner-shape; non-address owners surface as\n * `undefined`. The owner shape varies across SDK versions; this\n * helper covers the common surface and degrades gracefully. */\nconst pickAddressOwner = (change: CoinDiscoveryObjectChange): string | undefined => {\n\tconst owner = change.owner as\n\t\t| { readonly AddressOwner?: string; readonly $kind?: string }\n\t\t| string\n\t\t| undefined;\n\tif (owner === undefined || owner === null) return undefined;\n\tif (typeof owner === 'string') return owner; // some SDK projections flatten\n\tif (typeof owner === 'object' && 'AddressOwner' in owner) {\n\t\treturn owner.AddressOwner;\n\t}\n\treturn undefined;\n};\n\nconst pickString = (json: Record<string, unknown>, key: string): string | undefined => {\n\tconst value = json[key];\n\treturn typeof value === 'string' && value.length > 0 ? value : undefined;\n};\n\nconst pickNumber = (json: Record<string, unknown>, key: string): number | undefined => {\n\tconst value = json[key];\n\treturn typeof value === 'number' && Number.isFinite(value) ? value : undefined;\n};\n\n/** Project the `json` payload of a `created` object change into the\n * metadata fields the discovery aggregate consumes. Always returns a\n * `Partial<...>` (never `null`) — an empty object is the natural \"no\n * fields recognised\" outcome and lets callers spread unconditionally\n * without an `??` fallback. */\nconst pickMetadata = (\n\tchange: CoinDiscoveryObjectChange,\n): Partial<Omit<DiscoveredMetadata, 'id'>> => {\n\tconst json = change.json;\n\tif (json === null || typeof json !== 'object' || Array.isArray(json)) return {};\n\tconst record = json as Record<string, unknown>;\n\tconst decimals = pickNumber(record, 'decimals');\n\tconst symbol = pickString(record, 'symbol');\n\tconst displayName = pickString(record, 'name');\n\tconst iconUrl = pickString(record, 'iconUrl') ?? pickString(record, 'icon_url');\n\treturn {\n\t\t...(decimals === undefined ? {} : { decimals }),\n\t\t...(symbol === undefined ? {} : { symbol }),\n\t\t...(displayName === undefined ? {} : { displayName }),\n\t\t...(iconUrl === undefined ? {} : { iconUrl }),\n\t};\n};\n\n/** Walk a publish output for coin pairs.\n *\n * Sort ascending by fullCoinType — distilled-doc invariant 6 — so\n * the registry sees a stable order across re-runs of the same\n * publish.\n *\n * Pure. No Effect / RPC. */\nexport const discoverCoinsFromPublish = (\n\toutput: CoinDiscoveryPublishOutput,\n): ReadonlyArray<DiscoveredCoin> => {\n\tconst publisher = output.publisher;\n\t// Two passes over the changes: collect caps, collect metadata,\n\t// then JOIN on fullCoinType. The straightforward \"iterate once and\n\t// build per-coin records\" is harder to read when the two object\n\t// types interleave in the output.\n\tconst caps = new Map<string, { readonly id: string; readonly owner: string | undefined }>();\n\tconst metadata = new Map<string, DiscoveredMetadata>();\n\n\tfor (const change of output.objectChanges) {\n\t\tif (change.type !== 'created') continue;\n\t\tif (!change.objectType) continue;\n\t\tconst capInner = pickSuiFrameworkInnerGeneric(change.objectType, 'TreasuryCap');\n\t\tif (capInner !== null && change.objectId !== undefined) {\n\t\t\tcaps.set(capInner, {\n\t\t\t\tid: change.objectId,\n\t\t\t\towner: pickAddressOwner(change),\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tconst metaInner = pickSuiFrameworkInnerGeneric(change.objectType, 'CoinMetadata');\n\t\tif (metaInner !== null && change.objectId !== undefined) {\n\t\t\tmetadata.set(metaInner, {\n\t\t\t\tid: change.objectId,\n\t\t\t\t...pickMetadata(change),\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tconst currencyInner = pickSuiFrameworkInnerGenericFromModule(\n\t\t\tchange.objectType,\n\t\t\t'coin_registry',\n\t\t\t'Currency',\n\t\t);\n\t\tif (currencyInner !== null && change.objectId !== undefined) {\n\t\t\tmetadata.set(currencyInner, {\n\t\t\t\tid: change.objectId,\n\t\t\t\t...pickMetadata(change),\n\t\t\t});\n\t\t}\n\t}\n\n\t// Union the two sets of coin types — a coin with only a cap or\n\t// only metadata is still a coin (distilled-doc invariant: we\n\t// surface degraded records rather than drop them).\n\tconst allTypes = new Set<string>([...caps.keys(), ...metadata.keys()]);\n\tconst records: Array<DiscoveredCoin> = [];\n\tfor (const fullCoinType of allTypes) {\n\t\tconst parts = splitCoinType(fullCoinType);\n\t\tif (!parts) continue;\n\t\tconst cap = caps.get(fullCoinType);\n\t\tconst meta = metadata.get(fullCoinType);\n\t\tconst publisherOwnsCap = cap !== undefined && cap.owner === publisher;\n\t\trecords.push({\n\t\t\tfullCoinType,\n\t\t\twitness: parts.witness.toLowerCase(),\n\t\t\tmoduleName: parts.moduleName.toLowerCase(),\n\t\t\ttreasuryCapId: cap?.id,\n\t\t\ttreasuryCapOwner: cap?.owner,\n\t\t\tmetadataId: meta?.id,\n\t\t\t...(meta?.decimals === undefined ? {} : { decimals: meta.decimals }),\n\t\t\t...(meta?.symbol === undefined ? {} : { symbol: meta.symbol }),\n\t\t\t...(meta?.displayName === undefined ? {} : { displayName: meta.displayName }),\n\t\t\t...(meta?.iconUrl === undefined ? {} : { iconUrl: meta.iconUrl }),\n\t\t\tpublisherOwnsCap,\n\t\t});\n\t}\n\t// Distilled-doc invariant 6: ascending sort by fullCoinType. Stable\n\t// across re-runs so the \"first wins on collision\" tie-break is\n\t// deterministic.\n\trecords.sort((a, b) =>\n\t\ta.fullCoinType < b.fullCoinType ? -1 : a.fullCoinType > b.fullCoinType ? 1 : 0,\n\t);\n\treturn records;\n};\n"],"mappings":";;;AAkEA,MAAM,iBACL,iBACsE;CACtE,MAAM,QAAQ,aAAa,MAAM,IAAI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AAa,KAAA,IAAY,CAAC,IAAI,EAAE,UAAU,KAAK,SAAS;GAClE,GAAI,MAAM,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ,KAAK,OAAO;GAC5D,GAAI,MAAM,gBAAgB,KAAA,IAAY,CAAC,IAAI,EAAE,aAAa,KAAK,YAAY;GAC3E,GAAI,MAAM,YAAY,KAAA,IAAY,CAAC,IAAI,EAAE,SAAS,KAAK,QAAQ;GAC/D;EACD,CAAC;CACF;CAIA,QAAQ,MAAM,GAAG,MAChB,EAAE,eAAe,EAAE,eAAe,KAAK,EAAE,eAAe,EAAE,eAAe,IAAI,CAC9E;CACA,OAAO;AACR"}
@@ -4,10 +4,7 @@ const coinError = (phase, parts) => ({
4
4
  phase,
5
5
  ...parts
6
6
  });
7
- /** Error tags this plugin contributes — surfaced to the cause walker
8
- * via `PluginErrorContribution`. */
9
- const COIN_ERROR_TAGS = ["CoinError"];
10
7
  //#endregion
11
- export { COIN_ERROR_TAGS, coinError };
8
+ export { coinError };
12
9
 
13
10
  //# sourceMappingURL=errors.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.mjs","names":[],"sources":["../../../src/plugins/coin/errors.ts"],"sourcesContent":["// Coin plugin — typed errors.\n//\n// Distilled-doc finding (13-coin.md Pain point #8 \"No CoinError tag at\n// all\"): the v3 coin module reused `PublishError` for mint failures\n// and surfaced `CoinNotFoundError` / `CoinAmbiguousError` only on the\n// factory path. The redesign unifies coin-side failures into a SINGLE\n// tagged error with a CLOSED phase set so downstream `catchTag`\n// callers can distinguish \"not in registry\" from \"mint failed\" from\n// \"cap missing\".\n//\n// Effect v4: plain interface + `_tag` literal discriminator (no\n// subclassing). Mirrors the Account plugin's split shape and the\n// substrate's per-plugin tagged-error convention.\n\n/** Phases for `CoinError`. Closed sum — adding a phase requires\n * editing this list AND the cause walker's display table.\n *\n * Phase semantics:\n * - `not-found` — symbol/witness/bare-type didn't resolve\n * against the registry / on-chain metadata.\n * - `ambiguous` — two distinct coin types matched a single\n * registry-key lookup. Caller should\n * disambiguate via the witness form.\n * - `nested-generic` — bare-coin-type rejected because it\n * carried a nested generic (`<T<U>>`).\n * Distilled-doc invariant 7: refuse to\n * guess. Surfaces during the discovery\n * walker AND during the address-resolution\n * bare-string branch.\n * - `cap-missing` — the package didn't capture a\n * `TreasuryCap` under the requested field\n * (either no cap at all, or the captured\n * record key is wrong).\n * - `metadata-fetch` — `getCoinMetadata` failed after retries.\n * Soft-degradation path: the discovery\n * walker swallows this to keep partial\n * coverage; the bare-coin-type branch of\n * the user-facing factory surfaces it.\n * - `mint-tx` — sign-and-execute of the mint tx failed.\n * - `mint-parse` — the minted `Coin<T>` was not present in\n * the resulting `objectChanges`. */\nexport type CoinPhase =\n\t| 'not-found'\n\t| 'ambiguous'\n\t| 'nested-generic'\n\t| 'cap-missing'\n\t| 'metadata-fetch'\n\t| 'mint-tx'\n\t| 'mint-parse';\n\n/** Single tagged coin error. */\nexport interface CoinError {\n\treadonly _tag: 'CoinError';\n\treadonly phase: CoinPhase;\n\t/** User-facing identifier — the symbol / witness / bare-type the\n\t * caller passed. Populated even when the cause was a mint\n\t * (in which case it carries the resolved fullCoinType so the\n\t * pretty-cause walker can render context). */\n\treadonly identifier: string;\n\treadonly message: string;\n\t/** Optional list of registered candidates — populated by\n\t * `not-found` / `ambiguous` so the renderer can show what WAS\n\t * available. */\n\treadonly candidates?: ReadonlyArray<string>;\n\treadonly cause?: unknown;\n}\n\nexport const coinError = (\n\tphase: CoinPhase,\n\tparts: Omit<CoinError, '_tag' | 'phase'>,\n): CoinError => ({ _tag: 'CoinError', phase, ...parts });\n\n/** Error tags this plugin contributes surfaced to the cause walker\n * via `PluginErrorContribution`. */\nexport const COIN_ERROR_TAGS = ['CoinError'] as const;\n"],"mappings":";AAmEA,MAAa,aACZ,OACA,WACgB;CAAE,MAAM;CAAa;CAAO,GAAG;CAAO;;;AAIvD,MAAa,kBAAkB,CAAC,YAAY"}
1
+ {"version":3,"file":"errors.mjs","names":[],"sources":["../../../src/plugins/coin/errors.ts"],"sourcesContent":["// Coin plugin — typed errors.\n//\n// Coin-side failures unify into a SINGLE tagged error with a CLOSED\n// phase set so downstream `catchTag` callers can distinguish \"not in\n// registry\" from \"mint failed\" from \"cap missing\".\n//\n// Effect v4: plain interface + `_tag` literal discriminator (no\n// subclassing). Mirrors the Account plugin's split shape and the\n// substrate's per-plugin tagged-error convention.\n\n/** Phases for `CoinError`. Closed sum — adding a phase requires\n * editing this list AND the cause walker's display table.\n *\n * Phase semantics:\n * - `not-found` — symbol/witness/bare-type didn't resolve\n * against the registry / on-chain metadata.\n * - `ambiguous` — two distinct coin types matched a single\n * registry-key lookup. Caller should\n * disambiguate via the witness form.\n * - `nested-generic` — bare-coin-type rejected because it\n * carried a nested generic (`<T<U>>`).\n * Distilled-doc invariant 7: refuse to\n * guess. Surfaces during the discovery\n * walker AND during the address-resolution\n * bare-string branch.\n * - `cap-missing` — the package didn't capture a\n * `TreasuryCap` under the requested field\n * (either no cap at all, or the captured\n * record key is wrong).\n * - `metadata-fetch` — `getCoinMetadata` failed after retries.\n * Soft-degradation path: the discovery\n * walker swallows this to keep partial\n * coverage; the bare-coin-type branch of\n * the user-facing factory surfaces it.\n * - `mint-tx` — sign-and-execute of the mint tx failed.\n * - `mint-parse` — the minted `Coin<T>` was not present in\n * the resulting `objectChanges`. */\nexport type CoinPhase =\n\t| 'not-found'\n\t| 'ambiguous'\n\t| 'nested-generic'\n\t| 'cap-missing'\n\t| 'metadata-fetch'\n\t| 'mint-tx'\n\t| 'mint-parse';\n\n/** Single tagged coin error. */\nexport interface CoinError {\n\treadonly _tag: 'CoinError';\n\treadonly phase: CoinPhase;\n\t/** User-facing identifier — the symbol / witness / bare-type the\n\t * caller passed. Populated even when the cause was a mint\n\t * (in which case it carries the resolved fullCoinType so the\n\t * pretty-cause walker can render context). */\n\treadonly identifier: string;\n\treadonly message: string;\n\t/** Optional list of registered candidates — populated by\n\t * `not-found` / `ambiguous` so the renderer can show what WAS\n\t * available. */\n\treadonly candidates?: ReadonlyArray<string>;\n\treadonly cause?: unknown;\n}\n\nexport const coinError = (\n\tphase: CoinPhase,\n\tparts: Omit<CoinError, '_tag' | 'phase'>,\n): CoinError => ({ _tag: 'CoinError', phase, ...parts });\n\n/** The catchable error tags this plugin exposes. Pinned against the\n * user-facing error catalog by the error-catalog-parity test. */\nexport const COIN_ERROR_TAGS = ['CoinError'] as const;\n"],"mappings":";AA+DA,MAAa,aACZ,OACA,WACgB;CAAE,MAAM;CAAa;CAAO,GAAG;AAAM"}
@@ -1,10 +1,6 @@
1
- import { CodegenableDecl } from "../../contracts/codegenable.mjs";
2
- import { SnapshotableDecl } from "../../contracts/snapshotable.mjs";
3
1
  import { AnyResourceRef, Plugin, ResourceRef } from "../../substrate/plugin.mjs";
4
- import { SuiClient } from "../sui/mode/shared.mjs";
5
2
  import { SuiOptions } from "../sui/mode/spec.mjs";
6
- import { AccountFundingRequest } from "../../contracts/funding-strategy.mjs";
7
- import { ArtifactPublishError } from "../../primitives/artifact-publisher.mjs";
3
+ import { SuiClient } from "../sui/mode/shared.mjs";
8
4
  import { CoinError, CoinPhase } from "./errors.mjs";
9
5
  import { MintResult, MintSigner } from "./mint.mjs";
10
6
  import { isBareCoinType, validateBareCoinType } from "./metadata.mjs";
@@ -12,8 +8,6 @@ import { BUILTIN_COINS, BuiltinCoinName, ResolvedCoin } from "./address-resoluti
12
8
  import { CoinAddressForm, CoinValue } from "./service.mjs";
13
9
  import { CoinBindings } from "./codegen.mjs";
14
10
  import { DiscoveredCoin } from "./discovery.mjs";
15
- import { Effect } from "effect";
16
-
17
11
  //#region src/plugins/coin/index.d.ts
18
12
  type PackageNameOf<Pkg extends PackageMember> = Pkg extends ResourceRef<`package:${infer Name}`, PackageMemberValue> ? Name : string;
19
13
  /** A user-supplied package ref. The user passes the result of
@@ -40,37 +34,13 @@ declare const coin: {
40
34
  readonly sui: ResourceRef<"sui", SuiClient & {
41
35
  readonly mode: SuiOptions["mode"];
42
36
  }>;
43
- } ? T extends Readonly<Record<string, AnyResourceRef>> ? readonly T[keyof T][] : readonly [] : never : never, readonly [SnapshotableDecl, CodegenableDecl<`coin/${string}`>, ...{
44
- kind: "strategy-contributor";
45
- capabilityKey: `coinType:${string}`;
46
- strategy: {
47
- usesAccountSigner: true;
48
- request: (req: AccountFundingRequest<unknown>) => Effect.Effect<void, ArtifactPublishError | CoinError, never>;
49
- };
50
- autoMounted: true;
51
- }[]]>;
37
+ } ? T extends Readonly<Record<string, AnyResourceRef>> ? readonly T[keyof T][] : readonly [] : never : never>;
52
38
  readonly known: <FullType extends string>(fullCoinType: FullType) => Plugin<`coin:${string}`, CoinValue, readonly ResourceRef<"sui", SuiClient & {
53
39
  readonly mode: SuiOptions["mode"];
54
- }>[], readonly [SnapshotableDecl, CodegenableDecl<`coin/${string}`>, ...{
55
- kind: "strategy-contributor";
56
- capabilityKey: `coinType:${string}`;
57
- strategy: {
58
- usesAccountSigner: true;
59
- request: (req: AccountFundingRequest<unknown>) => Effect.Effect<void, ArtifactPublishError | CoinError, never>;
60
- };
61
- autoMounted: true;
62
- }[]]>;
40
+ }>[]>;
63
41
  readonly builtin: <Name extends keyof typeof BUILTIN_COINS>(name: Name) => Plugin<`coin:${Name}`, CoinValue, readonly ResourceRef<"sui", SuiClient & {
64
42
  readonly mode: SuiOptions["mode"];
65
- }>[], readonly [SnapshotableDecl, CodegenableDecl<`coin/${string}`>, ...{
66
- kind: "strategy-contributor";
67
- capabilityKey: `coinType:${string}`;
68
- strategy: {
69
- usesAccountSigner: true;
70
- request: (req: AccountFundingRequest<unknown>) => Effect.Effect<void, ArtifactPublishError | CoinError, never>;
71
- };
72
- autoMounted: true;
73
- }[]]>;
43
+ }>[]>;
74
44
  };
75
45
  //#endregion
76
46
  export { PackageMember, coin };
@@ -1,22 +1,21 @@
1
1
  import { definePlugin, resource } from "../../substrate/plugin.mjs";
2
2
  import "../../api/define-plugin.mjs";
3
- import { ArtifactPublisherService } from "../../substrate/runtime/artifact-publisher/index.mjs";
4
- import "./discovery.mjs";
3
+ import { CacheService } from "../../substrate/runtime/cache/service.mjs";
4
+ import "../../substrate/runtime/cache/index.mjs";
5
+ import { PluginContext, emitContributions } from "../../substrate/plugin-ctx.mjs";
5
6
  import { CoinRegistryService } from "./registry.mjs";
6
- import { pluginErrorContributions } from "../../api/plugin-errors.mjs";
7
7
  import { suiResource } from "../sui/index.mjs";
8
- import { makeCoinCodegen } from "./codegen.mjs";
8
+ import { makeCoinCodegen, makeCoinStaticCodegen } from "./codegen.mjs";
9
9
  import { makeCoinSnapshotable } from "./snapshot.mjs";
10
- import { COIN_ERROR_TAGS } from "./errors.mjs";
11
- import "./spans.mjs";
10
+ import "./errors.mjs";
12
11
  import "./metadata.mjs";
13
- import "./address-resolution.mjs";
12
+ import { BUILTIN_COINS } from "./address-resolution.mjs";
14
13
  import "./mint.mjs";
15
14
  import { acquireCoin } from "./service.mjs";
15
+ import "./discovery.mjs";
16
16
  import { Effect } from "effect";
17
17
  import { createHash } from "node:crypto";
18
18
  //#region src/plugins/coin/index.ts
19
- const coinErrorContributions = pluginErrorContributions(COIN_ERROR_TAGS);
20
19
  const coinFundingCapabilityKey = (fullCoinType) => `coinType:${fullCoinType}`;
21
20
  /** Resource id constructor. The symbolic name is part of the resource identity
22
21
  * so the substrate's compose-time dedup catches collisions. */
@@ -52,7 +51,7 @@ const projectCoinSdk = (sui) => ({
52
51
  client: sui.sdk.client,
53
52
  forkMode: sui.fork !== null
54
53
  });
55
- const buildCapabilities = (symbol, resolved) => {
54
+ const coinContributions = (symbol, resolved) => {
56
55
  const bindings = {
57
56
  symbol: resolved.symbol ?? symbol,
58
57
  fullCoinType: resolved.fullCoinType,
@@ -110,10 +109,15 @@ const fromPackage = (pkg, witnessName) => {
110
109
  },
111
110
  role: "task",
112
111
  section: "action",
112
+ staticCodegen: () => [makeCoinStaticCodegen({
113
+ symbol,
114
+ source: "registry"
115
+ })],
113
116
  start: ({ pkg: resolved, sui }) => Effect.gen(function* () {
114
- const artifactPublisher = yield* ArtifactPublisherService;
117
+ const ctx = yield* PluginContext;
118
+ const artifactPublisher = yield* CacheService;
115
119
  const registry = yield* CoinRegistryService;
116
- return yield* acquireCoin({
120
+ const value = yield* acquireCoin({
117
121
  kind: "witness",
118
122
  publishingPackageName: resolved.name,
119
123
  witness: witnessName,
@@ -121,12 +125,12 @@ const fromPackage = (pkg, witnessName) => {
121
125
  }, {
122
126
  registry,
123
127
  sdk: projectCoinSdk(sui),
124
- chain: sui.chain,
128
+ chainId: sui.chainId,
125
129
  publisher: artifactPublisher
126
130
  });
127
- }),
128
- errorContributions: coinErrorContributions,
129
- capabilities: ({ value }) => buildCapabilities(symbol, value)
131
+ emitContributions(ctx, coinContributions(symbol, value));
132
+ return value;
133
+ })
130
134
  });
131
135
  };
132
136
  /** Resolve a coin by bare on-chain type via `getCoinMetadata`.
@@ -143,21 +147,27 @@ const known = (fullCoinType) => {
143
147
  dependsOn: { sui: suiResource },
144
148
  role: "task",
145
149
  section: "action",
150
+ staticCodegen: () => [makeCoinStaticCodegen({
151
+ symbol: id,
152
+ source: "on-chain",
153
+ knownCoinType: fullCoinType
154
+ })],
146
155
  start: ({ sui }) => Effect.gen(function* () {
147
- const publisher = yield* ArtifactPublisherService;
156
+ const ctx = yield* PluginContext;
157
+ const publisher = yield* CacheService;
148
158
  const registry = yield* CoinRegistryService;
149
- return yield* acquireCoin({
159
+ const value = yield* acquireCoin({
150
160
  kind: "known",
151
161
  fullCoinType
152
162
  }, {
153
163
  registry,
154
164
  sdk: projectCoinSdk(sui),
155
- chain: sui.chain,
165
+ chainId: sui.chainId,
156
166
  publisher
157
167
  });
158
- }),
159
- errorContributions: coinErrorContributions,
160
- capabilities: ({ value }) => buildCapabilities(id, value)
168
+ emitContributions(ctx, coinContributions(id, value));
169
+ return value;
170
+ })
161
171
  });
162
172
  };
163
173
  /** Resolve a protocol-defined builtin coin. Currently `'sui'` only —
@@ -170,21 +180,30 @@ const builtin = (name) => {
170
180
  dependsOn: { sui: suiResource },
171
181
  role: "task",
172
182
  section: "action",
183
+ staticCodegen: () => [makeCoinStaticCodegen({
184
+ symbol,
185
+ source: "builtin",
186
+ constants: {
187
+ fullCoinType: BUILTIN_COINS[name].fullCoinType,
188
+ decimals: BUILTIN_COINS[name].decimals
189
+ }
190
+ })],
173
191
  start: ({ sui }) => Effect.gen(function* () {
174
- const publisher = yield* ArtifactPublisherService;
192
+ const ctx = yield* PluginContext;
193
+ const publisher = yield* CacheService;
175
194
  const registry = yield* CoinRegistryService;
176
- return yield* acquireCoin({
195
+ const value = yield* acquireCoin({
177
196
  kind: "builtin",
178
197
  name
179
198
  }, {
180
199
  registry,
181
200
  sdk: projectCoinSdk(sui),
182
- chain: sui.chain,
201
+ chainId: sui.chainId,
183
202
  publisher
184
203
  });
185
- }),
186
- errorContributions: coinErrorContributions,
187
- capabilities: ({ value }) => buildCapabilities(symbol, value)
204
+ emitContributions(ctx, coinContributions(symbol, value));
205
+ return value;
206
+ })
188
207
  });
189
208
  };
190
209
  /** User-facing factory namespace. Three variants — see file header for
@@ -196,6 +215,6 @@ const coin = {
196
215
  builtin
197
216
  };
198
217
  //#endregion
199
- export { coin, coinResourceId };
218
+ export { builtin, coin, coinResourceId, fromPackage };
200
219
 
201
220
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/plugins/coin/index.ts"],"sourcesContent":["// Coin plugin — barrel + `coin(...)` factory family.\n//\n// Architecture (13-coin.md): Coin is the user-facing primitive family\n// for *addressing* custom Move coin types. It does NOT publish Move\n// modules itself — the Package plugin publishes; coin auto-discovery\n// (in `discovery.ts`) folds the publish output into the per-stack\n// `CoinRegistry`; this factory resolves user-supplied addresses\n// (witness / bare-type / builtin) against that registry plus the live RPC.\n//\n// User-facing factory shape — three variants mirroring the address\n// forms:\n//\n// coin.fromPackage(pkg, 'MOCK_USDC') // package member → registry\n// coin.known('0x...::deep::DEEP') // bare → live RPC\n// coin.builtin('sui') // protocol-defined constant\n//\n// (A `coin(identifier)` convenience entry is intentionally NOT\n// exposed — distilled-doc 13-coin.md Pain point #6 documents how the\n// \"guess the form from the string\" path is a footgun. The three-form\n// surface forces the user to make the disambiguation explicit at the\n// call site.)\n//\n// Resource id: `'coin:<package>/<witness>'` for package-scoped coins and\n// `'coin:<identifier>'` for known/builtin coins — one tag per declared\n// coin instance, so the substrate's compose-time dedup detects collisions\n// cleanly. Mirrors the Package plugin's per-instance resource identity.\n\nimport { createHash } from 'node:crypto';\n\nimport { Effect } from 'effect';\n\nimport { definePlugin, resource, type ResourceRef } from '../../api/define-plugin.ts';\nimport { pluginErrorContributions } from '../../api/plugin-errors.ts';\nimport type { CodegenableDecl } from '../../contracts/codegenable.ts';\nimport type { SnapshotableDecl } from '../../contracts/snapshotable.ts';\nimport type { StrategyContributorDecl } from '../../contracts/strategy-contributor.ts';\nimport { ArtifactPublisherService } from '../../substrate/runtime/artifact-publisher/index.ts';\nimport { suiResource } from '../sui/index.ts';\nimport type { SuiClient } from '../sui/index.ts';\nimport type { AccountFundingStrategy } from '../../contracts/funding-strategy.ts';\n\nimport { makeCoinCodegen, type CoinBindings } from './codegen.ts';\nimport { makeCoinSnapshotable } from './snapshot.ts';\nimport { CoinRegistryService } from './registry.ts';\nimport { COIN_ERROR_TAGS } from './errors.ts';\nimport { acquireCoin, type CoinAddressForm, type CoinValue } from './service.ts';\nimport { BUILTIN_COINS } from './address-resolution.ts';\nimport type { MetadataSdkShim } from './metadata.ts';\nimport type { MintSdkShim } from './mint.ts';\n\nconst coinErrorContributions = pluginErrorContributions(COIN_ERROR_TAGS);\n\nexport const coinFundingCapabilityKey = <FullType extends string>(\n\tfullCoinType: FullType,\n): `coinType:${FullType}` => `coinType:${fullCoinType}` as const;\n\n// ---------------------------------------------------------------------------\n// Resource — one per declared coin instance, keyed by explicit address form.\n// ---------------------------------------------------------------------------\n\n/** Resource id constructor. The symbolic name is part of the resource identity\n * so the substrate's compose-time dedup catches collisions. */\nexport const coinResourceId = <Sym extends string>(symbol: Sym): `coin:${Sym}` => `coin:${symbol}`;\n\nexport type CoinResourceId<Sym extends string> = `coin:${Sym}`;\n\n/** Maximum length of the readable prefix in a `coin.known(...)` resource\n * id. Two long coin types sharing this prefix length would silently\n * collide in the substrate's compose-time dedup (string equality on\n * the resource id), so beyond this length we append a short hash of\n * the full coin type to disambiguate. */\nconst COIN_KNOWN_PREFIX_MAX = 60;\n\n/** Length of the SHA-256 hex suffix appended to long `coin.known(...)`\n * resource ids. Eight chars (~32 bits) is the same width used by other\n * collision-disambiguation hashes in the package (e.g. router profile,\n * fork preimage suffixes). */\nconst COIN_KNOWN_HASH_SUFFIX_LEN = 8;\n\n/** Derive a stable, human-readable, collision-free resource-id segment\n * for `coin.known(fullCoinType)`. Short types pass through as the\n * readable `<addr>_<module>_<witness>` form; long types get a hash\n * suffix so two types sharing a 60-char prefix can coexist. */\nconst coinKnownResourceKey = (fullCoinType: string): string => {\n\tconst readable = fullCoinType.replace(/^0x/, '').replace(/::/g, '_');\n\tif (readable.length <= COIN_KNOWN_PREFIX_MAX) {\n\t\treturn readable;\n\t}\n\tconst hash = createHash('sha256')\n\t\t.update(fullCoinType)\n\t\t.digest('hex')\n\t\t.slice(0, COIN_KNOWN_HASH_SUFFIX_LEN);\n\t// The readable prefix is truncated to leave room for the `_` divider\n\t// (`-1`) and the hash suffix (`-COIN_KNOWN_HASH_SUFFIX_LEN`), so the\n\t// resulting `<prefix>_<hash>` id has total length\n\t// ≤ COIN_KNOWN_PREFIX_MAX — bounded and deterministic per input.\n\treturn `${readable.slice(0, COIN_KNOWN_PREFIX_MAX - COIN_KNOWN_HASH_SUFFIX_LEN - 1)}_${hash}`;\n};\n\ntype PackageNameOf<Pkg extends PackageMember> =\n\tPkg extends ResourceRef<`package:${infer Name}`, PackageMemberValue> ? Name : string;\n\ntype PackageCoinResourceKey<\n\tPkg extends PackageMember,\n\tWit extends string,\n> = `${PackageNameOf<Pkg>}/${Lowercase<Wit>}`;\n\nconst packageNameFromMember = <Pkg extends PackageMember>(pkg: Pkg): PackageNameOf<Pkg> =>\n\tpkg.id.slice('package:'.length) as PackageNameOf<Pkg>;\n\n// ---------------------------------------------------------------------------\n// SDK shim projection\n// ---------------------------------------------------------------------------\n//\n// The coin plugin's resolvers need three Sui surfaces: `core.getObject`\n// (mint verify probe), `core.getCoinMetadata` (bare-type address form),\n// and the opaque `client` (`Transaction.build({client})` in the mint\n// produce body).\n//\n// `sui.sdk.core.getObject` lives on the typed `SuiSdkShim` directly;\n// `getCoinMetadata` lives on the underlying `ClientWithCoreApi['core']`\n// reached via `sui.sdk.client.core`. Project both onto the combined\n// `MetadataSdkShim & MintSdkShim` here at the boundary.\n\nconst projectCoinSdk = (sui: SuiClient): MetadataSdkShim & MintSdkShim => ({\n\tcore: {\n\t\tgetObject: sui.sdk.core.getObject,\n\t\tgetCoinMetadata: (args) => sui.sdk.client.core.getCoinMetadata(args),\n\t\tlistCoins: sui.sdk.core.listCoins,\n\t},\n\tclient: sui.sdk.client,\n\t// Fork mode mints offline with explicit gas (sui-fork has no simulate).\n\tforkMode: sui.fork !== null,\n});\n\n// ---------------------------------------------------------------------------\n// Per-form capability builders — dynamic (POST-acquire). Receive the\n// resolved `CoinValue` so codegen bindings stamp the REAL fullCoinType\n// + decimals instead of placeholder values.\n// ---------------------------------------------------------------------------\n\nconst buildCapabilities = (symbol: string, resolved: CoinValue) => {\n\tconst bindings: CoinBindings = {\n\t\tsymbol: resolved.symbol ?? symbol,\n\t\tfullCoinType: resolved.fullCoinType,\n\t\tdecimals: resolved.decimals,\n\t\tsource: resolved.source,\n\t\t...(resolved.displayName !== undefined ? { displayName: resolved.displayName } : {}),\n\t\t...(resolved.iconUrl !== undefined ? { iconUrl: resolved.iconUrl } : {}),\n\t\t...(resolved.treasuryCapId !== undefined ? { treasuryCapId: resolved.treasuryCapId } : {}),\n\t\t...(resolved.metadataId !== undefined ? { metadataId: resolved.metadataId } : {}),\n\t\t...(resolved.packageId !== undefined ? { packageId: resolved.packageId } : {}),\n\t};\n\tconst snap: SnapshotableDecl = makeCoinSnapshotable({ symbol });\n\tconst codegen: CodegenableDecl<`coin/${string}`> = makeCoinCodegen({\n\t\tsymbol,\n\t\tresolved: bindings,\n\t});\n\t// Project the coin's narrow `{address, amount}`-shaped strategy\n\t// to the wider cross-plugin `AccountFundingStrategy` contract\n\t// (`{address, amount, account}`) at the capability boundary. The\n\t// coin publisher signs the mint via its own lease (see\n\t// `coin/service.ts → mint`), so `account` is dropped honestly\n\t// here — the type-level contract is satisfied structurally\n\t// without a misleading `as` cast on the contribution literal.\n\t// Direct consumers (e.g. deepbook seed funding) keep using the\n\t// narrow shape on `CoinValue.fundingStrategy` directly.\n\tconst narrowStrategy = resolved.fundingStrategy;\n\tconst fundingContribution =\n\t\tnarrowStrategy === undefined\n\t\t\t? []\n\t\t\t: [\n\t\t\t\t\t{\n\t\t\t\t\t\tkind: 'strategy-contributor',\n\t\t\t\t\t\tcapabilityKey: coinFundingCapabilityKey(resolved.fullCoinType),\n\t\t\t\t\t\tstrategy: {\n\t\t\t\t\t\t\t// usesAccountSigner: true — the coin strategy mints via\n\t\t\t\t\t\t\t// the publisher account's own `withTransactionSigner`,\n\t\t\t\t\t\t\t// which acquires the per-address lease\n\t\t\t\t\t\t\t// `account:<publisherAddress>` internally (service.ts\n\t\t\t\t\t\t\t// mint -> performMint -> signAndDispatch). The account\n\t\t\t\t\t\t\t// funding dispatcher must therefore NOT wrap the request\n\t\t\t\t\t\t\t// in its own `account:<fundedAddress>` lease. Two reasons:\n\t\t\t\t\t\t\t// 1. The funded account is a passive `recipient` in\n\t\t\t\t\t\t\t// `mint_and_transfer` — it neither signs nor\n\t\t\t\t\t\t\t// contributes objects, so the funded-address lease\n\t\t\t\t\t\t\t// serializes nothing; the publisher lease already\n\t\t\t\t\t\t\t// serializes the only account whose gas + treasury\n\t\t\t\t\t\t\t// cap the mint consumes.\n\t\t\t\t\t\t\t// 2. When the funded address IS the publisher address\n\t\t\t\t\t\t\t// (fund a publisher with a coin it published), the\n\t\t\t\t\t\t\t// dispatcher's `account:<funded>` lease and the\n\t\t\t\t\t\t\t// mint's `account:<publisher>` lease collapse to the\n\t\t\t\t\t\t\t// same non-reentrant key, so the inner acquire would\n\t\t\t\t\t\t\t// block forever. Owning the lease inside the strategy\n\t\t\t\t\t\t\t// (signalled by this flag) makes self-funding\n\t\t\t\t\t\t\t// single-acquire and deadlock-free while leaving the\n\t\t\t\t\t\t\t// cross-account path's mint + publisher lease\n\t\t\t\t\t\t\t// unchanged.\n\t\t\t\t\t\t\t// Mirrors deepbook's DEEP strategy (faucet-strategy.ts),\n\t\t\t\t\t\t\t// which sets the same flag and self-acquires via\n\t\t\t\t\t\t\t// `req.account.withTransactionSigner`.\n\t\t\t\t\t\t\tusesAccountSigner: true,\n\t\t\t\t\t\t\trequest: (req) =>\n\t\t\t\t\t\t\t\tnarrowStrategy.request({ address: req.address, amount: req.amount }),\n\t\t\t\t\t\t} satisfies AccountFundingStrategy,\n\t\t\t\t\t\tautoMounted: true,\n\t\t\t\t\t} satisfies StrategyContributorDecl<`coinType:${string}`, AccountFundingStrategy>,\n\t\t\t\t];\n\treturn [snap, codegen, ...fundingContribution] as const;\n};\n\n// ---------------------------------------------------------------------------\n// Form 1: coin.fromPackage(pkg, witness) — package-scoped registry lookup\n// ---------------------------------------------------------------------------\n\n/** A user-supplied package ref. The user passes the result of\n * `localPackage('foo', …)` / `knownPackage('foo', …)` — NOT a bare string\n * value. Generic over the literal package name so the witness-form\n * coin's dependency preserves the per-package resource id. */\nexport interface PackageMemberValue {\n\treadonly name: string;\n\treadonly packageId: string;\n\treadonly publisher?: import('./mint.ts').MintSigner;\n}\n\nexport type PackageMember<Name extends string = string> = ResourceRef<\n\t`package:${Name}`,\n\tPackageMemberValue\n>;\n\n/** Resolve a coin by `(publishing package member, witness)`. Forces\n * a dep edge on the publishing package's resource — the substrate ensures\n * the publish has completed before this resolves.\n *\n * Resource identity includes both the package's symbolic name and the\n * witness name, so two packages can expose the same witness without\n * colliding in the substrate graph.\n *\n * Pass the package MEMBER (the value returned by `localPackage(...)`\n * / `knownPackage(...)`). The factory\n * projects it to a dependency resource and receives the package value\n * in `start`. */\nexport const fromPackage = <const Pkg extends PackageMember, Wit extends string>(\n\tpkg: Pkg,\n\twitnessName: Wit,\n) => {\n\tconst packageName = packageNameFromMember(pkg);\n\tconst symbol = witnessName.toLowerCase() as Lowercase<Wit>;\n\tconst resourceKey = `${packageName}/${symbol}` as PackageCoinResourceKey<Pkg, Wit>;\n\tconst coinRef = resource<CoinResourceId<typeof resourceKey>, CoinValue>(\n\t\tcoinResourceId(resourceKey),\n\t);\n\treturn definePlugin({\n\t\tid: coinRef.id,\n\t\tdependsOn: { pkg, sui: suiResource },\n\t\trole: 'task',\n\t\t// Coin lifecycle is action-shaped — uses the action section bucket;\n\t\t// see substrate/projection.ts `RowSection` for the canonical list.\n\t\t// All three coin factories (`fromPackage` / `known` / `builtin`)\n\t\t// share this deliberate bucketing; promoting to a dedicated\n\t\t// `'coin'` section would ripple through every projection / TUI\n\t\t// consumer for marginal display value.\n\t\tsection: 'action',\n\t\tstart: ({ pkg: resolved, sui }) =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst artifactPublisher = yield* ArtifactPublisherService;\n\t\t\t\tconst registry = yield* CoinRegistryService;\n\t\t\t\tconst form: CoinAddressForm = {\n\t\t\t\t\tkind: 'witness',\n\t\t\t\t\tpublishingPackageName: resolved.name,\n\t\t\t\t\twitness: witnessName,\n\t\t\t\t\t...(resolved.publisher === undefined ? {} : { fundingSigner: resolved.publisher }),\n\t\t\t\t};\n\t\t\t\treturn yield* acquireCoin(form, {\n\t\t\t\t\tregistry,\n\t\t\t\t\tsdk: projectCoinSdk(sui),\n\t\t\t\t\tchain: sui.chain,\n\t\t\t\t\tpublisher: artifactPublisher,\n\t\t\t\t});\n\t\t\t}),\n\t\terrorContributions: coinErrorContributions,\n\t\tcapabilities: ({ value }) => buildCapabilities(symbol, value),\n\t});\n};\n\n// ---------------------------------------------------------------------------\n// Form 2: coin.known(fullCoinType) — bare on-chain type\n// ---------------------------------------------------------------------------\n\n/** Resolve a coin by bare on-chain type via `getCoinMetadata`.\n * Used for live-net coins (mainnet DEEP, USDC etc.) that no local\n * `Package(...)` publishes.\n *\n * Soft-degrades to `decimals: 0` on RPC failure — distilled-doc\n * invariant. Resource id uses a deterministic-but-readable derivation of\n * the coin type so collisions surface at compose time. */\nexport const known = <FullType extends string>(fullCoinType: FullType) => {\n\t// Derive a resource id from the type: keep it readable but unique.\n\t// The substrate's compose-time dedup uses string equality on the id,\n\t// so two long coin types that share a 60-char prefix MUST NOT collide.\n\t// When the projection truncates, append a short hash of the FULL coin\n\t// type so the suffix disambiguates the two — the readable prefix\n\t// stays human-recognizable while the hash guarantees uniqueness.\n\tconst id = coinKnownResourceKey(fullCoinType);\n\tconst coinRef = resource<CoinResourceId<typeof id>, CoinValue>(\n\t\tcoinResourceId(id) as CoinResourceId<typeof id>,\n\t);\n\treturn definePlugin({\n\t\tid: coinRef.id,\n\t\tdependsOn: { sui: suiResource },\n\t\trole: 'task',\n\t\tsection: 'action',\n\t\tstart: ({ sui }) =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst publisher = yield* ArtifactPublisherService;\n\t\t\t\tconst registry = yield* CoinRegistryService;\n\t\t\t\tconst form: CoinAddressForm = { kind: 'known', fullCoinType };\n\t\t\t\treturn yield* acquireCoin(form, {\n\t\t\t\t\tregistry,\n\t\t\t\t\tsdk: projectCoinSdk(sui),\n\t\t\t\t\tchain: sui.chain,\n\t\t\t\t\tpublisher,\n\t\t\t\t});\n\t\t\t}),\n\t\terrorContributions: coinErrorContributions,\n\t\tcapabilities: ({ value }) => buildCapabilities(id, value),\n\t});\n};\n\n// ---------------------------------------------------------------------------\n// Form 3: coin.builtin('sui') — protocol-defined constant\n// ---------------------------------------------------------------------------\n\n/** Resolve a protocol-defined builtin coin. Currently `'sui'` only —\n * distilled-doc 13-coin.md Invariant 4: SUI is `0x2::sui::SUI`,\n * decimals=9. No RPC, no registry. */\nexport const builtin = <Name extends keyof typeof BUILTIN_COINS>(name: Name) => {\n\tconst symbol = name; // 'sui' today\n\tconst coinRef = resource<CoinResourceId<Name>, CoinValue>(coinResourceId(name));\n\treturn definePlugin({\n\t\tid: coinRef.id,\n\t\tdependsOn: { sui: suiResource },\n\t\trole: 'task',\n\t\tsection: 'action',\n\t\tstart: ({ sui }) =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst publisher = yield* ArtifactPublisherService;\n\t\t\t\tconst registry = yield* CoinRegistryService;\n\t\t\t\tconst form: CoinAddressForm = { kind: 'builtin', name };\n\t\t\t\treturn yield* acquireCoin(form, {\n\t\t\t\t\tregistry,\n\t\t\t\t\tsdk: projectCoinSdk(sui),\n\t\t\t\t\tchain: sui.chain,\n\t\t\t\t\tpublisher,\n\t\t\t\t});\n\t\t\t}),\n\t\terrorContributions: coinErrorContributions,\n\t\tcapabilities: ({ value }) => buildCapabilities(symbol, value),\n\t});\n};\n\n// ---------------------------------------------------------------------------\n// Public `coin` namespace\n// ---------------------------------------------------------------------------\n\n/** User-facing factory namespace. Three variants — see file header for\n * the rationale on not exposing a `coin(identifier)` form-guessing\n * entry. */\nexport const coin = {\n\tfromPackage,\n\tknown,\n\tbuiltin,\n} as const;\n\n// ---------------------------------------------------------------------------\n// Re-exports — advanced callers (Wallet, Faucet, Deepbook, examples)\n// ---------------------------------------------------------------------------\n\nexport type { CoinValue, CoinAddressForm } from './service.ts';\nexport type { ResolvedCoin, BuiltinCoinName } from './address-resolution.ts';\nexport { BUILTIN_COINS } from './address-resolution.ts';\n\nexport type { CoinRecord, CoinRegistry, CoinKey } from './registry.ts';\nexport { CoinRegistryService, layerCoinRegistry } from './registry.ts';\n\nexport type { CoinBindings } from './codegen.ts';\n\nexport type { DiscoveredCoin } from './discovery.ts';\nexport { discoverCoinsFromPublish } from './discovery.ts';\n\nexport type { MetadataSdkShim, OnchainCoinMetadata, CoinMetadataCache } from './metadata.ts';\nexport {\n\tOnchainCoinMetadataShape,\n\tMETADATA_FETCH_TIMEOUT_MS,\n\tMETADATA_RETRY_SCHEDULE,\n\tfetchCoinMetadataOnce,\n\tfetchCoinMetadataMany,\n\tmakeCoinMetadataCache,\n\tisBareCoinType,\n\tvalidateBareCoinType,\n} from './metadata.ts';\n\nexport type { MintInputs, MintResult, MintSigner, MintSdkShim, CachedMint } from './mint.ts';\nexport { performMint, MintedCoinVerifyShape, mintTxError, mintParseError } from './mint.ts';\n\nexport type { CoinError, CoinPhase } from './errors.ts';\nexport { coinError, COIN_ERROR_TAGS } from './errors.ts';\n\nexport { CoinSpans } from './spans.ts';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkDA,MAAM,yBAAyB,yBAAyB,gBAAgB;AAExE,MAAa,4BACZ,iBAC4B,YAAY;;;AAQzC,MAAa,kBAAsC,WAA+B,QAAQ;;;;;;AAS1F,MAAM,wBAAwB;;;;;AAM9B,MAAM,6BAA6B;;;;;AAMnC,MAAM,wBAAwB,iBAAiC;CAC9D,MAAM,WAAW,aAAa,QAAQ,OAAO,GAAG,CAAC,QAAQ,OAAO,IAAI;AACpE,KAAI,SAAS,UAAU,sBACtB,QAAO;CAER,MAAM,OAAO,WAAW,SAAS,CAC/B,OAAO,aAAa,CACpB,OAAO,MAAM,CACb,MAAM,GAAG,2BAA2B;AAKtC,QAAO,GAAG,SAAS,MAAM,GAAG,wBAAwB,6BAA6B,EAAE,CAAC,GAAG;;AAWxF,MAAM,yBAAoD,QACzD,IAAI,GAAG,MAAM,EAAkB;AAgBhC,MAAM,kBAAkB,SAAmD;CAC1E,MAAM;EACL,WAAW,IAAI,IAAI,KAAK;EACxB,kBAAkB,SAAS,IAAI,IAAI,OAAO,KAAK,gBAAgB,KAAK;EACpE,WAAW,IAAI,IAAI,KAAK;EACxB;CACD,QAAQ,IAAI,IAAI;CAEhB,UAAU,IAAI,SAAS;CACvB;AAQD,MAAM,qBA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AAa,OAAO;CACnB;CACA;CACA;CACA"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/plugins/coin/index.ts"],"sourcesContent":["// Coin plugin — barrel + `coin(...)` factory family.\n//\n// Architecture (13-coin.md): Coin is the user-facing primitive family\n// for *addressing* custom Move coin types. It does NOT publish Move\n// modules itself — the Package plugin publishes; coin auto-discovery\n// (in `discovery.ts`) folds the publish output into the per-stack\n// `CoinRegistry`; this factory resolves user-supplied addresses\n// (witness / bare-type / builtin) against that registry plus the live RPC.\n//\n// User-facing factory shape — three variants mirroring the address\n// forms:\n//\n// coin.fromPackage(pkg, 'MOCK_USDC') // package member → registry\n// coin.known('0x...::deep::DEEP') // bare → live RPC\n// coin.builtin('sui') // protocol-defined constant\n//\n// (A `coin(identifier)` convenience entry is intentionally NOT\n// exposed — distilled-doc 13-coin.md Pain point #6 documents how the\n// \"guess the form from the string\" path is a footgun. The three-form\n// surface forces the user to make the disambiguation explicit at the\n// call site.)\n//\n// Resource id: `'coin:<package>/<witness>'` for package-scoped coins and\n// `'coin:<identifier>'` for known/builtin coins — one tag per declared\n// coin instance, so the substrate's compose-time dedup detects collisions\n// cleanly. Mirrors the Package plugin's per-instance resource identity.\n\nimport { createHash } from 'node:crypto';\n\nimport { Effect } from 'effect';\n\nimport { definePlugin, resource, type ResourceRef } from '../../api/define-plugin.ts';\nimport type { CodegenableDecl } from '../../contracts/codegenable.ts';\nimport type { SnapshotableDecl } from '../../contracts/snapshotable.ts';\nimport type { StrategyContributorDecl } from '../../contracts/strategy-contributor.ts';\nimport type { Contribution } from '../../substrate/plugin-ctx.ts';\nimport { emitContributions, PluginContext } from '../../substrate/plugin-ctx.ts';\nimport { CacheService } from '../../substrate/runtime/cache/index.ts';\nimport { suiResource } from '../sui/index.ts';\nimport type { SuiClient } from '../sui/index.ts';\nimport type { AccountFundingStrategy } from '../../contracts/funding-strategy.ts';\n\nimport { makeCoinCodegen, makeCoinStaticCodegen, type CoinBindings } from './codegen.ts';\nimport { makeCoinSnapshotable } from './snapshot.ts';\nimport { CoinRegistryService } from './registry.ts';\nimport { acquireCoin, type CoinAddressForm, type CoinValue } from './service.ts';\nimport { BUILTIN_COINS } from './address-resolution.ts';\nimport type { MetadataSdkShim } from './metadata.ts';\nimport type { MintSdkShim } from './mint.ts';\n\nexport const coinFundingCapabilityKey = <FullType extends string>(\n\tfullCoinType: FullType,\n): `coinType:${FullType}` => `coinType:${fullCoinType}` as const;\n\n// ---------------------------------------------------------------------------\n// Resource — one per declared coin instance, keyed by explicit address form.\n// ---------------------------------------------------------------------------\n\n/** Resource id constructor. The symbolic name is part of the resource identity\n * so the substrate's compose-time dedup catches collisions. */\nexport const coinResourceId = <Sym extends string>(symbol: Sym): `coin:${Sym}` => `coin:${symbol}`;\n\nexport type CoinResourceId<Sym extends string> = `coin:${Sym}`;\n\n/** Maximum length of the readable prefix in a `coin.known(...)` resource\n * id. Two long coin types sharing this prefix length would silently\n * collide in the substrate's compose-time dedup (string equality on\n * the resource id), so beyond this length we append a short hash of\n * the full coin type to disambiguate. */\nconst COIN_KNOWN_PREFIX_MAX = 60;\n\n/** Length of the SHA-256 hex suffix appended to long `coin.known(...)`\n * resource ids. Eight chars (~32 bits) is the same width used by other\n * collision-disambiguation hashes in the package (e.g. router profile,\n * fork preimage suffixes). */\nconst COIN_KNOWN_HASH_SUFFIX_LEN = 8;\n\n/** Derive a stable, human-readable, collision-free resource-id segment\n * for `coin.known(fullCoinType)`. Short types pass through as the\n * readable `<addr>_<module>_<witness>` form; long types get a hash\n * suffix so two types sharing a 60-char prefix can coexist. */\nconst coinKnownResourceKey = (fullCoinType: string): string => {\n\tconst readable = fullCoinType.replace(/^0x/, '').replace(/::/g, '_');\n\tif (readable.length <= COIN_KNOWN_PREFIX_MAX) {\n\t\treturn readable;\n\t}\n\tconst hash = createHash('sha256')\n\t\t.update(fullCoinType)\n\t\t.digest('hex')\n\t\t.slice(0, COIN_KNOWN_HASH_SUFFIX_LEN);\n\t// The readable prefix is truncated to leave room for the `_` divider\n\t// (`-1`) and the hash suffix (`-COIN_KNOWN_HASH_SUFFIX_LEN`), so the\n\t// resulting `<prefix>_<hash>` id has total length\n\t// ≤ COIN_KNOWN_PREFIX_MAX — bounded and deterministic per input.\n\treturn `${readable.slice(0, COIN_KNOWN_PREFIX_MAX - COIN_KNOWN_HASH_SUFFIX_LEN - 1)}_${hash}`;\n};\n\ntype PackageNameOf<Pkg extends PackageMember> =\n\tPkg extends ResourceRef<`package:${infer Name}`, PackageMemberValue> ? Name : string;\n\ntype PackageCoinResourceKey<\n\tPkg extends PackageMember,\n\tWit extends string,\n> = `${PackageNameOf<Pkg>}/${Lowercase<Wit>}`;\n\nconst packageNameFromMember = <Pkg extends PackageMember>(pkg: Pkg): PackageNameOf<Pkg> =>\n\tpkg.id.slice('package:'.length) as PackageNameOf<Pkg>;\n\n// ---------------------------------------------------------------------------\n// SDK shim projection\n// ---------------------------------------------------------------------------\n//\n// The coin plugin's resolvers need three Sui surfaces: `core.getObject`\n// (mint verify probe), `core.getCoinMetadata` (bare-type address form),\n// and the opaque `client` (`Transaction.build({client})` in the mint\n// produce body).\n//\n// `sui.sdk.core.getObject` lives on the typed `SuiSdkShim` directly;\n// `getCoinMetadata` lives on the underlying `ClientWithCoreApi['core']`\n// reached via `sui.sdk.client.core`. Project both onto the combined\n// `MetadataSdkShim & MintSdkShim` here at the boundary.\n\nconst projectCoinSdk = (sui: SuiClient): MetadataSdkShim & MintSdkShim => ({\n\tcore: {\n\t\tgetObject: sui.sdk.core.getObject,\n\t\tgetCoinMetadata: (args) => sui.sdk.client.core.getCoinMetadata(args),\n\t\tlistCoins: sui.sdk.core.listCoins,\n\t},\n\tclient: sui.sdk.client,\n\t// Fork mode mints offline with explicit gas (sui-fork has no simulate).\n\tforkMode: sui.fork !== null,\n});\n\n// ---------------------------------------------------------------------------\n// Per-form contribution decls — dynamic (POST-acquire). Receive the\n// resolved `CoinValue` so codegen bindings stamp the REAL fullCoinType\n// + decimals instead of placeholder values.\n//\n// `coinContributions` is a PURE decl-builder (NOT a routing wrapper): the\n// three coin `start` bodies feed its return into the shared\n// `emitContributions(ctx, …)`, which routes each decl by `kind`. Shared by\n// all three forms so the rich funding-strategy projection below lives once.\n// Decl shapes + ORDER are load-bearing.\n//\n// Exported for the funding-strategy decl-shape test: it feeds a hand-built\n// resolved `CoinValue` here and asserts the projected `strategy-contributor`\n// decl via `emitContributions` against a capturing ctx.\n// ---------------------------------------------------------------------------\n\nexport const coinContributions = (\n\tsymbol: string,\n\tresolved: CoinValue,\n): ReadonlyArray<Contribution> => {\n\tconst bindings: CoinBindings = {\n\t\tsymbol: resolved.symbol ?? symbol,\n\t\tfullCoinType: resolved.fullCoinType,\n\t\tdecimals: resolved.decimals,\n\t\tsource: resolved.source,\n\t\t...(resolved.displayName !== undefined ? { displayName: resolved.displayName } : {}),\n\t\t...(resolved.iconUrl !== undefined ? { iconUrl: resolved.iconUrl } : {}),\n\t\t...(resolved.treasuryCapId !== undefined ? { treasuryCapId: resolved.treasuryCapId } : {}),\n\t\t...(resolved.metadataId !== undefined ? { metadataId: resolved.metadataId } : {}),\n\t\t...(resolved.packageId !== undefined ? { packageId: resolved.packageId } : {}),\n\t};\n\tconst snap: SnapshotableDecl = makeCoinSnapshotable({ symbol });\n\tconst codegen: CodegenableDecl = makeCoinCodegen({\n\t\tsymbol,\n\t\tresolved: bindings,\n\t});\n\t// Project the coin's narrow `{address, amount}`-shaped strategy\n\t// to the wider cross-plugin `AccountFundingStrategy` contract\n\t// (`{address, amount, account}`) at the capability boundary. The\n\t// coin publisher signs the mint via its own lease (see\n\t// `coin/service.ts → mint`), so `account` is dropped honestly\n\t// here — the type-level contract is satisfied structurally\n\t// without a misleading `as` cast on the contribution literal.\n\t// Direct consumers (e.g. deepbook seed funding) keep using the\n\t// narrow shape on `CoinValue.fundingStrategy` directly.\n\tconst narrowStrategy = resolved.fundingStrategy;\n\tconst fundingContribution =\n\t\tnarrowStrategy === undefined\n\t\t\t? []\n\t\t\t: [\n\t\t\t\t\t{\n\t\t\t\t\t\tkind: 'strategy-contributor',\n\t\t\t\t\t\tcapabilityKey: coinFundingCapabilityKey(resolved.fullCoinType),\n\t\t\t\t\t\tstrategy: {\n\t\t\t\t\t\t\t// usesAccountSigner: true — the coin strategy mints via\n\t\t\t\t\t\t\t// the publisher account's own `withTransactionSigner`,\n\t\t\t\t\t\t\t// which acquires the per-address lease\n\t\t\t\t\t\t\t// `account:<publisherAddress>` internally (service.ts\n\t\t\t\t\t\t\t// mint -> performMint -> signAndDispatch). The account\n\t\t\t\t\t\t\t// funding dispatcher must therefore NOT wrap the request\n\t\t\t\t\t\t\t// in its own `account:<fundedAddress>` lease. Two reasons:\n\t\t\t\t\t\t\t// 1. The funded account is a passive `recipient` in\n\t\t\t\t\t\t\t// `mint_and_transfer` — it neither signs nor\n\t\t\t\t\t\t\t// contributes objects, so the funded-address lease\n\t\t\t\t\t\t\t// serializes nothing; the publisher lease already\n\t\t\t\t\t\t\t// serializes the only account whose gas + treasury\n\t\t\t\t\t\t\t// cap the mint consumes.\n\t\t\t\t\t\t\t// 2. When the funded address IS the publisher address\n\t\t\t\t\t\t\t// (fund a publisher with a coin it published), the\n\t\t\t\t\t\t\t// dispatcher's `account:<funded>` lease and the\n\t\t\t\t\t\t\t// mint's `account:<publisher>` lease collapse to the\n\t\t\t\t\t\t\t// same non-reentrant key, so the inner acquire would\n\t\t\t\t\t\t\t// block forever. Owning the lease inside the strategy\n\t\t\t\t\t\t\t// (signalled by this flag) makes self-funding\n\t\t\t\t\t\t\t// single-acquire and deadlock-free while leaving the\n\t\t\t\t\t\t\t// cross-account path's mint + publisher lease\n\t\t\t\t\t\t\t// unchanged.\n\t\t\t\t\t\t\t// Mirrors deepbook's DEEP strategy (faucet-strategy.ts),\n\t\t\t\t\t\t\t// which sets the same flag and self-acquires via\n\t\t\t\t\t\t\t// `req.account.withTransactionSigner`.\n\t\t\t\t\t\t\tusesAccountSigner: true,\n\t\t\t\t\t\t\trequest: (req) =>\n\t\t\t\t\t\t\t\tnarrowStrategy.request({ address: req.address, amount: req.amount }),\n\t\t\t\t\t\t} satisfies AccountFundingStrategy,\n\t\t\t\t\t\tautoMounted: true,\n\t\t\t\t\t} satisfies StrategyContributorDecl<`coinType:${string}`, AccountFundingStrategy>,\n\t\t\t\t];\n\treturn [snap, codegen, ...fundingContribution];\n};\n\n// ---------------------------------------------------------------------------\n// Form 1: coin.fromPackage(pkg, witness) — package-scoped registry lookup\n// ---------------------------------------------------------------------------\n\n/** A user-supplied package ref. The user passes the result of\n * `localPackage('foo', …)` / `knownPackage('foo', …)` — NOT a bare string\n * value. Generic over the literal package name so the witness-form\n * coin's dependency preserves the per-package resource id. */\nexport interface PackageMemberValue {\n\treadonly name: string;\n\treadonly packageId: string;\n\treadonly publisher?: import('./mint.ts').MintSigner;\n}\n\nexport type PackageMember<Name extends string = string> = ResourceRef<\n\t`package:${Name}`,\n\tPackageMemberValue\n>;\n\n/** Resolve a coin by `(publishing package member, witness)`. Forces\n * a dep edge on the publishing package's resource — the substrate ensures\n * the publish has completed before this resolves.\n *\n * Resource identity includes both the package's symbolic name and the\n * witness name, so two packages can expose the same witness without\n * colliding in the substrate graph.\n *\n * Pass the package MEMBER (the value returned by `localPackage(...)`\n * / `knownPackage(...)`). The factory\n * projects it to a dependency resource and receives the package value\n * in `start`. */\nexport const fromPackage = <const Pkg extends PackageMember, Wit extends string>(\n\tpkg: Pkg,\n\twitnessName: Wit,\n) => {\n\tconst packageName = packageNameFromMember(pkg);\n\tconst symbol = witnessName.toLowerCase() as Lowercase<Wit>;\n\tconst resourceKey = `${packageName}/${symbol}` as PackageCoinResourceKey<Pkg, Wit>;\n\tconst coinRef = resource<CoinResourceId<typeof resourceKey>, CoinValue>(\n\t\tcoinResourceId(resourceKey),\n\t);\n\treturn definePlugin({\n\t\tid: coinRef.id,\n\t\tdependsOn: { pkg, sui: suiResource },\n\t\trole: 'task',\n\t\t// Coin lifecycle is action-shaped — uses the action section bucket;\n\t\t// see substrate/projection.ts `RowSection` for the canonical list.\n\t\t// All three coin factories (`fromPackage` / `known` / `builtin`)\n\t\t// share this deliberate bucketing; promoting to a dedicated\n\t\t// `'coin'` section would ripple through every projection / TUI\n\t\t// consumer for marginal display value.\n\t\tsection: 'action',\n\t\t// Stack-free codegen: a package coin's type / decimals / package id\n\t\t// are LOADED CONFIG DATA -- the committed stub emits\n\t\t// `resolveValue('coin:<symbol>', '<key>')`, never a baked coin type.\n\t\tstaticCodegen: () => [makeCoinStaticCodegen({ symbol, source: 'registry' })],\n\t\t// `deps` auto-infers the resolved `{ pkg, sui }` dependency object;\n\t\t// `ctx` arrives via the `PluginContext` service.\n\t\tstart: ({ pkg: resolved, sui }) =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst ctx = yield* PluginContext;\n\t\t\t\tconst artifactPublisher = yield* CacheService;\n\t\t\t\tconst registry = yield* CoinRegistryService;\n\t\t\t\tconst form: CoinAddressForm = {\n\t\t\t\t\tkind: 'witness',\n\t\t\t\t\tpublishingPackageName: resolved.name,\n\t\t\t\t\twitness: witnessName,\n\t\t\t\t\t...(resolved.publisher === undefined ? {} : { fundingSigner: resolved.publisher }),\n\t\t\t\t};\n\t\t\t\tconst value = yield* acquireCoin(form, {\n\t\t\t\t\tregistry,\n\t\t\t\t\tsdk: projectCoinSdk(sui),\n\t\t\t\t\tchainId: sui.chainId,\n\t\t\t\t\tpublisher: artifactPublisher,\n\t\t\t\t});\n\t\t\t\t// Emit the resolved coin's contributions inline. `value` is the\n\t\t\t\t// just-resolved `CoinValue`; `symbol` is the package-scoped\n\t\t\t\t// witness symbol in scope.\n\t\t\t\temitContributions(ctx, coinContributions(symbol, value));\n\t\t\t\treturn value;\n\t\t\t}),\n\t});\n};\n\n// ---------------------------------------------------------------------------\n// Form 2: coin.known(fullCoinType) — bare on-chain type\n// ---------------------------------------------------------------------------\n\n/** Resolve a coin by bare on-chain type via `getCoinMetadata`.\n * Used for live-net coins (mainnet DEEP, USDC etc.) that no local\n * `Package(...)` publishes.\n *\n * Soft-degrades to `decimals: 0` on RPC failure — distilled-doc\n * invariant. Resource id uses a deterministic-but-readable derivation of\n * the coin type so collisions surface at compose time. */\nexport const known = <FullType extends string>(fullCoinType: FullType) => {\n\t// Derive a resource id from the type: keep it readable but unique.\n\t// The substrate's compose-time dedup uses string equality on the id,\n\t// so two long coin types that share a 60-char prefix MUST NOT collide.\n\t// When the projection truncates, append a short hash of the FULL coin\n\t// type so the suffix disambiguates the two — the readable prefix\n\t// stays human-recognizable while the hash guarantees uniqueness.\n\tconst id = coinKnownResourceKey(fullCoinType);\n\tconst coinRef = resource<CoinResourceId<typeof id>, CoinValue>(\n\t\tcoinResourceId(id) as CoinResourceId<typeof id>,\n\t);\n\treturn definePlugin({\n\t\tid: coinRef.id,\n\t\tdependsOn: { sui: suiResource },\n\t\trole: 'task',\n\t\tsection: 'action',\n\t\t// Stack-free codegen: the caller DECLARED this on-chain coin type, so\n\t\t// the committed stub bakes `fullCoinType` as a LITERAL; `decimals` /\n\t\t// `packageId` still resolve at app build/dev time (they come from\n\t\t// `getCoinMetadata`, only known after a live probe).\n\t\tstaticCodegen: () => [\n\t\t\tmakeCoinStaticCodegen({ symbol: id, source: 'on-chain', knownCoinType: fullCoinType }),\n\t\t],\n\t\tstart: ({ sui }) =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst ctx = yield* PluginContext;\n\t\t\t\tconst publisher = yield* CacheService;\n\t\t\t\tconst registry = yield* CoinRegistryService;\n\t\t\t\tconst form: CoinAddressForm = { kind: 'known', fullCoinType };\n\t\t\t\tconst value = yield* acquireCoin(form, {\n\t\t\t\t\tregistry,\n\t\t\t\t\tsdk: projectCoinSdk(sui),\n\t\t\t\t\tchainId: sui.chainId,\n\t\t\t\t\tpublisher,\n\t\t\t\t});\n\t\t\t\t// Emit inline. `value` is the resolved `CoinValue`; `id` is the\n\t\t\t\t// derived `coin.known` resource key.\n\t\t\t\temitContributions(ctx, coinContributions(id, value));\n\t\t\t\treturn value;\n\t\t\t}),\n\t});\n};\n\n// ---------------------------------------------------------------------------\n// Form 3: coin.builtin('sui') — protocol-defined constant\n// ---------------------------------------------------------------------------\n\n/** Resolve a protocol-defined builtin coin. Currently `'sui'` only —\n * distilled-doc 13-coin.md Invariant 4: SUI is `0x2::sui::SUI`,\n * decimals=9. No RPC, no registry. */\nexport const builtin = <Name extends keyof typeof BUILTIN_COINS>(name: Name) => {\n\tconst symbol = name; // 'sui' today\n\tconst coinRef = resource<CoinResourceId<Name>, CoinValue>(coinResourceId(name));\n\treturn definePlugin({\n\t\tid: coinRef.id,\n\t\tdependsOn: { sui: suiResource },\n\t\trole: 'task',\n\t\tsection: 'action',\n\t\t// Stack-free codegen: a builtin coin (SUI) is protocol-defined --\n\t\t// its coin type + decimals are constants baked as LITERALS (no\n\t\t// `resolveValue` that would throw at module load for a coin with no\n\t\t// injected id).\n\t\tstaticCodegen: () => [\n\t\t\tmakeCoinStaticCodegen({\n\t\t\t\tsymbol,\n\t\t\t\tsource: 'builtin',\n\t\t\t\tconstants: {\n\t\t\t\t\tfullCoinType: BUILTIN_COINS[name].fullCoinType,\n\t\t\t\t\tdecimals: BUILTIN_COINS[name].decimals,\n\t\t\t\t},\n\t\t\t}),\n\t\t],\n\t\tstart: ({ sui }) =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst ctx = yield* PluginContext;\n\t\t\t\tconst publisher = yield* CacheService;\n\t\t\t\tconst registry = yield* CoinRegistryService;\n\t\t\t\tconst form: CoinAddressForm = { kind: 'builtin', name };\n\t\t\t\tconst value = yield* acquireCoin(form, {\n\t\t\t\t\tregistry,\n\t\t\t\t\tsdk: projectCoinSdk(sui),\n\t\t\t\t\tchainId: sui.chainId,\n\t\t\t\t\tpublisher,\n\t\t\t\t});\n\t\t\t\t// Emit inline. `value` is the resolved `CoinValue`; `symbol` is\n\t\t\t\t// the builtin coin name (`'sui'`).\n\t\t\t\temitContributions(ctx, coinContributions(symbol, value));\n\t\t\t\treturn value;\n\t\t\t}),\n\t});\n};\n\n// ---------------------------------------------------------------------------\n// Public `coin` namespace\n// ---------------------------------------------------------------------------\n\n/** User-facing factory namespace. Three variants — see file header for\n * the rationale on not exposing a `coin(identifier)` form-guessing\n * entry. */\nexport const coin = {\n\tfromPackage,\n\tknown,\n\tbuiltin,\n} as const;\n\n// ---------------------------------------------------------------------------\n// Re-exports — advanced callers (Wallet, Faucet, Deepbook, examples)\n// ---------------------------------------------------------------------------\n\nexport type { CoinValue, CoinAddressForm } from './service.ts';\nexport type { ResolvedCoin, BuiltinCoinName } from './address-resolution.ts';\nexport { BUILTIN_COINS } from './address-resolution.ts';\n\nexport type { CoinRecord, CoinRegistry, CoinKey } from './registry.ts';\nexport { CoinRegistryService, layerCoinRegistry } from './registry.ts';\n\nexport type { CoinBindings } from './codegen.ts';\n\nexport type { DiscoveredCoin } from './discovery.ts';\nexport { discoverCoinsFromPublish } from './discovery.ts';\n\nexport type { MetadataSdkShim, OnchainCoinMetadata, CoinMetadataCache } from './metadata.ts';\nexport {\n\tOnchainCoinMetadataShape,\n\tMETADATA_FETCH_TIMEOUT_MS,\n\tMETADATA_RETRY_SCHEDULE,\n\tfetchCoinMetadataOnce,\n\tfetchCoinMetadataMany,\n\tmakeCoinMetadataCache,\n\tisBareCoinType,\n\tvalidateBareCoinType,\n} from './metadata.ts';\n\nexport type { MintInputs, MintResult, MintSigner, MintSdkShim, CachedMint } from './mint.ts';\nexport { performMint, MintedCoinVerifyShape, mintTxError, mintParseError } from './mint.ts';\n\nexport type { CoinError, CoinPhase } from './errors.ts';\nexport { coinError } from './errors.ts';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkDA,MAAa,4BACZ,iBAC4B,YAAY;;;AAQzC,MAAa,kBAAsC,WAA+B,QAAQ;;;;;;AAS1F,MAAM,wBAAwB;;;;;AAM9B,MAAM,6BAA6B;;;;;AAMnC,MAAM,wBAAwB,iBAAiC;CAC9D,MAAM,WAAW,aAAa,QAAQ,OAAO,EAAE,CAAC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AC,CACtF;EACA,QAAQ,EAAE,UACT,OAAO,IAAI,aAAa;GACvB,MAAM,MAAM,OAAO;GACnB,MAAM,YAAY,OAAO;GACzB,MAAM,WAAW,OAAO;GAExB,MAAM,QAAQ,OAAO,YAAY;IADD,MAAM;IAAS;GACX,GAAG;IACtC;IACA,KAAK,eAAe,GAAG;IACvB,SAAS,IAAI;IACb;GACD,CAAC;GAGD,kBAAkB,KAAK,kBAAkB,IAAI,KAAK,CAAC;GACnD,OAAO;EACR,CAAC;CACH,CAAC;AACF;;;;AASA,MAAa,WAAoD,SAAe;CAC/E,MAAM,SAAS;CAEf,OAAO,aAAa;EACnB,IAFe,SAA0C,eAAe,IAAI,CAElE,CAAC,CAAC;EACZ,WAAW,EAAE,KAAK,YAAY;EAC9B,MAAM;EACN,SAAS;EAKT,qBAAqB,CACpB,sBAAsB;GACrB;GACA,QAAQ;GACR,WAAW;IACV,cAAc,cAAc,KAAK,CAAC;IAClC,UAAU,cAAc,KAAK,CAAC;GAC/B;EACD,CAAC,CACF;EACA,QAAQ,EAAE,UACT,OAAO,IAAI,aAAa;GACvB,MAAM,MAAM,OAAO;GACnB,MAAM,YAAY,OAAO;GACzB,MAAM,WAAW,OAAO;GAExB,MAAM,QAAQ,OAAO,YAAY;IADD,MAAM;IAAW;GACb,GAAG;IACtC;IACA,KAAK,eAAe,GAAG;IACvB,SAAS,IAAI;IACb;GACD,CAAC;GAGD,kBAAkB,KAAK,kBAAkB,QAAQ,KAAK,CAAC;GACvD,OAAO;EACR,CAAC;CACH,CAAC;AACF;;;;AASA,MAAa,OAAO;CACnB;CACA;CACA;AACD"}
@@ -1,5 +1,6 @@
1
1
  import { CoinError } from "./errors.mjs";
2
2
  import { Effect, Schema } from "effect";
3
+
3
4
  //#region src/plugins/coin/metadata.d.ts
4
5
  /** Bare-coin-type heuristic — distilled-doc 13-coin.md Invariant 3.
5
6
  *