@toon-protocol/client-mcp 0.11.0 → 0.12.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.
@@ -15,7 +15,7 @@ import {
15
15
  isEventExpired,
16
16
  parseIlpPeerInfo,
17
17
  readConfigFile
18
- } from "./chunk-CMGJ3NFT.js";
18
+ } from "./chunk-W6T6ZK7U.js";
19
19
  import {
20
20
  __require
21
21
  } from "./chunk-F22GNSF6.js";
@@ -1778,9 +1778,17 @@ var ClientRunner = class {
1778
1778
  const cm = apex.client.channelManager;
1779
1779
  if (saved && cm && typeof cm.trackChannel === "function") {
1780
1780
  cm.trackChannel(saved.channelId, saved.context);
1781
- this.log(
1782
- `[runner] resumed apex channel ${saved.channelId} (tracked, no re-deposit)`
1783
- );
1781
+ if (saved.context.chainType === "evm") {
1782
+ await apex.client.rehydrateChannelDeposit?.(saved.channelId, {
1783
+ chain: `evm:${saved.context.chainId}`,
1784
+ tokenNetworkAddress: saved.context.tokenNetworkAddress
1785
+ }).catch(
1786
+ (err) => this.log(
1787
+ `[runner] deposit re-hydrate for ${saved.channelId} failed: ${errMsg2(err)}`
1788
+ )
1789
+ );
1790
+ }
1791
+ this.log(`[runner] resumed apex channel ${saved.channelId} (deposit re-read)`);
1784
1792
  return saved.channelId;
1785
1793
  }
1786
1794
  if (opts.resumeOnly) return void 0;
@@ -2050,9 +2058,24 @@ var ClientRunner = class {
2050
2058
  eventId: result.eventId ?? req.event.id,
2051
2059
  ...result.data !== void 0 ? { data: result.data } : {},
2052
2060
  channelId,
2053
- nonce: apex.client.getChannelNonce(channelId)
2061
+ nonce: apex.client.getChannelNonce(channelId),
2062
+ feePaid: fee.toString(),
2063
+ channelBalanceAfter: this.channelAvailable(apex, channelId)
2054
2064
  };
2055
2065
  }
2066
+ /**
2067
+ * Available (spendable) balance for a channel after a write — locked collateral
2068
+ * minus cumulative spent, clamped at 0. Same math as {@link getChannels}; used
2069
+ * to report a truthful post-write balance in publish/upload receipts. Returns
2070
+ * undefined if the channel isn't tracked on this apex (balance unknown).
2071
+ */
2072
+ channelAvailable(apex, channelId) {
2073
+ if (!apex.client.getTrackedChannels().includes(channelId)) return void 0;
2074
+ const cumulative = apex.client.getChannelCumulativeAmount(channelId);
2075
+ const depositTotal = apex.client.getChannelDepositTotal(channelId);
2076
+ const available = depositTotal > cumulative ? depositTotal - cumulative : 0n;
2077
+ return available.toString();
2078
+ }
2056
2079
  /**
2057
2080
  * Build, sign (with the daemon-held key), and pay-to-write an event. The
2058
2081
  * caller supplies only the event shell; the private key never leaves the
@@ -2120,7 +2143,8 @@ var ClientRunner = class {
2120
2143
  `kind:${kind} publish leg failed after upload (blob stored at ${url}): ${detail}`
2121
2144
  );
2122
2145
  }
2123
- return { ...pub, url, txId: upload.txId };
2146
+ const feePaid = (fee + BigInt(pub.feePaid)).toString();
2147
+ return { ...pub, feePaid, url, txId: upload.txId };
2124
2148
  }
2125
2149
  /**
2126
2150
  * Read media bytes off disk for an upload `filePath`. The path is resolved
@@ -2783,4 +2807,4 @@ export {
2783
2807
  PublishRejectedError,
2784
2808
  registerRoutes
2785
2809
  };
2786
- //# sourceMappingURL=chunk-KVK6OZVD.js.map
2810
+ //# sourceMappingURL=chunk-HLATGATX.js.map