@toon-protocol/client-mcp 0.5.3 → 0.6.0

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.
@@ -6956,11 +6956,11 @@ function decodeUtf8(bytes) {
6956
6956
  function isBase64(str) {
6957
6957
  return /^[A-Za-z0-9+/]*={0,2}$/.test(str);
6958
6958
  }
6959
- var REQUEST_LINE = "POST /write HTTP/1.1";
6959
+ var DEFAULT_REQUEST_TARGET = "/write";
6960
6960
  var HEADERS = ["Host: relay", "Content-Type: application/json"];
6961
- function buildStoreWriteEnvelope(event) {
6961
+ function buildStoreWriteEnvelope(event, requestTarget = DEFAULT_REQUEST_TARGET) {
6962
6962
  const body = JSON.stringify({ event });
6963
- const head = [REQUEST_LINE, ...HEADERS].join("\r\n");
6963
+ const head = [`POST ${requestTarget} HTTP/1.1`, ...HEADERS].join("\r\n");
6964
6964
  return encodeUtf8(head + "\r\n\r\n" + body);
6965
6965
  }
6966
6966
  var CRLF = "\r\n";
@@ -8755,12 +8755,12 @@ var OnChainChannelClient = class {
8755
8755
  */
8756
8756
  parseChainId(chain2) {
8757
8757
  const parts = chain2.split(":");
8758
- if (parts.length < 3) {
8758
+ if (parts.length < 2) {
8759
8759
  throw new Error(
8760
- `Invalid chain format: "${chain2}". Expected "evm:{network}:{chainId}".`
8760
+ `Invalid chain format: "${chain2}". Expected "evm:{network}:{chainId}" or "evm:{chainId}".`
8761
8761
  );
8762
8762
  }
8763
- const chainIdStr = parts[2];
8763
+ const chainIdStr = parts.length >= 3 ? parts[2] : parts[1];
8764
8764
  if (!chainIdStr) {
8765
8765
  throw new Error(
8766
8766
  `Invalid chain format: "${chain2}". Expected "evm:{network}:{chainId}".`
@@ -9957,7 +9957,9 @@ async function requestBlobStorage(client, secretKey, params) {
9957
9957
  const result = await client.publishEvent(event, {
9958
9958
  destination: params.destination,
9959
9959
  claim: params.claim,
9960
- ilpAmount: params.ilpAmount
9960
+ ilpAmount: params.ilpAmount,
9961
+ // The store/DVM backend serves POST /store (not the relay's /write).
9962
+ proxyPath: "/store"
9961
9963
  });
9962
9964
  if (!result.success) {
9963
9965
  return {
@@ -10457,7 +10459,7 @@ var ToonClient = class {
10457
10459
  if (result.negotiatedChain && result.settlementAddress) {
10458
10460
  const chainType = result.negotiatedChain.split(":")[0] ?? "evm";
10459
10461
  const parts = result.negotiatedChain.split(":");
10460
- const chainId = parts.length >= 3 ? parseInt(parts[2] ?? "0", 10) : 0;
10462
+ const chainId = parts.length >= 3 ? parseInt(parts[2] ?? "0", 10) : parts.length >= 2 ? parseInt(parts[1] ?? "0", 10) : 0;
10461
10463
  const r = result;
10462
10464
  this.peerNegotiations.set(result.registeredPeerId, {
10463
10465
  chain: result.negotiatedChain,
@@ -10475,7 +10477,7 @@ var ToonClient = class {
10475
10477
  if (matchedChain) {
10476
10478
  const peerAddr = peerInfo.settlementAddresses?.[matchedChain];
10477
10479
  const parts = matchedChain.split(":");
10478
- const chainId = parts.length >= 3 ? parseInt(parts[2] ?? "0", 10) : 0;
10480
+ const chainId = parts.length >= 3 ? parseInt(parts[2] ?? "0", 10) : parts.length >= 2 ? parseInt(parts[1] ?? "0", 10) : 0;
10479
10481
  if (peerAddr) {
10480
10482
  this.peerNegotiations.set(result.registeredPeerId, {
10481
10483
  chain: matchedChain,
@@ -10560,7 +10562,7 @@ var ToonClient = class {
10560
10562
  const toonData = this.config.toonEncoder(event);
10561
10563
  const basePricePerByte = 10n;
10562
10564
  const amount = options?.ilpAmount !== void 0 ? String(options.ilpAmount) : String(BigInt(toonData.length) * basePricePerByte);
10563
- const writeData = buildStoreWriteEnvelope(event);
10565
+ const writeData = buildStoreWriteEnvelope(event, options?.proxyPath);
10564
10566
  const destination = options?.destination ?? this.config.destinationAddress;
10565
10567
  const transport = this.getClaimTransport();
10566
10568
  let claimMessage;
@@ -10932,7 +10934,7 @@ var ToonClient = class {
10932
10934
  getChainContext(negotiatedChain) {
10933
10935
  if (!negotiatedChain) return void 0;
10934
10936
  const parts = negotiatedChain.split(":");
10935
- const chainIdPart = parts.length >= 3 ? parts[2] : void 0;
10937
+ const chainIdPart = parts.length >= 3 ? parts[2] : parts.length >= 2 ? parts[1] : void 0;
10936
10938
  const numericChainId = chainIdPart !== void 0 ? parseInt(chainIdPart, 10) : NaN;
10937
10939
  if (isNaN(numericChainId)) return void 0;
10938
10940
  const tokenNetworkAddress = this.config.tokenNetworks?.[negotiatedChain];
@@ -11702,6 +11704,18 @@ function buildIlpPrepare(params) {
11702
11704
  };
11703
11705
  }
11704
11706
 
11707
+ // ../arweave/dist/gateways.js
11708
+ var ARWEAVE_GATEWAYS = [
11709
+ "https://ar-io.dev",
11710
+ "https://arweave.net",
11711
+ "https://permagate.io"
11712
+ ];
11713
+ function arweaveUrls(txId, gateways = ARWEAVE_GATEWAYS) {
11714
+ const all = (gateways.length ? gateways : ARWEAVE_GATEWAYS).map((g) => `${g}/${txId}`);
11715
+ const [url, ...fallbacks] = all;
11716
+ return { url: url ?? `${ARWEAVE_GATEWAYS[0]}/${txId}`, fallbacks };
11717
+ }
11718
+
11705
11719
  // src/daemon/config.ts
11706
11720
  var DEFAULT_KEYSTORE_PASSWORD = "toon-client-default";
11707
11721
  function configDir() {
@@ -11737,6 +11751,11 @@ function resolveMnemonic(file) {
11737
11751
  "No mnemonic configured. Set TOON_CLIENT_MNEMONIC, configure a keystorePath (+ TOON_CLIENT_KEYSTORE_PASSWORD), or add `mnemonic` to the config file."
11738
11752
  );
11739
11753
  }
11754
+ function parseCsvEnv(value) {
11755
+ if (!value) return void 0;
11756
+ const items = value.split(",").map((s) => s.trim()).filter(Boolean);
11757
+ return items.length ? items : void 0;
11758
+ }
11740
11759
  function resolveConfig(file) {
11741
11760
  const mnemonic = resolveMnemonic(file);
11742
11761
  const proxyUrl = process.env["TOON_CLIENT_PROXY_URL"] ?? file.proxyUrl;
@@ -11748,7 +11767,10 @@ function resolveConfig(file) {
11748
11767
  process.env["TOON_CLIENT_HTTP_PORT"] ?? file.httpPort ?? 8787
11749
11768
  );
11750
11769
  const destination = process.env["TOON_CLIENT_DESTINATION"] ?? file.destination ?? "g.townhouse.town";
11770
+ const publishDestination = process.env["TOON_CLIENT_PUBLISH_DESTINATION"] ?? file.publishDestination ?? destination;
11771
+ const storeDestination = process.env["TOON_CLIENT_STORE_DESTINATION"] ?? file.storeDestination ?? destination;
11751
11772
  const feePerEvent = BigInt(file.feePerEvent ?? "1");
11773
+ const arweaveGateways = parseCsvEnv(process.env["TOON_CLIENT_ARWEAVE_GATEWAYS"]) ?? file.arweaveGateways ?? [...ARWEAVE_GATEWAYS];
11752
11774
  const network = process.env["TOON_CLIENT_NETWORK"] ?? file.network;
11753
11775
  const chain2 = process.env["TOON_CLIENT_CHAIN"] ?? file.chain ?? "evm";
11754
11776
  const apex = file.apexChains?.[chain2] ?? file.apex ?? buildProxyApexNegotiation(file, chain2, destination);
@@ -11794,13 +11816,16 @@ function resolveConfig(file) {
11794
11816
  ...proxyUrl ? { proxyUrl } : {},
11795
11817
  ...faucetUrl ? { faucetUrl } : {},
11796
11818
  destination,
11819
+ publishDestination,
11820
+ storeDestination,
11797
11821
  feePerEvent,
11798
11822
  ...apex ? { apex } : {},
11799
11823
  ...file.apexChildPeers ? { apexChildPeers: file.apexChildPeers } : {},
11800
11824
  chain: chain2,
11801
11825
  apexChannelStorePath,
11802
11826
  toonClientConfig,
11803
- network
11827
+ network,
11828
+ arweaveGateways
11804
11829
  };
11805
11830
  }
11806
11831
  function defaultChainKey(chain2, chainId) {
@@ -11823,7 +11848,7 @@ function buildProxyApexNegotiation(file, chain2, destination) {
11823
11848
  const settlementAddress = settlementAddresses[chainKey];
11824
11849
  if (!settlementAddress) return void 0;
11825
11850
  const parts = chainKey.split(":");
11826
- const chainId = chain2 === "evm" && parts.length >= 3 ? Number(parts[2] ?? 0) : 0;
11851
+ const chainId = chain2 === "evm" && parts.length >= 2 ? Number(parts[2] ?? parts[1] ?? 0) : 0;
11827
11852
  const peerId = destination.split(".").at(-1) ?? destination;
11828
11853
  return {
11829
11854
  destination,
@@ -12080,6 +12105,7 @@ export {
12080
12105
  parseIlpPeerInfo2 as parseIlpPeerInfo,
12081
12106
  isEventExpired,
12082
12107
  buildIlpPrepare,
12108
+ arweaveUrls,
12083
12109
  DEFAULT_KEYSTORE_PASSWORD,
12084
12110
  configDir,
12085
12111
  defaultConfigPath,
@@ -12116,4 +12142,4 @@ export {
12116
12142
  @scure/bip32/lib/esm/index.js:
12117
12143
  (*! scure-bip32 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) *)
12118
12144
  */
12119
- //# sourceMappingURL=chunk-3UECPDBJ.js.map
12145
+ //# sourceMappingURL=chunk-TDXKG3EI.js.map