@mysten-incubation/devstack 0.1.1 → 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.
- package/README.md +6 -3
- package/dashboard-ui/assets/grpc-a4usE3Nk.js +3 -0
- package/dashboard-ui/assets/index-B82Bh84P.css +1 -0
- package/dashboard-ui/assets/index-CRYJ4pru.js +1277 -0
- package/dashboard-ui/index.html +2 -2
- package/dist/api/define-capabilities.d.mts +1 -20
- package/dist/api/define-capabilities.mjs +15 -22
- package/dist/api/define-capabilities.mjs.map +1 -1
- package/dist/api/define-devstack-with.d.mts +7 -1
- package/dist/api/define-devstack-with.mjs.map +1 -1
- package/dist/api/define-devstack.mjs.map +1 -1
- package/dist/api/define-plugin.d.mts +2 -1
- package/dist/api/inference-network.d.mts +31 -17
- package/dist/api/inference-network.mjs +40 -43
- package/dist/api/inference-network.mjs.map +1 -1
- package/dist/api/load-config.mjs +88 -0
- package/dist/api/load-config.mjs.map +1 -0
- package/dist/api/mode-narrowed-factory.d.mts +1 -1
- package/dist/api/mode-narrowed-factory.mjs.map +1 -1
- package/dist/api/run-stack-internal.mjs +202 -0
- package/dist/api/run-stack-internal.mjs.map +1 -0
- package/dist/api/run-stack.d.mts +82 -31
- package/dist/api/run-stack.mjs +22 -141
- package/dist/api/run-stack.mjs.map +1 -1
- package/dist/build-integrations/dapp-kit/index.d.mts +61 -0
- package/dist/build-integrations/dapp-kit/index.mjs +58 -0
- package/dist/build-integrations/dapp-kit/index.mjs.map +1 -0
- package/dist/build-integrations/playwright/config.d.mts +1 -30
- package/dist/build-integrations/playwright/config.mjs +1 -27
- package/dist/build-integrations/playwright/config.mjs.map +1 -1
- package/dist/build-integrations/playwright/errors.d.mts +4 -7
- package/dist/build-integrations/playwright/errors.mjs.map +1 -1
- package/dist/build-integrations/playwright/global-setup.d.mts +42 -71
- package/dist/build-integrations/playwright/global-setup.mjs +142 -218
- package/dist/build-integrations/playwright/global-setup.mjs.map +1 -1
- package/dist/build-integrations/playwright/index.d.mts +2 -2
- package/dist/build-integrations/playwright/index.mjs +2 -2
- package/dist/build-integrations/playwright/stack-context.d.mts +3 -1
- package/dist/build-integrations/playwright/stack-context.mjs +4 -2
- package/dist/build-integrations/playwright/stack-context.mjs.map +1 -1
- package/dist/build-integrations/playwright/wallet-context.mjs +44 -19
- package/dist/build-integrations/playwright/wallet-context.mjs.map +1 -1
- package/dist/build-integrations/runtime/cold-start-url.mjs.map +1 -1
- package/dist/build-integrations/runtime/conventional-routes.mjs.map +1 -1
- package/dist/build-integrations/runtime/dapp-kit-slot.mjs.map +1 -1
- package/dist/build-integrations/runtime/discover.d.mts +6 -4
- package/dist/build-integrations/runtime/discover.mjs +15 -4
- package/dist/build-integrations/runtime/discover.mjs.map +1 -1
- package/dist/build-integrations/runtime/endpoint-registry.mjs.map +1 -1
- package/dist/build-integrations/runtime/errors.mjs.map +1 -1
- package/dist/build-integrations/runtime/read-stack-context.mjs +3 -3
- package/dist/build-integrations/runtime/read-stack-context.mjs.map +1 -1
- package/dist/build-integrations/runtime/resolve-discovery-env.d.mts +23 -7
- package/dist/build-integrations/runtime/resolve-discovery-env.mjs +25 -12
- package/dist/build-integrations/runtime/resolve-discovery-env.mjs.map +1 -1
- package/dist/build-integrations/runtime/stack-context.d.mts +2 -2
- package/dist/build-integrations/vite/index.d.mts +84 -19
- package/dist/build-integrations/vite/index.mjs +203 -28
- package/dist/build-integrations/vite/index.mjs.map +1 -1
- package/dist/build-integrations/vitest/config.d.mts +20 -2
- package/dist/build-integrations/vitest/config.mjs +16 -4
- package/dist/build-integrations/vitest/config.mjs.map +1 -1
- package/dist/build-integrations/vitest/env.d.mts +18 -10
- package/dist/build-integrations/vitest/env.mjs +11 -10
- package/dist/build-integrations/vitest/env.mjs.map +1 -1
- package/dist/build-integrations/vitest/errors.d.mts +7 -11
- package/dist/build-integrations/vitest/errors.mjs +3 -4
- package/dist/build-integrations/vitest/errors.mjs.map +1 -1
- package/dist/build-integrations/vitest/global-setup.d.mts +35 -0
- package/dist/build-integrations/vitest/global-setup.mjs +156 -0
- package/dist/build-integrations/vitest/global-setup.mjs.map +1 -0
- package/dist/build-integrations/vitest/index.d.mts +3 -2
- package/dist/build-integrations/vitest/index.mjs +3 -2
- package/dist/build-integrations/vitest/setup.mjs +2 -2
- package/dist/build-integrations/vitest/setup.mjs.map +1 -1
- package/dist/build-integrations/vitest/stack-context.d.mts +5 -3
- package/dist/build-integrations/vitest/stack-context.mjs +3 -2
- package/dist/build-integrations/vitest/stack-context.mjs.map +1 -1
- package/dist/cli/bail.mjs.map +1 -1
- package/dist/cli/doctor-probes.mjs +1 -3
- package/dist/cli/doctor-probes.mjs.map +1 -1
- package/dist/cli/main.d.mts +23 -1
- package/dist/cli/main.mjs +63 -8
- package/dist/cli/main.mjs.map +1 -1
- package/dist/cli/prune-direct.mjs.map +1 -1
- package/dist/cli/snapshot-reader.mjs.map +1 -1
- package/dist/cli/up-lifecycle.mjs.map +1 -1
- package/dist/cli/wirings/apply.mjs +28 -21
- package/dist/cli/wirings/apply.mjs.map +1 -1
- package/dist/cli/wirings/codegen.mjs +108 -0
- package/dist/cli/wirings/codegen.mjs.map +1 -0
- package/dist/cli/wirings/config-loader.mjs +12 -62
- package/dist/cli/wirings/config-loader.mjs.map +1 -1
- package/dist/cli/wirings/dump-ids.mjs +86 -0
- package/dist/cli/wirings/dump-ids.mjs.map +1 -0
- package/dist/cli/wirings/engine-command.mjs +1 -1
- package/dist/cli/wirings/engine-command.mjs.map +1 -1
- package/dist/cli/wirings/identity.mjs +2 -2
- package/dist/cli/wirings/identity.mjs.map +1 -1
- package/dist/cli/wirings/provide-file-system.mjs.map +1 -1
- package/dist/cli/wirings/read-devstack-version.mjs +17 -0
- package/dist/cli/wirings/read-devstack-version.mjs.map +1 -0
- package/dist/cli/wirings/snapshot.mjs +27 -34
- package/dist/cli/wirings/snapshot.mjs.map +1 -1
- package/dist/cli/wirings/up-ipc.mjs +147 -0
- package/dist/cli/wirings/up-ipc.mjs.map +1 -0
- package/dist/cli/wirings/up.mjs +218 -198
- package/dist/cli/wirings/up.mjs.map +1 -1
- package/dist/cli/wirings/wipe.mjs +1 -1
- package/dist/cli/wirings/wipe.mjs.map +1 -1
- package/dist/contracts/chain-probe.d.mts +1 -1
- package/dist/contracts/chain-probe.mjs +1 -1
- package/dist/contracts/chain-probe.mjs.map +1 -1
- package/dist/contracts/codegenable.d.mts +60 -6
- package/dist/contracts/codegenable.mjs +28 -0
- package/dist/contracts/codegenable.mjs.map +1 -0
- package/dist/contracts/config-bindings.mjs +162 -0
- package/dist/contracts/config-bindings.mjs.map +1 -0
- package/dist/contracts/container-runtime.d.mts +23 -17
- package/dist/contracts/plugin-expander.mjs.map +1 -1
- package/dist/contracts/snapshotable.d.mts +5 -7
- package/dist/contracts/wallet-protocol.d.mts +2 -5
- package/dist/contracts/wallet-protocol.mjs +2 -5
- package/dist/contracts/wallet-protocol.mjs.map +1 -1
- package/dist/index.d.mts +21 -26
- package/dist/index.mjs +8 -9
- package/dist/orchestrators/boot.d.mts +28 -0
- package/dist/orchestrators/boot.mjs +440 -0
- package/dist/orchestrators/boot.mjs.map +1 -0
- package/dist/orchestrators/codegen/bindings.d.mts +13 -1
- package/dist/orchestrators/codegen/bindings.mjs +23 -9
- package/dist/orchestrators/codegen/bindings.mjs.map +1 -1
- package/dist/orchestrators/codegen/config-runtime.mjs +208 -0
- package/dist/orchestrators/codegen/config-runtime.mjs.map +1 -0
- package/dist/orchestrators/codegen/emit.mjs +1 -1
- package/dist/orchestrators/codegen/emit.mjs.map +1 -1
- package/dist/orchestrators/codegen/errors.mjs +21 -1
- package/dist/orchestrators/codegen/errors.mjs.map +1 -1
- package/dist/orchestrators/codegen/format.mjs +2 -0
- package/dist/orchestrators/codegen/format.mjs.map +1 -1
- package/dist/orchestrators/codegen/gitignore.mjs +30 -11
- package/dist/orchestrators/codegen/gitignore.mjs.map +1 -1
- package/dist/orchestrators/codegen/id-config.mjs +107 -0
- package/dist/orchestrators/codegen/id-config.mjs.map +1 -0
- package/dist/orchestrators/codegen/output-location.mjs +23 -32
- package/dist/orchestrators/codegen/output-location.mjs.map +1 -1
- package/dist/orchestrators/codegen/paths.mjs +8 -1
- package/dist/orchestrators/codegen/paths.mjs.map +1 -1
- package/dist/orchestrators/codegen/permissions.mjs.map +1 -1
- package/dist/orchestrators/codegen/service.mjs +286 -58
- package/dist/orchestrators/codegen/service.mjs.map +1 -1
- package/dist/orchestrators/layers.mjs +31 -0
- package/dist/orchestrators/layers.mjs.map +1 -0
- package/dist/orchestrators/lifecycle-prune/errors.mjs.map +1 -1
- package/dist/orchestrators/lifecycle-prune/index.mjs +8 -10
- package/dist/orchestrators/lifecycle-prune/index.mjs.map +1 -1
- package/dist/orchestrators/network-options.d.mts +52 -0
- package/dist/orchestrators/network-options.mjs +43 -0
- package/dist/orchestrators/network-options.mjs.map +1 -0
- package/dist/orchestrators/router/cleanup.mjs.map +1 -1
- package/dist/orchestrators/router/cors.mjs.map +1 -1
- package/dist/orchestrators/router/entrypoints.mjs.map +1 -1
- package/dist/orchestrators/router/errors.mjs.map +1 -1
- package/dist/orchestrators/router/file-provider.mjs.map +1 -1
- package/dist/orchestrators/router/hostname.mjs.map +1 -1
- package/dist/orchestrators/router/profile.mjs +1 -1
- package/dist/orchestrators/router/profile.mjs.map +1 -1
- package/dist/orchestrators/router/service.d.mts +2 -2
- package/dist/orchestrators/router/service.mjs +12 -27
- package/dist/orchestrators/router/service.mjs.map +1 -1
- package/dist/orchestrators/router/traefik-container.mjs +1 -1
- package/dist/orchestrators/router/traefik-container.mjs.map +1 -1
- package/dist/orchestrators/snapshot/capture.mjs +171 -195
- package/dist/orchestrators/snapshot/capture.mjs.map +1 -1
- package/dist/orchestrators/snapshot/descriptor.d.mts +1 -1
- package/dist/orchestrators/snapshot/descriptor.mjs +53 -11
- package/dist/orchestrators/snapshot/descriptor.mjs.map +1 -1
- package/dist/orchestrators/snapshot/identity-guard.mjs +3 -5
- package/dist/orchestrators/snapshot/identity-guard.mjs.map +1 -1
- package/dist/orchestrators/snapshot/image-bundle-tags.mjs +32 -101
- package/dist/orchestrators/snapshot/image-bundle-tags.mjs.map +1 -1
- package/dist/orchestrators/snapshot/index.mjs +1 -4
- package/dist/orchestrators/snapshot/integrity.mjs.map +1 -1
- package/dist/orchestrators/snapshot/interrupted-restore.mjs +116 -0
- package/dist/orchestrators/snapshot/interrupted-restore.mjs.map +1 -0
- package/dist/orchestrators/snapshot/phase-error.mjs.map +1 -1
- package/dist/orchestrators/snapshot/prune.mjs +40 -31
- package/dist/orchestrators/snapshot/prune.mjs.map +1 -1
- package/dist/orchestrators/snapshot/restore.mjs +221 -196
- package/dist/orchestrators/snapshot/restore.mjs.map +1 -1
- package/dist/orchestrators/snapshot/service.mjs +72 -62
- package/dist/orchestrators/snapshot/service.mjs.map +1 -1
- package/dist/orchestrators/snapshot/wipe.mjs +67 -56
- package/dist/orchestrators/snapshot/wipe.mjs.map +1 -1
- package/dist/plugins/account/codegen.mjs +3 -0
- package/dist/plugins/account/codegen.mjs.map +1 -1
- package/dist/plugins/account/errors.d.mts +2 -2
- package/dist/plugins/account/errors.mjs +1 -4
- package/dist/plugins/account/errors.mjs.map +1 -1
- package/dist/plugins/account/funding.mjs +3 -27
- package/dist/plugins/account/funding.mjs.map +1 -1
- package/dist/plugins/account/index.d.mts +3 -8
- package/dist/plugins/account/index.mjs +71 -35
- package/dist/plugins/account/index.mjs.map +1 -1
- package/dist/plugins/account/keypair.d.mts +8 -7
- package/dist/plugins/account/keypair.mjs +5 -18
- package/dist/plugins/account/keypair.mjs.map +1 -1
- package/dist/plugins/account/lease.mjs.map +1 -1
- package/dist/plugins/account/registry.d.mts +1 -46
- package/dist/plugins/account/registry.mjs.map +1 -1
- package/dist/plugins/account/service.d.mts +43 -34
- package/dist/plugins/account/service.mjs +9 -54
- package/dist/plugins/account/service.mjs.map +1 -1
- package/dist/plugins/account/snapshot.mjs.map +1 -1
- package/dist/plugins/account/variants/ephemeral.mjs.map +1 -1
- package/dist/plugins/account/variants/impersonate.mjs.map +1 -1
- package/dist/plugins/account/variants/signer.mjs.map +1 -1
- package/dist/plugins/action/discriminator.mjs.map +1 -1
- package/dist/plugins/action/errors.mjs +1 -4
- package/dist/plugins/action/errors.mjs.map +1 -1
- package/dist/plugins/action/execute.mjs +3 -4
- package/dist/plugins/action/execute.mjs.map +1 -1
- package/dist/plugins/action/index.d.mts +2 -2
- package/dist/plugins/action/index.mjs +7 -11
- package/dist/plugins/action/index.mjs.map +1 -1
- package/dist/plugins/action/service.d.mts +5 -7
- package/dist/plugins/action/service.mjs +2 -16
- package/dist/plugins/action/service.mjs.map +1 -1
- package/dist/plugins/coin/address-resolution.mjs.map +1 -1
- package/dist/plugins/coin/codegen.mjs +97 -16
- package/dist/plugins/coin/codegen.mjs.map +1 -1
- package/dist/plugins/coin/discovery.mjs.map +1 -1
- package/dist/plugins/coin/errors.mjs +1 -4
- package/dist/plugins/coin/errors.mjs.map +1 -1
- package/dist/plugins/coin/index.d.mts +4 -34
- package/dist/plugins/coin/index.mjs +47 -28
- package/dist/plugins/coin/index.mjs.map +1 -1
- package/dist/plugins/coin/metadata.d.mts +1 -0
- package/dist/plugins/coin/metadata.mjs +8 -9
- package/dist/plugins/coin/metadata.mjs.map +1 -1
- package/dist/plugins/coin/mint.mjs +7 -21
- package/dist/plugins/coin/mint.mjs.map +1 -1
- package/dist/plugins/coin/registry.mjs +33 -20
- package/dist/plugins/coin/registry.mjs.map +1 -1
- package/dist/plugins/coin/service.d.mts +1 -1
- package/dist/plugins/coin/service.mjs +1 -8
- package/dist/plugins/coin/service.mjs.map +1 -1
- package/dist/plugins/coin/snapshot.mjs.map +1 -1
- package/dist/plugins/coin/type-strings.mjs.map +1 -1
- package/dist/plugins/dashboard/domain.mjs +106 -167
- package/dist/plugins/dashboard/domain.mjs.map +1 -1
- package/dist/plugins/dashboard/index.mjs +13 -13
- package/dist/plugins/dashboard/index.mjs.map +1 -1
- package/dist/plugins/dashboard/origin-policy.mjs +3 -3
- package/dist/plugins/dashboard/origin-policy.mjs.map +1 -1
- package/dist/plugins/dashboard/routable.mjs.map +1 -1
- package/dist/plugins/dashboard/schema/builder.mjs.map +1 -1
- package/dist/plugins/dashboard/schema/enums.mjs.map +1 -1
- package/dist/plugins/dashboard/schema/root.mjs +23 -44
- package/dist/plugins/dashboard/schema/root.mjs.map +1 -1
- package/dist/plugins/dashboard/schema/types.mjs +37 -91
- package/dist/plugins/dashboard/schema/types.mjs.map +1 -1
- package/dist/plugins/dashboard/schema.mjs.map +1 -1
- package/dist/plugins/dashboard/server.mjs.map +1 -1
- package/dist/plugins/deepbook/codegen.d.mts +12 -11
- package/dist/plugins/deepbook/codegen.mjs +108 -11
- package/dist/plugins/deepbook/codegen.mjs.map +1 -1
- package/dist/plugins/deepbook/deploy.mjs +7 -14
- package/dist/plugins/deepbook/deploy.mjs.map +1 -1
- package/dist/plugins/deepbook/errors.mjs +4 -2
- package/dist/plugins/deepbook/errors.mjs.map +1 -1
- package/dist/plugins/deepbook/faucet-strategy.mjs +4 -10
- package/dist/plugins/deepbook/faucet-strategy.mjs.map +1 -1
- package/dist/plugins/deepbook/hash.mjs.map +1 -1
- package/dist/plugins/deepbook/index.d.mts +38 -34
- package/dist/plugins/deepbook/index.mjs +133 -64
- package/dist/plugins/deepbook/index.mjs.map +1 -1
- package/dist/plugins/deepbook/plugin-key.mjs.map +1 -1
- package/dist/plugins/deepbook/pyth/index.mjs +4 -8
- package/dist/plugins/deepbook/pyth/index.mjs.map +1 -1
- package/dist/plugins/deepbook/snapshot.mjs +0 -1
- package/dist/plugins/deepbook/snapshot.mjs.map +1 -1
- package/dist/plugins/deepbook/type-strings.mjs.map +1 -1
- package/dist/plugins/deepbook/types.d.mts +2 -1
- package/dist/plugins/deepbook/types.mjs.map +1 -1
- package/dist/plugins/faucet/dispatcher.d.mts +3 -3
- package/dist/plugins/faucet/dispatcher.mjs.map +1 -1
- package/dist/plugins/faucet/errors.mjs.map +1 -1
- package/dist/plugins/faucet/http.mjs +2 -10
- package/dist/plugins/faucet/http.mjs.map +1 -1
- package/dist/plugins/faucet/index.mjs +0 -1
- package/dist/plugins/faucet/index.mjs.map +1 -1
- package/dist/plugins/host-service/errors.d.mts +1 -3
- package/dist/plugins/host-service/errors.mjs +1 -2
- package/dist/plugins/host-service/errors.mjs.map +1 -1
- package/dist/plugins/host-service/index.d.mts +1 -2
- package/dist/plugins/host-service/index.mjs +11 -11
- package/dist/plugins/host-service/index.mjs.map +1 -1
- package/dist/plugins/host-service/routable.mjs.map +1 -1
- package/dist/plugins/host-service/service.mjs +13 -13
- package/dist/plugins/host-service/service.mjs.map +1 -1
- package/dist/plugins/internal/acquire-on-chain-artifact.mjs.map +1 -1
- package/dist/plugins/internal/codegen-helpers.mjs +2 -0
- package/dist/plugins/internal/codegen-helpers.mjs.map +1 -1
- package/dist/plugins/internal/funding-failure-error.mjs.map +1 -1
- package/dist/plugins/{postgres → internal/postgres-sidecar}/connection.mjs +1 -1
- package/dist/plugins/internal/postgres-sidecar/connection.mjs.map +1 -0
- package/dist/plugins/{postgres → internal/postgres-sidecar}/db-ensure.mjs +30 -16
- package/dist/plugins/internal/postgres-sidecar/db-ensure.mjs.map +1 -0
- package/dist/plugins/internal/postgres-sidecar/errors.mjs +21 -0
- package/dist/plugins/internal/postgres-sidecar/errors.mjs.map +1 -0
- package/dist/{substrate/runtime/scoped-multimap → plugins/internal/postgres-sidecar}/index.mjs +1 -0
- package/dist/plugins/internal/postgres-sidecar/service.mjs +121 -0
- package/dist/plugins/internal/postgres-sidecar/service.mjs.map +1 -0
- package/dist/plugins/package/build.mjs +2 -2
- package/dist/plugins/package/build.mjs.map +1 -1
- package/dist/plugins/package/codegen.d.mts +7 -14
- package/dist/plugins/package/codegen.mjs +187 -59
- package/dist/plugins/package/codegen.mjs.map +1 -1
- package/dist/plugins/package/dep-resolution.mjs +51 -3
- package/dist/plugins/package/dep-resolution.mjs.map +1 -1
- package/dist/plugins/package/errors.mjs +1 -4
- package/dist/plugins/package/errors.mjs.map +1 -1
- package/dist/plugins/package/git-source.d.mts +18 -0
- package/dist/plugins/package/git-source.mjs +119 -0
- package/dist/plugins/package/git-source.mjs.map +1 -0
- package/dist/plugins/package/index.d.mts +28 -19
- package/dist/plugins/package/index.mjs +107 -32
- package/dist/plugins/package/index.mjs.map +1 -1
- package/dist/plugins/package/mode-known.mjs +2 -2
- package/dist/plugins/package/mode-known.mjs.map +1 -1
- package/dist/plugins/package/mode-local.mjs +18 -35
- package/dist/plugins/package/mode-local.mjs.map +1 -1
- package/dist/plugins/package/publish-executor.mjs +13 -8
- package/dist/plugins/package/publish-executor.mjs.map +1 -1
- package/dist/plugins/package/publish-output.d.mts +1 -11
- package/dist/plugins/package/publish-output.mjs +1 -9
- package/dist/plugins/package/publish-output.mjs.map +1 -1
- package/dist/plugins/package/registry.d.mts +1 -1
- package/dist/plugins/package/registry.mjs +26 -14
- package/dist/plugins/package/registry.mjs.map +1 -1
- package/dist/plugins/package/service.mjs.map +1 -1
- package/dist/plugins/package/snapshot.mjs.map +1 -1
- package/dist/plugins/router-entrypoints.mjs +1 -3
- package/dist/plugins/router-entrypoints.mjs.map +1 -1
- package/dist/plugins/seal/bootstrap-assets/cargo-image.mjs +1 -2
- package/dist/plugins/seal/bootstrap-assets/cargo-image.mjs.map +1 -1
- package/dist/plugins/seal/bootstrap-assets/source-fetch.mjs +1 -6
- package/dist/plugins/seal/bootstrap-assets/source-fetch.mjs.map +1 -1
- package/dist/plugins/seal/codegen.d.mts +1 -5
- package/dist/plugins/seal/codegen.mjs +83 -12
- package/dist/plugins/seal/codegen.mjs.map +1 -1
- package/dist/plugins/seal/config-render.mjs +2 -6
- package/dist/plugins/seal/config-render.mjs.map +1 -1
- package/dist/plugins/seal/deploy.mjs +18 -29
- package/dist/plugins/seal/deploy.mjs.map +1 -1
- package/dist/plugins/seal/errors.d.mts +4 -5
- package/dist/plugins/seal/errors.mjs +1 -8
- package/dist/plugins/seal/errors.mjs.map +1 -1
- package/dist/plugins/seal/index.d.mts +7 -28
- package/dist/plugins/seal/index.mjs +69 -47
- package/dist/plugins/seal/index.mjs.map +1 -1
- package/dist/plugins/seal/key-manager.mjs.map +1 -1
- package/dist/plugins/seal/key-server.mjs +1 -6
- package/dist/plugins/seal/key-server.mjs.map +1 -1
- package/dist/plugins/seal/keygen.mjs +2 -3
- package/dist/plugins/seal/keygen.mjs.map +1 -1
- package/dist/plugins/seal/mode/fork-known.mjs.map +1 -1
- package/dist/plugins/seal/mode/live.mjs +1 -1
- package/dist/plugins/seal/mode/live.mjs.map +1 -1
- package/dist/plugins/seal/mode/local-keygen.mjs +4 -10
- package/dist/plugins/seal/mode/local-keygen.mjs.map +1 -1
- package/dist/plugins/seal/plugin-key.mjs.map +1 -1
- package/dist/plugins/seal/registry-publish.mjs.map +1 -1
- package/dist/plugins/seal/routable.mjs.map +1 -1
- package/dist/plugins/seal/service.mjs.map +1 -1
- package/dist/plugins/seal/snapshot.mjs +1 -2
- package/dist/plugins/seal/snapshot.mjs.map +1 -1
- package/dist/plugins/sui/auto-tick.mjs +5 -5
- package/dist/plugins/sui/auto-tick.mjs.map +1 -1
- package/dist/plugins/sui/chain-build-container.mjs +2 -2
- package/dist/plugins/sui/chain-build-container.mjs.map +1 -1
- package/dist/plugins/sui/chain-probe.mjs +4 -4
- package/dist/plugins/sui/chain-probe.mjs.map +1 -1
- package/dist/plugins/sui/codegen.d.mts +9 -7
- package/dist/plugins/sui/codegen.mjs +49 -46
- package/dist/plugins/sui/codegen.mjs.map +1 -1
- package/dist/plugins/sui/errors.d.mts +1 -1
- package/dist/plugins/sui/errors.mjs +1 -9
- package/dist/plugins/sui/errors.mjs.map +1 -1
- package/dist/{substrate/runtime/sui-execute → plugins/sui/exec}/index.d.mts +1 -1
- package/dist/{substrate/runtime/sui-execute → plugins/sui/exec}/index.mjs +3 -7
- package/dist/plugins/sui/exec/index.mjs.map +1 -0
- package/dist/{substrate/runtime/sui-execute → plugins/sui/exec}/sign-and-dispatch.mjs +1 -1
- package/dist/plugins/sui/exec/sign-and-dispatch.mjs.map +1 -0
- package/dist/plugins/sui/fork-faucet-strategy.mjs +2 -6
- package/dist/plugins/sui/fork-faucet-strategy.mjs.map +1 -1
- package/dist/plugins/sui/fork-orchestration.mjs +13 -23
- package/dist/plugins/sui/fork-orchestration.mjs.map +1 -1
- package/dist/plugins/sui/fork-transaction.mjs.map +1 -1
- package/dist/plugins/sui/index.d.mts +34 -83
- package/dist/plugins/sui/index.mjs +200 -68
- package/dist/plugins/sui/index.mjs.map +1 -1
- package/dist/{substrate/runtime/sui-ledger → plugins/sui/ledger}/object-ref.mjs +1 -1
- package/dist/plugins/sui/ledger/object-ref.mjs.map +1 -0
- package/dist/plugins/sui/local-faucet-strategy.mjs +1 -5
- package/dist/plugins/sui/local-faucet-strategy.mjs.map +1 -1
- package/dist/plugins/sui/log-attrs.mjs +11 -0
- package/dist/plugins/sui/log-attrs.mjs.map +1 -0
- package/dist/plugins/sui/mode/external.mjs +4 -12
- package/dist/plugins/sui/mode/external.mjs.map +1 -1
- package/dist/plugins/sui/mode/fork.mjs +19 -16
- package/dist/plugins/sui/mode/fork.mjs.map +1 -1
- package/dist/plugins/sui/mode/live.mjs +4 -17
- package/dist/plugins/sui/mode/live.mjs.map +1 -1
- package/dist/plugins/sui/mode/local.d.mts +1 -0
- package/dist/plugins/sui/mode/local.mjs +203 -61
- package/dist/plugins/sui/mode/local.mjs.map +1 -1
- package/dist/plugins/sui/mode/shared-boot.mjs +18 -23
- package/dist/plugins/sui/mode/shared-boot.mjs.map +1 -1
- package/dist/plugins/sui/mode/shared.d.mts +6 -7
- package/dist/plugins/sui/mode/shared.mjs.map +1 -1
- package/dist/plugins/sui/mode/spec.d.mts +23 -6
- package/dist/{substrate/runtime/sui-move-build → plugins/sui/move}/index.mjs +28 -30
- package/dist/plugins/sui/move/index.mjs.map +1 -0
- package/dist/plugins/sui/move-summary-runner.mjs +8 -4
- package/dist/plugins/sui/move-summary-runner.mjs.map +1 -1
- package/dist/{substrate/network.d.mts → plugins/sui/network-config.d.mts} +11 -10
- package/dist/plugins/sui/network-resolver.d.mts +6 -6
- package/dist/plugins/sui/routable.mjs.map +1 -1
- package/dist/plugins/sui/service.mjs +10 -6
- package/dist/plugins/sui/service.mjs.map +1 -1
- package/dist/plugins/sui/snapshot.mjs +10 -5
- package/dist/plugins/sui/snapshot.mjs.map +1 -1
- package/dist/plugins/wallet/codegen.d.mts +8 -6
- package/dist/plugins/wallet/codegen.mjs +4 -10
- package/dist/plugins/wallet/codegen.mjs.map +1 -1
- package/dist/plugins/wallet/errors.mjs +1 -4
- package/dist/plugins/wallet/errors.mjs.map +1 -1
- package/dist/plugins/wallet/index.d.mts +3 -6
- package/dist/plugins/wallet/index.mjs +16 -21
- package/dist/plugins/wallet/index.mjs.map +1 -1
- package/dist/plugins/wallet/origin-policy.mjs +3 -3
- package/dist/plugins/wallet/origin-policy.mjs.map +1 -1
- package/dist/plugins/wallet/pairing.mjs +6 -24
- package/dist/plugins/wallet/pairing.mjs.map +1 -1
- package/dist/plugins/wallet/protocol.mjs.map +1 -1
- package/dist/plugins/wallet/routable.mjs.map +1 -1
- package/dist/plugins/wallet/server.mjs +17 -24
- package/dist/plugins/wallet/server.mjs.map +1 -1
- package/dist/plugins/wallet/service.d.mts +2 -2
- package/dist/plugins/wallet/service.mjs +4 -15
- package/dist/plugins/wallet/service.mjs.map +1 -1
- package/dist/plugins/wallet/snapshot.mjs.map +1 -1
- package/dist/plugins/walrus/bootstrap-assets/cargo-image.mjs +1 -5
- package/dist/plugins/walrus/bootstrap-assets/cargo-image.mjs.map +1 -1
- package/dist/plugins/walrus/codegen.d.mts +2 -13
- package/dist/plugins/walrus/codegen.mjs +93 -28
- package/dist/plugins/walrus/codegen.mjs.map +1 -1
- package/dist/plugins/walrus/deploy-paths.mjs +2 -3
- package/dist/plugins/walrus/deploy-paths.mjs.map +1 -1
- package/dist/plugins/walrus/deploy.mjs +26 -19
- package/dist/plugins/walrus/deploy.mjs.map +1 -1
- package/dist/plugins/walrus/errors.mjs +1 -8
- package/dist/plugins/walrus/errors.mjs.map +1 -1
- package/dist/plugins/walrus/faucet-strategy.mjs +15 -1
- package/dist/plugins/walrus/faucet-strategy.mjs.map +1 -1
- package/dist/plugins/walrus/index.d.mts +13 -44
- package/dist/plugins/walrus/index.mjs +119 -122
- package/dist/plugins/walrus/index.mjs.map +1 -1
- package/dist/plugins/walrus/mode/known-deploy.mjs +6 -6
- package/dist/plugins/walrus/mode/known-deploy.mjs.map +1 -1
- package/dist/plugins/walrus/mode/local-cluster.d.mts +2 -2
- package/dist/plugins/walrus/mode/local-cluster.mjs +2 -10
- package/dist/plugins/walrus/mode/local-cluster.mjs.map +1 -1
- package/dist/plugins/walrus/plugin-key.mjs.map +1 -1
- package/dist/plugins/walrus/registry-publish.mjs.map +1 -1
- package/dist/plugins/walrus/routable.mjs.map +1 -1
- package/dist/plugins/walrus/service.mjs.map +1 -1
- package/dist/plugins/walrus/snapshot.mjs +3 -3
- package/dist/plugins/walrus/snapshot.mjs.map +1 -1
- package/dist/plugins/walrus/storage-nodes.mjs +53 -14
- package/dist/plugins/walrus/storage-nodes.mjs.map +1 -1
- package/dist/plugins/walrus/wal-swap.mjs +4 -8
- package/dist/plugins/walrus/wal-swap.mjs.map +1 -1
- package/dist/primitives/artifact-publisher.mjs.map +1 -1
- package/dist/primitives/cache.d.mts +1 -1
- package/dist/runtime/docker/client.mjs +47 -3
- package/dist/runtime/docker/client.mjs.map +1 -1
- package/dist/runtime/docker/container.mjs +37 -57
- package/dist/runtime/docker/container.mjs.map +1 -1
- package/dist/runtime/docker/errors.mjs.map +1 -1
- package/dist/runtime/docker/exec.mjs +2 -2
- package/dist/runtime/docker/exec.mjs.map +1 -1
- package/dist/runtime/docker/image.mjs +10 -11
- package/dist/runtime/docker/image.mjs.map +1 -1
- package/dist/runtime/docker/index.mjs +0 -1
- package/dist/runtime/docker/inspect-and-decode.mjs.map +1 -1
- package/dist/runtime/docker/inventory.mjs +9 -9
- package/dist/runtime/docker/inventory.mjs.map +1 -1
- package/dist/runtime/docker/labels.mjs +12 -1
- package/dist/runtime/docker/labels.mjs.map +1 -1
- package/dist/runtime/docker/network.mjs +6 -6
- package/dist/runtime/docker/network.mjs.map +1 -1
- package/dist/runtime/docker/render-run-args.mjs.map +1 -1
- package/dist/runtime/docker/service.mjs +31 -45
- package/dist/runtime/docker/service.mjs.map +1 -1
- package/dist/runtime/docker/sweep.mjs +14 -64
- package/dist/runtime/docker/sweep.mjs.map +1 -1
- package/dist/runtime/docker/volume.mjs +1 -1
- package/dist/runtime/docker/volume.mjs.map +1 -1
- package/dist/runtime/docker/wrap.mjs +14 -2
- package/dist/runtime/docker/wrap.mjs.map +1 -1
- package/dist/substrate/brand.d.mts +2 -5
- package/dist/substrate/brand.mjs +3 -2
- package/dist/substrate/brand.mjs.map +1 -1
- package/dist/substrate/cross-process.mjs +2 -16
- package/dist/substrate/cross-process.mjs.map +1 -1
- package/dist/substrate/event-time.mjs +0 -2
- package/dist/substrate/event-time.mjs.map +1 -1
- package/dist/substrate/events.d.mts +46 -16
- package/dist/substrate/identity.d.mts +11 -5
- package/dist/substrate/manifest.d.mts +33 -26
- package/dist/substrate/manifest.mjs +8 -3
- package/dist/substrate/manifest.mjs.map +1 -1
- package/dist/substrate/options.d.mts +33 -4
- package/dist/substrate/plugin-ctx.d.mts +70 -0
- package/dist/substrate/plugin-ctx.mjs +66 -0
- package/dist/substrate/plugin-ctx.mjs.map +1 -0
- package/dist/substrate/plugin.d.mts +46 -38
- package/dist/substrate/plugin.mjs +13 -9
- package/dist/substrate/plugin.mjs.map +1 -1
- package/dist/substrate/projection.d.mts +1 -1
- package/dist/substrate/runtime/atomic-write.mjs +3 -4
- package/dist/substrate/runtime/atomic-write.mjs.map +1 -1
- package/dist/substrate/runtime/cache/schema.mjs.map +1 -1
- package/dist/substrate/runtime/cache/service.mjs +50 -20
- package/dist/substrate/runtime/cache/service.mjs.map +1 -1
- package/dist/substrate/runtime/config-validation.mjs.map +1 -1
- package/dist/substrate/runtime/control-plane/domain.mjs +34 -12
- package/dist/substrate/runtime/control-plane/domain.mjs.map +1 -1
- package/dist/substrate/runtime/control-plane/service.mjs.map +1 -1
- package/dist/substrate/runtime/cross-process/command-channel/channel.mjs +14 -17
- package/dist/substrate/runtime/cross-process/command-channel/channel.mjs.map +1 -1
- package/dist/substrate/runtime/cross-process/command-channel/file-channel.mjs.map +1 -1
- package/dist/substrate/runtime/cross-process/command-channel/protocol.mjs.map +1 -1
- package/dist/substrate/runtime/cross-process/command-channel/runtime-control-lock.mjs.map +1 -1
- package/dist/substrate/runtime/cross-process/index.mjs +0 -2
- package/dist/substrate/runtime/cross-process/live-clock.mjs +1 -1
- package/dist/substrate/runtime/cross-process/live-clock.mjs.map +1 -1
- package/dist/substrate/runtime/cross-process/liveness.mjs +11 -18
- package/dist/substrate/runtime/cross-process/liveness.mjs.map +1 -1
- package/dist/substrate/runtime/cross-process/reclaim-stale-file.mjs +2 -2
- package/dist/substrate/runtime/cross-process/reclaim-stale-file.mjs.map +1 -1
- package/dist/substrate/runtime/cross-process/roster.mjs +17 -127
- package/dist/substrate/runtime/cross-process/roster.mjs.map +1 -1
- package/dist/substrate/runtime/cross-process/self-pid.mjs.map +1 -1
- package/dist/substrate/runtime/cross-process/stack-lock.mjs +29 -28
- package/dist/substrate/runtime/cross-process/stack-lock.mjs.map +1 -1
- package/dist/substrate/runtime/current-plugin.mjs.map +1 -1
- package/dist/substrate/runtime/errors.mjs +1 -13
- package/dist/substrate/runtime/errors.mjs.map +1 -1
- package/dist/substrate/runtime/format-unknown-error.mjs.map +1 -1
- package/dist/substrate/runtime/host-bind-mount-owner.mjs.map +1 -1
- package/dist/substrate/runtime/host-gateway.mjs.map +1 -1
- package/dist/substrate/runtime/host-tree-tar/index.mjs +15 -163
- package/dist/substrate/runtime/host-tree-tar/index.mjs.map +1 -1
- package/dist/substrate/runtime/http-probe.d.mts +1 -3
- package/dist/substrate/runtime/http-probe.mjs.map +1 -1
- package/dist/substrate/runtime/index.mjs +1 -6
- package/dist/substrate/runtime/lease-broker/service.mjs +5 -23
- package/dist/substrate/runtime/lease-broker/service.mjs.map +1 -1
- package/dist/substrate/runtime/lifecycle/dep-graph.mjs +3 -3
- package/dist/substrate/runtime/lifecycle/dep-graph.mjs.map +1 -1
- package/dist/substrate/runtime/lifecycle/graph-input-id.d.mts +1 -0
- package/dist/substrate/runtime/lifecycle/graph-input-id.mjs +133 -0
- package/dist/substrate/runtime/lifecycle/graph-input-id.mjs.map +1 -0
- package/dist/substrate/runtime/lifecycle/index.mjs +2 -2
- package/dist/substrate/runtime/lifecycle/plugin-registry.d.mts +1 -1
- package/dist/substrate/runtime/lifecycle/plugin-registry.mjs +22 -1
- package/dist/substrate/runtime/lifecycle/plugin-registry.mjs.map +1 -1
- package/dist/substrate/runtime/lifecycle/ready-gate.mjs +2 -15
- package/dist/substrate/runtime/lifecycle/ready-gate.mjs.map +1 -1
- package/dist/substrate/runtime/lifecycle/selective-restart.mjs +29 -25
- package/dist/substrate/runtime/lifecycle/selective-restart.mjs.map +1 -1
- package/dist/substrate/runtime/lifecycle/signals.mjs +1 -1
- package/dist/substrate/runtime/lifecycle/signals.mjs.map +1 -1
- package/dist/substrate/runtime/lifecycle/state-machine.mjs.map +1 -1
- package/dist/substrate/runtime/lifecycle/watch-attribution.d.mts +1 -1
- package/dist/substrate/runtime/lifecycle/watch-attribution.mjs +0 -1
- package/dist/substrate/runtime/lifecycle/watch-attribution.mjs.map +1 -1
- package/dist/substrate/runtime/managed-container.d.mts +5 -1
- package/dist/substrate/runtime/managed-container.mjs +8 -10
- package/dist/substrate/runtime/managed-container.mjs.map +1 -1
- package/dist/substrate/runtime/manifest/manifest.mjs +8 -30
- package/dist/substrate/runtime/manifest/manifest.mjs.map +1 -1
- package/dist/substrate/runtime/mode-errors.d.mts +1 -2
- package/dist/substrate/runtime/mode-errors.mjs.map +1 -1
- package/dist/substrate/runtime/observability/cascade-formatter.mjs +1 -11
- package/dist/substrate/runtime/observability/cascade-formatter.mjs.map +1 -1
- package/dist/substrate/runtime/observability/ignore-with-log.mjs.map +1 -1
- package/dist/substrate/runtime/observability/index.d.mts +1 -1
- package/dist/substrate/runtime/observability/index.mjs +4 -6
- package/dist/substrate/runtime/observability/log-attrs.mjs +46 -0
- package/dist/substrate/runtime/observability/log-attrs.mjs.map +1 -0
- package/dist/substrate/runtime/observability/log-store.mjs.map +1 -1
- package/dist/substrate/runtime/observability/logger.mjs +3 -3
- package/dist/substrate/runtime/observability/logger.mjs.map +1 -1
- package/dist/substrate/runtime/observability/output-truncate.mjs.map +1 -1
- package/dist/substrate/runtime/observability/pretty-error.mjs.map +1 -1
- package/dist/substrate/runtime/observability/process-lines.mjs.map +1 -1
- package/dist/substrate/runtime/observability/redaction.mjs.map +1 -1
- package/dist/substrate/runtime/observability/subprocess-capture.mjs +2 -2
- package/dist/substrate/runtime/observability/subprocess-capture.mjs.map +1 -1
- package/dist/substrate/runtime/passthrough-or-wrap.mjs.map +1 -1
- package/dist/substrate/runtime/paths.mjs +27 -9
- package/dist/substrate/runtime/paths.mjs.map +1 -1
- package/dist/substrate/runtime/phase-preserving-produce.mjs.map +1 -1
- package/dist/substrate/runtime/port-broker/service.mjs +10 -27
- package/dist/substrate/runtime/port-broker/service.mjs.map +1 -1
- package/dist/substrate/runtime/post-acquire-tasks.mjs.map +1 -1
- package/dist/substrate/runtime/probes.d.mts +2 -3
- package/dist/substrate/runtime/probes.mjs.map +1 -1
- package/dist/substrate/runtime/process-supervisor.mjs.map +1 -1
- package/dist/substrate/runtime/projection/operational-endpoints.mjs.map +1 -1
- package/dist/substrate/runtime/projection/state-ref.mjs.map +1 -1
- package/dist/substrate/runtime/projection/update.mjs +87 -11
- package/dist/substrate/runtime/projection/update.mjs.map +1 -1
- package/dist/substrate/runtime/random-suffix.mjs.map +1 -1
- package/dist/substrate/runtime/reconcile/fs-plan.mjs +146 -0
- package/dist/substrate/runtime/reconcile/fs-plan.mjs.map +1 -0
- package/dist/substrate/runtime/reconcile/graph.mjs +19 -0
- package/dist/substrate/runtime/reconcile/graph.mjs.map +1 -0
- package/dist/substrate/runtime/reconcile/index.mjs +5 -0
- package/dist/substrate/runtime/reconcile/label.mjs +41 -0
- package/dist/substrate/runtime/reconcile/label.mjs.map +1 -0
- package/dist/substrate/runtime/reconcile/spec.mjs +15 -0
- package/dist/substrate/runtime/reconcile/spec.mjs.map +1 -0
- package/dist/substrate/runtime/retry-policy.d.mts +2 -3
- package/dist/substrate/runtime/retry-policy.mjs.map +1 -1
- package/dist/substrate/runtime/routed-url.mjs.map +1 -1
- package/dist/substrate/runtime/runtime-decode.mjs.map +1 -1
- package/dist/substrate/runtime/scoped-http-server.mjs.map +1 -1
- package/dist/substrate/runtime/stage-and-swap/index.mjs +49 -12
- package/dist/substrate/runtime/stage-and-swap/index.mjs.map +1 -1
- package/dist/substrate/runtime/strategy-registry/chain-keyed-strategy-for.mjs.map +1 -1
- package/dist/substrate/runtime/strategy-registry/chain-probe-for.mjs.map +1 -1
- package/dist/substrate/runtime/strategy-registry/service.mjs +29 -17
- package/dist/substrate/runtime/strategy-registry/service.mjs.map +1 -1
- package/dist/substrate/runtime/subnet-broker.mjs.map +1 -1
- package/dist/substrate/runtime/supervisor/acquire-node.mjs +188 -56
- package/dist/substrate/runtime/supervisor/acquire-node.mjs.map +1 -1
- package/dist/substrate/runtime/supervisor/background-tasks.mjs +79 -65
- package/dist/substrate/runtime/supervisor/background-tasks.mjs.map +1 -1
- package/dist/substrate/runtime/supervisor/command-loop.mjs +82 -23
- package/dist/substrate/runtime/supervisor/command-loop.mjs.map +1 -1
- package/dist/substrate/runtime/supervisor/contribution-dispatcher.mjs +16 -0
- package/dist/substrate/runtime/supervisor/contribution-dispatcher.mjs.map +1 -0
- package/dist/substrate/runtime/supervisor/errors.mjs +11 -2
- package/dist/substrate/runtime/supervisor/errors.mjs.map +1 -1
- package/dist/substrate/runtime/supervisor/index.mjs +2 -0
- package/dist/substrate/runtime/supervisor/shutdown.mjs +6 -6
- package/dist/substrate/runtime/supervisor/shutdown.mjs.map +1 -1
- package/dist/substrate/runtime/supervisor/start-supervisor.mjs +60 -70
- package/dist/substrate/runtime/supervisor/start-supervisor.mjs.map +1 -1
- package/dist/substrate/runtime/supervisor/state.d.mts +1 -1
- package/dist/substrate/runtime/supervisor/state.mjs +1 -1
- package/dist/substrate/runtime/supervisor/state.mjs.map +1 -1
- package/dist/substrate/runtime/supervisor/teardown.mjs +10 -9
- package/dist/substrate/runtime/supervisor/teardown.mjs.map +1 -1
- package/dist/substrate/runtime/supervisor/wiring.mjs +6 -20
- package/dist/substrate/runtime/supervisor/wiring.mjs.map +1 -1
- package/dist/substrate/runtime/tar/reader.mjs +216 -0
- package/dist/substrate/runtime/tar/reader.mjs.map +1 -0
- package/dist/substrate/runtime/typed-env.mjs.map +1 -1
- package/dist/substrate/versioned-doc-schema.mjs.map +1 -1
- package/dist/substrate/versioned-doc-sync.mjs +5 -5
- package/dist/substrate/versioned-doc-sync.mjs.map +1 -1
- package/dist/surfaces/cli/command-tree.mjs +49 -7
- package/dist/surfaces/cli/command-tree.mjs.map +1 -1
- package/dist/surfaces/cli/commands/config.mjs +1 -1
- package/dist/surfaces/cli/commands/config.mjs.map +1 -1
- package/dist/surfaces/cli/commands/confirm-node.mjs.map +1 -1
- package/dist/surfaces/cli/commands/confirm.mjs.map +1 -1
- package/dist/surfaces/cli/commands/doctor.mjs +1 -1
- package/dist/surfaces/cli/commands/doctor.mjs.map +1 -1
- package/dist/surfaces/cli/commands/prune-picker-entry.mjs.map +1 -1
- package/dist/surfaces/cli/commands/prune-picker.mjs.map +1 -1
- package/dist/surfaces/cli/commands/prune.mjs +1 -1
- package/dist/surfaces/cli/commands/prune.mjs.map +1 -1
- package/dist/surfaces/cli/commands/snapshot.mjs +1 -1
- package/dist/surfaces/cli/commands/snapshot.mjs.map +1 -1
- package/dist/surfaces/cli/commands/status.mjs +1 -1
- package/dist/surfaces/cli/commands/status.mjs.map +1 -1
- package/dist/surfaces/cli/commands/supervisor-presence.mjs.map +1 -1
- package/dist/surfaces/cli/commands/wipe.mjs +3 -4
- package/dist/surfaces/cli/commands/wipe.mjs.map +1 -1
- package/dist/surfaces/cli/envelope.mjs.map +1 -1
- package/dist/surfaces/cli/errors.mjs.map +1 -1
- package/dist/surfaces/cli/flags.mjs.map +1 -1
- package/dist/surfaces/cli/index.mjs +45 -14
- package/dist/surfaces/cli/index.mjs.map +1 -1
- package/dist/surfaces/cli/output.mjs.map +1 -1
- package/dist/surfaces/cli/sysexits.mjs.map +1 -1
- package/dist/surfaces/tui/app.mjs +0 -21
- package/dist/surfaces/tui/app.mjs.map +1 -1
- package/dist/surfaces/tui/dashboard.mjs +0 -48
- package/dist/surfaces/tui/dashboard.mjs.map +1 -1
- package/dist/surfaces/tui/display-derivation.mjs +80 -16
- package/dist/surfaces/tui/display-derivation.mjs.map +1 -1
- package/dist/surfaces/tui/errors.mjs.map +1 -1
- package/dist/surfaces/tui/event-log.mjs +0 -9
- package/dist/surfaces/tui/event-log.mjs.map +1 -1
- package/dist/surfaces/tui/heartbeat.mjs.map +1 -1
- package/dist/surfaces/tui/index.mjs +2 -2
- package/dist/surfaces/tui/index.mjs.map +1 -1
- package/dist/surfaces/tui/input.mjs.map +1 -1
- package/dist/surfaces/tui/mode-detect.mjs.map +1 -1
- package/dist/surfaces/tui/mount-ink.mjs.map +1 -1
- package/dist/surfaces/tui/plain-renderer.mjs +26 -19
- package/dist/surfaces/tui/plain-renderer.mjs.map +1 -1
- package/dist/surfaces/tui/resource-table.mjs +8 -10
- package/dist/surfaces/tui/resource-table.mjs.map +1 -1
- package/images/postgres/Dockerfile +0 -1
- package/images/sui/Dockerfile +27 -54
- package/images/sui/entrypoint.sh +17 -179
- package/package.json +23 -15
- package/dashboard-ui/assets/index-Bmi1UtAg.js +0 -1356
- package/dashboard-ui/assets/index-D5EShVt4.js +0 -3
- package/dashboard-ui/assets/index-Deml9drg.css +0 -1
- package/dist/api/plugin-errors.d.mts +0 -7
- package/dist/api/plugin-errors.mjs +0 -10
- package/dist/api/plugin-errors.mjs.map +0 -1
- package/dist/cli/wirings/build-verb-layers.mjs +0 -42
- package/dist/cli/wirings/build-verb-layers.mjs.map +0 -1
- package/dist/contracts/capability-decl.d.mts +0 -40
- package/dist/orchestrators/built-in-plugin-layers.mjs +0 -54
- package/dist/orchestrators/built-in-plugin-layers.mjs.map +0 -1
- package/dist/orchestrators/run.mjs +0 -91
- package/dist/orchestrators/run.mjs.map +0 -1
- package/dist/orchestrators/runtime-composition.d.mts +0 -10
- package/dist/orchestrators/runtime-composition.mjs +0 -252
- package/dist/orchestrators/runtime-composition.mjs.map +0 -1
- package/dist/orchestrators/snapshot/capture-command.d.mts +0 -1
- package/dist/orchestrators/snapshot/capture-command.mjs +0 -25
- package/dist/orchestrators/snapshot/capture-command.mjs.map +0 -1
- package/dist/orchestrators/snapshot/pending-marker.mjs +0 -99
- package/dist/orchestrators/snapshot/pending-marker.mjs.map +0 -1
- package/dist/orchestrators/snapshot/recover-pending.mjs +0 -223
- package/dist/orchestrators/snapshot/recover-pending.mjs.map +0 -1
- package/dist/orchestrators/snapshot/state-document.d.mts +0 -1
- package/dist/orchestrators/snapshot/state-document.mjs +0 -58
- package/dist/orchestrators/snapshot/state-document.mjs.map +0 -1
- package/dist/plugins/account/spans.mjs +0 -16
- package/dist/plugins/account/spans.mjs.map +0 -1
- package/dist/plugins/account/variants/env.mjs +0 -24
- package/dist/plugins/account/variants/env.mjs.map +0 -1
- package/dist/plugins/account/variants/inline.mjs +0 -13
- package/dist/plugins/account/variants/inline.mjs.map +0 -1
- package/dist/plugins/account/variants/keystore.mjs +0 -91
- package/dist/plugins/account/variants/keystore.mjs.map +0 -1
- package/dist/plugins/action/spans.mjs +0 -11
- package/dist/plugins/action/spans.mjs.map +0 -1
- package/dist/plugins/coin/spans.mjs +0 -20
- package/dist/plugins/coin/spans.mjs.map +0 -1
- package/dist/plugins/deepbook/spans.mjs +0 -18
- package/dist/plugins/deepbook/spans.mjs.map +0 -1
- package/dist/plugins/faucet/spans.mjs +0 -12
- package/dist/plugins/faucet/spans.mjs.map +0 -1
- package/dist/plugins/package/spans.mjs +0 -14
- package/dist/plugins/package/spans.mjs.map +0 -1
- package/dist/plugins/postgres/codegen.mjs +0 -42
- package/dist/plugins/postgres/codegen.mjs.map +0 -1
- package/dist/plugins/postgres/connection.d.mts +0 -33
- package/dist/plugins/postgres/connection.mjs.map +0 -1
- package/dist/plugins/postgres/db-ensure.mjs.map +0 -1
- package/dist/plugins/postgres/errors.d.mts +0 -60
- package/dist/plugins/postgres/errors.mjs +0 -29
- package/dist/plugins/postgres/errors.mjs.map +0 -1
- package/dist/plugins/postgres/index.d.mts +0 -37
- package/dist/plugins/postgres/index.mjs +0 -68
- package/dist/plugins/postgres/index.mjs.map +0 -1
- package/dist/plugins/postgres/routable.mjs +0 -33
- package/dist/plugins/postgres/routable.mjs.map +0 -1
- package/dist/plugins/postgres/service.d.mts +0 -50
- package/dist/plugins/postgres/service.mjs +0 -179
- package/dist/plugins/postgres/service.mjs.map +0 -1
- package/dist/plugins/postgres/snapshot.mjs +0 -32
- package/dist/plugins/postgres/snapshot.mjs.map +0 -1
- package/dist/plugins/postgres/spans.mjs +0 -11
- package/dist/plugins/postgres/spans.mjs.map +0 -1
- package/dist/plugins/seal/spans.mjs +0 -18
- package/dist/plugins/seal/spans.mjs.map +0 -1
- package/dist/plugins/sui/spans.mjs +0 -17
- package/dist/plugins/sui/spans.mjs.map +0 -1
- package/dist/plugins/wallet/spans.mjs +0 -22
- package/dist/plugins/wallet/spans.mjs.map +0 -1
- package/dist/plugins/walrus/registry-publish.d.mts +0 -24
- package/dist/plugins/walrus/spans.mjs +0 -18
- package/dist/plugins/walrus/spans.mjs.map +0 -1
- package/dist/runtime/docker/logs.d.mts +0 -1
- package/dist/runtime/docker/logs.mjs +0 -34
- package/dist/runtime/docker/logs.mjs.map +0 -1
- package/dist/substrate/runtime/artifact-publisher/index.mjs +0 -86
- package/dist/substrate/runtime/artifact-publisher/index.mjs.map +0 -1
- package/dist/substrate/runtime/capability-sinks/index.d.mts +0 -1
- package/dist/substrate/runtime/capability-sinks/index.mjs +0 -3
- package/dist/substrate/runtime/capability-sinks/layer.d.mts +0 -1
- package/dist/substrate/runtime/capability-sinks/layer.mjs +0 -31
- package/dist/substrate/runtime/capability-sinks/layer.mjs.map +0 -1
- package/dist/substrate/runtime/capability-sinks/service.d.mts +0 -95
- package/dist/substrate/runtime/capability-sinks/service.mjs +0 -69
- package/dist/substrate/runtime/capability-sinks/service.mjs.map +0 -1
- package/dist/substrate/runtime/cross-process/lock.d.mts +0 -1
- package/dist/substrate/runtime/cross-process/lock.mjs +0 -23
- package/dist/substrate/runtime/cross-process/lock.mjs.map +0 -1
- package/dist/substrate/runtime/cross-process/snapshot-reservation.mjs +0 -113
- package/dist/substrate/runtime/cross-process/snapshot-reservation.mjs.map +0 -1
- package/dist/substrate/runtime/lifecycle/lifecycle-fact.mjs +0 -31
- package/dist/substrate/runtime/lifecycle/lifecycle-fact.mjs.map +0 -1
- package/dist/substrate/runtime/observability/formatter-registry.d.mts +0 -1
- package/dist/substrate/runtime/observability/formatter-registry.mjs +0 -48
- package/dist/substrate/runtime/observability/formatter-registry.mjs.map +0 -1
- package/dist/substrate/runtime/observability/span-store.d.mts +0 -1
- package/dist/substrate/runtime/observability/span-store.mjs +0 -110
- package/dist/substrate/runtime/observability/span-store.mjs.map +0 -1
- package/dist/substrate/runtime/observability/spans.d.mts +0 -1
- package/dist/substrate/runtime/observability/spans.mjs +0 -87
- package/dist/substrate/runtime/observability/spans.mjs.map +0 -1
- package/dist/substrate/runtime/projection/index.mjs +0 -4
- package/dist/substrate/runtime/projection/persisted.mjs +0 -213
- package/dist/substrate/runtime/projection/persisted.mjs.map +0 -1
- package/dist/substrate/runtime/scoped-multimap/service.mjs +0 -52
- package/dist/substrate/runtime/scoped-multimap/service.mjs.map +0 -1
- package/dist/substrate/runtime/scoped-ref-map/index.mjs +0 -2
- package/dist/substrate/runtime/scoped-ref-map/service.mjs +0 -83
- package/dist/substrate/runtime/scoped-ref-map/service.mjs.map +0 -1
- package/dist/substrate/runtime/state-store/index.mjs +0 -3
- package/dist/substrate/runtime/state-store/schema.d.mts +0 -1
- package/dist/substrate/runtime/state-store/schema.mjs +0 -41
- package/dist/substrate/runtime/state-store/schema.mjs.map +0 -1
- package/dist/substrate/runtime/state-store/service.d.mts +0 -1
- package/dist/substrate/runtime/state-store/service.mjs +0 -145
- package/dist/substrate/runtime/state-store/service.mjs.map +0 -1
- package/dist/substrate/runtime/sui-execute/index.mjs.map +0 -1
- package/dist/substrate/runtime/sui-execute/sign-and-dispatch.mjs.map +0 -1
- package/dist/substrate/runtime/sui-ledger/object-ref.mjs.map +0 -1
- package/dist/substrate/runtime/sui-move-build/index.mjs.map +0 -1
- package/dist/substrate/runtime/supervisor/dispatch-contributions.mjs +0 -151
- package/dist/substrate/runtime/supervisor/dispatch-contributions.mjs.map +0 -1
- package/dist/substrate/state-store.d.mts +0 -1
- /package/dist/orchestrators/{snapshot/pending-marker.d.mts → codegen/id-config.d.mts} +0 -0
- /package/dist/orchestrators/snapshot/{recover-pending.d.mts → interrupted-restore.d.mts} +0 -0
- /package/dist/{substrate/runtime/sui-execute → plugins/sui/exec}/sign-and-dispatch.d.mts +0 -0
- /package/dist/plugins/{postgres/snapshot.d.mts → sui/ledger/object-ref.d.mts} +0 -0
- /package/dist/{substrate/runtime/sui-move-build → plugins/sui/move}/index.d.mts +0 -0
- /package/dist/substrate/runtime/{state-store/index.d.mts → reconcile/graph.d.mts} +0 -0
- /package/dist/substrate/runtime/{cross-process/snapshot-reservation.d.mts → supervisor/contribution-dispatcher.d.mts} +0 -0
|
@@ -1,22 +1,103 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { keyedBucketSpec, liveBucketCodegen, staticBucketCodegen } from "../../contracts/config-bindings.mjs";
|
|
2
2
|
//#region src/plugins/coin/codegen.ts
|
|
3
|
-
/**
|
|
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
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
|
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,SAAU,QAAO;AACtC,KAAI,OAAO,UAAU,YAAY,kBAAkB,MAClD,QAAO,MAAM;;AAKf,MAAM,cAAc,MAA+B,QAAoC;CACtF,MAAM,QAAQ,KAAK;AACnB,QAAO,OAAO,UAAU,YAAY,MAAM,SAAS,IAAI,QAAQ,KAAA;;AAGhE,MAAM,cAAc,MAA+B,QAAoC;CACtF,MAAM,QAAQ,KAAK;AACnB,QAAO,OAAO,UAAU,YAAY,OAAO,SAAS,MAAM,GAAG,QAAQ,KAAA;;;;;;;AAQtE,MAAM,gBACL,WAC6C;CAC7C,MAAM,OAAO,OAAO;AACpB,KAAI,SAAS,QAAQ,OAAO,SAAS,YAAY,MAAM,QAAQ,KAAK,CAAE,QAAO,EAAE;CA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G,KAAK,MAAM,EAAE,GAAG,SAAS,MAAM,CAAC,CAAC;CACtE,MAAM,UAAiC,EAAE;AACzC,MAAK,MAAM,gBAAgB,UAAU;EACpC,MAAM,QAAQ,cAAc,aAAa;AACzC,MAAI,CAAC,MAAO;EACZ,MAAM,MAAM,KAAK,IAAI,aAAa;EAClC,MAAM,OAAO,SAAS,IAAI,aAAa;EACvC,MAAM,mBAAmB,QAAQ,KAAA,KAAa,IAAI,UAAU;AAC5D,UAAQ,KAAK;GACZ;GACA,SAAS,MAAM,QAAQ,aAAa;GACpC,YAAY,MAAM,WAAW,aAAa;GAC1C,eAAe,KAAK;GACpB,kBAAkB,KAAK;GACvB,YAAY,MAAM;GAClB,GAAI,MAAM,aAAa,KAAA,IAAY,EAAE,GAAG,EAAE,UAAU,KAAK,UAAU;GACnE,GAAI,MAAM,WAAW,KAAA,IAAY,EAAE,GAAG,EAAE,QAAQ,KAAK,QAAQ;GAC7D,GAAI,MAAM,gBAAgB,KAAA,IAAY,EAAE,GAAG,EAAE,aAAa,KAAK,aAAa;GAC5E,GAAI,MAAM,YAAY,KAAA,IAAY,EAAE,GAAG,EAAE,SAAS,KAAK,SAAS;GAChE;GACA,CAAC;;AAKH,SAAQ,MAAM,GAAG,MAChB,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;CACrC,IAAI,MAAM,WAAW,GAAG,OAAO;CAC/B,MAAM,GAAG,YAAY,WAAW;CAChC,IAAI,eAAe,KAAA,KAAa,YAAY,KAAA,GAAW,OAAO;CAC9D,OAAO;EAAE;EAAY;CAAQ;AAC9B;;;;;AAMA,MAAM,oBAAoB,WAA0D;CACnF,MAAM,QAAQ,OAAO;CAIrB,IAAI,UAAU,KAAA,KAAa,UAAU,MAAM,OAAO,KAAA;CAClD,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,IAAI,OAAO,UAAU,YAAY,kBAAkB,OAClD,OAAO,MAAM;AAGf;AAEA,MAAM,cAAc,MAA+B,QAAoC;CACtF,MAAM,QAAQ,KAAK;CACnB,OAAO,OAA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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 {
|
|
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//
|
|
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 {
|
|
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
|
|
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
|
-
}>[]
|
|
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
|
-
}>[]
|
|
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 {
|
|
4
|
-
import "
|
|
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
|
|
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
|
|
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
|
|
117
|
+
const ctx = yield* PluginContext;
|
|
118
|
+
const artifactPublisher = yield* CacheService;
|
|
115
119
|
const registry = yield* CoinRegistryService;
|
|
116
|
-
|
|
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
|
-
|
|
128
|
+
chainId: sui.chainId,
|
|
125
129
|
publisher: artifactPublisher
|
|
126
130
|
});
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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
|
|
156
|
+
const ctx = yield* PluginContext;
|
|
157
|
+
const publisher = yield* CacheService;
|
|
148
158
|
const registry = yield* CoinRegistryService;
|
|
149
|
-
|
|
159
|
+
const value = yield* acquireCoin({
|
|
150
160
|
kind: "known",
|
|
151
161
|
fullCoinType
|
|
152
162
|
}, {
|
|
153
163
|
registry,
|
|
154
164
|
sdk: projectCoinSdk(sui),
|
|
155
|
-
|
|
165
|
+
chainId: sui.chainId,
|
|
156
166
|
publisher
|
|
157
167
|
});
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
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
|
|
192
|
+
const ctx = yield* PluginContext;
|
|
193
|
+
const publisher = yield* CacheService;
|
|
175
194
|
const registry = yield* CoinRegistryService;
|
|
176
|
-
|
|
195
|
+
const value = yield* acquireCoin({
|
|
177
196
|
kind: "builtin",
|
|
178
197
|
name
|
|
179
198
|
}, {
|
|
180
199
|
registry,
|
|
181
200
|
sdk: projectCoinSdk(sui),
|
|
182
|
-
|
|
201
|
+
chainId: sui.chainId,
|
|
183
202
|
publisher
|
|
184
203
|
});
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
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,I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ACA,KAAK,eAAe,IAAI;IACxB,OAAO,IAAI;IACX;IACA,CAAC;IACD;EACH,oBAAoB;EACpB,eAAe,EAAE,YAAY,kBAAkB,QAAQ,MAAM;EAC7D,CAAC;;;;;AAUH,MAAa,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,W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