@toon-protocol/client-mcp 0.6.0 → 0.7.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-XBD4J7XA.js → chunk-6N2FGTST.js} +8 -3
- package/dist/chunk-6N2FGTST.js.map +1 -0
- package/dist/{chunk-TDXKG3EI.js → chunk-CHTBE4PI.js} +96 -6
- package/dist/{chunk-TDXKG3EI.js.map → chunk-CHTBE4PI.js.map} +1 -1
- package/dist/{chunk-V2SV6C3U.js → chunk-Y5U4UCHU.js} +2 -2
- package/dist/daemon.js +2 -2
- package/dist/index.d.ts +25 -9
- package/dist/index.js +3 -3
- package/dist/mcp.js +2 -2
- package/package.json +4 -4
- package/dist/chunk-XBD4J7XA.js.map +0 -1
- /package/dist/{chunk-V2SV6C3U.js.map → chunk-Y5U4UCHU.js.map} +0 -0
|
@@ -11045,6 +11045,9 @@ var ToonClient = class {
|
|
|
11045
11045
|
return this.state.discoveryTracker.getDiscoveredPeers();
|
|
11046
11046
|
}
|
|
11047
11047
|
};
|
|
11048
|
+
function defaultFaucetTimeout(chain2) {
|
|
11049
|
+
return chain2 === "mina" ? 12e4 : 3e4;
|
|
11050
|
+
}
|
|
11048
11051
|
function faucetPath(chain2) {
|
|
11049
11052
|
switch (chain2) {
|
|
11050
11053
|
case "evm":
|
|
@@ -11065,7 +11068,7 @@ async function fundWallet(faucetUrl, address, chain2, options = {}) {
|
|
|
11065
11068
|
const base = faucetUrl.replace(/\/+$/, "");
|
|
11066
11069
|
const url = `${base}${faucetPath(chain2)}`;
|
|
11067
11070
|
const fetchImpl = options.fetchImpl ?? fetch;
|
|
11068
|
-
const timeout = options.timeout ??
|
|
11071
|
+
const timeout = options.timeout ?? defaultFaucetTimeout(chain2);
|
|
11069
11072
|
const controller = new AbortController();
|
|
11070
11073
|
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
11071
11074
|
let response;
|
|
@@ -11675,6 +11678,80 @@ function isEventExpired(event, nowSeconds = Math.floor(Date.now() / 1e3)) {
|
|
|
11675
11678
|
const exp = getEventExpiration(event);
|
|
11676
11679
|
return exp !== void 0 && exp <= nowSeconds;
|
|
11677
11680
|
}
|
|
11681
|
+
var genesis_peers_default2 = [];
|
|
11682
|
+
var PUBKEY_REGEX32 = /^[0-9a-f]{64}$/;
|
|
11683
|
+
var ILP_ADDRESS_REGEX2 = /^g\.[a-zA-Z0-9.-]+$/;
|
|
11684
|
+
function isValidPubkey22(pubkey) {
|
|
11685
|
+
return PUBKEY_REGEX32.test(pubkey);
|
|
11686
|
+
}
|
|
11687
|
+
function isValidRelayUrl2(url) {
|
|
11688
|
+
return url.startsWith("wss://") || url.startsWith("ws://");
|
|
11689
|
+
}
|
|
11690
|
+
function isValidIlpAddress2(address) {
|
|
11691
|
+
return ILP_ADDRESS_REGEX2.test(address);
|
|
11692
|
+
}
|
|
11693
|
+
function isValidBtpEndpoint2(url) {
|
|
11694
|
+
return url.startsWith("wss://") || url.startsWith("ws://");
|
|
11695
|
+
}
|
|
11696
|
+
function isValidGenesisPeer2(entry) {
|
|
11697
|
+
if (typeof entry !== "object" || entry === null) return false;
|
|
11698
|
+
const obj = entry;
|
|
11699
|
+
return typeof obj["pubkey"] === "string" && typeof obj["relayUrl"] === "string" && typeof obj["ilpAddress"] === "string" && typeof obj["btpEndpoint"] === "string" && isValidPubkey22(obj["pubkey"]) && isValidRelayUrl2(obj["relayUrl"]) && isValidIlpAddress2(obj["ilpAddress"]) && isValidBtpEndpoint2(obj["btpEndpoint"]);
|
|
11700
|
+
}
|
|
11701
|
+
function deduplicateByPubkey2(peers) {
|
|
11702
|
+
const map = /* @__PURE__ */ new Map();
|
|
11703
|
+
for (const peer of peers) {
|
|
11704
|
+
map.set(peer.pubkey, peer);
|
|
11705
|
+
}
|
|
11706
|
+
return [...map.values()];
|
|
11707
|
+
}
|
|
11708
|
+
function loadGenesisPeers2() {
|
|
11709
|
+
const raw = genesis_peers_default2;
|
|
11710
|
+
const valid = [];
|
|
11711
|
+
for (const entry of raw) {
|
|
11712
|
+
if (isValidGenesisPeer2(entry)) {
|
|
11713
|
+
valid.push(entry);
|
|
11714
|
+
} else {
|
|
11715
|
+
console.warn("Skipping invalid genesis peer entry:", entry);
|
|
11716
|
+
}
|
|
11717
|
+
}
|
|
11718
|
+
return deduplicateByPubkey2(valid);
|
|
11719
|
+
}
|
|
11720
|
+
function loadAdditionalPeers2(json) {
|
|
11721
|
+
let parsed;
|
|
11722
|
+
try {
|
|
11723
|
+
parsed = JSON.parse(json);
|
|
11724
|
+
} catch {
|
|
11725
|
+
console.warn("Failed to parse additional peers JSON:", json);
|
|
11726
|
+
return [];
|
|
11727
|
+
}
|
|
11728
|
+
if (!Array.isArray(parsed)) {
|
|
11729
|
+
console.warn("Additional peers JSON is not an array");
|
|
11730
|
+
return [];
|
|
11731
|
+
}
|
|
11732
|
+
const valid = [];
|
|
11733
|
+
for (const entry of parsed) {
|
|
11734
|
+
if (isValidGenesisPeer2(entry)) {
|
|
11735
|
+
valid.push(entry);
|
|
11736
|
+
} else {
|
|
11737
|
+
console.warn("Skipping invalid additional peer entry:", entry);
|
|
11738
|
+
}
|
|
11739
|
+
}
|
|
11740
|
+
return valid;
|
|
11741
|
+
}
|
|
11742
|
+
function loadAllPeers2(additionalPeersJson) {
|
|
11743
|
+
const genesis = loadGenesisPeers2();
|
|
11744
|
+
if (!additionalPeersJson) {
|
|
11745
|
+
return genesis;
|
|
11746
|
+
}
|
|
11747
|
+
const additional = loadAdditionalPeers2(additionalPeersJson);
|
|
11748
|
+
return deduplicateByPubkey2([...genesis, ...additional]);
|
|
11749
|
+
}
|
|
11750
|
+
var GenesisPeerLoader2 = {
|
|
11751
|
+
loadGenesisPeers: loadGenesisPeers2,
|
|
11752
|
+
loadAdditionalPeers: loadAdditionalPeers2,
|
|
11753
|
+
loadAllPeers: loadAllPeers2
|
|
11754
|
+
};
|
|
11678
11755
|
var ILP_TO_SEMANTIC2 = Object.freeze({
|
|
11679
11756
|
T00: "internal_error",
|
|
11680
11757
|
T04: "insufficient_funds",
|
|
@@ -11756,19 +11833,31 @@ function parseCsvEnv(value) {
|
|
|
11756
11833
|
const items = value.split(",").map((s) => s.trim()).filter(Boolean);
|
|
11757
11834
|
return items.length ? items : void 0;
|
|
11758
11835
|
}
|
|
11836
|
+
function deriveRouteDestinations(anchor) {
|
|
11837
|
+
const segs = anchor.split(".");
|
|
11838
|
+
if (segs.at(-1) === "store" && segs.at(-2) === "relay") {
|
|
11839
|
+
const base = segs.slice(0, -2).join(".");
|
|
11840
|
+
return { publish: `${base}.relay`, store: `${base}.store` };
|
|
11841
|
+
}
|
|
11842
|
+
return { publish: anchor, store: anchor };
|
|
11843
|
+
}
|
|
11759
11844
|
function resolveConfig(file) {
|
|
11760
11845
|
const mnemonic = resolveMnemonic(file);
|
|
11761
11846
|
const proxyUrl = process.env["TOON_CLIENT_PROXY_URL"] ?? file.proxyUrl;
|
|
11762
11847
|
const faucetUrl = process.env["TOON_CLIENT_FAUCET_URL"] ?? file.faucetUrl;
|
|
11848
|
+
const faucetTimeoutEnv = process.env["TOON_CLIENT_FAUCET_TIMEOUT_MS"];
|
|
11849
|
+
const faucetTimeoutMs = faucetTimeoutEnv && Number.isFinite(Number(faucetTimeoutEnv)) ? Number(faucetTimeoutEnv) : file.faucetTimeoutMs;
|
|
11763
11850
|
const btpUrl = process.env["TOON_CLIENT_BTP_URL"] ?? file.btpUrl;
|
|
11764
11851
|
const hasUplink = Boolean(btpUrl || proxyUrl);
|
|
11765
|
-
const
|
|
11852
|
+
const genesisSeed = GenesisPeerLoader2.loadGenesisPeers()[0];
|
|
11853
|
+
const relayUrl = process.env["TOON_CLIENT_RELAY_URL"] ?? file.relayUrl ?? genesisSeed?.relayUrl ?? "ws://localhost:7100";
|
|
11766
11854
|
const httpPort = Number(
|
|
11767
11855
|
process.env["TOON_CLIENT_HTTP_PORT"] ?? file.httpPort ?? 8787
|
|
11768
11856
|
);
|
|
11769
|
-
const destination = process.env["TOON_CLIENT_DESTINATION"] ?? file.destination ?? "g.townhouse.town";
|
|
11770
|
-
const
|
|
11771
|
-
const
|
|
11857
|
+
const destination = process.env["TOON_CLIENT_DESTINATION"] ?? file.destination ?? genesisSeed?.ilpAddress ?? "g.townhouse.town";
|
|
11858
|
+
const routes = deriveRouteDestinations(destination);
|
|
11859
|
+
const publishDestination = process.env["TOON_CLIENT_PUBLISH_DESTINATION"] ?? file.publishDestination ?? routes.publish;
|
|
11860
|
+
const storeDestination = process.env["TOON_CLIENT_STORE_DESTINATION"] ?? file.storeDestination ?? routes.store;
|
|
11772
11861
|
const feePerEvent = BigInt(file.feePerEvent ?? "1");
|
|
11773
11862
|
const arweaveGateways = parseCsvEnv(process.env["TOON_CLIENT_ARWEAVE_GATEWAYS"]) ?? file.arweaveGateways ?? [...ARWEAVE_GATEWAYS];
|
|
11774
11863
|
const network = process.env["TOON_CLIENT_NETWORK"] ?? file.network;
|
|
@@ -11815,6 +11904,7 @@ function resolveConfig(file) {
|
|
|
11815
11904
|
hasUplink,
|
|
11816
11905
|
...proxyUrl ? { proxyUrl } : {},
|
|
11817
11906
|
...faucetUrl ? { faucetUrl } : {},
|
|
11907
|
+
...faucetTimeoutMs !== void 0 ? { faucetTimeoutMs } : {},
|
|
11818
11908
|
destination,
|
|
11819
11909
|
publishDestination,
|
|
11820
11910
|
storeDestination,
|
|
@@ -12142,4 +12232,4 @@ export {
|
|
|
12142
12232
|
@scure/bip32/lib/esm/index.js:
|
|
12143
12233
|
(*! scure-bip32 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) *)
|
|
12144
12234
|
*/
|
|
12145
|
-
//# sourceMappingURL=chunk-
|
|
12235
|
+
//# sourceMappingURL=chunk-CHTBE4PI.js.map
|