@continuumdao/ctm-mpc-defi 0.1.3 → 0.1.4
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/README.md +16 -1
- package/dist/agent/catalog.cjs +36 -2
- package/dist/agent/catalog.cjs.map +1 -1
- package/dist/agent/catalog.d.cts +79 -1
- package/dist/agent/catalog.d.ts +79 -1
- package/dist/agent/catalog.js +36 -3
- package/dist/agent/catalog.js.map +1 -1
- package/dist/core/index.cjs +76 -0
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +35 -2
- package/dist/core/index.d.ts +35 -2
- package/dist/core/index.js +70 -1
- package/dist/core/index.js.map +1 -1
- package/dist/index.cjs +111 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +105 -3
- package/dist/index.js.map +1 -1
- package/dist/protocols/evm/uniswap-v4/index.cjs +31 -11
- package/dist/protocols/evm/uniswap-v4/index.cjs.map +1 -1
- package/dist/protocols/evm/uniswap-v4/index.d.cts +2 -1
- package/dist/protocols/evm/uniswap-v4/index.d.ts +2 -1
- package/dist/protocols/evm/uniswap-v4/index.js +31 -11
- package/dist/protocols/evm/uniswap-v4/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { C as ChainCategory, a as ChainSupportContext, E as EvmTokenKind, K as KeyGenSubset, M as MultisignBuildResult, b as MultisignCommonArgs, N as NearTokenKind, P as ParamDoc, c as ProtocolActionDescriptor, d as ProtocolModule, S as SolanaTokenKind, T as TokenRef } from './types-Ce2qNHai.cjs';
|
|
2
2
|
export { K as KeyGenSubsetForPermit, f as firstClientIdFromKeyGen, k as keyListFromKeyGen, r as requirePubKeyHex } from './keygen-CfNp8yKJ.cjs';
|
|
3
|
-
export { mergePurposeText } from './core/index.cjs';
|
|
3
|
+
export { ManagementSigFields, buildManagementPostBody, fetchManagementNonce, fetchNodeKey, managementSigFields, mergePurposeText, messageToSignManagementBody, normalizeManagementNodeKey, withManagementClientSig } from './core/index.cjs';
|
|
4
4
|
export { C as ChainCategoryBuildInput, a as ChainCategoryModule, M as MultisignLeg, c as coreChainCategoryModule, f as finalizeMultisign } from './envelope-DYDPnrHZ.cjs';
|
|
5
5
|
export { g as getActionsByChainCategory, a as getProtocolModule, b as getProtocolModules, r as registerProtocolModule } from './registry-BwZoE668.cjs';
|
|
6
6
|
export { N as NodeReadAuth, n as nodeFetchWithReadAuth } from './nodeRead-BnmSaMGO.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { C as ChainCategory, a as ChainSupportContext, E as EvmTokenKind, K as KeyGenSubset, M as MultisignBuildResult, b as MultisignCommonArgs, N as NearTokenKind, P as ParamDoc, c as ProtocolActionDescriptor, d as ProtocolModule, S as SolanaTokenKind, T as TokenRef } from './types-Ce2qNHai.js';
|
|
2
2
|
export { K as KeyGenSubsetForPermit, f as firstClientIdFromKeyGen, k as keyListFromKeyGen, r as requirePubKeyHex } from './keygen-DsINazx8.js';
|
|
3
|
-
export { mergePurposeText } from './core/index.js';
|
|
3
|
+
export { ManagementSigFields, buildManagementPostBody, fetchManagementNonce, fetchNodeKey, managementSigFields, mergePurposeText, messageToSignManagementBody, normalizeManagementNodeKey, withManagementClientSig } from './core/index.js';
|
|
4
4
|
export { C as ChainCategoryBuildInput, a as ChainCategoryModule, M as MultisignLeg, c as coreChainCategoryModule, f as finalizeMultisign } from './envelope-CcE5Cz_q.js';
|
|
5
5
|
export { g as getActionsByChainCategory, a as getProtocolModule, b as getProtocolModules, r as registerProtocolModule } from './registry-oMKlO_5z.js';
|
|
6
6
|
export { N as NodeReadAuth, n as nodeFetchWithReadAuth } from './nodeRead-BnmSaMGO.js';
|
package/dist/index.js
CHANGED
|
@@ -112,6 +112,75 @@ function nodeFetchWithReadAuth(url, init, auth) {
|
|
|
112
112
|
}
|
|
113
113
|
return fetch(url, { ...init, headers });
|
|
114
114
|
}
|
|
115
|
+
|
|
116
|
+
// src/core/managementPostSig.ts
|
|
117
|
+
function normalizeManagementNodeKey(nodeKey) {
|
|
118
|
+
const nk = nodeKey?.trim().replace(/^0x/i, "");
|
|
119
|
+
if (!nk || !/^[0-9a-fA-F]{128}$/.test(nk)) {
|
|
120
|
+
throw new Error("nodeKey is required (128 hex from GET /getNodeKey).");
|
|
121
|
+
}
|
|
122
|
+
return nk.toLowerCase();
|
|
123
|
+
}
|
|
124
|
+
function managementSigFields(nonce, nodeKey) {
|
|
125
|
+
return { nonce, clientSig: "", nodeKey: normalizeManagementNodeKey(nodeKey) };
|
|
126
|
+
}
|
|
127
|
+
function buildManagementPostBody(nonce, nodeKey, fields = {}) {
|
|
128
|
+
return { ...managementSigFields(nonce, nodeKey), ...fields };
|
|
129
|
+
}
|
|
130
|
+
function messageToSignManagementBody(body) {
|
|
131
|
+
return JSON.stringify({ ...body, clientSig: "" });
|
|
132
|
+
}
|
|
133
|
+
function withManagementClientSig(body, clientSig) {
|
|
134
|
+
return { ...body, clientSig: clientSig.trim().replace(/^0x/i, "") };
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// src/core/managementNonce.ts
|
|
138
|
+
function mpcAuthData(raw) {
|
|
139
|
+
const code = raw.Code ?? raw.code;
|
|
140
|
+
if (code !== 0 && code !== void 0) return void 0;
|
|
141
|
+
return raw.Data ?? raw.data;
|
|
142
|
+
}
|
|
143
|
+
async function fetchNodeKey(nodeUrl, readAuth = { bearerOnGet: false, jwt: null }) {
|
|
144
|
+
const base = nodeUrl.trim().replace(/\/$/, "");
|
|
145
|
+
const res = await nodeFetchWithReadAuth(`${base}/getNodeKey`, { cache: "no-store" }, readAuth);
|
|
146
|
+
const text = await res.text();
|
|
147
|
+
let raw;
|
|
148
|
+
try {
|
|
149
|
+
raw = JSON.parse(text);
|
|
150
|
+
} catch {
|
|
151
|
+
return { nodeKey: "", ok: false };
|
|
152
|
+
}
|
|
153
|
+
const data = mpcAuthData(raw);
|
|
154
|
+
const nk = typeof data === "string" ? data : data != null && typeof data === "object" && !Array.isArray(data) ? String(data.nodeKey ?? data.NodeKey ?? "") : data != null ? String(data) : "";
|
|
155
|
+
const trimmed = nk.trim().replace(/^0x/i, "");
|
|
156
|
+
if (!/^[0-9a-fA-F]{128}$/.test(trimmed)) {
|
|
157
|
+
return { nodeKey: "", ok: false };
|
|
158
|
+
}
|
|
159
|
+
return { nodeKey: trimmed.toLowerCase(), ok: res.ok };
|
|
160
|
+
}
|
|
161
|
+
async function fetchManagementNonce(nodeUrl, useEd25519, ed25519PublicKey, readAuth = { bearerOnGet: false, jwt: null }) {
|
|
162
|
+
const base = nodeUrl.trim().replace(/\/$/, "");
|
|
163
|
+
const path = useEd25519 ? "/getPublicMgtKeyNonce" : "/getNodeMgtKeyNonce";
|
|
164
|
+
const url = useEd25519 && ed25519PublicKey && /^[0-9a-fA-F]{64}$/.test(ed25519PublicKey.trim()) ? `${base}${path}?publicKey=${encodeURIComponent(ed25519PublicKey.trim())}` : `${base}${path}`;
|
|
165
|
+
const res = await nodeFetchWithReadAuth(url, { cache: "no-store" }, readAuth);
|
|
166
|
+
const text = await res.text();
|
|
167
|
+
let raw;
|
|
168
|
+
try {
|
|
169
|
+
raw = JSON.parse(text);
|
|
170
|
+
} catch {
|
|
171
|
+
return { nonce: 0, ok: false, code: -1 };
|
|
172
|
+
}
|
|
173
|
+
const code = raw.Code ?? raw.code;
|
|
174
|
+
const payload = mpcAuthData(raw) ?? raw.Data ?? raw.data;
|
|
175
|
+
let nonce = 0;
|
|
176
|
+
if (typeof payload === "number" && !Number.isNaN(payload)) {
|
|
177
|
+
nonce = payload;
|
|
178
|
+
} else if (payload && typeof payload === "object") {
|
|
179
|
+
const n = payload.nonce ?? payload.Nonce;
|
|
180
|
+
nonce = typeof n === "number" && !Number.isNaN(n) ? n : Number(n) || 0;
|
|
181
|
+
}
|
|
182
|
+
return { nonce, ok: res.ok && (code === 0 || code === void 0), code: code ?? -1 };
|
|
183
|
+
}
|
|
115
184
|
function isEvmNativeToken(address) {
|
|
116
185
|
try {
|
|
117
186
|
return getAddress(address) === zeroAddress;
|
|
@@ -2219,6 +2288,31 @@ var MULTISIGN_OUTPUT_DOC = {
|
|
|
2219
2288
|
}
|
|
2220
2289
|
}
|
|
2221
2290
|
};
|
|
2291
|
+
var MANAGEMENT_SIG_DOC = {
|
|
2292
|
+
description: "Management POST bodies embed NodeMgtKeySig: { nonce, clientSig, nodeKey }. Sign JSON with clientSig cleared; POST with clientSig set to the Ed25519 128-hex or EIP-191 signature. Legacy Nonce/Sig/sig field names are not accepted.",
|
|
2293
|
+
fields: {
|
|
2294
|
+
nonce: {
|
|
2295
|
+
type: "number",
|
|
2296
|
+
description: "From GET /getPublicMgtKeyNonce (Ed25519) or GET /getNodeMgtKeyNonce (Ethereum NodeMgtKey)."
|
|
2297
|
+
},
|
|
2298
|
+
clientSig: {
|
|
2299
|
+
type: "string",
|
|
2300
|
+
description: "Management signature; empty string in the message to sign."
|
|
2301
|
+
},
|
|
2302
|
+
nodeKey: {
|
|
2303
|
+
type: "string",
|
|
2304
|
+
description: "Required. 128-hex MPC node id from GET /getNodeKey (no 0x prefix)."
|
|
2305
|
+
}
|
|
2306
|
+
},
|
|
2307
|
+
helpers: {
|
|
2308
|
+
managementSigFields: "Base envelope with clientSig cleared.",
|
|
2309
|
+
buildManagementPostBody: "Spread managementSigFields then endpoint fields.",
|
|
2310
|
+
messageToSignManagementBody: "Canonical JSON string to sign.",
|
|
2311
|
+
withManagementClientSig: "Attach signature to POST body.",
|
|
2312
|
+
fetchNodeKey: "GET /getNodeKey via nodeFetchWithReadAuth.",
|
|
2313
|
+
fetchManagementNonce: "GET nonce for Ed25519 or Ethereum management key."
|
|
2314
|
+
}
|
|
2315
|
+
};
|
|
2222
2316
|
|
|
2223
2317
|
// src/agent/mcpTools.ts
|
|
2224
2318
|
function paramProperties(params, includeCommon = []) {
|
|
@@ -2340,7 +2434,7 @@ var MCP_TOOL_DEFINITIONS = [
|
|
|
2340
2434
|
"executorAddress matching MPC wallet",
|
|
2341
2435
|
"RPC URL and chainDetail from node chain config"
|
|
2342
2436
|
],
|
|
2343
|
-
followUp: ["Sign messageToSign", "POST /multiSignRequest with clientSig"],
|
|
2437
|
+
followUp: ["Sign messageToSign", "POST /multiSignRequest with clientSig and signedMessage"],
|
|
2344
2438
|
handler: { importPath: "protocols/evm/uniswap-v4", exportName: "buildEvmMultisignBodyUniswapV4SkipPermit2Batch" },
|
|
2345
2439
|
inputSchema: {
|
|
2346
2440
|
type: "object",
|
|
@@ -2375,7 +2469,7 @@ var MCP_TOOL_DEFINITIONS = [
|
|
|
2375
2469
|
chainCategory: "evm",
|
|
2376
2470
|
description: "Build mpc-auth multiSignRequest for a Curve Router NG swap via @curvefi/api populateSwap. Optionally batches ERC-20 approve txs when allowance is insufficient, then exchange. Requires JSON-RPC and Curve-supported chain.",
|
|
2377
2471
|
prerequisites: ["keyGen", "executorAddress", "tokenIn/tokenOut/amountHuman/slippage", "RPC URL"],
|
|
2378
|
-
followUp: ["Sign messageToSign", "POST /multiSignRequest"],
|
|
2472
|
+
followUp: ["Sign messageToSign", "POST /multiSignRequest with clientSig and signedMessage"],
|
|
2379
2473
|
handler: { importPath: "protocols/evm/curve-dao", exportName: "buildEvmMultisignBodyCurveDaoBatch" },
|
|
2380
2474
|
inputSchema: {
|
|
2381
2475
|
type: "object",
|
|
@@ -2407,6 +2501,7 @@ function getAgentCatalogForMcp() {
|
|
|
2407
2501
|
protocols: getProtocolModules(),
|
|
2408
2502
|
commonParams: EVM_COMMON_PARAM_DOCS,
|
|
2409
2503
|
multisignOutput: MULTISIGN_OUTPUT_DOC,
|
|
2504
|
+
managementSig: MANAGEMENT_SIG_DOC,
|
|
2410
2505
|
workflow: {
|
|
2411
2506
|
evmSwapTypical: [
|
|
2412
2507
|
"1. Quote (protocol-specific API if needed)",
|
|
@@ -2414,6 +2509,13 @@ function getAgentCatalogForMcp() {
|
|
|
2414
2509
|
"3. build_*_multisign \u2192 { bodyForSign, messageToSign }",
|
|
2415
2510
|
"4. Sign messageToSign (MetaMask or Ed25519)",
|
|
2416
2511
|
"5. POST /multiSignRequest with clientSig and signedMessage"
|
|
2512
|
+
],
|
|
2513
|
+
managementPostTypical: [
|
|
2514
|
+
"1. GET /getNodeKey \u2192 nodeKey (128 hex)",
|
|
2515
|
+
"2. GET /getPublicMgtKeyNonce or /getNodeMgtKeyNonce \u2192 nonce",
|
|
2516
|
+
"3. buildManagementPostBody(nonce, nodeKey, { \u2026endpoint fields })",
|
|
2517
|
+
"4. messageToSignManagementBody(body) \u2192 sign \u2192 withManagementClientSig(body, sig)",
|
|
2518
|
+
"5. POST management route with signed body"
|
|
2417
2519
|
]
|
|
2418
2520
|
}
|
|
2419
2521
|
};
|
|
@@ -2441,6 +2543,6 @@ function getAgentCatalog() {
|
|
|
2441
2543
|
registerProtocolModule(uniswapV4ProtocolModule);
|
|
2442
2544
|
registerProtocolModule(curveDaoProtocolModule);
|
|
2443
2545
|
|
|
2444
|
-
export { NEAR_CHAIN_CATEGORY, SOLANA_CHAIN_CATEGORY, alignEip1559FeesWithLatestBase, buildEvmMultisignBatch, chainSnapshotForCustomGasExtraJSON, composeFeePayloadToTxParams, coreChainCategoryModule, curveDao, curveDaoProtocolModule, evmChainCategoryModule, fetchChainFeeParams, finalizeMultisign, firstClientIdFromKeyGen, gasLimitFromEstimateAndChainConfig, getActionsByChainCategory, getAgentCatalog, getProtocolModule, getProtocolModules, gweiToDecimalString, isEvmNativeToken, keyListFromKeyGen, matchEvmTokenKind, mergePurposeText, nearChainCategoryModule, nodeFetchWithReadAuth, parseEvmChainIdToNumber, proposalTxParamsToFeeSnapshot, registerProtocolModule, requirePubKeyHex, routerSwapGasLimitFromEstimate, solanaChainCategoryModule, triggerTxParamsFromComposeBody, uniswapV4, uniswapV4ProtocolModule };
|
|
2546
|
+
export { NEAR_CHAIN_CATEGORY, SOLANA_CHAIN_CATEGORY, alignEip1559FeesWithLatestBase, buildEvmMultisignBatch, buildManagementPostBody, chainSnapshotForCustomGasExtraJSON, composeFeePayloadToTxParams, coreChainCategoryModule, curveDao, curveDaoProtocolModule, evmChainCategoryModule, fetchChainFeeParams, fetchManagementNonce, fetchNodeKey, finalizeMultisign, firstClientIdFromKeyGen, gasLimitFromEstimateAndChainConfig, getActionsByChainCategory, getAgentCatalog, getProtocolModule, getProtocolModules, gweiToDecimalString, isEvmNativeToken, keyListFromKeyGen, managementSigFields, matchEvmTokenKind, mergePurposeText, messageToSignManagementBody, nearChainCategoryModule, nodeFetchWithReadAuth, normalizeManagementNodeKey, parseEvmChainIdToNumber, proposalTxParamsToFeeSnapshot, registerProtocolModule, requirePubKeyHex, routerSwapGasLimitFromEstimate, solanaChainCategoryModule, triggerTxParamsFromComposeBody, uniswapV4, uniswapV4ProtocolModule, withManagementClientSig };
|
|
2445
2547
|
//# sourceMappingURL=index.js.map
|
|
2446
2548
|
//# sourceMappingURL=index.js.map
|