@mysten-incubation/devstack 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/README.md +10 -11
  2. package/dashboard-ui/assets/{grpc-Clz0oOtc.js → grpc-CpkDu4SA.js} +1 -1
  3. package/dashboard-ui/assets/{index-Cmqv9kiU.js → index-jLPRmjst.js} +2 -2
  4. package/dashboard-ui/index.html +1 -1
  5. package/dist/api/inference-network.d.mts +5 -5
  6. package/dist/api/inference-network.mjs +5 -5
  7. package/dist/api/inference-network.mjs.map +1 -1
  8. package/dist/api/run-stack-internal.mjs +1 -3
  9. package/dist/api/run-stack-internal.mjs.map +1 -1
  10. package/dist/build-integrations/dapp-kit/index.d.mts +12 -0
  11. package/dist/build-integrations/dapp-kit/index.mjs +14 -1
  12. package/dist/build-integrations/dapp-kit/index.mjs.map +1 -1
  13. package/dist/build-integrations/playwright/errors.d.mts +1 -1
  14. package/dist/build-integrations/playwright/errors.mjs.map +1 -1
  15. package/dist/build-integrations/playwright/index.d.mts +2 -2
  16. package/dist/build-integrations/playwright/index.mjs +2 -2
  17. package/dist/build-integrations/playwright/wallet-context.d.mts +2 -1
  18. package/dist/build-integrations/playwright/wallet-context.mjs +141 -41
  19. package/dist/build-integrations/playwright/wallet-context.mjs.map +1 -1
  20. package/dist/build-integrations/runtime/dapp-kit-slot.mjs +1 -1
  21. package/dist/build-integrations/runtime/dapp-kit-slot.mjs.map +1 -1
  22. package/dist/build-integrations/vite/index.d.mts +54 -42
  23. package/dist/build-integrations/vite/index.mjs +239 -106
  24. package/dist/build-integrations/vite/index.mjs.map +1 -1
  25. package/dist/build-integrations/vitest/global-setup.mjs +8 -8
  26. package/dist/build-integrations/vitest/global-setup.mjs.map +1 -1
  27. package/dist/cli/main.mjs +3 -2
  28. package/dist/cli/main.mjs.map +1 -1
  29. package/dist/cli/wirings/apply.mjs +0 -1
  30. package/dist/cli/wirings/apply.mjs.map +1 -1
  31. package/dist/cli/wirings/codegen.mjs +2 -3
  32. package/dist/cli/wirings/codegen.mjs.map +1 -1
  33. package/dist/cli/wirings/dump-deployment.mjs +141 -0
  34. package/dist/cli/wirings/dump-deployment.mjs.map +1 -0
  35. package/dist/cli/wirings/snapshot.mjs +0 -1
  36. package/dist/cli/wirings/snapshot.mjs.map +1 -1
  37. package/dist/contracts/codegenable.d.mts +22 -25
  38. package/dist/contracts/codegenable.mjs +35 -4
  39. package/dist/contracts/codegenable.mjs.map +1 -1
  40. package/dist/contracts/config-bindings.mjs +43 -18
  41. package/dist/contracts/config-bindings.mjs.map +1 -1
  42. package/dist/index.d.mts +1 -1
  43. package/dist/index.mjs +1 -1
  44. package/dist/orchestrators/boot.d.mts +0 -10
  45. package/dist/orchestrators/boot.mjs +19 -59
  46. package/dist/orchestrators/boot.mjs.map +1 -1
  47. package/dist/orchestrators/codegen/bindings.mjs.map +1 -1
  48. package/dist/orchestrators/codegen/config-runtime.mjs +137 -112
  49. package/dist/orchestrators/codegen/config-runtime.mjs.map +1 -1
  50. package/dist/orchestrators/codegen/deployment-network-file.mjs +130 -0
  51. package/dist/orchestrators/codegen/deployment-network-file.mjs.map +1 -0
  52. package/dist/orchestrators/codegen/deployment-strict.mjs +77 -0
  53. package/dist/orchestrators/codegen/deployment-strict.mjs.map +1 -0
  54. package/dist/orchestrators/codegen/deployment.d.mts +63 -0
  55. package/dist/orchestrators/codegen/deployment.mjs +153 -0
  56. package/dist/orchestrators/codegen/deployment.mjs.map +1 -0
  57. package/dist/orchestrators/codegen/errors.mjs +7 -9
  58. package/dist/orchestrators/codegen/errors.mjs.map +1 -1
  59. package/dist/orchestrators/codegen/format.mjs +20 -1
  60. package/dist/orchestrators/codegen/format.mjs.map +1 -1
  61. package/dist/orchestrators/codegen/paths.mjs +1 -8
  62. package/dist/orchestrators/codegen/paths.mjs.map +1 -1
  63. package/dist/orchestrators/codegen/service.mjs +354 -141
  64. package/dist/orchestrators/codegen/service.mjs.map +1 -1
  65. package/dist/orchestrators/layers.mjs +0 -1
  66. package/dist/orchestrators/layers.mjs.map +1 -1
  67. package/dist/orchestrators/network-options.d.mts +37 -35
  68. package/dist/orchestrators/network-options.mjs +13 -10
  69. package/dist/orchestrators/network-options.mjs.map +1 -1
  70. package/dist/plugins/account/codegen.d.mts +3 -4
  71. package/dist/plugins/account/codegen.mjs +5 -7
  72. package/dist/plugins/account/codegen.mjs.map +1 -1
  73. package/dist/plugins/account/index.mjs +1 -3
  74. package/dist/plugins/account/index.mjs.map +1 -1
  75. package/dist/plugins/coin/codegen.mjs +5 -5
  76. package/dist/plugins/coin/codegen.mjs.map +1 -1
  77. package/dist/plugins/coin/index.mjs.map +1 -1
  78. package/dist/plugins/dashboard/schema/root.mjs +3 -1
  79. package/dist/plugins/dashboard/schema/root.mjs.map +1 -1
  80. package/dist/plugins/deepbook/codegen.mjs +4 -4
  81. package/dist/plugins/deepbook/codegen.mjs.map +1 -1
  82. package/dist/plugins/deepbook/index.d.mts +36 -6
  83. package/dist/plugins/deepbook/index.mjs +52 -16
  84. package/dist/plugins/deepbook/index.mjs.map +1 -1
  85. package/dist/plugins/internal/codegen-helpers.mjs +0 -1
  86. package/dist/plugins/internal/codegen-helpers.mjs.map +1 -1
  87. package/dist/plugins/package/codegen.d.mts +1 -12
  88. package/dist/plugins/package/codegen.mjs +43 -25
  89. package/dist/plugins/package/codegen.mjs.map +1 -1
  90. package/dist/plugins/package/dep-resolution.mjs +1 -1
  91. package/dist/plugins/package/dep-resolution.mjs.map +1 -1
  92. package/dist/plugins/package/index.d.mts +14 -11
  93. package/dist/plugins/package/index.mjs +6 -7
  94. package/dist/plugins/package/index.mjs.map +1 -1
  95. package/dist/plugins/seal/codegen.d.mts +5 -0
  96. package/dist/plugins/seal/codegen.mjs +55 -12
  97. package/dist/plugins/seal/codegen.mjs.map +1 -1
  98. package/dist/plugins/seal/index.d.mts +64 -19
  99. package/dist/plugins/seal/index.mjs +26 -36
  100. package/dist/plugins/seal/index.mjs.map +1 -1
  101. package/dist/plugins/seal/mode/fork-known.d.mts +0 -2
  102. package/dist/plugins/seal/mode/fork-known.mjs +11 -22
  103. package/dist/plugins/seal/mode/fork-known.mjs.map +1 -1
  104. package/dist/plugins/seal/mode/live.d.mts +36 -13
  105. package/dist/plugins/seal/mode/live.mjs +104 -43
  106. package/dist/plugins/seal/mode/live.mjs.map +1 -1
  107. package/dist/plugins/seal/mode/local-keygen.mjs +2 -1
  108. package/dist/plugins/seal/mode/local-keygen.mjs.map +1 -1
  109. package/dist/plugins/seal/registry-publish.d.mts +15 -3
  110. package/dist/plugins/seal/registry-publish.mjs.map +1 -1
  111. package/dist/plugins/sui/codegen.mjs +5 -4
  112. package/dist/plugins/sui/codegen.mjs.map +1 -1
  113. package/dist/plugins/sui/index.mjs +1 -2
  114. package/dist/plugins/sui/index.mjs.map +1 -1
  115. package/dist/plugins/wallet/codegen.d.mts +8 -12
  116. package/dist/plugins/wallet/codegen.mjs +22 -15
  117. package/dist/plugins/wallet/codegen.mjs.map +1 -1
  118. package/dist/plugins/wallet/index.d.mts +4 -3
  119. package/dist/plugins/wallet/index.mjs +1 -1
  120. package/dist/plugins/wallet/index.mjs.map +1 -1
  121. package/dist/plugins/wallet/service.d.mts +2 -2
  122. package/dist/plugins/wallet/service.mjs +2 -3
  123. package/dist/plugins/wallet/service.mjs.map +1 -1
  124. package/dist/plugins/walrus/codegen.mjs +4 -4
  125. package/dist/plugins/walrus/codegen.mjs.map +1 -1
  126. package/dist/plugins/walrus/index.d.mts +137 -8
  127. package/dist/plugins/walrus/index.mjs +46 -9
  128. package/dist/plugins/walrus/index.mjs.map +1 -1
  129. package/dist/plugins/walrus/mode/known-deploy.d.mts +5 -1
  130. package/dist/plugins/walrus/mode/known-deploy.mjs +13 -10
  131. package/dist/plugins/walrus/mode/known-deploy.mjs.map +1 -1
  132. package/dist/substrate/manifest.d.mts +17 -22
  133. package/dist/substrate/manifest.mjs +4 -6
  134. package/dist/substrate/manifest.mjs.map +1 -1
  135. package/dist/substrate/plugin-ctx.d.mts +6 -6
  136. package/dist/substrate/plugin-ctx.mjs.map +1 -1
  137. package/dist/substrate/runtime/cross-process/liveness.mjs.map +1 -1
  138. package/dist/substrate/runtime/manifest/manifest.mjs.map +1 -1
  139. package/dist/substrate/runtime/paths.mjs +1 -1
  140. package/dist/surfaces/cli/command-tree.mjs +6 -6
  141. package/dist/surfaces/cli/command-tree.mjs.map +1 -1
  142. package/dist/surfaces/cli/index.mjs +6 -4
  143. package/dist/surfaces/cli/index.mjs.map +1 -1
  144. package/dist/surfaces/tui/plain-renderer.mjs.map +1 -1
  145. package/package.json +2 -2
  146. package/dist/cli/wirings/dump-ids.mjs +0 -86
  147. package/dist/cli/wirings/dump-ids.mjs.map +0 -1
  148. package/dist/orchestrators/codegen/id-config.d.mts +0 -1
  149. package/dist/orchestrators/codegen/id-config.mjs +0 -107
  150. package/dist/orchestrators/codegen/id-config.mjs.map +0 -1
  151. package/dist/orchestrators/codegen/output-location.mjs +0 -32
  152. package/dist/orchestrators/codegen/output-location.mjs.map +0 -1
  153. package/dist/plugins/seal/service.mjs +0 -17
  154. package/dist/plugins/seal/service.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 `resolveValue` channel would otherwise return `unknown`). The
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 (`resolveValue`). */
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 id-config `values` channel.
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 `resolveValue('deepbook:<name>', '<key>')` for the runtime
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 id-config `values`\n// channel.\n// - STATIC (committed tree): emits `resolveValue('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/id-config.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 `resolveValue`. */\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 `resolveValue` 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 (`resolveValue`). */\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 id-config `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 `resolveValue('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 =>\n\tstaticBucketCodegen(deepbookBucketSpec(config));\n"],"mappings":";;;;;;;AAiGA,MAAM,eACL;AACD,MAAM,eACL;AACD,MAAM,iBAAiB;;;;AAKvB,MAAM,sBACL,eAC0C;CAC1C,MAAM,QAAQ,WAAW;CAGzB,MAAM,WACL,KACA,SAEA,UAAU,KAAA,IACP;EAAE;EAAK,SAAS;EAAW,OAAO,MAAM;CAAK,IAC7C;EAAE;EAAK,SAAS;EAAY,QAAQ;EAAU;CAAK;CACvD,MAAM,SAAwD;EAC7D;GAAE,KAAK;GAAQ,SAAS;GAAW,OAAO,WAAW;EAAK;EAC1D;GAAE,KAAK;GAAW,SAAS;GAAW,OAAO,WAAW;EAAQ;EAChE,QAAQ,cAAc,MAAM,EAAE,SAAS;EACvC,QAAQ,eAAe,MAAM,EAAE,UAAU;EAGzC;GAAE,KAAK;GAAc,SAAS;GAAY,QAAQ;GAAiB,OAAO,MAAM,EAAE;EAAW;EAG7F,UAAU,KAAA,IACP;GACA,KAAK;GACL,SAAS;GACT,OAAQ,MAAM,kBAAkB;EACjC,IACC;GACA,KAAK;GACL,SAAS;GACT,QAAQ;GACR,OAAO,MAAM,EAAE;EAChB;EAGF;GACC,KAAK;GACL,SAAS;GACT,QAAQ;GACR,OAAO,MAAM,EAAE;EAChB;EAGA,UAAU,KAAA,IACP;GAAE,KAAK;GAAQ,SAAS;GAAW,OAAQ,MAAM,QAAQ;EAAmB,IAC5E;GACA,KAAK;GACL,SAAS;GACT,QAAQ;GACR,OAAO,MAAM,EAAE;EAChB;EACF;GACC,KAAK;GACL,SAAS;GACT,QAAQ;GACR,OAAO,MAAM,EAAE;EAChB;EACA;GAAE,KAAK;GAAa,SAAS;GAAY,QAAQ;GAAiB,OAAO,MAAM,EAAE;EAAU;EAC3F;GAAE,KAAK;GAAc,SAAS;GAAY,QAAQ;GAAiB,OAAO,MAAM,EAAE;EAAW;CAC9F;CACA,OAAO,gBAAgB;EAAE,QAAQ;EAAe,MAAM;EAAY,KAAK,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"}
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 =>\n\tstaticBucketCodegen(deepbookBucketSpec(config));\n"],"mappings":";;;;;;;AAiGA,MAAM,eACL;AACD,MAAM,eACL;AACD,MAAM,iBAAiB;;;;AAKvB,MAAM,sBACL,eAC0C;CAC1C,MAAM,QAAQ,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,WACzC,oBAAoB,mBAAmB,MAAM,CAAC"}
@@ -94,6 +94,11 @@ interface DeepbookKnownExplicitOptions extends DeepbookKnownCommonOptions {
94
94
  readonly network?: DeepbookKnownNetwork;
95
95
  }
96
96
  type DeepbookKnownOptions = DeepbookKnownNetworkOptions | DeepbookKnownExplicitOptions;
97
+ /** Per-network factory options for `deepbookFor(net).testnet()`/`.mainnet()`.
98
+ * The `network` is injected by the namespace method, so the caller only
99
+ * supplies optional per-field overrides (`packageId`/`registryId`/`name`).
100
+ * Plugin-INTERNAL — deliberately NOT re-exported from `src/index.ts`. */
101
+ type DeepbookKnownByNetworkOptions = Omit<DeepbookKnownNetworkOptions, 'network'>;
97
102
  type DeepbookOptions<Publisher extends AccountMemberAlias = AccountMemberAlias, Pyth extends PythOptions | undefined = PythOptions | undefined> = ({
98
103
  readonly mode: 'local';
99
104
  } & DeepbookLocalOptions<Publisher, DeepbookPackageMember, ReadonlyArray<DeepbookPoolSpec>, Pyth>) | ({
@@ -134,14 +139,21 @@ declare function deepbookCore<const Publisher extends AccountMemberAlias, const
134
139
  * const local = { mode: 'local', network: 'localnet' } as const;
135
140
  * deepbookFor(local).local({publisher, package, pools}) // OK
136
141
  * deepbookFor(local).override({packageId, registryId, adminCapId}) // OK
137
- * deepbookFor(local).known({...}) // OK
142
+ * deepbookFor(local).testnet() // OK (known testnet)
143
+ * deepbookFor(local).known({packageId, registryId}) // OK (raw-id override)
144
+ *
145
+ * const live = { mode: 'live', chainId: 'sui:testnet' } as const;
146
+ * deepbookFor(live).mainnet() // OK (known mainnet)
138
147
  *
139
148
  * const fork = { mode: 'fork', network: 'mainnet-fork', upstream: 'mainnet' } as const;
140
149
  * deepbookFor(fork).local({...}) // COMPILE ERROR
141
150
  * deepbookFor(fork).override({...}) // COMPILE ERROR
142
151
  *
143
- * The fork branch has NO `.local` or `.override` entry — `deepbookFor(forkNetwork).local`
144
- * is a compile-time refusal. */
152
+ * Per-network methods (`.testnet`/`.mainnet`) inject the network into
153
+ * `buildKnownPlugin`; `.known(...)` is now the raw-id explicit-override form
154
+ * only (`DeepbookKnownExplicitOptions`) — the `network`-in-`.known()` path was
155
+ * HARD CUT. The fork branch has NO `.local` or `.override` entry —
156
+ * `deepbookFor(forkNetwork).local` is a compile-time refusal. */
145
157
  declare const deepbookFor: ModeNamespace<{
146
158
  local: {
147
159
  local: <const Publisher extends AccountMemberAlias, const Package extends DeepbookPackageMember, const Pools extends ReadonlyArray<DeepbookPoolSpec> = readonly [], const Pyth extends PythOptions | undefined = undefined>(opts: DeepbookLocalOptions<Publisher, Package, Pools, Pyth>) => Plugin<`deepbook/${string}`, DeepbookResolved, readonly [ResourceRef<"sui", SuiClient & {
@@ -150,17 +162,35 @@ declare const deepbookFor: ModeNamespace<{
150
162
  override: (opts: DeepbookOverrideOptions) => Plugin<`deepbook/${string}`, DeepbookResolved, readonly [ResourceRef<"sui", SuiClient & {
151
163
  readonly mode: SuiOptions["mode"];
152
164
  }>]>;
153
- known: (opts: DeepbookKnownOptions) => Plugin<`deepbook/${string}`, DeepbookResolved, readonly [ResourceRef<"sui", SuiClient & {
165
+ known: (opts: DeepbookKnownExplicitOptions) => Plugin<`deepbook/${string}`, DeepbookResolved, readonly [ResourceRef<"sui", SuiClient & {
166
+ readonly mode: SuiOptions["mode"];
167
+ }>]>;
168
+ testnet: (opts?: DeepbookKnownByNetworkOptions) => Plugin<`deepbook/${string}`, DeepbookResolved, readonly [ResourceRef<"sui", SuiClient & {
169
+ readonly mode: SuiOptions["mode"];
170
+ }>]>;
171
+ mainnet: (opts?: DeepbookKnownByNetworkOptions) => Plugin<`deepbook/${string}`, DeepbookResolved, readonly [ResourceRef<"sui", SuiClient & {
154
172
  readonly mode: SuiOptions["mode"];
155
173
  }>]>;
156
174
  };
157
175
  live: {
158
- known: (opts: DeepbookKnownOptions) => Plugin<`deepbook/${string}`, DeepbookResolved, readonly [ResourceRef<"sui", SuiClient & {
176
+ known: (opts: DeepbookKnownExplicitOptions) => Plugin<`deepbook/${string}`, DeepbookResolved, readonly [ResourceRef<"sui", SuiClient & {
177
+ readonly mode: SuiOptions["mode"];
178
+ }>]>;
179
+ testnet: (opts?: DeepbookKnownByNetworkOptions) => Plugin<`deepbook/${string}`, DeepbookResolved, readonly [ResourceRef<"sui", SuiClient & {
180
+ readonly mode: SuiOptions["mode"];
181
+ }>]>;
182
+ mainnet: (opts?: DeepbookKnownByNetworkOptions) => Plugin<`deepbook/${string}`, DeepbookResolved, readonly [ResourceRef<"sui", SuiClient & {
159
183
  readonly mode: SuiOptions["mode"];
160
184
  }>]>;
161
185
  };
162
186
  fork: {
163
- known: (opts: DeepbookKnownOptions) => Plugin<`deepbook/${string}`, DeepbookResolved, readonly [ResourceRef<"sui", SuiClient & {
187
+ known: (opts: DeepbookKnownExplicitOptions) => Plugin<`deepbook/${string}`, DeepbookResolved, readonly [ResourceRef<"sui", SuiClient & {
188
+ readonly mode: SuiOptions["mode"];
189
+ }>]>;
190
+ testnet: (opts?: DeepbookKnownByNetworkOptions) => Plugin<`deepbook/${string}`, DeepbookResolved, readonly [ResourceRef<"sui", SuiClient & {
191
+ readonly mode: SuiOptions["mode"];
192
+ }>]>;
193
+ mainnet: (opts?: DeepbookKnownByNetworkOptions) => Plugin<`deepbook/${string}`, DeepbookResolved, readonly [ResourceRef<"sui", SuiClient & {
164
194
  readonly mode: SuiOptions["mode"];
165
195
  }>]>;
166
196
  };
@@ -19,31 +19,32 @@ import { createDeepbookPools, seedDeepbookPools } from "./deploy.mjs";
19
19
  import "./types.mjs";
20
20
  import { initLocalPythFeeds } from "./pyth/index.mjs";
21
21
  import { Effect } from "effect";
22
+ import { mainnetPackageIds, mainnetPythConfigs, testnetPackageIds, testnetPythConfigs } from "@mysten/deepbook-v3";
22
23
  //#region src/plugins/deepbook/index.ts
23
24
  const makeDeepbookResource = (name) => resource(`deepbook/${name}`);
24
25
  const DEFAULT_NAME = "deepbook";
25
26
  const KNOWN_DEEPBOOK_DEPLOYMENTS = {
26
27
  testnet: {
27
28
  network: "testnet",
28
- packageId: "0x22be4cade64bf2d02412c7e8d0e8beea2f78828b948118d46735315409371a3c",
29
- registryId: "0x7c256edbda983a2cd6f946655f4bf3f00a41043993781f8674a7046e8c0e11d1",
30
- deepTreasuryId: "0x69fffdae0075f8f71f4fa793549c11079266910e8905169845af1f5d00e09dcb",
29
+ packageId: testnetPackageIds.DEEPBOOK_PACKAGE_ID,
30
+ registryId: testnetPackageIds.REGISTRY_ID,
31
+ deepTreasuryId: testnetPackageIds.DEEP_TREASURY_ID,
31
32
  pyth: {
32
33
  packageId: null,
33
- stateId: "0x243759059f4c3111179da5878c12f68d612c21a8d54d85edc86164bb18be1c7c",
34
- wormholeStateId: "0x31358d198147da50db32eda2562951d53973a0c0ad5ed738e9b17d88b213d790",
34
+ stateId: testnetPythConfigs.pythStateId,
35
+ wormholeStateId: testnetPythConfigs.wormholeStateId,
35
36
  feeds: []
36
37
  }
37
38
  },
38
39
  mainnet: {
39
40
  network: "mainnet",
40
- packageId: "0xf48222c4e057fa468baf136bff8e12504209d43850c5778f76159292a96f621e",
41
- registryId: "0xaf16199a2dff736e9f07a845f23c5da6df6f756eddb631aed9d24a93efc4549d",
42
- deepTreasuryId: "0x032abf8948dda67a271bcc18e776dbbcfb0d58c8d288a700ff0d5521e57a1ffe",
41
+ packageId: mainnetPackageIds.DEEPBOOK_PACKAGE_ID,
42
+ registryId: mainnetPackageIds.REGISTRY_ID,
43
+ deepTreasuryId: mainnetPackageIds.DEEP_TREASURY_ID,
43
44
  pyth: {
44
45
  packageId: null,
45
- stateId: "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8",
46
- wormholeStateId: "0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c",
46
+ stateId: mainnetPythConfigs.pythStateId,
47
+ wormholeStateId: mainnetPythConfigs.wormholeStateId,
47
48
  feeds: []
48
49
  }
49
50
  }
@@ -408,22 +409,57 @@ function deepbookCore(opts) {
408
409
  * const local = { mode: 'local', network: 'localnet' } as const;
409
410
  * deepbookFor(local).local({publisher, package, pools}) // OK
410
411
  * deepbookFor(local).override({packageId, registryId, adminCapId}) // OK
411
- * deepbookFor(local).known({...}) // OK
412
+ * deepbookFor(local).testnet() // OK (known testnet)
413
+ * deepbookFor(local).known({packageId, registryId}) // OK (raw-id override)
414
+ *
415
+ * const live = { mode: 'live', chainId: 'sui:testnet' } as const;
416
+ * deepbookFor(live).mainnet() // OK (known mainnet)
412
417
  *
413
418
  * const fork = { mode: 'fork', network: 'mainnet-fork', upstream: 'mainnet' } as const;
414
419
  * deepbookFor(fork).local({...}) // COMPILE ERROR
415
420
  * deepbookFor(fork).override({...}) // COMPILE ERROR
416
421
  *
417
- * The fork branch has NO `.local` or `.override` entry — `deepbookFor(forkNetwork).local`
418
- * is a compile-time refusal. */
422
+ * Per-network methods (`.testnet`/`.mainnet`) inject the network into
423
+ * `buildKnownPlugin`; `.known(...)` is now the raw-id explicit-override form
424
+ * only (`DeepbookKnownExplicitOptions`) — the `network`-in-`.known()` path was
425
+ * HARD CUT. The fork branch has NO `.local` or `.override` entry —
426
+ * `deepbookFor(forkNetwork).local` is a compile-time refusal. */
419
427
  const deepbookFor = defineModeNamespace({
420
428
  local: {
421
429
  local: (opts) => buildLocalPluginPublic(opts),
422
430
  override: (opts) => buildOverridePlugin(opts),
423
- known: (opts) => buildKnownPlugin(opts)
431
+ known: (opts) => buildKnownPlugin(opts),
432
+ testnet: (opts = {}) => buildKnownPlugin({
433
+ network: "testnet",
434
+ ...opts
435
+ }),
436
+ mainnet: (opts = {}) => buildKnownPlugin({
437
+ network: "mainnet",
438
+ ...opts
439
+ })
440
+ },
441
+ live: {
442
+ known: (opts) => buildKnownPlugin(opts),
443
+ testnet: (opts = {}) => buildKnownPlugin({
444
+ network: "testnet",
445
+ ...opts
446
+ }),
447
+ mainnet: (opts = {}) => buildKnownPlugin({
448
+ network: "mainnet",
449
+ ...opts
450
+ })
424
451
  },
425
- live: { known: (opts) => buildKnownPlugin(opts) },
426
- fork: { known: (opts) => buildKnownPlugin(opts) }
452
+ fork: {
453
+ known: (opts) => buildKnownPlugin(opts),
454
+ testnet: (opts = {}) => buildKnownPlugin({
455
+ network: "testnet",
456
+ ...opts
457
+ }),
458
+ mainnet: (opts = {}) => buildKnownPlugin({
459
+ network: "mainnet",
460
+ ...opts
461
+ })
462
+ }
427
463
  });
428
464
  //#endregion
429
465
  export { deepbookCore, deepbookFor };
@@ -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` 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// `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\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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,QAAQ,KAAK;MACb,QAAQ,KAAK;MACb,mBAAmB,KAAK;MACxB,OAAO,KAAK,MAAM,SAAS;MAC3B,MAAM,KAAK;KACZ,EAAE;IACH,IACC;IACH,QAAQ;IACR,WAAW;IACX,YAAY;GACb;GACA,IAAI,cAAc,IAAI;GACtB,IAAI,QAAQ,wBAAwB,QAAQ,CAAC;GAC7C,IAAI,SAAS,uBAAuB,MACnC,IAAI,SAAS,oCAAoC,SAAS,mBAAmB,CAAC;GAE/E,OAAO;EACR,CAAC;CACH,CAAC;AACF;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"}
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';\nimport {\n\tmainnetPackageIds,\n\tmainnetPythConfigs,\n\ttestnetPackageIds,\n\ttestnetPythConfigs,\n} from '@mysten/deepbook-v3';\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\n/** Per-network factory options for `deepbookFor(net).testnet()`/`.mainnet()`.\n * The `network` is injected by the namespace method, so the caller only\n * supplies optional per-field overrides (`packageId`/`registryId`/`name`).\n * Plugin-INTERNAL — deliberately NOT re-exported from `src/index.ts`. */\ntype DeepbookKnownByNetworkOptions = Omit<DeepbookKnownNetworkOptions, 'network'>;\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\n// Known-deployment ids are DERIVED from the `@mysten/deepbook-v3` SDK\n// constants rather than hand-copied, so they can never drift from the SDK\n// (a stale mainnet packageId is exactly what this guards against). Future\n// SDK bumps flow through automatically. DeepBook ships testnet + mainnet\n// only — there is no devnet deployment.\n//\n// We surface only the core ids the plugin needs. The SDK's MARGIN_*/\n// LIQUIDATION_* package ids and its coin/pool maps are intentionally NOT\n// re-exported here (out of scope); consumers that need them import from\n// `@mysten/deepbook-v3` directly.\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: testnetPackageIds.DEEPBOOK_PACKAGE_ID,\n\t\tregistryId: testnetPackageIds.REGISTRY_ID,\n\t\tdeepTreasuryId: testnetPackageIds.DEEP_TREASURY_ID,\n\t\tpyth: {\n\t\t\tpackageId: null,\n\t\t\tstateId: testnetPythConfigs.pythStateId,\n\t\t\twormholeStateId: testnetPythConfigs.wormholeStateId,\n\t\t\tfeeds: [],\n\t\t},\n\t},\n\tmainnet: {\n\t\tnetwork: 'mainnet',\n\t\tpackageId: mainnetPackageIds.DEEPBOOK_PACKAGE_ID,\n\t\tregistryId: mainnetPackageIds.REGISTRY_ID,\n\t\tdeepTreasuryId: mainnetPackageIds.DEEP_TREASURY_ID,\n\t\tpyth: {\n\t\t\tpackageId: null,\n\t\t\tstateId: mainnetPythConfigs.pythStateId,\n\t\t\twormholeStateId: mainnetPythConfigs.wormholeStateId,\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).testnet() // OK (known testnet)\n * deepbookFor(local).known({packageId, registryId}) // OK (raw-id override)\n *\n * const live = { mode: 'live', chainId: 'sui:testnet' } as const;\n * deepbookFor(live).mainnet() // OK (known mainnet)\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 * Per-network methods (`.testnet`/`.mainnet`) inject the network into\n * `buildKnownPlugin`; `.known(...)` is now the raw-id explicit-override form\n * only (`DeepbookKnownExplicitOptions`) — the `network`-in-`.known()` path was\n * HARD CUT. The fork branch has NO `.local` or `.override` entry —\n * `deepbookFor(forkNetwork).local` 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: DeepbookKnownExplicitOptions) => buildKnownPlugin(opts),\n\t\ttestnet: (opts: DeepbookKnownByNetworkOptions = {}) =>\n\t\t\tbuildKnownPlugin({ network: 'testnet', ...opts }),\n\t\tmainnet: (opts: DeepbookKnownByNetworkOptions = {}) =>\n\t\t\tbuildKnownPlugin({ network: 'mainnet', ...opts }),\n\t},\n\tlive: {\n\t\tknown: (opts: DeepbookKnownExplicitOptions) => buildKnownPlugin(opts),\n\t\ttestnet: (opts: DeepbookKnownByNetworkOptions = {}) =>\n\t\t\tbuildKnownPlugin({ network: 'testnet', ...opts }),\n\t\tmainnet: (opts: DeepbookKnownByNetworkOptions = {}) =>\n\t\t\tbuildKnownPlugin({ network: 'mainnet', ...opts }),\n\t},\n\tfork: {\n\t\t// `.override` intentionally absent — compile-time refusal.\n\t\tknown: (opts: DeepbookKnownExplicitOptions) => buildKnownPlugin(opts),\n\t\ttestnet: (opts: DeepbookKnownByNetworkOptions = {}) =>\n\t\t\tbuildKnownPlugin({ network: 'testnet', ...opts }),\n\t\tmainnet: (opts: DeepbookKnownByNetworkOptions = {}) =>\n\t\t\tbuildKnownPlugin({ network: 'mainnet', ...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":";;;;;;;;;;;;;;;;;;;;;;;AAsGA,MAAM,wBAA6C,SAClD,SACC,YAAY,MACb;AAoID,MAAM,eAAe;AAYrB,MAAM,6BASF;CACH,SAAS;EACR,SAAS;EACT,WAAW,kBAAkB;EAC7B,YAAY,kBAAkB;EAC9B,gBAAgB,kBAAkB;EAClC,MAAM;GACL,WAAW;GACX,SAAS,mBAAmB;GAC5B,iBAAiB,mBAAmB;GACpC,OAAO,CAAC;EACT;CACD;CACA,SAAS;EACR,SAAS;EACT,WAAW,kBAAkB;EAC7B,YAAY,kBAAkB;EAC9B,gBAAgB,kBAAkB;EAClC,MAAM;GACL,WAAW;GACX,SAAS,mBAAmB;GAC5B,iBAAiB,mBAAmB;GACpC,OAAO,CAAC;EACT;CACD;AACD;AAwBA,MAAM,gBACL,UAEA,MAAM,SAAS,SAAS,CAAC,KAAK,KAAK,MAAM,KAAK,MAA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;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;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,cAAc,oBAAoB;CAC9C,OAAO;EACN,QAMC,SACI,uBAAuB,IAAI;EAChC,WAAW,SAAkC,oBAAoB,IAAI;EACrE,QAAQ,SAAuC,iBAAiB,IAAI;EACpE,UAAU,OAAsC,CAAC,MAChD,iBAAiB;GAAE,SAAS;GAAW,GAAG;EAAK,CAAC;EACjD,UAAU,OAAsC,CAAC,MAChD,iBAAiB;GAAE,SAAS;GAAW,GAAG;EAAK,CAAC;CAClD;CACA,MAAM;EACL,QAAQ,SAAuC,iBAAiB,IAAI;EACpE,UAAU,OAAsC,CAAC,MAChD,iBAAiB;GAAE,SAAS;GAAW,GAAG;EAAK,CAAC;EACjD,UAAU,OAAsC,CAAC,MAChD,iBAAiB;GAAE,SAAS;GAAW,GAAG;EAAK,CAAC;CAClD;CACA,MAAM;EAEL,QAAQ,SAAuC,iBAAiB,IAAI;EACpE,UAAU,OAAsC,CAAC,MAChD,iBAAiB;GAAE,SAAS;GAAW,GAAG;EAAK,CAAC;EACjD,UAAU,OAAsC,CAAC,MAChD,iBAAiB;GAAE,SAAS;GAAW,GAAG;EAAK,CAAC;CAClD;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 {\n\tAggregateContribution,\n\tCodegenableDecl,\n\tOutputLocation,\n} 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/** Which codegen tree the standalone file lands in. Default\n\t * `'generated'`. */\n\treadonly outputLocation?: OutputLocation;\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.outputLocation ? { outputLocation: spec.outputLocation } : {}),\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":";;AA4CA,MAAa,2BACZ,UAC+B;CAC/B,MAAM;CACN,aAAa,KAAK;CAClB,YAAY,KAAK;CACjB,WAAW,KAAK,aAAa;CAC7B,GAAI,KAAK,iBAAiB,EAAE,gBAAgB,KAAK,eAAe,IAAI,CAAC;CACrE,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
+ {"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";