@toon-protocol/townhouse 0.4.0 → 0.5.1
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.
- package/dist/{chunk-SXKZUTGE.js → chunk-EQ6SS4ZJ.js} +105 -23
- package/dist/chunk-EQ6SS4ZJ.js.map +1 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +16 -3
- package/dist/cli.js.map +1 -1
- package/dist/compose/townhouse-hs.yml +8 -8
- package/dist/image-manifest.json +10 -10
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/{manager-D9Y_iWHo.d.ts → manager-DSkD9Td1.d.ts} +14 -1
- package/package.json +3 -3
- package/dist/chunk-SXKZUTGE.js.map +0 -1
|
@@ -6444,6 +6444,19 @@ function validateConfig(raw) {
|
|
|
6444
6444
|
}
|
|
6445
6445
|
network = raw["network"];
|
|
6446
6446
|
}
|
|
6447
|
+
let endpoints;
|
|
6448
|
+
if (raw["endpoints"] !== void 0) {
|
|
6449
|
+
assertObject(raw["endpoints"], "config.endpoints");
|
|
6450
|
+
const e = raw["endpoints"];
|
|
6451
|
+
if (e["evmUrl"] !== void 0)
|
|
6452
|
+
assertString(e["evmUrl"], "config.endpoints.evmUrl");
|
|
6453
|
+
if (e["solUrl"] !== void 0)
|
|
6454
|
+
assertString(e["solUrl"], "config.endpoints.solUrl");
|
|
6455
|
+
endpoints = {
|
|
6456
|
+
...e["evmUrl"] !== void 0 ? { evmUrl: e["evmUrl"] } : {},
|
|
6457
|
+
...e["solUrl"] !== void 0 ? { solUrl: e["solUrl"] } : {}
|
|
6458
|
+
};
|
|
6459
|
+
}
|
|
6447
6460
|
let chainProviders;
|
|
6448
6461
|
if (raw["chainProviders"] !== void 0) {
|
|
6449
6462
|
if (!Array.isArray(raw["chainProviders"])) {
|
|
@@ -6577,6 +6590,7 @@ function validateConfig(raw) {
|
|
|
6577
6590
|
level: logging["level"]
|
|
6578
6591
|
},
|
|
6579
6592
|
...network !== void 0 ? { network } : {},
|
|
6593
|
+
...endpoints !== void 0 ? { endpoints } : {},
|
|
6580
6594
|
...chainProviders !== void 0 ? { chainProviders } : {}
|
|
6581
6595
|
};
|
|
6582
6596
|
}
|
|
@@ -14070,6 +14084,12 @@ function buildMinaProviderEntry(config, keyId) {
|
|
|
14070
14084
|
network: config.network
|
|
14071
14085
|
};
|
|
14072
14086
|
}
|
|
14087
|
+
var DEV_EVM_PRESET = "anvil";
|
|
14088
|
+
var DEV_SOLANA = {
|
|
14089
|
+
usdcMint: "6GbdrVghwNKTz9raga7y3Y4qqX5Zgg3AC4d48Kt7C59Q",
|
|
14090
|
+
programId: ""
|
|
14091
|
+
// TOON payment-channel program not deployed on the dev Solana node
|
|
14092
|
+
};
|
|
14073
14093
|
var RELAY_ONLY_CHAIN = "none";
|
|
14074
14094
|
var EVM_TIER = {
|
|
14075
14095
|
mainnet: { primary: "base-mainnet", also: ["arbitrum-one"] },
|
|
@@ -14122,7 +14142,11 @@ function evmSettlementComplete(p) {
|
|
|
14122
14142
|
}
|
|
14123
14143
|
function resolveNetworkProfile(network, opts = {}) {
|
|
14124
14144
|
if (network === "custom") {
|
|
14125
|
-
return resolveCustom(
|
|
14145
|
+
return resolveCustom(
|
|
14146
|
+
opts.customProviders ?? [],
|
|
14147
|
+
opts.endpoints ?? {},
|
|
14148
|
+
opts.keyId
|
|
14149
|
+
);
|
|
14126
14150
|
}
|
|
14127
14151
|
const tier = network;
|
|
14128
14152
|
const chainProviders = [];
|
|
@@ -14184,7 +14208,10 @@ function resolveNetworkProfile(network, opts = {}) {
|
|
|
14184
14208
|
}
|
|
14185
14209
|
return { network, chainProviders, nodeEnv, status };
|
|
14186
14210
|
}
|
|
14187
|
-
function resolveCustom(providers) {
|
|
14211
|
+
function resolveCustom(providers, endpoints, keyId) {
|
|
14212
|
+
if (providers.length === 0 && (endpoints.evmUrl || endpoints.solUrl)) {
|
|
14213
|
+
return resolveCustomEndpoints(endpoints, keyId);
|
|
14214
|
+
}
|
|
14188
14215
|
const status = {
|
|
14189
14216
|
evm: "unconfigured",
|
|
14190
14217
|
solana: "unconfigured",
|
|
@@ -14213,6 +14240,50 @@ function resolveCustom(providers) {
|
|
|
14213
14240
|
}
|
|
14214
14241
|
return { network: "custom", chainProviders: providers, nodeEnv, status };
|
|
14215
14242
|
}
|
|
14243
|
+
function resolveCustomEndpoints(endpoints, keyId) {
|
|
14244
|
+
const evm = CHAIN_PRESETS[DEV_EVM_PRESET];
|
|
14245
|
+
const status = {
|
|
14246
|
+
evm: "unconfigured",
|
|
14247
|
+
solana: "unconfigured",
|
|
14248
|
+
mina: "unconfigured"
|
|
14249
|
+
};
|
|
14250
|
+
const chainProviders = [];
|
|
14251
|
+
const nodeEnv = {
|
|
14252
|
+
EVM_CHAIN: DEV_EVM_PRESET,
|
|
14253
|
+
EVM_CHAIN_ID: String(evm.chainId),
|
|
14254
|
+
EVM_USDC_ADDRESS: evm.usdcAddress
|
|
14255
|
+
};
|
|
14256
|
+
if (endpoints.evmUrl) {
|
|
14257
|
+
nodeEnv.EVM_RPC_URL = endpoints.evmUrl;
|
|
14258
|
+
status.evm = "configured";
|
|
14259
|
+
if (keyId) {
|
|
14260
|
+
chainProviders.push(
|
|
14261
|
+
buildEvmProviderEntry({ ...evm, rpcUrl: endpoints.evmUrl }, keyId)
|
|
14262
|
+
);
|
|
14263
|
+
}
|
|
14264
|
+
} else {
|
|
14265
|
+
nodeEnv.EVM_CHAIN = RELAY_ONLY_CHAIN;
|
|
14266
|
+
}
|
|
14267
|
+
if (endpoints.solUrl) {
|
|
14268
|
+
nodeEnv.SOLANA_RPC_URL = endpoints.solUrl;
|
|
14269
|
+
nodeEnv.SOLANA_USDC_MINT = DEV_SOLANA.usdcMint;
|
|
14270
|
+
}
|
|
14271
|
+
return { network: "custom", chainProviders, nodeEnv, status };
|
|
14272
|
+
}
|
|
14273
|
+
|
|
14274
|
+
// src/config/network-profile.ts
|
|
14275
|
+
function resolveConfigNetworkProfile(config, keyId) {
|
|
14276
|
+
if (config.chainProviders && config.chainProviders.length > 0) {
|
|
14277
|
+
return resolveNetworkProfile("custom", {
|
|
14278
|
+
keyId,
|
|
14279
|
+
customProviders: config.chainProviders
|
|
14280
|
+
});
|
|
14281
|
+
}
|
|
14282
|
+
return resolveNetworkProfile(config.network ?? "mainnet", {
|
|
14283
|
+
keyId,
|
|
14284
|
+
endpoints: config.endpoints
|
|
14285
|
+
});
|
|
14286
|
+
}
|
|
14216
14287
|
|
|
14217
14288
|
// src/connector/hs-config-writer.ts
|
|
14218
14289
|
var HS_DIR = "/var/lib/anon/hs";
|
|
@@ -14229,11 +14300,10 @@ function writeHsConnectorConfig(configDir, config, options = {}) {
|
|
|
14229
14300
|
} catch {
|
|
14230
14301
|
}
|
|
14231
14302
|
}
|
|
14232
|
-
const
|
|
14233
|
-
|
|
14234
|
-
|
|
14235
|
-
|
|
14236
|
-
}).chainProviders;
|
|
14303
|
+
const derived = resolveConfigNetworkProfile(
|
|
14304
|
+
config,
|
|
14305
|
+
DEFAULT_HS_CHAIN_PROVIDERS[0]?.keyId
|
|
14306
|
+
).chainProviders;
|
|
14237
14307
|
const hsConfig = derived.length > 0 ? { ...config, chainProviders: derived } : { ...config, chainProviders: [...DEFAULT_HS_CHAIN_PROVIDERS] };
|
|
14238
14308
|
const generator = new ConnectorConfigGenerator(hsConfig);
|
|
14239
14309
|
const baseConfig = generator.generate([]);
|
|
@@ -14275,9 +14345,7 @@ import { join as join5 } from "path";
|
|
|
14275
14345
|
function writeHsNodeEnvFile(configDir, config) {
|
|
14276
14346
|
const composeDir = join5(configDir, "compose");
|
|
14277
14347
|
const envPath = join5(composeDir, ".env");
|
|
14278
|
-
const profile =
|
|
14279
|
-
customProviders: config.chainProviders
|
|
14280
|
-
});
|
|
14348
|
+
const profile = resolveConfigNetworkProfile(config);
|
|
14281
14349
|
const lines = [
|
|
14282
14350
|
"# Generated by `townhouse hs up` from the `network` mode \u2014 do not edit.",
|
|
14283
14351
|
`# network=${profile.network}`
|
|
@@ -20296,9 +20364,7 @@ async function waitForHealthy(url, timeoutMs) {
|
|
|
20296
20364
|
);
|
|
20297
20365
|
}
|
|
20298
20366
|
function buildNetworkNodeEnv(config) {
|
|
20299
|
-
const profile =
|
|
20300
|
-
customProviders: config.chainProviders
|
|
20301
|
-
});
|
|
20367
|
+
const profile = resolveConfigNetworkProfile(config);
|
|
20302
20368
|
const env = {};
|
|
20303
20369
|
for (const [key, value] of Object.entries(profile.nodeEnv)) {
|
|
20304
20370
|
if (value !== void 0) env[key] = value;
|
|
@@ -21835,12 +21901,10 @@ function registerChainsRoutes(app, deps) {
|
|
|
21835
21901
|
|
|
21836
21902
|
// src/api/routes/network.ts
|
|
21837
21903
|
var NETWORK_MODES = ["mainnet", "testnet", "devnet", "custom"];
|
|
21838
|
-
function networkView(
|
|
21839
|
-
const profile =
|
|
21840
|
-
customProviders: config.chainProviders
|
|
21841
|
-
});
|
|
21904
|
+
function networkView(config) {
|
|
21905
|
+
const profile = resolveConfigNetworkProfile(config);
|
|
21842
21906
|
return {
|
|
21843
|
-
network,
|
|
21907
|
+
network: config.network ?? "mainnet",
|
|
21844
21908
|
status: profile.status,
|
|
21845
21909
|
// Public endpoints only — no secrets in the network node env.
|
|
21846
21910
|
nodeEnv: profile.nodeEnv
|
|
@@ -21852,30 +21916,45 @@ var patchBodySchema4 = {
|
|
|
21852
21916
|
additionalProperties: false,
|
|
21853
21917
|
required: ["network"],
|
|
21854
21918
|
properties: {
|
|
21855
|
-
network: { type: "string", enum: NETWORK_MODES }
|
|
21919
|
+
network: { type: "string", enum: NETWORK_MODES },
|
|
21920
|
+
endpoints: {
|
|
21921
|
+
type: "object",
|
|
21922
|
+
additionalProperties: false,
|
|
21923
|
+
properties: {
|
|
21924
|
+
evmUrl: { type: "string", maxLength: 2048 },
|
|
21925
|
+
solUrl: { type: "string", maxLength: 2048 }
|
|
21926
|
+
}
|
|
21927
|
+
}
|
|
21856
21928
|
}
|
|
21857
21929
|
}
|
|
21858
21930
|
};
|
|
21859
21931
|
function registerNetworkRoutes(app, deps) {
|
|
21860
21932
|
app.get("/api/network", async (_request, reply) => {
|
|
21861
|
-
|
|
21862
|
-
|
|
21933
|
+
return reply.status(200).send({
|
|
21934
|
+
...networkView(deps.config),
|
|
21935
|
+
endpoints: deps.config.endpoints,
|
|
21936
|
+
ts: Date.now()
|
|
21937
|
+
});
|
|
21863
21938
|
});
|
|
21864
21939
|
app.patch(
|
|
21865
21940
|
"/api/network",
|
|
21866
21941
|
{ schema: patchBodySchema4 },
|
|
21867
21942
|
async (request, reply) => {
|
|
21868
21943
|
const next = request.body.network;
|
|
21944
|
+
const nextEndpoints = request.body.endpoints;
|
|
21869
21945
|
if (!acquireConfigMutex()) {
|
|
21870
21946
|
return reply.status(409).send({ error: "config_mutation_in_flight" });
|
|
21871
21947
|
}
|
|
21872
21948
|
const prior = deps.config.network;
|
|
21949
|
+
const priorEndpoints = deps.config.endpoints;
|
|
21873
21950
|
try {
|
|
21874
21951
|
deps.config.network = next;
|
|
21952
|
+
if (nextEndpoints !== void 0) deps.config.endpoints = nextEndpoints;
|
|
21875
21953
|
try {
|
|
21876
21954
|
validateConfig(deps.config);
|
|
21877
21955
|
} catch (validationError) {
|
|
21878
21956
|
deps.config.network = prior;
|
|
21957
|
+
deps.config.endpoints = priorEndpoints;
|
|
21879
21958
|
return reply.status(400).send({
|
|
21880
21959
|
error: "config_validation_error",
|
|
21881
21960
|
message: validationError instanceof Error ? validationError.message : "Invalid network"
|
|
@@ -21885,6 +21964,7 @@ function registerNetworkRoutes(app, deps) {
|
|
|
21885
21964
|
await saveConfig(deps.configPath, deps.config);
|
|
21886
21965
|
} catch (saveError) {
|
|
21887
21966
|
deps.config.network = prior;
|
|
21967
|
+
deps.config.endpoints = priorEndpoints;
|
|
21888
21968
|
return reply.status(500).send({
|
|
21889
21969
|
error: "config_save_failed",
|
|
21890
21970
|
message: saveError instanceof Error ? saveError.message : "Failed to persist config"
|
|
@@ -21895,6 +21975,7 @@ function registerNetworkRoutes(app, deps) {
|
|
|
21895
21975
|
await deps.orchestrator.regenerateConnectorConfig(activeNodes);
|
|
21896
21976
|
} catch (restartError) {
|
|
21897
21977
|
deps.config.network = prior;
|
|
21978
|
+
deps.config.endpoints = priorEndpoints;
|
|
21898
21979
|
try {
|
|
21899
21980
|
await saveConfig(deps.configPath, deps.config);
|
|
21900
21981
|
} catch {
|
|
@@ -21905,7 +21986,8 @@ function registerNetworkRoutes(app, deps) {
|
|
|
21905
21986
|
});
|
|
21906
21987
|
}
|
|
21907
21988
|
return reply.status(200).send({
|
|
21908
|
-
...networkView(
|
|
21989
|
+
...networkView(deps.config),
|
|
21990
|
+
endpoints: deps.config.endpoints,
|
|
21909
21991
|
restartTriggered: true,
|
|
21910
21992
|
restartedAt: Date.now()
|
|
21911
21993
|
});
|
|
@@ -22707,4 +22789,4 @@ export {
|
|
|
22707
22789
|
@scure/bip32/index.js:
|
|
22708
22790
|
(*! scure-bip32 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) *)
|
|
22709
22791
|
*/
|
|
22710
|
-
//# sourceMappingURL=chunk-
|
|
22792
|
+
//# sourceMappingURL=chunk-EQ6SS4ZJ.js.map
|