@continuumdao/ctm-mpc-defi 0.2.19 → 0.2.22
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/agent/catalog.cjs +303 -93
- package/dist/agent/catalog.cjs.map +1 -1
- package/dist/agent/catalog.d.ts +985 -709
- package/dist/agent/catalog.js +299 -94
- package/dist/agent/catalog.js.map +1 -1
- package/dist/agent/skills/hyperliquid/SKILL.md +24 -20
- package/dist/agent/skills/uniswap-v4/SKILL.md +58 -0
- package/dist/chains/evm/index.cjs +6 -2
- package/dist/chains/evm/index.cjs.map +1 -1
- package/dist/chains/evm/index.d.ts +4 -4
- package/dist/chains/evm/index.js +6 -2
- package/dist/chains/evm/index.js.map +1 -1
- package/dist/chains/near/index.d.ts +1 -1
- package/dist/chains/solana/index.d.ts +1 -1
- package/dist/core/index.cjs +95 -1
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.ts +44 -4
- package/dist/core/index.js +91 -2
- package/dist/core/index.js.map +1 -1
- package/dist/{envelope-CpBUh9eP.d.ts → envelope-C_bfuKab.d.ts} +3 -1
- package/dist/index.cjs +96 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +93 -4
- package/dist/index.js.map +1 -1
- package/dist/protocols/evm/aave-v4/index.cjs +6 -2
- package/dist/protocols/evm/aave-v4/index.cjs.map +1 -1
- package/dist/protocols/evm/aave-v4/index.d.ts +1 -1
- package/dist/protocols/evm/aave-v4/index.js +6 -2
- package/dist/protocols/evm/aave-v4/index.js.map +1 -1
- package/dist/protocols/evm/circle-cctp/index.cjs +6 -2
- package/dist/protocols/evm/circle-cctp/index.cjs.map +1 -1
- package/dist/protocols/evm/circle-cctp/index.d.ts +2 -2
- package/dist/protocols/evm/circle-cctp/index.js +6 -2
- package/dist/protocols/evm/circle-cctp/index.js.map +1 -1
- package/dist/protocols/evm/curve-dao/index.cjs +6 -2
- package/dist/protocols/evm/curve-dao/index.cjs.map +1 -1
- package/dist/protocols/evm/curve-dao/index.d.ts +2 -2
- package/dist/protocols/evm/curve-dao/index.js +6 -2
- package/dist/protocols/evm/curve-dao/index.js.map +1 -1
- package/dist/protocols/evm/ethena/index.cjs +6 -2
- package/dist/protocols/evm/ethena/index.cjs.map +1 -1
- package/dist/protocols/evm/ethena/index.d.ts +1 -1
- package/dist/protocols/evm/ethena/index.js +6 -2
- package/dist/protocols/evm/ethena/index.js.map +1 -1
- package/dist/protocols/evm/euler-v2/index.cjs +6 -2
- package/dist/protocols/evm/euler-v2/index.cjs.map +1 -1
- package/dist/protocols/evm/euler-v2/index.d.ts +1 -1
- package/dist/protocols/evm/euler-v2/index.js +6 -2
- package/dist/protocols/evm/euler-v2/index.js.map +1 -1
- package/dist/protocols/evm/gmx/index.cjs +54 -22
- package/dist/protocols/evm/gmx/index.cjs.map +1 -1
- package/dist/protocols/evm/gmx/index.d.ts +22 -8
- package/dist/protocols/evm/gmx/index.js +53 -23
- package/dist/protocols/evm/gmx/index.js.map +1 -1
- package/dist/protocols/evm/hyperliquid/index.cjs +467 -2
- package/dist/protocols/evm/hyperliquid/index.cjs.map +1 -1
- package/dist/protocols/evm/hyperliquid/index.d.ts +189 -3
- package/dist/protocols/evm/hyperliquid/index.js +447 -4
- package/dist/protocols/evm/hyperliquid/index.js.map +1 -1
- package/dist/protocols/evm/lido/index.cjs +6 -2
- package/dist/protocols/evm/lido/index.cjs.map +1 -1
- package/dist/protocols/evm/lido/index.d.ts +1 -1
- package/dist/protocols/evm/lido/index.js +6 -2
- package/dist/protocols/evm/lido/index.js.map +1 -1
- package/dist/protocols/evm/maple/index.cjs +6 -2
- package/dist/protocols/evm/maple/index.cjs.map +1 -1
- package/dist/protocols/evm/maple/index.d.ts +1 -1
- package/dist/protocols/evm/maple/index.js +6 -2
- package/dist/protocols/evm/maple/index.js.map +1 -1
- package/dist/protocols/evm/morpho/index.cjs +6 -2
- package/dist/protocols/evm/morpho/index.cjs.map +1 -1
- package/dist/protocols/evm/morpho/index.d.ts +1 -1
- package/dist/protocols/evm/morpho/index.js +6 -2
- package/dist/protocols/evm/morpho/index.js.map +1 -1
- package/dist/protocols/evm/permit2/index.cjs +206 -0
- package/dist/protocols/evm/permit2/index.cjs.map +1 -0
- package/dist/protocols/evm/permit2/index.d.ts +43 -0
- package/dist/protocols/evm/permit2/index.js +203 -0
- package/dist/protocols/evm/permit2/index.js.map +1 -0
- package/dist/protocols/evm/sky/index.cjs +6 -2
- package/dist/protocols/evm/sky/index.cjs.map +1 -1
- package/dist/protocols/evm/sky/index.d.ts +1 -1
- package/dist/protocols/evm/sky/index.js +6 -2
- package/dist/protocols/evm/sky/index.js.map +1 -1
- package/dist/protocols/evm/uniswap-v4/index.cjs +685 -2
- package/dist/protocols/evm/uniswap-v4/index.cjs.map +1 -1
- package/dist/protocols/evm/uniswap-v4/index.d.ts +180 -3
- package/dist/protocols/evm/uniswap-v4/index.js +663 -3
- package/dist/protocols/evm/uniswap-v4/index.js.map +1 -1
- package/dist/{registry-Bv5o37_w.d.ts → registry-DxDSPQ-p.d.ts} +1 -1
- package/dist/{types-BfjWdw1j.d.ts → types-PZrvtjv8.d.ts} +2 -0
- package/dist/{types-DUeNJLr9.d.ts → types-RZWOTm8c.d.ts} +1 -1
- package/package.json +8 -2
package/dist/core/index.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var continuumNodeSdk = require('@continuumdao/continuum-node-sdk');
|
|
4
|
+
var viem = require('viem');
|
|
4
5
|
|
|
5
6
|
// src/core/index.ts
|
|
6
7
|
|
|
@@ -35,7 +36,7 @@ function finalizeMultisign(input) {
|
|
|
35
36
|
batchMeta,
|
|
36
37
|
...input.extraJSON ?? {}
|
|
37
38
|
};
|
|
38
|
-
const extraJSON = JSON.stringify(extraPayload);
|
|
39
|
+
const extraJSON = JSON.stringify(extraPayload, (_, v) => typeof v === "bigint" ? v.toString() : v);
|
|
39
40
|
const bodyForSign = {
|
|
40
41
|
keyList,
|
|
41
42
|
pubKey: ph,
|
|
@@ -60,6 +61,9 @@ function finalizeMultisign(input) {
|
|
|
60
61
|
bodyForSign.value = valueWei.toString();
|
|
61
62
|
}
|
|
62
63
|
if (clientId) bodyForSign.clientId = clientId;
|
|
64
|
+
if (input.expiryDate != null && input.expiryDate > 0) {
|
|
65
|
+
bodyForSign.expiryDate = Math.floor(input.expiryDate);
|
|
66
|
+
}
|
|
63
67
|
return { bodyForSign, messageToSign: JSON.stringify(bodyForSign) };
|
|
64
68
|
}
|
|
65
69
|
var coreChainCategoryModule = {
|
|
@@ -148,12 +152,102 @@ async function postJsonViaOptionalProxy(args) {
|
|
|
148
152
|
}
|
|
149
153
|
return await r.json();
|
|
150
154
|
}
|
|
155
|
+
var EIP712_SIGN_REQUEST_KIND = "eip712";
|
|
156
|
+
function msgHashNo0x(digest) {
|
|
157
|
+
return digest.startsWith("0x") ? digest.slice(2) : digest;
|
|
158
|
+
}
|
|
159
|
+
function eip712SignatureText(domain, primaryType) {
|
|
160
|
+
return JSON.stringify({
|
|
161
|
+
kind: "EIP-712",
|
|
162
|
+
...typeof domain.name === "string" ? { name: domain.name } : {},
|
|
163
|
+
primaryType
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
function jsonStringifyForAudit(value) {
|
|
167
|
+
return JSON.stringify(value, (_, v) => typeof v === "bigint" ? v.toString() : v);
|
|
168
|
+
}
|
|
169
|
+
function eip712MsgRawHex(typedData, delivery) {
|
|
170
|
+
const envelope = {
|
|
171
|
+
version: 1,
|
|
172
|
+
...typedData,
|
|
173
|
+
delivery
|
|
174
|
+
};
|
|
175
|
+
return viem.stringToHex(jsonStringifyForAudit(envelope));
|
|
176
|
+
}
|
|
177
|
+
function buildEip712MultisignBody(args) {
|
|
178
|
+
const { typedData, delivery } = args;
|
|
179
|
+
const digest = viem.hashTypedData({
|
|
180
|
+
domain: typedData.domain,
|
|
181
|
+
types: typedData.types,
|
|
182
|
+
primaryType: typedData.primaryType,
|
|
183
|
+
message: typedData.message
|
|
184
|
+
});
|
|
185
|
+
const extraJSON = {
|
|
186
|
+
signRequestKind: EIP712_SIGN_REQUEST_KIND,
|
|
187
|
+
eip712: {
|
|
188
|
+
version: 1,
|
|
189
|
+
digest,
|
|
190
|
+
domain: typedData.domain,
|
|
191
|
+
types: typedData.types,
|
|
192
|
+
primaryType: typedData.primaryType,
|
|
193
|
+
message: typedData.message
|
|
194
|
+
},
|
|
195
|
+
delivery
|
|
196
|
+
};
|
|
197
|
+
return finalizeMultisign({
|
|
198
|
+
keyGen: args.keyGen,
|
|
199
|
+
purposeText: args.purposeText,
|
|
200
|
+
purposeSuffix: args.purposeSuffix,
|
|
201
|
+
destinationChainID: args.destinationChainID,
|
|
202
|
+
destinationAddress: args.destinationAddress,
|
|
203
|
+
extraJSON,
|
|
204
|
+
expiryDate: args.expiryDate,
|
|
205
|
+
legs: [
|
|
206
|
+
{
|
|
207
|
+
msgHash: msgHashNo0x(digest),
|
|
208
|
+
msgRaw: eip712MsgRawHex(typedData, delivery),
|
|
209
|
+
destinationAddress: args.destinationAddress,
|
|
210
|
+
signatureText: eip712SignatureText(typedData.domain, typedData.primaryType),
|
|
211
|
+
audit: {
|
|
212
|
+
kind: "EIP712",
|
|
213
|
+
primaryType: typedData.primaryType,
|
|
214
|
+
deliveryKind: delivery.kind,
|
|
215
|
+
...args.audit ?? {}
|
|
216
|
+
},
|
|
217
|
+
feeSnapshot: {}
|
|
218
|
+
}
|
|
219
|
+
]
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// src/core/expiry.ts
|
|
224
|
+
var DEFAULT_DEFI_MULTISIGN_EXPIRY_SECONDS = 30 * 60;
|
|
225
|
+
var DEFI_PROTOCOLS_WITH_30MIN_EXPIRY = /* @__PURE__ */ new Set([
|
|
226
|
+
"uniswap-v4",
|
|
227
|
+
"gmx",
|
|
228
|
+
"hyperliquid",
|
|
229
|
+
"curve-dao"
|
|
230
|
+
]);
|
|
231
|
+
function defiMultisignExpiryUnixSeconds(protocolId, explicitExpiryDate) {
|
|
232
|
+
if (typeof explicitExpiryDate === "number" && Number.isFinite(explicitExpiryDate) && explicitExpiryDate > 0) {
|
|
233
|
+
return Math.floor(explicitExpiryDate);
|
|
234
|
+
}
|
|
235
|
+
if (protocolId && DEFI_PROTOCOLS_WITH_30MIN_EXPIRY.has(protocolId)) {
|
|
236
|
+
return Math.floor(Date.now() / 1e3) + DEFAULT_DEFI_MULTISIGN_EXPIRY_SECONDS;
|
|
237
|
+
}
|
|
238
|
+
return void 0;
|
|
239
|
+
}
|
|
151
240
|
|
|
152
241
|
Object.defineProperty(exports, "firstClientIdFromKeyGen", {
|
|
153
242
|
enumerable: true,
|
|
154
243
|
get: function () { return continuumNodeSdk.getClientIdFromKeyGenResult; }
|
|
155
244
|
});
|
|
245
|
+
exports.DEFAULT_DEFI_MULTISIGN_EXPIRY_SECONDS = DEFAULT_DEFI_MULTISIGN_EXPIRY_SECONDS;
|
|
246
|
+
exports.DEFI_PROTOCOLS_WITH_30MIN_EXPIRY = DEFI_PROTOCOLS_WITH_30MIN_EXPIRY;
|
|
247
|
+
exports.EIP712_SIGN_REQUEST_KIND = EIP712_SIGN_REQUEST_KIND;
|
|
248
|
+
exports.buildEip712MultisignBody = buildEip712MultisignBody;
|
|
156
249
|
exports.coreChainCategoryModule = coreChainCategoryModule;
|
|
250
|
+
exports.defiMultisignExpiryUnixSeconds = defiMultisignExpiryUnixSeconds;
|
|
157
251
|
exports.finalizeMultisign = finalizeMultisign;
|
|
158
252
|
exports.getAaveGraphqlProxyUrl = getAaveGraphqlProxyUrl;
|
|
159
253
|
exports.getActionsByChainCategory = getActionsByChainCategory;
|
package/dist/core/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/purpose.ts","../../src/core/envelope.ts","../../src/core/registry.ts","../../src/core/defiProxy.ts"],"names":["getClientIdFromKeyGenResult","r"],"m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AAA,CAAA,GAAK,CAAA,WAAA,EAAcA,EAAAA,CAAE,MAAM,CAAA,CAAE,CAAA;AAAA,IAC7F;AACA,IAAA,OAAQ,MAAMA,GAAE,IAAA,EAAK;AAAA,EACvB;AACA,EAAA,MAAM,CAAA,GAAI,MAAM,KAAA,CAAM,IAAA,CAAK,SAAA,EAAW;AAAA,IACpC,MAAA,EAAQ,MAAA;AAAA,IACR,OAAA,EAAS,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.cjs","sourcesContent":["/** Merge user purpose text with an optional batch / protocol suffix. */\nexport function mergePurposeText(purposeText: string | undefined, 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 morphoGraphqlProxyUrl: 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 setMorphoGraphqlProxyUrl(url: string | undefined): void {\n morphoGraphqlProxyUrl = url?.trim() || undefined\n}\n\nexport function getMorphoGraphqlProxyUrl(): string | undefined {\n return morphoGraphqlProxyUrl\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
|
+
{"version":3,"sources":["../../src/core/purpose.ts","../../src/core/envelope.ts","../../src/core/registry.ts","../../src/core/defiProxy.ts","../../src/core/eip712Multisign.ts","../../src/core/expiry.ts"],"names":["getClientIdFromKeyGenResult","r","stringToHex","hashTypedData"],"mappings":";;;;;;;;AACO,SAAS,gBAAA,CAAiB,aAAiC,aAAA,EAAgC;AAChG,EAAA,MAAM,CAAA,GAAA,CAAK,WAAA,IAAe,EAAA,EAAI,IAAA,EAAK;AACnC,EAAA,MAAM,MAAA,GAAA,CAAU,aAAA,IAAiB,EAAA,EAAI,IAAA,EAAK;AAC1C,EAAA,IAAI,CAAC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AAAA,IACzB,oBAAoB,IAAA,CAAK,kBAAA;AAAA,IACzB,SAAA;AAAA,IACA,YAAY,IAAA,CAAK,UAAA;AAAA,IACjB,IAAA,EAAM;AAAA,MACJ;AAAA,QACE,OAAA,EAAS,YAAY,MAAM,CAAA;AAAA,QAC3B,MAAA,EAAQ,eAAA,CAAgB,SAAA,EAAW,QAAQ,CAAA;AAAA,QAC3C,oBAAoB,IAAA,CAAK,kBAAA;AAAA,QACzB,aAAA,EAAe,mBAAA,CAAoB,SAAA,CAAU,MAAA,EAAQ,UAAU,WAAW,CAAA;AAAA,QAC1E,KAAA,EAAO;AAAA,UACL,IAAA,EAAM,QAAA;AAAA,UACN,aAAa,SAAA,CAAU,WAAA;AAAA,UACvB,cAAc,QAAA,CAAS,IAAA;AAAA,UACvB,GAAI,IAAA,CAAK,KAAA,IAAS;AAAC,SACrB;AAAA,QACA,aAAa;AAAC;AAChB;AACF,GACD,CAAA;AACH;;;ACxGO,IAAM,wCAAwC,EAAA,GAAK;AAGnD,IAAM,gCAAA,uBAAuC,GAAA,CAAI;AAAA,EACtD,YAAA;AAAA,EACA,KAAA;AAAA,EACA,aAAA;AAAA,EACA;AACF,CAAC;AAEM,SAAS,8BAAA,CACd,YACA,kBAAA,EACoB;AACpB,EAAA,IAAI,OAAO,uBAAuB,QAAA,IAAY,MAAA,CAAO,SAAS,kBAAkB,CAAA,IAAK,qBAAqB,CAAA,EAAG;AAC3G,IAAA,OAAO,IAAA,CAAK,MAAM,kBAAkB,CAAA;AAAA,EACtC;AACA,EAAA,IAAI,UAAA,IAAc,gCAAA,CAAiC,GAAA,CAAI,UAAU,CAAA,EAAG;AAClE,IAAA,OAAO,KAAK,KAAA,CAAM,IAAA,CAAK,GAAA,EAAI,GAAI,GAAI,CAAA,GAAI,qCAAA;AAAA,EACzC;AACA,EAAA,OAAO,MAAA;AACT","file":"index.cjs","sourcesContent":["/** Merge user purpose text with an optional batch / protocol suffix. */\nexport function mergePurposeText(purposeText: string | undefined, 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 /** Unix seconds (UTC) for mpc-auth multiSignRequest expiryDate. */\n expiryDate?: number\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, (_, v) => (typeof v === 'bigint' ? v.toString() : v))\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 if (input.expiryDate != null && input.expiryDate > 0) {\n bodyForSign.expiryDate = Math.floor(input.expiryDate)\n }\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 morphoGraphqlProxyUrl: 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 setMorphoGraphqlProxyUrl(url: string | undefined): void {\n morphoGraphqlProxyUrl = url?.trim() || undefined\n}\n\nexport function getMorphoGraphqlProxyUrl(): string | undefined {\n return morphoGraphqlProxyUrl\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","import { hashTypedData, stringToHex, type TypedDataDomain } from 'viem'\nimport type { KeyGenSubset, MultisignBuildResult } from './types.js'\nimport { finalizeMultisign } from './envelope.js'\n\nexport const EIP712_SIGN_REQUEST_KIND = 'eip712' as const\n\nexport type Eip712TypedDataField = { name: string; type: string }\n\nexport type Eip712TypedDataPayload = {\n domain: TypedDataDomain\n types: Record<string, readonly Eip712TypedDataField[] | Eip712TypedDataField[]>\n primaryType: string\n message: Record<string, unknown>\n}\n\nexport type Eip712MultisignDelivery = Record<string, unknown> & { kind: string }\n\nexport type BuildEip712MultisignBodyArgs = {\n keyGen: KeyGenSubset\n purposeText: string\n purposeSuffix?: string\n /** Chain id stored on the sign request (protocol context; may differ from EIP-712 domain chainId). */\n destinationChainID: string\n destinationAddress: string\n typedData: Eip712TypedDataPayload\n delivery: Eip712MultisignDelivery\n audit?: Record<string, unknown>\n expiryDate?: number\n}\n\nfunction msgHashNo0x(digest: `0x${string}`): string {\n return digest.startsWith('0x') ? digest.slice(2) : digest\n}\n\nfunction eip712SignatureText(domain: TypedDataDomain, primaryType: string): string {\n return JSON.stringify({\n kind: 'EIP-712',\n ...(typeof domain.name === 'string' ? { name: domain.name } : {}),\n primaryType,\n })\n}\n\nfunction jsonStringifyForAudit(value: unknown): string {\n return JSON.stringify(value, (_, v) => (typeof v === 'bigint' ? v.toString() : v))\n}\n\nfunction eip712MsgRawHex(typedData: Eip712TypedDataPayload, delivery: Eip712MultisignDelivery): string {\n const envelope = {\n version: 1,\n ...typedData,\n delivery,\n }\n return stringToHex(jsonStringifyForAudit(envelope))\n}\n\n/**\n * Build an mpc-auth multiSignRequest body for a single-leg EIP-712 digest (no EVM tx broadcast).\n * `msgHash` is the EIP-712 hash; `msgRaw` is UTF-8 hex JSON audit envelope (not RLP calldata).\n */\nexport function buildEip712MultisignBody(args: BuildEip712MultisignBodyArgs): MultisignBuildResult {\n const { typedData, delivery } = args\n const digest = hashTypedData({\n domain: typedData.domain,\n types: typedData.types,\n primaryType: typedData.primaryType,\n message: typedData.message,\n })\n\n const extraJSON: Record<string, unknown> = {\n signRequestKind: EIP712_SIGN_REQUEST_KIND,\n eip712: {\n version: 1,\n digest,\n domain: typedData.domain,\n types: typedData.types,\n primaryType: typedData.primaryType,\n message: typedData.message,\n },\n delivery,\n }\n\n return finalizeMultisign({\n keyGen: args.keyGen,\n purposeText: args.purposeText,\n purposeSuffix: args.purposeSuffix,\n destinationChainID: args.destinationChainID,\n destinationAddress: args.destinationAddress,\n extraJSON,\n expiryDate: args.expiryDate,\n legs: [\n {\n msgHash: msgHashNo0x(digest),\n msgRaw: eip712MsgRawHex(typedData, delivery),\n destinationAddress: args.destinationAddress,\n signatureText: eip712SignatureText(typedData.domain, typedData.primaryType),\n audit: {\n kind: 'EIP712',\n primaryType: typedData.primaryType,\n deliveryKind: delivery.kind,\n ...(args.audit ?? {}),\n },\n feeSnapshot: {},\n },\n ],\n })\n}\n","/** Default MPC sign-request agreement window for fast-moving DeFi protocols (30 minutes). */\nexport const DEFAULT_DEFI_MULTISIGN_EXPIRY_SECONDS = 30 * 60\n\n/** Protocol ids that default to 30-minute expiry when `expiryDate` is omitted on multisign MCP tools. */\nexport const DEFI_PROTOCOLS_WITH_30MIN_EXPIRY = new Set([\n 'uniswap-v4',\n 'gmx',\n 'hyperliquid',\n 'curve-dao',\n])\n\nexport function defiMultisignExpiryUnixSeconds(\n protocolId: string | undefined,\n explicitExpiryDate?: number | null,\n): number | undefined {\n if (typeof explicitExpiryDate === 'number' && Number.isFinite(explicitExpiryDate) && explicitExpiryDate > 0) {\n return Math.floor(explicitExpiryDate)\n }\n if (protocolId && DEFI_PROTOCOLS_WITH_30MIN_EXPIRY.has(protocolId)) {\n return Math.floor(Date.now() / 1000) + DEFAULT_DEFI_MULTISIGN_EXPIRY_SECONDS\n }\n return undefined\n}\n"]}
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { K as KeyGenSubset, M as MultisignBuildResult } from '../types-PZrvtjv8.js';
|
|
2
|
+
export { C as ChainCategory, a as ChainSupportContext, E as EvmTokenKind, b as KeyGenSubsetForPermit, c as MultisignCommonArgs, N as NearTokenKind, P as ParamDoc, d as ProtocolActionDescriptor, e as ProtocolModule, S as SolanaTokenKind, T as TokenRef } from '../types-PZrvtjv8.js';
|
|
2
3
|
export { getClientIdFromKeyGenResult as firstClientIdFromKeyGen } from '@continuumdao/continuum-node-sdk';
|
|
3
|
-
export { C as ChainCategoryBuildInput, a as ChainCategoryModule, M as MultisignLeg, c as coreChainCategoryModule, f as finalizeMultisign } from '../envelope-
|
|
4
|
-
export { g as getActionsByChainCategory, a as getProtocolModule, b as getProtocolModules, r as registerProtocolModule } from '../registry-
|
|
4
|
+
export { C as ChainCategoryBuildInput, a as ChainCategoryModule, M as MultisignLeg, c as coreChainCategoryModule, f as finalizeMultisign } from '../envelope-C_bfuKab.js';
|
|
5
|
+
export { g as getActionsByChainCategory, a as getProtocolModule, b as getProtocolModules, r as registerProtocolModule } from '../registry-DxDSPQ-p.js';
|
|
6
|
+
import { TypedDataDomain } from 'viem';
|
|
5
7
|
|
|
6
8
|
/** Merge user purpose text with an optional batch / protocol suffix. */
|
|
7
9
|
declare function mergePurposeText(purposeText: string | undefined, purposeSuffix?: string): string;
|
|
@@ -27,4 +29,42 @@ declare function postJsonViaOptionalProxy<T>(args: {
|
|
|
27
29
|
proxyEnvelope?: unknown;
|
|
28
30
|
}): Promise<T>;
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
declare const EIP712_SIGN_REQUEST_KIND: "eip712";
|
|
33
|
+
type Eip712TypedDataField = {
|
|
34
|
+
name: string;
|
|
35
|
+
type: string;
|
|
36
|
+
};
|
|
37
|
+
type Eip712TypedDataPayload = {
|
|
38
|
+
domain: TypedDataDomain;
|
|
39
|
+
types: Record<string, readonly Eip712TypedDataField[] | Eip712TypedDataField[]>;
|
|
40
|
+
primaryType: string;
|
|
41
|
+
message: Record<string, unknown>;
|
|
42
|
+
};
|
|
43
|
+
type Eip712MultisignDelivery = Record<string, unknown> & {
|
|
44
|
+
kind: string;
|
|
45
|
+
};
|
|
46
|
+
type BuildEip712MultisignBodyArgs = {
|
|
47
|
+
keyGen: KeyGenSubset;
|
|
48
|
+
purposeText: string;
|
|
49
|
+
purposeSuffix?: string;
|
|
50
|
+
/** Chain id stored on the sign request (protocol context; may differ from EIP-712 domain chainId). */
|
|
51
|
+
destinationChainID: string;
|
|
52
|
+
destinationAddress: string;
|
|
53
|
+
typedData: Eip712TypedDataPayload;
|
|
54
|
+
delivery: Eip712MultisignDelivery;
|
|
55
|
+
audit?: Record<string, unknown>;
|
|
56
|
+
expiryDate?: number;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Build an mpc-auth multiSignRequest body for a single-leg EIP-712 digest (no EVM tx broadcast).
|
|
60
|
+
* `msgHash` is the EIP-712 hash; `msgRaw` is UTF-8 hex JSON audit envelope (not RLP calldata).
|
|
61
|
+
*/
|
|
62
|
+
declare function buildEip712MultisignBody(args: BuildEip712MultisignBodyArgs): MultisignBuildResult;
|
|
63
|
+
|
|
64
|
+
/** Default MPC sign-request agreement window for fast-moving DeFi protocols (30 minutes). */
|
|
65
|
+
declare const DEFAULT_DEFI_MULTISIGN_EXPIRY_SECONDS: number;
|
|
66
|
+
/** Protocol ids that default to 30-minute expiry when `expiryDate` is omitted on multisign MCP tools. */
|
|
67
|
+
declare const DEFI_PROTOCOLS_WITH_30MIN_EXPIRY: Set<string>;
|
|
68
|
+
declare function defiMultisignExpiryUnixSeconds(protocolId: string | undefined, explicitExpiryDate?: number | null): number | undefined;
|
|
69
|
+
|
|
70
|
+
export { type BuildEip712MultisignBodyArgs, DEFAULT_DEFI_MULTISIGN_EXPIRY_SECONDS, DEFI_PROTOCOLS_WITH_30MIN_EXPIRY, EIP712_SIGN_REQUEST_KIND, type Eip712MultisignDelivery, type Eip712TypedDataField, type Eip712TypedDataPayload, KeyGenSubset, MultisignBuildResult, buildEip712MultisignBody, defiMultisignExpiryUnixSeconds, getAaveGraphqlProxyUrl, getCoingeckoProxyUrl, getEulerGraphqlProxyUrl, getMapleGraphqlProxyUrl, getMorphoGraphqlProxyUrl, mergePurposeText, postJsonViaOptionalProxy, setAaveGraphqlProxyUrl, setCoingeckoProxyUrl, setEulerGraphqlProxyUrl, setMapleGraphqlProxyUrl, setMorphoGraphqlProxyUrl };
|
package/dist/core/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getClientIdFromKeyGenResult } from '@continuumdao/continuum-node-sdk';
|
|
2
2
|
export { getClientIdFromKeyGenResult as firstClientIdFromKeyGen } from '@continuumdao/continuum-node-sdk';
|
|
3
|
+
import { hashTypedData, stringToHex } from 'viem';
|
|
3
4
|
|
|
4
5
|
// src/core/index.ts
|
|
5
6
|
|
|
@@ -34,7 +35,7 @@ function finalizeMultisign(input) {
|
|
|
34
35
|
batchMeta,
|
|
35
36
|
...input.extraJSON ?? {}
|
|
36
37
|
};
|
|
37
|
-
const extraJSON = JSON.stringify(extraPayload);
|
|
38
|
+
const extraJSON = JSON.stringify(extraPayload, (_, v) => typeof v === "bigint" ? v.toString() : v);
|
|
38
39
|
const bodyForSign = {
|
|
39
40
|
keyList,
|
|
40
41
|
pubKey: ph,
|
|
@@ -59,6 +60,9 @@ function finalizeMultisign(input) {
|
|
|
59
60
|
bodyForSign.value = valueWei.toString();
|
|
60
61
|
}
|
|
61
62
|
if (clientId) bodyForSign.clientId = clientId;
|
|
63
|
+
if (input.expiryDate != null && input.expiryDate > 0) {
|
|
64
|
+
bodyForSign.expiryDate = Math.floor(input.expiryDate);
|
|
65
|
+
}
|
|
62
66
|
return { bodyForSign, messageToSign: JSON.stringify(bodyForSign) };
|
|
63
67
|
}
|
|
64
68
|
var coreChainCategoryModule = {
|
|
@@ -147,7 +151,92 @@ async function postJsonViaOptionalProxy(args) {
|
|
|
147
151
|
}
|
|
148
152
|
return await r.json();
|
|
149
153
|
}
|
|
154
|
+
var EIP712_SIGN_REQUEST_KIND = "eip712";
|
|
155
|
+
function msgHashNo0x(digest) {
|
|
156
|
+
return digest.startsWith("0x") ? digest.slice(2) : digest;
|
|
157
|
+
}
|
|
158
|
+
function eip712SignatureText(domain, primaryType) {
|
|
159
|
+
return JSON.stringify({
|
|
160
|
+
kind: "EIP-712",
|
|
161
|
+
...typeof domain.name === "string" ? { name: domain.name } : {},
|
|
162
|
+
primaryType
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
function jsonStringifyForAudit(value) {
|
|
166
|
+
return JSON.stringify(value, (_, v) => typeof v === "bigint" ? v.toString() : v);
|
|
167
|
+
}
|
|
168
|
+
function eip712MsgRawHex(typedData, delivery) {
|
|
169
|
+
const envelope = {
|
|
170
|
+
version: 1,
|
|
171
|
+
...typedData,
|
|
172
|
+
delivery
|
|
173
|
+
};
|
|
174
|
+
return stringToHex(jsonStringifyForAudit(envelope));
|
|
175
|
+
}
|
|
176
|
+
function buildEip712MultisignBody(args) {
|
|
177
|
+
const { typedData, delivery } = args;
|
|
178
|
+
const digest = hashTypedData({
|
|
179
|
+
domain: typedData.domain,
|
|
180
|
+
types: typedData.types,
|
|
181
|
+
primaryType: typedData.primaryType,
|
|
182
|
+
message: typedData.message
|
|
183
|
+
});
|
|
184
|
+
const extraJSON = {
|
|
185
|
+
signRequestKind: EIP712_SIGN_REQUEST_KIND,
|
|
186
|
+
eip712: {
|
|
187
|
+
version: 1,
|
|
188
|
+
digest,
|
|
189
|
+
domain: typedData.domain,
|
|
190
|
+
types: typedData.types,
|
|
191
|
+
primaryType: typedData.primaryType,
|
|
192
|
+
message: typedData.message
|
|
193
|
+
},
|
|
194
|
+
delivery
|
|
195
|
+
};
|
|
196
|
+
return finalizeMultisign({
|
|
197
|
+
keyGen: args.keyGen,
|
|
198
|
+
purposeText: args.purposeText,
|
|
199
|
+
purposeSuffix: args.purposeSuffix,
|
|
200
|
+
destinationChainID: args.destinationChainID,
|
|
201
|
+
destinationAddress: args.destinationAddress,
|
|
202
|
+
extraJSON,
|
|
203
|
+
expiryDate: args.expiryDate,
|
|
204
|
+
legs: [
|
|
205
|
+
{
|
|
206
|
+
msgHash: msgHashNo0x(digest),
|
|
207
|
+
msgRaw: eip712MsgRawHex(typedData, delivery),
|
|
208
|
+
destinationAddress: args.destinationAddress,
|
|
209
|
+
signatureText: eip712SignatureText(typedData.domain, typedData.primaryType),
|
|
210
|
+
audit: {
|
|
211
|
+
kind: "EIP712",
|
|
212
|
+
primaryType: typedData.primaryType,
|
|
213
|
+
deliveryKind: delivery.kind,
|
|
214
|
+
...args.audit ?? {}
|
|
215
|
+
},
|
|
216
|
+
feeSnapshot: {}
|
|
217
|
+
}
|
|
218
|
+
]
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// src/core/expiry.ts
|
|
223
|
+
var DEFAULT_DEFI_MULTISIGN_EXPIRY_SECONDS = 30 * 60;
|
|
224
|
+
var DEFI_PROTOCOLS_WITH_30MIN_EXPIRY = /* @__PURE__ */ new Set([
|
|
225
|
+
"uniswap-v4",
|
|
226
|
+
"gmx",
|
|
227
|
+
"hyperliquid",
|
|
228
|
+
"curve-dao"
|
|
229
|
+
]);
|
|
230
|
+
function defiMultisignExpiryUnixSeconds(protocolId, explicitExpiryDate) {
|
|
231
|
+
if (typeof explicitExpiryDate === "number" && Number.isFinite(explicitExpiryDate) && explicitExpiryDate > 0) {
|
|
232
|
+
return Math.floor(explicitExpiryDate);
|
|
233
|
+
}
|
|
234
|
+
if (protocolId && DEFI_PROTOCOLS_WITH_30MIN_EXPIRY.has(protocolId)) {
|
|
235
|
+
return Math.floor(Date.now() / 1e3) + DEFAULT_DEFI_MULTISIGN_EXPIRY_SECONDS;
|
|
236
|
+
}
|
|
237
|
+
return void 0;
|
|
238
|
+
}
|
|
150
239
|
|
|
151
|
-
export { coreChainCategoryModule, finalizeMultisign, getAaveGraphqlProxyUrl, getActionsByChainCategory, getCoingeckoProxyUrl, getEulerGraphqlProxyUrl, getMapleGraphqlProxyUrl, getMorphoGraphqlProxyUrl, getProtocolModule, getProtocolModules, mergePurposeText, postJsonViaOptionalProxy, registerProtocolModule, setAaveGraphqlProxyUrl, setCoingeckoProxyUrl, setEulerGraphqlProxyUrl, setMapleGraphqlProxyUrl, setMorphoGraphqlProxyUrl };
|
|
240
|
+
export { DEFAULT_DEFI_MULTISIGN_EXPIRY_SECONDS, DEFI_PROTOCOLS_WITH_30MIN_EXPIRY, EIP712_SIGN_REQUEST_KIND, buildEip712MultisignBody, coreChainCategoryModule, defiMultisignExpiryUnixSeconds, finalizeMultisign, getAaveGraphqlProxyUrl, getActionsByChainCategory, getCoingeckoProxyUrl, getEulerGraphqlProxyUrl, getMapleGraphqlProxyUrl, getMorphoGraphqlProxyUrl, getProtocolModule, getProtocolModules, mergePurposeText, postJsonViaOptionalProxy, registerProtocolModule, setAaveGraphqlProxyUrl, setCoingeckoProxyUrl, setEulerGraphqlProxyUrl, setMapleGraphqlProxyUrl, setMorphoGraphqlProxyUrl };
|
|
152
241
|
//# sourceMappingURL=index.js.map
|
|
153
242
|
//# sourceMappingURL=index.js.map
|
package/dist/core/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,aAAiC,aAAA,EAAgC;AAChG,EAAA,MAAM,CAAA,GAAA,CAAK,WAAA,IAAe,EAAA,EAAI,IAAA,EAAK;AACnC,EAAA,MAAM,MAAA,GAAA,CAAU,aAAA,IAAiB,EAAA,EAAI,IAAA,EAAK;AAC1C,EAAA,IAAI,CAAC,QAAQ,OAAO,CAAA;AACpB,EAAA,OAAO,CAAA,GAAI,GAAG,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,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 | undefined, 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 morphoGraphqlProxyUrl: 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 setMorphoGraphqlProxyUrl(url: string | undefined): void {\n morphoGraphqlProxyUrl = url?.trim() || undefined\n}\n\nexport function getMorphoGraphqlProxyUrl(): string | undefined {\n return morphoGraphqlProxyUrl\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
|
+
{"version":3,"sources":["../../src/core/purpose.ts","../../src/core/envelope.ts","../../src/core/registry.ts","../../src/core/defiProxy.ts","../../src/core/eip712Multisign.ts","../../src/core/expiry.ts"],"names":["r"],"mappings":";;;;;;;AACO,SAAS,gBAAA,CAAiB,aAAiC,aAAA,EAAgC;AAChG,EAAA,MAAM,CAAA,GAAA,CAAK,WAAA,IAAe,EAAA,EAAI,IAAA,EAAK;AACnC,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;ACgCO,SAAS,kBAAkB,KAAA,EAAsD;AACtF,EAAA,MAAM,EAAE,MAAA,EAAQ,kBAAA,EAAoB,IAAA,EAAK,GAAI,KAAA;AAC7C,EAAA,IAAI,IAAA,CAAK,WAAW,CAAA,EAAG;AACrB,IAAA,MAAM,IAAI,MAAM,6CAA6C,CAAA;AAAA,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AAA,EAAQ,UAAU,WAAW,CAAA;AAAA,QAC1E,KAAA,EAAO;AAAA,UACL,IAAA,EAAM,QAAA;AAAA,UACN,aAAa,SAAA,CAAU,WAAA;AAAA,UACvB,cAAc,QAAA,CAAS,IAAA;AAAA,UACvB,GAAI,IAAA,CAAK,KAAA,IAAS;AAAC,SACrB;AAAA,QACA,aAAa;AAAC;AAChB;AACF,GACD,CAAA;AACH;;;ACxGO,IAAM,wCAAwC,EAAA,GAAK;AAGnD,IAAM,gCAAA,uBAAuC,GAAA,CAAI;AAAA,EACtD,YAAA;AAAA,EACA,KAAA;AAAA,EACA,aAAA;AAAA,EACA;AACF,CAAC;AAEM,SAAS,8BAAA,CACd,YACA,kBAAA,EACoB;AACpB,EAAA,IAAI,OAAO,uBAAuB,QAAA,IAAY,MAAA,CAAO,SAAS,kBAAkB,CAAA,IAAK,qBAAqB,CAAA,EAAG;AAC3G,IAAA,OAAO,IAAA,CAAK,MAAM,kBAAkB,CAAA;AAAA,EACtC;AACA,EAAA,IAAI,UAAA,IAAc,gCAAA,CAAiC,GAAA,CAAI,UAAU,CAAA,EAAG;AAClE,IAAA,OAAO,KAAK,KAAA,CAAM,IAAA,CAAK,GAAA,EAAI,GAAI,GAAI,CAAA,GAAI,qCAAA;AAAA,EACzC;AACA,EAAA,OAAO,MAAA;AACT","file":"index.js","sourcesContent":["/** Merge user purpose text with an optional batch / protocol suffix. */\nexport function mergePurposeText(purposeText: string | undefined, 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 /** Unix seconds (UTC) for mpc-auth multiSignRequest expiryDate. */\n expiryDate?: number\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, (_, v) => (typeof v === 'bigint' ? v.toString() : v))\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 if (input.expiryDate != null && input.expiryDate > 0) {\n bodyForSign.expiryDate = Math.floor(input.expiryDate)\n }\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 morphoGraphqlProxyUrl: 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 setMorphoGraphqlProxyUrl(url: string | undefined): void {\n morphoGraphqlProxyUrl = url?.trim() || undefined\n}\n\nexport function getMorphoGraphqlProxyUrl(): string | undefined {\n return morphoGraphqlProxyUrl\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","import { hashTypedData, stringToHex, type TypedDataDomain } from 'viem'\nimport type { KeyGenSubset, MultisignBuildResult } from './types.js'\nimport { finalizeMultisign } from './envelope.js'\n\nexport const EIP712_SIGN_REQUEST_KIND = 'eip712' as const\n\nexport type Eip712TypedDataField = { name: string; type: string }\n\nexport type Eip712TypedDataPayload = {\n domain: TypedDataDomain\n types: Record<string, readonly Eip712TypedDataField[] | Eip712TypedDataField[]>\n primaryType: string\n message: Record<string, unknown>\n}\n\nexport type Eip712MultisignDelivery = Record<string, unknown> & { kind: string }\n\nexport type BuildEip712MultisignBodyArgs = {\n keyGen: KeyGenSubset\n purposeText: string\n purposeSuffix?: string\n /** Chain id stored on the sign request (protocol context; may differ from EIP-712 domain chainId). */\n destinationChainID: string\n destinationAddress: string\n typedData: Eip712TypedDataPayload\n delivery: Eip712MultisignDelivery\n audit?: Record<string, unknown>\n expiryDate?: number\n}\n\nfunction msgHashNo0x(digest: `0x${string}`): string {\n return digest.startsWith('0x') ? digest.slice(2) : digest\n}\n\nfunction eip712SignatureText(domain: TypedDataDomain, primaryType: string): string {\n return JSON.stringify({\n kind: 'EIP-712',\n ...(typeof domain.name === 'string' ? { name: domain.name } : {}),\n primaryType,\n })\n}\n\nfunction jsonStringifyForAudit(value: unknown): string {\n return JSON.stringify(value, (_, v) => (typeof v === 'bigint' ? v.toString() : v))\n}\n\nfunction eip712MsgRawHex(typedData: Eip712TypedDataPayload, delivery: Eip712MultisignDelivery): string {\n const envelope = {\n version: 1,\n ...typedData,\n delivery,\n }\n return stringToHex(jsonStringifyForAudit(envelope))\n}\n\n/**\n * Build an mpc-auth multiSignRequest body for a single-leg EIP-712 digest (no EVM tx broadcast).\n * `msgHash` is the EIP-712 hash; `msgRaw` is UTF-8 hex JSON audit envelope (not RLP calldata).\n */\nexport function buildEip712MultisignBody(args: BuildEip712MultisignBodyArgs): MultisignBuildResult {\n const { typedData, delivery } = args\n const digest = hashTypedData({\n domain: typedData.domain,\n types: typedData.types,\n primaryType: typedData.primaryType,\n message: typedData.message,\n })\n\n const extraJSON: Record<string, unknown> = {\n signRequestKind: EIP712_SIGN_REQUEST_KIND,\n eip712: {\n version: 1,\n digest,\n domain: typedData.domain,\n types: typedData.types,\n primaryType: typedData.primaryType,\n message: typedData.message,\n },\n delivery,\n }\n\n return finalizeMultisign({\n keyGen: args.keyGen,\n purposeText: args.purposeText,\n purposeSuffix: args.purposeSuffix,\n destinationChainID: args.destinationChainID,\n destinationAddress: args.destinationAddress,\n extraJSON,\n expiryDate: args.expiryDate,\n legs: [\n {\n msgHash: msgHashNo0x(digest),\n msgRaw: eip712MsgRawHex(typedData, delivery),\n destinationAddress: args.destinationAddress,\n signatureText: eip712SignatureText(typedData.domain, typedData.primaryType),\n audit: {\n kind: 'EIP712',\n primaryType: typedData.primaryType,\n deliveryKind: delivery.kind,\n ...(args.audit ?? {}),\n },\n feeSnapshot: {},\n },\n ],\n })\n}\n","/** Default MPC sign-request agreement window for fast-moving DeFi protocols (30 minutes). */\nexport const DEFAULT_DEFI_MULTISIGN_EXPIRY_SECONDS = 30 * 60\n\n/** Protocol ids that default to 30-minute expiry when `expiryDate` is omitted on multisign MCP tools. */\nexport const DEFI_PROTOCOLS_WITH_30MIN_EXPIRY = new Set([\n 'uniswap-v4',\n 'gmx',\n 'hyperliquid',\n 'curve-dao',\n])\n\nexport function defiMultisignExpiryUnixSeconds(\n protocolId: string | undefined,\n explicitExpiryDate?: number | null,\n): number | undefined {\n if (typeof explicitExpiryDate === 'number' && Number.isFinite(explicitExpiryDate) && explicitExpiryDate > 0) {\n return Math.floor(explicitExpiryDate)\n }\n if (protocolId && DEFI_PROTOCOLS_WITH_30MIN_EXPIRY.has(protocolId)) {\n return Math.floor(Date.now() / 1000) + DEFAULT_DEFI_MULTISIGN_EXPIRY_SECONDS\n }\n return undefined\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { K as KeyGenSubset, C as ChainCategory, M as MultisignBuildResult } from './types-
|
|
1
|
+
import { K as KeyGenSubset, C as ChainCategory, M as MultisignBuildResult } from './types-PZrvtjv8.js';
|
|
2
2
|
|
|
3
3
|
interface MultisignLeg {
|
|
4
4
|
msgHash: string;
|
|
@@ -20,6 +20,8 @@ interface ChainCategoryBuildInput {
|
|
|
20
20
|
extraJSON?: Record<string, unknown>;
|
|
21
21
|
/** Top-level destination address (first leg destination if omitted) */
|
|
22
22
|
destinationAddress?: string;
|
|
23
|
+
/** Unix seconds (UTC) for mpc-auth multiSignRequest expiryDate. */
|
|
24
|
+
expiryDate?: number;
|
|
23
25
|
}
|
|
24
26
|
interface ChainCategoryModule {
|
|
25
27
|
category: ChainCategory;
|
package/dist/index.cjs
CHANGED
|
@@ -36,7 +36,7 @@ function finalizeMultisign(input) {
|
|
|
36
36
|
batchMeta,
|
|
37
37
|
...input.extraJSON ?? {}
|
|
38
38
|
};
|
|
39
|
-
const extraJSON = JSON.stringify(extraPayload);
|
|
39
|
+
const extraJSON = JSON.stringify(extraPayload, (_, v) => typeof v === "bigint" ? v.toString() : v);
|
|
40
40
|
const bodyForSign = {
|
|
41
41
|
keyList,
|
|
42
42
|
pubKey: ph,
|
|
@@ -61,6 +61,9 @@ function finalizeMultisign(input) {
|
|
|
61
61
|
bodyForSign.value = valueWei.toString();
|
|
62
62
|
}
|
|
63
63
|
if (clientId) bodyForSign.clientId = clientId;
|
|
64
|
+
if (input.expiryDate != null && input.expiryDate > 0) {
|
|
65
|
+
bodyForSign.expiryDate = Math.floor(input.expiryDate);
|
|
66
|
+
}
|
|
64
67
|
return { bodyForSign, messageToSign: JSON.stringify(bodyForSign) };
|
|
65
68
|
}
|
|
66
69
|
var coreChainCategoryModule = {
|
|
@@ -149,6 +152,91 @@ async function postJsonViaOptionalProxy(args) {
|
|
|
149
152
|
}
|
|
150
153
|
return await r.json();
|
|
151
154
|
}
|
|
155
|
+
var EIP712_SIGN_REQUEST_KIND = "eip712";
|
|
156
|
+
function msgHashNo0x(digest) {
|
|
157
|
+
return digest.startsWith("0x") ? digest.slice(2) : digest;
|
|
158
|
+
}
|
|
159
|
+
function eip712SignatureText(domain, primaryType) {
|
|
160
|
+
return JSON.stringify({
|
|
161
|
+
kind: "EIP-712",
|
|
162
|
+
...typeof domain.name === "string" ? { name: domain.name } : {},
|
|
163
|
+
primaryType
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
function jsonStringifyForAudit(value) {
|
|
167
|
+
return JSON.stringify(value, (_, v) => typeof v === "bigint" ? v.toString() : v);
|
|
168
|
+
}
|
|
169
|
+
function eip712MsgRawHex(typedData, delivery) {
|
|
170
|
+
const envelope = {
|
|
171
|
+
version: 1,
|
|
172
|
+
...typedData,
|
|
173
|
+
delivery
|
|
174
|
+
};
|
|
175
|
+
return viem.stringToHex(jsonStringifyForAudit(envelope));
|
|
176
|
+
}
|
|
177
|
+
function buildEip712MultisignBody(args) {
|
|
178
|
+
const { typedData, delivery } = args;
|
|
179
|
+
const digest = viem.hashTypedData({
|
|
180
|
+
domain: typedData.domain,
|
|
181
|
+
types: typedData.types,
|
|
182
|
+
primaryType: typedData.primaryType,
|
|
183
|
+
message: typedData.message
|
|
184
|
+
});
|
|
185
|
+
const extraJSON = {
|
|
186
|
+
signRequestKind: EIP712_SIGN_REQUEST_KIND,
|
|
187
|
+
eip712: {
|
|
188
|
+
version: 1,
|
|
189
|
+
digest,
|
|
190
|
+
domain: typedData.domain,
|
|
191
|
+
types: typedData.types,
|
|
192
|
+
primaryType: typedData.primaryType,
|
|
193
|
+
message: typedData.message
|
|
194
|
+
},
|
|
195
|
+
delivery
|
|
196
|
+
};
|
|
197
|
+
return finalizeMultisign({
|
|
198
|
+
keyGen: args.keyGen,
|
|
199
|
+
purposeText: args.purposeText,
|
|
200
|
+
purposeSuffix: args.purposeSuffix,
|
|
201
|
+
destinationChainID: args.destinationChainID,
|
|
202
|
+
destinationAddress: args.destinationAddress,
|
|
203
|
+
extraJSON,
|
|
204
|
+
expiryDate: args.expiryDate,
|
|
205
|
+
legs: [
|
|
206
|
+
{
|
|
207
|
+
msgHash: msgHashNo0x(digest),
|
|
208
|
+
msgRaw: eip712MsgRawHex(typedData, delivery),
|
|
209
|
+
destinationAddress: args.destinationAddress,
|
|
210
|
+
signatureText: eip712SignatureText(typedData.domain, typedData.primaryType),
|
|
211
|
+
audit: {
|
|
212
|
+
kind: "EIP712",
|
|
213
|
+
primaryType: typedData.primaryType,
|
|
214
|
+
deliveryKind: delivery.kind,
|
|
215
|
+
...args.audit ?? {}
|
|
216
|
+
},
|
|
217
|
+
feeSnapshot: {}
|
|
218
|
+
}
|
|
219
|
+
]
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// src/core/expiry.ts
|
|
224
|
+
var DEFAULT_DEFI_MULTISIGN_EXPIRY_SECONDS = 30 * 60;
|
|
225
|
+
var DEFI_PROTOCOLS_WITH_30MIN_EXPIRY = /* @__PURE__ */ new Set([
|
|
226
|
+
"uniswap-v4",
|
|
227
|
+
"gmx",
|
|
228
|
+
"hyperliquid",
|
|
229
|
+
"curve-dao"
|
|
230
|
+
]);
|
|
231
|
+
function defiMultisignExpiryUnixSeconds(protocolId, explicitExpiryDate) {
|
|
232
|
+
if (typeof explicitExpiryDate === "number" && Number.isFinite(explicitExpiryDate) && explicitExpiryDate > 0) {
|
|
233
|
+
return Math.floor(explicitExpiryDate);
|
|
234
|
+
}
|
|
235
|
+
if (protocolId && DEFI_PROTOCOLS_WITH_30MIN_EXPIRY.has(protocolId)) {
|
|
236
|
+
return Math.floor(Date.now() / 1e3) + DEFAULT_DEFI_MULTISIGN_EXPIRY_SECONDS;
|
|
237
|
+
}
|
|
238
|
+
return void 0;
|
|
239
|
+
}
|
|
152
240
|
function isEvmNativeToken(address) {
|
|
153
241
|
try {
|
|
154
242
|
return viem.getAddress(address) === viem.zeroAddress;
|
|
@@ -324,7 +412,8 @@ async function buildEvmMultisignBatch(args) {
|
|
|
324
412
|
destinationChainID: String(chainId),
|
|
325
413
|
destinationAddress: args.destinationAddress ?? steps[0].to,
|
|
326
414
|
legs,
|
|
327
|
-
extraJSON: Object.keys(extraJSON).length > 0 ? extraJSON : void 0
|
|
415
|
+
extraJSON: Object.keys(extraJSON).length > 0 ? extraJSON : void 0,
|
|
416
|
+
expiryDate: context.expiryDate
|
|
328
417
|
});
|
|
329
418
|
const pv = args.payableValueWei;
|
|
330
419
|
if (pv != null && pv > 0n) {
|
|
@@ -2622,15 +2711,20 @@ Object.defineProperty(exports, "firstClientIdFromKeyGen", {
|
|
|
2622
2711
|
get: function () { return continuumNodeSdk.getClientIdFromKeyGenResult; }
|
|
2623
2712
|
});
|
|
2624
2713
|
exports.COINGECKO_PLATFORM_BY_CHAIN_ID = COINGECKO_PLATFORM_BY_CHAIN_ID;
|
|
2714
|
+
exports.DEFAULT_DEFI_MULTISIGN_EXPIRY_SECONDS = DEFAULT_DEFI_MULTISIGN_EXPIRY_SECONDS;
|
|
2715
|
+
exports.DEFI_PROTOCOLS_WITH_30MIN_EXPIRY = DEFI_PROTOCOLS_WITH_30MIN_EXPIRY;
|
|
2716
|
+
exports.EIP712_SIGN_REQUEST_KIND = EIP712_SIGN_REQUEST_KIND;
|
|
2625
2717
|
exports.NEAR_CHAIN_CATEGORY = NEAR_CHAIN_CATEGORY;
|
|
2626
2718
|
exports.SOLANA_CHAIN_CATEGORY = SOLANA_CHAIN_CATEGORY;
|
|
2627
2719
|
exports.approveStepsToEvmTxSteps = approveStepsToEvmTxSteps;
|
|
2628
2720
|
exports.buildConditionalErc20ApproveSteps = buildConditionalErc20ApproveSteps;
|
|
2721
|
+
exports.buildEip712MultisignBody = buildEip712MultisignBody;
|
|
2629
2722
|
exports.buildEvmMultisignBatch = buildEvmMultisignBatch;
|
|
2630
2723
|
exports.coingeckoPlatformForChainId = coingeckoPlatformForChainId;
|
|
2631
2724
|
exports.coreChainCategoryModule = coreChainCategoryModule;
|
|
2632
2725
|
exports.curveDao = curveDao;
|
|
2633
2726
|
exports.curveDaoProtocolModule = curveDaoProtocolModule;
|
|
2727
|
+
exports.defiMultisignExpiryUnixSeconds = defiMultisignExpiryUnixSeconds;
|
|
2634
2728
|
exports.evmChainCategoryModule = evmChainCategoryModule;
|
|
2635
2729
|
exports.finalizeMultisign = finalizeMultisign;
|
|
2636
2730
|
exports.getAaveGraphqlProxyUrl = getAaveGraphqlProxyUrl;
|