@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
|
@@ -2,7 +2,7 @@ import { keyedBucketSpec, liveBucketCodegen, staticBucketCodegen } from "../../c
|
|
|
2
2
|
//#region src/plugins/deepbook/codegen.ts
|
|
3
3
|
/** TS source-type strings for the resolved deepbook fields, so the committed
|
|
4
4
|
* `deepbook.ts` carries the SAME concrete types `DeepbookBindings` declares
|
|
5
|
-
* (the generic `
|
|
5
|
+
* (the generic `requireValue` channel would otherwise return `unknown`). The
|
|
6
6
|
* composite blobs (`pools`/`pyth`/`margin`) inline the structural literal
|
|
7
7
|
* types so no emitted type-import is needed. */
|
|
8
8
|
const POOL_TS_TYPE = "ReadonlyArray<{ readonly name: string; readonly poolId: string; readonly base: string; readonly quote: string; readonly baseCoinType: string; readonly quoteCoinType: string }>";
|
|
@@ -10,7 +10,7 @@ const PYTH_TS_TYPE = "{ readonly packageId: string | null; readonly stateId: str
|
|
|
10
10
|
const MARGIN_TS_TYPE = "{ readonly packageId: string; readonly registryId: string } | null";
|
|
11
11
|
/** Build the deepbook instance's config-binding spec for `name`. `name` /
|
|
12
12
|
* `network` are structural literals; the deployment ids + composite values
|
|
13
|
-
* are runtime-resolved (`
|
|
13
|
+
* are runtime-resolved (`requireValue`). */
|
|
14
14
|
const deepbookBucketSpec = (structural) => {
|
|
15
15
|
const known = structural.known;
|
|
16
16
|
const idField = (key, live) => known !== void 0 ? {
|
|
@@ -95,7 +95,7 @@ const deepbookBucketSpec = (structural) => {
|
|
|
95
95
|
});
|
|
96
96
|
};
|
|
97
97
|
/** Build the LIVE Codegenable contribution for a deepbook instance. Bakes
|
|
98
|
-
* the resolved deployment + feeds the generic
|
|
98
|
+
* the resolved deployment + feeds the generic deployment `values` channel.
|
|
99
99
|
* Every instance folds into one `generated/deepbook.ts` exporting
|
|
100
100
|
* `export const deepbook = { <name>: DeepbookBindings, ... }`. */
|
|
101
101
|
const makeDeepbookCodegenable = (bindings) => liveBucketCodegen(deepbookBucketSpec({
|
|
@@ -103,7 +103,7 @@ const makeDeepbookCodegenable = (bindings) => liveBucketCodegen(deepbookBucketSp
|
|
|
103
103
|
network: bindings.network
|
|
104
104
|
}), bindings);
|
|
105
105
|
/** Build the STATIC (stack-free) Codegenable contribution for a deepbook
|
|
106
|
-
* instance. Emits `
|
|
106
|
+
* instance. Emits `requireValue(dep, 'deepbook:<name>', '<key>')` for the runtime
|
|
107
107
|
* fields; the committed `deepbook.ts` carries no baked on-chain id / URL. */
|
|
108
108
|
const makeDeepbookStaticCodegen = (config) => staticBucketCodegen(deepbookBucketSpec(config));
|
|
109
109
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codegen.mjs","names":[],"sources":["../../../src/plugins/deepbook/codegen.ts"],"sourcesContent":["// Deepbook plugin — Codegenable contribution, via the UNIFIED config-binding\n// declaration.\n//\n// ONE declaration, TWO derivations. A deepbook instance declares its\n// `deepbook.ts` contribution ONCE as a `ConfigBindingSet` (rooted under its\n// instance name). The framework derives both behaviors (see\n// `contracts/config-bindings.ts`):\n// - LIVE (boot): bakes the resolved deployment (package / registry / pool\n// ids, pyth feed ids, …) AND feeds the generic
|
|
1
|
+
{"version":3,"file":"codegen.mjs","names":[],"sources":["../../../src/plugins/deepbook/codegen.ts"],"sourcesContent":["// Deepbook plugin — Codegenable contribution, via the UNIFIED config-binding\n// declaration.\n//\n// ONE declaration, TWO derivations. A deepbook instance declares its\n// `deepbook.ts` contribution ONCE as a `ConfigBindingSet` (rooted under its\n// instance name). The framework derives both behaviors (see\n// `contracts/config-bindings.ts`):\n// - LIVE (boot): bakes the resolved deployment (package / registry / pool\n// ids, pyth feed ids, …) AND feeds the generic deployment `values`\n// channel.\n// - STATIC (committed tree): emits `requireValue(dep, 'deepbook:<name>', '<key>')`\n// so the committed `deepbook.ts` carries NO baked on-chain id / URL.\n//\n// STRUCTURAL fields (`name`, `network`) stay literals. The scalar ids\n// (`packageId` / `registryId` / `adminCapId` / `deepTreasuryId`) and the\n// composite values (`pools` / `pyth` / `margin` / endpoint URLs) are RUNTIME\n// (loaded config data). The composite values carry interleaved structural\n// names + runtime ids in array shapes the flat config-path model can't split,\n// so each is resolved as ONE whole-value blob through the generic channel.\n\nimport type { CodegenableDecl } from '../../contracts/codegenable.ts';\nimport {\n\tkeyedBucketSpec,\n\tliveBucketCodegen,\n\tstaticBucketCodegen,\n\ttype BucketField,\n\ttype SiblingBucketSpec,\n} from '../../contracts/config-bindings.ts';\nimport type { JsonValue } from '../../orchestrators/codegen/deployment.ts';\n\nexport interface DeepbookBindings {\n\treadonly name: string;\n\treadonly network: string;\n\treadonly packageId: string;\n\treadonly registryId: string;\n\treadonly adminCapId: string | null;\n\treadonly deepTreasuryId: string | null;\n\t/** Per-pool typed shape (informational only — pools resolve as one blob):\n\t * `{ name, poolId, base, quote, baseCoinType, quoteCoinType }`. */\n\treadonly pools: ReadonlyArray<{\n\t\treadonly name: string;\n\t\treadonly poolId: string;\n\t\treadonly base: string;\n\t\treadonly quote: string;\n\t\treadonly baseCoinType: string;\n\t\treadonly quoteCoinType: string;\n\t}>;\n\treadonly pyth: {\n\t\treadonly packageId: string | null;\n\t\treadonly stateId: string | null;\n\t\treadonly wormholeStateId: string | null;\n\t\treadonly feeds: ReadonlyArray<{\n\t\t\treadonly symbol: string;\n\t\t\treadonly feedId: string;\n\t\t\treadonly priceInfoObjectId: string;\n\t\t\treadonly price: string;\n\t\t\treadonly expo: number;\n\t\t}>;\n\t} | null;\n\treadonly margin: {\n\t\treadonly packageId: string;\n\t\treadonly registryId: string;\n\t} | null;\n\treadonly serverUrl: string | null;\n\treadonly indexerUrl: string | null;\n}\n\n/** User-declared known/override deployment ids, available at factory time. A\n * KNOWN or OVERRIDE deployment's ids are DECLARED config (not loaded-at-runtime\n * data), so the committed `deepbook.ts` bakes them as LITERALS. Only the\n * always-declared scalar ids + the (declared, feed-less) pyth blob are carried;\n * the dynamically-discovered fields (`adminCapId` for known, `pools`, server\n * URLs) stay `requireValue`. */\nexport interface DeepbookKnownIds {\n\treadonly packageId: string;\n\treadonly registryId: string;\n\treadonly deepTreasuryId?: string | null;\n\treadonly pyth?: DeepbookBindings['pyth'];\n}\n\n/** Static-config shape a deepbook instance can describe BEFORE acquire —\n * the structural names the stack-free `staticCodegen` hook needs. When\n * `known` is present (known / override mode), its declared ids are baked as\n * literals; otherwise (local mode) every id resolves at app build/dev time. */\nexport interface DeepbookStaticConfig {\n\treadonly name: string;\n\treadonly network: string;\n\treadonly known?: DeepbookKnownIds;\n}\n\ntype DeepbookLiveState = DeepbookBindings;\n\n/** TS source-type strings for the resolved deepbook fields, so the committed\n * `deepbook.ts` carries the SAME concrete types `DeepbookBindings` declares\n * (the generic `requireValue` channel would otherwise return `unknown`). The\n * composite blobs (`pools`/`pyth`/`margin`) inline the structural literal\n * types so no emitted type-import is needed. */\nconst POOL_TS_TYPE =\n\t'ReadonlyArray<{ readonly name: string; readonly poolId: string; readonly base: string; readonly quote: string; readonly baseCoinType: string; readonly quoteCoinType: string }>';\nconst PYTH_TS_TYPE =\n\t'{ readonly packageId: string | null; readonly stateId: string | null; readonly wormholeStateId: string | null; readonly feeds: ReadonlyArray<{ readonly symbol: string; readonly feedId: string; readonly priceInfoObjectId: string; readonly price: string; readonly expo: number }> } | null';\nconst MARGIN_TS_TYPE = '{ readonly packageId: string; readonly registryId: string } | null';\n\n/** Build the deepbook instance's config-binding spec for `name`. `name` /\n * `network` are structural literals; the deployment ids + composite values\n * are runtime-resolved (`requireValue`). */\nconst deepbookBucketSpec = (\n\tstructural: DeepbookStaticConfig,\n): SiblingBucketSpec<DeepbookLiveState> => {\n\tconst known = structural.known;\n\t// A known/override deployment's declared scalar ids are config, baked as\n\t// literals; a local deployment's ids are dynamic, resolved at build/dev time.\n\tconst idField = (\n\t\tkey: 'packageId' | 'registryId',\n\t\tlive: (s: DeepbookLiveState) => JsonValue,\n\t): BucketField<DeepbookLiveState> =>\n\t\tknown !== undefined\n\t\t\t? { key, variant: 'literal', value: known[key] }\n\t\t\t: { key, variant: 'resolved', tsType: 'string', live };\n\tconst fields: ReadonlyArray<BucketField<DeepbookLiveState>> = [\n\t\t{ key: 'name', variant: 'literal', value: structural.name },\n\t\t{ key: 'network', variant: 'literal', value: structural.network },\n\t\tidField('packageId', (s) => s.packageId),\n\t\tidField('registryId', (s) => s.registryId),\n\t\t// `adminCapId` is null for known/override (never declared there) and\n\t\t// dynamically captured for local — always resolved.\n\t\t{ key: 'adminCapId', variant: 'resolved', tsType: 'string | null', live: (s) => s.adminCapId },\n\t\t// `deepTreasuryId` is a declared known-deployment id when present; a\n\t\t// dynamic local capture otherwise.\n\t\tknown !== undefined\n\t\t\t? {\n\t\t\t\t\tkey: 'deepTreasuryId',\n\t\t\t\t\tvariant: 'literal',\n\t\t\t\t\tvalue: (known.deepTreasuryId ?? null) as JsonValue,\n\t\t\t\t}\n\t\t\t: {\n\t\t\t\t\tkey: 'deepTreasuryId',\n\t\t\t\t\tvariant: 'resolved',\n\t\t\t\t\ttsType: 'string | null',\n\t\t\t\t\tlive: (s) => s.deepTreasuryId,\n\t\t\t\t},\n\t\t// `pools` is always dynamically discovered (even known/override start\n\t\t// empty + may be populated live) — resolved as one whole-value blob.\n\t\t{\n\t\t\tkey: 'pools',\n\t\t\tvariant: 'resolved',\n\t\t\ttsType: POOL_TS_TYPE,\n\t\t\tlive: (s) => s.pools as unknown as JsonValue,\n\t\t},\n\t\t// `pyth` is a DECLARED testnet/mainnet blob for known deployments\n\t\t// (literal); a dynamically-deployed mock-Pyth blob for local (resolved).\n\t\tknown !== undefined\n\t\t\t? { key: 'pyth', variant: 'literal', value: (known.pyth ?? null) as JsonValue }\n\t\t\t: {\n\t\t\t\t\tkey: 'pyth',\n\t\t\t\t\tvariant: 'resolved',\n\t\t\t\t\ttsType: PYTH_TS_TYPE,\n\t\t\t\t\tlive: (s) => s.pyth as unknown as JsonValue,\n\t\t\t\t},\n\t\t{\n\t\t\tkey: 'margin',\n\t\t\tvariant: 'resolved',\n\t\t\ttsType: MARGIN_TS_TYPE,\n\t\t\tlive: (s) => s.margin as unknown as JsonValue,\n\t\t},\n\t\t{ key: 'serverUrl', variant: 'resolved', tsType: 'string | null', live: (s) => s.serverUrl },\n\t\t{ key: 'indexerUrl', variant: 'resolved', tsType: 'string | null', live: (s) => s.indexerUrl },\n\t];\n\treturn keyedBucketSpec({ bucket: 'deepbook.ts', kind: 'deepbook', key: structural.name, fields });\n};\n\n/** Build the LIVE Codegenable contribution for a deepbook instance. Bakes\n * the resolved deployment + feeds the generic deployment `values` channel.\n * Every instance folds into one `generated/deepbook.ts` exporting\n * `export const deepbook = { <name>: DeepbookBindings, ... }`. */\nexport const makeDeepbookCodegenable = (bindings: DeepbookBindings): CodegenableDecl =>\n\tliveBucketCodegen(\n\t\tdeepbookBucketSpec({ name: bindings.name, network: bindings.network }),\n\t\tbindings,\n\t);\n\n/** Build the STATIC (stack-free) Codegenable contribution for a deepbook\n * instance. Emits `requireValue(dep, 'deepbook:<name>', '<key>')` for the runtime\n * fields; the committed `deepbook.ts` carries no baked on-chain id / URL. */\nexport const makeDeepbookStaticCodegen = (config: DeepbookStaticConfig): CodegenableDecl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WAAW;EAAM;CAAO,CAAC;AACjG;;;;;AAMA,MAAa,2BAA2B,aACvC,kBACC,mBAAmB;CAAE,MAAM,SAAS;CAAM,SAAS,SAAS;AAAQ,CAAC,GACrE,QACD;;;;AAKD,MAAa,6BAA6B,WACzC,oBAAoB,mBAAmB,MAAM,CAAC"}
|
|
@@ -10,8 +10,10 @@ import { DeepbookBindings } from "./codegen.mjs";
|
|
|
10
10
|
/** The deepbook resolved value. Mode-asymmetric:
|
|
11
11
|
*
|
|
12
12
|
* - `adminCapId` is `null` for known-deployment mode.
|
|
13
|
-
* - `margin` / `serverUrl` / `indexerUrl`
|
|
14
|
-
*
|
|
13
|
+
* - `margin` / `serverUrl` / `indexerUrl` are `null` when the
|
|
14
|
+
* corresponding sub-feature is not enabled.
|
|
15
|
+
* - `hasSeedLiquidity` is `true` when one or more pools placed seed
|
|
16
|
+
* orders at boot (it is NOT a market-maker process state). */
|
|
15
17
|
interface DeepbookResolved {
|
|
16
18
|
readonly mode: 'local' | 'override' | 'known';
|
|
17
19
|
readonly network: string;
|
|
@@ -27,7 +29,9 @@ interface DeepbookResolved {
|
|
|
27
29
|
} | null;
|
|
28
30
|
readonly serverUrl: string | null;
|
|
29
31
|
readonly indexerUrl: string | null;
|
|
30
|
-
|
|
32
|
+
/** `true` when one or more pools placed seed orders at boot. This reflects
|
|
33
|
+
* "a pool was seeded with liquidity", NOT a running market-maker process. */
|
|
34
|
+
readonly hasSeedLiquidity: boolean;
|
|
31
35
|
readonly deepFundingStrategy: DeepbookDeepFundingStrategy | null;
|
|
32
36
|
}
|
|
33
37
|
interface DeepbookCommonOptions {
|
|
@@ -132,7 +132,7 @@ const buildOverridePlugin = (opts) => {
|
|
|
132
132
|
margin: null,
|
|
133
133
|
serverUrl: null,
|
|
134
134
|
indexerUrl: null,
|
|
135
|
-
|
|
135
|
+
hasSeedLiquidity: false,
|
|
136
136
|
deepFundingStrategy: null
|
|
137
137
|
};
|
|
138
138
|
const bindings = {
|
|
@@ -257,7 +257,7 @@ const buildLocalPlugin = (rawOpts) => {
|
|
|
257
257
|
margin: null,
|
|
258
258
|
serverUrl: null,
|
|
259
259
|
indexerUrl: null,
|
|
260
|
-
|
|
260
|
+
hasSeedLiquidity: seedResults.length > 0,
|
|
261
261
|
deepFundingStrategy: null
|
|
262
262
|
};
|
|
263
263
|
const snap = makeLocalSnapshotable({ name });
|
|
@@ -352,7 +352,7 @@ const buildKnownPlugin = (opts) => {
|
|
|
352
352
|
margin: null,
|
|
353
353
|
serverUrl: null,
|
|
354
354
|
indexerUrl: null,
|
|
355
|
-
|
|
355
|
+
hasSeedLiquidity: false,
|
|
356
356
|
deepFundingStrategy: opts.network === "testnet" ? makeDeepbookDeepFundingStrategy({ suiSdk: sui.sdk }) : null
|
|
357
357
|
};
|
|
358
358
|
const bindings = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["coinFromPackage","builtinCoin","localOpts"],"sources":["../../../src/plugins/deepbook/index.ts"],"sourcesContent":["// Deepbook plugin — barrel + factories.\n//\n// Architecture: Deepbook is a task plugin that resolves a managed\n// local deployment, a known deployment, or explicit caller-supplied\n// override ids, then emits bindings.\n//\n// Mode discipline:\n//\n// - `deepbook(opts)` — explicit mode selection.\n// Localnet can default to local when\n// passed local options.\n// - `deepbookFor(network).local` — local-branch managed deployment.\n// - `deepbookFor(network).override` — local-branch override for\n// caller-supplied deployment ids.\n// - `deepbookFor(network).known` — known-deployment branch (live +\n// fork networks; wraps an already-\n// deployed canonical instance).\n//\n// During `start`, the plugin emits (via the typed `ctx.*` verbs):\n//\n// Local mode:\n// 1. `ctx.snapshotExtra` — `deepbook/<name>` subtree.\n// 2. `ctx.codegen` — `deepbook-network` bindings.\n//\n// Override mode:\n// 1. `ctx.snapshotExtra` — identity guard only.\n// 2. `ctx.codegen` — `deepbook-network` bindings.\n//\n// Known mode:\n// 1. `ctx.snapshotExtra` — identity guard only.\n// 2. `ctx.codegen` — `deepbook-network` bindings (mode='known').\n//\n// Resource id: `deepbook/<name>`. Plugin key: `deepbook:<name>`.\n\nimport { Effect } from 'effect';\n\nimport { defineModeNamespace } from '../../api/mode-narrowed-factory.ts';\nimport { definePlugin, resource, type ResourceValueOf } from '../../api/define-plugin.ts';\nimport type { SnapshotableDecl } from '../../contracts/snapshotable.ts';\nimport { PluginContext } from '../../substrate/plugin-ctx.ts';\nimport { CacheService } from '../../substrate/runtime/cache/index.ts';\nimport { setCurrentPluginPhase } from '../../substrate/runtime/current-plugin.ts';\nimport { passthroughOrWrap } from '../../substrate/runtime/passthrough-or-wrap.ts';\nimport { IdentityContext } from '../../substrate/runtime/paths.ts';\nimport { suiResource } from '../sui/index.ts';\nimport type { AccountValue } from '../account/index.ts';\nimport {\n\tbuiltin as builtinCoin,\n\tfromPackage as coinFromPackage,\n\ttype CoinValue,\n} from '../coin/index.ts';\nimport type { LocalPackageResolved } from '../package/index.ts';\n\nimport { deepbookPluginKey } from './plugin-key.ts';\nimport {\n\tDEEPBOOK_ERROR_TAGS,\n\tdeepbookConfigError,\n\tdeepbookPluginError,\n\ttype DeepbookConfigError,\n\ttype DeepbookError,\n\ttype DeepbookPluginError,\n} from './errors.ts';\nimport {\n\tmakeDeepbookCodegenable,\n\tmakeDeepbookStaticCodegen,\n\ttype DeepbookBindings,\n} from './codegen.ts';\nimport { LOCAL_NETWORK_NAME } from '../../api/inference-network.ts';\nimport {\n\tmakeDeepbookDeepFundingContribution,\n\tmakeDeepbookDeepFundingStrategy,\n\ttype DeepbookDeepFundingStrategy,\n} from './faucet-strategy.ts';\nimport { makeKnownSnapshotable, makeLocalSnapshotable } from './snapshot.ts';\nimport {\n\tcreateDeepbookPools,\n\tseedDeepbookPools,\n\ttype DeepbookDeployment,\n\ttype ResolvedDeepbookPoolSpec,\n} from './deploy.ts';\nimport { initLocalPythFeeds } from './pyth/index.ts';\nimport type {\n\tAccountMemberAlias,\n\tDeepbookPackageMember,\n\tDeepbookPool,\n\tDeepbookPoolSpec,\n\tPythHandle,\n\tPythOptions,\n} from './types.ts';\n\n// ---------------------------------------------------------------------------\n// Resource — the resolved value all consumers read\n// ---------------------------------------------------------------------------\n\nexport type DeepbookResourceId<Name extends string> = `deepbook/${Name}`;\n\nconst makeDeepbookResource = <Name extends string>(name: Name) =>\n\tresource<DeepbookResourceId<Name>, DeepbookResolved>(\n\t\t`deepbook/${name}` as DeepbookResourceId<Name>,\n\t);\n\n/** The deepbook resolved value. Mode-asymmetric:\n *\n * - `adminCapId` is `null` for known-deployment mode.\n * - `margin` / `serverUrl` / `indexerUrl` / `marketMakerRunning`\n * are `null` when the corresponding sub-feature is not enabled. */\nexport interface DeepbookResolved {\n\treadonly mode: 'local' | 'override' | 'known';\n\treadonly network: string;\n\treadonly packageId: string;\n\treadonly registryId: string;\n\treadonly adminCapId: string | null;\n\treadonly deepTreasuryId: string | null;\n\treadonly pools: ReadonlyArray<DeepbookPool>;\n\treadonly pyth: PythHandle | null;\n\treadonly margin: {\n\t\treadonly packageId: string;\n\t\treadonly registryId: string;\n\t} | null;\n\treadonly serverUrl: string | null;\n\treadonly indexerUrl: string | null;\n\treadonly marketMakerRunning: boolean;\n\treadonly deepFundingStrategy: DeepbookDeepFundingStrategy | null;\n}\n\n// ---------------------------------------------------------------------------\n// Options\n// ---------------------------------------------------------------------------\n\nexport interface DeepbookCommonOptions {\n\treadonly name?: string;\n}\n\n/** Override mode wraps an explicitly supplied deployment. It does not\n * publish or manage DeepBook locally. */\nexport interface DeepbookOverrideOptions extends DeepbookCommonOptions {\n\treadonly packageId: string;\n\treadonly registryId: string;\n\treadonly adminCapId: string;\n\treadonly network?: string;\n}\n\n/** Local mode wraps an explicitly supplied local DeepBook package.\n *\n * Explicit-config discipline: `publisher`, `package`, and `pools` are all\n * REQUIRED — the caller publishes the DeepBook Move tree, funds a publisher,\n * and declares the pools. There is no zero-arg auto-synthesis; an\n * under-specified `deepbook({ mode: 'local' })` fails fast with a tagged\n * config error (see the guard in `resolveLocalOptions`). `pyth` stays\n * optional — pass it to seed local mock price feeds, omit it for a\n * feed-less DeX. */\nexport interface DeepbookLocalOptions<\n\tPublisher extends AccountMemberAlias = AccountMemberAlias,\n\tPackage extends DeepbookPackageMember = DeepbookPackageMember,\n\tPools extends ReadonlyArray<DeepbookPoolSpec> = readonly [],\n\tPyth extends PythOptions | undefined = undefined,\n> extends DeepbookCommonOptions {\n\t/** Publisher account — Direct Member Ref (locked API decision). Required. */\n\treadonly publisher: Publisher;\n\t/** Published DeepBook package member. The package must capture the\n\t * `registry::Registry` and `registry::DeepbookAdminCap` object ids.\n\t * Required. */\n\treadonly package: Package;\n\t/** Optional local mock-Pyth package + feed setup. Omit for a feed-less\n\t * local DeX. */\n\treadonly pyth?: Pyth;\n\t/** Capture key for the package-created `registry::Registry`. */\n\treadonly registryIdKey?: string;\n\t/** Capture key for the package-created `registry::DeepbookAdminCap`. */\n\treadonly adminCapIdKey?: string;\n\t/** Optional capture key for a DEEP treasury object used by SDK bindings. */\n\treadonly deepTreasuryIdKey?: string;\n\t/** Pools to create after the DeepBook package publishes. OPTIONAL: when\n\t * omitted, a single unseeded (empty-book) `DEEP/SUI` pool is synthesized\n\t * (the DEEP coin comes from `package`, SUI is built-in — no extra package\n\t * needed), so a minimal `deepbook({ mode:'local', publisher, package })`\n\t * boots a usable DeX. Pass `[]` explicitly for a known-empty deployment, or your own\n\t * pools for full control. */\n\treadonly pools?: Pools;\n}\n\nexport type DeepbookKnownNetwork = 'mainnet' | 'testnet';\n\ninterface DeepbookKnownCommonOptions extends DeepbookCommonOptions {\n\t/** Optional network override (defaults to the configured network). */\n\treadonly network?: string;\n}\n\ninterface DeepbookKnownNetworkOptions extends DeepbookKnownCommonOptions {\n\treadonly network: DeepbookKnownNetwork;\n\treadonly packageId?: string;\n\treadonly registryId?: string;\n}\n\ninterface DeepbookKnownExplicitOptions extends DeepbookKnownCommonOptions {\n\treadonly packageId: string;\n\treadonly registryId: string;\n\treadonly network?: DeepbookKnownNetwork;\n}\n\nexport type DeepbookKnownOptions = DeepbookKnownNetworkOptions | DeepbookKnownExplicitOptions;\n\nexport type DeepbookOptions<\n\tPublisher extends AccountMemberAlias = AccountMemberAlias,\n\tPyth extends PythOptions | undefined = PythOptions | undefined,\n> =\n\t| ({\n\t\t\treadonly mode: 'local';\n\t } & DeepbookLocalOptions<\n\t\t\tPublisher,\n\t\t\tDeepbookPackageMember,\n\t\t\tReadonlyArray<DeepbookPoolSpec>,\n\t\t\tPyth\n\t >)\n\t| ({ readonly mode: 'override' } & DeepbookOverrideOptions)\n\t| ({ readonly mode: 'known' } & DeepbookKnownOptions);\n\n// ---------------------------------------------------------------------------\n// Plugin construction — override\n// ---------------------------------------------------------------------------\n\nconst DEFAULT_NAME = 'deepbook';\n\nconst KNOWN_DEEPBOOK_DEPLOYMENTS: Record<\n\tDeepbookKnownNetwork,\n\t{\n\t\treadonly network: string;\n\t\treadonly packageId: string;\n\t\treadonly registryId: string;\n\t\treadonly deepTreasuryId: string;\n\t\treadonly pyth: PythHandle;\n\t}\n> = {\n\ttestnet: {\n\t\tnetwork: 'testnet',\n\t\tpackageId: '0x22be4cade64bf2d02412c7e8d0e8beea2f78828b948118d46735315409371a3c',\n\t\tregistryId: '0x7c256edbda983a2cd6f946655f4bf3f00a41043993781f8674a7046e8c0e11d1',\n\t\tdeepTreasuryId: '0x69fffdae0075f8f71f4fa793549c11079266910e8905169845af1f5d00e09dcb',\n\t\tpyth: {\n\t\t\tpackageId: null,\n\t\t\tstateId: '0x243759059f4c3111179da5878c12f68d612c21a8d54d85edc86164bb18be1c7c',\n\t\t\twormholeStateId: '0x31358d198147da50db32eda2562951d53973a0c0ad5ed738e9b17d88b213d790',\n\t\t\tfeeds: [],\n\t\t},\n\t},\n\tmainnet: {\n\t\tnetwork: 'mainnet',\n\t\tpackageId: '0xf48222c4e057fa468baf136bff8e12504209d43850c5778f76159292a96f621e',\n\t\tregistryId: '0xaf16199a2dff736e9f07a845f23c5da6df6f756eddb631aed9d24a93efc4549d',\n\t\tdeepTreasuryId: '0x032abf8948dda67a271bcc18e776dbbcfb0d58c8d288a700ff0d5521e57a1ffe',\n\t\tpyth: {\n\t\t\tpackageId: null,\n\t\t\tstateId: '0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8',\n\t\t\twormholeStateId: '0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c',\n\t\t\tfeeds: [],\n\t\t},\n\t},\n};\n\ntype PoolCoinRefs<Pools extends ReadonlyArray<DeepbookPoolSpec>> =\n\tPools[number] extends DeepbookPoolSpec<infer Base, infer Quote> ? Base | Quote : never;\ntype PoolCoinRefTuple<Pools extends ReadonlyArray<DeepbookPoolSpec>> = Pools extends readonly []\n\t? readonly []\n\t: readonly PoolCoinRefs<Pools>[];\n\ntype PythRefs<Pyth extends PythOptions | undefined> =\n\tPyth extends PythOptions<infer Package, infer Pusher> ? readonly [Pusher, Package] : readonly [];\n\ntype LocalDependsOn<\n\tPublisher extends AccountMemberAlias,\n\tPackage extends DeepbookPackageMember,\n\tPools extends ReadonlyArray<DeepbookPoolSpec>,\n\tPyth extends PythOptions | undefined,\n> = readonly [\n\ttypeof suiResource,\n\tPublisher,\n\tPackage,\n\t...PythRefs<Pyth>,\n\t...PoolCoinRefTuple<Pools>,\n];\n\nconst poolCoinRefs = <Pools extends ReadonlyArray<DeepbookPoolSpec>>(\n\tpools: Pools,\n): ReadonlyArray<PoolCoinRefs<Pools>> =>\n\tpools.flatMap((pool) => [pool.base.coin, pool.quote.coin]) as unknown as ReadonlyArray<\n\t\tPoolCoinRefs<Pools>\n\t>;\n\nconst pythRefs = <Pyth extends PythOptions | undefined>(pyth: Pyth): PythRefs<Pyth> =>\n\t(pyth === undefined ? [] : [pyth.pusher, pyth.package]) as unknown as PythRefs<Pyth>;\n\nconst localDependsOn = <\n\tPublisher extends AccountMemberAlias,\n\tPackage extends DeepbookPackageMember,\n\tPools extends ReadonlyArray<DeepbookPoolSpec>,\n\tPyth extends PythOptions | undefined,\n>(\n\topts: DeepbookLocalOptions<Publisher, Package, Pools, Pyth>,\n): LocalDependsOn<Publisher, Package, Pools, Pyth> =>\n\t[\n\t\tsuiResource,\n\t\topts.publisher,\n\t\topts.package,\n\t\t...pythRefs(opts.pyth),\n\t\t...poolCoinRefs((opts.pools ?? []) as Pools),\n\t] as unknown as LocalDependsOn<Publisher, Package, Pools, Pyth>;\n\nconst requireCapturedId = (\n\tpkg: LocalPackageResolved,\n\tkey: string,\n\tkind: 'registryId' | 'adminCapId',\n): Effect.Effect<string, DeepbookPluginError> => {\n\tconst value = pkg.captured[key];\n\tif (typeof value === 'string' && value.length > 0) {\n\t\treturn Effect.succeed(value);\n\t}\n\treturn Effect.fail(\n\t\tdeepbookPluginError(\n\t\t\t'publish',\n\t\t\t`deepbook local package '${pkg.name}' is missing captured ${kind} '${key}'.`,\n\t\t),\n\t);\n};\n\nconst requirePoolCoinValue = (\n\tcoinValuesByRefId: ReadonlyMap<string, CoinValue>,\n\tpoolName: string,\n\tside: 'base' | 'quote',\n\tcoinRefId: string,\n): Effect.Effect<CoinValue, DeepbookConfigError> => {\n\tconst value = coinValuesByRefId.get(coinRefId);\n\tif (value === undefined) {\n\t\t// Compose-time bug — `dependsOn`/`poolCoinRefs` dropped this coin.\n\t\t// Surface a typed config error naming the missing coin id rather\n\t\t// than letting a double-cast `undefined` slip into the resolved\n\t\t// pool spec. Lands on the typed E channel (not a sync throw, which\n\t\t// inside Effect.gen would become an uncaught DEFECT that\n\t\t// `passthroughOrWrap` could not see); `DeepbookConfigError` is in\n\t\t// `DEEPBOOK_ERROR_TAGS`, so the outer pipeline passes it through\n\t\t// untouched.\n\t\treturn Effect.fail(\n\t\t\tdeepbookConfigError(\n\t\t\t\t'pools',\n\t\t\t\t`deepbook: pool '${poolName}' ${side} coin '${coinRefId}' was not resolved by the dependency tuple.`,\n\t\t\t\t'This is a compose-time bug — ensure the coin member is included in `dependsOn`/`poolCoinRefs`.',\n\t\t\t),\n\t\t);\n\t}\n\treturn Effect.succeed(value);\n};\n\nconst resolvePoolSpecs = (\n\tpools: ReadonlyArray<DeepbookPoolSpec>,\n\tcoinValuesByRefId: ReadonlyMap<string, CoinValue>,\n): Effect.Effect<ReadonlyArray<ResolvedDeepbookPoolSpec>, DeepbookConfigError> =>\n\tEffect.forEach(pools, (pool) =>\n\t\tEffect.gen(function* () {\n\t\t\tconst base = yield* requirePoolCoinValue(\n\t\t\t\tcoinValuesByRefId,\n\t\t\t\tpool.name,\n\t\t\t\t'base',\n\t\t\t\tpool.base.coin.id,\n\t\t\t);\n\t\t\tconst quote = yield* requirePoolCoinValue(\n\t\t\t\tcoinValuesByRefId,\n\t\t\t\tpool.name,\n\t\t\t\t'quote',\n\t\t\t\tpool.quote.coin.id,\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tname: pool.name,\n\t\t\t\tbase: pool.base.key,\n\t\t\t\tquote: pool.quote.key,\n\t\t\t\tbaseCoinType: base.fullCoinType,\n\t\t\t\tquoteCoinType: quote.fullCoinType,\n\t\t\t\t...(base.fundingStrategy === undefined\n\t\t\t\t\t? {}\n\t\t\t\t\t: { baseFundingStrategy: base.fundingStrategy }),\n\t\t\t\t...(quote.fundingStrategy === undefined\n\t\t\t\t\t? {}\n\t\t\t\t\t: { quoteFundingStrategy: quote.fundingStrategy }),\n\t\t\t\ttickSize: pool.tickSize,\n\t\t\t\tlotSize: pool.lotSize,\n\t\t\t\tminSize: pool.minSize,\n\t\t\t\twhitelisted: pool.whitelisted ?? true,\n\t\t\t\tstablePool: pool.stablePool ?? false,\n\t\t\t\t...(pool.seed === undefined ? {} : { seed: pool.seed }),\n\t\t\t};\n\t\t}),\n\t);\n\nconst assertUniquePoolNames = (name: string, pools: ReadonlyArray<DeepbookPoolSpec>) => {\n\tconst seen = new Set<string>();\n\tfor (const pool of pools) {\n\t\tif (seen.has(pool.name)) {\n\t\t\tthrow deepbookConfigError(\n\t\t\t\t'pools',\n\t\t\t\t`deepbook({mode:'local', name:'${name}'}) has duplicate pool '${pool.name}'.`,\n\t\t\t\t'Give each local DeepBook pool a unique SDK key.',\n\t\t\t);\n\t\t}\n\t\tseen.add(pool.name);\n\t\tfor (const order of pool.seed?.orders ?? []) {\n\t\t\tif (order.quantity < pool.minSize) {\n\t\t\t\tthrow deepbookConfigError(\n\t\t\t\t\t'pools',\n\t\t\t\t\t`deepbook({mode:'local', name:'${name}'}) seed order for pool '${pool.name}' is below minSize.`,\n\t\t\t\t\t'Use a seed order quantity greater than or equal to the pool minSize.',\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (order.quantity % pool.lotSize !== 0n) {\n\t\t\t\tthrow deepbookConfigError(\n\t\t\t\t\t'pools',\n\t\t\t\t\t`deepbook({mode:'local', name:'${name}'}) seed order for pool '${pool.name}' is not lot-aligned.`,\n\t\t\t\t\t'Use a seed order quantity divisible by the pool lotSize.',\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (order.price % pool.tickSize !== 0n) {\n\t\t\t\tthrow deepbookConfigError(\n\t\t\t\t\t'pools',\n\t\t\t\t\t`deepbook({mode:'local', name:'${name}'}) seed order for pool '${pool.name}' is not tick-aligned.`,\n\t\t\t\t\t'Use a seed order price divisible by the pool tickSize.',\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n};\n\nconst buildOverridePlugin = (opts: DeepbookOverrideOptions) => {\n\tconst name = opts.name ?? DEFAULT_NAME;\n\tif (!opts.packageId || !opts.registryId || !opts.adminCapId) {\n\t\tthrow deepbookConfigError(\n\t\t\t'packageId',\n\t\t\t`deepbook({mode:'override', name:'${name}'}) requires packageId, registryId, and adminCapId.`,\n\t\t\t`Pass explicit deployment ids or use deepbook({mode:'known', network:'testnet'}).`,\n\t\t);\n\t}\n\tconst deepbookResource = makeDeepbookResource(name);\n\tconst snap = makeKnownSnapshotable({ name });\n\n\treturn definePlugin({\n\t\tid: deepbookResource.id,\n\t\tdependsOn: [suiResource] as const,\n\t\trole: 'task',\n\t\tsection: 'service',\n\t\tpluginKey: deepbookPluginKey(name),\n\t\t// Override mode's deployment ids are DECLARED config — bake them as\n\t\t// literals in the committed tree (mirrors `knownPackage`).\n\t\tstaticCodegen: () => [\n\t\t\tmakeDeepbookStaticCodegen({\n\t\t\t\tname,\n\t\t\t\tnetwork: opts.network ?? LOCAL_NETWORK_NAME,\n\t\t\t\tknown: {\n\t\t\t\t\tpackageId: opts.packageId,\n\t\t\t\t\tregistryId: opts.registryId,\n\t\t\t\t},\n\t\t\t}),\n\t\t],\n\t\t// `deps` auto-infers the resolved `[sui]` tuple from the\n\t\t// `[suiResource] as const` dependency. `ctx` arrives via the\n\t\t// `PluginContext` service.\n\t\tstart: () =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst ctx = yield* PluginContext;\n\t\t\t\tconst identity = yield* IdentityContext;\n\t\t\t\tconst network = opts.network ?? identity.network;\n\t\t\t\tconst resolved: DeepbookResolved = {\n\t\t\t\t\tmode: 'override',\n\t\t\t\t\tnetwork,\n\t\t\t\t\tpackageId: opts.packageId,\n\t\t\t\t\tregistryId: opts.registryId,\n\t\t\t\t\tadminCapId: opts.adminCapId,\n\t\t\t\t\tdeepTreasuryId: null,\n\t\t\t\t\tpools: [],\n\t\t\t\t\tpyth: null,\n\t\t\t\t\tmargin: null,\n\t\t\t\t\tserverUrl: null,\n\t\t\t\t\tindexerUrl: null,\n\t\t\t\t\tmarketMakerRunning: false,\n\t\t\t\t\tdeepFundingStrategy: null,\n\t\t\t\t};\n\t\t\t\t// Emit contributions inline: snapshot -> codegen. `resolved` is\n\t\t\t\t// the just-computed value; `snap` is the override-mode\n\t\t\t\t// identity-guard snapshotable in scope. No DEEP funding.\n\t\t\t\tconst bindings: DeepbookBindings = {\n\t\t\t\t\tname,\n\t\t\t\t\tnetwork: resolved.network,\n\t\t\t\t\tpackageId: resolved.packageId,\n\t\t\t\t\tregistryId: resolved.registryId,\n\t\t\t\t\tadminCapId: resolved.adminCapId,\n\t\t\t\t\tdeepTreasuryId: resolved.deepTreasuryId,\n\t\t\t\t\tpools: [],\n\t\t\t\t\tpyth: null,\n\t\t\t\t\tmargin: null,\n\t\t\t\t\tserverUrl: null,\n\t\t\t\t\tindexerUrl: null,\n\t\t\t\t};\n\t\t\t\tctx.snapshotExtra(snap);\n\t\t\t\tctx.codegen(makeDeepbookCodegenable(bindings));\n\t\t\t\treturn resolved;\n\t\t\t}),\n\t});\n};\n\n/** Concrete local options after the explicit-config guard: `publisher`,\n * `package`, and `pools` are guaranteed present. */\ntype ResolvedLocalOptions = DeepbookLocalOptions<\n\tAccountMemberAlias,\n\tDeepbookPackageMember,\n\tReadonlyArray<DeepbookPoolSpec>,\n\tPythOptions | undefined\n> & {\n\treadonly publisher: AccountMemberAlias;\n\treadonly package: DeepbookPackageMember;\n\treadonly pools: ReadonlyArray<DeepbookPoolSpec>;\n};\n\n/** Default local pool synthesized when `pools` is omitted: a single whitelisted\n * `DEEP/SUI` pool. DEEP is the deepbook package's own coin (no extra package to\n * publish), SUI is built-in, so this needs nothing beyond the `package` the\n * caller already passes — and NO seed, so it requires no DEEP minting (i.e. no\n * `deepTreasuryIdKey`) and works for a bare `deepbook({ publisher, package })`.\n * The pool is created with an empty book; pass explicit `pools` with a `seed`\n * (see `examples/deepbook-trader`) for pre-populated liquidity. */\nconst defaultLocalPools = (pkg: DeepbookPackageMember): ReadonlyArray<DeepbookPoolSpec> => [\n\t{\n\t\tname: 'DEEP_SUI',\n\t\tbase: { key: 'DEEP', coin: coinFromPackage(pkg, 'DEEP') },\n\t\tquote: { key: 'SUI', coin: builtinCoin('sui') },\n\t\ttickSize: 1_000_000n,\n\t\tlotSize: 1_000_000n,\n\t\tminSize: 10_000_000n,\n\t\twhitelisted: true,\n\t\tstablePool: false,\n\t},\n];\n\n/** Fail-fast guard for local mode: `publisher` and `package` are REQUIRED — a\n * publish tx needs a signer and the DeepBook Move package must be published\n * (capturing `registry::Registry` + `registry::DeepbookAdminCap`). `pools` is\n * OPTIONAL: omit it for a default unseeded (empty-book) `DEEP/SUI` pool (a\n * minimal usable DeX), pass `[]` for a pool-less deployment, or declare your own. `pyth`\n * stays optional (omit for a feed-less DeX). Missing a required field raises a\n * tagged `DeepbookConfigError` naming what to pass. */\nconst resolveLocalOptions = (\n\topts: DeepbookLocalOptions<\n\t\tAccountMemberAlias,\n\t\tDeepbookPackageMember,\n\t\tReadonlyArray<DeepbookPoolSpec>,\n\t\tPythOptions | undefined\n\t>,\n): ResolvedLocalOptions => {\n\tconst name = opts.name ?? DEFAULT_NAME;\n\tconst missing: string[] = [];\n\tif (!opts.publisher) {\n\t\tmissing.push('publisher');\n\t}\n\tif (!opts.package) {\n\t\tmissing.push('package');\n\t}\n\tif (missing.length > 0) {\n\t\tthrow deepbookConfigError(\n\t\t\tmissing[0] as string,\n\t\t\t`deepbook({mode:'local', name:'${name}'}) requires explicit ${missing.join(', ')}.`,\n\t\t\t`Publish the DeepBook Move package and pass at least { publisher, package } ` +\n\t\t\t\t`(see examples/deepbook-trader). Pools default to an unseeded (empty-book) DEEP/SUI pool.`,\n\t\t);\n\t}\n\t// Default to a single unseeded (empty-book) DEEP/SUI pool when none are declared.\n\tconst pools = opts.pools ?? defaultLocalPools(opts.package);\n\treturn { ...opts, pools } as ResolvedLocalOptions;\n};\n\nconst buildLocalPlugin = <\n\tconst Publisher extends AccountMemberAlias,\n\tconst Package extends DeepbookPackageMember,\n\tconst Pools extends ReadonlyArray<DeepbookPoolSpec> = readonly [],\n\tconst Pyth extends PythOptions | undefined = undefined,\n>(\n\trawOpts: DeepbookLocalOptions<Publisher, Package, Pools, Pyth>,\n) => {\n\tconst opts = resolveLocalOptions(\n\t\trawOpts as DeepbookLocalOptions<\n\t\t\tAccountMemberAlias,\n\t\t\tDeepbookPackageMember,\n\t\t\tReadonlyArray<DeepbookPoolSpec>,\n\t\t\tPythOptions | undefined\n\t\t>,\n\t);\n\tconst name = opts.name ?? DEFAULT_NAME;\n\tassertUniquePoolNames(name, opts.pools);\n\n\tconst deepbookResource = makeDeepbookResource(name);\n\t// Runtime `dependsOn` carries the caller's explicit member refs so\n\t// `defineDevstack`'s dependency-closure expander pulls the publisher /\n\t// package / coin / pyth members into the stack. The STATIC type stays keyed\n\t// to the caller's narrow generics so explicit callers keep their exact\n\t// closure (no generic `coin:`/`package:` provider demands).\n\tconst dependsOn = localDependsOn(opts) as unknown as LocalDependsOn<\n\t\tPublisher,\n\t\tPackage,\n\t\tPools,\n\t\tPyth\n\t>;\n\n\treturn definePlugin({\n\t\tid: deepbookResource.id,\n\t\tdependsOn,\n\t\trole: 'task',\n\t\tsection: 'service',\n\t\tpluginKey: deepbookPluginKey(name),\n\t\t// Stack-free codegen: a local deployment's ids / pools / pyth feeds\n\t\t// are LOADED CONFIG DATA -- the committed `deepbook.ts` stub emits\n\t\t// `resolveValue('deepbook:<name>', '<key>')`, never a baked id.\n\t\tstaticCodegen: () => [makeDeepbookStaticCodegen({ name, network: LOCAL_NETWORK_NAME })],\n\t\t// `deps` auto-infers from the runtime-built `dependsOn`; it\n\t\t// resolves to a heterogeneous tuple the body re-narrows via the\n\t\t// `as unknown as` cast below. `ctx` arrives via the\n\t\t// `PluginContext` service.\n\t\tstart: (deps) =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst ctx = yield* PluginContext;\n\t\t\t\tconst identity = yield* IdentityContext;\n\t\t\t\tconst [sui, publisher, deepbookPackage, ...extraValues] = deps as unknown as readonly [\n\t\t\t\t\tResourceValueOf<typeof suiResource>,\n\t\t\t\t\tAccountValue,\n\t\t\t\t\tLocalPackageResolved,\n\t\t\t\t\t...(AccountValue | LocalPackageResolved | CoinValue)[],\n\t\t\t\t];\n\t\t\t\tconst pythValueCount = opts.pyth === undefined ? 0 : 2;\n\t\t\t\tconst pythValues = extraValues.slice(0, pythValueCount);\n\t\t\t\tconst coinValues = extraValues.slice(pythValueCount) as CoinValue[];\n\n\t\t\t\tyield* setCurrentPluginPhase('reading deployment captures');\n\n\t\t\t\tconst registryId = yield* requireCapturedId(\n\t\t\t\t\tdeepbookPackage,\n\t\t\t\t\topts.registryIdKey ?? 'registryId',\n\t\t\t\t\t'registryId',\n\t\t\t\t);\n\t\t\t\tconst adminCapId = yield* requireCapturedId(\n\t\t\t\t\tdeepbookPackage,\n\t\t\t\t\topts.adminCapIdKey ?? 'adminCapId',\n\t\t\t\t\t'adminCapId',\n\t\t\t\t);\n\t\t\t\tconst deepTreasuryId =\n\t\t\t\t\topts.deepTreasuryIdKey === undefined\n\t\t\t\t\t\t? null\n\t\t\t\t\t\t: (deepbookPackage.captured[opts.deepTreasuryIdKey] ?? null);\n\t\t\t\tconst deployment: DeepbookDeployment = {\n\t\t\t\t\tpackageId: deepbookPackage.packageId,\n\t\t\t\t\tregistryId,\n\t\t\t\t\tadminCapId,\n\t\t\t\t\tdeepTreasuryId,\n\t\t\t\t};\n\t\t\t\tconst poolRefs = poolCoinRefs(opts.pools);\n\t\t\t\tconst coinValuesByRefId = new Map<string, CoinValue>();\n\t\t\t\tfor (let i = 0; i < poolRefs.length; i += 1) {\n\t\t\t\t\tconst ref = poolRefs[i];\n\t\t\t\t\tconst value = coinValues[i];\n\t\t\t\t\tif (ref !== undefined && value !== undefined) {\n\t\t\t\t\t\tcoinValuesByRefId.set(ref.id, value);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst poolSpecs = yield* resolvePoolSpecs(opts.pools, coinValuesByRefId);\n\t\t\t\tconst artifactPublisher = yield* CacheService;\n\t\t\t\tyield* setCurrentPluginPhase(\n\t\t\t\t\topts.pyth === undefined ? 'creating pools' : 'initializing Pyth feeds',\n\t\t\t\t);\n\t\t\t\tconst pyth =\n\t\t\t\t\topts.pyth === undefined\n\t\t\t\t\t\t? null\n\t\t\t\t\t\t: yield* initLocalPythFeeds(\n\t\t\t\t\t\t\t\tartifactPublisher,\n\t\t\t\t\t\t\t\tsui.sdk,\n\t\t\t\t\t\t\t\tsui.chainId,\n\t\t\t\t\t\t\t\tpythValues[0] as AccountValue,\n\t\t\t\t\t\t\t\t{ packageId: (pythValues[1] as LocalPackageResolved).packageId },\n\t\t\t\t\t\t\t\topts.pyth.feeds,\n\t\t\t\t\t\t\t);\n\t\t\t\tyield* setCurrentPluginPhase('creating pools');\n\t\t\t\tconst poolResult = yield* createDeepbookPools(\n\t\t\t\t\tartifactPublisher,\n\t\t\t\t\tsui.sdk,\n\t\t\t\t\tsui.chainId,\n\t\t\t\t\tpublisher,\n\t\t\t\t\tdeployment,\n\t\t\t\t\tpoolSpecs,\n\t\t\t\t);\n\t\t\t\tyield* setCurrentPluginPhase('seeding pools');\n\t\t\t\tconst seedResults = yield* seedDeepbookPools(\n\t\t\t\t\tartifactPublisher,\n\t\t\t\t\tsui.sdk,\n\t\t\t\t\tsui.chainId,\n\t\t\t\t\tpublisher,\n\t\t\t\t\tdeployment,\n\t\t\t\t\tpoolSpecs,\n\t\t\t\t\tpoolResult.pools,\n\t\t\t\t);\n\t\t\t\tyield* setCurrentPluginPhase(null);\n\n\t\t\t\tconst resolved: DeepbookResolved = {\n\t\t\t\t\tmode: 'local',\n\t\t\t\t\tnetwork: identity.network,\n\t\t\t\t\tpackageId: deployment.packageId,\n\t\t\t\t\tregistryId: deployment.registryId,\n\t\t\t\t\tadminCapId: deployment.adminCapId,\n\t\t\t\t\tdeepTreasuryId,\n\t\t\t\t\tpools: poolResult.pools,\n\t\t\t\t\tpyth,\n\t\t\t\t\tmargin: null,\n\t\t\t\t\tserverUrl: null,\n\t\t\t\t\tindexerUrl: null,\n\t\t\t\t\tmarketMakerRunning: seedResults.length > 0,\n\t\t\t\t\tdeepFundingStrategy: null,\n\t\t\t\t};\n\t\t\t\t// Emit contributions inline: snapshot -> codegen. `resolved` is\n\t\t\t\t// the just-computed value; the snapshotable is the local-mode\n\t\t\t\t// `deepbook/<name>` subtree. No DEEP funding (null in local).\n\t\t\t\tconst snap: SnapshotableDecl = makeLocalSnapshotable({ name });\n\t\t\t\tconst bindings: DeepbookBindings = {\n\t\t\t\t\tname,\n\t\t\t\t\tnetwork: resolved.network,\n\t\t\t\t\tpackageId: resolved.packageId,\n\t\t\t\t\tregistryId: resolved.registryId,\n\t\t\t\t\tadminCapId: resolved.adminCapId,\n\t\t\t\t\tdeepTreasuryId: resolved.deepTreasuryId,\n\t\t\t\t\tpools: resolved.pools.map((p) => ({\n\t\t\t\t\t\tname: p.name,\n\t\t\t\t\t\tpoolId: p.poolId,\n\t\t\t\t\t\tbase: p.base,\n\t\t\t\t\t\tquote: p.quote,\n\t\t\t\t\t\tbaseCoinType: p.baseCoinType,\n\t\t\t\t\t\tquoteCoinType: p.quoteCoinType,\n\t\t\t\t\t})),\n\t\t\t\t\tpyth: resolved.pyth\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tpackageId: resolved.pyth.packageId,\n\t\t\t\t\t\t\t\tstateId: resolved.pyth.stateId,\n\t\t\t\t\t\t\t\twormholeStateId: resolved.pyth.wormholeStateId,\n\t\t\t\t\t\t\t\tfeeds: resolved.pyth.feeds.map((feed) => ({\n\t\t\t\t\t\t\t\t\tsymbol: feed.symbol,\n\t\t\t\t\t\t\t\t\tfeedId: feed.feedId,\n\t\t\t\t\t\t\t\t\tpriceInfoObjectId: feed.priceInfoObjectId,\n\t\t\t\t\t\t\t\t\tprice: feed.price.toString(),\n\t\t\t\t\t\t\t\t\texpo: feed.expo,\n\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: null,\n\t\t\t\t\tmargin: resolved.margin,\n\t\t\t\t\tserverUrl: resolved.serverUrl,\n\t\t\t\t\tindexerUrl: resolved.indexerUrl,\n\t\t\t\t};\n\t\t\t\tctx.snapshotExtra(snap);\n\t\t\t\tctx.codegen(makeDeepbookCodegenable(bindings));\n\t\t\t\treturn resolved;\n\t\t\t}).pipe(\n\t\t\t\t// The body's aggregate E channel includes substrate Effects\n\t\t\t\t// whose error shape is unknown to TS (ArtifactPublisher\n\t\t\t\t// produce bodies, dependency reads). `Effect.catchTags`\n\t\t\t\t// would need a statically-known tagged union; the\n\t\t\t\t// substrate's `passthroughOrWrap` runtime-checks the `_tag`\n\t\t\t\t// against `DEEPBOOK_ERROR_TAGS`, passing typed deepbook\n\t\t\t\t// errors through untouched and wrapping everything else\n\t\t\t\t// under `'publish'` so cascade attribution stays with the\n\t\t\t\t// plugin.\n\t\t\t\tpassthroughOrWrap.for<DeepbookError>()(DEEPBOOK_ERROR_TAGS, (err) =>\n\t\t\t\t\tdeepbookPluginError('publish', `deepbook acquire failed: ${String(err)}`, {\n\t\t\t\t\t\tcause: err,\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t),\n\t});\n};\n\nfunction buildLocalPluginPublic<\n\tconst Publisher extends AccountMemberAlias,\n\tconst Package extends DeepbookPackageMember,\n\tconst Pools extends ReadonlyArray<DeepbookPoolSpec>,\n\tconst Pyth extends PythOptions | undefined = undefined,\n>(\n\topts: DeepbookLocalOptions<Publisher, Package, Pools, Pyth>,\n): DeepbookLocalMember<Publisher, Package, Pools, Pyth>;\nfunction buildLocalPluginPublic<\n\tconst Publisher extends AccountMemberAlias,\n\tconst Package extends DeepbookPackageMember,\n\tconst Pools extends ReadonlyArray<DeepbookPoolSpec>,\n\tconst Pyth extends PythOptions | undefined = undefined,\n>(opts: DeepbookLocalOptions<Publisher, Package, Pools, Pyth>) {\n\treturn buildLocalPlugin(opts);\n}\n\n// ---------------------------------------------------------------------------\n// Plugin construction — known\n// ---------------------------------------------------------------------------\n\nconst buildKnownPlugin = (opts: DeepbookKnownOptions) => {\n\tconst name = opts.name ?? DEFAULT_NAME;\n\tconst known = opts.network ? KNOWN_DEEPBOOK_DEPLOYMENTS[opts.network] : null;\n\tconst packageId = opts.packageId ?? known?.packageId;\n\tconst registryId = opts.registryId ?? known?.registryId;\n\tif (!packageId || !registryId) {\n\t\tthrow deepbookConfigError(\n\t\t\t'packageId',\n\t\t\t`deepbook({mode:'known', name:'${name}'}) requires packageId and registryId, or network:'mainnet'|'testnet'.`,\n\t\t\t`Pass explicit ids or use deepbook({mode:'known', network:'testnet'}).`,\n\t\t);\n\t}\n\tconst deepbookResource = makeDeepbookResource(name);\n\tconst snap = makeKnownSnapshotable({ name });\n\n\treturn definePlugin({\n\t\tid: deepbookResource.id,\n\t\tdependsOn: [suiResource] as const,\n\t\trole: 'task',\n\t\tsection: 'service',\n\t\tpluginKey: deepbookPluginKey(name),\n\t\t// Known mode's deployment ids (package / registry / deep-treasury) and\n\t\t// its declared testnet/mainnet Pyth ids are DECLARED config — bake them\n\t\t// as literals in the committed tree (mirrors `knownPackage`).\n\t\tstaticCodegen: () => [\n\t\t\tmakeDeepbookStaticCodegen({\n\t\t\t\tname,\n\t\t\t\tnetwork: opts.network ?? known?.network ?? LOCAL_NETWORK_NAME,\n\t\t\t\tknown: {\n\t\t\t\t\tpackageId,\n\t\t\t\t\tregistryId,\n\t\t\t\t\tdeepTreasuryId: known?.deepTreasuryId ?? null,\n\t\t\t\t\tpyth: known?.pyth\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tpackageId: known.pyth.packageId,\n\t\t\t\t\t\t\t\tstateId: known.pyth.stateId,\n\t\t\t\t\t\t\t\twormholeStateId: known.pyth.wormholeStateId,\n\t\t\t\t\t\t\t\tfeeds: known.pyth.feeds.map((feed) => ({\n\t\t\t\t\t\t\t\t\tsymbol: feed.symbol,\n\t\t\t\t\t\t\t\t\tfeedId: feed.feedId,\n\t\t\t\t\t\t\t\t\tpriceInfoObjectId: feed.priceInfoObjectId,\n\t\t\t\t\t\t\t\t\tprice: feed.price.toString(),\n\t\t\t\t\t\t\t\t\texpo: feed.expo,\n\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: null,\n\t\t\t\t},\n\t\t\t}),\n\t\t],\n\t\t// `deps` auto-infers the resolved `[sui]` tuple from the\n\t\t// `[suiResource] as const` dependency. `ctx` arrives via the\n\t\t// `PluginContext` service.\n\t\tstart: (deps) =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst ctx = yield* PluginContext;\n\t\t\t\tconst identity = yield* IdentityContext;\n\t\t\t\tconst [sui] = deps;\n\t\t\t\tconst network = opts.network ?? known?.network ?? identity.network;\n\t\t\t\tconst resolved: DeepbookResolved = {\n\t\t\t\t\tmode: 'known',\n\t\t\t\t\tnetwork,\n\t\t\t\t\tpackageId,\n\t\t\t\t\tregistryId,\n\t\t\t\t\tadminCapId: null,\n\t\t\t\t\tdeepTreasuryId: known?.deepTreasuryId ?? null,\n\t\t\t\t\tpools: [],\n\t\t\t\t\tpyth: known?.pyth ?? null,\n\t\t\t\t\tmargin: null,\n\t\t\t\t\tserverUrl: null,\n\t\t\t\t\tindexerUrl: null,\n\t\t\t\t\tmarketMakerRunning: false,\n\t\t\t\t\t// DEEP funding is a testnet-deepbook concern — gate on the\n\t\t\t\t\t// network name alone. (The old `&& String(chain) === 'sui:testnet'`\n\t\t\t\t\t// conjunct compared a genesis-digest chainId against a network\n\t\t\t\t\t// literal and was dead for every non-literal `chain` value.)\n\t\t\t\t\tdeepFundingStrategy:\n\t\t\t\t\t\topts.network === 'testnet'\n\t\t\t\t\t\t\t? makeDeepbookDeepFundingStrategy({ suiSdk: sui.sdk })\n\t\t\t\t\t\t\t: null,\n\t\t\t\t};\n\t\t\t\t// Emit contributions inline: snapshot -> codegen -> (optional\n\t\t\t\t// DEEP funding strategy). `resolved` is the just-computed value;\n\t\t\t\t// `snap` is the known-mode identity-guard snapshotable in scope.\n\t\t\t\t// The DEEP funding contributor is emitted only when\n\t\t\t\t// `resolved.deepFundingStrategy` is non-null.\n\t\t\t\tconst bindings: DeepbookBindings = {\n\t\t\t\t\tname,\n\t\t\t\t\tnetwork: resolved.network,\n\t\t\t\t\tpackageId: resolved.packageId,\n\t\t\t\t\tregistryId: resolved.registryId,\n\t\t\t\t\tadminCapId: null,\n\t\t\t\t\tdeepTreasuryId: resolved.deepTreasuryId,\n\t\t\t\t\tpools: [],\n\t\t\t\t\tpyth: resolved.pyth\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tpackageId: resolved.pyth.packageId,\n\t\t\t\t\t\t\t\tstateId: resolved.pyth.stateId,\n\t\t\t\t\t\t\t\twormholeStateId: resolved.pyth.wormholeStateId,\n\t\t\t\t\t\t\t\tfeeds: resolved.pyth.feeds.map((feed) => ({\n\t\t\t\t\t\t\t\t\tsymbol: feed.symbol,\n\t\t\t\t\t\t\t\t\tfeedId: feed.feedId,\n\t\t\t\t\t\t\t\t\tpriceInfoObjectId: feed.priceInfoObjectId,\n\t\t\t\t\t\t\t\t\tprice: feed.price.toString(),\n\t\t\t\t\t\t\t\t\texpo: feed.expo,\n\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: null,\n\t\t\t\t\tmargin: null,\n\t\t\t\t\tserverUrl: null,\n\t\t\t\t\tindexerUrl: null,\n\t\t\t\t};\n\t\t\t\tctx.snapshotExtra(snap);\n\t\t\t\tctx.codegen(makeDeepbookCodegenable(bindings));\n\t\t\t\tif (resolved.deepFundingStrategy != null) {\n\t\t\t\t\tctx.provides(makeDeepbookDeepFundingContribution(resolved.deepFundingStrategy));\n\t\t\t\t}\n\t\t\t\treturn resolved;\n\t\t\t}),\n\t});\n};\n\n// ---------------------------------------------------------------------------\n// Default option resolution (env-driven)\n// ---------------------------------------------------------------------------\n\nconst resolveDefaultMode = <\n\tconst Publisher extends AccountMemberAlias,\n\tconst Package extends DeepbookPackageMember,\n\tconst Pools extends ReadonlyArray<DeepbookPoolSpec> = readonly [],\n\tconst Pyth extends PythOptions | undefined = undefined,\n>(\n\topts?: DeepbookLocalOptions<Publisher, Package, Pools, Pyth>,\n): DeepbookOptions<Publisher, Pyth> => {\n\tconst env = (globalThis as { process?: { env?: Record<string, string | undefined> } }).process\n\t\t?.env?.DEVSTACK_NETWORK;\n\tif (env === undefined || env === 'localnet') {\n\t\t// Local DeepBook: default to local mode on localnet. The caller must\n\t\t// supply explicit `{ publisher, package, pools }`; `resolveLocalOptions`\n\t\t// fails fast otherwise (no auto-synthesis).\n\t\treturn { mode: 'local', ...opts } as DeepbookOptions<Publisher, Pyth>;\n\t}\n\t// Non-local default: refuse — known mode requires explicit\n\t// packageId/registryId. The user passes them via\n\t// `deepbookFor(network).known({...})` or `deepbook({mode:'known',...})`.\n\tthrow deepbookConfigError(\n\t\t'mode',\n\t\t`deepbook(): cannot auto-default to known mode on network='${env}'.`,\n\t\t`Use deepbookFor(network).known({packageId, registryId, ...}).`,\n\t);\n};\n\n// ---------------------------------------------------------------------------\n// User-facing factories\n// ---------------------------------------------------------------------------\n\n/** Env-driven factory. Defaults to local mode on localnet when passed local\n * options. Explicit `override` and `known` modes bypass env inference. */\ntype DeepbookLocalMember<\n\tPublisher extends AccountMemberAlias,\n\tPackage extends DeepbookPackageMember,\n\tPools extends ReadonlyArray<DeepbookPoolSpec>,\n\tPyth extends PythOptions | undefined = undefined,\n> = ReturnType<typeof buildLocalPlugin<Publisher, Package, Pools, Pyth>>;\ntype DeepbookOverrideMember = ReturnType<typeof buildOverridePlugin>;\ntype DeepbookKnownMember = ReturnType<typeof buildKnownPlugin>;\n\n// Local DeepBook requires explicit `{ publisher, package, pools }`. There is\n// no zero-arg/synthesized overload — an under-specified call fails fast (see\n// `resolveLocalOptions`).\nexport function deepbookCore<\n\tconst Publisher extends AccountMemberAlias,\n\tconst Package extends DeepbookPackageMember,\n\tconst Pools extends ReadonlyArray<DeepbookPoolSpec> = readonly [],\n\tconst Pyth extends PythOptions | undefined = undefined,\n>(\n\topts: { readonly mode: 'local' } & DeepbookLocalOptions<Publisher, Package, Pools, Pyth>,\n): DeepbookLocalMember<Publisher, Package, Pools, Pyth>;\nexport function deepbookCore(\n\topts: { readonly mode: 'override' } & DeepbookOverrideOptions,\n): DeepbookOverrideMember;\nexport function deepbookCore(\n\topts: { readonly mode: 'known' } & DeepbookKnownOptions,\n): DeepbookKnownMember;\nexport function deepbookCore<\n\tconst Publisher extends AccountMemberAlias,\n\tconst Package extends DeepbookPackageMember,\n\tconst Pools extends ReadonlyArray<DeepbookPoolSpec> = readonly [],\n\tconst Pyth extends PythOptions | undefined = undefined,\n>(\n\topts: DeepbookLocalOptions<Publisher, Package, Pools, Pyth>,\n): DeepbookLocalMember<Publisher, Package, Pools, Pyth>;\nexport function deepbookCore<\n\tconst Publisher extends AccountMemberAlias,\n\tconst Package extends DeepbookPackageMember,\n\tconst Pools extends ReadonlyArray<DeepbookPoolSpec> = readonly [],\n\tconst Pyth extends PythOptions | undefined = undefined,\n>(\n\topts?: DeepbookLocalOptions<Publisher, Package, Pools, Pyth> | DeepbookOptions<Publisher, Pyth>,\n):\n\t| DeepbookLocalMember<Publisher, Package, Pools, Pyth>\n\t| DeepbookOverrideMember\n\t| DeepbookKnownMember {\n\tconst resolved: DeepbookOptions<Publisher, Pyth> =\n\t\topts !== undefined && 'mode' in opts\n\t\t\t? (opts as DeepbookOptions<Publisher, Pyth>)\n\t\t\t: resolveDefaultMode(\n\t\t\t\t\topts as DeepbookLocalOptions<Publisher, Package, Pools, Pyth> | undefined,\n\t\t\t\t);\n\tswitch (resolved.mode) {\n\t\tcase 'local': {\n\t\t\tconst localOpts = resolved as { readonly mode: 'local' } & DeepbookLocalOptions<\n\t\t\t\tPublisher,\n\t\t\t\tPackage,\n\t\t\t\tPools,\n\t\t\t\tPyth\n\t\t\t>;\n\t\t\t// Explicit-config path only; `buildLocalPlugin` -> `resolveLocalOptions`\n\t\t\t// fails fast when `publisher`/`package`/`pools` are missing.\n\t\t\treturn buildLocalPluginPublic(localOpts) as DeepbookLocalMember<\n\t\t\t\tPublisher,\n\t\t\t\tPackage,\n\t\t\t\tPools,\n\t\t\t\tPyth\n\t\t\t>;\n\t\t}\n\t\tcase 'override':\n\t\t\treturn buildOverridePlugin(resolved);\n\t\tcase 'known':\n\t\t\treturn buildKnownPlugin(resolved);\n\t}\n}\n\n/** Mode-narrowed factory namespace.\n *\n * Usage:\n * const local = { mode: 'local', network: 'localnet' } as const;\n * deepbookFor(local).local({publisher, package, pools}) // OK\n * deepbookFor(local).override({packageId, registryId, adminCapId}) // OK\n * deepbookFor(local).known({...}) // OK\n *\n * const fork = { mode: 'fork', network: 'mainnet-fork', upstream: 'mainnet' } as const;\n * deepbookFor(fork).local({...}) // COMPILE ERROR\n * deepbookFor(fork).override({...}) // COMPILE ERROR\n *\n * The fork branch has NO `.local` or `.override` entry — `deepbookFor(forkNetwork).local`\n * is a compile-time refusal. */\nexport const deepbookFor = defineModeNamespace({\n\tlocal: {\n\t\tlocal: <\n\t\t\tconst Publisher extends AccountMemberAlias,\n\t\t\tconst Package extends DeepbookPackageMember,\n\t\t\tconst Pools extends ReadonlyArray<DeepbookPoolSpec> = readonly [],\n\t\t\tconst Pyth extends PythOptions | undefined = undefined,\n\t\t>(\n\t\t\topts: DeepbookLocalOptions<Publisher, Package, Pools, Pyth>,\n\t\t) => buildLocalPluginPublic(opts),\n\t\toverride: (opts: DeepbookOverrideOptions) => buildOverridePlugin(opts),\n\t\tknown: (opts: DeepbookKnownOptions) => buildKnownPlugin(opts),\n\t},\n\tlive: {\n\t\tknown: (opts: DeepbookKnownOptions) => buildKnownPlugin(opts),\n\t},\n\tfork: {\n\t\t// `.override` intentionally absent — compile-time refusal.\n\t\tknown: (opts: DeepbookKnownOptions) => buildKnownPlugin(opts),\n\t},\n});\n\nexport { deepbookCore as deepbook };\n\n// ---------------------------------------------------------------------------\n// Re-exports for advanced callers\n// ---------------------------------------------------------------------------\n\nexport {\n\tDEEPBOOK_DEEP_FAUCET_STRATEGY_KEY,\n\tDEEPBOOK_TESTNET_DEEP_COIN_TYPE,\n} from './faucet-strategy.ts';\nexport {\n\ttype DeepbookError,\n\ttype DeepbookPluginError,\n\ttype DeepbookConfigError,\n\ttype DeepbookPhase,\n} from './errors.ts';\nexport type { DeepbookBindings } from './codegen.ts';\nexport type {\n\tAccountMemberAlias,\n\tCoinMemberAlias,\n\tDeepbookPackageMember,\n\tDeepbookPool,\n\tDeepbookPoolCoin,\n\tDeepbookPoolSeedLiquidity,\n\tDeepbookPoolSeedOrder,\n\tDeepbookPoolSpec,\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ts"],"sources":["../../../src/plugins/deepbook/index.ts"],"sourcesContent":["// Deepbook plugin — barrel + factories.\n//\n// Architecture: Deepbook is a task plugin that resolves a managed\n// local deployment, a known deployment, or explicit caller-supplied\n// override ids, then emits bindings.\n//\n// Mode discipline:\n//\n// - `deepbook(opts)` — explicit mode selection.\n// Localnet can default to local when\n// passed local options.\n// - `deepbookFor(network).local` — local-branch managed deployment.\n// - `deepbookFor(network).override` — local-branch override for\n// caller-supplied deployment ids.\n// - `deepbookFor(network).known` — known-deployment branch (live +\n// fork networks; wraps an already-\n// deployed canonical instance).\n//\n// During `start`, the plugin emits (via the typed `ctx.*` verbs):\n//\n// Local mode:\n// 1. `ctx.snapshotExtra` — `deepbook/<name>` subtree.\n// 2. `ctx.codegen` — `deepbook-network` bindings.\n//\n// Override mode:\n// 1. `ctx.snapshotExtra` — identity guard only.\n// 2. `ctx.codegen` — `deepbook-network` bindings.\n//\n// Known mode:\n// 1. `ctx.snapshotExtra` — identity guard only.\n// 2. `ctx.codegen` — `deepbook-network` bindings (mode='known').\n//\n// Resource id: `deepbook/<name>`. Plugin key: `deepbook:<name>`.\n\nimport { Effect } from 'effect';\n\nimport { defineModeNamespace } from '../../api/mode-narrowed-factory.ts';\nimport { definePlugin, resource, type ResourceValueOf } from '../../api/define-plugin.ts';\nimport type { SnapshotableDecl } from '../../contracts/snapshotable.ts';\nimport { PluginContext } from '../../substrate/plugin-ctx.ts';\nimport { CacheService } from '../../substrate/runtime/cache/index.ts';\nimport { setCurrentPluginPhase } from '../../substrate/runtime/current-plugin.ts';\nimport { passthroughOrWrap } from '../../substrate/runtime/passthrough-or-wrap.ts';\nimport { IdentityContext } from '../../substrate/runtime/paths.ts';\nimport { suiResource } from '../sui/index.ts';\nimport type { AccountValue } from '../account/index.ts';\nimport {\n\tbuiltin as builtinCoin,\n\tfromPackage as coinFromPackage,\n\ttype CoinValue,\n} from '../coin/index.ts';\nimport type { LocalPackageResolved } from '../package/index.ts';\n\nimport { deepbookPluginKey } from './plugin-key.ts';\nimport {\n\tDEEPBOOK_ERROR_TAGS,\n\tdeepbookConfigError,\n\tdeepbookPluginError,\n\ttype DeepbookConfigError,\n\ttype DeepbookError,\n\ttype DeepbookPluginError,\n} from './errors.ts';\nimport {\n\tmakeDeepbookCodegenable,\n\tmakeDeepbookStaticCodegen,\n\ttype DeepbookBindings,\n} from './codegen.ts';\nimport { LOCAL_NETWORK_NAME } from '../../api/inference-network.ts';\nimport {\n\tmakeDeepbookDeepFundingContribution,\n\tmakeDeepbookDeepFundingStrategy,\n\ttype DeepbookDeepFundingStrategy,\n} from './faucet-strategy.ts';\nimport { makeKnownSnapshotable, makeLocalSnapshotable } from './snapshot.ts';\nimport {\n\tcreateDeepbookPools,\n\tseedDeepbookPools,\n\ttype DeepbookDeployment,\n\ttype ResolvedDeepbookPoolSpec,\n} from './deploy.ts';\nimport { initLocalPythFeeds } from './pyth/index.ts';\nimport type {\n\tAccountMemberAlias,\n\tDeepbookPackageMember,\n\tDeepbookPool,\n\tDeepbookPoolSpec,\n\tPythHandle,\n\tPythOptions,\n} from './types.ts';\n\n// ---------------------------------------------------------------------------\n// Resource — the resolved value all consumers read\n// ---------------------------------------------------------------------------\n\nexport type DeepbookResourceId<Name extends string> = `deepbook/${Name}`;\n\nconst makeDeepbookResource = <Name extends string>(name: Name) =>\n\tresource<DeepbookResourceId<Name>, DeepbookResolved>(\n\t\t`deepbook/${name}` as DeepbookResourceId<Name>,\n\t);\n\n/** The deepbook resolved value. Mode-asymmetric:\n *\n * - `adminCapId` is `null` for known-deployment mode.\n * - `margin` / `serverUrl` / `indexerUrl` are `null` when the\n * corresponding sub-feature is not enabled.\n * - `hasSeedLiquidity` is `true` when one or more pools placed seed\n * orders at boot (it is NOT a market-maker process state). */\nexport interface DeepbookResolved {\n\treadonly mode: 'local' | 'override' | 'known';\n\treadonly network: string;\n\treadonly packageId: string;\n\treadonly registryId: string;\n\treadonly adminCapId: string | null;\n\treadonly deepTreasuryId: string | null;\n\treadonly pools: ReadonlyArray<DeepbookPool>;\n\treadonly pyth: PythHandle | null;\n\treadonly margin: {\n\t\treadonly packageId: string;\n\t\treadonly registryId: string;\n\t} | null;\n\treadonly serverUrl: string | null;\n\treadonly indexerUrl: string | null;\n\t/** `true` when one or more pools placed seed orders at boot. This reflects\n\t * \"a pool was seeded with liquidity\", NOT a running market-maker process. */\n\treadonly hasSeedLiquidity: boolean;\n\treadonly deepFundingStrategy: DeepbookDeepFundingStrategy | null;\n}\n\n// ---------------------------------------------------------------------------\n// Options\n// ---------------------------------------------------------------------------\n\nexport interface DeepbookCommonOptions {\n\treadonly name?: string;\n}\n\n/** Override mode wraps an explicitly supplied deployment. It does not\n * publish or manage DeepBook locally. */\nexport interface DeepbookOverrideOptions extends DeepbookCommonOptions {\n\treadonly packageId: string;\n\treadonly registryId: string;\n\treadonly adminCapId: string;\n\treadonly network?: string;\n}\n\n/** Local mode wraps an explicitly supplied local DeepBook package.\n *\n * Explicit-config discipline: `publisher`, `package`, and `pools` are all\n * REQUIRED — the caller publishes the DeepBook Move tree, funds a publisher,\n * and declares the pools. There is no zero-arg auto-synthesis; an\n * under-specified `deepbook({ mode: 'local' })` fails fast with a tagged\n * config error (see the guard in `resolveLocalOptions`). `pyth` stays\n * optional — pass it to seed local mock price feeds, omit it for a\n * feed-less DeX. */\nexport interface DeepbookLocalOptions<\n\tPublisher extends AccountMemberAlias = AccountMemberAlias,\n\tPackage extends DeepbookPackageMember = DeepbookPackageMember,\n\tPools extends ReadonlyArray<DeepbookPoolSpec> = readonly [],\n\tPyth extends PythOptions | undefined = undefined,\n> extends DeepbookCommonOptions {\n\t/** Publisher account — Direct Member Ref (locked API decision). Required. */\n\treadonly publisher: Publisher;\n\t/** Published DeepBook package member. The package must capture the\n\t * `registry::Registry` and `registry::DeepbookAdminCap` object ids.\n\t * Required. */\n\treadonly package: Package;\n\t/** Optional local mock-Pyth package + feed setup. Omit for a feed-less\n\t * local DeX. */\n\treadonly pyth?: Pyth;\n\t/** Capture key for the package-created `registry::Registry`. */\n\treadonly registryIdKey?: string;\n\t/** Capture key for the package-created `registry::DeepbookAdminCap`. */\n\treadonly adminCapIdKey?: string;\n\t/** Optional capture key for a DEEP treasury object used by SDK bindings. */\n\treadonly deepTreasuryIdKey?: string;\n\t/** Pools to create after the DeepBook package publishes. OPTIONAL: when\n\t * omitted, a single unseeded (empty-book) `DEEP/SUI` pool is synthesized\n\t * (the DEEP coin comes from `package`, SUI is built-in — no extra package\n\t * needed), so a minimal `deepbook({ mode:'local', publisher, package })`\n\t * boots a usable DeX. Pass `[]` explicitly for a known-empty deployment, or your own\n\t * pools for full control. */\n\treadonly pools?: Pools;\n}\n\nexport type DeepbookKnownNetwork = 'mainnet' | 'testnet';\n\ninterface DeepbookKnownCommonOptions extends DeepbookCommonOptions {\n\t/** Optional network override (defaults to the configured network). */\n\treadonly network?: string;\n}\n\ninterface DeepbookKnownNetworkOptions extends DeepbookKnownCommonOptions {\n\treadonly network: DeepbookKnownNetwork;\n\treadonly packageId?: string;\n\treadonly registryId?: string;\n}\n\ninterface DeepbookKnownExplicitOptions extends DeepbookKnownCommonOptions {\n\treadonly packageId: string;\n\treadonly registryId: string;\n\treadonly network?: DeepbookKnownNetwork;\n}\n\nexport type DeepbookKnownOptions = DeepbookKnownNetworkOptions | DeepbookKnownExplicitOptions;\n\nexport type DeepbookOptions<\n\tPublisher extends AccountMemberAlias = AccountMemberAlias,\n\tPyth extends PythOptions | undefined = PythOptions | undefined,\n> =\n\t| ({\n\t\t\treadonly mode: 'local';\n\t } & DeepbookLocalOptions<\n\t\t\tPublisher,\n\t\t\tDeepbookPackageMember,\n\t\t\tReadonlyArray<DeepbookPoolSpec>,\n\t\t\tPyth\n\t >)\n\t| ({ readonly mode: 'override' } & DeepbookOverrideOptions)\n\t| ({ readonly mode: 'known' } & DeepbookKnownOptions);\n\n// ---------------------------------------------------------------------------\n// Plugin construction — override\n// ---------------------------------------------------------------------------\n\nconst DEFAULT_NAME = 'deepbook';\n\nconst KNOWN_DEEPBOOK_DEPLOYMENTS: Record<\n\tDeepbookKnownNetwork,\n\t{\n\t\treadonly network: string;\n\t\treadonly packageId: string;\n\t\treadonly registryId: string;\n\t\treadonly deepTreasuryId: string;\n\t\treadonly pyth: PythHandle;\n\t}\n> = {\n\ttestnet: {\n\t\tnetwork: 'testnet',\n\t\tpackageId: '0x22be4cade64bf2d02412c7e8d0e8beea2f78828b948118d46735315409371a3c',\n\t\tregistryId: '0x7c256edbda983a2cd6f946655f4bf3f00a41043993781f8674a7046e8c0e11d1',\n\t\tdeepTreasuryId: '0x69fffdae0075f8f71f4fa793549c11079266910e8905169845af1f5d00e09dcb',\n\t\tpyth: {\n\t\t\tpackageId: null,\n\t\t\tstateId: '0x243759059f4c3111179da5878c12f68d612c21a8d54d85edc86164bb18be1c7c',\n\t\t\twormholeStateId: '0x31358d198147da50db32eda2562951d53973a0c0ad5ed738e9b17d88b213d790',\n\t\t\tfeeds: [],\n\t\t},\n\t},\n\tmainnet: {\n\t\tnetwork: 'mainnet',\n\t\tpackageId: '0xf48222c4e057fa468baf136bff8e12504209d43850c5778f76159292a96f621e',\n\t\tregistryId: '0xaf16199a2dff736e9f07a845f23c5da6df6f756eddb631aed9d24a93efc4549d',\n\t\tdeepTreasuryId: '0x032abf8948dda67a271bcc18e776dbbcfb0d58c8d288a700ff0d5521e57a1ffe',\n\t\tpyth: {\n\t\t\tpackageId: null,\n\t\t\tstateId: '0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8',\n\t\t\twormholeStateId: '0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c',\n\t\t\tfeeds: [],\n\t\t},\n\t},\n};\n\ntype PoolCoinRefs<Pools extends ReadonlyArray<DeepbookPoolSpec>> =\n\tPools[number] extends DeepbookPoolSpec<infer Base, infer Quote> ? Base | Quote : never;\ntype PoolCoinRefTuple<Pools extends ReadonlyArray<DeepbookPoolSpec>> = Pools extends readonly []\n\t? readonly []\n\t: readonly PoolCoinRefs<Pools>[];\n\ntype PythRefs<Pyth extends PythOptions | undefined> =\n\tPyth extends PythOptions<infer Package, infer Pusher> ? readonly [Pusher, Package] : readonly [];\n\ntype LocalDependsOn<\n\tPublisher extends AccountMemberAlias,\n\tPackage extends DeepbookPackageMember,\n\tPools extends ReadonlyArray<DeepbookPoolSpec>,\n\tPyth extends PythOptions | undefined,\n> = readonly [\n\ttypeof suiResource,\n\tPublisher,\n\tPackage,\n\t...PythRefs<Pyth>,\n\t...PoolCoinRefTuple<Pools>,\n];\n\nconst poolCoinRefs = <Pools extends ReadonlyArray<DeepbookPoolSpec>>(\n\tpools: Pools,\n): ReadonlyArray<PoolCoinRefs<Pools>> =>\n\tpools.flatMap((pool) => [pool.base.coin, pool.quote.coin]) as unknown as ReadonlyArray<\n\t\tPoolCoinRefs<Pools>\n\t>;\n\nconst pythRefs = <Pyth extends PythOptions | undefined>(pyth: Pyth): PythRefs<Pyth> =>\n\t(pyth === undefined ? [] : [pyth.pusher, pyth.package]) as unknown as PythRefs<Pyth>;\n\nconst localDependsOn = <\n\tPublisher extends AccountMemberAlias,\n\tPackage extends DeepbookPackageMember,\n\tPools extends ReadonlyArray<DeepbookPoolSpec>,\n\tPyth extends PythOptions | undefined,\n>(\n\topts: DeepbookLocalOptions<Publisher, Package, Pools, Pyth>,\n): LocalDependsOn<Publisher, Package, Pools, Pyth> =>\n\t[\n\t\tsuiResource,\n\t\topts.publisher,\n\t\topts.package,\n\t\t...pythRefs(opts.pyth),\n\t\t...poolCoinRefs((opts.pools ?? []) as Pools),\n\t] as unknown as LocalDependsOn<Publisher, Package, Pools, Pyth>;\n\nconst requireCapturedId = (\n\tpkg: LocalPackageResolved,\n\tkey: string,\n\tkind: 'registryId' | 'adminCapId',\n): Effect.Effect<string, DeepbookPluginError> => {\n\tconst value = pkg.captured[key];\n\tif (typeof value === 'string' && value.length > 0) {\n\t\treturn Effect.succeed(value);\n\t}\n\treturn Effect.fail(\n\t\tdeepbookPluginError(\n\t\t\t'publish',\n\t\t\t`deepbook local package '${pkg.name}' is missing captured ${kind} '${key}'.`,\n\t\t),\n\t);\n};\n\nconst requirePoolCoinValue = (\n\tcoinValuesByRefId: ReadonlyMap<string, CoinValue>,\n\tpoolName: string,\n\tside: 'base' | 'quote',\n\tcoinRefId: string,\n): Effect.Effect<CoinValue, DeepbookConfigError> => {\n\tconst value = coinValuesByRefId.get(coinRefId);\n\tif (value === undefined) {\n\t\t// Compose-time bug — `dependsOn`/`poolCoinRefs` dropped this coin.\n\t\t// Surface a typed config error naming the missing coin id rather\n\t\t// than letting a double-cast `undefined` slip into the resolved\n\t\t// pool spec. Lands on the typed E channel (not a sync throw, which\n\t\t// inside Effect.gen would become an uncaught DEFECT that\n\t\t// `passthroughOrWrap` could not see); `DeepbookConfigError` is in\n\t\t// `DEEPBOOK_ERROR_TAGS`, so the outer pipeline passes it through\n\t\t// untouched.\n\t\treturn Effect.fail(\n\t\t\tdeepbookConfigError(\n\t\t\t\t'pools',\n\t\t\t\t`deepbook: pool '${poolName}' ${side} coin '${coinRefId}' was not resolved by the dependency tuple.`,\n\t\t\t\t'This is a compose-time bug — ensure the coin member is included in `dependsOn`/`poolCoinRefs`.',\n\t\t\t),\n\t\t);\n\t}\n\treturn Effect.succeed(value);\n};\n\nconst resolvePoolSpecs = (\n\tpools: ReadonlyArray<DeepbookPoolSpec>,\n\tcoinValuesByRefId: ReadonlyMap<string, CoinValue>,\n): Effect.Effect<ReadonlyArray<ResolvedDeepbookPoolSpec>, DeepbookConfigError> =>\n\tEffect.forEach(pools, (pool) =>\n\t\tEffect.gen(function* () {\n\t\t\tconst base = yield* requirePoolCoinValue(\n\t\t\t\tcoinValuesByRefId,\n\t\t\t\tpool.name,\n\t\t\t\t'base',\n\t\t\t\tpool.base.coin.id,\n\t\t\t);\n\t\t\tconst quote = yield* requirePoolCoinValue(\n\t\t\t\tcoinValuesByRefId,\n\t\t\t\tpool.name,\n\t\t\t\t'quote',\n\t\t\t\tpool.quote.coin.id,\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tname: pool.name,\n\t\t\t\tbase: pool.base.key,\n\t\t\t\tquote: pool.quote.key,\n\t\t\t\tbaseCoinType: base.fullCoinType,\n\t\t\t\tquoteCoinType: quote.fullCoinType,\n\t\t\t\t...(base.fundingStrategy === undefined\n\t\t\t\t\t? {}\n\t\t\t\t\t: { baseFundingStrategy: base.fundingStrategy }),\n\t\t\t\t...(quote.fundingStrategy === undefined\n\t\t\t\t\t? {}\n\t\t\t\t\t: { quoteFundingStrategy: quote.fundingStrategy }),\n\t\t\t\ttickSize: pool.tickSize,\n\t\t\t\tlotSize: pool.lotSize,\n\t\t\t\tminSize: pool.minSize,\n\t\t\t\twhitelisted: pool.whitelisted ?? true,\n\t\t\t\tstablePool: pool.stablePool ?? false,\n\t\t\t\t...(pool.seed === undefined ? {} : { seed: pool.seed }),\n\t\t\t};\n\t\t}),\n\t);\n\nconst assertUniquePoolNames = (name: string, pools: ReadonlyArray<DeepbookPoolSpec>) => {\n\tconst seen = new Set<string>();\n\tfor (const pool of pools) {\n\t\tif (seen.has(pool.name)) {\n\t\t\tthrow deepbookConfigError(\n\t\t\t\t'pools',\n\t\t\t\t`deepbook({mode:'local', name:'${name}'}) has duplicate pool '${pool.name}'.`,\n\t\t\t\t'Give each local DeepBook pool a unique SDK key.',\n\t\t\t);\n\t\t}\n\t\tseen.add(pool.name);\n\t\tfor (const order of pool.seed?.orders ?? []) {\n\t\t\tif (order.quantity < pool.minSize) {\n\t\t\t\tthrow deepbookConfigError(\n\t\t\t\t\t'pools',\n\t\t\t\t\t`deepbook({mode:'local', name:'${name}'}) seed order for pool '${pool.name}' is below minSize.`,\n\t\t\t\t\t'Use a seed order quantity greater than or equal to the pool minSize.',\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (order.quantity % pool.lotSize !== 0n) {\n\t\t\t\tthrow deepbookConfigError(\n\t\t\t\t\t'pools',\n\t\t\t\t\t`deepbook({mode:'local', name:'${name}'}) seed order for pool '${pool.name}' is not lot-aligned.`,\n\t\t\t\t\t'Use a seed order quantity divisible by the pool lotSize.',\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (order.price % pool.tickSize !== 0n) {\n\t\t\t\tthrow deepbookConfigError(\n\t\t\t\t\t'pools',\n\t\t\t\t\t`deepbook({mode:'local', name:'${name}'}) seed order for pool '${pool.name}' is not tick-aligned.`,\n\t\t\t\t\t'Use a seed order price divisible by the pool tickSize.',\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n};\n\nconst buildOverridePlugin = (opts: DeepbookOverrideOptions) => {\n\tconst name = opts.name ?? DEFAULT_NAME;\n\tif (!opts.packageId || !opts.registryId || !opts.adminCapId) {\n\t\tthrow deepbookConfigError(\n\t\t\t'packageId',\n\t\t\t`deepbook({mode:'override', name:'${name}'}) requires packageId, registryId, and adminCapId.`,\n\t\t\t`Pass explicit deployment ids or use deepbook({mode:'known', network:'testnet'}).`,\n\t\t);\n\t}\n\tconst deepbookResource = makeDeepbookResource(name);\n\tconst snap = makeKnownSnapshotable({ name });\n\n\treturn definePlugin({\n\t\tid: deepbookResource.id,\n\t\tdependsOn: [suiResource] as const,\n\t\trole: 'task',\n\t\tsection: 'service',\n\t\tpluginKey: deepbookPluginKey(name),\n\t\t// Override mode's deployment ids are DECLARED config — bake them as\n\t\t// literals in the committed tree (mirrors `knownPackage`).\n\t\tstaticCodegen: () => [\n\t\t\tmakeDeepbookStaticCodegen({\n\t\t\t\tname,\n\t\t\t\tnetwork: opts.network ?? LOCAL_NETWORK_NAME,\n\t\t\t\tknown: {\n\t\t\t\t\tpackageId: opts.packageId,\n\t\t\t\t\tregistryId: opts.registryId,\n\t\t\t\t},\n\t\t\t}),\n\t\t],\n\t\t// `deps` auto-infers the resolved `[sui]` tuple from the\n\t\t// `[suiResource] as const` dependency. `ctx` arrives via the\n\t\t// `PluginContext` service.\n\t\tstart: () =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst ctx = yield* PluginContext;\n\t\t\t\tconst identity = yield* IdentityContext;\n\t\t\t\tconst network = opts.network ?? identity.network;\n\t\t\t\tconst resolved: DeepbookResolved = {\n\t\t\t\t\tmode: 'override',\n\t\t\t\t\tnetwork,\n\t\t\t\t\tpackageId: opts.packageId,\n\t\t\t\t\tregistryId: opts.registryId,\n\t\t\t\t\tadminCapId: opts.adminCapId,\n\t\t\t\t\tdeepTreasuryId: null,\n\t\t\t\t\tpools: [],\n\t\t\t\t\tpyth: null,\n\t\t\t\t\tmargin: null,\n\t\t\t\t\tserverUrl: null,\n\t\t\t\t\tindexerUrl: null,\n\t\t\t\t\thasSeedLiquidity: false,\n\t\t\t\t\tdeepFundingStrategy: null,\n\t\t\t\t};\n\t\t\t\t// Emit contributions inline: snapshot -> codegen. `resolved` is\n\t\t\t\t// the just-computed value; `snap` is the override-mode\n\t\t\t\t// identity-guard snapshotable in scope. No DEEP funding.\n\t\t\t\tconst bindings: DeepbookBindings = {\n\t\t\t\t\tname,\n\t\t\t\t\tnetwork: resolved.network,\n\t\t\t\t\tpackageId: resolved.packageId,\n\t\t\t\t\tregistryId: resolved.registryId,\n\t\t\t\t\tadminCapId: resolved.adminCapId,\n\t\t\t\t\tdeepTreasuryId: resolved.deepTreasuryId,\n\t\t\t\t\tpools: [],\n\t\t\t\t\tpyth: null,\n\t\t\t\t\tmargin: null,\n\t\t\t\t\tserverUrl: null,\n\t\t\t\t\tindexerUrl: null,\n\t\t\t\t};\n\t\t\t\tctx.snapshotExtra(snap);\n\t\t\t\tctx.codegen(makeDeepbookCodegenable(bindings));\n\t\t\t\treturn resolved;\n\t\t\t}),\n\t});\n};\n\n/** Concrete local options after the explicit-config guard: `publisher`,\n * `package`, and `pools` are guaranteed present. */\ntype ResolvedLocalOptions = DeepbookLocalOptions<\n\tAccountMemberAlias,\n\tDeepbookPackageMember,\n\tReadonlyArray<DeepbookPoolSpec>,\n\tPythOptions | undefined\n> & {\n\treadonly publisher: AccountMemberAlias;\n\treadonly package: DeepbookPackageMember;\n\treadonly pools: ReadonlyArray<DeepbookPoolSpec>;\n};\n\n/** Default local pool synthesized when `pools` is omitted: a single whitelisted\n * `DEEP/SUI` pool. DEEP is the deepbook package's own coin (no extra package to\n * publish), SUI is built-in, so this needs nothing beyond the `package` the\n * caller already passes — and NO seed, so it requires no DEEP minting (i.e. no\n * `deepTreasuryIdKey`) and works for a bare `deepbook({ publisher, package })`.\n * The pool is created with an empty book; pass explicit `pools` with a `seed`\n * (see `examples/deepbook-trader`) for pre-populated liquidity. */\nconst defaultLocalPools = (pkg: DeepbookPackageMember): ReadonlyArray<DeepbookPoolSpec> => [\n\t{\n\t\tname: 'DEEP_SUI',\n\t\tbase: { key: 'DEEP', coin: coinFromPackage(pkg, 'DEEP') },\n\t\tquote: { key: 'SUI', coin: builtinCoin('sui') },\n\t\ttickSize: 1_000_000n,\n\t\tlotSize: 1_000_000n,\n\t\tminSize: 10_000_000n,\n\t\twhitelisted: true,\n\t\tstablePool: false,\n\t},\n];\n\n/** Fail-fast guard for local mode: `publisher` and `package` are REQUIRED — a\n * publish tx needs a signer and the DeepBook Move package must be published\n * (capturing `registry::Registry` + `registry::DeepbookAdminCap`). `pools` is\n * OPTIONAL: omit it for a default unseeded (empty-book) `DEEP/SUI` pool (a\n * minimal usable DeX), pass `[]` for a pool-less deployment, or declare your own. `pyth`\n * stays optional (omit for a feed-less DeX). Missing a required field raises a\n * tagged `DeepbookConfigError` naming what to pass. */\nconst resolveLocalOptions = (\n\topts: DeepbookLocalOptions<\n\t\tAccountMemberAlias,\n\t\tDeepbookPackageMember,\n\t\tReadonlyArray<DeepbookPoolSpec>,\n\t\tPythOptions | undefined\n\t>,\n): ResolvedLocalOptions => {\n\tconst name = opts.name ?? DEFAULT_NAME;\n\tconst missing: string[] = [];\n\tif (!opts.publisher) {\n\t\tmissing.push('publisher');\n\t}\n\tif (!opts.package) {\n\t\tmissing.push('package');\n\t}\n\tif (missing.length > 0) {\n\t\tthrow deepbookConfigError(\n\t\t\tmissing[0] as string,\n\t\t\t`deepbook({mode:'local', name:'${name}'}) requires explicit ${missing.join(', ')}.`,\n\t\t\t`Publish the DeepBook Move package and pass at least { publisher, package } ` +\n\t\t\t\t`(see examples/deepbook-trader). Pools default to an unseeded (empty-book) DEEP/SUI pool.`,\n\t\t);\n\t}\n\t// Default to a single unseeded (empty-book) DEEP/SUI pool when none are declared.\n\tconst pools = opts.pools ?? defaultLocalPools(opts.package);\n\treturn { ...opts, pools } as ResolvedLocalOptions;\n};\n\nconst buildLocalPlugin = <\n\tconst Publisher extends AccountMemberAlias,\n\tconst Package extends DeepbookPackageMember,\n\tconst Pools extends ReadonlyArray<DeepbookPoolSpec> = readonly [],\n\tconst Pyth extends PythOptions | undefined = undefined,\n>(\n\trawOpts: DeepbookLocalOptions<Publisher, Package, Pools, Pyth>,\n) => {\n\tconst opts = resolveLocalOptions(\n\t\trawOpts as DeepbookLocalOptions<\n\t\t\tAccountMemberAlias,\n\t\t\tDeepbookPackageMember,\n\t\t\tReadonlyArray<DeepbookPoolSpec>,\n\t\t\tPythOptions | undefined\n\t\t>,\n\t);\n\tconst name = opts.name ?? DEFAULT_NAME;\n\tassertUniquePoolNames(name, opts.pools);\n\n\tconst deepbookResource = makeDeepbookResource(name);\n\t// Runtime `dependsOn` carries the caller's explicit member refs so\n\t// `defineDevstack`'s dependency-closure expander pulls the publisher /\n\t// package / coin / pyth members into the stack. The STATIC type stays keyed\n\t// to the caller's narrow generics so explicit callers keep their exact\n\t// closure (no generic `coin:`/`package:` provider demands).\n\tconst dependsOn = localDependsOn(opts) as unknown as LocalDependsOn<\n\t\tPublisher,\n\t\tPackage,\n\t\tPools,\n\t\tPyth\n\t>;\n\n\treturn definePlugin({\n\t\tid: deepbookResource.id,\n\t\tdependsOn,\n\t\trole: 'task',\n\t\tsection: 'service',\n\t\tpluginKey: deepbookPluginKey(name),\n\t\t// Stack-free codegen: a local deployment's ids / pools / pyth feeds\n\t\t// are LOADED CONFIG DATA -- the committed `deepbook.ts` stub emits\n\t\t// `requireValue(dep, 'deepbook:<name>', '<key>')`, never a baked id.\n\t\tstaticCodegen: () => [makeDeepbookStaticCodegen({ name, network: LOCAL_NETWORK_NAME })],\n\t\t// `deps` auto-infers from the runtime-built `dependsOn`; it\n\t\t// resolves to a heterogeneous tuple the body re-narrows via the\n\t\t// `as unknown as` cast below. `ctx` arrives via the\n\t\t// `PluginContext` service.\n\t\tstart: (deps) =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst ctx = yield* PluginContext;\n\t\t\t\tconst identity = yield* IdentityContext;\n\t\t\t\tconst [sui, publisher, deepbookPackage, ...extraValues] = deps as unknown as readonly [\n\t\t\t\t\tResourceValueOf<typeof suiResource>,\n\t\t\t\t\tAccountValue,\n\t\t\t\t\tLocalPackageResolved,\n\t\t\t\t\t...(AccountValue | LocalPackageResolved | CoinValue)[],\n\t\t\t\t];\n\t\t\t\tconst pythValueCount = opts.pyth === undefined ? 0 : 2;\n\t\t\t\tconst pythValues = extraValues.slice(0, pythValueCount);\n\t\t\t\tconst coinValues = extraValues.slice(pythValueCount) as CoinValue[];\n\n\t\t\t\tyield* setCurrentPluginPhase('reading deployment captures');\n\n\t\t\t\tconst registryId = yield* requireCapturedId(\n\t\t\t\t\tdeepbookPackage,\n\t\t\t\t\topts.registryIdKey ?? 'registryId',\n\t\t\t\t\t'registryId',\n\t\t\t\t);\n\t\t\t\tconst adminCapId = yield* requireCapturedId(\n\t\t\t\t\tdeepbookPackage,\n\t\t\t\t\topts.adminCapIdKey ?? 'adminCapId',\n\t\t\t\t\t'adminCapId',\n\t\t\t\t);\n\t\t\t\tconst deepTreasuryId =\n\t\t\t\t\topts.deepTreasuryIdKey === undefined\n\t\t\t\t\t\t? null\n\t\t\t\t\t\t: (deepbookPackage.captured[opts.deepTreasuryIdKey] ?? null);\n\t\t\t\tconst deployment: DeepbookDeployment = {\n\t\t\t\t\tpackageId: deepbookPackage.packageId,\n\t\t\t\t\tregistryId,\n\t\t\t\t\tadminCapId,\n\t\t\t\t\tdeepTreasuryId,\n\t\t\t\t};\n\t\t\t\tconst poolRefs = poolCoinRefs(opts.pools);\n\t\t\t\tconst coinValuesByRefId = new Map<string, CoinValue>();\n\t\t\t\tfor (let i = 0; i < poolRefs.length; i += 1) {\n\t\t\t\t\tconst ref = poolRefs[i];\n\t\t\t\t\tconst value = coinValues[i];\n\t\t\t\t\tif (ref !== undefined && value !== undefined) {\n\t\t\t\t\t\tcoinValuesByRefId.set(ref.id, value);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst poolSpecs = yield* resolvePoolSpecs(opts.pools, coinValuesByRefId);\n\t\t\t\tconst artifactPublisher = yield* CacheService;\n\t\t\t\tyield* setCurrentPluginPhase(\n\t\t\t\t\topts.pyth === undefined ? 'creating pools' : 'initializing Pyth feeds',\n\t\t\t\t);\n\t\t\t\tconst pyth =\n\t\t\t\t\topts.pyth === undefined\n\t\t\t\t\t\t? null\n\t\t\t\t\t\t: yield* initLocalPythFeeds(\n\t\t\t\t\t\t\t\tartifactPublisher,\n\t\t\t\t\t\t\t\tsui.sdk,\n\t\t\t\t\t\t\t\tsui.chainId,\n\t\t\t\t\t\t\t\tpythValues[0] as AccountValue,\n\t\t\t\t\t\t\t\t{ packageId: (pythValues[1] as LocalPackageResolved).packageId },\n\t\t\t\t\t\t\t\topts.pyth.feeds,\n\t\t\t\t\t\t\t);\n\t\t\t\tyield* setCurrentPluginPhase('creating pools');\n\t\t\t\tconst poolResult = yield* createDeepbookPools(\n\t\t\t\t\tartifactPublisher,\n\t\t\t\t\tsui.sdk,\n\t\t\t\t\tsui.chainId,\n\t\t\t\t\tpublisher,\n\t\t\t\t\tdeployment,\n\t\t\t\t\tpoolSpecs,\n\t\t\t\t);\n\t\t\t\tyield* setCurrentPluginPhase('seeding pools');\n\t\t\t\tconst seedResults = yield* seedDeepbookPools(\n\t\t\t\t\tartifactPublisher,\n\t\t\t\t\tsui.sdk,\n\t\t\t\t\tsui.chainId,\n\t\t\t\t\tpublisher,\n\t\t\t\t\tdeployment,\n\t\t\t\t\tpoolSpecs,\n\t\t\t\t\tpoolResult.pools,\n\t\t\t\t);\n\t\t\t\tyield* setCurrentPluginPhase(null);\n\n\t\t\t\tconst resolved: DeepbookResolved = {\n\t\t\t\t\tmode: 'local',\n\t\t\t\t\tnetwork: identity.network,\n\t\t\t\t\tpackageId: deployment.packageId,\n\t\t\t\t\tregistryId: deployment.registryId,\n\t\t\t\t\tadminCapId: deployment.adminCapId,\n\t\t\t\t\tdeepTreasuryId,\n\t\t\t\t\tpools: poolResult.pools,\n\t\t\t\t\tpyth,\n\t\t\t\t\tmargin: null,\n\t\t\t\t\tserverUrl: null,\n\t\t\t\t\tindexerUrl: null,\n\t\t\t\t\thasSeedLiquidity: seedResults.length > 0,\n\t\t\t\t\tdeepFundingStrategy: null,\n\t\t\t\t};\n\t\t\t\t// Emit contributions inline: snapshot -> codegen. `resolved` is\n\t\t\t\t// the just-computed value; the snapshotable is the local-mode\n\t\t\t\t// `deepbook/<name>` subtree. No DEEP funding (null in local).\n\t\t\t\tconst snap: SnapshotableDecl = makeLocalSnapshotable({ name });\n\t\t\t\tconst bindings: DeepbookBindings = {\n\t\t\t\t\tname,\n\t\t\t\t\tnetwork: resolved.network,\n\t\t\t\t\tpackageId: resolved.packageId,\n\t\t\t\t\tregistryId: resolved.registryId,\n\t\t\t\t\tadminCapId: resolved.adminCapId,\n\t\t\t\t\tdeepTreasuryId: resolved.deepTreasuryId,\n\t\t\t\t\tpools: resolved.pools.map((p) => ({\n\t\t\t\t\t\tname: p.name,\n\t\t\t\t\t\tpoolId: p.poolId,\n\t\t\t\t\t\tbase: p.base,\n\t\t\t\t\t\tquote: p.quote,\n\t\t\t\t\t\tbaseCoinType: p.baseCoinType,\n\t\t\t\t\t\tquoteCoinType: p.quoteCoinType,\n\t\t\t\t\t})),\n\t\t\t\t\tpyth: resolved.pyth\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tpackageId: resolved.pyth.packageId,\n\t\t\t\t\t\t\t\tstateId: resolved.pyth.stateId,\n\t\t\t\t\t\t\t\twormholeStateId: resolved.pyth.wormholeStateId,\n\t\t\t\t\t\t\t\tfeeds: resolved.pyth.feeds.map((feed) => ({\n\t\t\t\t\t\t\t\t\tsymbol: feed.symbol,\n\t\t\t\t\t\t\t\t\tfeedId: feed.feedId,\n\t\t\t\t\t\t\t\t\tpriceInfoObjectId: feed.priceInfoObjectId,\n\t\t\t\t\t\t\t\t\tprice: feed.price.toString(),\n\t\t\t\t\t\t\t\t\texpo: feed.expo,\n\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: null,\n\t\t\t\t\tmargin: resolved.margin,\n\t\t\t\t\tserverUrl: resolved.serverUrl,\n\t\t\t\t\tindexerUrl: resolved.indexerUrl,\n\t\t\t\t};\n\t\t\t\tctx.snapshotExtra(snap);\n\t\t\t\tctx.codegen(makeDeepbookCodegenable(bindings));\n\t\t\t\treturn resolved;\n\t\t\t}).pipe(\n\t\t\t\t// The body's aggregate E channel includes substrate Effects\n\t\t\t\t// whose error shape is unknown to TS (ArtifactPublisher\n\t\t\t\t// produce bodies, dependency reads). `Effect.catchTags`\n\t\t\t\t// would need a statically-known tagged union; the\n\t\t\t\t// substrate's `passthroughOrWrap` runtime-checks the `_tag`\n\t\t\t\t// against `DEEPBOOK_ERROR_TAGS`, passing typed deepbook\n\t\t\t\t// errors through untouched and wrapping everything else\n\t\t\t\t// under `'publish'` so cascade attribution stays with the\n\t\t\t\t// plugin.\n\t\t\t\tpassthroughOrWrap.for<DeepbookError>()(DEEPBOOK_ERROR_TAGS, (err) =>\n\t\t\t\t\tdeepbookPluginError('publish', `deepbook acquire failed: ${String(err)}`, {\n\t\t\t\t\t\tcause: err,\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t),\n\t});\n};\n\nfunction buildLocalPluginPublic<\n\tconst Publisher extends AccountMemberAlias,\n\tconst Package extends DeepbookPackageMember,\n\tconst Pools extends ReadonlyArray<DeepbookPoolSpec>,\n\tconst Pyth extends PythOptions | undefined = undefined,\n>(\n\topts: DeepbookLocalOptions<Publisher, Package, Pools, Pyth>,\n): DeepbookLocalMember<Publisher, Package, Pools, Pyth>;\nfunction buildLocalPluginPublic<\n\tconst Publisher extends AccountMemberAlias,\n\tconst Package extends DeepbookPackageMember,\n\tconst Pools extends ReadonlyArray<DeepbookPoolSpec>,\n\tconst Pyth extends PythOptions | undefined = undefined,\n>(opts: DeepbookLocalOptions<Publisher, Package, Pools, Pyth>) {\n\treturn buildLocalPlugin(opts);\n}\n\n// ---------------------------------------------------------------------------\n// Plugin construction — known\n// ---------------------------------------------------------------------------\n\nconst buildKnownPlugin = (opts: DeepbookKnownOptions) => {\n\tconst name = opts.name ?? DEFAULT_NAME;\n\tconst known = opts.network ? KNOWN_DEEPBOOK_DEPLOYMENTS[opts.network] : null;\n\tconst packageId = opts.packageId ?? known?.packageId;\n\tconst registryId = opts.registryId ?? known?.registryId;\n\tif (!packageId || !registryId) {\n\t\tthrow deepbookConfigError(\n\t\t\t'packageId',\n\t\t\t`deepbook({mode:'known', name:'${name}'}) requires packageId and registryId, or network:'mainnet'|'testnet'.`,\n\t\t\t`Pass explicit ids or use deepbook({mode:'known', network:'testnet'}).`,\n\t\t);\n\t}\n\tconst deepbookResource = makeDeepbookResource(name);\n\tconst snap = makeKnownSnapshotable({ name });\n\n\treturn definePlugin({\n\t\tid: deepbookResource.id,\n\t\tdependsOn: [suiResource] as const,\n\t\trole: 'task',\n\t\tsection: 'service',\n\t\tpluginKey: deepbookPluginKey(name),\n\t\t// Known mode's deployment ids (package / registry / deep-treasury) and\n\t\t// its declared testnet/mainnet Pyth ids are DECLARED config — bake them\n\t\t// as literals in the committed tree (mirrors `knownPackage`).\n\t\tstaticCodegen: () => [\n\t\t\tmakeDeepbookStaticCodegen({\n\t\t\t\tname,\n\t\t\t\tnetwork: opts.network ?? known?.network ?? LOCAL_NETWORK_NAME,\n\t\t\t\tknown: {\n\t\t\t\t\tpackageId,\n\t\t\t\t\tregistryId,\n\t\t\t\t\tdeepTreasuryId: known?.deepTreasuryId ?? null,\n\t\t\t\t\tpyth: known?.pyth\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tpackageId: known.pyth.packageId,\n\t\t\t\t\t\t\t\tstateId: known.pyth.stateId,\n\t\t\t\t\t\t\t\twormholeStateId: known.pyth.wormholeStateId,\n\t\t\t\t\t\t\t\tfeeds: known.pyth.feeds.map((feed) => ({\n\t\t\t\t\t\t\t\t\tsymbol: feed.symbol,\n\t\t\t\t\t\t\t\t\tfeedId: feed.feedId,\n\t\t\t\t\t\t\t\t\tpriceInfoObjectId: feed.priceInfoObjectId,\n\t\t\t\t\t\t\t\t\tprice: feed.price.toString(),\n\t\t\t\t\t\t\t\t\texpo: feed.expo,\n\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: null,\n\t\t\t\t},\n\t\t\t}),\n\t\t],\n\t\t// `deps` auto-infers the resolved `[sui]` tuple from the\n\t\t// `[suiResource] as const` dependency. `ctx` arrives via the\n\t\t// `PluginContext` service.\n\t\tstart: (deps) =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst ctx = yield* PluginContext;\n\t\t\t\tconst identity = yield* IdentityContext;\n\t\t\t\tconst [sui] = deps;\n\t\t\t\tconst network = opts.network ?? known?.network ?? identity.network;\n\t\t\t\tconst resolved: DeepbookResolved = {\n\t\t\t\t\tmode: 'known',\n\t\t\t\t\tnetwork,\n\t\t\t\t\tpackageId,\n\t\t\t\t\tregistryId,\n\t\t\t\t\tadminCapId: null,\n\t\t\t\t\tdeepTreasuryId: known?.deepTreasuryId ?? null,\n\t\t\t\t\tpools: [],\n\t\t\t\t\tpyth: known?.pyth ?? null,\n\t\t\t\t\tmargin: null,\n\t\t\t\t\tserverUrl: null,\n\t\t\t\t\tindexerUrl: null,\n\t\t\t\t\thasSeedLiquidity: false,\n\t\t\t\t\t// DEEP funding is a testnet-deepbook concern — gate on the\n\t\t\t\t\t// network name alone. (The old `&& String(chain) === 'sui:testnet'`\n\t\t\t\t\t// conjunct compared a genesis-digest chainId against a network\n\t\t\t\t\t// literal and was dead for every non-literal `chain` value.)\n\t\t\t\t\tdeepFundingStrategy:\n\t\t\t\t\t\topts.network === 'testnet'\n\t\t\t\t\t\t\t? makeDeepbookDeepFundingStrategy({ suiSdk: sui.sdk })\n\t\t\t\t\t\t\t: null,\n\t\t\t\t};\n\t\t\t\t// Emit contributions inline: snapshot -> codegen -> (optional\n\t\t\t\t// DEEP funding strategy). `resolved` is the just-computed value;\n\t\t\t\t// `snap` is the known-mode identity-guard snapshotable in scope.\n\t\t\t\t// The DEEP funding contributor is emitted only when\n\t\t\t\t// `resolved.deepFundingStrategy` is non-null.\n\t\t\t\tconst bindings: DeepbookBindings = {\n\t\t\t\t\tname,\n\t\t\t\t\tnetwork: resolved.network,\n\t\t\t\t\tpackageId: resolved.packageId,\n\t\t\t\t\tregistryId: resolved.registryId,\n\t\t\t\t\tadminCapId: null,\n\t\t\t\t\tdeepTreasuryId: resolved.deepTreasuryId,\n\t\t\t\t\tpools: [],\n\t\t\t\t\tpyth: resolved.pyth\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tpackageId: resolved.pyth.packageId,\n\t\t\t\t\t\t\t\tstateId: resolved.pyth.stateId,\n\t\t\t\t\t\t\t\twormholeStateId: resolved.pyth.wormholeStateId,\n\t\t\t\t\t\t\t\tfeeds: resolved.pyth.feeds.map((feed) => ({\n\t\t\t\t\t\t\t\t\tsymbol: feed.symbol,\n\t\t\t\t\t\t\t\t\tfeedId: feed.feedId,\n\t\t\t\t\t\t\t\t\tpriceInfoObjectId: feed.priceInfoObjectId,\n\t\t\t\t\t\t\t\t\tprice: feed.price.toString(),\n\t\t\t\t\t\t\t\t\texpo: feed.expo,\n\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: null,\n\t\t\t\t\tmargin: null,\n\t\t\t\t\tserverUrl: null,\n\t\t\t\t\tindexerUrl: null,\n\t\t\t\t};\n\t\t\t\tctx.snapshotExtra(snap);\n\t\t\t\tctx.codegen(makeDeepbookCodegenable(bindings));\n\t\t\t\tif (resolved.deepFundingStrategy != null) {\n\t\t\t\t\tctx.provides(makeDeepbookDeepFundingContribution(resolved.deepFundingStrategy));\n\t\t\t\t}\n\t\t\t\treturn resolved;\n\t\t\t}),\n\t});\n};\n\n// ---------------------------------------------------------------------------\n// Default option resolution (env-driven)\n// ---------------------------------------------------------------------------\n\nconst resolveDefaultMode = <\n\tconst Publisher extends AccountMemberAlias,\n\tconst Package extends DeepbookPackageMember,\n\tconst Pools extends ReadonlyArray<DeepbookPoolSpec> = readonly [],\n\tconst Pyth extends PythOptions | undefined = undefined,\n>(\n\topts?: DeepbookLocalOptions<Publisher, Package, Pools, Pyth>,\n): DeepbookOptions<Publisher, Pyth> => {\n\tconst env = (globalThis as { process?: { env?: Record<string, string | undefined> } }).process\n\t\t?.env?.DEVSTACK_NETWORK;\n\tif (env === undefined || env === 'localnet') {\n\t\t// Local DeepBook: default to local mode on localnet. The caller must\n\t\t// supply explicit `{ publisher, package, pools }`; `resolveLocalOptions`\n\t\t// fails fast otherwise (no auto-synthesis).\n\t\treturn { mode: 'local', ...opts } as DeepbookOptions<Publisher, Pyth>;\n\t}\n\t// Non-local default: refuse — known mode requires explicit\n\t// packageId/registryId. The user passes them via\n\t// `deepbookFor(network).known({...})` or `deepbook({mode:'known',...})`.\n\tthrow deepbookConfigError(\n\t\t'mode',\n\t\t`deepbook(): cannot auto-default to known mode on network='${env}'.`,\n\t\t`Use deepbookFor(network).known({packageId, registryId, ...}).`,\n\t);\n};\n\n// ---------------------------------------------------------------------------\n// User-facing factories\n// ---------------------------------------------------------------------------\n\n/** Env-driven factory. Defaults to local mode on localnet when passed local\n * options. Explicit `override` and `known` modes bypass env inference. */\ntype DeepbookLocalMember<\n\tPublisher extends AccountMemberAlias,\n\tPackage extends DeepbookPackageMember,\n\tPools extends ReadonlyArray<DeepbookPoolSpec>,\n\tPyth extends PythOptions | undefined = undefined,\n> = ReturnType<typeof buildLocalPlugin<Publisher, Package, Pools, Pyth>>;\ntype DeepbookOverrideMember = ReturnType<typeof buildOverridePlugin>;\ntype DeepbookKnownMember = ReturnType<typeof buildKnownPlugin>;\n\n// Local DeepBook requires explicit `{ publisher, package, pools }`. There is\n// no zero-arg/synthesized overload — an under-specified call fails fast (see\n// `resolveLocalOptions`).\nexport function deepbookCore<\n\tconst Publisher extends AccountMemberAlias,\n\tconst Package extends DeepbookPackageMember,\n\tconst Pools extends ReadonlyArray<DeepbookPoolSpec> = readonly [],\n\tconst Pyth extends PythOptions | undefined = undefined,\n>(\n\topts: { readonly mode: 'local' } & DeepbookLocalOptions<Publisher, Package, Pools, Pyth>,\n): DeepbookLocalMember<Publisher, Package, Pools, Pyth>;\nexport function deepbookCore(\n\topts: { readonly mode: 'override' } & DeepbookOverrideOptions,\n): DeepbookOverrideMember;\nexport function deepbookCore(\n\topts: { readonly mode: 'known' } & DeepbookKnownOptions,\n): DeepbookKnownMember;\nexport function deepbookCore<\n\tconst Publisher extends AccountMemberAlias,\n\tconst Package extends DeepbookPackageMember,\n\tconst Pools extends ReadonlyArray<DeepbookPoolSpec> = readonly [],\n\tconst Pyth extends PythOptions | undefined = undefined,\n>(\n\topts: DeepbookLocalOptions<Publisher, Package, Pools, Pyth>,\n): DeepbookLocalMember<Publisher, Package, Pools, Pyth>;\nexport function deepbookCore<\n\tconst Publisher extends AccountMemberAlias,\n\tconst Package extends DeepbookPackageMember,\n\tconst Pools extends ReadonlyArray<DeepbookPoolSpec> = readonly [],\n\tconst Pyth extends PythOptions | undefined = undefined,\n>(\n\topts?: DeepbookLocalOptions<Publisher, Package, Pools, Pyth> | DeepbookOptions<Publisher, Pyth>,\n):\n\t| DeepbookLocalMember<Publisher, Package, Pools, Pyth>\n\t| DeepbookOverrideMember\n\t| DeepbookKnownMember {\n\tconst resolved: DeepbookOptions<Publisher, Pyth> =\n\t\topts !== undefined && 'mode' in opts\n\t\t\t? (opts as DeepbookOptions<Publisher, Pyth>)\n\t\t\t: resolveDefaultMode(\n\t\t\t\t\topts as DeepbookLocalOptions<Publisher, Package, Pools, Pyth> | undefined,\n\t\t\t\t);\n\tswitch (resolved.mode) {\n\t\tcase 'local': {\n\t\t\tconst localOpts = resolved as { readonly mode: 'local' } & DeepbookLocalOptions<\n\t\t\t\tPublisher,\n\t\t\t\tPackage,\n\t\t\t\tPools,\n\t\t\t\tPyth\n\t\t\t>;\n\t\t\t// Explicit-config path only; `buildLocalPlugin` -> `resolveLocalOptions`\n\t\t\t// fails fast when `publisher`/`package`/`pools` are missing.\n\t\t\treturn buildLocalPluginPublic(localOpts) as DeepbookLocalMember<\n\t\t\t\tPublisher,\n\t\t\t\tPackage,\n\t\t\t\tPools,\n\t\t\t\tPyth\n\t\t\t>;\n\t\t}\n\t\tcase 'override':\n\t\t\treturn buildOverridePlugin(resolved);\n\t\tcase 'known':\n\t\t\treturn buildKnownPlugin(resolved);\n\t}\n}\n\n/** Mode-narrowed factory namespace.\n *\n * Usage:\n * const local = { mode: 'local', network: 'localnet' } as const;\n * deepbookFor(local).local({publisher, package, pools}) // OK\n * deepbookFor(local).override({packageId, registryId, adminCapId}) // OK\n * deepbookFor(local).known({...}) // OK\n *\n * const fork = { mode: 'fork', network: 'mainnet-fork', upstream: 'mainnet' } as const;\n * deepbookFor(fork).local({...}) // COMPILE ERROR\n * deepbookFor(fork).override({...}) // COMPILE ERROR\n *\n * The fork branch has NO `.local` or `.override` entry — `deepbookFor(forkNetwork).local`\n * is a compile-time refusal. */\nexport const deepbookFor = defineModeNamespace({\n\tlocal: {\n\t\tlocal: <\n\t\t\tconst Publisher extends AccountMemberAlias,\n\t\t\tconst Package extends DeepbookPackageMember,\n\t\t\tconst Pools extends ReadonlyArray<DeepbookPoolSpec> = readonly [],\n\t\t\tconst Pyth extends PythOptions | undefined = undefined,\n\t\t>(\n\t\t\topts: DeepbookLocalOptions<Publisher, Package, Pools, Pyth>,\n\t\t) => buildLocalPluginPublic(opts),\n\t\toverride: (opts: DeepbookOverrideOptions) => buildOverridePlugin(opts),\n\t\tknown: (opts: DeepbookKnownOptions) => buildKnownPlugin(opts),\n\t},\n\tlive: {\n\t\tknown: (opts: DeepbookKnownOptions) => buildKnownPlugin(opts),\n\t},\n\tfork: {\n\t\t// `.override` intentionally absent — compile-time refusal.\n\t\tknown: (opts: DeepbookKnownOptions) => buildKnownPlugin(opts),\n\t},\n});\n\nexport { deepbookCore as deepbook };\n\n// ---------------------------------------------------------------------------\n// Re-exports for advanced callers\n// ---------------------------------------------------------------------------\n\nexport {\n\tDEEPBOOK_DEEP_FAUCET_STRATEGY_KEY,\n\tDEEPBOOK_TESTNET_DEEP_COIN_TYPE,\n} from './faucet-strategy.ts';\nexport {\n\ttype DeepbookError,\n\ttype DeepbookPluginError,\n\ttype DeepbookConfigError,\n\ttype DeepbookPhase,\n} from './errors.ts';\nexport type { DeepbookBindings } from './codegen.ts';\nexport type {\n\tAccountMemberAlias,\n\tCoinMemberAlias,\n\tDeepbookPackageMember,\n\tDeepbookPool,\n\tDeepbookPoolCoin,\n\tDeepbookPoolSeedLiquidity,\n\tDeepbookPoolSeedOrder,\n\tDeepbookPoolSpec,\n} from './types.ts';\nexport {\n\tDEEP_PRICE_FEED_ID,\n\tpythPriceFeedId,\n\tSUI_PRICE_FEED_ID,\n\tUSDC_PRICE_FEED_ID,\n} from './types.ts';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAgGA,MAAM,wBAA6C,SAClD,SACC,YAAY,MACb;AA8HD,MAAM,eAAe;AAErB,MAAM,6BASF;CACH,SAAS;EACR,SAAS;EACT,WAAW;EACX,YAAY;EACZ,gBAAgB;EAChB,MAAM;GACL,WAAW;GACX,SAAS;GACT,iBAAiB;GACjB,OAAO,CAAC;EACT;CACD;CACA,SAAS;EACR,SAAS;EACT,WAAW;EACX,YAAY;EACZ,gBAAgB;EAChB,MAAM;GACL,WAAW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AAMA,MAAM,sBAML,SACsC;CACtC,MAAM,MAAO,WAA0E,SACpF,KAAK;CACR,IAAI,QAAQ,KAAA,KAAa,QAAQ,YAIhC,OAAO;EAAE,MAAM;EAAS,GAAG;CAAK;CAKjC,MAAM,oBACL,QACA,6DAA6D,IAAI,KACjE,+DACD;AACD;AA0CA,SAAgB,aAMf,MAIsB;CACtB,MAAM,WACL,SAAS,KAAA,KAAa,UAAU,OAC5B,OACD,mBACA,IACD;CACH,QAAQ,SAAS,MAAjB;EACC,KAAK,SASJ,OAAO,uBAAuBC,QAAS;EAOxC,KAAK,YACJ,OAAO,oBAAoB,QAAQ;EACpC,KAAK,SACJ,OAAO,iBAAiB,QAAQ;CAClC;AACD;;;;;;;;;;;;;;;AAgBA,MAAa,cAAc,oBAAoB;CAC9C,OAAO;EACN,QAMC,SACI,uBAAuB,IAAI;EAChC,WAAW,SAAkC,oBAAoB,IAAI;EACrE,QAAQ,SAA+B,iBAAiB,IAAI;CAC7D;CACA,MAAM,EACL,QAAQ,SAA+B,iBAAiB,IAAI,EAC7D;CACA,MAAM,EAEL,QAAQ,SAA+B,iBAAiB,IAAI,EAC7D;AACD,CAAC"}
|
|
@@ -5,7 +5,6 @@ const defineSimpleConstExport = (spec) => ({
|
|
|
5
5
|
emitterName: spec.emitterName,
|
|
6
6
|
outputPath: spec.outputPath,
|
|
7
7
|
sensitive: spec.sensitive ?? false,
|
|
8
|
-
...spec.outputLocation ? { outputLocation: spec.outputLocation } : {},
|
|
9
8
|
...spec.aggregateOnly ? { aggregateOnly: spec.aggregateOnly } : {},
|
|
10
9
|
...spec.aggregate ? { aggregate: spec.aggregate } : {},
|
|
11
10
|
emit: (ctx) => Effect.gen(function* () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codegen-helpers.mjs","names":[],"sources":["../../../src/plugins/internal/codegen-helpers.ts"],"sourcesContent":["// Internal plugin helpers — codegen shape factories.\n//\n// `defineSimpleConstExport` collapses the duplicated `CodegenableDecl`\n// boilerplate shared by the per-plugin `codegen.ts` modules. Each of\n// those plugins emits one file containing exactly one `export const`\n// from a resolved value record, optionally joining a cross-decl\n// aggregate bucket and optionally running a pre-emit Effect (e.g. span\n// annotation) before writing.\n//\n// Internal to this package — not re-exported from the root barrel.\n\nimport { Effect } from 'effect';\n\nimport type {
|
|
1
|
+
{"version":3,"file":"codegen-helpers.mjs","names":[],"sources":["../../../src/plugins/internal/codegen-helpers.ts"],"sourcesContent":["// Internal plugin helpers — codegen shape factories.\n//\n// `defineSimpleConstExport` collapses the duplicated `CodegenableDecl`\n// boilerplate shared by the per-plugin `codegen.ts` modules. Each of\n// those plugins emits one file containing exactly one `export const`\n// from a resolved value record, optionally joining a cross-decl\n// aggregate bucket and optionally running a pre-emit Effect (e.g. span\n// annotation) before writing.\n//\n// Internal to this package — not re-exported from the root barrel.\n\nimport { Effect } from 'effect';\n\nimport type { AggregateContribution, CodegenableDecl } from '../../contracts/codegenable.ts';\n\n/** Spec for a `CodegenableDecl` that emits a single `export const`.\n *\n * `Emitter` is preserved as a generic so plugins that template the\n * emitter name (e.g. `coin/${symbol}`, `account/${name}`) keep their\n * literal-typed emission identity. */\nexport interface SimpleConstExportSpec<Emitter extends string, Value> {\n\treadonly emitterName: Emitter;\n\treadonly outputPath: string;\n\treadonly exportName: string;\n\treadonly value: Value;\n\treadonly sensitive?: boolean;\n\t/** Contribute only to the `aggregate` bucket — skip the standalone\n\t * file. Default `false`. */\n\treadonly aggregateOnly?: boolean;\n\treadonly aggregate?: AggregateContribution;\n\t/** Optional Effect run before the `exportConst` write — used by the\n\t * wallet plugin to annotate the current span with a redacted form\n\t * of the emitted value. Runs inside the emit Effect so the\n\t * annotation lands on the codegen span. */\n\treadonly preEmit?: Effect.Effect<void>;\n}\n\nexport const defineSimpleConstExport = <Emitter extends string, Value>(\n\tspec: SimpleConstExportSpec<Emitter, Value>,\n): CodegenableDecl<Emitter> => ({\n\tkind: 'codegenable',\n\temitterName: spec.emitterName,\n\toutputPath: spec.outputPath,\n\tsensitive: spec.sensitive ?? false,\n\t...(spec.aggregateOnly ? { aggregateOnly: spec.aggregateOnly } : {}),\n\t...(spec.aggregate ? { aggregate: spec.aggregate } : {}),\n\temit: (ctx) =>\n\t\tEffect.gen(function* () {\n\t\t\tif (spec.preEmit) {\n\t\t\t\tyield* spec.preEmit;\n\t\t\t}\n\t\t\tctx.exportConst(spec.exportName, spec.value);\n\t\t\treturn ctx.done();\n\t\t}),\n});\n"],"mappings":";;AAqCA,MAAa,2BACZ,UAC+B;CAC/B,MAAM;CACN,aAAa,KAAK;CAClB,YAAY,KAAK;CACjB,WAAW,KAAK,aAAa;CAC7B,GAAI,KAAK,gBAAgB,EAAE,eAAe,KAAK,cAAc,IAAI,CAAC;CAClE,GAAI,KAAK,YAAY,EAAE,WAAW,KAAK,UAAU,IAAI,CAAC;CACtD,OAAO,QACN,OAAO,IAAI,aAAa;EACvB,IAAI,KAAK,SACR,OAAO,KAAK;EAEb,IAAI,YAAY,KAAK,YAAY,KAAK,KAAK;EAC3C,OAAO,IAAI,KAAK;CACjB,CAAC;AACH"}
|
|
@@ -1,12 +1 @@
|
|
|
1
|
-
import { PackageBindings } from "../../orchestrators/codegen/bindings.mjs";
|
|
2
|
-
//#region src/plugins/package/codegen.d.ts
|
|
3
|
-
/** Per-network declared ids — pure literals the user supplies for
|
|
4
|
-
* prod-targeting (`testnet`/`mainnet`). No resolution. */
|
|
5
|
-
interface PackageNetworkEntry {
|
|
6
|
-
readonly packageId: string;
|
|
7
|
-
readonly objects?: Readonly<Record<string, string>>;
|
|
8
|
-
}
|
|
9
|
-
type PackageNetworks = Readonly<Record<string, PackageNetworkEntry>>;
|
|
10
|
-
//#endregion
|
|
11
|
-
export { PackageNetworkEntry, PackageNetworks };
|
|
12
|
-
//# sourceMappingURL=codegen.d.mts.map
|
|
1
|
+
import { PackageBindings } from "../../orchestrators/codegen/bindings.mjs";
|
|
@@ -1,16 +1,26 @@
|
|
|
1
|
-
import { LOCAL_NETWORK_NAME } from "../../api/inference-network.mjs";
|
|
2
1
|
import { configCodegenable } from "../../contracts/config-bindings.mjs";
|
|
3
2
|
import { mvrNamedForm, mvrNamedFormFrom } from "./dep-resolution.mjs";
|
|
4
3
|
//#region src/plugins/package/codegen.ts
|
|
4
|
+
/** Validate + normalize a declared MVR-type suffix. Entries are
|
|
5
|
+
* `'<module>::<Name>'` relative to the package; we reject anything that does
|
|
6
|
+
* not parse as two `::`-joined Move identifiers so a typo fails at config time
|
|
7
|
+
* rather than emitting an `isValidNamedType`-rejected key into the override
|
|
8
|
+
* map. The `@local/<slug>::` prefix is implied (and stripped if the developer
|
|
9
|
+
* redundantly included it). */
|
|
10
|
+
const normalizeMvrTypeSuffix = (packageName, mvr, entry) => {
|
|
11
|
+
const suffix = entry.startsWith(`${mvr}::`) ? entry.slice(mvr.length + 2) : entry;
|
|
12
|
+
if (!/^[A-Za-z_][\w]*::[A-Za-z_][\w]*$/.test(suffix)) throw new Error(`localPackage('${packageName}') mvrTypes entry '${entry}' must be '<module>::<Name>' (two Move identifiers joined by '::'); the '${mvr}' package prefix is implied.`);
|
|
13
|
+
return suffix;
|
|
14
|
+
};
|
|
5
15
|
/**
|
|
6
16
|
* Build the package's config-binding set, declared ONCE. The `name` keys the
|
|
7
17
|
* `config.packages.<name>` entry; `mvrPlaceholder` is a literal in both paths;
|
|
8
|
-
* the active-network id is a RESOLVED binding (sugar `
|
|
18
|
+
* the active-network id is a RESOLVED binding (sugar `requireId(dep, '<mvr>')` when
|
|
9
19
|
* `resolveViaRuntime`, otherwise a literal already-known id). Declared
|
|
10
20
|
* per-network literals (testnet/mainnet) and captured objects are literals.
|
|
11
21
|
*
|
|
12
22
|
* The same set drives `projectStaticConfig` (committed tree) and
|
|
13
|
-
* `projectLiveConfig` (boot
|
|
23
|
+
* `projectLiveConfig` (boot deployment) — no parallel projectors.
|
|
14
24
|
*/
|
|
15
25
|
const packageConfigBindings = (input) => {
|
|
16
26
|
const { name, mvrPlaceholder } = input;
|
|
@@ -45,22 +55,6 @@ const packageConfigBindings = (input) => {
|
|
|
45
55
|
name,
|
|
46
56
|
"packageId"
|
|
47
57
|
]));
|
|
48
|
-
bindings.push(idBinding([
|
|
49
|
-
"packages",
|
|
50
|
-
name,
|
|
51
|
-
"byNetwork",
|
|
52
|
-
LOCAL_NETWORK_NAME
|
|
53
|
-
]));
|
|
54
|
-
for (const [net, entry] of Object.entries(input.networks ?? {})) bindings.push({
|
|
55
|
-
variant: "literal",
|
|
56
|
-
configPath: [
|
|
57
|
-
"packages",
|
|
58
|
-
name,
|
|
59
|
-
"byNetwork",
|
|
60
|
-
net
|
|
61
|
-
],
|
|
62
|
-
value: entry.packageId
|
|
63
|
-
});
|
|
64
58
|
const objectKeys = input.objectKeys ?? Object.keys(input.captured);
|
|
65
59
|
if (objectKeys.length > 0) {
|
|
66
60
|
const objectsNamespace = `package:${name}:objects`;
|
|
@@ -85,7 +79,31 @@ const packageConfigBindings = (input) => {
|
|
|
85
79
|
]));
|
|
86
80
|
}
|
|
87
81
|
}
|
|
88
|
-
if (pinned === void 0 || pinned.length > 0) bindings.push(idBinding([
|
|
82
|
+
if (pinned === void 0 || pinned.length > 0) bindings.push(idBinding([
|
|
83
|
+
"mvrOverrides",
|
|
84
|
+
"packages",
|
|
85
|
+
mvrPlaceholder
|
|
86
|
+
]));
|
|
87
|
+
for (const entry of input.mvrTypes ?? []) {
|
|
88
|
+
const typeSuffix = normalizeMvrTypeSuffix(name, mvrPlaceholder, entry);
|
|
89
|
+
const tag = `${mvrPlaceholder}::${typeSuffix}`;
|
|
90
|
+
bindings.push({
|
|
91
|
+
variant: "resolved",
|
|
92
|
+
configPath: [
|
|
93
|
+
"mvrOverrides",
|
|
94
|
+
"types",
|
|
95
|
+
tag
|
|
96
|
+
],
|
|
97
|
+
namespace: "package",
|
|
98
|
+
key: `${name}:mvrType:${tag}`,
|
|
99
|
+
sugar: {
|
|
100
|
+
kind: "mvrType",
|
|
101
|
+
mvrPlaceholder,
|
|
102
|
+
typeSuffix
|
|
103
|
+
},
|
|
104
|
+
live: () => tag
|
|
105
|
+
});
|
|
106
|
+
}
|
|
89
107
|
return {
|
|
90
108
|
bucket: "config.ts",
|
|
91
109
|
kind: "package",
|
|
@@ -97,7 +115,7 @@ const packageConfigBindings = (input) => {
|
|
|
97
115
|
/**
|
|
98
116
|
* Build the package's `CodegenableDecl` from its binding set via the unified
|
|
99
117
|
* `configCodegenable` derivation. Mode `'live'` bakes concrete values + feeds
|
|
100
|
-
* the
|
|
118
|
+
* the deployment; `'static'` emits resolver expressions. The decl ALSO exports
|
|
101
119
|
* `packageBindings` (the `extraExports` hook) so the orchestrator's
|
|
102
120
|
* `isPackageBindings` seam forwards it to the Move-bindings emitter (bindings
|
|
103
121
|
* stay in `generated/bindings/`).
|
|
@@ -111,7 +129,7 @@ const makeLocalCodegenable = (resolved, options) => {
|
|
|
111
129
|
name: resolved.name,
|
|
112
130
|
mvrPlaceholder,
|
|
113
131
|
captured: resolved.captured,
|
|
114
|
-
...options.
|
|
132
|
+
...options.mvrTypes !== void 0 ? { mvrTypes: options.mvrTypes } : {}
|
|
115
133
|
}), {
|
|
116
134
|
name: resolved.name,
|
|
117
135
|
packageId: resolved.packageId,
|
|
@@ -137,7 +155,7 @@ const makeKnownCodegenable = (resolved, options = {}) => {
|
|
|
137
155
|
mvrPlaceholder,
|
|
138
156
|
captured: {},
|
|
139
157
|
pinnedId: resolved.packageId,
|
|
140
|
-
...options.
|
|
158
|
+
...options.mvrTypes !== void 0 ? { mvrTypes: options.mvrTypes } : {}
|
|
141
159
|
}), {
|
|
142
160
|
name: resolved.name,
|
|
143
161
|
packageId: resolved.packageId,
|
|
@@ -158,7 +176,7 @@ const makeLocalStaticCodegen = (config) => {
|
|
|
158
176
|
mvrPlaceholder,
|
|
159
177
|
captured: {},
|
|
160
178
|
...config.objectKeys !== void 0 ? { objectKeys: config.objectKeys } : {},
|
|
161
|
-
...config.
|
|
179
|
+
...config.mvrTypes !== void 0 ? { mvrTypes: config.mvrTypes } : {}
|
|
162
180
|
}), {
|
|
163
181
|
name: config.name,
|
|
164
182
|
packageId: "",
|
|
@@ -179,7 +197,7 @@ const makeKnownStaticCodegen = (config) => {
|
|
|
179
197
|
mvrPlaceholder,
|
|
180
198
|
captured: {},
|
|
181
199
|
pinnedId: config.packageId,
|
|
182
|
-
...config.
|
|
200
|
+
...config.mvrTypes !== void 0 ? { mvrTypes: config.mvrTypes } : {}
|
|
183
201
|
}), {
|
|
184
202
|
name: config.name,
|
|
185
203
|
packageId: config.packageId,
|