@toon-protocol/client-mcp 0.14.0 → 0.14.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-SL7UGVOC.js → chunk-N7MWQMBC.js} +2 -2
- package/dist/{chunk-UXCFHAUC.js → chunk-P7YF72JB.js} +190 -1
- package/dist/chunk-P7YF72JB.js.map +1 -0
- package/dist/{chunk-JCQENRQK.js → chunk-XAPHWDHP.js} +6 -6
- package/dist/{chunk-JCQENRQK.js.map → chunk-XAPHWDHP.js.map} +1 -1
- package/dist/daemon.js +2 -2
- package/dist/index.js +3 -3
- package/dist/mcp.js +2 -2
- package/package.json +4 -4
- package/dist/chunk-UXCFHAUC.js.map +0 -1
- /package/dist/{chunk-SL7UGVOC.js.map → chunk-N7MWQMBC.js.map} +0 -0
|
@@ -2,7 +2,7 @@ import { createRequire as __cr } from 'module'; const require = __cr(import.meta
|
|
|
2
2
|
import {
|
|
3
3
|
ControlApiError,
|
|
4
4
|
DaemonUnreachableError
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-P7YF72JB.js";
|
|
6
6
|
|
|
7
7
|
// ../views/dist/tool-names.js
|
|
8
8
|
var PUBLISH_TOOL = "toon_publish_unsigned";
|
|
@@ -1811,4 +1811,4 @@ export {
|
|
|
1811
1811
|
TOOL_DEFINITIONS,
|
|
1812
1812
|
dispatchTool
|
|
1813
1813
|
};
|
|
1814
|
-
//# sourceMappingURL=chunk-
|
|
1814
|
+
//# sourceMappingURL=chunk-N7MWQMBC.js.map
|
|
@@ -10333,6 +10333,38 @@ async function readEvmTokenBalance(opts) {
|
|
|
10333
10333
|
if (decimals !== void 0) out.assetScale = Number(decimals);
|
|
10334
10334
|
return out;
|
|
10335
10335
|
}
|
|
10336
|
+
async function readEvmNativeBalance(opts) {
|
|
10337
|
+
const chainId = parseEvmChainId(opts.chainKey);
|
|
10338
|
+
const client = createPublicClient2({
|
|
10339
|
+
transport: http2(opts.rpcUrl),
|
|
10340
|
+
chain: defineChain2({
|
|
10341
|
+
id: chainId,
|
|
10342
|
+
name: opts.chainKey,
|
|
10343
|
+
nativeCurrency: { name: "ETH", symbol: "ETH", decimals: 18 },
|
|
10344
|
+
rpcUrls: { default: { http: [opts.rpcUrl] } }
|
|
10345
|
+
})
|
|
10346
|
+
});
|
|
10347
|
+
const wei = await client.getBalance({ address: opts.owner });
|
|
10348
|
+
return { symbol: "ETH", amount: wei.toString(), decimals: 18 };
|
|
10349
|
+
}
|
|
10350
|
+
async function readSolanaNativeBalance(opts) {
|
|
10351
|
+
const fetchImpl = opts.fetchImpl ?? fetch;
|
|
10352
|
+
const res = await fetchImpl(opts.rpcUrl, {
|
|
10353
|
+
method: "POST",
|
|
10354
|
+
headers: { "content-type": "application/json" },
|
|
10355
|
+
body: JSON.stringify({
|
|
10356
|
+
jsonrpc: "2.0",
|
|
10357
|
+
id: 1,
|
|
10358
|
+
method: "getBalance",
|
|
10359
|
+
params: [opts.owner, { commitment: "confirmed" }]
|
|
10360
|
+
})
|
|
10361
|
+
});
|
|
10362
|
+
if (!res.ok) throw new Error(`Solana RPC request failed: HTTP ${res.status}`);
|
|
10363
|
+
const json = await res.json();
|
|
10364
|
+
if (json.error) throw new Error(`Solana RPC error: ${json.error.message ?? "unknown"}`);
|
|
10365
|
+
const lamports = BigInt(json.result?.value ?? 0);
|
|
10366
|
+
return { symbol: "SOL", amount: lamports.toString(), decimals: 9 };
|
|
10367
|
+
}
|
|
10336
10368
|
async function readSolanaTokenBalance(opts) {
|
|
10337
10369
|
const fetchImpl = opts.fetchImpl ?? fetch;
|
|
10338
10370
|
const res = await fetchImpl(opts.rpcUrl, {
|
|
@@ -10380,6 +10412,95 @@ async function readMinaBalance(opts) {
|
|
|
10380
10412
|
assetScale: 9
|
|
10381
10413
|
};
|
|
10382
10414
|
}
|
|
10415
|
+
var errText = (e) => e instanceof Error ? e.message : String(e);
|
|
10416
|
+
function foldNative(out, settled, errors) {
|
|
10417
|
+
if (settled.status === "fulfilled") out.native = settled.value;
|
|
10418
|
+
else errors.push(errText(settled.reason));
|
|
10419
|
+
}
|
|
10420
|
+
function foldToken(out, settled, tokenAddress, errors) {
|
|
10421
|
+
if (settled.status === "rejected") {
|
|
10422
|
+
errors.push(errText(settled.reason));
|
|
10423
|
+
return;
|
|
10424
|
+
}
|
|
10425
|
+
const bal = settled.value;
|
|
10426
|
+
if (!bal) return;
|
|
10427
|
+
out.tokens.push({
|
|
10428
|
+
symbol: bal.asset,
|
|
10429
|
+
amount: bal.amount,
|
|
10430
|
+
decimals: bal.assetScale,
|
|
10431
|
+
...tokenAddress ? { address: tokenAddress } : {}
|
|
10432
|
+
});
|
|
10433
|
+
}
|
|
10434
|
+
function finalizeChain(out, errors) {
|
|
10435
|
+
if (errors.length > 0) out.error = errors[0];
|
|
10436
|
+
if (out.native === void 0 && out.tokens.length === 0) out.unreadable = true;
|
|
10437
|
+
}
|
|
10438
|
+
async function readWalletBalances(sources) {
|
|
10439
|
+
const { fetchImpl } = sources;
|
|
10440
|
+
const tasks = [];
|
|
10441
|
+
if (sources.evm) {
|
|
10442
|
+
const { chainKey, rpcUrl, owner, tokenAddress } = sources.evm;
|
|
10443
|
+
tasks.push(
|
|
10444
|
+
(async () => {
|
|
10445
|
+
const out = { chain: "evm", chainKey, address: owner, tokens: [] };
|
|
10446
|
+
const errors = [];
|
|
10447
|
+
const [nativeR, tokenR] = await Promise.allSettled([
|
|
10448
|
+
readEvmNativeBalance({ rpcUrl, chainKey, owner }),
|
|
10449
|
+
tokenAddress ? readEvmTokenBalance({ rpcUrl, chainKey, tokenAddress, owner }) : Promise.resolve(void 0)
|
|
10450
|
+
]);
|
|
10451
|
+
foldNative(out, nativeR, errors);
|
|
10452
|
+
foldToken(out, tokenR, tokenAddress, errors);
|
|
10453
|
+
finalizeChain(out, errors);
|
|
10454
|
+
return out;
|
|
10455
|
+
})()
|
|
10456
|
+
);
|
|
10457
|
+
}
|
|
10458
|
+
if (sources.solana) {
|
|
10459
|
+
const { chainKey = "solana", rpcUrl, owner, tokenMint } = sources.solana;
|
|
10460
|
+
tasks.push(
|
|
10461
|
+
(async () => {
|
|
10462
|
+
const out = { chain: "solana", chainKey, address: owner, tokens: [] };
|
|
10463
|
+
const errors = [];
|
|
10464
|
+
const [nativeR, tokenR] = await Promise.allSettled([
|
|
10465
|
+
readSolanaNativeBalance({ rpcUrl, owner, fetchImpl }),
|
|
10466
|
+
tokenMint ? readSolanaTokenBalance({ rpcUrl, mint: tokenMint, owner, fetchImpl }) : Promise.resolve(void 0)
|
|
10467
|
+
]);
|
|
10468
|
+
foldNative(out, nativeR, errors);
|
|
10469
|
+
if (tokenR.status === "fulfilled" && tokenR.value && tokenR.value.asset === void 0) {
|
|
10470
|
+
tokenR.value.asset = "USDC";
|
|
10471
|
+
}
|
|
10472
|
+
foldToken(out, tokenR, tokenMint, errors);
|
|
10473
|
+
finalizeChain(out, errors);
|
|
10474
|
+
return out;
|
|
10475
|
+
})()
|
|
10476
|
+
);
|
|
10477
|
+
}
|
|
10478
|
+
if (sources.mina) {
|
|
10479
|
+
const { chainKey = "mina", graphqlUrl, owner } = sources.mina;
|
|
10480
|
+
tasks.push(
|
|
10481
|
+
(async () => {
|
|
10482
|
+
const out = { chain: "mina", chainKey, address: owner, tokens: [] };
|
|
10483
|
+
const errors = [];
|
|
10484
|
+
const nativeR = await Promise.allSettled([readMinaBalance({ graphqlUrl, owner, fetchImpl })]);
|
|
10485
|
+
foldNative(
|
|
10486
|
+
out,
|
|
10487
|
+
nativeR[0].status === "fulfilled" ? {
|
|
10488
|
+
status: "fulfilled",
|
|
10489
|
+
value: {
|
|
10490
|
+
symbol: nativeR[0].value.asset,
|
|
10491
|
+
amount: nativeR[0].value.amount,
|
|
10492
|
+
decimals: nativeR[0].value.assetScale
|
|
10493
|
+
}
|
|
10494
|
+
} : nativeR[0],
|
|
10495
|
+
errors
|
|
10496
|
+
);
|
|
10497
|
+
finalizeChain(out, errors);
|
|
10498
|
+
return out;
|
|
10499
|
+
})()
|
|
10500
|
+
);
|
|
10501
|
+
}
|
|
10502
|
+
return Promise.all(tasks);
|
|
10503
|
+
}
|
|
10383
10504
|
var ARWEAVE_TX_ID_REGEX = /^[A-Za-z0-9_-]{43}$/;
|
|
10384
10505
|
async function requestBlobStorage(client, secretKey, params) {
|
|
10385
10506
|
const bid = params.bid ?? (params.ilpAmount !== void 0 ? String(params.ilpAmount) : void 0);
|
|
@@ -11523,6 +11644,74 @@ var ToonClient = class {
|
|
|
11523
11644
|
}
|
|
11524
11645
|
return out;
|
|
11525
11646
|
}
|
|
11647
|
+
/**
|
|
11648
|
+
* The FULL multi-chain wallet view (#299): for every chain the identity is
|
|
11649
|
+
* configured for, the native coin (ETH / SOL / MINA) AND every configured
|
|
11650
|
+
* token (USDC), grouped per chain with the identity's address on that chain.
|
|
11651
|
+
* A superset of {@link getBalances} — which stays scoped to the channel's
|
|
11652
|
+
* settlement token — kept as a separate reader so channel-settlement callers
|
|
11653
|
+
* are unaffected.
|
|
11654
|
+
*
|
|
11655
|
+
* FREE: read-only RPC, no signing, no payment. Works on an UNSTARTED client:
|
|
11656
|
+
* the Solana/Mina addresses (which the signers only register during
|
|
11657
|
+
* `start()`) are derived on demand from the retained mnemonic — the SAME keys
|
|
11658
|
+
* `start()` would register and that `rig fund` prints — so all configured
|
|
11659
|
+
* chains appear even before a start. Best-effort per chain: an unreachable
|
|
11660
|
+
* RPC yields `{ unreadable: true }` for that chain, never failing the others.
|
|
11661
|
+
*/
|
|
11662
|
+
async getWalletBalances() {
|
|
11663
|
+
const sources = {};
|
|
11664
|
+
let derived;
|
|
11665
|
+
let derivedTried = false;
|
|
11666
|
+
const ensureDerived = async () => {
|
|
11667
|
+
if (derivedTried) return derived;
|
|
11668
|
+
derivedTried = true;
|
|
11669
|
+
if (this.config.mnemonic) {
|
|
11670
|
+
derived = await deriveFullIdentity(
|
|
11671
|
+
this.config.mnemonic,
|
|
11672
|
+
this.config.mnemonicAccountIndex ?? 0
|
|
11673
|
+
);
|
|
11674
|
+
}
|
|
11675
|
+
return derived;
|
|
11676
|
+
};
|
|
11677
|
+
const evmAddress = this.getEvmAddress();
|
|
11678
|
+
const rpcUrls = this.config.chainRpcUrls;
|
|
11679
|
+
const tokens = this.config.preferredTokens;
|
|
11680
|
+
if (evmAddress && rpcUrls) {
|
|
11681
|
+
const usableEvm = (c) => c.startsWith("evm") && Boolean(rpcUrls[c]);
|
|
11682
|
+
const settlementKeys = Object.keys(this.config.settlementAddresses ?? {});
|
|
11683
|
+
const chainKeys = this.config.supportedChains ?? Object.keys(rpcUrls);
|
|
11684
|
+
const chainKey = settlementKeys.find(usableEvm) ?? chainKeys.find(usableEvm);
|
|
11685
|
+
if (chainKey && rpcUrls[chainKey]) {
|
|
11686
|
+
sources.evm = {
|
|
11687
|
+
chainKey,
|
|
11688
|
+
rpcUrl: rpcUrls[chainKey],
|
|
11689
|
+
owner: evmAddress,
|
|
11690
|
+
...tokens?.[chainKey] ? { tokenAddress: tokens[chainKey] } : {}
|
|
11691
|
+
};
|
|
11692
|
+
}
|
|
11693
|
+
}
|
|
11694
|
+
const sol = this.config.solanaChannel;
|
|
11695
|
+
if (sol?.rpcUrl) {
|
|
11696
|
+
const solAddress = this.getSolanaAddress() ?? (await ensureDerived())?.solana.publicKey;
|
|
11697
|
+
if (solAddress) {
|
|
11698
|
+
sources.solana = {
|
|
11699
|
+
chainKey: "solana",
|
|
11700
|
+
rpcUrl: sol.rpcUrl,
|
|
11701
|
+
owner: solAddress,
|
|
11702
|
+
...sol.tokenMint ? { tokenMint: sol.tokenMint } : {}
|
|
11703
|
+
};
|
|
11704
|
+
}
|
|
11705
|
+
}
|
|
11706
|
+
const mina = this.config.minaChannel;
|
|
11707
|
+
if (mina?.graphqlUrl) {
|
|
11708
|
+
const minaAddress = this.getMinaAddress() ?? (await ensureDerived())?.mina.publicKey;
|
|
11709
|
+
if (minaAddress) {
|
|
11710
|
+
sources.mina = { chainKey: "mina", graphqlUrl: mina.graphqlUrl, owner: minaAddress };
|
|
11711
|
+
}
|
|
11712
|
+
}
|
|
11713
|
+
return readWalletBalances(sources);
|
|
11714
|
+
}
|
|
11526
11715
|
/**
|
|
11527
11716
|
* Resolves an ILP destination address to a peer ID.
|
|
11528
11717
|
* Convention: destination "g.toon.peer1" → peerId "peer1" (last segment).
|
|
@@ -12945,4 +13134,4 @@ export {
|
|
|
12945
13134
|
@scure/bip32/lib/esm/index.js:
|
|
12946
13135
|
(*! scure-bip32 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) *)
|
|
12947
13136
|
*/
|
|
12948
|
-
//# sourceMappingURL=chunk-
|
|
13137
|
+
//# sourceMappingURL=chunk-P7YF72JB.js.map
|