@toon-protocol/townhouse 0.5.1 → 0.5.3

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.
@@ -14288,6 +14288,7 @@ function resolveConfigNetworkProfile(config, keyId) {
14288
14288
  // src/connector/hs-config-writer.ts
14289
14289
  var HS_DIR = "/var/lib/anon/hs";
14290
14290
  var HS_PORT = 3e3;
14291
+ var DVM_HANDLER_URL = "http://townhouse-hs-dvm:3300";
14291
14292
  function writeHsConnectorConfig(configDir, config, options = {}) {
14292
14293
  const yamlPath = join4(configDir, "connector.yaml");
14293
14294
  if (!options.force && existsSync2(yamlPath)) {
@@ -14326,6 +14327,19 @@ function writeHsConnectorConfig(configDir, config, options = {}) {
14326
14327
  const baseYaml = generator.toYaml(hsRuntimeConfig);
14327
14328
  const parsed = parse2(baseYaml);
14328
14329
  parsed["anon"] = { enabled: true };
14330
+ const apexNodeId = typeof parsed["nodeId"] === "string" ? parsed["nodeId"] : "g.townhouse";
14331
+ parsed["localDelivery"] = { enabled: true, handlerUrl: DVM_HANDLER_URL };
14332
+ const existingRoutes = Array.isArray(parsed["routes"]) ? parsed["routes"] : [];
14333
+ if (!existingRoutes.some(
14334
+ (r) => r["prefix"] === apexNodeId && r["nextHop"] === "local"
14335
+ )) {
14336
+ existingRoutes.push({
14337
+ prefix: apexNodeId,
14338
+ nextHop: "local",
14339
+ priority: 100
14340
+ });
14341
+ }
14342
+ parsed["routes"] = existingRoutes;
14329
14343
  const finalYaml = yamlStringify2(parsed);
14330
14344
  writeFileSync3(yamlPath, finalYaml, { mode: 384, encoding: "utf-8" });
14331
14345
  chmodSync(yamlPath, 384);
@@ -14627,7 +14641,14 @@ var BootReconciler = class {
14627
14641
  id: entry.peerId,
14628
14642
  url: deriveBtpUrl(entry),
14629
14643
  authToken: "",
14630
- routes: [{ prefix: entry.ilpAddress, priority: 0 }]
14644
+ routes: [{ prefix: entry.ilpAddress, priority: 0 }],
14645
+ // Re-registration must mirror the provisioning-path peer config
14646
+ // (nodes-lifecycle.ts), or a connector restart silently restores
14647
+ // peers as settlement 'peer's (paid packets → T00) dialled over the
14648
+ // global SOCKS5 transport (Docker-internal hostnames → HostUnreachable).
14649
+ // Every nodes.yaml entry is an apex-owned child.
14650
+ relation: "child",
14651
+ transport: "direct"
14631
14652
  });
14632
14653
  summary.reregistered++;
14633
14654
  await this.tryAppendLog({
@@ -20311,6 +20332,17 @@ var ACCOUNT_INDEX = {
20311
20332
  dvm: ACCOUNT_INDEX_DVM
20312
20333
  };
20313
20334
  var APEX_ILP_ADDRESS = "g.townhouse";
20335
+ function zeroChannelIdForChain(chain2) {
20336
+ if (chain2.startsWith("solana:")) return "1".repeat(32);
20337
+ return "0x" + "0".repeat(64);
20338
+ }
20339
+ function buildMillChainProviders(config) {
20340
+ const source = config.chainProviders && config.chainProviders.length > 0 ? config.chainProviders : DEFAULT_HS_CHAIN_PROVIDERS;
20341
+ return source.map((provider) => {
20342
+ const { keyId: _keyId, ...rest } = provider;
20343
+ return rest;
20344
+ });
20345
+ }
20314
20346
  function buildMillSwapPairConfig(config) {
20315
20347
  const fromChain = config.chainProviders?.[0]?.chainId ?? "evm:base:31337";
20316
20348
  const toChain = "solana:devnet";
@@ -20326,12 +20358,13 @@ function buildMillSwapPairConfig(config) {
20326
20358
  ],
20327
20359
  chains: ["evm", "solana"],
20328
20360
  // Bootstrap: validateConfig() requires a non-empty channels array for
20329
- // each distinct pair.to.chain. The zero channelId is a valid-format
20330
- // sentinel that will never match a real on-chain channel.
20361
+ // each distinct pair.to.chain. The sentinel channelId is valid-FORMAT for
20362
+ // the target chain (see zeroChannelIdForChain) and never matches a real
20363
+ // on-chain channel.
20331
20364
  channels: {
20332
20365
  [toChain]: [
20333
20366
  {
20334
- channelId: "0x" + "0".repeat(64),
20367
+ channelId: zeroChannelIdForChain(toChain),
20335
20368
  cumulativeAmount: "0",
20336
20369
  nonce: "0"
20337
20370
  }
@@ -20340,7 +20373,9 @@ function buildMillSwapPairConfig(config) {
20340
20373
  // Zero initial SOL inventory; parsed to 0n by the Mill CLI.
20341
20374
  inventory: {
20342
20375
  [toChain]: "0"
20343
- }
20376
+ },
20377
+ // Per-packet claim service config — REQUIRED for the mill to accept swaps.
20378
+ chainProviders: buildMillChainProviders(config)
20344
20379
  };
20345
20380
  }
20346
20381
  async function waitForHealthy(url, timeoutMs) {
@@ -20601,7 +20636,7 @@ function registerNodeLifecycleRoutes(app, deps) {
20601
20636
  await fs5.chmod(dirname8(millConfigPath), 448);
20602
20637
  await fs5.writeFile(millConfigPath, defaultMillConfig, {
20603
20638
  encoding: "utf-8",
20604
- mode: 384
20639
+ mode: 420
20605
20640
  });
20606
20641
  millConfigWritten = true;
20607
20642
  } catch (err) {
@@ -20753,6 +20788,16 @@ function registerNodeLifecycleRoutes(app, deps) {
20753
20788
  url: btpUrl,
20754
20789
  authToken: "",
20755
20790
  routes: [{ prefix: ilpAddress, priority: 0 }],
20791
+ // Tag every provisioned node as a CHILD of the apex. The connector's
20792
+ // `requiresSettlementClaim()` returns false for children, so the apex
20793
+ // forwards client-paid PREPAREs to the node for FREE (parent→child
20794
+ // packets carry no per-packet claim — the apex settles in aggregate).
20795
+ // Without this the peer defaults to 'peer' and every paid packet
20796
+ // forwarded to a town/mill/dvm node is rejected `T00 No payment
20797
+ // channel available for peer`. Pairs with the child-side
20798
+ // `TOON_PARENT_PEER_ID` in townhouse-hs.yml (which MUST equal the
20799
+ // apex connector's nodeId so the child applies the parent relation).
20800
+ relation: "child",
20756
20801
  // Force direct (non-SOCKS5) BTP dial for this Docker-sibling
20757
20802
  // peer. The apex connector runs with `transport.type: socks5`
20758
20803
  // so the .anyone HS can publish; without this override, every
@@ -22789,4 +22834,4 @@ export {
22789
22834
  @scure/bip32/index.js:
22790
22835
  (*! scure-bip32 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) *)
22791
22836
  */
22792
- //# sourceMappingURL=chunk-EQ6SS4ZJ.js.map
22837
+ //# sourceMappingURL=chunk-XFPIK22M.js.map