shared: route ref-script server helpers via tx/server (keep buyer bundle clean)

Static re-exports from tx/index.ts caused vite to trace
loadEscrowScript/loadAdvertScript/buildLiveTxForPublishReferenceScripts
into the buyer UI bundle, hitting the CML WASM "ESM integration proposal"
limitation. Sibling builders avoid this with /* @vite-ignore */ dynamic
imports; we keep symmetry by parking the helpers on a separate
@marketplace/shared/tx/server entry that the buyer never imports.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
david
2026-05-14 15:41:29 +02:00
parent 5cae0c4f6c
commit 57e77e0e25
4 changed files with 27 additions and 11 deletions

View File

@@ -10,7 +10,8 @@
"./chain": "./src/chain/index.ts", "./chain": "./src/chain/index.ts",
"./cbor": "./src/cbor/index.ts", "./cbor": "./src/cbor/index.ts",
"./receipt": "./src/receipt/index.ts", "./receipt": "./src/receipt/index.ts",
"./tx": "./src/tx/index.ts" "./tx": "./src/tx/index.ts",
"./tx/server": "./src/tx/server.ts"
}, },
"scripts": { "scripts": {
"typecheck": "tsc --noEmit" "typecheck": "tsc --noEmit"

View File

@@ -10,14 +10,11 @@ export type { Signer } from "./signer.js";
export { MockSigner } from "./signer.js"; export { MockSigner } from "./signer.js";
export type { Blueprint } from "./blueprint.js"; export type { Blueprint } from "./blueprint.js";
export { loadBlueprint } from "./blueprint.js"; export { loadBlueprint } from "./blueprint.js";
// Script-bytes loaders (used by the publish-reference-scripts CLI). // Note: live-CBOR helpers (loadEscrowScript, loadAdvertScript,
export { loadEscrowScript, loadAdvertScript } from "./internal/liveCbor.js"; // buildLiveTxForPublishReferenceScripts, pkhToEnterpriseAddress) live in
export { pkhToEnterpriseAddress } from "./internal/pkhAddress.js"; // "./server.js" — kept OUT of this index so the buyer's vite bundle
export type { // doesn't trace into lucid-evolution / CML WASM (sibling builders use
LivePublishRefScriptsParams, // /* @vite-ignore */ dynamic imports for the same reason).
PublishRefScriptsBuildResult,
} from "./internal/publishReferenceScripts.js";
export { buildLiveTxForPublishReferenceScripts } from "./internal/publishReferenceScripts.js";
// Advert builders // Advert builders
export type { PostAdvertParams } from "./advert/postAdvert.js"; export type { PostAdvertParams } from "./advert/postAdvert.js";

View File

@@ -0,0 +1,18 @@
/**
* tx/server.ts — server-only re-exports.
*
* These bind the lucid-evolution + CML WASM dep graph at import time, so
* they MUST NOT be imported from anything that gets bundled by Vite (i.e.
* the buyer UI). The buyer SDK uses /* @vite-ignore *\/ dynamic imports
* to reach the live-CBOR builders for the same reason.
*
* Consumers: supplier CLIs and Node-only tx tooling.
*/
export { loadEscrowScript, loadAdvertScript } from "./internal/liveCbor.js";
export { pkhToEnterpriseAddress } from "./internal/pkhAddress.js";
export type {
LivePublishRefScriptsParams,
PublishRefScriptsBuildResult,
} from "./internal/publishReferenceScripts.js";
export { buildLiveTxForPublishReferenceScripts } from "./internal/publishReferenceScripts.js";

View File

@@ -25,13 +25,13 @@ import * as ed from "@noble/ed25519";
import { blake2b } from "@noble/hashes/blake2b"; import { blake2b } from "@noble/hashes/blake2b";
import { bech32 } from "bech32"; import { bech32 } from "bech32";
import { LiveOgmiosProvider } from "@marketplace/shared/chain"; import { LiveOgmiosProvider } from "@marketplace/shared/chain";
import type { WalletKey } from "@marketplace/shared/tx";
import { import {
buildLiveTxForPublishReferenceScripts, buildLiveTxForPublishReferenceScripts,
loadEscrowScript, loadEscrowScript,
loadAdvertScript, loadAdvertScript,
pkhToEnterpriseAddress, pkhToEnterpriseAddress,
} from "@marketplace/shared/tx"; } from "@marketplace/shared/tx/server";
import type { WalletKey } from "@marketplace/shared/tx";
ed.etc.sha512Sync = (...messages: Uint8Array[]): Uint8Array => { ed.etc.sha512Sync = (...messages: Uint8Array[]): Uint8Array => {
const h = createHash("sha512"); const h = createHash("sha512");