@continuumdao/ctm-mpc-defi 0.2.20 → 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 +118 -37
- package/dist/agent/catalog.cjs.map +1 -1
- package/dist/agent/catalog.d.ts +310 -97
- package/dist/agent/catalog.js +117 -38
- package/dist/agent/catalog.js.map +1 -1
- package/dist/agent/skills/uniswap-v4/SKILL.md +58 -0
- package/dist/chains/evm/index.cjs +5 -1
- package/dist/chains/evm/index.cjs.map +1 -1
- package/dist/chains/evm/index.d.ts +4 -4
- package/dist/chains/evm/index.js +5 -1
- 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 +25 -0
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.ts +12 -5
- package/dist/core/index.js +23 -1
- 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 +27 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +25 -2
- package/dist/index.js.map +1 -1
- package/dist/protocols/evm/aave-v4/index.cjs +5 -1
- 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 +5 -1
- package/dist/protocols/evm/aave-v4/index.js.map +1 -1
- package/dist/protocols/evm/circle-cctp/index.cjs +5 -1
- 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 +5 -1
- package/dist/protocols/evm/circle-cctp/index.js.map +1 -1
- package/dist/protocols/evm/curve-dao/index.cjs +5 -1
- 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 +5 -1
- package/dist/protocols/evm/curve-dao/index.js.map +1 -1
- package/dist/protocols/evm/ethena/index.cjs +5 -1
- 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 +5 -1
- package/dist/protocols/evm/ethena/index.js.map +1 -1
- package/dist/protocols/evm/euler-v2/index.cjs +5 -1
- 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 +5 -1
- package/dist/protocols/evm/euler-v2/index.js.map +1 -1
- package/dist/protocols/evm/gmx/index.cjs +5 -1
- package/dist/protocols/evm/gmx/index.cjs.map +1 -1
- package/dist/protocols/evm/gmx/index.d.ts +2 -2
- package/dist/protocols/evm/gmx/index.js +5 -1
- package/dist/protocols/evm/gmx/index.js.map +1 -1
- package/dist/protocols/evm/hyperliquid/index.cjs +6 -1
- package/dist/protocols/evm/hyperliquid/index.cjs.map +1 -1
- package/dist/protocols/evm/hyperliquid/index.d.ts +2 -2
- package/dist/protocols/evm/hyperliquid/index.js +6 -1
- package/dist/protocols/evm/hyperliquid/index.js.map +1 -1
- package/dist/protocols/evm/lido/index.cjs +5 -1
- 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 +5 -1
- package/dist/protocols/evm/lido/index.js.map +1 -1
- package/dist/protocols/evm/maple/index.cjs +5 -1
- 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 +5 -1
- package/dist/protocols/evm/maple/index.js.map +1 -1
- package/dist/protocols/evm/morpho/index.cjs +5 -1
- 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 +5 -1
- package/dist/protocols/evm/morpho/index.js.map +1 -1
- package/dist/protocols/evm/permit2/index.cjs +4 -0
- package/dist/protocols/evm/permit2/index.cjs.map +1 -1
- package/dist/protocols/evm/permit2/index.d.ts +1 -1
- package/dist/protocols/evm/permit2/index.js +4 -0
- package/dist/protocols/evm/permit2/index.js.map +1 -1
- package/dist/protocols/evm/sky/index.cjs +5 -1
- 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 +5 -1
- package/dist/protocols/evm/sky/index.js.map +1 -1
- package/dist/protocols/evm/uniswap-v4/index.cjs +684 -1
- 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 +662 -2
- 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 +2 -2
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","../../src/core/eip712Multisign.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,QAAQ,OAAO,CAAA;AACpB,EAAA,OAAO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,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","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, (_, 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 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}\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 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"]}
|
|
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,E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AA,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,8 +1,8 @@
|
|
|
1
|
-
import { K as KeyGenSubset, M as MultisignBuildResult } from '../types-
|
|
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-
|
|
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';
|
|
3
3
|
export { getClientIdFromKeyGenResult as firstClientIdFromKeyGen } from '@continuumdao/continuum-node-sdk';
|
|
4
|
-
export { C as ChainCategoryBuildInput, a as ChainCategoryModule, M as MultisignLeg, c as coreChainCategoryModule, f as finalizeMultisign } from '../envelope-
|
|
5
|
-
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
6
|
import { TypedDataDomain } from 'viem';
|
|
7
7
|
|
|
8
8
|
/** Merge user purpose text with an optional batch / protocol suffix. */
|
|
@@ -53,6 +53,7 @@ type BuildEip712MultisignBodyArgs = {
|
|
|
53
53
|
typedData: Eip712TypedDataPayload;
|
|
54
54
|
delivery: Eip712MultisignDelivery;
|
|
55
55
|
audit?: Record<string, unknown>;
|
|
56
|
+
expiryDate?: number;
|
|
56
57
|
};
|
|
57
58
|
/**
|
|
58
59
|
* Build an mpc-auth multiSignRequest body for a single-leg EIP-712 digest (no EVM tx broadcast).
|
|
@@ -60,4 +61,10 @@ type BuildEip712MultisignBodyArgs = {
|
|
|
60
61
|
*/
|
|
61
62
|
declare function buildEip712MultisignBody(args: BuildEip712MultisignBodyArgs): MultisignBuildResult;
|
|
62
63
|
|
|
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
|
@@ -60,6 +60,9 @@ function finalizeMultisign(input) {
|
|
|
60
60
|
bodyForSign.value = valueWei.toString();
|
|
61
61
|
}
|
|
62
62
|
if (clientId) bodyForSign.clientId = clientId;
|
|
63
|
+
if (input.expiryDate != null && input.expiryDate > 0) {
|
|
64
|
+
bodyForSign.expiryDate = Math.floor(input.expiryDate);
|
|
65
|
+
}
|
|
63
66
|
return { bodyForSign, messageToSign: JSON.stringify(bodyForSign) };
|
|
64
67
|
}
|
|
65
68
|
var coreChainCategoryModule = {
|
|
@@ -197,6 +200,7 @@ function buildEip712MultisignBody(args) {
|
|
|
197
200
|
destinationChainID: args.destinationChainID,
|
|
198
201
|
destinationAddress: args.destinationAddress,
|
|
199
202
|
extraJSON,
|
|
203
|
+
expiryDate: args.expiryDate,
|
|
200
204
|
legs: [
|
|
201
205
|
{
|
|
202
206
|
msgHash: msgHashNo0x(digest),
|
|
@@ -215,6 +219,24 @@ function buildEip712MultisignBody(args) {
|
|
|
215
219
|
});
|
|
216
220
|
}
|
|
217
221
|
|
|
218
|
-
|
|
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
|
+
}
|
|
239
|
+
|
|
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 };
|
|
219
241
|
//# sourceMappingURL=index.js.map
|
|
220
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","../../src/core/eip712Multisign.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;AC8BO,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,EAC/D;AAEA,E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AAChB;AACF,GACD,CAAA;AACH","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, (_, 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 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}\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 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"]}
|
|
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,IAA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3C,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.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
|
@@ -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 = {
|
|
@@ -198,6 +201,7 @@ function buildEip712MultisignBody(args) {
|
|
|
198
201
|
destinationChainID: args.destinationChainID,
|
|
199
202
|
destinationAddress: args.destinationAddress,
|
|
200
203
|
extraJSON,
|
|
204
|
+
expiryDate: args.expiryDate,
|
|
201
205
|
legs: [
|
|
202
206
|
{
|
|
203
207
|
msgHash: msgHashNo0x(digest),
|
|
@@ -215,6 +219,24 @@ function buildEip712MultisignBody(args) {
|
|
|
215
219
|
]
|
|
216
220
|
});
|
|
217
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
|
+
}
|
|
218
240
|
function isEvmNativeToken(address) {
|
|
219
241
|
try {
|
|
220
242
|
return viem.getAddress(address) === viem.zeroAddress;
|
|
@@ -390,7 +412,8 @@ async function buildEvmMultisignBatch(args) {
|
|
|
390
412
|
destinationChainID: String(chainId),
|
|
391
413
|
destinationAddress: args.destinationAddress ?? steps[0].to,
|
|
392
414
|
legs,
|
|
393
|
-
extraJSON: Object.keys(extraJSON).length > 0 ? extraJSON : void 0
|
|
415
|
+
extraJSON: Object.keys(extraJSON).length > 0 ? extraJSON : void 0,
|
|
416
|
+
expiryDate: context.expiryDate
|
|
394
417
|
});
|
|
395
418
|
const pv = args.payableValueWei;
|
|
396
419
|
if (pv != null && pv > 0n) {
|
|
@@ -2688,6 +2711,8 @@ Object.defineProperty(exports, "firstClientIdFromKeyGen", {
|
|
|
2688
2711
|
get: function () { return continuumNodeSdk.getClientIdFromKeyGenResult; }
|
|
2689
2712
|
});
|
|
2690
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;
|
|
2691
2716
|
exports.EIP712_SIGN_REQUEST_KIND = EIP712_SIGN_REQUEST_KIND;
|
|
2692
2717
|
exports.NEAR_CHAIN_CATEGORY = NEAR_CHAIN_CATEGORY;
|
|
2693
2718
|
exports.SOLANA_CHAIN_CATEGORY = SOLANA_CHAIN_CATEGORY;
|
|
@@ -2699,6 +2724,7 @@ exports.coingeckoPlatformForChainId = coingeckoPlatformForChainId;
|
|
|
2699
2724
|
exports.coreChainCategoryModule = coreChainCategoryModule;
|
|
2700
2725
|
exports.curveDao = curveDao;
|
|
2701
2726
|
exports.curveDaoProtocolModule = curveDaoProtocolModule;
|
|
2727
|
+
exports.defiMultisignExpiryUnixSeconds = defiMultisignExpiryUnixSeconds;
|
|
2702
2728
|
exports.evmChainCategoryModule = evmChainCategoryModule;
|
|
2703
2729
|
exports.finalizeMultisign = finalizeMultisign;
|
|
2704
2730
|
exports.getAaveGraphqlProxyUrl = getAaveGraphqlProxyUrl;
|