@continuumdao/ctm-mpc-defi 0.2.0 → 0.2.2

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.
Files changed (100) hide show
  1. package/README.md +20 -78
  2. package/dist/agent/catalog.cjs +563 -5
  3. package/dist/agent/catalog.cjs.map +1 -1
  4. package/dist/agent/catalog.d.ts +166 -20
  5. package/dist/agent/catalog.js +551 -7
  6. package/dist/agent/catalog.js.map +1 -1
  7. package/dist/agent/skills/aave-v4/SKILL.md +43 -0
  8. package/dist/agent/skills/curve-dao/SKILL.md +13 -0
  9. package/dist/agent/skills/ethena/SKILL.md +10 -0
  10. package/dist/agent/skills/euler-v2/SKILL.md +10 -0
  11. package/dist/agent/skills/lido/SKILL.md +22 -0
  12. package/dist/agent/skills/maple-syrup/SKILL.md +10 -0
  13. package/dist/agent/skills/sky/SKILL.md +10 -0
  14. package/dist/agent/skills/uniswap-v4/SKILL.md +22 -0
  15. package/dist/chains/evm/index.cjs +79 -224
  16. package/dist/chains/evm/index.cjs.map +1 -1
  17. package/dist/chains/evm/index.d.ts +26 -26
  18. package/dist/chains/evm/index.js +69 -209
  19. package/dist/chains/evm/index.js.map +1 -1
  20. package/dist/chains/near/index.d.ts +1 -1
  21. package/dist/chains/solana/index.d.ts +1 -1
  22. package/dist/core/index.cjs +68 -106
  23. package/dist/core/index.cjs.map +1 -1
  24. package/dist/core/index.d.ts +21 -36
  25. package/dist/core/index.js +57 -96
  26. package/dist/core/index.js.map +1 -1
  27. package/dist/{envelope-CcE5Cz_q.d.ts → envelope-CpBUh9eP.d.ts} +1 -1
  28. package/dist/index.cjs +356 -1855
  29. package/dist/index.cjs.map +1 -1
  30. package/dist/index.d.ts +7 -11
  31. package/dist/index.js +332 -1826
  32. package/dist/index.js.map +1 -1
  33. package/dist/protocols/evm/aave-v4/index.cjs +1152 -669
  34. package/dist/protocols/evm/aave-v4/index.cjs.map +1 -1
  35. package/dist/protocols/evm/aave-v4/index.d.ts +418 -3
  36. package/dist/protocols/evm/aave-v4/index.js +1126 -670
  37. package/dist/protocols/evm/aave-v4/index.js.map +1 -1
  38. package/dist/protocols/evm/curve-dao/index.cjs +257 -131
  39. package/dist/protocols/evm/curve-dao/index.cjs.map +1 -1
  40. package/dist/protocols/evm/curve-dao/index.d.ts +69 -5
  41. package/dist/protocols/evm/curve-dao/index.js +242 -124
  42. package/dist/protocols/evm/curve-dao/index.js.map +1 -1
  43. package/dist/protocols/evm/ethena/index.cjs +394 -402
  44. package/dist/protocols/evm/ethena/index.cjs.map +1 -1
  45. package/dist/protocols/evm/ethena/index.d.ts +47 -3
  46. package/dist/protocols/evm/ethena/index.js +390 -404
  47. package/dist/protocols/evm/ethena/index.js.map +1 -1
  48. package/dist/protocols/evm/euler-v2/index.cjs +2810 -1191
  49. package/dist/protocols/evm/euler-v2/index.cjs.map +1 -1
  50. package/dist/protocols/evm/euler-v2/index.d.ts +465 -3
  51. package/dist/protocols/evm/euler-v2/index.js +2761 -1192
  52. package/dist/protocols/evm/euler-v2/index.js.map +1 -1
  53. package/dist/protocols/evm/lido/index.cjs +351 -236
  54. package/dist/protocols/evm/lido/index.cjs.map +1 -1
  55. package/dist/protocols/evm/lido/index.d.ts +34 -4
  56. package/dist/protocols/evm/lido/index.js +348 -238
  57. package/dist/protocols/evm/lido/index.js.map +1 -1
  58. package/dist/protocols/evm/maple/index.cjs +390 -395
  59. package/dist/protocols/evm/maple/index.cjs.map +1 -1
  60. package/dist/protocols/evm/maple/index.d.ts +23 -3
  61. package/dist/protocols/evm/maple/index.js +390 -397
  62. package/dist/protocols/evm/maple/index.js.map +1 -1
  63. package/dist/protocols/evm/sky/index.cjs +454 -232
  64. package/dist/protocols/evm/sky/index.cjs.map +1 -1
  65. package/dist/protocols/evm/sky/index.d.ts +57 -3
  66. package/dist/protocols/evm/sky/index.js +444 -231
  67. package/dist/protocols/evm/sky/index.js.map +1 -1
  68. package/dist/protocols/evm/uniswap-v4/index.cjs +423 -658
  69. package/dist/protocols/evm/uniswap-v4/index.cjs.map +1 -1
  70. package/dist/protocols/evm/uniswap-v4/index.d.ts +3 -4
  71. package/dist/protocols/evm/uniswap-v4/index.js +422 -657
  72. package/dist/protocols/evm/uniswap-v4/index.js.map +1 -1
  73. package/dist/{registry-oMKlO_5z.d.ts → registry-Bv5o37_w.d.ts} +1 -1
  74. package/dist/{types-Ce2qNHai.d.cts → types-BfjWdw1j.d.ts} +3 -1
  75. package/dist/{types-5u863Fd9.d.ts → types-DUeNJLr9.d.ts} +1 -1
  76. package/package.json +7 -6
  77. package/dist/agent/catalog.d.cts +0 -939
  78. package/dist/chains/evm/index.d.cts +0 -64
  79. package/dist/chains/near/index.d.cts +0 -37
  80. package/dist/chains/solana/index.d.cts +0 -40
  81. package/dist/core/index.d.cts +0 -43
  82. package/dist/envelope-DYDPnrHZ.d.cts +0 -35
  83. package/dist/index.d.cts +0 -16
  84. package/dist/keygen-CfNp8yKJ.d.cts +0 -9
  85. package/dist/keygen-DsINazx8.d.ts +0 -9
  86. package/dist/nodeRead-BnmSaMGO.d.cts +0 -8
  87. package/dist/nodeRead-BnmSaMGO.d.ts +0 -8
  88. package/dist/protocols/evm/aave-v4/index.d.cts +0 -500
  89. package/dist/protocols/evm/curve-dao/index.d.cts +0 -147
  90. package/dist/protocols/evm/ethena/index.d.cts +0 -161
  91. package/dist/protocols/evm/euler-v2/index.d.cts +0 -317
  92. package/dist/protocols/evm/lido/index.d.cts +0 -120
  93. package/dist/protocols/evm/maple/index.d.cts +0 -109
  94. package/dist/protocols/evm/sky/index.d.cts +0 -218
  95. package/dist/protocols/evm/uniswap-v4/index.d.cts +0 -324
  96. package/dist/registry-BwZoE668.d.cts +0 -8
  97. package/dist/txParams-BC7ogvdR.d.cts +0 -19
  98. package/dist/txParams-BC7ogvdR.d.ts +0 -19
  99. package/dist/types-B8idm_gu.d.cts +0 -34
  100. package/dist/types-Ce2qNHai.d.ts +0 -57
@@ -1,20 +1,7 @@
1
- // src/core/keygen.ts
2
- function firstClientIdFromKeyGen(data) {
3
- const map = data?.ClientKeys;
4
- if (!map || typeof map !== "object") return null;
5
- for (const v of Object.values(map)) {
6
- if (typeof v === "string" && v.trim()) return v.trim();
7
- }
8
- return null;
9
- }
10
- function requirePubKeyHex(keyGen) {
11
- const ph = (keyGen.pubkeyhex ?? "").trim();
12
- if (!ph) throw new Error("keyGen pubKey (pubkeyhex) is required");
13
- return ph;
14
- }
15
- function keyListFromKeyGen(keyGen) {
16
- return keyGen.keylist ?? [];
17
- }
1
+ import { getClientIdFromKeyGenResult } from '@continuumdao/continuum-node-sdk';
2
+ export { getClientIdFromKeyGenResult as firstClientIdFromKeyGen } from '@continuumdao/continuum-node-sdk';
3
+
4
+ // src/core/index.ts
18
5
 
19
6
  // src/core/purpose.ts
20
7
  function mergePurposeText(purposeText, purposeSuffix) {
@@ -25,8 +12,6 @@ function mergePurposeText(purposeText, purposeSuffix) {
25
12
 
26
13
  ${suffix}` : suffix;
27
14
  }
28
-
29
- // src/core/envelope.ts
30
15
  function finalizeMultisign(input) {
31
16
  const { keyGen, destinationChainID, legs } = input;
32
17
  if (legs.length === 0) {
@@ -35,7 +20,7 @@ function finalizeMultisign(input) {
35
20
  const ph = (keyGen.pubkeyhex ?? "").trim();
36
21
  if (!ph) throw new Error("keyGen pubKey (pubkeyhex) is required");
37
22
  const keyList = keyGen.keylist ?? [];
38
- const clientId = firstClientIdFromKeyGen(keyGen);
23
+ const clientId = getClientIdFromKeyGenResult(keyGen);
39
24
  const first = legs[0];
40
25
  const messageHashes = legs.map((l) => l.msgHash);
41
26
  const messageRawBatch = legs.map((l) => l.msgRaw);
@@ -101,85 +86,61 @@ function getActionsByChainCategory(category) {
101
86
  return modules.filter((m) => m.chainCategory === category).flatMap((m) => m.actions);
102
87
  }
103
88
 
104
- // src/core/nodeRead.ts
105
- function nodeFetchWithReadAuth(url, init, auth) {
106
- const method = (init?.method ?? "GET").toUpperCase();
107
- const headers = new Headers(init?.headers);
108
- if (auth.bearerOnGet && method === "GET" && auth.jwt && auth.jwt.trim()) {
109
- headers.set("Authorization", `Bearer ${auth.jwt.trim()}`);
110
- }
111
- return fetch(url, { ...init, headers });
112
- }
113
-
114
- // src/core/managementPostSig.ts
115
- function normalizeManagementNodeKey(nodeKey) {
116
- const nk = nodeKey?.trim().replace(/^0x/i, "");
117
- if (!nk || !/^[0-9a-fA-F]{128}$/.test(nk)) {
118
- throw new Error("nodeKey is required (128 hex from GET /getNodeKey).");
119
- }
120
- return nk.toLowerCase();
121
- }
122
- function managementSigFields(nonce, nodeKey) {
123
- return { nonce, clientSig: "", nodeKey: normalizeManagementNodeKey(nodeKey) };
124
- }
125
- function buildManagementPostBody(nonce, nodeKey, fields = {}) {
126
- return { ...managementSigFields(nonce, nodeKey), ...fields };
127
- }
128
- function messageToSignManagementBody(body) {
129
- return JSON.stringify({ ...body, clientSig: "" });
130
- }
131
- function withManagementClientSig(body, clientSig) {
132
- return { ...body, clientSig: clientSig.trim().replace(/^0x/i, "") };
133
- }
134
-
135
- // src/core/managementNonce.ts
136
- function mpcAuthData(raw) {
137
- const code = raw.Code ?? raw.code;
138
- if (code !== 0 && code !== void 0) return void 0;
139
- return raw.Data ?? raw.data;
140
- }
141
- async function fetchNodeKey(nodeUrl, readAuth = { bearerOnGet: false, jwt: null }) {
142
- const base = nodeUrl.trim().replace(/\/$/, "");
143
- const res = await nodeFetchWithReadAuth(`${base}/getNodeKey`, { cache: "no-store" }, readAuth);
144
- const text = await res.text();
145
- let raw;
146
- try {
147
- raw = JSON.parse(text);
148
- } catch {
149
- return { nodeKey: "", ok: false };
150
- }
151
- const data = mpcAuthData(raw);
152
- const nk = typeof data === "string" ? data : data != null && typeof data === "object" && !Array.isArray(data) ? String(data.nodeKey ?? data.NodeKey ?? "") : data != null ? String(data) : "";
153
- const trimmed = nk.trim().replace(/^0x/i, "");
154
- if (!/^[0-9a-fA-F]{128}$/.test(trimmed)) {
155
- return { nodeKey: "", ok: false };
156
- }
157
- return { nodeKey: trimmed.toLowerCase(), ok: res.ok };
158
- }
159
- async function fetchManagementNonce(nodeUrl, useEd25519, ed25519PublicKey, readAuth = { bearerOnGet: false, jwt: null }) {
160
- const base = nodeUrl.trim().replace(/\/$/, "");
161
- const path = useEd25519 ? "/getPublicMgtKeyNonce" : "/getNodeMgtKeyNonce";
162
- const url = useEd25519 && ed25519PublicKey && /^[0-9a-fA-F]{64}$/.test(ed25519PublicKey.trim()) ? `${base}${path}?publicKey=${encodeURIComponent(ed25519PublicKey.trim())}` : `${base}${path}`;
163
- const res = await nodeFetchWithReadAuth(url, { cache: "no-store" }, readAuth);
164
- const text = await res.text();
165
- let raw;
166
- try {
167
- raw = JSON.parse(text);
168
- } catch {
169
- return { nonce: 0, ok: false, code: -1 };
89
+ // src/core/defiProxy.ts
90
+ var aaveGraphqlProxyUrl;
91
+ var eulerGraphqlProxyUrl;
92
+ var mapleGraphqlProxyUrl;
93
+ var coingeckoProxyUrl;
94
+ function setAaveGraphqlProxyUrl(url) {
95
+ aaveGraphqlProxyUrl = url?.trim() || void 0;
96
+ }
97
+ function getAaveGraphqlProxyUrl() {
98
+ return aaveGraphqlProxyUrl;
99
+ }
100
+ function setEulerGraphqlProxyUrl(url) {
101
+ eulerGraphqlProxyUrl = url?.trim() || void 0;
102
+ }
103
+ function getEulerGraphqlProxyUrl() {
104
+ return eulerGraphqlProxyUrl;
105
+ }
106
+ function setMapleGraphqlProxyUrl(url) {
107
+ mapleGraphqlProxyUrl = url?.trim() || void 0;
108
+ }
109
+ function getMapleGraphqlProxyUrl() {
110
+ return mapleGraphqlProxyUrl;
111
+ }
112
+ function setCoingeckoProxyUrl(url) {
113
+ coingeckoProxyUrl = url?.trim() || void 0;
114
+ }
115
+ function getCoingeckoProxyUrl() {
116
+ return coingeckoProxyUrl;
117
+ }
118
+ async function postJsonViaOptionalProxy(args) {
119
+ const proxy = args.proxyUrl?.trim();
120
+ if (proxy) {
121
+ const r2 = await fetch(proxy, {
122
+ method: "POST",
123
+ headers: { "content-type": "application/json" },
124
+ body: JSON.stringify(args.proxyEnvelope ?? args.body)
125
+ });
126
+ if (!r2.ok) {
127
+ const t = await r2.text().catch(() => "");
128
+ throw new Error(t ? `Proxy HTTP ${r2.status}: ${t.slice(0, 200)}` : `Proxy HTTP ${r2.status}`);
129
+ }
130
+ return await r2.json();
170
131
  }
171
- const code = raw.Code ?? raw.code;
172
- const payload = mpcAuthData(raw) ?? raw.Data ?? raw.data;
173
- let nonce = 0;
174
- if (typeof payload === "number" && !Number.isNaN(payload)) {
175
- nonce = payload;
176
- } else if (payload && typeof payload === "object") {
177
- const n = payload.nonce ?? payload.Nonce;
178
- nonce = typeof n === "number" && !Number.isNaN(n) ? n : Number(n) || 0;
132
+ const r = await fetch(args.directUrl, {
133
+ method: "POST",
134
+ headers: { "content-type": "application/json" },
135
+ body: JSON.stringify(args.body)
136
+ });
137
+ if (!r.ok) {
138
+ const t = await r.text().catch(() => "");
139
+ throw new Error(t ? `HTTP ${r.status}: ${t.slice(0, 200)}` : `HTTP ${r.status}`);
179
140
  }
180
- return { nonce, ok: res.ok && (code === 0 || code === void 0), code: code ?? -1 };
141
+ return await r.json();
181
142
  }
182
143
 
183
- export { buildManagementPostBody, coreChainCategoryModule, fetchManagementNonce, fetchNodeKey, finalizeMultisign, firstClientIdFromKeyGen, getActionsByChainCategory, getProtocolModule, getProtocolModules, keyListFromKeyGen, managementSigFields, mergePurposeText, messageToSignManagementBody, nodeFetchWithReadAuth, normalizeManagementNodeKey, registerProtocolModule, requirePubKeyHex, withManagementClientSig };
144
+ export { coreChainCategoryModule, finalizeMultisign, getAaveGraphqlProxyUrl, getActionsByChainCategory, getCoingeckoProxyUrl, getEulerGraphqlProxyUrl, getMapleGraphqlProxyUrl, getProtocolModule, getProtocolModules, mergePurposeText, postJsonViaOptionalProxy, registerProtocolModule, setAaveGraphqlProxyUrl, setCoingeckoProxyUrl, setEulerGraphqlProxyUrl, setMapleGraphqlProxyUrl };
184
145
  //# sourceMappingURL=index.js.map
185
146
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/core/keygen.ts","../../src/core/purpose.ts","../../src/core/envelope.ts","../../src/core/registry.ts","../../src/core/nodeRead.ts","../../src/core/managementPostSig.ts","../../src/core/managementNonce.ts"],"names":[],"mappings":";AAOO,SAAS,wBAAwB,IAAA,EAAsD;AAC5F,EAAA,MAAM,MAAM,IAAA,EAAM,UAAA;AAClB,EAAA,IAAI,CAAC,GAAA,IAAO,OAAO,GAAA,KAAQ,UAAU,OAAO,IAAA;AAC5C,EAAA,KAAA,MAAW,CAAA,IAAK,MAAA,CAAO,MAAA,CAAO,GAAG,CAAA,EAAG;AAClC,IAAA,IAAI,OAAO,MAAM,QAAA,IAAY,CAAA,CAAE,MAAK,EAAG,OAAO,EAAE,IAAA,EAAK;AAAA,EACvD;AACA,EAAA,OAAO,IAAA;AACT;AAEO,SAAS,iBAAiB,MAAA,EAA8B;AAC7D,EAAA,MAAM,EAAA,GAAA,CAAM,MAAA,CAAO,SAAA,IAAa,EAAA,EAAI,IAAA,EAAK;AACzC,EAAA,IAAI,CAAC,EAAA,EAAI,MAAM,IAAI,MAAM,uCAAuC,CAAA;AAChE,EAAA,OAAO,EAAA;AACT;AAEO,SAAS,kBAAkB,MAAA,EAAgC;AAChE,EAAA,OAAO,MAAA,CAAO,WAAW,EAAC;AAC5B;;;ACvBO,SAAS,gBAAA,CAAiB,aAAqB,aAAA,EAAgC;AACpF,EAAA,MAAM,CAAA,GAAI,YAAY,IAAA,EAAK;AAC3B,EAAA,MAAM,MAAA,GAAA,CAAU,aAAA,IAAiB,EAAA,EAAI,IAAA,EAAK;AAC1C,EAAA,IAAI,CAAC,QAAQ,OAAO,CAAA;AACpB,EAAA,OAAO,CAAA,GAAI,GAAG,CAAC;;AAAA,EAAO,MAAM,CAAA,CAAA,GAAK,MAAA;AACnC;;;AC+BO,SAAS,kBAAkB,KAAA,EAAsD;AACtF,EAAA,MAAM,EAAE,MAAA,EAAQ,kBA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C7F,IAAA,KAAA,GAAQ,OAAO,CAAA,KAAM,QAAA,IAAY,CAAC,MAAA,CAAO,KAAA,CAAM,CAAC,CAAA,GAAI,CAAA,GAAI,MAAA,CAAO,CAAC,CAAA,IAAK,CAAA;AAAA,EACvE;AACA,EAAA,OAAO,EAAE,KAAA,EAAO,EAAA,EAAI,GAAA,CAAI,EAAA,KAAO,IAAA,KAAS,CAAA,IAAK,IAAA,KAAS,MAAA,CAAA,EAAY,IAAA,EAAM,IAAA,IAAQ,EAAA,EAAG;AACrF","file":"index.js","sourcesContent":["import type { KeyGenSubset } from './types.js'\n\nexport type { KeyGenSubset }\n\n/** App-compatible alias used by existing multisign builders. */\nexport type KeyGenSubsetForPermit = KeyGenSubset\n\nexport function firstClientIdFromKeyGen(data: KeyGenSubset | null | undefined): string | null {\n const map = data?.ClientKeys\n if (!map || typeof map !== 'object') return null\n for (const v of Object.values(map)) {\n if (typeof v === 'string' && v.trim()) return v.trim()\n }\n return null\n}\n\nexport function requirePubKeyHex(keyGen: KeyGenSubset): string {\n const ph = (keyGen.pubkeyhex ?? '').trim()\n if (!ph) throw new Error('keyGen pubKey (pubkeyhex) is required')\n return ph\n}\n\nexport function keyListFromKeyGen(keyGen: KeyGenSubset): string[] {\n return keyGen.keylist ?? []\n}\n","/** Merge user purpose text with an optional batch / protocol suffix. */\nexport function mergePurposeText(purposeText: string, purposeSuffix?: string): string {\n const t = purposeText.trim()\n const suffix = (purposeSuffix ?? '').trim()\n if (!suffix) return t\n return t ? `${t}\\n\\n${suffix}` : suffix\n}\n","import type { ChainCategory, MultisignBuildResult } from './types.js'\nimport type { KeyGenSubset } from './keygen.js'\nimport { firstClientIdFromKeyGen } from './keygen.js'\nimport { mergePurposeText } from './purpose.js'\n\nexport interface MultisignLeg {\n msgHash: string\n msgRaw: string\n destinationAddress: string\n signatureText: string\n audit: Record<string, unknown>\n feeSnapshot: Record<string, unknown>\n proposalTxParams?: Record<string, unknown>\n /** Payable value wei string for first leg only when relevant */\n valueWei?: bigint\n}\n\nexport interface ChainCategoryBuildInput {\n keyGen: KeyGenSubset\n purposeText: string\n purposeSuffix?: string\n destinationChainID: string\n legs: MultisignLeg[]\n extraJSON?: Record<string, unknown>\n /** Top-level destination address (first leg destination if omitted) */\n destinationAddress?: string\n}\n\nexport interface ChainCategoryModule {\n category: ChainCategory\n finalizeMultisign(input: ChainCategoryBuildInput): MultisignBuildResult\n}\n\n/**\n * Assemble mpc-auth `bodyForSign` from category-built legs.\n * Supports single-tx and batch (messageHashes / messageRawBatch / proposalTxParams).\n */\nexport function finalizeMultisign(input: ChainCategoryBuildInput): MultisignBuildResult {\n const { keyGen, destinationChainID, legs } = input\n if (legs.length === 0) {\n throw new Error('finalizeMultisign requires at least one leg')\n }\n\n const ph = (keyGen.pubkeyhex ?? '').trim()\n if (!ph) throw new Error('keyGen pubKey (pubkeyhex) is required')\n\n const keyList = keyGen.keylist ?? []\n const clientId = firstClientIdFromKeyGen(keyGen)\n const first = legs[0]!\n\n const messageHashes = legs.map((l) => l.msgHash)\n const messageRawBatch = legs.map((l) => l.msgRaw)\n const batchMeta = legs.map((l) => ({\n destinationAddress: l.destinationAddress,\n signatureText: l.signatureText,\n ...l.audit,\n }))\n\n const proposalTxParams = legs\n .map((l) => l.proposalTxParams)\n .filter((p): p is Record<string, unknown> => p != null && typeof p === 'object')\n\n const extraPayload: Record<string, unknown> = {\n batchMeta,\n ...(input.extraJSON ?? {}),\n }\n const extraJSON = JSON.stringify(extraPayload)\n\n const bodyForSign: Record<string, unknown> = {\n keyList,\n pubKey: ph,\n msgHash: messageHashes[0],\n msgRaw: first.msgRaw,\n destinationChainID,\n destinationAddress: input.destinationAddress ?? first.destinationAddress,\n extraJSON,\n signatureText: first.signatureText,\n purpose: mergePurposeText(input.purposeText, input.purposeSuffix),\n ...first.feeSnapshot,\n }\n\n if (legs.length > 1) {\n bodyForSign.messageHashes = messageHashes\n bodyForSign.messageRawBatch = messageRawBatch\n }\n\n if (proposalTxParams.length > 0) {\n bodyForSign.proposalTxParams = proposalTxParams\n }\n\n const valueWei = first.valueWei\n if (valueWei != null && valueWei > 0n) {\n bodyForSign.value = valueWei.toString()\n }\n\n if (clientId) bodyForSign.clientId = clientId\n\n return { bodyForSign, messageToSign: JSON.stringify(bodyForSign) }\n}\n\nexport const coreChainCategoryModule: ChainCategoryModule = {\n category: 'evm',\n finalizeMultisign,\n}\n","import type { ProtocolModule } from './types.js'\n\nconst modules: ProtocolModule[] = []\n\nexport function registerProtocolModule(mod: ProtocolModule): void {\n const existing = modules.findIndex((m) => m.id === mod.id)\n if (existing >= 0) {\n modules[existing] = mod\n } else {\n modules.push(mod)\n }\n}\n\nexport function getProtocolModules(): readonly ProtocolModule[] {\n return modules\n}\n\nexport function getProtocolModule(id: string): ProtocolModule | undefined {\n return modules.find((m) => m.id === id)\n}\n\nexport function getActionsByChainCategory(category: string): ProtocolModule['actions'] {\n return modules.filter((m) => m.chainCategory === category).flatMap((m) => m.actions)\n}\n","/** GET requests to mpc-auth management node with optional Bearer JWT (Browser HTTPS). */\nexport type NodeReadAuth = {\n bearerOnGet: boolean\n jwt: string | null\n}\n\nexport function nodeFetchWithReadAuth(\n url: string,\n init: RequestInit | undefined,\n auth: NodeReadAuth,\n): Promise<Response> {\n const method = (init?.method ?? 'GET').toUpperCase()\n const headers = new Headers(init?.headers)\n if (auth.bearerOnGet && method === 'GET' && auth.jwt && auth.jwt.trim()) {\n headers.set('Authorization', `Bearer ${auth.jwt.trim()}`)\n }\n return fetch(url, { ...init, headers })\n}\n","/** mpc-auth NodeMgtKeySig envelope: `{ nonce, clientSig, nodeKey }` (all lowercase). */\n\nexport type ManagementSigFields = {\n nonce: number\n clientSig: string\n nodeKey: string\n}\n\nexport function normalizeManagementNodeKey(nodeKey: string | null | undefined): string {\n const nk = nodeKey?.trim().replace(/^0x/i, '')\n if (!nk || !/^[0-9a-fA-F]{128}$/.test(nk)) {\n throw new Error('nodeKey is required (128 hex from GET /getNodeKey).')\n }\n return nk.toLowerCase()\n}\n\n/** Base fields for NodeMgtKeySig-style POST bodies (`clientSig` cleared for signing). */\nexport function managementSigFields(\n nonce: number,\n nodeKey: string | null | undefined,\n): ManagementSigFields {\n return { nonce, clientSig: '', nodeKey: normalizeManagementNodeKey(nodeKey) }\n}\n\n/** Spread management fields first, then endpoint-specific fields (preserves key order when spreading). */\nexport function buildManagementPostBody(\n nonce: number,\n nodeKey: string | null | undefined,\n fields: Record<string, unknown> = {},\n): Record<string, unknown> {\n return { ...managementSigFields(nonce, nodeKey), ...fields }\n}\n\n/** Exact UTF-8 string to sign: same JSON with `clientSig` cleared. */\nexport function messageToSignManagementBody(body: Record<string, unknown>): string {\n return JSON.stringify({ ...body, clientSig: '' })\n}\n\nexport function withManagementClientSig(\n body: Record<string, unknown>,\n clientSig: string,\n): Record<string, unknown> {\n return { ...body, clientSig: clientSig.trim().replace(/^0x/i, '') }\n}\n","import { nodeFetchWithReadAuth, type NodeReadAuth } from './nodeRead.js'\n\nfunction mpcAuthData(raw: Record<string, unknown>): unknown {\n const code = (raw.Code ?? raw.code) as number | undefined\n if (code !== 0 && code !== undefined) return undefined\n return raw.Data ?? raw.data\n}\n\n/**\n * GET /getNodeKey — 128-hex MPC node id required on all NodeMgtKeySig POST bodies.\n */\nexport async function fetchNodeKey(\n nodeUrl: string,\n readAuth: NodeReadAuth = { bearerOnGet: false, jwt: null },\n): Promise<{ nodeKey: string; ok: boolean }> {\n const base = nodeUrl.trim().replace(/\\/$/, '')\n const res = await nodeFetchWithReadAuth(`${base}/getNodeKey`, { cache: 'no-store' }, readAuth)\n const text = await res.text()\n let raw: Record<string, unknown>\n try {\n raw = JSON.parse(text) as Record<string, unknown>\n } catch {\n return { nodeKey: '', ok: false }\n }\n const data = mpcAuthData(raw)\n const nk =\n typeof data === 'string'\n ? data\n : data != null && typeof data === 'object' && !Array.isArray(data)\n ? String((data as Record<string, unknown>).nodeKey ?? (data as Record<string, unknown>).NodeKey ?? '')\n : data != null\n ? String(data)\n : ''\n const trimmed = nk.trim().replace(/^0x/i, '')\n if (!/^[0-9a-fA-F]{128}$/.test(trimmed)) {\n return { nodeKey: '', ok: false }\n }\n return { nodeKey: trimmed.toLowerCase(), ok: res.ok }\n}\n\n/**\n * Fetch management nonce: GET /getPublicMgtKeyNonce (Ed25519) or GET /getNodeMgtKeyNonce (Ethereum NodeMgtKey).\n * For Ed25519 added keys, pass `?publicKey=<64-hex>`.\n */\nexport async function fetchManagementNonce(\n nodeUrl: string,\n useEd25519: boolean,\n ed25519PublicKey?: string,\n readAuth: NodeReadAuth = { bearerOnGet: false, jwt: null },\n): Promise<{ nonce: number; ok: boolean; code: number }> {\n const base = nodeUrl.trim().replace(/\\/$/, '')\n const path = useEd25519 ? '/getPublicMgtKeyNonce' : '/getNodeMgtKeyNonce'\n const url =\n useEd25519 && ed25519PublicKey && /^[0-9a-fA-F]{64}$/.test(ed25519PublicKey.trim())\n ? `${base}${path}?publicKey=${encodeURIComponent(ed25519PublicKey.trim())}`\n : `${base}${path}`\n const res = await nodeFetchWithReadAuth(url, { cache: 'no-store' }, readAuth)\n const text = await res.text()\n let raw: Record<string, unknown>\n try {\n raw = JSON.parse(text) as Record<string, unknown>\n } catch {\n return { nonce: 0, ok: false, code: -1 }\n }\n const code = (raw.Code ?? raw.code) as number | undefined\n const payload = mpcAuthData(raw) ?? raw.Data ?? raw.data\n let nonce = 0\n if (typeof payload === 'number' && !Number.isNaN(payload)) {\n nonce = payload\n } else if (payload && typeof payload === 'object') {\n const n = (payload as Record<string, unknown>).nonce ?? (payload as Record<string, unknown>).Nonce\n nonce = typeof n === 'number' && !Number.isNaN(n) ? n : Number(n) || 0\n }\n return { nonce, ok: res.ok && (code === 0 || code === undefined), code: code ?? -1 }\n}\n"]}
1
+ {"version":3,"sources":["../../src/core/purpose.ts","../../src/core/envelope.ts","../../src/core/registry.ts","../../src/core/defiProxy.ts"],"names":["r"],"mappings":";;;;;;AACO,SAAS,gBAAA,CAAiB,aAAqB,aAAA,EAAgC;AACpF,E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AAS,EAAC,cAAA,EAAgB,kBAAA,EAAkB;AAAA,IAC5C,IAAA,EAAM,IAAA,CAAK,SAAA,CAAU,IAAA,CAAK,IAAI;AAAA,GAC/B,CAAA;AACD,EAAA,IAAI,CAAC,EAAE,EAAA,EAAI;AACT,IAAA,MAAM,IAAI,MAAM,CAAA,CAAE,MAAK,CAAE,KAAA,CAAM,MAAM,EAAE,CAAA;AACvC,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,GAAI,CAAA,KAAA,EAAQ,CAAA,CAAE,MAAM,CAAA,EAAA,EAAK,CAAA,CAAE,KAAA,CAAM,CAAA,EAAG,GAAG,CAAC,CAAA,CAAA,GAAK,CAAA,KAAA,EAAQ,CAAA,CAAE,MAAM,CAAA,CAAE,CAAA;AAAA,EACjF;AACA,EAAA,OAAQ,MAAM,EAAE,IAAA,EAAK;AACvB","file":"index.js","sourcesContent":["/** Merge user purpose text with an optional batch / protocol suffix. */\nexport function mergePurposeText(purposeText: string, purposeSuffix?: string): string {\n const t = purposeText.trim()\n const suffix = (purposeSuffix ?? '').trim()\n if (!suffix) return t\n return t ? `${t}\\n\\n${suffix}` : suffix\n}\n","import type { ChainCategory, MultisignBuildResult, KeyGenSubset } from './types.js'\nimport { getClientIdFromKeyGenResult } from '@continuumdao/continuum-node-sdk'\nimport { mergePurposeText } from './purpose.js'\n\nexport interface MultisignLeg {\n msgHash: string\n msgRaw: string\n destinationAddress: string\n signatureText: string\n audit: Record<string, unknown>\n feeSnapshot: Record<string, unknown>\n proposalTxParams?: Record<string, unknown>\n /** Payable value wei string for first leg only when relevant */\n valueWei?: bigint\n}\n\nexport interface ChainCategoryBuildInput {\n keyGen: KeyGenSubset\n purposeText: string\n purposeSuffix?: string\n destinationChainID: string\n legs: MultisignLeg[]\n extraJSON?: Record<string, unknown>\n /** Top-level destination address (first leg destination if omitted) */\n destinationAddress?: string\n}\n\nexport interface ChainCategoryModule {\n category: ChainCategory\n finalizeMultisign(input: ChainCategoryBuildInput): MultisignBuildResult\n}\n\n/**\n * Assemble mpc-auth `bodyForSign` from category-built legs.\n * Supports single-tx and batch (messageHashes / messageRawBatch / proposalTxParams).\n */\nexport function finalizeMultisign(input: ChainCategoryBuildInput): MultisignBuildResult {\n const { keyGen, destinationChainID, legs } = input\n if (legs.length === 0) {\n throw new Error('finalizeMultisign requires at least one leg')\n }\n\n const ph = (keyGen.pubkeyhex ?? '').trim()\n if (!ph) throw new Error('keyGen pubKey (pubkeyhex) is required')\n\n const keyList = keyGen.keylist ?? []\n const clientId = getClientIdFromKeyGenResult(keyGen)\n const first = legs[0]!\n\n const messageHashes = legs.map((l) => l.msgHash)\n const messageRawBatch = legs.map((l) => l.msgRaw)\n const batchMeta = legs.map((l) => ({\n destinationAddress: l.destinationAddress,\n signatureText: l.signatureText,\n ...l.audit,\n }))\n\n const proposalTxParams = legs\n .map((l) => l.proposalTxParams)\n .filter((p): p is Record<string, unknown> => p != null && typeof p === 'object')\n\n const extraPayload: Record<string, unknown> = {\n batchMeta,\n ...(input.extraJSON ?? {}),\n }\n const extraJSON = JSON.stringify(extraPayload)\n\n const bodyForSign: Record<string, unknown> = {\n keyList,\n pubKey: ph,\n msgHash: messageHashes[0],\n msgRaw: first.msgRaw,\n destinationChainID,\n destinationAddress: input.destinationAddress ?? first.destinationAddress,\n extraJSON,\n signatureText: first.signatureText,\n purpose: mergePurposeText(input.purposeText, input.purposeSuffix),\n ...first.feeSnapshot,\n }\n\n if (legs.length > 1) {\n bodyForSign.messageHashes = messageHashes\n bodyForSign.messageRawBatch = messageRawBatch\n }\n\n if (proposalTxParams.length > 0) {\n bodyForSign.proposalTxParams = proposalTxParams\n }\n\n const valueWei = first.valueWei\n if (valueWei != null && valueWei > 0n) {\n bodyForSign.value = valueWei.toString()\n }\n\n if (clientId) bodyForSign.clientId = clientId\n\n return { bodyForSign, messageToSign: JSON.stringify(bodyForSign) }\n}\n\nexport const coreChainCategoryModule: ChainCategoryModule = {\n category: 'evm',\n finalizeMultisign,\n}\n","import type { ProtocolModule } from './types.js'\n\nconst modules: ProtocolModule[] = []\n\nexport function registerProtocolModule(mod: ProtocolModule): void {\n const existing = modules.findIndex((m) => m.id === mod.id)\n if (existing >= 0) {\n modules[existing] = mod\n } else {\n modules.push(mod)\n }\n}\n\nexport function getProtocolModules(): readonly ProtocolModule[] {\n return modules\n}\n\nexport function getProtocolModule(id: string): ProtocolModule | undefined {\n return modules.find((m) => m.id === id)\n}\n\nexport function getActionsByChainCategory(category: string): ProtocolModule['actions'] {\n return modules.filter((m) => m.chainCategory === category).flatMap((m) => m.actions)\n}\n","/**\n * Optional browser → Next.js API proxy paths for DeFi upstream calls.\n * Set once from continuumdao-node-app client bootstrap.\n */\n\nlet aaveGraphqlProxyUrl: string | undefined\nlet eulerGraphqlProxyUrl: string | undefined\nlet mapleGraphqlProxyUrl: string | undefined\nlet coingeckoProxyUrl: string | undefined\n\nexport function setAaveGraphqlProxyUrl(url: string | undefined): void {\n aaveGraphqlProxyUrl = url?.trim() || undefined\n}\n\nexport function getAaveGraphqlProxyUrl(): string | undefined {\n return aaveGraphqlProxyUrl\n}\n\nexport function setEulerGraphqlProxyUrl(url: string | undefined): void {\n eulerGraphqlProxyUrl = url?.trim() || undefined\n}\n\nexport function getEulerGraphqlProxyUrl(): string | undefined {\n return eulerGraphqlProxyUrl\n}\n\nexport function setMapleGraphqlProxyUrl(url: string | undefined): void {\n mapleGraphqlProxyUrl = url?.trim() || undefined\n}\n\nexport function getMapleGraphqlProxyUrl(): string | undefined {\n return mapleGraphqlProxyUrl\n}\n\nexport function setCoingeckoProxyUrl(url: string | undefined): void {\n coingeckoProxyUrl = url?.trim() || undefined\n}\n\nexport function getCoingeckoProxyUrl(): string | undefined {\n return coingeckoProxyUrl\n}\n\nexport async function postJsonViaOptionalProxy<T>(args: {\n directUrl: string\n body: unknown\n proxyUrl?: string\n proxyEnvelope?: unknown\n}): Promise<T> {\n const proxy = args.proxyUrl?.trim()\n if (proxy) {\n const r = await fetch(proxy, {\n method: 'POST',\n headers: {'content-type': 'application/json'},\n body: JSON.stringify(args.proxyEnvelope ?? args.body),\n })\n if (!r.ok) {\n const t = await r.text().catch(() => '')\n throw new Error(t ? `Proxy HTTP ${r.status}: ${t.slice(0, 200)}` : `Proxy HTTP ${r.status}`)\n }\n return (await r.json()) as T\n }\n const r = await fetch(args.directUrl, {\n method: 'POST',\n headers: {'content-type': 'application/json'},\n body: JSON.stringify(args.body),\n })\n if (!r.ok) {\n const t = await r.text().catch(() => '')\n throw new Error(t ? `HTTP ${r.status}: ${t.slice(0, 200)}` : `HTTP ${r.status}`)\n }\n return (await r.json()) as T\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { K as KeyGenSubset, C as ChainCategory, M as MultisignBuildResult } from './types-Ce2qNHai.js';
1
+ import { K as KeyGenSubset, C as ChainCategory, M as MultisignBuildResult } from './types-BfjWdw1j.js';
2
2
 
3
3
  interface MultisignLeg {
4
4
  msgHash: string;