diff --git a/buyer/src/cli/reclaim-orphans.ts b/buyer/src/cli/reclaim-orphans.ts index 6feb601..61a4419 100644 --- a/buyer/src/cli/reclaim-orphans.ts +++ b/buyer/src/cli/reclaim-orphans.ts @@ -109,6 +109,11 @@ async function main(argv: string[]): Promise { return 1; } const networkId: 0 | 1 = env.NETWORK_ID === "1" ? 1 : 0; + // Inject loaded vars into process.env so shared tx builders see them + // (e.g. lucidContext.ts's VECTOR_ZERO_TIME_MS). See run-cycle.ts for context. + for (const key of ["VECTOR_ZERO_TIME_MS", "OGMIOS_URL", "INDEXER_URL", "NETWORK_ID"]) { + if (env[key] && !process.env[key]) process.env[key] = env[key]; + } const wk = deriveWalletKey(env.BUYER_PRIV_KEY_HEX, networkId); const chain: ChainProvider = new LiveOgmiosProvider({ ogmiosUrl: env.OGMIOS_URL }); diff --git a/buyer/src/cli/run-cycle.ts b/buyer/src/cli/run-cycle.ts index 10f353d..8085e92 100644 --- a/buyer/src/cli/run-cycle.ts +++ b/buyer/src/cli/run-cycle.ts @@ -179,6 +179,12 @@ async function main(argv: string[]): Promise { return 1; } const networkId: 0 | 1 = env.NETWORK_ID === "1" ? 1 : 0; + // Inject loaded vars into process.env so downstream tx-building modules + // (e.g. lucidContext.ts's VECTOR_ZERO_TIME_MS) see them. The shared tx + // builders read these from process.env, not the CLI-local env map. + for (const key of ["VECTOR_ZERO_TIME_MS", "OGMIOS_URL", "INDEXER_URL", "NETWORK_ID"]) { + if (env[key] && !process.env[key]) process.env[key] = env[key]; + } const advertRef = parseEscrowRef(env.ADVERT_REF); const wk = deriveWalletKey(env.BUYER_PRIV_KEY_HEX, networkId); const chain: ChainProvider = new LiveOgmiosProvider({ ogmiosUrl: env.OGMIOS_URL }); diff --git a/packages/shared/src/tx/internal/lucidContext.ts b/packages/shared/src/tx/internal/lucidContext.ts index 2f0266f..c90757c 100644 --- a/packages/shared/src/tx/internal/lucidContext.ts +++ b/packages/shared/src/tx/internal/lucidContext.ts @@ -41,11 +41,15 @@ const HEX64_RE = /^[0-9a-fA-F]{64}$/; // idempotent — repeated calls leave the values identical. createLucidContext // invokes it before constructing the Lucid instance. -const VECTOR_ZERO_TIME = Number(process.env.VECTOR_ZERO_TIME_MS) || 1_752_057_484_000; const VECTOR_ZERO_SLOT = 0; const VECTOR_SLOT_LENGTH = 1000; export function applyVectorSlotConfig(): void { + // Read VECTOR_ZERO_TIME_MS lazily so callers that populate process.env after + // module load (e.g. CLIs that read a .env file at runtime) still get the + // right value. Capturing this as a module-level const broke run-cycle.ts + // with the testnet default while pointing at mainnet. + const VECTOR_ZERO_TIME = Number(process.env.VECTOR_ZERO_TIME_MS) || 1_752_057_484_000; const cfg = SLOT_CONFIG_NETWORK["Mainnet"]; if ( cfg.zeroTime !== VECTOR_ZERO_TIME ||