@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.
- package/dist/app/index.html +132 -92
- package/dist/{chunk-JPQ4VCCF.js → chunk-GTSWCJOE.js} +185 -21
- package/dist/chunk-GTSWCJOE.js.map +1 -0
- package/dist/{chunk-KVK6OZVD.js → chunk-HLATGATX.js} +31 -7
- package/dist/chunk-HLATGATX.js.map +1 -0
- package/dist/{chunk-CMGJ3NFT.js → chunk-W6T6ZK7U.js} +56 -1
- package/dist/chunk-W6T6ZK7U.js.map +1 -0
- package/dist/daemon.js +2 -2
- package/dist/index.d.ts +45 -0
- package/dist/index.js +3 -3
- package/dist/mcp.js +16 -7
- package/dist/mcp.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-CMGJ3NFT.js.map +0 -1
- package/dist/chunk-JPQ4VCCF.js.map +0 -1
- package/dist/chunk-KVK6OZVD.js.map +0 -1
|
@@ -8705,6 +8705,17 @@ var TOKEN_NETWORK_ABI = [
|
|
|
8705
8705
|
{ name: "participant2", type: "address" }
|
|
8706
8706
|
]
|
|
8707
8707
|
},
|
|
8708
|
+
{
|
|
8709
|
+
name: "participants",
|
|
8710
|
+
type: "function",
|
|
8711
|
+
stateMutability: "view",
|
|
8712
|
+
inputs: [{ type: "bytes32" }, { type: "address" }],
|
|
8713
|
+
outputs: [
|
|
8714
|
+
{ name: "deposit", type: "uint256" },
|
|
8715
|
+
{ name: "nonce", type: "uint256" },
|
|
8716
|
+
{ name: "transferredAmount", type: "uint256" }
|
|
8717
|
+
]
|
|
8718
|
+
},
|
|
8708
8719
|
{
|
|
8709
8720
|
name: "ChannelOpened",
|
|
8710
8721
|
type: "event",
|
|
@@ -9036,6 +9047,23 @@ var OnChainChannelClient = class {
|
|
|
9036
9047
|
});
|
|
9037
9048
|
return { settlementTimeout: res[0], state: Number(res[1]), closedAt: res[2] };
|
|
9038
9049
|
}
|
|
9050
|
+
/**
|
|
9051
|
+
* Read a participant's on-chain channel state — `deposit` (locked collateral),
|
|
9052
|
+
* `nonce`, and `transferredAmount` — straight from the `participants` mapping.
|
|
9053
|
+
* Takes the chain + token-network explicitly so it works for a channel that
|
|
9054
|
+
* was RESUMED from disk (no in-memory `channelContext` yet), which is exactly
|
|
9055
|
+
* when the daemon needs to re-hydrate the deposit it doesn't persist.
|
|
9056
|
+
*/
|
|
9057
|
+
async readEvmParticipantState(opts) {
|
|
9058
|
+
const { publicClient } = this.createClients(opts.chain);
|
|
9059
|
+
const res = await publicClient.readContract({
|
|
9060
|
+
address: opts.tokenNetworkAddress,
|
|
9061
|
+
abi: TOKEN_NETWORK_ABI,
|
|
9062
|
+
functionName: "participants",
|
|
9063
|
+
args: [opts.channelId, opts.participant]
|
|
9064
|
+
});
|
|
9065
|
+
return { deposit: res[0], nonce: res[1], transferredAmount: res[2] };
|
|
9066
|
+
}
|
|
9039
9067
|
/**
|
|
9040
9068
|
* Opens a REAL on-chain Solana payment channel.
|
|
9041
9069
|
*
|
|
@@ -11379,6 +11407,33 @@ var ToonClient = class {
|
|
|
11379
11407
|
if (!this.channelManager) throw new Error("ChannelManager not initialized");
|
|
11380
11408
|
return this.channelManager.getChannelCloseState(channelId);
|
|
11381
11409
|
}
|
|
11410
|
+
getSettleableAt(channelId) {
|
|
11411
|
+
if (!this.channelManager) throw new Error("ChannelManager not initialized");
|
|
11412
|
+
return this.channelManager.getSettleableAt(channelId);
|
|
11413
|
+
}
|
|
11414
|
+
/**
|
|
11415
|
+
* Re-hydrate a RESUMED channel's on-chain deposit. Persisted channel state
|
|
11416
|
+
* omits `depositTotal`, so after a daemon restart the tracked deposit is `0`
|
|
11417
|
+
* and the wallet shows 0 spendable even though real collateral is locked
|
|
11418
|
+
* on-chain. Read the participant's `deposit` from the `participants` mapping
|
|
11419
|
+
* and update the tracked total so `depositTotal - cumulativeAmount` is right.
|
|
11420
|
+
* Best-effort by caller (await + catch); returns the on-chain deposit, or
|
|
11421
|
+
* `undefined` when it can't be read (no channel manager / on-chain client /
|
|
11422
|
+
* EVM address).
|
|
11423
|
+
*/
|
|
11424
|
+
async rehydrateChannelDeposit(channelId, opts) {
|
|
11425
|
+
if (!this.channelManager || !this.onChainChannelClient) return void 0;
|
|
11426
|
+
const participant = this.getEvmAddress();
|
|
11427
|
+
if (!participant) return void 0;
|
|
11428
|
+
const { deposit } = await this.onChainChannelClient.readEvmParticipantState({
|
|
11429
|
+
chain: opts.chain,
|
|
11430
|
+
tokenNetworkAddress: opts.tokenNetworkAddress,
|
|
11431
|
+
channelId,
|
|
11432
|
+
participant
|
|
11433
|
+
});
|
|
11434
|
+
this.channelManager.setDepositTotal(channelId, deposit);
|
|
11435
|
+
return deposit;
|
|
11436
|
+
}
|
|
11382
11437
|
/**
|
|
11383
11438
|
* Read the on-chain settlement-token balance of this client's OWN wallet on
|
|
11384
11439
|
* each configured chain (EVM token, Solana SPL, native MINA). A free read — no
|
|
@@ -12809,4 +12864,4 @@ export {
|
|
|
12809
12864
|
@scure/bip32/lib/esm/index.js:
|
|
12810
12865
|
(*! scure-bip32 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) *)
|
|
12811
12866
|
*/
|
|
12812
|
-
//# sourceMappingURL=chunk-
|
|
12867
|
+
//# sourceMappingURL=chunk-W6T6ZK7U.js.map
|