@mysten-incubation/devstack 0.2.0 → 0.4.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 +1 -1
- package/dashboard-ui/assets/{grpc-a4usE3Nk.js → grpc-CpkDu4SA.js} +1 -1
- package/dashboard-ui/assets/{index-CRYJ4pru.js → index-jLPRmjst.js} +39 -33
- package/dashboard-ui/index.html +1 -1
- package/dist/api/inference-network.d.mts +5 -5
- package/dist/api/inference-network.mjs +5 -5
- package/dist/api/inference-network.mjs.map +1 -1
- package/dist/api/run-stack-internal.mjs +2 -3
- package/dist/api/run-stack-internal.mjs.map +1 -1
- package/dist/build-integrations/dapp-kit/index.d.mts +12 -0
- package/dist/build-integrations/dapp-kit/index.mjs +14 -1
- package/dist/build-integrations/dapp-kit/index.mjs.map +1 -1
- package/dist/build-integrations/playwright/config.d.mts +2 -1
- package/dist/build-integrations/playwright/config.mjs +1 -1
- package/dist/build-integrations/playwright/config.mjs.map +1 -1
- package/dist/build-integrations/playwright/errors.d.mts +1 -1
- package/dist/build-integrations/playwright/errors.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/wallet-context.d.mts +2 -1
- package/dist/build-integrations/playwright/wallet-context.mjs +141 -41
- package/dist/build-integrations/playwright/wallet-context.mjs.map +1 -1
- package/dist/build-integrations/runtime/dapp-kit-slot.mjs +1 -1
- package/dist/build-integrations/runtime/dapp-kit-slot.mjs.map +1 -1
- package/dist/build-integrations/vite/index.d.mts +82 -40
- package/dist/build-integrations/vite/index.mjs +281 -112
- package/dist/build-integrations/vite/index.mjs.map +1 -1
- package/dist/build-integrations/vitest/config.mjs +3 -4
- package/dist/build-integrations/vitest/config.mjs.map +1 -1
- package/dist/build-integrations/vitest/global-setup.mjs +8 -8
- package/dist/build-integrations/vitest/global-setup.mjs.map +1 -1
- package/dist/cli/doctor-probes.mjs +7 -2
- package/dist/cli/doctor-probes.mjs.map +1 -1
- package/dist/cli/main.mjs +5 -4
- package/dist/cli/main.mjs.map +1 -1
- package/dist/cli/wirings/apply.mjs +0 -1
- package/dist/cli/wirings/apply.mjs.map +1 -1
- package/dist/cli/wirings/codegen.mjs +37 -38
- package/dist/cli/wirings/codegen.mjs.map +1 -1
- package/dist/cli/wirings/dump-deployment.mjs +141 -0
- package/dist/cli/wirings/dump-deployment.mjs.map +1 -0
- package/dist/cli/wirings/snapshot.mjs +0 -1
- package/dist/cli/wirings/snapshot.mjs.map +1 -1
- package/dist/cli/wirings/up.mjs +7 -0
- package/dist/cli/wirings/up.mjs.map +1 -1
- package/dist/contracts/codegenable.d.mts +22 -25
- package/dist/contracts/codegenable.mjs +35 -4
- package/dist/contracts/codegenable.mjs.map +1 -1
- package/dist/contracts/config-bindings.mjs +43 -18
- package/dist/contracts/config-bindings.mjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/orchestrators/boot.d.mts +0 -10
- package/dist/orchestrators/boot.mjs +24 -54
- package/dist/orchestrators/boot.mjs.map +1 -1
- package/dist/orchestrators/codegen/bindings.mjs.map +1 -1
- package/dist/orchestrators/codegen/config-runtime.mjs +137 -112
- package/dist/orchestrators/codegen/config-runtime.mjs.map +1 -1
- package/dist/orchestrators/codegen/deployment-network-file.mjs +130 -0
- package/dist/orchestrators/codegen/deployment-network-file.mjs.map +1 -0
- package/dist/orchestrators/codegen/deployment-strict.mjs +77 -0
- package/dist/orchestrators/codegen/deployment-strict.mjs.map +1 -0
- package/dist/orchestrators/codegen/deployment.d.mts +63 -0
- package/dist/orchestrators/codegen/deployment.mjs +153 -0
- package/dist/orchestrators/codegen/deployment.mjs.map +1 -0
- package/dist/orchestrators/codegen/errors.mjs +7 -9
- package/dist/orchestrators/codegen/errors.mjs.map +1 -1
- package/dist/orchestrators/codegen/format.mjs +20 -1
- package/dist/orchestrators/codegen/format.mjs.map +1 -1
- package/dist/orchestrators/codegen/paths.mjs +1 -8
- package/dist/orchestrators/codegen/paths.mjs.map +1 -1
- package/dist/orchestrators/codegen/service.mjs +369 -141
- package/dist/orchestrators/codegen/service.mjs.map +1 -1
- package/dist/orchestrators/layers.mjs +0 -1
- package/dist/orchestrators/layers.mjs.map +1 -1
- package/dist/orchestrators/network-options.d.mts +37 -35
- package/dist/orchestrators/network-options.mjs +13 -10
- package/dist/orchestrators/network-options.mjs.map +1 -1
- package/dist/plugins/account/codegen.d.mts +3 -4
- package/dist/plugins/account/codegen.mjs +5 -7
- package/dist/plugins/account/codegen.mjs.map +1 -1
- package/dist/plugins/account/index.mjs +1 -3
- package/dist/plugins/account/index.mjs.map +1 -1
- package/dist/plugins/coin/codegen.mjs +5 -5
- package/dist/plugins/coin/codegen.mjs.map +1 -1
- package/dist/plugins/coin/index.mjs.map +1 -1
- package/dist/plugins/dashboard/domain.mjs +18 -1
- package/dist/plugins/dashboard/domain.mjs.map +1 -1
- package/dist/plugins/dashboard/schema/root.mjs +5 -3
- package/dist/plugins/dashboard/schema/root.mjs.map +1 -1
- package/dist/plugins/dashboard/schema/types.mjs +15 -2
- package/dist/plugins/dashboard/schema/types.mjs.map +1 -1
- package/dist/plugins/deepbook/codegen.mjs +4 -4
- package/dist/plugins/deepbook/codegen.mjs.map +1 -1
- package/dist/plugins/deepbook/index.d.mts +7 -3
- package/dist/plugins/deepbook/index.mjs +3 -3
- package/dist/plugins/deepbook/index.mjs.map +1 -1
- package/dist/plugins/internal/codegen-helpers.mjs +0 -1
- package/dist/plugins/internal/codegen-helpers.mjs.map +1 -1
- package/dist/plugins/package/codegen.d.mts +1 -12
- package/dist/plugins/package/codegen.mjs +43 -25
- package/dist/plugins/package/codegen.mjs.map +1 -1
- package/dist/plugins/package/dep-resolution.mjs +1 -1
- package/dist/plugins/package/dep-resolution.mjs.map +1 -1
- package/dist/plugins/package/index.d.mts +14 -11
- package/dist/plugins/package/index.mjs +6 -7
- package/dist/plugins/package/index.mjs.map +1 -1
- package/dist/plugins/seal/codegen.mjs +3 -3
- package/dist/plugins/seal/codegen.mjs.map +1 -1
- package/dist/plugins/seal/index.mjs.map +1 -1
- package/dist/plugins/sui/codegen.mjs +5 -4
- package/dist/plugins/sui/codegen.mjs.map +1 -1
- package/dist/plugins/sui/index.d.mts +10 -10
- package/dist/plugins/sui/index.mjs +1 -2
- package/dist/plugins/sui/index.mjs.map +1 -1
- package/dist/plugins/sui/move-summary-runner.mjs +29 -2
- package/dist/plugins/sui/move-summary-runner.mjs.map +1 -1
- package/dist/plugins/wallet/codegen.d.mts +8 -12
- package/dist/plugins/wallet/codegen.mjs +22 -15
- package/dist/plugins/wallet/codegen.mjs.map +1 -1
- package/dist/plugins/wallet/index.d.mts +4 -3
- package/dist/plugins/wallet/index.mjs +1 -1
- package/dist/plugins/wallet/index.mjs.map +1 -1
- package/dist/plugins/wallet/service.d.mts +2 -2
- package/dist/plugins/wallet/service.mjs +2 -3
- package/dist/plugins/wallet/service.mjs.map +1 -1
- package/dist/plugins/walrus/codegen.mjs +4 -4
- package/dist/plugins/walrus/codegen.mjs.map +1 -1
- package/dist/plugins/walrus/index.mjs +1 -1
- package/dist/plugins/walrus/index.mjs.map +1 -1
- package/dist/substrate/manifest.d.mts +17 -22
- package/dist/substrate/manifest.mjs +4 -6
- package/dist/substrate/manifest.mjs.map +1 -1
- package/dist/substrate/plugin-ctx.d.mts +6 -6
- package/dist/substrate/plugin-ctx.mjs.map +1 -1
- package/dist/substrate/runtime/cross-process/liveness.mjs.map +1 -1
- package/dist/substrate/runtime/index.mjs +1 -0
- package/dist/substrate/runtime/lifecycle/file-watcher.d.mts +1 -0
- package/dist/substrate/runtime/lifecycle/file-watcher.mjs +54 -0
- package/dist/substrate/runtime/lifecycle/file-watcher.mjs.map +1 -0
- package/dist/substrate/runtime/lifecycle/index.mjs +1 -0
- package/dist/substrate/runtime/lifecycle/watch-attribution.mjs +76 -6
- package/dist/substrate/runtime/lifecycle/watch-attribution.mjs.map +1 -1
- package/dist/substrate/runtime/manifest/manifest.mjs.map +1 -1
- package/dist/substrate/runtime/paths.mjs +1 -1
- package/dist/substrate/runtime/supervisor/start-supervisor.mjs +2 -6
- package/dist/substrate/runtime/supervisor/start-supervisor.mjs.map +1 -1
- package/dist/surfaces/cli/command-tree.mjs +6 -6
- package/dist/surfaces/cli/command-tree.mjs.map +1 -1
- package/dist/surfaces/cli/index.mjs +6 -4
- package/dist/surfaces/cli/index.mjs.map +1 -1
- package/dist/surfaces/tui/plain-renderer.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/cli/wirings/dump-ids.mjs +0 -86
- package/dist/cli/wirings/dump-ids.mjs.map +0 -1
- package/dist/orchestrators/codegen/id-config.d.mts +0 -1
- package/dist/orchestrators/codegen/id-config.mjs +0 -107
- package/dist/orchestrators/codegen/id-config.mjs.map +0 -1
- package/dist/orchestrators/codegen/output-location.mjs +0 -32
- package/dist/orchestrators/codegen/output-location.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bindings.mjs","names":[],"sources":["../../../src/orchestrators/codegen/bindings.ts"],"sourcesContent":["// Move-package bindings emission.\n//\n// Distilled-doc § \"Move-to-TS bindings: per-published-package typed\n// client modules produced from each local Move package's summary.\"\n// Drives `@mysten/codegen`'s `generateFromPackageSummary` against\n// `MoveSummary` JSON contributed by a plugin-owned\n// `MoveSummaryRunnerService`.\n//\n// sourcePath-known-vs-unknown discipline:\n// - `Package` plugin's `Codegenable` emits a `PackageBindings`\n// shape with `sourcePath: string | null`.\n// - The bindings emitter filters to `sourcePath !== null` (i.e.\n// LOCAL packages); `KnownPackage` entries (`sourcePath: null`)\n// are skipped — their bindings come from the SDK or MVR.\n//\n// Architecture seam:\n// - `MoveSummaryRunnerService` is contributed by a plugin (the\n// sui plugin ships `layerSuiMoveSummaryRunnerDocker` /\n// `layerSuiMoveSummaryRunnerHost`). The codegen orchestrator\n// consumes only the abstract service — it never names the Sui\n// CLI binary or container image (architecture: \"Orchestrator\n// boundaries — never names a service\").\n// - The call to `@mysten/codegen.generateFromPackageSummary` is\n// similarly behind a tagged service so unit tests can stub it\n// without pulling in the heavyweight `@mysten/codegen` graph.\n//\n// Distilled-doc § \"Silent no-op from a downstream tool is a\n// failure\": after summary + render, we probe the output dir.\n// If it's empty, that's a `CodegenBindingsFailed` with a hint about\n// the common `Move.toml` `[addresses]` cause.\n\nimport { mkdtemp, readdir, readFile, rm } from 'node:fs/promises';\nimport { tmpdir } from 'node:os';\nimport { join, relative, sep } from 'node:path';\n\nimport { generateFromPackageSummary } from '@mysten/codegen';\nimport { Context, Effect, FileSystem, Layer } from 'effect';\n\nimport type { ImageRef } from '../../contracts/container-runtime.ts';\n\nimport { emitOne } from './emit.ts';\nimport { CodegenBindingsFailed } from './errors.ts';\nimport { NON_SENSITIVE_DIR_MODE, NON_SENSITIVE_FILE_MODE } from './permissions.ts';\n\n// -----------------------------------------------------------------------------\n// Service seam — Move summary + codegen invocation\n// -----------------------------------------------------------------------------\n\n/** Result of `sui move summary` — opaque JSON the codegen generator\n * consumes. We don't decode it here; `@mysten/codegen` owns the\n * schema. */\nexport interface MoveSummary {\n\treadonly packageName: string;\n\treadonly sourcePath: string;\n\treadonly summaryPath?: string;\n\treadonly cleanupPath?: string;\n\treadonly summaryJson: unknown;\n}\n\nexport interface MoveSummaryInput {\n\treadonly packageName: string;\n\treadonly sourcePath: string;\n\treadonly buildImage?: ImageRef | null;\n}\n\n/** Shape of the Move summary runner. Implementations live in\n * plugin packages (e.g. `plugins/sui/move-summary-runner.ts`\n * exports `layerSuiMoveSummaryRunnerDocker` and\n * `layerSuiMoveSummaryRunnerHost`); tests use `stubMoveSummaryRunner`\n * below. */\nexport interface MoveSummaryRunner {\n\treadonly runSummary: (\n\t\tinput: MoveSummaryInput,\n\t) => Effect.Effect<MoveSummary, CodegenBindingsFailed>;\n}\n\nexport class MoveSummaryRunnerService extends Context.Service<\n\tMoveSummaryRunnerService,\n\tMoveSummaryRunner\n>()('@devstack/orchestrator/MoveSummaryRunner') {}\n\n/** Shape of the `@mysten/codegen` invocation. Returns the rendered\n * TS files (path → content) for one package. */\nexport interface MoveCodegen {\n\treadonly generate: (input: {\n\t\treadonly packageName: string;\n\t\treadonly sourcePath: string;\n\t\treadonly summary: MoveSummary;\n\t\treadonly mvrPlaceholder: string;\n\t\treadonly importExtension: '.ts' | '.js' | '';\n\t}) => Effect.Effect<\n\t\tReadonlyArray<{ readonly relPath: string; readonly content: string }>,\n\t\tCodegenBindingsFailed\n\t>;\n}\n\nexport class MoveCodegenService extends Context.Service<MoveCodegenService, MoveCodegen>()(\n\t'@devstack/orchestrator/MoveCodegen',\n) {}\n\n// -----------------------------------------------------------------------------\n// Public entry — emit bindings for the local packages in a set of\n// PackageBindings contributions.\n// -----------------------------------------------------------------------------\n\nexport interface PackageBindings {\n\treadonly name: string;\n\treadonly packageId: string;\n\treadonly mvrPlaceholder: string;\n\treadonly sourcePath: string | null;\n\treadonly excluded: boolean;\n}\n\n/**\n * Consumer-side shape guard: does an aggregated value look like a\n * Move-bindings contribution that `emitBindings` knows how to consume?\n * This is structural validation of the orchestrator's own input\n * contract, NOT a plugin-name match — any plugin whose\n * `aggregate.project` returns objects with this shape is forwarded to\n * the Move bindings emitter. The single definition of the seam; both\n * the codegen orchestrator service and the Package plugin reference it.\n */\nexport const isPackageBindings = (v: unknown): v is PackageBindings =>\n\ttypeof v === 'object' &&\n\tv !== null &&\n\t'name' in v &&\n\t'packageId' in v &&\n\t'mvrPlaceholder' in v &&\n\t'sourcePath' in v;\n\nexport interface EmitBindingsInput {\n\treadonly bindingsDir: string;\n\treadonly packages: ReadonlyArray<PackageBindings>;\n\treadonly importExtension?: '.ts' | '.js' | '';\n}\n\nexport interface EmitBindingsResult {\n\treadonly packagesEmitted: ReadonlyArray<string>;\n\treadonly packagesSkipped: ReadonlyArray<string>;\n\treadonly filesWritten: ReadonlyArray<string>;\n}\n\n/**\n * Walk the `PackageBindings` set, filter to LOCAL packages\n * (`sourcePath !== null`), run `sui move summary` + `@mysten/codegen`\n * for each, and write the rendered files into `bindingsDir/<name>/`.\n *\n * Serial within a cycle (distilled-doc § \"Serial within a cycle\":\n * shared Move build cache races). Per-package parallelism is unsafe.\n */\nexport const emitBindings = (\n\tinput: EmitBindingsInput,\n): Effect.Effect<\n\tEmitBindingsResult,\n\tCodegenBindingsFailed,\n\tFileSystem.FileSystem | MoveSummaryRunnerService | MoveCodegenService\n> =>\n\tEffect.gen(function* () {\n\t\tconst runner = yield* MoveSummaryRunnerService;\n\t\tconst generator = yield* MoveCodegenService;\n\t\tconst importExtension = input.importExtension ?? '.ts';\n\n\t\t// Dedup by package name. First-wins; distilled-doc § \"Duplicate\n\t\t// package names\": warn + skip the duplicate to avoid the HMR\n\t\t// re-emit storm.\n\t\t// Dedup by package IDENTITY (packageId + sourcePath), keyed for\n\t\t// lookup by name. The SAME package legitimately appears more than\n\t\t// once in the contribution set (e.g. the plugin's localPackage\n\t\t// binding AND a coin's package reference both point at it) — that\n\t\t// is a benign self-duplicate and is skipped SILENTLY. We only warn\n\t\t// when two genuinely DIFFERENT packages (different id/sourcePath)\n\t\t// collide on the same name, which is the real HMR re-emit hazard.\n\t\tconst seenIdentityByName = new Map<string, string>();\n\t\tconst identityOf = (pkg: PackageBindings): string => `${pkg.packageId} ${pkg.sourcePath ?? ''}`;\n\t\tconst targets: Array<PackageBindings> = [];\n\t\tconst skipped: Array<string> = [];\n\t\tfor (const pkg of input.packages) {\n\t\t\tif (pkg.sourcePath === null) {\n\t\t\t\tskipped.push(pkg.name);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (pkg.excluded) {\n\t\t\t\tskipped.push(pkg.name);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst identity = identityOf(pkg);\n\t\t\tconst seenIdentity = seenIdentityByName.get(pkg.name);\n\t\t\tif (seenIdentity !== undefined) {\n\t\t\t\tif (seenIdentity !== identity) {\n\t\t\t\t\t// Two genuinely DIFFERENT packages share a name — a real\n\t\t\t\t\t// collision and a real HMR re-emit hazard.\n\t\t\t\t\tyield* Effect.logWarning(\n\t\t\t\t\t\t`codegen.bindings: duplicate package name '${pkg.name}' — keeping ` +\n\t\t\t\t\t\t\t`first and skipping duplicate to avoid HMR re-emit storm. ` +\n\t\t\t\t\t\t\t`Rename one of the packages.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// Same identity → benign self-duplicate (e.g. localPackage +\n\t\t\t\t// coin package ref): skip silently, no warning.\n\t\t\t\tskipped.push(pkg.name);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tseenIdentityByName.set(pkg.name, identity);\n\t\t\ttargets.push(pkg);\n\t\t}\n\t\t// Deterministic order: lexicographic by package name.\n\t\ttargets.sort((a, b) => a.name.localeCompare(b.name));\n\n\t\tconst emitted: Array<string> = [];\n\t\tconst filesWritten: Array<string> = [];\n\t\tfor (const pkg of targets) {\n\t\t\t// sourcePath is non-null per the filter above. Narrow.\n\t\t\tif (pkg.sourcePath === null) continue;\n\t\t\tconst summary = yield* runner.runSummary({\n\t\t\t\tpackageName: pkg.name,\n\t\t\t\tsourcePath: pkg.sourcePath,\n\t\t\t});\n\t\t\tconst files = yield* generator.generate({\n\t\t\t\tpackageName: pkg.name,\n\t\t\t\tsourcePath: pkg.sourcePath,\n\t\t\t\tsummary,\n\t\t\t\tmvrPlaceholder: pkg.mvrPlaceholder,\n\t\t\t\timportExtension,\n\t\t\t});\n\t\t\t// Post-emit probe — silent no-op detection.\n\t\t\tif (files.length === 0) {\n\t\t\t\treturn yield* Effect.fail(\n\t\t\t\t\tnew CodegenBindingsFailed({\n\t\t\t\t\t\tpackage: pkg.name,\n\t\t\t\t\t\tsourcePath: pkg.sourcePath,\n\t\t\t\t\t\treason: 'no-output',\n\t\t\t\t\t\thint:\n\t\t\t\t\t\t\t'The Move codegen generator produced no files. This is ' +\n\t\t\t\t\t\t\t'usually caused by a missing `[addresses]` block in the ' +\n\t\t\t\t\t\t\t\"package's Move.toml, or a non-published address mapping.\",\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t\tfor (const f of files) {\n\t\t\t\tif (f.relPath.includes('..') || f.relPath.startsWith('/')) {\n\t\t\t\t\treturn yield* Effect.fail(\n\t\t\t\t\t\tnew CodegenBindingsFailed({\n\t\t\t\t\t\t\tpackage: pkg.name,\n\t\t\t\t\t\t\tsourcePath: pkg.sourcePath,\n\t\t\t\t\t\t\treason: 'write-failed',\n\t\t\t\t\t\t\tcause: new Error(`generated binding path escapes output dir: ${f.relPath}`),\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst abs = joinPath(input.bindingsDir, f.relPath);\n\t\t\t\tconst outcome = yield* emitOne({\n\t\t\t\t\tpath: abs,\n\t\t\t\t\tcontent: stabilizeGeneratedBindingContent(f.content),\n\t\t\t\t\tmode: NON_SENSITIVE_FILE_MODE,\n\t\t\t\t\tparentMode: NON_SENSITIVE_DIR_MODE,\n\t\t\t\t}).pipe(\n\t\t\t\t\tEffect.mapError(\n\t\t\t\t\t\t(cause) =>\n\t\t\t\t\t\t\tnew CodegenBindingsFailed({\n\t\t\t\t\t\t\t\tpackage: pkg.name,\n\t\t\t\t\t\t\t\tsourcePath: pkg.sourcePath!,\n\t\t\t\t\t\t\t\treason: 'write-failed',\n\t\t\t\t\t\t\t\tcause,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tif (outcome.outcome !== 'unchanged') {\n\t\t\t\t\tfilesWritten.push(abs);\n\t\t\t\t}\n\t\t\t}\n\t\t\temitted.push(pkg.name);\n\t\t}\n\n\t\treturn {\n\t\t\tpackagesEmitted: emitted,\n\t\t\tpackagesSkipped: skipped,\n\t\t\tfilesWritten,\n\t\t};\n\t});\n\n// -----------------------------------------------------------------------------\n// Stub implementations for tests\n// -----------------------------------------------------------------------------\n\n/** Stub runner — returns a synthetic summary. Used in unit tests\n * to exercise the bindings pipeline without a real `sui` binary. */\nexport const stubMoveSummaryRunner = (\n\tsummaryFor: (sourcePath: string) => MoveSummary,\n): MoveSummaryRunner => ({\n\trunSummary: ({ sourcePath }) => Effect.succeed(summaryFor(sourcePath)),\n});\n\n/** Stub generator — returns a synthetic file set. Used in unit\n * tests to exercise the bindings pipeline without pulling in the\n * heavyweight `@mysten/codegen` graph. */\nexport const stubMoveCodegen = (\n\tfiles: (\n\t\tinput: Parameters<MoveCodegen['generate']>[0],\n\t) => ReadonlyArray<{ readonly relPath: string; readonly content: string }>,\n): MoveCodegen => ({\n\tgenerate: (input) => Effect.succeed(files(input)),\n});\n\n// -----------------------------------------------------------------------------\n// Production implementations\n// -----------------------------------------------------------------------------\n//\n// Layer factories for `MoveSummaryRunnerService` are plugin-owned —\n// they live in `src/plugins/sui/move-summary-runner.ts`. The codegen\n// orchestrator does not name the Sui CLI binary or container image;\n// per \"Orchestrator boundaries — never names a service\", any plugin\n// that can produce `MoveSummary` JSON may contribute a runner Layer.\n\nexport const layerMystenMoveCodegen = (\n\toptions: {\n\t\t/** Forwarded verbatim to `@mysten/codegen`'s\n\t\t * `generateFromPackageSummary({ includePhantomTypeParameters })`.\n\t\t * Default `false` (`@mysten/codegen`'s own default): phantom-only\n\t\t * structs render as plain consts with the `<phantom T>` placeholder\n\t\t * baked into `.name`. `true` renders them as factory functions whose\n\t\t * phantom type parameters are REQUIRED arguments, so the returned\n\t\t * instance's `.name` is a fully-qualified, composable type tag\n\t\t * (`Pool(DBTC, DUSDC).name`). Static per stack — threaded from\n\t\t * `DevstackOptions['codegen']` through\n\t\t * `resolveProductionCodegenOptions`, never per-cycle. */\n\t\treadonly includePhantomTypeParameters?: boolean;\n\t} = {},\n): Layer.Layer<MoveCodegenService> =>\n\tLayer.succeed(\n\t\tMoveCodegenService,\n\t\tMoveCodegenService.of({\n\t\t\tgenerate: (input) =>\n\t\t\t\tEffect.tryPromise({\n\t\t\t\t\ttry: async () => {\n\t\t\t\t\t\tconst tmp = await mkdtemp(join(tmpdir(), 'devstack-move-codegen-'));\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t// `sui move summary` keys each `package_summaries/<dir>`\n\t\t\t\t\t\t\t// subdirectory by the package's NAMED ADDRESS, not its\n\t\t\t\t\t\t\t// `[package].name`. These legitimately differ (the canonical\n\t\t\t\t\t\t\t// example is MoveStdlib, whose package name is \"MoveStdlib\"\n\t\t\t\t\t\t\t// but whose named address is \"std\"). `@mysten/codegen`'s\n\t\t\t\t\t\t\t// resolver matches the summary subdir by either (1) a single\n\t\t\t\t\t\t\t// `[addresses]` label or (2) the `packageName` — but it reads\n\t\t\t\t\t\t\t// the Move.toml at the path WE pass it (the summary scratch\n\t\t\t\t\t\t\t// dir), which has NO `[addresses]` table, so its label-based\n\t\t\t\t\t\t\t// path (1) is defeated and it falls back to (2). We pass the\n\t\t\t\t\t\t\t// symbolic localPackage() NAME as `packageName`, which is the\n\t\t\t\t\t\t\t// `[package].name`, NOT the named address — so codegen throws\n\t\t\t\t\t\t\t// \"Could not identify main package directory\" whenever the two\n\t\t\t\t\t\t\t// differ. Recover the correct subdir name here from the REAL\n\t\t\t\t\t\t\t// source Move.toml's `[addresses]` table (which devstack still\n\t\t\t\t\t\t\t// has at `input.sourcePath`), falling back to the name when the\n\t\t\t\t\t\t\t// source is unreadable or ambiguous (a no-op for the common\n\t\t\t\t\t\t\t// case where name == address).\n\t\t\t\t\t\t\tconst packageName =\n\t\t\t\t\t\t\t\t(await resolveSummaryDirName(input.sourcePath)) ?? input.packageName;\n\t\t\t\t\t\t\tawait generateFromPackageSummary({\n\t\t\t\t\t\t\t\tpackage: {\n\t\t\t\t\t\t\t\t\tpath: input.summary.summaryPath ?? input.sourcePath,\n\t\t\t\t\t\t\t\t\tpackage: input.mvrPlaceholder,\n\t\t\t\t\t\t\t\t\tpackageName,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tprune: true,\n\t\t\t\t\t\t\t\toutputDir: tmp,\n\t\t\t\t\t\t\t\timportExtension: input.importExtension,\n\t\t\t\t\t\t\t\tincludePhantomTypeParameters: options.includePhantomTypeParameters,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\treturn await collectGeneratedFiles(tmp);\n\t\t\t\t\t\t} finally {\n\t\t\t\t\t\t\tawait rm(tmp, { recursive: true, force: true });\n\t\t\t\t\t\t\tif (input.summary.cleanupPath !== undefined) {\n\t\t\t\t\t\t\t\tawait rm(input.summary.cleanupPath, { recursive: true, force: true });\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tcatch: (cause) =>\n\t\t\t\t\t\tnew CodegenBindingsFailed({\n\t\t\t\t\t\t\tpackage: input.packageName,\n\t\t\t\t\t\t\tsourcePath: input.sourcePath,\n\t\t\t\t\t\t\treason: 'render-failed',\n\t\t\t\t\t\t\tcause,\n\t\t\t\t\t\t}),\n\t\t\t\t}),\n\t\t}),\n\t);\n\n// -----------------------------------------------------------------------------\n// Local helpers — keep the module dep-free of Path.Path so the\n// caller can compose without an extra service yield.\n// -----------------------------------------------------------------------------\n\nconst joinPath = (...parts: ReadonlyArray<string>): string =>\n\tparts.map((p, i) => (i === 0 ? p.replace(/\\/+$/, '') : p.replace(/^\\/+|\\/+$/g, ''))).join('/');\n\n/**\n * Determine the `package_summaries/<dir>` subdirectory name for a local\n * Move package from its REAL source `Move.toml`. `sui move summary` keys\n * these subdirs by the NAMED ADDRESS (e.g. MoveStdlib → \"std\"), not the\n * `[package].name`, so when the two differ we must hand `@mysten/codegen`\n * the address label rather than the symbolic package name.\n *\n * Returns the single `[addresses]` label when the table has exactly one\n * entry (the overwhelmingly common case — and a no-op when name == address),\n * and `null` otherwise (unreadable Move.toml, no `[addresses]` table, or an\n * ambiguous multi-address table) so the caller can fall back to the package\n * name and preserve `@mysten/codegen`'s own resolution.\n *\n * Hand-parse rather than pull in a TOML dependency: the sibling Move-build\n * path already harvests `{ local = \"../x\" }` deps from Move.toml by regex\n * (`plugins/sui/move/index.ts`), and we only need the `[addresses]` section's\n * left-hand labels — never their values.\n */\nconst resolveSummaryDirName = async (sourcePath: string): Promise<string | null> => {\n\tlet toml: string;\n\ttry {\n\t\ttoml = await readFile(join(sourcePath, 'Move.toml'), 'utf8');\n\t} catch {\n\t\treturn null;\n\t}\n\tconst labels = parseAddressLabels(toml);\n\treturn labels.length === 1 ? labels[0]! : null;\n};\n\n/** Left-hand labels of the `[addresses]` table in a Move.toml. Scans from\n * the `[addresses]` header to the next `[section]` header (or EOF) and\n * collects each `name = \"...\"` key, ignoring blank/comment lines. */\nconst parseAddressLabels = (toml: string): ReadonlyArray<string> => {\n\tconst lines = toml.split(/\\r?\\n/);\n\tconst start = lines.findIndex((line) => /^\\s*\\[addresses\\]\\s*$/.test(line));\n\tif (start === -1) return [];\n\tconst labels: Array<string> = [];\n\tfor (const line of lines.slice(start + 1)) {\n\t\t// Next table header ends the `[addresses]` section.\n\t\tif (/^\\s*\\[/.test(line)) break;\n\t\tconst stripped = line.replace(/#.*$/, '').trim();\n\t\tif (stripped === '') continue;\n\t\tconst match = /^([A-Za-z_][\\w-]*)\\s*=/.exec(stripped);\n\t\tif (match) labels.push(match[1]!);\n\t}\n\treturn labels;\n};\n\nconst generatedBcsFactoryPattern =\n\t/export function ([A-Za-z_$][\\w$]*)<((?:[^<>]|<[^<>]*>)+)>\\((\\.\\.\\.typeParameters: \\[[\\s\\S]*?\\n\\])\\) \\{\\n(\\s*)return new (MoveStruct|MoveEnum|MoveTuple)\\(/g;\n\nconst bcsFactoryReturnType = (constructorName: string): string => {\n\tif (constructorName === 'MoveEnum') {\n\t\treturn 'MoveEnum<any, string>';\n\t}\n\tif (constructorName === 'MoveTuple') {\n\t\treturn 'MoveTuple<any, string>';\n\t}\n\treturn 'MoveStruct<any, string>';\n};\n\nconst stabilizeGeneratedBindingContent = (content: string): string =>\n\tcontent.replace(\n\t\tgeneratedBcsFactoryPattern,\n\t\t(_match, name, generics, parameters, indent, constructorName: string) =>\n\t\t\t`export function ${name}<${generics}>(${parameters}): ${bcsFactoryReturnType(\n\t\t\t\tconstructorName,\n\t\t\t)} {\\n${indent}return new ${constructorName}(`,\n\t);\n\nconst collectGeneratedFiles = async (\n\troot: string,\n): Promise<ReadonlyArray<{ readonly relPath: string; readonly content: string }>> => {\n\tconst out: Array<{ readonly relPath: string; readonly content: string }> = [];\n\tconst walk = async (dir: string): Promise<void> => {\n\t\tconst entries = await readdir(dir, { withFileTypes: true });\n\t\tfor (const entry of entries) {\n\t\t\tconst abs = join(dir, entry.name);\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\tawait walk(abs);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!entry.isFile()) continue;\n\t\t\tconst relPath = relative(root, abs).split(sep).join('/');\n\t\t\tout.push({ relPath, content: await readFile(abs, 'utf8') });\n\t\t}\n\t};\n\tawait walk(root);\n\tout.sort((a, b) => a.relPath.localeCompare(b.relPath));\n\treturn out;\n};\n"],"mappings":";;;;;;;;;AA4EA,IAAa,2BAAb,cAA8C,QAAQ,QAGpD,CAAC,CAAC,0CAA0C,CAAC,CAAC,CAAC;AAiBjD,IAAa,qBAAb,cAAwC,QAAQ,QAAyC,CAAC,CACzF,oCACD,CAAC,CAAC,CAAC;;;;;;;;;;AAwBH,MAAa,qBAAqB,MACjC,OAAO,MAAM,YACb,MAAM,QACN,UAAU,KACV,eAAe,KACf,oBAAoB,KACpB,gBAAgB;;;;;;;;;AAsBjB,MAAa,gBACZ,UAMA,OAAO,IAAI,aAAa;CACvB,MAAM,SAAS,OAAO;CACtB,MAAM,YAAY,OAAO;CACzB,MAAM,kBAAkB,MAAM,mBAAmB;CAYjD,MAAM,qCAAqB,IAAI,IAAoB;CACnD,MAAM,cAAc,QAAiC,GAAG,IAAI,UAAU,GAAG,IAAI,cAAc;CAC3F,MAAM,UAAkC,CAAC;CACzC,MAAM,UAAyB,CAAC;CAChC,KAAK,MAAM,OAAO,MAAM,UAAU;EACjC,IAAI,IAAI,eAAe,MAAM;GAC5B,QAAQ,KAAK,IAAI,IAAI;GAC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AAS,SAAS;GAC5B,MAAM,MAAM,KAAK,KAAK,MAAM,IAAI;GAChC,IAAI,MAAM,YAAY,GAAG;IACxB,MAAM,KAAK,GAAG;IACd;GACD;GACA,IAAI,CAAC,MAAM,OAAO,GAAG;GACrB,MAAM,UAAU,SAAS,MAAM,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG;GACvD,IAAI,KAAK;IAAE;IAAS,SAAS,MAAM,SAAS,KAAK,MAAM;GAAE,CAAC;EAC3D;CACD;CACA,MAAM,KAAK,IAAI;CACf,IAAI,MAAM,GAAG,MAAM,EAAE,QAAQ,cAAc,EAAE,OAAO,CAAC;CACrD,OAAO;AACR"}
|
|
1
|
+
{"version":3,"file":"bindings.mjs","names":[],"sources":["../../../src/orchestrators/codegen/bindings.ts"],"sourcesContent":["// Move-package bindings emission.\n//\n// Distilled-doc § \"Move-to-TS bindings: per-published-package typed\n// client modules produced from each local Move package's summary.\"\n// Drives `@mysten/codegen`'s `generateFromPackageSummary` against\n// `MoveSummary` JSON contributed by a plugin-owned\n// `MoveSummaryRunnerService`.\n//\n// sourcePath-known-vs-unknown discipline:\n// - `Package` plugin's `Codegenable` emits a `PackageBindings`\n// shape with `sourcePath: string | null`.\n// - The bindings emitter filters to `sourcePath !== null` (i.e.\n// LOCAL packages); `KnownPackage` entries (`sourcePath: null`)\n// are skipped — their bindings come from the SDK or MVR.\n//\n// Architecture seam:\n// - `MoveSummaryRunnerService` is contributed by a plugin (the\n// sui plugin ships `layerSuiMoveSummaryRunnerDocker` /\n// `layerSuiMoveSummaryRunnerHost`). The codegen orchestrator\n// consumes only the abstract service — it never names the Sui\n// CLI binary or container image (architecture: \"Orchestrator\n// boundaries — never names a service\").\n// - The call to `@mysten/codegen.generateFromPackageSummary` is\n// similarly behind a tagged service so unit tests can stub it\n// without pulling in the heavyweight `@mysten/codegen` graph.\n//\n// Distilled-doc § \"Silent no-op from a downstream tool is a\n// failure\": after summary + render, we probe the output dir.\n// If it's empty, that's a `CodegenBindingsFailed` with a hint about\n// the common `Move.toml` `[addresses]` cause.\n\nimport { mkdtemp, readdir, readFile, rm } from 'node:fs/promises';\nimport { tmpdir } from 'node:os';\nimport { join, relative, sep } from 'node:path';\n\nimport { generateFromPackageSummary } from '@mysten/codegen';\nimport { Context, Effect, FileSystem, Layer } from 'effect';\n\nimport type { ImageRef } from '../../contracts/container-runtime.ts';\n\nimport { emitOne } from './emit.ts';\nimport { CodegenBindingsFailed } from './errors.ts';\nimport { NON_SENSITIVE_DIR_MODE, NON_SENSITIVE_FILE_MODE } from './permissions.ts';\n\n// -----------------------------------------------------------------------------\n// Service seam — Move summary + codegen invocation\n// -----------------------------------------------------------------------------\n\n/** Result of `sui move summary` — opaque JSON the codegen generator\n * consumes. We don't decode it here; `@mysten/codegen` owns the\n * schema. */\nexport interface MoveSummary {\n\treadonly packageName: string;\n\treadonly sourcePath: string;\n\treadonly summaryPath?: string;\n\treadonly cleanupPath?: string;\n\treadonly summaryJson: unknown;\n}\n\nexport interface MoveSummaryInput {\n\treadonly packageName: string;\n\treadonly sourcePath: string;\n\treadonly buildImage?: ImageRef | null;\n}\n\n/** Shape of the Move summary runner. Implementations live in\n * plugin packages (e.g. `plugins/sui/move-summary-runner.ts`\n * exports `layerSuiMoveSummaryRunnerDocker` and\n * `layerSuiMoveSummaryRunnerHost`); tests use `stubMoveSummaryRunner`\n * below. */\nexport interface MoveSummaryRunner {\n\treadonly runSummary: (\n\t\tinput: MoveSummaryInput,\n\t) => Effect.Effect<MoveSummary, CodegenBindingsFailed>;\n}\n\nexport class MoveSummaryRunnerService extends Context.Service<\n\tMoveSummaryRunnerService,\n\tMoveSummaryRunner\n>()('@devstack/orchestrator/MoveSummaryRunner') {}\n\n/** One rendered binding file — relative path + TS content. */\nexport interface GeneratedBindingFile {\n\treadonly relPath: string;\n\treadonly content: string;\n}\n\n/** Shape of the `@mysten/codegen` invocation. Returns the rendered\n * TS files (path → content) for one package. */\nexport interface MoveCodegen {\n\treadonly generate: (input: {\n\t\treadonly packageName: string;\n\t\treadonly sourcePath: string;\n\t\treadonly summary: MoveSummary;\n\t\treadonly mvrPlaceholder: string;\n\t\treadonly importExtension: '.ts' | '.js' | '';\n\t}) => Effect.Effect<ReadonlyArray<GeneratedBindingFile>, CodegenBindingsFailed>;\n}\n\nexport class MoveCodegenService extends Context.Service<MoveCodegenService, MoveCodegen>()(\n\t'@devstack/orchestrator/MoveCodegen',\n) {}\n\n// -----------------------------------------------------------------------------\n// Public entry — emit bindings for the local packages in a set of\n// PackageBindings contributions.\n// -----------------------------------------------------------------------------\n\nexport interface PackageBindings {\n\treadonly name: string;\n\treadonly packageId: string;\n\treadonly mvrPlaceholder: string;\n\treadonly sourcePath: string | null;\n\treadonly excluded: boolean;\n}\n\n/**\n * Consumer-side shape guard: does an aggregated value look like a\n * Move-bindings contribution that `emitBindings` knows how to consume?\n * This is structural validation of the orchestrator's own input\n * contract, NOT a plugin-name match — any plugin whose\n * `aggregate.project` returns objects with this shape is forwarded to\n * the Move bindings emitter. The single definition of the seam; both\n * the codegen orchestrator service and the Package plugin reference it.\n */\nexport const isPackageBindings = (v: unknown): v is PackageBindings =>\n\ttypeof v === 'object' &&\n\tv !== null &&\n\t'name' in v &&\n\t'packageId' in v &&\n\t'mvrPlaceholder' in v &&\n\t'sourcePath' in v;\n\nexport interface EmitBindingsInput {\n\treadonly bindingsDir: string;\n\treadonly packages: ReadonlyArray<PackageBindings>;\n\treadonly importExtension?: '.ts' | '.js' | '';\n}\n\nexport interface EmitBindingsResult {\n\treadonly packagesEmitted: ReadonlyArray<string>;\n\treadonly packagesSkipped: ReadonlyArray<string>;\n\treadonly filesWritten: ReadonlyArray<string>;\n}\n\n/**\n * Walk the `PackageBindings` set, filter to LOCAL packages\n * (`sourcePath !== null`), run `sui move summary` + `@mysten/codegen`\n * for each, and write the rendered files into `bindingsDir/<name>/`.\n *\n * Serial within a cycle (distilled-doc § \"Serial within a cycle\":\n * shared Move build cache races). Per-package parallelism is unsafe.\n */\nexport const emitBindings = (\n\tinput: EmitBindingsInput,\n): Effect.Effect<\n\tEmitBindingsResult,\n\tCodegenBindingsFailed,\n\tFileSystem.FileSystem | MoveSummaryRunnerService | MoveCodegenService\n> =>\n\tEffect.gen(function* () {\n\t\tconst runner = yield* MoveSummaryRunnerService;\n\t\tconst generator = yield* MoveCodegenService;\n\t\tconst importExtension = input.importExtension ?? '.ts';\n\n\t\t// Dedup by package name. First-wins; distilled-doc § \"Duplicate\n\t\t// package names\": warn + skip the duplicate to avoid the HMR\n\t\t// re-emit storm.\n\t\t// Dedup by package IDENTITY (packageId + sourcePath), keyed for\n\t\t// lookup by name. The SAME package legitimately appears more than\n\t\t// once in the contribution set (e.g. the plugin's localPackage\n\t\t// binding AND a coin's package reference both point at it) — that\n\t\t// is a benign self-duplicate and is skipped SILENTLY. We only warn\n\t\t// when two genuinely DIFFERENT packages (different id/sourcePath)\n\t\t// collide on the same name, which is the real HMR re-emit hazard.\n\t\tconst seenIdentityByName = new Map<string, string>();\n\t\tconst identityOf = (pkg: PackageBindings): string => `${pkg.packageId} ${pkg.sourcePath ?? ''}`;\n\t\tconst targets: Array<PackageBindings> = [];\n\t\tconst skipped: Array<string> = [];\n\t\tfor (const pkg of input.packages) {\n\t\t\tif (pkg.sourcePath === null) {\n\t\t\t\tskipped.push(pkg.name);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (pkg.excluded) {\n\t\t\t\tskipped.push(pkg.name);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst identity = identityOf(pkg);\n\t\t\tconst seenIdentity = seenIdentityByName.get(pkg.name);\n\t\t\tif (seenIdentity !== undefined) {\n\t\t\t\tif (seenIdentity !== identity) {\n\t\t\t\t\t// Two genuinely DIFFERENT packages share a name — a real\n\t\t\t\t\t// collision and a real HMR re-emit hazard.\n\t\t\t\t\tyield* Effect.logWarning(\n\t\t\t\t\t\t`codegen.bindings: duplicate package name '${pkg.name}' — keeping ` +\n\t\t\t\t\t\t\t`first and skipping duplicate to avoid HMR re-emit storm. ` +\n\t\t\t\t\t\t\t`Rename one of the packages.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// Same identity → benign self-duplicate (e.g. localPackage +\n\t\t\t\t// coin package ref): skip silently, no warning.\n\t\t\t\tskipped.push(pkg.name);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tseenIdentityByName.set(pkg.name, identity);\n\t\t\ttargets.push(pkg);\n\t\t}\n\t\t// Deterministic order: lexicographic by package name.\n\t\ttargets.sort((a, b) => a.name.localeCompare(b.name));\n\n\t\tconst emitted: Array<string> = [];\n\t\tconst filesWritten: Array<string> = [];\n\t\tfor (const pkg of targets) {\n\t\t\t// sourcePath is non-null per the filter above. Narrow.\n\t\t\tif (pkg.sourcePath === null) continue;\n\t\t\tconst summary = yield* runner.runSummary({\n\t\t\t\tpackageName: pkg.name,\n\t\t\t\tsourcePath: pkg.sourcePath,\n\t\t\t});\n\t\t\tconst files = yield* generator.generate({\n\t\t\t\tpackageName: pkg.name,\n\t\t\t\tsourcePath: pkg.sourcePath,\n\t\t\t\tsummary,\n\t\t\t\tmvrPlaceholder: pkg.mvrPlaceholder,\n\t\t\t\timportExtension,\n\t\t\t});\n\t\t\t// Post-emit probe — silent no-op detection.\n\t\t\tif (files.length === 0) {\n\t\t\t\treturn yield* Effect.fail(\n\t\t\t\t\tnew CodegenBindingsFailed({\n\t\t\t\t\t\tpackage: pkg.name,\n\t\t\t\t\t\tsourcePath: pkg.sourcePath,\n\t\t\t\t\t\treason: 'no-output',\n\t\t\t\t\t\thint:\n\t\t\t\t\t\t\t'The Move codegen generator produced no files. This is ' +\n\t\t\t\t\t\t\t'usually caused by a missing `[addresses]` block in the ' +\n\t\t\t\t\t\t\t\"package's Move.toml, or a non-published address mapping.\",\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t\tfor (const f of files) {\n\t\t\t\tif (f.relPath.includes('..') || f.relPath.startsWith('/')) {\n\t\t\t\t\treturn yield* Effect.fail(\n\t\t\t\t\t\tnew CodegenBindingsFailed({\n\t\t\t\t\t\t\tpackage: pkg.name,\n\t\t\t\t\t\t\tsourcePath: pkg.sourcePath,\n\t\t\t\t\t\t\treason: 'write-failed',\n\t\t\t\t\t\t\tcause: new Error(`generated binding path escapes output dir: ${f.relPath}`),\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst abs = joinPath(input.bindingsDir, f.relPath);\n\t\t\t\tconst outcome = yield* emitOne({\n\t\t\t\t\tpath: abs,\n\t\t\t\t\tcontent: stabilizeGeneratedBindingContent(f.content),\n\t\t\t\t\tmode: NON_SENSITIVE_FILE_MODE,\n\t\t\t\t\tparentMode: NON_SENSITIVE_DIR_MODE,\n\t\t\t\t}).pipe(\n\t\t\t\t\tEffect.mapError(\n\t\t\t\t\t\t(cause) =>\n\t\t\t\t\t\t\tnew CodegenBindingsFailed({\n\t\t\t\t\t\t\t\tpackage: pkg.name,\n\t\t\t\t\t\t\t\tsourcePath: pkg.sourcePath!,\n\t\t\t\t\t\t\t\treason: 'write-failed',\n\t\t\t\t\t\t\t\tcause,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tif (outcome.outcome !== 'unchanged') {\n\t\t\t\t\tfilesWritten.push(abs);\n\t\t\t\t}\n\t\t\t}\n\t\t\temitted.push(pkg.name);\n\t\t}\n\n\t\treturn {\n\t\t\tpackagesEmitted: emitted,\n\t\t\tpackagesSkipped: skipped,\n\t\t\tfilesWritten,\n\t\t};\n\t});\n\n// -----------------------------------------------------------------------------\n// Stub implementations for tests\n// -----------------------------------------------------------------------------\n\n/** Stub runner — returns a synthetic summary. Used in unit tests\n * to exercise the bindings pipeline without a real `sui` binary. */\nexport const stubMoveSummaryRunner = (\n\tsummaryFor: (sourcePath: string) => MoveSummary,\n): MoveSummaryRunner => ({\n\trunSummary: ({ sourcePath }) => Effect.succeed(summaryFor(sourcePath)),\n});\n\n/** Stub generator — returns a synthetic file set. Used in unit\n * tests to exercise the bindings pipeline without pulling in the\n * heavyweight `@mysten/codegen` graph. */\nexport const stubMoveCodegen = (\n\tfiles: (\n\t\tinput: Parameters<MoveCodegen['generate']>[0],\n\t) => ReadonlyArray<{ readonly relPath: string; readonly content: string }>,\n): MoveCodegen => ({\n\tgenerate: (input) => Effect.succeed(files(input)),\n});\n\n// -----------------------------------------------------------------------------\n// Production implementations\n// -----------------------------------------------------------------------------\n//\n// Layer factories for `MoveSummaryRunnerService` are plugin-owned —\n// they live in `src/plugins/sui/move-summary-runner.ts`. The codegen\n// orchestrator does not name the Sui CLI binary or container image;\n// per \"Orchestrator boundaries — never names a service\", any plugin\n// that can produce `MoveSummary` JSON may contribute a runner Layer.\n\nexport const layerMystenMoveCodegen = (\n\toptions: {\n\t\t/** Forwarded verbatim to `@mysten/codegen`'s\n\t\t * `generateFromPackageSummary({ includePhantomTypeParameters })`.\n\t\t * Default `false` (`@mysten/codegen`'s own default): phantom-only\n\t\t * structs render as plain consts with the `<phantom T>` placeholder\n\t\t * baked into `.name`. `true` renders them as factory functions whose\n\t\t * phantom type parameters are REQUIRED arguments, so the returned\n\t\t * instance's `.name` is a fully-qualified, composable type tag\n\t\t * (`Pool(DBTC, DUSDC).name`). Static per stack — threaded from\n\t\t * `DevstackOptions['codegen']` through\n\t\t * `resolveProductionCodegenOptions`, never per-cycle. */\n\t\treadonly includePhantomTypeParameters?: boolean;\n\t} = {},\n): Layer.Layer<MoveCodegenService> =>\n\tLayer.succeed(\n\t\tMoveCodegenService,\n\t\tMoveCodegenService.of({\n\t\t\tgenerate: (input) =>\n\t\t\t\tEffect.tryPromise({\n\t\t\t\t\ttry: async () => {\n\t\t\t\t\t\tconst tmp = await mkdtemp(join(tmpdir(), 'devstack-move-codegen-'));\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t// `sui move summary` keys each `package_summaries/<dir>`\n\t\t\t\t\t\t\t// subdirectory by the package's NAMED ADDRESS, not its\n\t\t\t\t\t\t\t// `[package].name`. These legitimately differ (the canonical\n\t\t\t\t\t\t\t// example is MoveStdlib, whose package name is \"MoveStdlib\"\n\t\t\t\t\t\t\t// but whose named address is \"std\"). `@mysten/codegen`'s\n\t\t\t\t\t\t\t// resolver matches the summary subdir by either (1) a single\n\t\t\t\t\t\t\t// `[addresses]` label or (2) the `packageName` — but it reads\n\t\t\t\t\t\t\t// the Move.toml at the path WE pass it (the summary scratch\n\t\t\t\t\t\t\t// dir), which has NO `[addresses]` table, so its label-based\n\t\t\t\t\t\t\t// path (1) is defeated and it falls back to (2). We pass the\n\t\t\t\t\t\t\t// symbolic localPackage() NAME as `packageName`, which is the\n\t\t\t\t\t\t\t// `[package].name`, NOT the named address — so codegen throws\n\t\t\t\t\t\t\t// \"Could not identify main package directory\" whenever the two\n\t\t\t\t\t\t\t// differ. Recover the correct subdir name here from the REAL\n\t\t\t\t\t\t\t// source Move.toml's `[addresses]` table (which devstack still\n\t\t\t\t\t\t\t// has at `input.sourcePath`), falling back to the name when the\n\t\t\t\t\t\t\t// source is unreadable or ambiguous (a no-op for the common\n\t\t\t\t\t\t\t// case where name == address).\n\t\t\t\t\t\t\tconst packageName =\n\t\t\t\t\t\t\t\t(await resolveSummaryDirName(input.sourcePath)) ?? input.packageName;\n\t\t\t\t\t\t\tawait generateFromPackageSummary({\n\t\t\t\t\t\t\t\tpackage: {\n\t\t\t\t\t\t\t\t\tpath: input.summary.summaryPath ?? input.sourcePath,\n\t\t\t\t\t\t\t\t\tpackage: input.mvrPlaceholder,\n\t\t\t\t\t\t\t\t\tpackageName,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tprune: true,\n\t\t\t\t\t\t\t\toutputDir: tmp,\n\t\t\t\t\t\t\t\timportExtension: input.importExtension,\n\t\t\t\t\t\t\t\tincludePhantomTypeParameters: options.includePhantomTypeParameters,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\treturn await collectGeneratedFiles(tmp);\n\t\t\t\t\t\t} finally {\n\t\t\t\t\t\t\tawait rm(tmp, { recursive: true, force: true });\n\t\t\t\t\t\t\tif (input.summary.cleanupPath !== undefined) {\n\t\t\t\t\t\t\t\tawait rm(input.summary.cleanupPath, { recursive: true, force: true });\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tcatch: (cause) =>\n\t\t\t\t\t\tnew CodegenBindingsFailed({\n\t\t\t\t\t\t\tpackage: input.packageName,\n\t\t\t\t\t\t\tsourcePath: input.sourcePath,\n\t\t\t\t\t\t\treason: 'render-failed',\n\t\t\t\t\t\t\tcause,\n\t\t\t\t\t\t}),\n\t\t\t\t}),\n\t\t}),\n\t);\n\n// -----------------------------------------------------------------------------\n// Local helpers — keep the module dep-free of Path.Path so the\n// caller can compose without an extra service yield.\n// -----------------------------------------------------------------------------\n\nconst joinPath = (...parts: ReadonlyArray<string>): string =>\n\tparts.map((p, i) => (i === 0 ? p.replace(/\\/+$/, '') : p.replace(/^\\/+|\\/+$/g, ''))).join('/');\n\n/**\n * Determine the `package_summaries/<dir>` subdirectory name for a local\n * Move package from its REAL source `Move.toml`. `sui move summary` keys\n * these subdirs by the NAMED ADDRESS (e.g. MoveStdlib → \"std\"), not the\n * `[package].name`, so when the two differ we must hand `@mysten/codegen`\n * the address label rather than the symbolic package name.\n *\n * Returns the single `[addresses]` label when the table has exactly one\n * entry (the overwhelmingly common case — and a no-op when name == address),\n * and `null` otherwise (unreadable Move.toml, no `[addresses]` table, or an\n * ambiguous multi-address table) so the caller can fall back to the package\n * name and preserve `@mysten/codegen`'s own resolution.\n *\n * Hand-parse rather than pull in a TOML dependency: the sibling Move-build\n * path already harvests `{ local = \"../x\" }` deps from Move.toml by regex\n * (`plugins/sui/move/index.ts`), and we only need the `[addresses]` section's\n * left-hand labels — never their values.\n */\nconst resolveSummaryDirName = async (sourcePath: string): Promise<string | null> => {\n\tlet toml: string;\n\ttry {\n\t\ttoml = await readFile(join(sourcePath, 'Move.toml'), 'utf8');\n\t} catch {\n\t\treturn null;\n\t}\n\tconst labels = parseAddressLabels(toml);\n\treturn labels.length === 1 ? labels[0]! : null;\n};\n\n/** Left-hand labels of the `[addresses]` table in a Move.toml. Scans from\n * the `[addresses]` header to the next `[section]` header (or EOF) and\n * collects each `name = \"...\"` key, ignoring blank/comment lines. */\nconst parseAddressLabels = (toml: string): ReadonlyArray<string> => {\n\tconst lines = toml.split(/\\r?\\n/);\n\tconst start = lines.findIndex((line) => /^\\s*\\[addresses\\]\\s*$/.test(line));\n\tif (start === -1) return [];\n\tconst labels: Array<string> = [];\n\tfor (const line of lines.slice(start + 1)) {\n\t\t// Next table header ends the `[addresses]` section.\n\t\tif (/^\\s*\\[/.test(line)) break;\n\t\tconst stripped = line.replace(/#.*$/, '').trim();\n\t\tif (stripped === '') continue;\n\t\tconst match = /^([A-Za-z_][\\w-]*)\\s*=/.exec(stripped);\n\t\tif (match) labels.push(match[1]!);\n\t}\n\treturn labels;\n};\n\nconst generatedBcsFactoryPattern =\n\t/export function ([A-Za-z_$][\\w$]*)<((?:[^<>]|<[^<>]*>)+)>\\((\\.\\.\\.typeParameters: \\[[\\s\\S]*?\\n\\])\\) \\{\\n(\\s*)return new (MoveStruct|MoveEnum|MoveTuple)\\(/g;\n\nconst bcsFactoryReturnType = (constructorName: string): string => {\n\tif (constructorName === 'MoveEnum') {\n\t\treturn 'MoveEnum<any, string>';\n\t}\n\tif (constructorName === 'MoveTuple') {\n\t\treturn 'MoveTuple<any, string>';\n\t}\n\treturn 'MoveStruct<any, string>';\n};\n\nconst stabilizeGeneratedBindingContent = (content: string): string =>\n\tcontent.replace(\n\t\tgeneratedBcsFactoryPattern,\n\t\t(_match, name, generics, parameters, indent, constructorName: string) =>\n\t\t\t`export function ${name}<${generics}>(${parameters}): ${bcsFactoryReturnType(\n\t\t\t\tconstructorName,\n\t\t\t)} {\\n${indent}return new ${constructorName}(`,\n\t);\n\nconst collectGeneratedFiles = async (\n\troot: string,\n): Promise<ReadonlyArray<{ readonly relPath: string; readonly content: string }>> => {\n\tconst out: Array<{ readonly relPath: string; readonly content: string }> = [];\n\tconst walk = async (dir: string): Promise<void> => {\n\t\tconst entries = await readdir(dir, { withFileTypes: true });\n\t\tfor (const entry of entries) {\n\t\t\tconst abs = join(dir, entry.name);\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\tawait walk(abs);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!entry.isFile()) continue;\n\t\t\tconst relPath = relative(root, abs).split(sep).join('/');\n\t\t\tout.push({ relPath, content: await readFile(abs, 'utf8') });\n\t\t}\n\t};\n\tawait walk(root);\n\tout.sort((a, b) => a.relPath.localeCompare(b.relPath));\n\treturn out;\n};\n"],"mappings":";;;;;;;;;AA4EA,IAAa,2BAAb,cAA8C,QAAQ,QAGpD,CAAC,CAAC,0CAA0C,CAAC,CAAC,CAAC;AAoBjD,IAAa,qBAAb,cAAwC,QAAQ,QAAyC,CAAC,CACzF,oCACD,CAAC,CAAC,CAAC;;;;;;;;;;AAwBH,MAAa,qBAAqB,MACjC,OAAO,MAAM,YACb,MAAM,QACN,UAAU,KACV,eAAe,KACf,oBAAoB,KACpB,gBAAgB;;;;;;;;;AAsBjB,MAAa,gBACZ,UAMA,OAAO,IAAI,aAAa;CACvB,MAAM,SAAS,OAAO;CACtB,MAAM,YAAY,OAAO;CACzB,MAAM,kBAAkB,MAAM,mBAAmB;CAYjD,MAAM,qCAAqB,IAAI,IAAoB;CACnD,MAAM,cAAc,QAAiC,GAAG,IAAI,UAAU,GAAG,IAAI,cAAc;CAC3F,MAAM,UAAkC,CAAC;CACzC,MAAM,UAAyB,CAAC;CAChC,KAAK,MAAM,OAAO,MAAM,UAAU;EACjC,IAAI,IAAI,eAAe,MAAM;GAC5B,QAAQ,KAAK,IAAI,IAAI;GACrB;EACD;EACA,IAAI,IAAI,UAAU;GACjB,QAAQ,KAAK,IAAI,IAAI;GACrB;EACD;EACA,MAAM,WAAW,WAAW,GAAG;EA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AG;IACd;GACD;GACA,IAAI,CAAC,MAAM,OAAO,GAAG;GACrB,MAAM,UAAU,SAAS,MAAM,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG;GACvD,IAAI,KAAK;IAAE;IAAS,SAAS,MAAM,SAAS,KAAK,MAAM;GAAE,CAAC;EAC3D;CACD;CACA,MAAM,KAAK,IAAI;CACf,IAAI,MAAM,GAAG,MAAM,EAAE,QAAQ,cAAc,EAAE,OAAO,CAAC;CACrD,OAAO;AACR"}
|
|
@@ -7,28 +7,29 @@ const CONFIG_RUNTIME_SOURCE = `// THIS FILE IS AUTO-GENERATED BY @mysten/devstac
|
|
|
7
7
|
// \`devstack codegen\`. Apps consume codegen output; codegen output never
|
|
8
8
|
// imports from devstack.
|
|
9
9
|
//
|
|
10
|
-
//
|
|
11
|
-
// ids; it resolves each id through
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
10
|
+
// On-chain deployment resolver. The committed \`config.ts\`
|
|
11
|
+
// carries no ids; it resolves each id through the deployment API here
|
|
12
|
+
// (\`loadDeployment()\` / \`requireId(dep, ...)\`), which reads the build-time-
|
|
13
|
+
// injected \`__DEVSTACK_DEPLOYMENT__\` envelope. Run \`devstack up\` for local
|
|
14
|
+
// dev (the Vite plugin injects the live deployment), or commit a per-network
|
|
15
|
+
// \`deployments/<net>.ts\` for a real deployment.
|
|
15
16
|
|
|
16
17
|
const UNRESOLVED_ID =
|
|
17
18
|
'0x0000000000000000000000000000000000000000000000000000000000000000';
|
|
18
19
|
|
|
19
|
-
// Node-only runtime fallback for the
|
|
20
|
-
// path injects \`
|
|
20
|
+
// Node-only runtime fallback for the injected deployment. The browser/dev/prod
|
|
21
|
+
// path injects \`__DEVSTACK_DEPLOYMENT__\` via the Vite \`define\` (replaced at
|
|
21
22
|
// transform time); this fallback ONLY engages when that define is absent —
|
|
22
23
|
// i.e. under Node/vitest, where the \`define\` bakes to \`null\` because the
|
|
23
24
|
// test stack is booted by the vitest \`globalSetup\` AFTER the Vite config
|
|
24
25
|
// (and so this module) is evaluated. The devstack vitest \`globalSetup\`
|
|
25
|
-
// publishes the booted stack's
|
|
26
|
-
// \`process.env.
|
|
27
|
-
// browser bundles (no \`process\`, no \`node:fs\`) never touch
|
|
28
|
-
// \`null\` on any miss, so
|
|
29
|
-
// Minimal LOCAL shapes (no \`@types/node\` dependency — this
|
|
30
|
-
// type-checked in browser tsconfigs that don't load node types).
|
|
31
|
-
// \`process\` through \`globalThis\` and feature-test every member.
|
|
26
|
+
// publishes the booted stack's deployment FILE path as
|
|
27
|
+
// \`process.env.DEVSTACK_DEPLOYMENT_FILE\`; we read+parse the ENVELOPE lazily
|
|
28
|
+
// here. Guarded so browser bundles (no \`process\`, no \`node:fs\`) never touch
|
|
29
|
+
// it. Returns \`null\` on any miss, so the resolvers throw their actionable
|
|
30
|
+
// error as before. Minimal LOCAL shapes (no \`@types/node\` dependency — this
|
|
31
|
+
// file is also type-checked in browser tsconfigs that don't load node types).
|
|
32
|
+
// We reach \`process\` through \`globalThis\` and feature-test every member.
|
|
32
33
|
interface NodeProcessLike {
|
|
33
34
|
readonly env?: { readonly [k: string]: string | undefined };
|
|
34
35
|
readonly getBuiltinModule?: (id: string) => unknown;
|
|
@@ -37,15 +38,15 @@ interface NodeFsLike {
|
|
|
37
38
|
readonly existsSync: (p: string) => boolean;
|
|
38
39
|
readonly readFileSync: (p: string, enc: 'utf8') => string;
|
|
39
40
|
}
|
|
40
|
-
let nodeFallbackCache:
|
|
41
|
-
const
|
|
41
|
+
let nodeFallbackCache: DevstackDeployment | null | undefined;
|
|
42
|
+
const readNodeFallbackDeployment = (): DevstackDeployment | null => {
|
|
42
43
|
if (nodeFallbackCache !== undefined) return nodeFallbackCache;
|
|
43
44
|
nodeFallbackCache = null;
|
|
44
45
|
try {
|
|
45
46
|
const proc = (globalThis as { process?: NodeProcessLike }).process;
|
|
46
47
|
if (proc === undefined) return null;
|
|
47
|
-
const
|
|
48
|
-
if (
|
|
48
|
+
const file = proc.env?.DEVSTACK_DEPLOYMENT_FILE;
|
|
49
|
+
if (file === undefined || file.length === 0) return null;
|
|
49
50
|
// \`process.getBuiltinModule\` (Node >=22.3) loads \`node:fs\`
|
|
50
51
|
// synchronously without an \`import\`/\`require\` literal a browser
|
|
51
52
|
// bundler would try to resolve — this whole branch is unreachable in
|
|
@@ -53,153 +54,177 @@ const readNodeFallbackIds = (): DevstackIds | null => {
|
|
|
53
54
|
const getBuiltin = proc.getBuiltinModule;
|
|
54
55
|
if (typeof getBuiltin !== 'function') return null;
|
|
55
56
|
const fs = getBuiltin('node:fs') as NodeFsLike;
|
|
56
|
-
if (!fs.existsSync(
|
|
57
|
-
nodeFallbackCache = JSON.parse(fs.readFileSync(
|
|
57
|
+
if (!fs.existsSync(file)) return null;
|
|
58
|
+
nodeFallbackCache = JSON.parse(fs.readFileSync(file, 'utf8')) as DevstackDeployment;
|
|
58
59
|
return nodeFallbackCache;
|
|
59
60
|
} catch {
|
|
60
61
|
return null;
|
|
61
62
|
}
|
|
62
63
|
};
|
|
63
64
|
|
|
64
|
-
/** The injected
|
|
65
|
-
* \`
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
/** The injected deployment envelope, or — under Node with no injected define —
|
|
66
|
+
* the \`DEVSTACK_DEPLOYMENT_FILE\` fallback. \`null\` when neither is
|
|
67
|
+
* available. */
|
|
68
|
+
const injectedDeployment = (): DevstackDeployment | null => {
|
|
69
|
+
const injected =
|
|
70
|
+
typeof __DEVSTACK_DEPLOYMENT__ === 'undefined' ? null : __DEVSTACK_DEPLOYMENT__;
|
|
68
71
|
if (injected !== null && injected !== undefined) return injected;
|
|
69
|
-
return
|
|
72
|
+
return readNodeFallbackDeployment();
|
|
70
73
|
};
|
|
71
74
|
|
|
72
|
-
/** One network
|
|
73
|
-
* reads synchronously; \`chainId\`/\`faucet
|
|
74
|
-
*
|
|
75
|
-
|
|
75
|
+
/** One network's full resolved deployment — connection fields (\`rpc\` is the
|
|
76
|
+
* load-bearing one the app reads synchronously; \`chainId\`/\`faucet\`/
|
|
77
|
+
* \`graphql\` are optional diagnostics) plus the on-chain ids/values for that
|
|
78
|
+
* network. The per-network UNIT of the multi-network envelope; hand-writable
|
|
79
|
+
* for production. */
|
|
80
|
+
export interface NetworkDeployment {
|
|
81
|
+
readonly network?: string;
|
|
76
82
|
readonly rpc: string;
|
|
77
83
|
readonly chainId?: string;
|
|
78
84
|
readonly faucet?: string | null;
|
|
79
85
|
readonly graphql?: string | null;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
* id-config file was supplied at build time. */
|
|
84
|
-
export interface DevstackIds {
|
|
85
|
-
readonly network: string;
|
|
86
|
-
readonly networks: { readonly [name: string]: DevstackNetworkEntry };
|
|
86
|
+
/** Marks a live LOCAL network (a \`devstack up\` stack). Production builds
|
|
87
|
+
* ship only non-local networks. */
|
|
88
|
+
readonly local?: boolean;
|
|
87
89
|
readonly packages: {
|
|
88
90
|
readonly [name: string]: { readonly id: string; readonly objects?: { readonly [k: string]: string } };
|
|
89
91
|
};
|
|
90
|
-
readonly
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
*
|
|
92
|
+
readonly mvrOverrides: {
|
|
93
|
+
readonly packages: { readonly [mvrPlaceholder: string]: string };
|
|
94
|
+
readonly types: { readonly [namedType: string]: string };
|
|
95
|
+
};
|
|
96
|
+
/** Generic resolver channel: \`values[namespace][key]\` carries arbitrary
|
|
97
|
+
* plugin JSON the typed fields above can't (deepbook pool ids, coin
|
|
98
|
+
* types, walrus/seal endpoints). Optional — an older injected unit (no
|
|
99
|
+
* \`values\`) still satisfies the typed resolvers. */
|
|
96
100
|
readonly values?: { readonly [namespace: string]: { readonly [key: string]: unknown } };
|
|
97
101
|
}
|
|
98
102
|
|
|
103
|
+
/** The injected multi-network ENVELOPE: every network this build supports,
|
|
104
|
+
* keyed by name, plus the default the app opens on. \`null\` when no stack is
|
|
105
|
+
* running and no committed deployment was supplied at build time. */
|
|
106
|
+
export interface DevstackDeployment {
|
|
107
|
+
readonly defaultNetwork: string;
|
|
108
|
+
readonly networks: { readonly [name: string]: NetworkDeployment };
|
|
109
|
+
/** DEV-only account name → address map. Network-AGNOSTIC (keypair gen
|
|
110
|
+
* needs no network), so it lives on the envelope, NOT per-network. Only
|
|
111
|
+
* present when running THROUGH devstack (dev serve); a real prod
|
|
112
|
+
* deployment carries none. Optional — \`resolveAccounts()\` defaults to
|
|
113
|
+
* \`{}\` when absent. */
|
|
114
|
+
readonly accounts?: { readonly [name: string]: string };
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** Accessor returned by \`loadDeployment()\` — the default network, the set of
|
|
118
|
+
* available network names (for dapp-kit's network list), and a per-network
|
|
119
|
+
* lookup that throws when the network is unknown. */
|
|
120
|
+
export interface LoadedDeployment {
|
|
121
|
+
readonly defaultNetwork: string;
|
|
122
|
+
readonly networkNames: readonly string[];
|
|
123
|
+
readonly forNetwork: (network: string) => NetworkDeployment;
|
|
124
|
+
}
|
|
125
|
+
|
|
99
126
|
declare global {
|
|
100
127
|
// Injected by the devstack Vite plugin via \`define\`. \`null\` when no
|
|
101
|
-
//
|
|
102
|
-
const
|
|
128
|
+
// deployment is available (no stack up + no committed deployment).
|
|
129
|
+
const __DEVSTACK_DEPLOYMENT__: DevstackDeployment | null | undefined;
|
|
103
130
|
}
|
|
104
131
|
|
|
105
132
|
/** Thrown when a generated config value needs an on-chain id but none was
|
|
106
|
-
* injected
|
|
133
|
+
* injected. */
|
|
107
134
|
export class DevstackConfigMissingError extends Error {
|
|
108
135
|
constructor(detail: string) {
|
|
109
136
|
super(
|
|
110
137
|
\`[devstack] \${detail}\\n\` +
|
|
111
|
-
\`No on-chain
|
|
112
|
-
\`(the Vite dev server injects the live
|
|
113
|
-
\`
|
|
114
|
-
\`(the Vite plugin \\\`
|
|
115
|
-
\`\\\`pnpm build\\\`. See your example
|
|
116
|
-
\`section.\`,
|
|
138
|
+
\`No on-chain deployment is available. For local dev, run \\\`devstack up\\\` \` +
|
|
139
|
+
\`(the Vite dev server injects the live deployment). For a production build, \` +
|
|
140
|
+
\`commit the known deployment's per-network \\\`deployments/<net>.ts\\\` \` +
|
|
141
|
+
\`(wired into the Vite plugin's \\\`deployments\\\` option, or pointed at via \` +
|
|
142
|
+
\`\\\`DEVSTACK_DEPLOYMENT_FILE\\\`) before \\\`pnpm build\\\`. See your example \` +
|
|
143
|
+
\`README's "Deploy to a real network" section.\`,
|
|
117
144
|
);
|
|
118
145
|
this.name = 'DevstackConfigMissingError';
|
|
119
146
|
}
|
|
120
147
|
}
|
|
121
148
|
|
|
122
|
-
|
|
123
|
-
|
|
149
|
+
/** Wrap a resolved \`DevstackDeployment\` envelope in the \`LoadedDeployment\`
|
|
150
|
+
* accessor the app consumes. */
|
|
151
|
+
const loadedFrom = (deployment: DevstackDeployment): LoadedDeployment => ({
|
|
152
|
+
defaultNetwork: deployment.defaultNetwork,
|
|
153
|
+
networkNames: Object.keys(deployment.networks),
|
|
154
|
+
forNetwork: (network) => {
|
|
155
|
+
const entry = deployment.networks[network];
|
|
156
|
+
if (entry === undefined) {
|
|
157
|
+
throw new DevstackConfigMissingError(\`network "\${network}" has no deployment\`);
|
|
158
|
+
}
|
|
159
|
+
return entry;
|
|
160
|
+
},
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
/** Load the injected deployment envelope. Throws once here when nothing
|
|
164
|
+
* was injected; the app then reads typed fields off \`forNetwork(net)\`. */
|
|
165
|
+
export const loadDeployment = (): LoadedDeployment => {
|
|
166
|
+
const injected = injectedDeployment();
|
|
124
167
|
if (injected === null || injected === undefined) {
|
|
125
|
-
throw new DevstackConfigMissingError('
|
|
168
|
+
throw new DevstackConfigMissingError('no deployment was ever injected');
|
|
126
169
|
}
|
|
127
|
-
return injected;
|
|
170
|
+
return loadedFrom(injected);
|
|
128
171
|
};
|
|
129
172
|
|
|
130
|
-
/**
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
export const
|
|
134
|
-
const
|
|
173
|
+
/** Non-throwing sibling of \`loadDeployment\` — returns \`null\` instead of
|
|
174
|
+
* throwing when nothing was injected. For dev-only consumers (e.g. the dev
|
|
175
|
+
* wallet) that must no-op gracefully when no stack is running. */
|
|
176
|
+
export const loadDeploymentOptional = (): LoadedDeployment | null => {
|
|
177
|
+
const injected = injectedDeployment();
|
|
178
|
+
if (injected === null || injected === undefined) return null;
|
|
179
|
+
return loadedFrom(injected);
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
/** The DEV-only account name → address map off the injected envelope.
|
|
183
|
+
* Accounts are network-AGNOSTIC dev identities (envelope-level, never
|
|
184
|
+
* per-network), injected only when running THROUGH devstack. Returns \`{}\`
|
|
185
|
+
* — without throwing — when no deployment was injected or none carries
|
|
186
|
+
* accounts (a pure prod build), so a dev-only consumer (e.g. the dev
|
|
187
|
+
* wallet) no-ops gracefully. */
|
|
188
|
+
export const resolveAccounts = (): { readonly [name: string]: string } => {
|
|
189
|
+
const injected = injectedDeployment();
|
|
190
|
+
return injected?.accounts ?? {};
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
/** Resolve a package id for an MVR placeholder off a loaded deployment.
|
|
194
|
+
* Throws when the id is missing or unresolved. */
|
|
195
|
+
export const requireId = (deployment: NetworkDeployment, mvrPlaceholder: string): string => {
|
|
196
|
+
const id = deployment.mvrOverrides.packages[mvrPlaceholder];
|
|
135
197
|
if (id === undefined || id === UNRESOLVED_ID) {
|
|
136
198
|
throw new DevstackConfigMissingError(\`id for "\${mvrPlaceholder}" is unresolved\`);
|
|
137
199
|
}
|
|
138
200
|
return id;
|
|
139
201
|
};
|
|
140
202
|
|
|
141
|
-
/** Resolve
|
|
142
|
-
*
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
* so this is injected, never baked. Throws when no ids were injected. */
|
|
150
|
-
export const resolveNetworks = (): { readonly [name: string]: DevstackNetworkEntry } =>
|
|
151
|
-
ids().networks;
|
|
152
|
-
|
|
153
|
-
/** Resolve the ACTIVE network's connection entry —
|
|
154
|
-
* \`resolveNetworks()[resolveNetwork()]\` with a non-undefined return type and
|
|
155
|
-
* a loud throw. Removes the \`config.networks[config.network]\` index-signature
|
|
156
|
-
* footgun: the app reads \`.rpc\` etc. off a guaranteed entry instead of
|
|
157
|
-
* threading an \`undefined\` past the index lookup. Throws
|
|
158
|
-
* \`DevstackConfigMissingError\` when no ids were injected or the active
|
|
159
|
-
* network has no entry in the injected map. */
|
|
160
|
-
export const resolveActiveNetwork = (): DevstackNetworkEntry => {
|
|
161
|
-
const network = resolveNetwork();
|
|
162
|
-
const entry = resolveNetworks()[network];
|
|
163
|
-
if (entry === undefined) {
|
|
164
|
-
throw new DevstackConfigMissingError(\`active network "\${network}" has no entry\`);
|
|
165
|
-
}
|
|
166
|
-
return entry;
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
/** Resolve a generic plugin value (\`values[namespace][key]\`). The committed
|
|
170
|
-
* \`config.ts\` calls this for any live plugin value that isn't a package id
|
|
171
|
-
* or the network — deepbook pool ids, coin types, walrus/seal endpoints.
|
|
172
|
-
* Throws \`DevstackConfigMissingError\` when no ids were injected, the value
|
|
173
|
-
* is missing, or it is the all-zero sentinel. */
|
|
174
|
-
export const resolveValue = <T = unknown>(namespace: string, key: string): T => {
|
|
175
|
-
const values = ids().values ?? {};
|
|
176
|
-
const namespaceValues = values[namespace];
|
|
203
|
+
/** Resolve a generic plugin value (\`values[namespace][key]\`) off a loaded
|
|
204
|
+
* deployment. Throws when the value is missing or unresolved. */
|
|
205
|
+
export const requireValue = <T = unknown>(
|
|
206
|
+
deployment: NetworkDeployment,
|
|
207
|
+
namespace: string,
|
|
208
|
+
key: string,
|
|
209
|
+
): T => {
|
|
210
|
+
const namespaceValues = deployment.values?.[namespace];
|
|
177
211
|
const value = namespaceValues === undefined ? undefined : namespaceValues[key];
|
|
178
212
|
if (value === undefined || value === UNRESOLVED_ID) {
|
|
179
|
-
throw new DevstackConfigMissingError(
|
|
180
|
-
\`value "\${namespace}.\${key}" is unresolved\`,
|
|
181
|
-
);
|
|
213
|
+
throw new DevstackConfigMissingError(\`value "\${namespace}.\${key}" is unresolved\`);
|
|
182
214
|
}
|
|
183
215
|
return value as T;
|
|
184
216
|
};
|
|
185
217
|
|
|
186
|
-
/** Non-throwing
|
|
187
|
-
*
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
* live publish) rather than the load-bearing fields that should fail loud. */
|
|
191
|
-
export const resolveValueOptional = <T = unknown>(
|
|
218
|
+
/** Non-throwing sibling of \`requireValue\` for discovery-only fields the app
|
|
219
|
+
* gates on (returns \`undefined\` when missing, unresolved, or absent). */
|
|
220
|
+
export const optionalValue = <T = unknown>(
|
|
221
|
+
deployment: NetworkDeployment,
|
|
192
222
|
namespace: string,
|
|
193
223
|
key: string,
|
|
194
224
|
): T | undefined => {
|
|
195
|
-
const
|
|
196
|
-
const values = injected?.values ?? {};
|
|
197
|
-
const namespaceValues = values[namespace];
|
|
225
|
+
const namespaceValues = deployment.values?.[namespace];
|
|
198
226
|
const value = namespaceValues === undefined ? undefined : namespaceValues[key];
|
|
199
|
-
|
|
200
|
-
return undefined;
|
|
201
|
-
}
|
|
202
|
-
return value as T;
|
|
227
|
+
return value === undefined || value === UNRESOLVED_ID ? undefined : (value as T);
|
|
203
228
|
};
|
|
204
229
|
`;
|
|
205
230
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-runtime.mjs","names":[],"sources":["../../../src/orchestrators/codegen/config-runtime.ts"],"sourcesContent":["// The FIXED `config-runtime.ts` source the codegen verb emits into the\n// committed `src/generated` tree.\n//\n// This is NOT routed through the literal renderer (`format.ts`) — it is a\n// constant string, emitted verbatim. It is the loud-failing id resolver\n// the committed `config.ts` calls: `config.ts` carries NO on-chain id\n// (those are LOADED CONFIG DATA, not codegen output), so each id is a\n// `resolveId('@local/<slug>')` call into this module, which reads the\n// build-time-injected `__DEVSTACK_IDS__` global and THROWS a clear,\n// actionable error when the id is absent or the all-zero sentinel.\n//\n// `__DEVSTACK_IDS__` is injected synchronously by the devstack Vite plugin\n// (`build-integrations/vite/index.ts`) via `define`:\n// - dev (stack up): the live `.devstack/stacks/<stack>/devstack-ids.json`.\n// - prod build: a committed id-config FILE (same schema) — the Vite\n// plugin `ids` option or a `DEVSTACK_IDS_FILE` path.\n// - neither: `null` → `resolveId` throws at access time.\n\n/** Output path (relative to the generated tree) of the emitted resolver. */\nexport const CONFIG_RUNTIME_OUTPUT_PATH = 'config-runtime.ts';\n\n/** The verbatim source emitted as `src/generated/config-runtime.ts`. */\nexport const CONFIG_RUNTIME_SOURCE = `// THIS FILE IS AUTO-GENERATED BY @mysten/devstack.\n// Do not edit by hand — your changes will be overwritten by the next\n// \\`devstack codegen\\`. Apps consume codegen output; codegen output never\n// imports from devstack.\n//\n// Loud-failing on-chain id resolver. The committed \\`config.ts\\` carries no\n// ids; it resolves each id through \\`resolveId(...)\\` here, which reads the\n// build-time-injected \\`__DEVSTACK_IDS__\\` global. Run \\`devstack up\\` for\n// local dev (the Vite plugin injects the live ids), or point the build at a\n// committed id-config file for a real deployment.\n\nconst UNRESOLVED_ID =\n\t'0x0000000000000000000000000000000000000000000000000000000000000000';\n\n// Node-only runtime fallback for the on-chain ids. The browser/dev/prod\n// path injects \\`__DEVSTACK_IDS__\\` via the Vite \\`define\\` (replaced at\n// transform time); this fallback ONLY engages when that define is absent —\n// i.e. under Node/vitest, where the \\`define\\` bakes to \\`null\\` because the\n// test stack is booted by the vitest \\`globalSetup\\` AFTER the Vite config\n// (and so this module) is evaluated. The devstack vitest \\`globalSetup\\`\n// publishes the booted stack's id-config FILE path as\n// \\`process.env.DEVSTACK_IDS_FILE\\`; we read+parse it lazily here. Guarded so\n// browser bundles (no \\`process\\`, no \\`node:fs\\`) never touch it. Returns\n// \\`null\\` on any miss, so \\`ids()\\` throws its actionable error as before.\n// Minimal LOCAL shapes (no \\`@types/node\\` dependency — this file is also\n// type-checked in browser tsconfigs that don't load node types). We reach\n// \\`process\\` through \\`globalThis\\` and feature-test every member.\ninterface NodeProcessLike {\n\treadonly env?: { readonly [k: string]: string | undefined };\n\treadonly getBuiltinModule?: (id: string) => unknown;\n}\ninterface NodeFsLike {\n\treadonly existsSync: (p: string) => boolean;\n\treadonly readFileSync: (p: string, enc: 'utf8') => string;\n}\nlet nodeFallbackCache: DevstackIds | null | undefined;\nconst readNodeFallbackIds = (): DevstackIds | null => {\n\tif (nodeFallbackCache !== undefined) return nodeFallbackCache;\n\tnodeFallbackCache = null;\n\ttry {\n\t\tconst proc = (globalThis as { process?: NodeProcessLike }).process;\n\t\tif (proc === undefined) return null;\n\t\tconst idsFile = proc.env?.DEVSTACK_IDS_FILE;\n\t\tif (idsFile === undefined || idsFile.length === 0) return null;\n\t\t// \\`process.getBuiltinModule\\` (Node >=22.3) loads \\`node:fs\\`\n\t\t// synchronously without an \\`import\\`/\\`require\\` literal a browser\n\t\t// bundler would try to resolve — this whole branch is unreachable in\n\t\t// the browser (no \\`process\\`), so node:fs never enters the bundle.\n\t\tconst getBuiltin = proc.getBuiltinModule;\n\t\tif (typeof getBuiltin !== 'function') return null;\n\t\tconst fs = getBuiltin('node:fs') as NodeFsLike;\n\t\tif (!fs.existsSync(idsFile)) return null;\n\t\tnodeFallbackCache = JSON.parse(fs.readFileSync(idsFile, 'utf8')) as DevstackIds;\n\t\treturn nodeFallbackCache;\n\t} catch {\n\t\treturn null;\n\t}\n};\n\n/** The injected ids, or — under Node with no injected define — the\n * \\`DEVSTACK_IDS_FILE\\` fallback. \\`null\\` when neither is available. */\nconst injectedIds = (): DevstackIds | null => {\n\tconst injected = typeof __DEVSTACK_IDS__ === 'undefined' ? null : __DEVSTACK_IDS__;\n\tif (injected !== null && injected !== undefined) return injected;\n\treturn readNodeFallbackIds();\n};\n\n/** One network connection entry — \\`rpc\\` is the load-bearing field the app\n * reads synchronously; \\`chainId\\`/\\`faucet\\`/\\`graphql\\` are optional\n * diagnostics (mirrors \\`IdConfigNetworkSchema\\`). */\nexport interface DevstackNetworkEntry {\n\treadonly rpc: string;\n\treadonly chainId?: string;\n\treadonly faucet?: string | null;\n\treadonly graphql?: string | null;\n}\n\n/** Shape of the injected ids. \\`null\\` when no stack is running and no\n * id-config file was supplied at build time. */\nexport interface DevstackIds {\n\treadonly network: string;\n\treadonly networks: { readonly [name: string]: DevstackNetworkEntry };\n\treadonly packages: {\n\t\treadonly [name: string]: { readonly id: string; readonly objects?: { readonly [k: string]: string } };\n\t};\n\treadonly accounts: { readonly [name: string]: string };\n\treadonly mvrOverrides: { readonly [mvrPlaceholder: string]: string };\n\t/** Generic resolver channel: \\`values[namespace][key]\\` carries\n\t * arbitrary plugin JSON the typed fields above can't (deepbook pool\n\t * ids, coin types, walrus/seal endpoints). Optional — an older\n\t * injected blob (no \\`values\\`) still satisfies the typed resolvers. */\n\treadonly values?: { readonly [namespace: string]: { readonly [key: string]: unknown } };\n}\n\ndeclare global {\n\t// Injected by the devstack Vite plugin via \\`define\\`. \\`null\\` when no\n\t// ids are available (no stack up + no id-config file).\n\tconst __DEVSTACK_IDS__: DevstackIds | null | undefined;\n}\n\n/** Thrown when a generated config value needs an on-chain id but none was\n * injected — actionable, not a silent zero. */\nexport class DevstackConfigMissingError extends Error {\n\tconstructor(detail: string) {\n\t\tsuper(\n\t\t\t\\`[devstack] \\${detail}\\\\n\\` +\n\t\t\t\t\\`No on-chain ids are available. For local dev, run \\\\\\`devstack up\\\\\\` \\` +\n\t\t\t\t\\`(the Vite dev server injects the live ids). For a production build, \\` +\n\t\t\t\t\\`point the build at the known deployment's committed id-config file \\` +\n\t\t\t\t\\`(the Vite plugin \\\\\\`ids\\\\\\` option, or \\\\\\`DEVSTACK_IDS_FILE\\\\\\`) before \\` +\n\t\t\t\t\\`\\\\\\`pnpm build\\\\\\`. See your example README's \"Deploy to a real network\" \\` +\n\t\t\t\t\\`section.\\`,\n\t\t);\n\t\tthis.name = 'DevstackConfigMissingError';\n\t}\n}\n\nconst ids = (): DevstackIds => {\n\tconst injected = injectedIds();\n\tif (injected === null || injected === undefined) {\n\t\tthrow new DevstackConfigMissingError('on-chain ids were never injected');\n\t}\n\treturn injected;\n};\n\n/** Resolve the active-network id for an MVR placeholder (\\`@local/<slug>\\`).\n * Throws \\`DevstackConfigMissingError\\` when the id is absent or the\n * all-zero sentinel. */\nexport const resolveId = (mvrPlaceholder: string): string => {\n\tconst id = ids().mvrOverrides[mvrPlaceholder];\n\tif (id === undefined || id === UNRESOLVED_ID) {\n\t\tthrow new DevstackConfigMissingError(\\`id for \"\\${mvrPlaceholder}\" is unresolved\\`);\n\t}\n\treturn id;\n};\n\n/** Resolve the active network name (the \\`networks.<name>\\` key the app\n * reads). Environment/live data — the local stack picks a dynamic value\n * and a real deployment names a different network — so it is injected,\n * never baked into the committed tree. Throws when no ids were injected. */\nexport const resolveNetwork = (): string => ids().network;\n\n/** Resolve the network connection map (\\`{ [name]: DevstackNetworkEntry }\\`).\n * The local rpc carries a dynamic port; a real deployment supplies its own —\n * so this is injected, never baked. Throws when no ids were injected. */\nexport const resolveNetworks = (): { readonly [name: string]: DevstackNetworkEntry } =>\n\tids().networks;\n\n/** Resolve the ACTIVE network's connection entry —\n * \\`resolveNetworks()[resolveNetwork()]\\` with a non-undefined return type and\n * a loud throw. Removes the \\`config.networks[config.network]\\` index-signature\n * footgun: the app reads \\`.rpc\\` etc. off a guaranteed entry instead of\n * threading an \\`undefined\\` past the index lookup. Throws\n * \\`DevstackConfigMissingError\\` when no ids were injected or the active\n * network has no entry in the injected map. */\nexport const resolveActiveNetwork = (): DevstackNetworkEntry => {\n\tconst network = resolveNetwork();\n\tconst entry = resolveNetworks()[network];\n\tif (entry === undefined) {\n\t\tthrow new DevstackConfigMissingError(\\`active network \"\\${network}\" has no entry\\`);\n\t}\n\treturn entry;\n};\n\n/** Resolve a generic plugin value (\\`values[namespace][key]\\`). The committed\n * \\`config.ts\\` calls this for any live plugin value that isn't a package id\n * or the network — deepbook pool ids, coin types, walrus/seal endpoints.\n * Throws \\`DevstackConfigMissingError\\` when no ids were injected, the value\n * is missing, or it is the all-zero sentinel. */\nexport const resolveValue = <T = unknown>(namespace: string, key: string): T => {\n\tconst values = ids().values ?? {};\n\tconst namespaceValues = values[namespace];\n\tconst value = namespaceValues === undefined ? undefined : namespaceValues[key];\n\tif (value === undefined || value === UNRESOLVED_ID) {\n\t\tthrow new DevstackConfigMissingError(\n\t\t\t\\`value \"\\${namespace}.\\${key}\" is unresolved\\`,\n\t\t);\n\t}\n\treturn value as T;\n};\n\n/** Non-throwing variant of \\`resolveValue\\`: returns \\`undefined\\` instead of\n * throwing \\`DevstackConfigMissingError\\` when no ids were injected, the value\n * is missing, or it is the all-zero sentinel. For discovery-only ids the app\n * GATES on (e.g. a coin's \\`treasuryCapId\\`/\\`metadataId\\`, only known after a\n * live publish) rather than the load-bearing fields that should fail loud. */\nexport const resolveValueOptional = <T = unknown>(\n\tnamespace: string,\n\tkey: string,\n): T | undefined => {\n\tconst injected = injectedIds();\n\tconst values = injected?.values ?? {};\n\tconst namespaceValues = values[namespace];\n\tconst value = namespaceValues === undefined ? undefined : namespaceValues[key];\n\tif (value === undefined || value === UNRESOLVED_ID) {\n\t\treturn undefined;\n\t}\n\treturn value as T;\n};\n`;\n"],"mappings":";;AAmBA,MAAa,6BAA6B;;AAG1C,MAAa,wBAAwB"}
|
|
1
|
+
{"version":3,"file":"config-runtime.mjs","names":[],"sources":["../../../src/orchestrators/codegen/config-runtime.ts"],"sourcesContent":["// The FIXED `config-runtime.ts` source the codegen verb emits into the\n// committed `src/generated` tree.\n//\n// This is NOT routed through the literal renderer (`format.ts`) — it is a\n// constant string, emitted verbatim. It is the deployment\n// resolver the committed `config.ts` calls: `config.ts` carries NO on-chain\n// id (those are LOADED CONFIG DATA, not codegen output), so each id resolves\n// through `requireId(dep, '@local/<slug>')` / `loadDeployment()` here, which\n// reads the build-time-injected `__DEVSTACK_DEPLOYMENT__` global and throws a\n// clear, actionable error when the id is absent or unresolved.\n//\n// `__DEVSTACK_DEPLOYMENT__` is the multi-network ENVELOPE\n// `{ defaultNetwork, networks: { <net>: NetworkDeployment } }`, injected\n// synchronously by the devstack Vite plugin (`build-integrations/vite/index.ts`)\n// via `define`:\n// - dev (stack up): the live local network OVERLAID on any committed\n// networks (the live network is the default).\n// - prod build: the committed, non-local networks only (the per-network\n// `deployments/<net>.ts` thunks the plugin merges).\n// - neither: `null` → the resolvers throw at access time.\n\n/** Output path (relative to the generated tree) of the emitted resolver. */\nexport const CONFIG_RUNTIME_OUTPUT_PATH = 'config-runtime.ts';\n\n/** The verbatim source emitted as `src/generated/config-runtime.ts`. */\nexport const CONFIG_RUNTIME_SOURCE = `// THIS FILE IS AUTO-GENERATED BY @mysten/devstack.\n// Do not edit by hand — your changes will be overwritten by the next\n// \\`devstack codegen\\`. Apps consume codegen output; codegen output never\n// imports from devstack.\n//\n// On-chain deployment resolver. The committed \\`config.ts\\`\n// carries no ids; it resolves each id through the deployment API here\n// (\\`loadDeployment()\\` / \\`requireId(dep, ...)\\`), which reads the build-time-\n// injected \\`__DEVSTACK_DEPLOYMENT__\\` envelope. Run \\`devstack up\\` for local\n// dev (the Vite plugin injects the live deployment), or commit a per-network\n// \\`deployments/<net>.ts\\` for a real deployment.\n\nconst UNRESOLVED_ID =\n\t'0x0000000000000000000000000000000000000000000000000000000000000000';\n\n// Node-only runtime fallback for the injected deployment. The browser/dev/prod\n// path injects \\`__DEVSTACK_DEPLOYMENT__\\` via the Vite \\`define\\` (replaced at\n// transform time); this fallback ONLY engages when that define is absent —\n// i.e. under Node/vitest, where the \\`define\\` bakes to \\`null\\` because the\n// test stack is booted by the vitest \\`globalSetup\\` AFTER the Vite config\n// (and so this module) is evaluated. The devstack vitest \\`globalSetup\\`\n// publishes the booted stack's deployment FILE path as\n// \\`process.env.DEVSTACK_DEPLOYMENT_FILE\\`; we read+parse the ENVELOPE lazily\n// here. Guarded so browser bundles (no \\`process\\`, no \\`node:fs\\`) never touch\n// it. Returns \\`null\\` on any miss, so the resolvers throw their actionable\n// error as before. Minimal LOCAL shapes (no \\`@types/node\\` dependency — this\n// file is also type-checked in browser tsconfigs that don't load node types).\n// We reach \\`process\\` through \\`globalThis\\` and feature-test every member.\ninterface NodeProcessLike {\n\treadonly env?: { readonly [k: string]: string | undefined };\n\treadonly getBuiltinModule?: (id: string) => unknown;\n}\ninterface NodeFsLike {\n\treadonly existsSync: (p: string) => boolean;\n\treadonly readFileSync: (p: string, enc: 'utf8') => string;\n}\nlet nodeFallbackCache: DevstackDeployment | null | undefined;\nconst readNodeFallbackDeployment = (): DevstackDeployment | null => {\n\tif (nodeFallbackCache !== undefined) return nodeFallbackCache;\n\tnodeFallbackCache = null;\n\ttry {\n\t\tconst proc = (globalThis as { process?: NodeProcessLike }).process;\n\t\tif (proc === undefined) return null;\n\t\tconst file = proc.env?.DEVSTACK_DEPLOYMENT_FILE;\n\t\tif (file === undefined || file.length === 0) return null;\n\t\t// \\`process.getBuiltinModule\\` (Node >=22.3) loads \\`node:fs\\`\n\t\t// synchronously without an \\`import\\`/\\`require\\` literal a browser\n\t\t// bundler would try to resolve — this whole branch is unreachable in\n\t\t// the browser (no \\`process\\`), so node:fs never enters the bundle.\n\t\tconst getBuiltin = proc.getBuiltinModule;\n\t\tif (typeof getBuiltin !== 'function') return null;\n\t\tconst fs = getBuiltin('node:fs') as NodeFsLike;\n\t\tif (!fs.existsSync(file)) return null;\n\t\tnodeFallbackCache = JSON.parse(fs.readFileSync(file, 'utf8')) as DevstackDeployment;\n\t\treturn nodeFallbackCache;\n\t} catch {\n\t\treturn null;\n\t}\n};\n\n/** The injected deployment envelope, or — under Node with no injected define —\n * the \\`DEVSTACK_DEPLOYMENT_FILE\\` fallback. \\`null\\` when neither is\n * available. */\nconst injectedDeployment = (): DevstackDeployment | null => {\n\tconst injected =\n\t\ttypeof __DEVSTACK_DEPLOYMENT__ === 'undefined' ? null : __DEVSTACK_DEPLOYMENT__;\n\tif (injected !== null && injected !== undefined) return injected;\n\treturn readNodeFallbackDeployment();\n};\n\n/** One network's full resolved deployment — connection fields (\\`rpc\\` is the\n * load-bearing one the app reads synchronously; \\`chainId\\`/\\`faucet\\`/\n * \\`graphql\\` are optional diagnostics) plus the on-chain ids/values for that\n * network. The per-network UNIT of the multi-network envelope; hand-writable\n * for production. */\nexport interface NetworkDeployment {\n\treadonly network?: string;\n\treadonly rpc: string;\n\treadonly chainId?: string;\n\treadonly faucet?: string | null;\n\treadonly graphql?: string | null;\n\t/** Marks a live LOCAL network (a \\`devstack up\\` stack). Production builds\n\t * ship only non-local networks. */\n\treadonly local?: boolean;\n\treadonly packages: {\n\t\treadonly [name: string]: { readonly id: string; readonly objects?: { readonly [k: string]: string } };\n\t};\n\treadonly mvrOverrides: {\n\t\treadonly packages: { readonly [mvrPlaceholder: string]: string };\n\t\treadonly types: { readonly [namedType: string]: string };\n\t};\n\t/** Generic resolver channel: \\`values[namespace][key]\\` carries arbitrary\n\t * plugin JSON the typed fields above can't (deepbook pool ids, coin\n\t * types, walrus/seal endpoints). Optional — an older injected unit (no\n\t * \\`values\\`) still satisfies the typed resolvers. */\n\treadonly values?: { readonly [namespace: string]: { readonly [key: string]: unknown } };\n}\n\n/** The injected multi-network ENVELOPE: every network this build supports,\n * keyed by name, plus the default the app opens on. \\`null\\` when no stack is\n * running and no committed deployment was supplied at build time. */\nexport interface DevstackDeployment {\n\treadonly defaultNetwork: string;\n\treadonly networks: { readonly [name: string]: NetworkDeployment };\n\t/** DEV-only account name → address map. Network-AGNOSTIC (keypair gen\n\t * needs no network), so it lives on the envelope, NOT per-network. Only\n\t * present when running THROUGH devstack (dev serve); a real prod\n\t * deployment carries none. Optional — \\`resolveAccounts()\\` defaults to\n\t * \\`{}\\` when absent. */\n\treadonly accounts?: { readonly [name: string]: string };\n}\n\n/** Accessor returned by \\`loadDeployment()\\` — the default network, the set of\n * available network names (for dapp-kit's network list), and a per-network\n * lookup that throws when the network is unknown. */\nexport interface LoadedDeployment {\n\treadonly defaultNetwork: string;\n\treadonly networkNames: readonly string[];\n\treadonly forNetwork: (network: string) => NetworkDeployment;\n}\n\ndeclare global {\n\t// Injected by the devstack Vite plugin via \\`define\\`. \\`null\\` when no\n\t// deployment is available (no stack up + no committed deployment).\n\tconst __DEVSTACK_DEPLOYMENT__: DevstackDeployment | null | undefined;\n}\n\n/** Thrown when a generated config value needs an on-chain id but none was\n * injected. */\nexport class DevstackConfigMissingError extends Error {\n\tconstructor(detail: string) {\n\t\tsuper(\n\t\t\t\\`[devstack] \\${detail}\\\\n\\` +\n\t\t\t\t\\`No on-chain deployment is available. For local dev, run \\\\\\`devstack up\\\\\\` \\` +\n\t\t\t\t\\`(the Vite dev server injects the live deployment). For a production build, \\` +\n\t\t\t\t\\`commit the known deployment's per-network \\\\\\`deployments/<net>.ts\\\\\\` \\` +\n\t\t\t\t\\`(wired into the Vite plugin's \\\\\\`deployments\\\\\\` option, or pointed at via \\` +\n\t\t\t\t\\`\\\\\\`DEVSTACK_DEPLOYMENT_FILE\\\\\\`) before \\\\\\`pnpm build\\\\\\`. See your example \\` +\n\t\t\t\t\\`README's \"Deploy to a real network\" section.\\`,\n\t\t);\n\t\tthis.name = 'DevstackConfigMissingError';\n\t}\n}\n\n/** Wrap a resolved \\`DevstackDeployment\\` envelope in the \\`LoadedDeployment\\`\n * accessor the app consumes. */\nconst loadedFrom = (deployment: DevstackDeployment): LoadedDeployment => ({\n\tdefaultNetwork: deployment.defaultNetwork,\n\tnetworkNames: Object.keys(deployment.networks),\n\tforNetwork: (network) => {\n\t\tconst entry = deployment.networks[network];\n\t\tif (entry === undefined) {\n\t\t\tthrow new DevstackConfigMissingError(\\`network \"\\${network}\" has no deployment\\`);\n\t\t}\n\t\treturn entry;\n\t},\n});\n\n/** Load the injected deployment envelope. Throws once here when nothing\n * was injected; the app then reads typed fields off \\`forNetwork(net)\\`. */\nexport const loadDeployment = (): LoadedDeployment => {\n\tconst injected = injectedDeployment();\n\tif (injected === null || injected === undefined) {\n\t\tthrow new DevstackConfigMissingError('no deployment was ever injected');\n\t}\n\treturn loadedFrom(injected);\n};\n\n/** Non-throwing sibling of \\`loadDeployment\\` — returns \\`null\\` instead of\n * throwing when nothing was injected. For dev-only consumers (e.g. the dev\n * wallet) that must no-op gracefully when no stack is running. */\nexport const loadDeploymentOptional = (): LoadedDeployment | null => {\n\tconst injected = injectedDeployment();\n\tif (injected === null || injected === undefined) return null;\n\treturn loadedFrom(injected);\n};\n\n/** The DEV-only account name → address map off the injected envelope.\n * Accounts are network-AGNOSTIC dev identities (envelope-level, never\n * per-network), injected only when running THROUGH devstack. Returns \\`{}\\`\n * — without throwing — when no deployment was injected or none carries\n * accounts (a pure prod build), so a dev-only consumer (e.g. the dev\n * wallet) no-ops gracefully. */\nexport const resolveAccounts = (): { readonly [name: string]: string } => {\n\tconst injected = injectedDeployment();\n\treturn injected?.accounts ?? {};\n};\n\n/** Resolve a package id for an MVR placeholder off a loaded deployment.\n * Throws when the id is missing or unresolved. */\nexport const requireId = (deployment: NetworkDeployment, mvrPlaceholder: string): string => {\n\tconst id = deployment.mvrOverrides.packages[mvrPlaceholder];\n\tif (id === undefined || id === UNRESOLVED_ID) {\n\t\tthrow new DevstackConfigMissingError(\\`id for \"\\${mvrPlaceholder}\" is unresolved\\`);\n\t}\n\treturn id;\n};\n\n/** Resolve a generic plugin value (\\`values[namespace][key]\\`) off a loaded\n * deployment. Throws when the value is missing or unresolved. */\nexport const requireValue = <T = unknown>(\n\tdeployment: NetworkDeployment,\n\tnamespace: string,\n\tkey: string,\n): T => {\n\tconst namespaceValues = deployment.values?.[namespace];\n\tconst value = namespaceValues === undefined ? undefined : namespaceValues[key];\n\tif (value === undefined || value === UNRESOLVED_ID) {\n\t\tthrow new DevstackConfigMissingError(\\`value \"\\${namespace}.\\${key}\" is unresolved\\`);\n\t}\n\treturn value as T;\n};\n\n/** Non-throwing sibling of \\`requireValue\\` for discovery-only fields the app\n * gates on (returns \\`undefined\\` when missing, unresolved, or absent). */\nexport const optionalValue = <T = unknown>(\n\tdeployment: NetworkDeployment,\n\tnamespace: string,\n\tkey: string,\n): T | undefined => {\n\tconst namespaceValues = deployment.values?.[namespace];\n\tconst value = namespaceValues === undefined ? undefined : namespaceValues[key];\n\treturn value === undefined || value === UNRESOLVED_ID ? undefined : (value as T);\n};\n`;\n"],"mappings":";;AAsBA,MAAa,6BAA6B;;AAG1C,MAAa,wBAAwB"}
|