From 30702d98c85f073fa30fe9c8ff46be0d5e2fcdb2 Mon Sep 17 00:00:00 2001 From: Vladimir Rogojin Date: Wed, 8 Jul 2026 17:04:57 +0200 Subject: [PATCH] feat(cli)(sphere-cli-p6-fork): thread network through local-HM boot for testnet2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds `network` to `LocalHmConfig` and threads the trader spawn's `--network` option through `ensureLocalHM` → `buildHmEnv` → `UNICITY_NETWORK` on the HM container. The HM then inherits the network into every tenant it spawns (trader, escrow, etc). Before this change, `sphere trader spawn --network testnet2` was accepted by the CLI but the HM booted with UNICITY_NETWORK=testnet, so tenants ran against v1 gateway (which is retired) instead of testnet2. Widened the `network` type to include 'testnet2' at three sites: - LocalHmConfig.network (new optional field) - TraderSpawnOptions.network (was: testnet|mainnet|dev) - TraderSpawnCliOpts.network (was: testnet|mainnet|dev) - --network help text updated Also supports SPHERE_LOCAL_HM_NETWORK env var as a fallback source. Companion to sphere-sdk PR #656 (wave 6-P2-20 retry wrapper) which handles testnet2 gateway 5xx transients. --- src/host/local-hm.ts | 8 ++++++++ src/trader/spawn.ts | 3 ++- src/trader/trader-commands.ts | 4 ++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/host/local-hm.ts b/src/host/local-hm.ts index 99dad2e..f1dee15 100644 --- a/src/host/local-hm.ts +++ b/src/host/local-hm.ts @@ -179,6 +179,13 @@ export interface LocalHmConfig { * Override with `--hm-image` or `SPHERE_LOCAL_HM_IMAGE`. */ readonly image?: string; + /** + * Sphere network to inject into the HM (`UNICITY_NETWORK`) so the + * HM inherits it into every tenant it spawns. Defaults to 'testnet' + * for backward compat; pass 'testnet2' to run tenants against the + * v2 gateway (Phase-6 UXF fork). + */ + readonly network?: string; /** * Health-port to expose on `127.0.0.1`. The HM listens on 9401 * internally; we map each per-developer HM to a different host port @@ -788,6 +795,7 @@ export async function ensureLocalHM(config: LocalHmConfig): Promise', 'Override the local HM container image') .option('--templates-file ', 'Override templates.json mounted into the HM') .option('--health-port ', 'Override HM health-port host mapping (127.0.0.1:)') - .option('--network ', 'Sphere network: testnet|mainnet|dev (default: testnet)') + .option('--network ', 'Sphere network: testnet|testnet2|mainnet|dev (default: testnet)') .action(async function (this: Command, opts: TraderSpawnCliOpts) { await handleSpawn(this, opts); });