@continuumdao/ctm-mpc-defi 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -78
- package/dist/agent/catalog.cjs +511 -4
- package/dist/agent/catalog.cjs.map +1 -1
- package/dist/agent/catalog.d.ts +140 -20
- package/dist/agent/catalog.js +501 -6
- package/dist/agent/catalog.js.map +1 -1
- package/dist/agent/skills/aave-v4/SKILL.md +43 -0
- package/dist/agent/skills/curve-dao/SKILL.md +12 -0
- package/dist/agent/skills/ethena/SKILL.md +10 -0
- package/dist/agent/skills/euler-v2/SKILL.md +10 -0
- package/dist/agent/skills/lido/SKILL.md +22 -0
- package/dist/agent/skills/maple-syrup/SKILL.md +10 -0
- package/dist/agent/skills/sky/SKILL.md +10 -0
- package/dist/agent/skills/uniswap-v4/SKILL.md +22 -0
- package/dist/chains/evm/index.cjs +27 -226
- package/dist/chains/evm/index.cjs.map +1 -1
- package/dist/chains/evm/index.d.ts +14 -26
- package/dist/chains/evm/index.js +21 -211
- 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 +8 -110
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.ts +5 -39
- package/dist/core/index.js +6 -100
- package/dist/core/index.js.map +1 -1
- package/dist/{envelope-CcE5Cz_q.d.ts → envelope-CpBUh9eP.d.ts} +1 -1
- package/dist/index.cjs +238 -1868
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +7 -11
- package/dist/index.js +227 -1839
- package/dist/index.js.map +1 -1
- package/dist/protocols/evm/aave-v4/index.cjs +385 -662
- package/dist/protocols/evm/aave-v4/index.cjs.map +1 -1
- package/dist/protocols/evm/aave-v4/index.d.ts +1 -2
- package/dist/protocols/evm/aave-v4/index.js +385 -662
- package/dist/protocols/evm/aave-v4/index.js.map +1 -1
- package/dist/protocols/evm/curve-dao/index.cjs +24 -124
- package/dist/protocols/evm/curve-dao/index.cjs.map +1 -1
- package/dist/protocols/evm/curve-dao/index.d.ts +3 -4
- package/dist/protocols/evm/curve-dao/index.js +15 -115
- package/dist/protocols/evm/curve-dao/index.js.map +1 -1
- package/dist/protocols/evm/ethena/index.cjs +290 -402
- package/dist/protocols/evm/ethena/index.cjs.map +1 -1
- package/dist/protocols/evm/ethena/index.d.ts +1 -2
- package/dist/protocols/evm/ethena/index.js +291 -403
- package/dist/protocols/evm/ethena/index.js.map +1 -1
- package/dist/protocols/evm/euler-v2/index.cjs +485 -1163
- package/dist/protocols/evm/euler-v2/index.cjs.map +1 -1
- package/dist/protocols/evm/euler-v2/index.d.ts +1 -2
- package/dist/protocols/evm/euler-v2/index.js +486 -1164
- package/dist/protocols/evm/euler-v2/index.js.map +1 -1
- package/dist/protocols/evm/lido/index.cjs +241 -236
- package/dist/protocols/evm/lido/index.cjs.map +1 -1
- package/dist/protocols/evm/lido/index.d.ts +1 -2
- package/dist/protocols/evm/lido/index.js +242 -237
- package/dist/protocols/evm/lido/index.js.map +1 -1
- package/dist/protocols/evm/maple/index.cjs +310 -398
- package/dist/protocols/evm/maple/index.cjs.map +1 -1
- package/dist/protocols/evm/maple/index.d.ts +1 -2
- package/dist/protocols/evm/maple/index.js +311 -399
- package/dist/protocols/evm/maple/index.js.map +1 -1
- package/dist/protocols/evm/sky/index.cjs +238 -233
- package/dist/protocols/evm/sky/index.cjs.map +1 -1
- package/dist/protocols/evm/sky/index.d.ts +1 -2
- package/dist/protocols/evm/sky/index.js +236 -231
- package/dist/protocols/evm/sky/index.js.map +1 -1
- package/dist/protocols/evm/uniswap-v4/index.cjs +423 -658
- package/dist/protocols/evm/uniswap-v4/index.cjs.map +1 -1
- package/dist/protocols/evm/uniswap-v4/index.d.ts +3 -4
- package/dist/protocols/evm/uniswap-v4/index.js +422 -657
- package/dist/protocols/evm/uniswap-v4/index.js.map +1 -1
- package/dist/{registry-oMKlO_5z.d.ts → registry-Bv5o37_w.d.ts} +1 -1
- package/dist/{types-Ce2qNHai.d.cts → types-BfjWdw1j.d.ts} +3 -1
- package/dist/{types-5u863Fd9.d.ts → types-DUeNJLr9.d.ts} +1 -1
- package/package.json +7 -6
- package/dist/agent/catalog.d.cts +0 -939
- package/dist/chains/evm/index.d.cts +0 -64
- package/dist/chains/near/index.d.cts +0 -37
- package/dist/chains/solana/index.d.cts +0 -40
- package/dist/core/index.d.cts +0 -43
- package/dist/envelope-DYDPnrHZ.d.cts +0 -35
- package/dist/index.d.cts +0 -16
- package/dist/keygen-CfNp8yKJ.d.cts +0 -9
- package/dist/keygen-DsINazx8.d.ts +0 -9
- package/dist/nodeRead-BnmSaMGO.d.cts +0 -8
- package/dist/nodeRead-BnmSaMGO.d.ts +0 -8
- package/dist/protocols/evm/aave-v4/index.d.cts +0 -500
- package/dist/protocols/evm/curve-dao/index.d.cts +0 -147
- package/dist/protocols/evm/ethena/index.d.cts +0 -161
- package/dist/protocols/evm/euler-v2/index.d.cts +0 -317
- package/dist/protocols/evm/lido/index.d.cts +0 -120
- package/dist/protocols/evm/maple/index.d.cts +0 -109
- package/dist/protocols/evm/sky/index.d.cts +0 -218
- package/dist/protocols/evm/uniswap-v4/index.d.cts +0 -324
- package/dist/registry-BwZoE668.d.cts +0 -8
- package/dist/txParams-BC7ogvdR.d.cts +0 -19
- package/dist/txParams-BC7ogvdR.d.ts +0 -19
- package/dist/types-B8idm_gu.d.cts +0 -34
- package/dist/types-Ce2qNHai.d.ts +0 -57
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/chains/evm/types.ts","../../../src/chains/evm/txParams.ts","../../../src/core/keygen.ts","../../../src/core/purpose.ts","../../../src/core/envelope.ts","../../../src/chains/evm/fees/chainFees.ts","../../../src/chains/evm/fees/eip1559Align.ts","../../../src/chains/evm/buildBatch.ts","../../../src/chains/evm/fees/customGas.ts","../../../src/chains/evm/chainIdParse.ts","../../../src/chains/evm/rpcUrl.ts"],"names":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I,MAAA,CAAO,QAAA,CAAS,IAAA,EAAM,EAAE,CAAA;AAClC,IAAA,OAAO,OAAO,KAAA,CAAM,CAAC,KAAK,CAAA,GAAI,CAAA,GAAI,OAAO,GAAA,GAAM,CAAA;AAAA,EACjD;AACA,EAAA,IAAI,GAAA,CAAI,UAAA,CAAW,IAAI,CAAA,EAAG;AACxB,IAAA,OAAO,MAAA,CAAO,QAAA,CAAS,CAAA,EAAG,EAAE,CAAA;AAAA,EAC9B;AACA,EAAA,OAAO,MAAA,CAAO,QAAA,CAAS,CAAA,EAAG,EAAE,CAAA;AAC9B;;;ACtBO,SAAS,cAAc,GAAA,EAAsB;AAClD,EAAA,MAAM,CAAA,GAAI,IAAI,IAAA,EAAK;AACnB,EAAA,IAAI,CAAC,GAAG,OAAO,KAAA;AACf,EAAA,IAAI;AACF,IAAA,MAAM,CAAA,GAAI,IAAI,GAAA,CAAI,CAAC,CAAA;AACnB,IAAA,OAAO,CAAA,CAAE,QAAA,KAAa,OAAA,IAAW,CAAA,CAAE,QAAA,KAAa,QAAA;AAAA,EAClD,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,KAAA;AAAA,EACT;AACF","file":"index.js","sourcesContent":["import type { EvmTokenKind, MultisignCommonArgs } from '../../core/types.js'\nimport { getAddress, zeroAddress, type Address } from 'viem'\n\nexport type EvmChainDetail = {\n legacy?: boolean\n gasLimit?: number\n gasMultiplier?: number\n gasPrice?: number\n baseFee?: number\n priorityFee?: number\n baseFeeMultiplier?: number\n}\n\nexport interface EvmProtocolContext extends MultisignCommonArgs {\n chainCategory: 'evm'\n chainId: number\n rpcUrl: string\n executorAddress: Address\n chainDetail: EvmChainDetail\n useCustomGas: boolean\n customGasChainDetails?: Record<string, unknown> | null\n}\n\nexport type EvmTxStep = {\n to: Address\n data: `0x${string}`\n value: bigint\n /** Fallback when estimateGas reverts */\n fallbackGas?: bigint\n /** When set, use routerSwapGasLimitFromEstimate instead of plain estimate */\n routerSwap?: boolean\n}\n\nexport function isEvmNativeToken(address: string): boolean {\n try {\n return getAddress(address as `0x${string}`) === zeroAddress\n } catch {\n return address.toLowerCase() === zeroAddress\n }\n}\n\nexport function matchEvmTokenKind(\n kind: EvmTokenKind,\n address: string,\n): boolean {\n if (kind === 'native') return isEvmNativeToken(address)\n if (kind === 'erc20' || kind === 'ctmerc20' || kind === 'ctmrwa1') {\n return !isEvmNativeToken(address)\n }\n return true\n}\n","/**\n * Proposal-time EVM fields for POST /multiSignRequest (mpc-auth).\n * Same shape as trigger txParams and GET /getSignRequestById?tx_params=1.\n */\n\nexport type ProposalTxParams = {\n nonce: number\n gasLimit: string\n txType: 'eip1559' | 'legacy'\n maxFeePerGas?: string\n maxPriorityFeePerGas?: string\n gasPrice?: string\n}\n\nexport function gasLimitFromEstimateAndChainConfig(\n estimatedGas: bigint,\n chainGasLimit?: number,\n): bigint {\n if (chainGasLimit == null || !Number.isFinite(chainGasLimit) || chainGasLimit <= 0) {\n return estimatedGas\n }\n const cfg = BigInt(Math.floor(chainGasLimit))\n return cfg > estimatedGas ? cfg : estimatedGas\n}\n\nexport function routerSwapGasLimitFromEstimate(\n estimatedGas: bigint,\n chainGasLimit?: number | null,\n): bigint {\n if (chainGasLimit != null && Number.isFinite(chainGasLimit) && chainGasLimit > 0) {\n return gasLimitFromEstimateAndChainConfig(estimatedGas, chainGasLimit)\n }\n return (estimatedGas * 12n + 9n) / 10n\n}\n\nexport function composeFeePayloadToTxParams(\n p: Record<string, unknown>,\n legacy: boolean,\n): ProposalTxParams | undefined {\n const gl = p.txGasLimit ?? p.txgaslimit\n if (gl == null || String(gl).trim() === '') return undefined\n const n = p.txNonce ?? p.txnonce\n let nonce = 0\n if (typeof n === 'bigint') nonce = Number(n)\n else if (typeof n === 'number') nonce = n\n else if (n != null) nonce = parseInt(String(n), 10)\n if (!Number.isFinite(nonce)) nonce = 0\n const gasLimit = String(gl)\n if (legacy) {\n const gp = p.txGasPrice ?? p.txgasprice\n return {\n nonce,\n gasLimit,\n txType: 'legacy',\n gasPrice: gp != null ? String(gp) : '0',\n }\n }\n return {\n nonce,\n gasLimit,\n txType: 'eip1559',\n maxFeePerGas: String(p.txMaxFeePerGas ?? ''),\n maxPriorityFeePerGas: String(p.txMaxPriorityFeePerGas ?? ''),\n }\n}\n\nexport function triggerTxParamsFromComposeBody(body: Record<string, unknown>): ProposalTxParams {\n const existing = body.txParams\n if (existing && typeof existing === 'object' && !Array.isArray(existing)) {\n const o = existing as ProposalTxParams & { gasLimit?: string }\n if (String(o.gasLimit ?? '').trim() !== '') {\n return { ...o }\n }\n }\n const pb = body.proposalTxParams\n if (Array.isArray(pb) && pb.length > 0 && typeof pb[0] === 'object' && pb[0] !== null) {\n const first = pb[0] as ProposalTxParams & { gasLimit?: string }\n if (String(first.gasLimit ?? '').trim() !== '') {\n return { ...first }\n }\n }\n const fromSnapshot = composeFeePayloadToTxParams(\n body,\n body.txMaxFeePerGas == null && body.txMaxPriorityFeePerGas == null,\n )\n if (fromSnapshot) return fromSnapshot\n return {\n nonce: 0,\n gasLimit: '',\n txType: 'legacy',\n gasPrice: '0',\n }\n}\n\nexport function proposalTxParamsToFeeSnapshot(\n params: ProposalTxParams,\n): Record<string, unknown> {\n if (params.txType === 'legacy') {\n return {\n txNonce: params.nonce,\n txGasLimit: params.gasLimit,\n txGasPrice: params.gasPrice ?? '0',\n }\n }\n return {\n txNonce: params.nonce,\n txGasLimit: params.gasLimit,\n txMaxFeePerGas: params.maxFeePerGas ?? '',\n txMaxPriorityFeePerGas: params.maxPriorityFeePerGas ?? '',\n }\n}\n","import type { KeyGenSubset } from './types.js'\n\nexport type { KeyGenSubset }\n\n/** App-compatible alias used by existing multisign builders. */\nexport type KeyGenSubsetForPermit = KeyGenSubset\n\nexport function firstClientIdFromKeyGen(data: KeyGenSubset | null | undefined): string | null {\n const map = data?.ClientKeys\n if (!map || typeof map !== 'object') return null\n for (const v of Object.values(map)) {\n if (typeof v === 'string' && v.trim()) return v.trim()\n }\n return null\n}\n\nexport function requirePubKeyHex(keyGen: KeyGenSubset): string {\n const ph = (keyGen.pubkeyhex ?? '').trim()\n if (!ph) throw new Error('keyGen pubKey (pubkeyhex) is required')\n return ph\n}\n\nexport function keyListFromKeyGen(keyGen: KeyGenSubset): string[] {\n return keyGen.keylist ?? []\n}\n","/** Merge user purpose text with an optional batch / protocol suffix. */\nexport function mergePurposeText(purposeText: string, purposeSuffix?: string): string {\n const t = purposeText.trim()\n const suffix = (purposeSuffix ?? '').trim()\n if (!suffix) return t\n return t ? `${t}\\n\\n${suffix}` : suffix\n}\n","import type { ChainCategory, MultisignBuildResult } from './types.js'\nimport type { KeyGenSubset } from './keygen.js'\nimport { firstClientIdFromKeyGen } from './keygen.js'\nimport { mergePurposeText } from './purpose.js'\n\nexport interface MultisignLeg {\n msgHash: string\n msgRaw: string\n destinationAddress: string\n signatureText: string\n audit: Record<string, unknown>\n feeSnapshot: Record<string, unknown>\n proposalTxParams?: Record<string, unknown>\n /** Payable value wei string for first leg only when relevant */\n valueWei?: bigint\n}\n\nexport interface ChainCategoryBuildInput {\n keyGen: KeyGenSubset\n purposeText: string\n purposeSuffix?: string\n destinationChainID: string\n legs: MultisignLeg[]\n extraJSON?: Record<string, unknown>\n /** Top-level destination address (first leg destination if omitted) */\n destinationAddress?: string\n}\n\nexport interface ChainCategoryModule {\n category: ChainCategory\n finalizeMultisign(input: ChainCategoryBuildInput): MultisignBuildResult\n}\n\n/**\n * Assemble mpc-auth `bodyForSign` from category-built legs.\n * Supports single-tx and batch (messageHashes / messageRawBatch / proposalTxParams).\n */\nexport function finalizeMultisign(input: ChainCategoryBuildInput): MultisignBuildResult {\n const { keyGen, destinationChainID, legs } = input\n if (legs.length === 0) {\n throw new Error('finalizeMultisign requires at least one leg')\n }\n\n const ph = (keyGen.pubkeyhex ?? '').trim()\n if (!ph) throw new Error('keyGen pubKey (pubkeyhex) is required')\n\n const keyList = keyGen.keylist ?? []\n const clientId = firstClientIdFromKeyGen(keyGen)\n const first = legs[0]!\n\n const messageHashes = legs.map((l) => l.msgHash)\n const messageRawBatch = legs.map((l) => l.msgRaw)\n const batchMeta = legs.map((l) => ({\n destinationAddress: l.destinationAddress,\n signatureText: l.signatureText,\n ...l.audit,\n }))\n\n const proposalTxParams = legs\n .map((l) => l.proposalTxParams)\n .filter((p): p is Record<string, unknown> => p != null && typeof p === 'object')\n\n const extraPayload: Record<string, unknown> = {\n batchMeta,\n ...(input.extraJSON ?? {}),\n }\n const extraJSON = JSON.stringify(extraPayload)\n\n const bodyForSign: Record<string, unknown> = {\n keyList,\n pubKey: ph,\n msgHash: messageHashes[0],\n msgRaw: first.msgRaw,\n destinationChainID,\n destinationAddress: input.destinationAddress ?? first.destinationAddress,\n extraJSON,\n signatureText: first.signatureText,\n purpose: mergePurposeText(input.purposeText, input.purposeSuffix),\n ...first.feeSnapshot,\n }\n\n if (legs.length > 1) {\n bodyForSign.messageHashes = messageHashes\n bodyForSign.messageRawBatch = messageRawBatch\n }\n\n if (proposalTxParams.length > 0) {\n bodyForSign.proposalTxParams = proposalTxParams\n }\n\n const valueWei = first.valueWei\n if (valueWei != null && valueWei > 0n) {\n bodyForSign.value = valueWei.toString()\n }\n\n if (clientId) bodyForSign.clientId = clientId\n\n return { bodyForSign, messageToSign: JSON.stringify(bodyForSign) }\n}\n\nexport const coreChainCategoryModule: ChainCategoryModule = {\n category: 'evm',\n finalizeMultisign,\n}\n","import { createPublicClient, http, defineChain, formatUnits } from 'viem'\n\nexport interface ChainFeeParams {\n isEip1559: boolean\n baseFeeGwei?: number\n priorityFeeGwei?: number\n gasPriceGwei?: number\n}\n\nexport async function fetchChainFeeParams(\n rpcUrl: string,\n chainId: number | string,\n): Promise<ChainFeeParams> {\n const url = rpcUrl.trim()\n if (!url) return { isEip1559: false }\n\n const chainIdNum = typeof chainId === 'string' ? parseInt(chainId, 10) : chainId\n if (Number.isNaN(chainIdNum)) return { isEip1559: false }\n\n const chain = defineChain({\n id: chainIdNum,\n name: 'Discovery',\n nativeCurrency: { decimals: 18, name: 'Ether', symbol: 'ETH' },\n rpcUrls: { default: { http: [url] } },\n })\n\n const publicClient = createPublicClient({\n chain,\n transport: http(url),\n })\n\n const getGasPriceGwei = async (): Promise<number> => {\n const gasPriceWei = await publicClient.getGasPrice()\n return parseFloat(formatUnits(gasPriceWei, 9))\n }\n\n try {\n const block = await publicClient.getBlock({ blockTag: 'latest' })\n const baseFeePerGas = block?.baseFeePerGas\n if (baseFeePerGas == null || baseFeePerGas === undefined) {\n const gasPriceGwei = await getGasPriceGwei()\n return { isEip1559: false, gasPriceGwei }\n }\n\n const baseFeeGwei = parseFloat(formatUnits(baseFeePerGas, 9))\n\n let priorityFeeGwei: number | undefined\n try {\n const priorityWei = await publicClient.estimateMaxPriorityFeePerGas()\n priorityFeeGwei = parseFloat(formatUnits(priorityWei, 9))\n } catch {\n /* chain may not support eth_maxPriorityFeePerGas */\n }\n\n const gasPriceGwei = await getGasPriceGwei()\n return {\n isEip1559: true,\n baseFeeGwei,\n priorityFeeGwei,\n gasPriceGwei,\n }\n } catch {\n try {\n const gasPriceWei = await publicClient.getGasPrice()\n const gasPriceGwei = parseFloat(formatUnits(gasPriceWei, 9))\n return { isEip1559: false, gasPriceGwei }\n } catch {\n return { isEip1559: false }\n }\n }\n}\n","import { parseGwei } from 'viem'\n\nexport type ResolvedEip1559Fees = {\n maxFeePerGas: bigint\n maxPriorityFeePerGas: bigint\n}\n\nfunction finalizeEip1559Fees(\n maxFeePerGas: bigint,\n maxPriorityFeePerGas: bigint,\n floor: { maxFeePerGas: bigint; maxPriorityFeePerGas: bigint } | null | undefined,\n baseWei: bigint,\n): ResolvedEip1559Fees {\n let maxP = maxPriorityFeePerGas\n let maxF = maxFeePerGas\n if (floor) {\n if (maxP < floor.maxPriorityFeePerGas) maxP = floor.maxPriorityFeePerGas\n if (maxF < floor.maxFeePerGas) maxF = floor.maxFeePerGas\n }\n if (baseWei > 0n && maxF < baseWei + maxP) {\n maxF = baseWei + maxP + parseGwei('0.001')\n }\n if (maxF < maxP) {\n maxF = baseWei > 0n ? baseWei + maxP + parseGwei('0.001') : maxP * 2n\n }\n return { maxFeePerGas: maxF, maxPriorityFeePerGas: maxP }\n}\n\n/** Align EIP-1559 fees with the latest head base fee (same rules as Get Sig). */\nexport function alignEip1559FeesWithLatestBase(\n maxFeePerGas: bigint,\n maxPriorityFeePerGas: bigint,\n latestBlockBaseFeeWei: bigint,\n): ResolvedEip1559Fees {\n return finalizeEip1559Fees(maxFeePerGas, maxPriorityFeePerGas, null, latestBlockBaseFeeWei)\n}\n\nexport function gweiToDecimalString(n: number): string {\n if (!Number.isFinite(n)) return '0'\n if (n === 0) return '0'\n const s = String(n)\n if (s.indexOf('e') !== -1 || s.indexOf('E') !== -1) return n.toFixed(9).replace(/\\.?0+$/, '') || '0'\n return s\n}\n","import {\n keccak256,\n createPublicClient,\n defineChain,\n http,\n serializeTransaction,\n getAddress,\n parseGwei,\n type Address,\n type PublicClient,\n} from 'viem'\nimport type { MultisignBuildResult } from '../../core/types.js'\nimport { finalizeMultisign, type MultisignLeg } from '../../core/envelope.js'\nimport type { KeyGenSubset } from '../../core/keygen.js'\nimport { fetchChainFeeParams } from './fees/chainFees.js'\nimport { alignEip1559FeesWithLatestBase, gweiToDecimalString } from './fees/eip1559Align.js'\nimport {\n gasLimitFromEstimateAndChainConfig,\n routerSwapGasLimitFromEstimate,\n proposalTxParamsToFeeSnapshot,\n type ProposalTxParams,\n} from './txParams.js'\nimport type { EvmProtocolContext, EvmTxStep } from './types.js'\n\nexport type EvmBatchMetaBuilder = (args: {\n step: EvmTxStep\n index: number\n gasLimit: bigint\n}) => Record<string, unknown>\n\nexport type EvmBuildBatchArgs = {\n context: EvmProtocolContext\n steps: EvmTxStep[]\n purposeSuffix?: string\n buildBatchMeta: EvmBatchMetaBuilder\n /** First leg msgRaw without 0x prefix; defaults to first step calldata */\n firstMsgRawNo0x?: string\n destinationAddress?: Address\n /** Top-level `value` on bodyForSign when the payable amount is not on the first leg */\n payableValueWei?: bigint\n resolveGasLimit?: (args: {\n step: EvmTxStep\n index: number\n estimatedGas: bigint\n publicClient: PublicClient\n }) => Promise<bigint> | bigint\n}\n\n/**\n * Build unsigned EVM txs, estimate gas, serialize, hash — then assemble mpc-auth body via core envelope.\n */\nexport async function buildEvmMultisignBatch(args: EvmBuildBatchArgs): Promise<MultisignBuildResult> {\n const { context, steps } = args\n const {\n chainId,\n rpcUrl,\n executorAddress,\n chainDetail,\n useCustomGas,\n customGasChainDetails,\n keyGen,\n purposeText,\n } = context\n\n if (steps.length === 0) throw new Error('buildEvmMultisignBatch requires at least one step')\n\n const ch = defineChain({\n id: chainId,\n name: 'Destination',\n nativeCurrency: { decimals: 18, name: 'Ether', symbol: 'ETH' },\n rpcUrls: { default: { http: [rpcUrl] } },\n })\n const publicClient = createPublicClient({ chain: ch, transport: http(rpcUrl) })\n\n const feeParams = await fetchChainFeeParams(rpcUrl, chainId)\n const legacy = Boolean(chainDetail?.legacy) || !feeParams.isEip1559\n const latestBaseFeeWei = !legacy\n ? ((await publicClient.getBlock({ blockTag: 'latest' })).baseFeePerGas ?? 0n)\n : 0n\n\n const gasLimitConfig =\n useCustomGas && chainDetail?.gasLimit != null ? Number(chainDetail.gasLimit) : undefined\n const chainGasLimitRouter =\n chainDetail?.gasLimit != null &&\n Number.isFinite(Number(chainDetail.gasLimit)) &&\n Number(chainDetail.gasLimit) > 0\n ? Number(chainDetail.gasLimit)\n : undefined\n const gasFeeMultiplier =\n useCustomGas && chainDetail?.gasMultiplier != null ? Number(chainDetail.gasMultiplier) : undefined\n\n const executor = getAddress(executorAddress)\n const baseNonce = await publicClient.getTransactionCount({ address: executor, blockTag: 'pending' })\n\n const legs: MultisignLeg[] = []\n\n for (let i = 0; i < steps.length; i++) {\n const step = steps[i]!\n const currentNonce = baseNonce + i\n\n let estimatedGas: bigint\n try {\n estimatedGas = await publicClient.estimateGas({\n to: step.to,\n data: step.data,\n value: step.value,\n account: executor,\n })\n } catch {\n estimatedGas = step.fallbackGas ?? 100_000n\n }\n\n let gasLimitI: bigint\n if (args.resolveGasLimit) {\n gasLimitI = await args.resolveGasLimit({ step, index: i, estimatedGas, publicClient })\n } else if (step.routerSwap) {\n gasLimitI = routerSwapGasLimitFromEstimate(estimatedGas, chainGasLimitRouter)\n } else {\n gasLimitI = useCustomGas\n ? gasLimitFromEstimateAndChainConfig(estimatedGas, gasLimitConfig)\n : estimatedGas\n }\n\n let proposalTxParams: ProposalTxParams\n let feeSnapshot: Record<string, unknown>\n let serialized: `0x${string}`\n\n if (legacy) {\n let gasPriceWei = await publicClient.getGasPrice()\n if (useCustomGas && gasFeeMultiplier != null && gasFeeMultiplier > 0) {\n gasPriceWei = (gasPriceWei * BigInt(100 + gasFeeMultiplier)) / 100n\n }\n if (useCustomGas && chainDetail?.gasPrice != null && chainDetail.gasPrice > 0) {\n const configured = parseGwei(gweiToDecimalString(Number(chainDetail.gasPrice)))\n if (configured > gasPriceWei) gasPriceWei = configured\n }\n serialized = serializeTransaction({\n type: 'legacy',\n to: step.to,\n data: step.data,\n value: step.value,\n gas: gasLimitI,\n gasPrice: gasPriceWei,\n nonce: currentNonce,\n chainId,\n })\n proposalTxParams = {\n nonce: currentNonce,\n gasLimit: gasLimitI.toString(),\n txType: 'legacy',\n gasPrice: gasPriceWei.toString(),\n }\n feeSnapshot = proposalTxParamsToFeeSnapshot(proposalTxParams)\n } else {\n const fetchedBase = feeParams.baseFeeGwei ?? 0\n const fetchedPriority = feeParams.priorityFeeGwei ?? 0\n const configuredBase =\n useCustomGas && chainDetail?.baseFee != null ? Number(chainDetail.baseFee) : 0\n const configuredPriority =\n useCustomGas && chainDetail?.priorityFee != null ? Number(chainDetail.priorityFee) : 0\n const effectiveBaseFeeGwei = Math.max(fetchedBase, configuredBase)\n const effectivePriorityFeeGwei = Math.max(fetchedPriority, configuredPriority)\n const baseFeeMultiplierPct =\n useCustomGas && chainDetail?.baseFeeMultiplier != null\n ? Math.max(100, Number(chainDetail.baseFeeMultiplier))\n : 100\n const baseComponentGwei = (effectiveBaseFeeGwei * baseFeeMultiplierPct) / 100\n const maxFeePerGasGwei = baseComponentGwei + effectivePriorityFeeGwei\n let maxPriorityFeePerGas =\n effectivePriorityFeeGwei > 0\n ? parseGwei(gweiToDecimalString(effectivePriorityFeeGwei))\n : parseGwei('1')\n let maxFeePerGas = parseGwei(gweiToDecimalString(maxFeePerGasGwei))\n if (useCustomGas && gasFeeMultiplier != null && gasFeeMultiplier > 0) {\n maxPriorityFeePerGas = (maxPriorityFeePerGas * BigInt(100 + gasFeeMultiplier)) / 100n\n maxFeePerGas = (maxFeePerGas * BigInt(100 + gasFeeMultiplier)) / 100n\n }\n ;({ maxFeePerGas, maxPriorityFeePerGas } = alignEip1559FeesWithLatestBase(\n maxFeePerGas,\n maxPriorityFeePerGas,\n latestBaseFeeWei,\n ))\n serialized = serializeTransaction({\n type: 'eip1559',\n to: step.to,\n data: step.data,\n value: step.value,\n gas: gasLimitI,\n maxFeePerGas,\n maxPriorityFeePerGas,\n nonce: currentNonce,\n chainId,\n })\n proposalTxParams = {\n nonce: currentNonce,\n gasLimit: gasLimitI.toString(),\n txType: 'eip1559',\n maxFeePerGas: maxFeePerGas.toString(),\n maxPriorityFeePerGas: maxPriorityFeePerGas.toString(),\n }\n feeSnapshot = i === 0 ? proposalTxParamsToFeeSnapshot(proposalTxParams) : {}\n }\n\n const h = keccak256(serialized)\n const msgHash = h.startsWith('0x') ? h.slice(2) : h\n\n const batchMetaExtra = args.buildBatchMeta({ step, index: i, gasLimit: gasLimitI })\n\n legs.push({\n msgHash,\n msgRaw: i === 0 && args.firstMsgRawNo0x != null ? args.firstMsgRawNo0x : serialized,\n destinationAddress: step.to,\n signatureText:\n typeof batchMetaExtra.signatureText === 'string'\n ? batchMetaExtra.signatureText\n : JSON.stringify(batchMetaExtra.signatureText ?? {}),\n audit: batchMetaExtra,\n feeSnapshot: i === 0 ? feeSnapshot : {},\n proposalTxParams,\n valueWei: i === 0 ? step.value : undefined,\n })\n\n if (i === 0 && args.firstMsgRawNo0x != null) {\n legs[0]!.msgRaw = args.firstMsgRawNo0x\n }\n }\n\n const extraJSON: Record<string, unknown> = {}\n if (useCustomGas && customGasChainDetails && Object.keys(customGasChainDetails).length > 0) {\n extraJSON.customGasChainDetails = customGasChainDetails\n }\n\n const result = finalizeMultisign({\n keyGen: keyGen as KeyGenSubset,\n purposeText,\n purposeSuffix: args.purposeSuffix,\n destinationChainID: String(chainId),\n destinationAddress: args.destinationAddress ?? steps[0]!.to,\n legs,\n extraJSON: Object.keys(extraJSON).length > 0 ? extraJSON : undefined,\n })\n const pv = args.payableValueWei\n if (pv != null && pv > 0n) {\n result.bodyForSign.value = pv.toString()\n }\n return result\n}\n\nexport const evmChainCategoryModule = {\n category: 'evm' as const,\n finalizeMultisign,\n buildEvmMultisignBatch,\n}\n","import type { EvmChainDetail } from '../types.js'\n\n/** Snapshot chain gas config for extraJSON when Use Custom Gas is on. */\nexport function chainSnapshotForCustomGasExtraJSON(chainDetail: EvmChainDetail): Record<string, unknown> {\n const lr = chainDetail.legacy as boolean | string | undefined\n const legacy = lr === true || (typeof lr === 'string' && lr.toLowerCase() === 'true')\n\n const push = (o: Record<string, unknown>, key: string, v: unknown) => {\n if (v === undefined || v === null) return\n if (typeof v === 'string' && v.trim() === '') return\n o[key] = v\n }\n\n const fields: Record<string, unknown> = {}\n push(fields, 'gasLimit', chainDetail.gasLimit)\n if (legacy) {\n push(fields, 'gasMultiplier', chainDetail.gasMultiplier)\n push(fields, 'gasPrice', chainDetail.gasPrice)\n } else {\n push(fields, 'gasMultiplier', chainDetail.gasMultiplier)\n push(fields, 'baseFee', chainDetail.baseFee)\n push(fields, 'priorityFee', chainDetail.priorityFee)\n push(fields, 'baseFeeMultiplier', chainDetail.baseFeeMultiplier)\n }\n push(fields, 'legacy', legacy)\n return fields\n}\n","/** Parse chain id for comparisons (decimal, 0x hex, CAIP-2 eip155:N, bigint). */\nexport function parseEvmChainIdToNumber(chainId: string | number | bigint | null | undefined): number {\n if (chainId == null) return Number.NaN\n if (typeof chainId === 'bigint') {\n const n = Number(chainId)\n return Number.isSafeInteger(n) && n >= 0 ? n : Number.NaN\n }\n if (typeof chainId === 'number') {\n return Number.isInteger(chainId) && chainId >= 0 ? chainId : Number.NaN\n }\n const t = String(chainId).trim()\n if (!t) return Number.NaN\n const low = t.toLowerCase()\n if (low.startsWith('eip155:')) {\n const rest = t.slice('eip155:'.length).trim()\n const n = Number.parseInt(rest, 10)\n return Number.isNaN(n) || n < 0 ? Number.NaN : n\n }\n if (low.startsWith('0x')) {\n return Number.parseInt(t, 16)\n }\n return Number.parseInt(t, 10)\n}\n","export function isValidRpcUrl(url: string): boolean {\n const t = url.trim()\n if (!t) return false\n try {\n const u = new URL(t)\n return u.protocol === 'http:' || u.protocol === 'https:'\n } catch {\n return false\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/chains/evm/types.ts","../../../src/core/purpose.ts","../../../src/core/envelope.ts","../../../src/chains/evm/routerSwapGas.ts","../../../src/chains/evm/buildBatch.ts","../../../src/chains/evm/chainIdParse.ts"],"names":["getAddress","gasLimitFromEstimateAndChainConfig"],"mappings":";;;;AAiCO,SAAS,iBAAiB,OAAA,EAA0B;AACzD,EAAA,IAAI;AACF,IAAA,OAAO,UAAA,CAAW,OAAwB,CAAA,KAAM,WAAA;AAAA,EAClD,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,OAAA,CAAQ,aAAY,KAAM,WAAA;AAAA,EACnC;AACF;AAEO,SAAS,iBAAA,CACd,MACA,OAAA,EACS;AACT,EAAA,IAAI,IAAA,KAAS,QAAA,EAAU,OAAO,gBAAA,CAAiB,OAAO,CAAA;AACtD,EAAA,IAAI,IAAA,KAAS,OAAA,IAAW,IAAA,KAAS,UAAA,IAAc,SAAS,SAAA,EAAW;AACjE,IAAA,OAAO,CAAC,iBAAiB,OAAO,CAAA;AAAA,EAClC;AACA,EAAA,OAAO,IAAA;AACT;;;ACjDO,SAAS,gBAAA,CAAiB,aAAqB,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AAA,CAAO,GAAA;AAAA,EACtE;AACA,EAAA,MAAM,CAAA,GAAI,MAAA,CAAO,OAAO,CAAA,CAAE,IAAA,EAAK;AAC/B,EAAA,IAAI,CAAC,CAAA,EAAG,OAAO,MAAA,CAAO,GAAA;AACtB,EAAA,MAAM,GAAA,GAAM,EAAE,WAAA,EAAY;AAC1B,EAAA,IAAI,GAAA,CAAI,UAAA,CAAW,SAAS,CAAA,EAAG;AAC7B,IAAA,MAAM,OAAO,CAAA,CAAE,KAAA,CAAM,SAAA,CAAU,MAAM,EAAE,IAAA,EAAK;AAC5C,IAAA,MAAM,CAAA,GAAI,MAAA,CAAO,QAAA,CAAS,IAAA,EAAM,EAAE,CAAA;AAClC,IAAA,OAAO,OAAO,KAAA,CAAM,CAAC,KAAK,CAAA,GAAI,CAAA,GAAI,OAAO,GAAA,GAAM,CAAA;AAAA,EACjD;AACA,EAAA,IAAI,GAAA,CAAI,UAAA,CAAW,IAAI,CAAA,EAAG;AACxB,IAAA,OAAO,MAAA,CAAO,QAAA,CAAS,CAAA,EAAG,EAAE,CAAA;AAAA,EAC9B;AACA,EAAA,OAAO,MAAA,CAAO,QAAA,CAAS,CAAA,EAAG,EAAE,CAAA;AAC9B","file":"index.js","sourcesContent":["import type { EvmTokenKind, MultisignCommonArgs } from '../../core/types.js'\nimport { getAddress, zeroAddress, type Address } from 'viem'\n\nexport type EvmChainDetail = {\n legacy?: boolean\n gasLimit?: number\n gasMultiplier?: number\n gasPrice?: number\n baseFee?: number\n priorityFee?: number\n baseFeeMultiplier?: number\n}\n\nexport interface EvmProtocolContext extends MultisignCommonArgs {\n chainCategory: 'evm'\n chainId: number\n rpcUrl: string\n executorAddress: Address\n chainDetail: EvmChainDetail\n useCustomGas: boolean\n customGasChainDetails?: Record<string, unknown> | null\n}\n\nexport type EvmTxStep = {\n to: Address\n data: `0x${string}`\n value: bigint\n /** Fallback when estimateGas reverts */\n fallbackGas?: bigint\n /** When set, use routerSwapGasLimitFromEstimate instead of plain estimate */\n routerSwap?: boolean\n}\n\nexport function isEvmNativeToken(address: string): boolean {\n try {\n return getAddress(address as `0x${string}`) === zeroAddress\n } catch {\n return address.toLowerCase() === zeroAddress\n }\n}\n\nexport function matchEvmTokenKind(\n kind: EvmTokenKind,\n address: string,\n): boolean {\n if (kind === 'native') return isEvmNativeToken(address)\n if (kind === 'erc20' || kind === 'ctmerc20' || kind === 'ctmrwa1') {\n return !isEvmNativeToken(address)\n }\n return true\n}\n","/** Merge user purpose text with an optional batch / protocol suffix. */\nexport function mergePurposeText(purposeText: string, purposeSuffix?: string): string {\n const t = purposeText.trim()\n const suffix = (purposeSuffix ?? '').trim()\n if (!suffix) return t\n return t ? `${t}\\n\\n${suffix}` : suffix\n}\n","import type { ChainCategory, MultisignBuildResult, 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 { gasLimitFromEstimateAndChainConfig } from '@continuumdao/continuum-node-sdk'\n\n/** Curve router swap gas: chain cap when set, else 12/10 estimate bump. */\nexport function routerSwapGasLimitFromEstimate(\n estimatedGas: bigint,\n chainGasLimit?: number | null,\n): bigint {\n if (chainGasLimit != null && Number.isFinite(chainGasLimit) && chainGasLimit > 0) {\n return gasLimitFromEstimateAndChainConfig(estimatedGas, chainGasLimit)\n }\n return (estimatedGas * 12n + 9n) / 10n\n}\n","import {\n keccak256,\n createPublicClient,\n defineChain,\n http,\n serializeTransaction,\n getAddress,\n parseGwei,\n type Address,\n type PublicClient,\n} from 'viem'\nimport type { MultisignBuildResult } from '../../core/types.js'\nimport { finalizeMultisign, type MultisignLeg } from '../../core/envelope.js'\nimport type { KeyGenSubset } from '../../core/types.js'\nimport {\n fetchChainFeeParams,\n alignEip1559FeesWithLatestBase,\n gweiToDecimalString,\n gasLimitFromEstimateAndChainConfig,\n proposalTxParamsToFeeSnapshot,\n type ProposalTxParams,\n} from '@continuumdao/continuum-node-sdk'\nimport { routerSwapGasLimitFromEstimate } from './routerSwapGas.js'\nimport type { EvmProtocolContext, EvmTxStep } from './types.js'\n\nexport type EvmBatchMetaBuilder = (args: {\n step: EvmTxStep\n index: number\n gasLimit: bigint\n}) => Record<string, unknown>\n\nexport type EvmBuildBatchArgs = {\n context: EvmProtocolContext\n steps: EvmTxStep[]\n purposeSuffix?: string\n buildBatchMeta: EvmBatchMetaBuilder\n /** First leg msgRaw without 0x prefix; defaults to first step calldata */\n firstMsgRawNo0x?: string\n destinationAddress?: Address\n /** Top-level `value` on bodyForSign when the payable amount is not on the first leg */\n payableValueWei?: bigint\n resolveGasLimit?: (args: {\n step: EvmTxStep\n index: number\n estimatedGas: bigint\n publicClient: PublicClient\n }) => Promise<bigint> | bigint\n /** Override default `estimateGas` (e.g. trade-API gas, skip post-approve deposit estimate). */\n estimateGasForStep?: (args: {\n step: EvmTxStep\n index: number\n publicClient: PublicClient\n executor: Address\n }) => Promise<bigint> | bigint\n}\n\n/**\n * Build unsigned EVM txs, estimate gas, serialize, hash — then assemble mpc-auth body via core envelope.\n */\nexport async function buildEvmMultisignBatch(args: EvmBuildBatchArgs): Promise<MultisignBuildResult> {\n const { context, steps } = args\n const {\n chainId,\n rpcUrl,\n executorAddress,\n chainDetail,\n useCustomGas,\n customGasChainDetails,\n keyGen,\n purposeText,\n } = context\n\n if (steps.length === 0) throw new Error('buildEvmMultisignBatch requires at least one step')\n\n const ch = defineChain({\n id: chainId,\n name: 'Destination',\n nativeCurrency: { decimals: 18, name: 'Ether', symbol: 'ETH' },\n rpcUrls: { default: { http: [rpcUrl] } },\n })\n const publicClient = createPublicClient({ chain: ch, transport: http(rpcUrl) })\n\n const feeParams = await fetchChainFeeParams(rpcUrl, chainId)\n const legacy = Boolean(chainDetail?.legacy) || !feeParams.isEip1559\n const latestBaseFeeWei = !legacy\n ? ((await publicClient.getBlock({ blockTag: 'latest' })).baseFeePerGas ?? 0n)\n : 0n\n\n const gasLimitConfig =\n useCustomGas && chainDetail?.gasLimit != null ? Number(chainDetail.gasLimit) : undefined\n const chainGasLimitRouter =\n chainDetail?.gasLimit != null &&\n Number.isFinite(Number(chainDetail.gasLimit)) &&\n Number(chainDetail.gasLimit) > 0\n ? Number(chainDetail.gasLimit)\n : undefined\n const gasFeeMultiplier =\n useCustomGas && chainDetail?.gasMultiplier != null ? Number(chainDetail.gasMultiplier) : undefined\n\n const executor = getAddress(executorAddress)\n const baseNonce = await publicClient.getTransactionCount({ address: executor, blockTag: 'pending' })\n\n const legs: MultisignLeg[] = []\n\n for (let i = 0; i < steps.length; i++) {\n const step = steps[i]!\n const currentNonce = baseNonce + i\n\n let estimatedGas: bigint\n if (args.estimateGasForStep) {\n estimatedGas = await args.estimateGasForStep({ step, index: i, publicClient, executor })\n } else {\n try {\n estimatedGas = await publicClient.estimateGas({\n to: step.to,\n data: step.data,\n value: step.value,\n account: executor,\n })\n } catch {\n estimatedGas = step.fallbackGas ?? 100_000n\n }\n }\n\n let gasLimitI: bigint\n if (args.resolveGasLimit) {\n gasLimitI = await args.resolveGasLimit({ step, index: i, estimatedGas, publicClient })\n } else if (step.routerSwap) {\n gasLimitI = routerSwapGasLimitFromEstimate(estimatedGas, chainGasLimitRouter)\n } else {\n gasLimitI = useCustomGas\n ? gasLimitFromEstimateAndChainConfig(estimatedGas, gasLimitConfig)\n : estimatedGas\n }\n\n let proposalTxParams: ProposalTxParams\n let feeSnapshot: Record<string, unknown>\n let serialized: `0x${string}`\n\n if (legacy) {\n let gasPriceWei = await publicClient.getGasPrice()\n if (useCustomGas && gasFeeMultiplier != null && gasFeeMultiplier > 0) {\n gasPriceWei = (gasPriceWei * BigInt(100 + gasFeeMultiplier)) / 100n\n }\n if (useCustomGas && chainDetail?.gasPrice != null && chainDetail.gasPrice > 0) {\n const configured = parseGwei(gweiToDecimalString(Number(chainDetail.gasPrice)))\n if (configured > gasPriceWei) gasPriceWei = configured\n }\n serialized = serializeTransaction({\n type: 'legacy',\n to: step.to,\n data: step.data,\n value: step.value,\n gas: gasLimitI,\n gasPrice: gasPriceWei,\n nonce: currentNonce,\n chainId,\n })\n proposalTxParams = {\n nonce: currentNonce,\n gasLimit: gasLimitI.toString(),\n txType: 'legacy',\n gasPrice: gasPriceWei.toString(),\n }\n feeSnapshot = proposalTxParamsToFeeSnapshot(proposalTxParams)\n } else {\n const fetchedBase = feeParams.baseFeeGwei ?? 0\n const fetchedPriority = feeParams.priorityFeeGwei ?? 0\n const configuredBase =\n useCustomGas && chainDetail?.baseFee != null ? Number(chainDetail.baseFee) : 0\n const configuredPriority =\n useCustomGas && chainDetail?.priorityFee != null ? Number(chainDetail.priorityFee) : 0\n const effectiveBaseFeeGwei = Math.max(fetchedBase, configuredBase)\n const effectivePriorityFeeGwei = Math.max(fetchedPriority, configuredPriority)\n const baseFeeMultiplierPct =\n useCustomGas && chainDetail?.baseFeeMultiplier != null\n ? Math.max(100, Number(chainDetail.baseFeeMultiplier))\n : 100\n const baseComponentGwei = (effectiveBaseFeeGwei * baseFeeMultiplierPct) / 100\n const maxFeePerGasGwei = baseComponentGwei + effectivePriorityFeeGwei\n let maxPriorityFeePerGas =\n effectivePriorityFeeGwei > 0\n ? parseGwei(gweiToDecimalString(effectivePriorityFeeGwei))\n : parseGwei('1')\n let maxFeePerGas = parseGwei(gweiToDecimalString(maxFeePerGasGwei))\n if (useCustomGas && gasFeeMultiplier != null && gasFeeMultiplier > 0) {\n maxPriorityFeePerGas = (maxPriorityFeePerGas * BigInt(100 + gasFeeMultiplier)) / 100n\n maxFeePerGas = (maxFeePerGas * BigInt(100 + gasFeeMultiplier)) / 100n\n }\n ;({ maxFeePerGas, maxPriorityFeePerGas } = alignEip1559FeesWithLatestBase(\n maxFeePerGas,\n maxPriorityFeePerGas,\n latestBaseFeeWei,\n ))\n serialized = serializeTransaction({\n type: 'eip1559',\n to: step.to,\n data: step.data,\n value: step.value,\n gas: gasLimitI,\n maxFeePerGas,\n maxPriorityFeePerGas,\n nonce: currentNonce,\n chainId,\n })\n proposalTxParams = {\n nonce: currentNonce,\n gasLimit: gasLimitI.toString(),\n txType: 'eip1559',\n maxFeePerGas: maxFeePerGas.toString(),\n maxPriorityFeePerGas: maxPriorityFeePerGas.toString(),\n }\n feeSnapshot = i === 0 ? proposalTxParamsToFeeSnapshot(proposalTxParams) : {}\n }\n\n const h = keccak256(serialized)\n const msgHash = h.startsWith('0x') ? h.slice(2) : h\n\n const batchMetaExtra = args.buildBatchMeta({ step, index: i, gasLimit: gasLimitI })\n\n legs.push({\n msgHash,\n msgRaw: i === 0 && args.firstMsgRawNo0x != null ? args.firstMsgRawNo0x : serialized,\n destinationAddress: step.to,\n signatureText:\n typeof batchMetaExtra.signatureText === 'string'\n ? batchMetaExtra.signatureText\n : JSON.stringify(batchMetaExtra.signatureText ?? {}),\n audit: batchMetaExtra,\n feeSnapshot: i === 0 ? feeSnapshot : {},\n proposalTxParams,\n valueWei: i === 0 ? step.value : undefined,\n })\n\n if (i === 0 && args.firstMsgRawNo0x != null) {\n legs[0]!.msgRaw = args.firstMsgRawNo0x\n }\n }\n\n const extraJSON: Record<string, unknown> = {}\n if (useCustomGas && customGasChainDetails && Object.keys(customGasChainDetails).length > 0) {\n extraJSON.customGasChainDetails = customGasChainDetails\n }\n\n const result = finalizeMultisign({\n keyGen: keyGen as KeyGenSubset,\n purposeText,\n purposeSuffix: args.purposeSuffix,\n destinationChainID: String(chainId),\n destinationAddress: args.destinationAddress ?? steps[0]!.to,\n legs,\n extraJSON: Object.keys(extraJSON).length > 0 ? extraJSON : undefined,\n })\n const pv = args.payableValueWei\n if (pv != null && pv > 0n) {\n result.bodyForSign.value = pv.toString()\n }\n return result\n}\n\nexport const evmChainCategoryModule = {\n category: 'evm' as const,\n finalizeMultisign,\n buildEvmMultisignBatch,\n}\n","/** Parse chain id for comparisons (decimal, 0x hex, CAIP-2 eip155:N, bigint). */\nexport function parseEvmChainIdToNumber(chainId: string | number | bigint | null | undefined): number {\n if (chainId == null) return Number.NaN\n if (typeof chainId === 'bigint') {\n const n = Number(chainId)\n return Number.isSafeInteger(n) && n >= 0 ? n : Number.NaN\n }\n if (typeof chainId === 'number') {\n return Number.isInteger(chainId) && chainId >= 0 ? chainId : Number.NaN\n }\n const t = String(chainId).trim()\n if (!t) return Number.NaN\n const low = t.toLowerCase()\n if (low.startsWith('eip155:')) {\n const rest = t.slice('eip155:'.length).trim()\n const n = Number.parseInt(rest, 10)\n return Number.isNaN(n) || n < 0 ? Number.NaN : n\n }\n if (low.startsWith('0x')) {\n return Number.parseInt(t, 16)\n }\n return Number.parseInt(t, 10)\n}\n"]}
|
package/dist/core/index.cjs
CHANGED
|
@@ -1,22 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if (!map || typeof map !== "object") return null;
|
|
7
|
-
for (const v of Object.values(map)) {
|
|
8
|
-
if (typeof v === "string" && v.trim()) return v.trim();
|
|
9
|
-
}
|
|
10
|
-
return null;
|
|
11
|
-
}
|
|
12
|
-
function requirePubKeyHex(keyGen) {
|
|
13
|
-
const ph = (keyGen.pubkeyhex ?? "").trim();
|
|
14
|
-
if (!ph) throw new Error("keyGen pubKey (pubkeyhex) is required");
|
|
15
|
-
return ph;
|
|
16
|
-
}
|
|
17
|
-
function keyListFromKeyGen(keyGen) {
|
|
18
|
-
return keyGen.keylist ?? [];
|
|
19
|
-
}
|
|
3
|
+
var continuumNodeSdk = require('@continuumdao/continuum-node-sdk');
|
|
4
|
+
|
|
5
|
+
// src/core/index.ts
|
|
20
6
|
|
|
21
7
|
// src/core/purpose.ts
|
|
22
8
|
function mergePurposeText(purposeText, purposeSuffix) {
|
|
@@ -27,8 +13,6 @@ function mergePurposeText(purposeText, purposeSuffix) {
|
|
|
27
13
|
|
|
28
14
|
${suffix}` : suffix;
|
|
29
15
|
}
|
|
30
|
-
|
|
31
|
-
// src/core/envelope.ts
|
|
32
16
|
function finalizeMultisign(input) {
|
|
33
17
|
const { keyGen, destinationChainID, legs } = input;
|
|
34
18
|
if (legs.length === 0) {
|
|
@@ -37,7 +21,7 @@ function finalizeMultisign(input) {
|
|
|
37
21
|
const ph = (keyGen.pubkeyhex ?? "").trim();
|
|
38
22
|
if (!ph) throw new Error("keyGen pubKey (pubkeyhex) is required");
|
|
39
23
|
const keyList = keyGen.keylist ?? [];
|
|
40
|
-
const clientId =
|
|
24
|
+
const clientId = continuumNodeSdk.getClientIdFromKeyGenResult(keyGen);
|
|
41
25
|
const first = legs[0];
|
|
42
26
|
const messageHashes = legs.map((l) => l.msgHash);
|
|
43
27
|
const messageRawBatch = legs.map((l) => l.msgRaw);
|
|
@@ -103,102 +87,16 @@ function getActionsByChainCategory(category) {
|
|
|
103
87
|
return modules.filter((m) => m.chainCategory === category).flatMap((m) => m.actions);
|
|
104
88
|
}
|
|
105
89
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
if (auth.bearerOnGet && method === "GET" && auth.jwt && auth.jwt.trim()) {
|
|
111
|
-
headers.set("Authorization", `Bearer ${auth.jwt.trim()}`);
|
|
112
|
-
}
|
|
113
|
-
return fetch(url, { ...init, headers });
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// src/core/managementPostSig.ts
|
|
117
|
-
function normalizeManagementNodeKey(nodeKey) {
|
|
118
|
-
const nk = nodeKey?.trim().replace(/^0x/i, "");
|
|
119
|
-
if (!nk || !/^[0-9a-fA-F]{128}$/.test(nk)) {
|
|
120
|
-
throw new Error("nodeKey is required (128 hex from GET /getNodeKey).");
|
|
121
|
-
}
|
|
122
|
-
return nk.toLowerCase();
|
|
123
|
-
}
|
|
124
|
-
function managementSigFields(nonce, nodeKey) {
|
|
125
|
-
return { nonce, clientSig: "", nodeKey: normalizeManagementNodeKey(nodeKey) };
|
|
126
|
-
}
|
|
127
|
-
function buildManagementPostBody(nonce, nodeKey, fields = {}) {
|
|
128
|
-
return { ...managementSigFields(nonce, nodeKey), ...fields };
|
|
129
|
-
}
|
|
130
|
-
function messageToSignManagementBody(body) {
|
|
131
|
-
return JSON.stringify({ ...body, clientSig: "" });
|
|
132
|
-
}
|
|
133
|
-
function withManagementClientSig(body, clientSig) {
|
|
134
|
-
return { ...body, clientSig: clientSig.trim().replace(/^0x/i, "") };
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// src/core/managementNonce.ts
|
|
138
|
-
function mpcAuthData(raw) {
|
|
139
|
-
const code = raw.Code ?? raw.code;
|
|
140
|
-
if (code !== 0 && code !== void 0) return void 0;
|
|
141
|
-
return raw.Data ?? raw.data;
|
|
142
|
-
}
|
|
143
|
-
async function fetchNodeKey(nodeUrl, readAuth = { bearerOnGet: false, jwt: null }) {
|
|
144
|
-
const base = nodeUrl.trim().replace(/\/$/, "");
|
|
145
|
-
const res = await nodeFetchWithReadAuth(`${base}/getNodeKey`, { cache: "no-store" }, readAuth);
|
|
146
|
-
const text = await res.text();
|
|
147
|
-
let raw;
|
|
148
|
-
try {
|
|
149
|
-
raw = JSON.parse(text);
|
|
150
|
-
} catch {
|
|
151
|
-
return { nodeKey: "", ok: false };
|
|
152
|
-
}
|
|
153
|
-
const data = mpcAuthData(raw);
|
|
154
|
-
const nk = typeof data === "string" ? data : data != null && typeof data === "object" && !Array.isArray(data) ? String(data.nodeKey ?? data.NodeKey ?? "") : data != null ? String(data) : "";
|
|
155
|
-
const trimmed = nk.trim().replace(/^0x/i, "");
|
|
156
|
-
if (!/^[0-9a-fA-F]{128}$/.test(trimmed)) {
|
|
157
|
-
return { nodeKey: "", ok: false };
|
|
158
|
-
}
|
|
159
|
-
return { nodeKey: trimmed.toLowerCase(), ok: res.ok };
|
|
160
|
-
}
|
|
161
|
-
async function fetchManagementNonce(nodeUrl, useEd25519, ed25519PublicKey, readAuth = { bearerOnGet: false, jwt: null }) {
|
|
162
|
-
const base = nodeUrl.trim().replace(/\/$/, "");
|
|
163
|
-
const path = useEd25519 ? "/getPublicMgtKeyNonce" : "/getNodeMgtKeyNonce";
|
|
164
|
-
const url = useEd25519 && ed25519PublicKey && /^[0-9a-fA-F]{64}$/.test(ed25519PublicKey.trim()) ? `${base}${path}?publicKey=${encodeURIComponent(ed25519PublicKey.trim())}` : `${base}${path}`;
|
|
165
|
-
const res = await nodeFetchWithReadAuth(url, { cache: "no-store" }, readAuth);
|
|
166
|
-
const text = await res.text();
|
|
167
|
-
let raw;
|
|
168
|
-
try {
|
|
169
|
-
raw = JSON.parse(text);
|
|
170
|
-
} catch {
|
|
171
|
-
return { nonce: 0, ok: false, code: -1 };
|
|
172
|
-
}
|
|
173
|
-
const code = raw.Code ?? raw.code;
|
|
174
|
-
const payload = mpcAuthData(raw) ?? raw.Data ?? raw.data;
|
|
175
|
-
let nonce = 0;
|
|
176
|
-
if (typeof payload === "number" && !Number.isNaN(payload)) {
|
|
177
|
-
nonce = payload;
|
|
178
|
-
} else if (payload && typeof payload === "object") {
|
|
179
|
-
const n = payload.nonce ?? payload.Nonce;
|
|
180
|
-
nonce = typeof n === "number" && !Number.isNaN(n) ? n : Number(n) || 0;
|
|
181
|
-
}
|
|
182
|
-
return { nonce, ok: res.ok && (code === 0 || code === void 0), code: code ?? -1 };
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
exports.buildManagementPostBody = buildManagementPostBody;
|
|
90
|
+
Object.defineProperty(exports, "firstClientIdFromKeyGen", {
|
|
91
|
+
enumerable: true,
|
|
92
|
+
get: function () { return continuumNodeSdk.getClientIdFromKeyGenResult; }
|
|
93
|
+
});
|
|
186
94
|
exports.coreChainCategoryModule = coreChainCategoryModule;
|
|
187
|
-
exports.fetchManagementNonce = fetchManagementNonce;
|
|
188
|
-
exports.fetchNodeKey = fetchNodeKey;
|
|
189
95
|
exports.finalizeMultisign = finalizeMultisign;
|
|
190
|
-
exports.firstClientIdFromKeyGen = firstClientIdFromKeyGen;
|
|
191
96
|
exports.getActionsByChainCategory = getActionsByChainCategory;
|
|
192
97
|
exports.getProtocolModule = getProtocolModule;
|
|
193
98
|
exports.getProtocolModules = getProtocolModules;
|
|
194
|
-
exports.keyListFromKeyGen = keyListFromKeyGen;
|
|
195
|
-
exports.managementSigFields = managementSigFields;
|
|
196
99
|
exports.mergePurposeText = mergePurposeText;
|
|
197
|
-
exports.messageToSignManagementBody = messageToSignManagementBody;
|
|
198
|
-
exports.nodeFetchWithReadAuth = nodeFetchWithReadAuth;
|
|
199
|
-
exports.normalizeManagementNodeKey = normalizeManagementNodeKey;
|
|
200
100
|
exports.registerProtocolModule = registerProtocolModule;
|
|
201
|
-
exports.requirePubKeyHex = requirePubKeyHex;
|
|
202
|
-
exports.withManagementClientSig = withManagementClientSig;
|
|
203
101
|
//# sourceMappingURL=index.cjs.map
|
|
204
102
|
//# sourceMappingURL=index.cjs.map
|
package/dist/core/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/keygen.ts","../../src/core/purpose.ts","../../src/core/envelope.ts","../../src/core/registry.ts","../../src/core/nodeRead.ts","../../src/core/managementPostSig.ts","../../src/core/managementNonce.ts"],"names":[],"mappings":";;;AAOO,SAAS,wBAAwB,IAAA,EAAsD;AAC5F,EAAA,MAAM,MAAM,IAAA,EAAM,UAAA;AAClB,EAAA,IAAI,CAAC,GAAA,IAAO,OAAO,GAAA,KAAQ,UAAU,OAAO,IAAA;AAC5C,EAAA,KAAA,MAAW,CAAA,IAAK,MAAA,CA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{ KeyGenSubset }\n\n/** App-compatible alias used by existing multisign builders. */\nexport type KeyGenSubsetForPermit = KeyGenSubset\n\nexport function firstClientIdFromKeyGen(data: KeyGenSubset | null | undefined): string | null {\n const map = data?.ClientKeys\n if (!map || typeof map !== 'object') return null\n for (const v of Object.values(map)) {\n if (typeof v === 'string' && v.trim()) return v.trim()\n }\n return null\n}\n\nexport function requirePubKeyHex(keyGen: KeyGenSubset): string {\n const ph = (keyGen.pubkeyhex ?? '').trim()\n if (!ph) throw new Error('keyGen pubKey (pubkeyhex) is required')\n return ph\n}\n\nexport function keyListFromKeyGen(keyGen: KeyGenSubset): string[] {\n return keyGen.keylist ?? []\n}\n","/** Merge user purpose text with an optional batch / protocol suffix. */\nexport function mergePurposeText(purposeText: string, purposeSuffix?: string): string {\n const t = purposeText.trim()\n const suffix = (purposeSuffix ?? '').trim()\n if (!suffix) return t\n return t ? `${t}\\n\\n${suffix}` : suffix\n}\n","import type { ChainCategory, MultisignBuildResult } from './types.js'\nimport type { KeyGenSubset } from './keygen.js'\nimport { firstClientIdFromKeyGen } from './keygen.js'\nimport { mergePurposeText } from './purpose.js'\n\nexport interface MultisignLeg {\n msgHash: string\n msgRaw: string\n destinationAddress: string\n signatureText: string\n audit: Record<string, unknown>\n feeSnapshot: Record<string, unknown>\n proposalTxParams?: Record<string, unknown>\n /** Payable value wei string for first leg only when relevant */\n valueWei?: bigint\n}\n\nexport interface ChainCategoryBuildInput {\n keyGen: KeyGenSubset\n purposeText: string\n purposeSuffix?: string\n destinationChainID: string\n legs: MultisignLeg[]\n extraJSON?: Record<string, unknown>\n /** Top-level destination address (first leg destination if omitted) */\n destinationAddress?: string\n}\n\nexport interface ChainCategoryModule {\n category: ChainCategory\n finalizeMultisign(input: ChainCategoryBuildInput): MultisignBuildResult\n}\n\n/**\n * Assemble mpc-auth `bodyForSign` from category-built legs.\n * Supports single-tx and batch (messageHashes / messageRawBatch / proposalTxParams).\n */\nexport function finalizeMultisign(input: ChainCategoryBuildInput): MultisignBuildResult {\n const { keyGen, destinationChainID, legs } = input\n if (legs.length === 0) {\n throw new Error('finalizeMultisign requires at least one leg')\n }\n\n const ph = (keyGen.pubkeyhex ?? '').trim()\n if (!ph) throw new Error('keyGen pubKey (pubkeyhex) is required')\n\n const keyList = keyGen.keylist ?? []\n const clientId = firstClientIdFromKeyGen(keyGen)\n const first = legs[0]!\n\n const messageHashes = legs.map((l) => l.msgHash)\n const messageRawBatch = legs.map((l) => l.msgRaw)\n const batchMeta = legs.map((l) => ({\n destinationAddress: l.destinationAddress,\n signatureText: l.signatureText,\n ...l.audit,\n }))\n\n const proposalTxParams = legs\n .map((l) => l.proposalTxParams)\n .filter((p): p is Record<string, unknown> => p != null && typeof p === 'object')\n\n const extraPayload: Record<string, unknown> = {\n batchMeta,\n ...(input.extraJSON ?? {}),\n }\n const extraJSON = JSON.stringify(extraPayload)\n\n const bodyForSign: Record<string, unknown> = {\n keyList,\n pubKey: ph,\n msgHash: messageHashes[0],\n msgRaw: first.msgRaw,\n destinationChainID,\n destinationAddress: input.destinationAddress ?? first.destinationAddress,\n extraJSON,\n signatureText: first.signatureText,\n purpose: mergePurposeText(input.purposeText, input.purposeSuffix),\n ...first.feeSnapshot,\n }\n\n if (legs.length > 1) {\n bodyForSign.messageHashes = messageHashes\n bodyForSign.messageRawBatch = messageRawBatch\n }\n\n if (proposalTxParams.length > 0) {\n bodyForSign.proposalTxParams = proposalTxParams\n }\n\n const valueWei = first.valueWei\n if (valueWei != null && valueWei > 0n) {\n bodyForSign.value = valueWei.toString()\n }\n\n if (clientId) bodyForSign.clientId = clientId\n\n return { bodyForSign, messageToSign: JSON.stringify(bodyForSign) }\n}\n\nexport const coreChainCategoryModule: ChainCategoryModule = {\n category: 'evm',\n finalizeMultisign,\n}\n","import type { ProtocolModule } from './types.js'\n\nconst modules: ProtocolModule[] = []\n\nexport function registerProtocolModule(mod: ProtocolModule): void {\n const existing = modules.findIndex((m) => m.id === mod.id)\n if (existing >= 0) {\n modules[existing] = mod\n } else {\n modules.push(mod)\n }\n}\n\nexport function getProtocolModules(): readonly ProtocolModule[] {\n return modules\n}\n\nexport function getProtocolModule(id: string): ProtocolModule | undefined {\n return modules.find((m) => m.id === id)\n}\n\nexport function getActionsByChainCategory(category: string): ProtocolModule['actions'] {\n return modules.filter((m) => m.chainCategory === category).flatMap((m) => m.actions)\n}\n","/** GET requests to mpc-auth management node with optional Bearer JWT (Browser HTTPS). */\nexport type NodeReadAuth = {\n bearerOnGet: boolean\n jwt: string | null\n}\n\nexport function nodeFetchWithReadAuth(\n url: string,\n init: RequestInit | undefined,\n auth: NodeReadAuth,\n): Promise<Response> {\n const method = (init?.method ?? 'GET').toUpperCase()\n const headers = new Headers(init?.headers)\n if (auth.bearerOnGet && method === 'GET' && auth.jwt && auth.jwt.trim()) {\n headers.set('Authorization', `Bearer ${auth.jwt.trim()}`)\n }\n return fetch(url, { ...init, headers })\n}\n","/** mpc-auth NodeMgtKeySig envelope: `{ nonce, clientSig, nodeKey }` (all lowercase). */\n\nexport type ManagementSigFields = {\n nonce: number\n clientSig: string\n nodeKey: string\n}\n\nexport function normalizeManagementNodeKey(nodeKey: string | null | undefined): string {\n const nk = nodeKey?.trim().replace(/^0x/i, '')\n if (!nk || !/^[0-9a-fA-F]{128}$/.test(nk)) {\n throw new Error('nodeKey is required (128 hex from GET /getNodeKey).')\n }\n return nk.toLowerCase()\n}\n\n/** Base fields for NodeMgtKeySig-style POST bodies (`clientSig` cleared for signing). */\nexport function managementSigFields(\n nonce: number,\n nodeKey: string | null | undefined,\n): ManagementSigFields {\n return { nonce, clientSig: '', nodeKey: normalizeManagementNodeKey(nodeKey) }\n}\n\n/** Spread management fields first, then endpoint-specific fields (preserves key order when spreading). */\nexport function buildManagementPostBody(\n nonce: number,\n nodeKey: string | null | undefined,\n fields: Record<string, unknown> = {},\n): Record<string, unknown> {\n return { ...managementSigFields(nonce, nodeKey), ...fields }\n}\n\n/** Exact UTF-8 string to sign: same JSON with `clientSig` cleared. */\nexport function messageToSignManagementBody(body: Record<string, unknown>): string {\n return JSON.stringify({ ...body, clientSig: '' })\n}\n\nexport function withManagementClientSig(\n body: Record<string, unknown>,\n clientSig: string,\n): Record<string, unknown> {\n return { ...body, clientSig: clientSig.trim().replace(/^0x/i, '') }\n}\n","import { nodeFetchWithReadAuth, type NodeReadAuth } from './nodeRead.js'\n\nfunction mpcAuthData(raw: Record<string, unknown>): unknown {\n const code = (raw.Code ?? raw.code) as number | undefined\n if (code !== 0 && code !== undefined) return undefined\n return raw.Data ?? raw.data\n}\n\n/**\n * GET /getNodeKey — 128-hex MPC node id required on all NodeMgtKeySig POST bodies.\n */\nexport async function fetchNodeKey(\n nodeUrl: string,\n readAuth: NodeReadAuth = { bearerOnGet: false, jwt: null },\n): Promise<{ nodeKey: string; ok: boolean }> {\n const base = nodeUrl.trim().replace(/\\/$/, '')\n const res = await nodeFetchWithReadAuth(`${base}/getNodeKey`, { cache: 'no-store' }, readAuth)\n const text = await res.text()\n let raw: Record<string, unknown>\n try {\n raw = JSON.parse(text) as Record<string, unknown>\n } catch {\n return { nodeKey: '', ok: false }\n }\n const data = mpcAuthData(raw)\n const nk =\n typeof data === 'string'\n ? data\n : data != null && typeof data === 'object' && !Array.isArray(data)\n ? String((data as Record<string, unknown>).nodeKey ?? (data as Record<string, unknown>).NodeKey ?? '')\n : data != null\n ? String(data)\n : ''\n const trimmed = nk.trim().replace(/^0x/i, '')\n if (!/^[0-9a-fA-F]{128}$/.test(trimmed)) {\n return { nodeKey: '', ok: false }\n }\n return { nodeKey: trimmed.toLowerCase(), ok: res.ok }\n}\n\n/**\n * Fetch management nonce: GET /getPublicMgtKeyNonce (Ed25519) or GET /getNodeMgtKeyNonce (Ethereum NodeMgtKey).\n * For Ed25519 added keys, pass `?publicKey=<64-hex>`.\n */\nexport async function fetchManagementNonce(\n nodeUrl: string,\n useEd25519: boolean,\n ed25519PublicKey?: string,\n readAuth: NodeReadAuth = { bearerOnGet: false, jwt: null },\n): Promise<{ nonce: number; ok: boolean; code: number }> {\n const base = nodeUrl.trim().replace(/\\/$/, '')\n const path = useEd25519 ? '/getPublicMgtKeyNonce' : '/getNodeMgtKeyNonce'\n const url =\n useEd25519 && ed25519PublicKey && /^[0-9a-fA-F]{64}$/.test(ed25519PublicKey.trim())\n ? `${base}${path}?publicKey=${encodeURIComponent(ed25519PublicKey.trim())}`\n : `${base}${path}`\n const res = await nodeFetchWithReadAuth(url, { cache: 'no-store' }, readAuth)\n const text = await res.text()\n let raw: Record<string, unknown>\n try {\n raw = JSON.parse(text) as Record<string, unknown>\n } catch {\n return { nonce: 0, ok: false, code: -1 }\n }\n const code = (raw.Code ?? raw.code) as number | undefined\n const payload = mpcAuthData(raw) ?? raw.Data ?? raw.data\n let nonce = 0\n if (typeof payload === 'number' && !Number.isNaN(payload)) {\n nonce = payload\n } else if (payload && typeof payload === 'object') {\n const n = (payload as Record<string, unknown>).nonce ?? (payload as Record<string, unknown>).Nonce\n nonce = typeof n === 'number' && !Number.isNaN(n) ? n : Number(n) || 0\n }\n return { nonce, ok: res.ok && (code === 0 || code === undefined), code: code ?? -1 }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/core/purpose.ts","../../src/core/envelope.ts","../../src/core/registry.ts"],"names":["getClientIdFromKeyGenResult"],"mappings":";;;;;;;AACO,SAAS,gBAAA,CAAiB,aAAqB,aAAA,EAAgC;AACpF,EAAA,MAAM,CAAA,GAAI,YAAY,IAAA,EAAK;AAC3B,EAAA,MAAM,MAAA,GAAA,CAAU,aAAA,IAAiB,EAAA,EAAI,IAAA,EAAK;AAC1C,EAAA,IAAI,CAAC,QAAQ,OAAO,CAAA;AACpB,EAAA,OAAO,CAAA,GAAI,GAAG,CAAC;;AAAA,EAAO,MAAM,CAAA,CAAA,GAAK,MAAA;AACnC;AC8BO,SAAS,kBAAkB,KAAA,EAAsD;AACtF,EAAA,MAAM,EAAE,MAAA,EAAQ,kBAAA,EAAoB,IAAA,EAAK,GAAI,KAAA;AAC7C,EAA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AI,GAAA;AAAA,EACtB,CAAA,MAAO;AACL,IAAA,OAAA,CAAQ,KAAK,GAAG,CAAA;AAAA,EAClB;AACF;AAEO,SAAS,kBAAA,GAAgD;AAC9D,EAAA,OAAO,OAAA;AACT;AAEO,SAAS,kBAAkB,EAAA,EAAwC;AACxE,EAAA,OAAO,QAAQ,IAAA,CAAK,CAAC,CAAA,KAAM,CAAA,CAAE,OAAO,EAAE,CAAA;AACxC;AAEO,SAAS,0BAA0B,QAAA,EAA6C;AACrF,EAAA,OAAO,OAAA,CAAQ,MAAA,CAAO,CAAC,CAAA,KAAM,CAAA,CAAE,aAAA,KAAkB,QAAQ,CAAA,CAAE,OAAA,CAAQ,CAAC,CAAA,KAAM,CAAA,CAAE,OAAO,CAAA;AACrF","file":"index.cjs","sourcesContent":["/** Merge user purpose text with an optional batch / protocol suffix. */\nexport function mergePurposeText(purposeText: string, purposeSuffix?: string): string {\n const t = purposeText.trim()\n const suffix = (purposeSuffix ?? '').trim()\n if (!suffix) return t\n return t ? `${t}\\n\\n${suffix}` : suffix\n}\n","import type { ChainCategory, MultisignBuildResult, KeyGenSubset } from './types.js'\nimport { getClientIdFromKeyGenResult } from '@continuumdao/continuum-node-sdk'\nimport { mergePurposeText } from './purpose.js'\n\nexport interface MultisignLeg {\n msgHash: string\n msgRaw: string\n destinationAddress: string\n signatureText: string\n audit: Record<string, unknown>\n feeSnapshot: Record<string, unknown>\n proposalTxParams?: Record<string, unknown>\n /** Payable value wei string for first leg only when relevant */\n valueWei?: bigint\n}\n\nexport interface ChainCategoryBuildInput {\n keyGen: KeyGenSubset\n purposeText: string\n purposeSuffix?: string\n destinationChainID: string\n legs: MultisignLeg[]\n extraJSON?: Record<string, unknown>\n /** Top-level destination address (first leg destination if omitted) */\n destinationAddress?: string\n}\n\nexport interface ChainCategoryModule {\n category: ChainCategory\n finalizeMultisign(input: ChainCategoryBuildInput): MultisignBuildResult\n}\n\n/**\n * Assemble mpc-auth `bodyForSign` from category-built legs.\n * Supports single-tx and batch (messageHashes / messageRawBatch / proposalTxParams).\n */\nexport function finalizeMultisign(input: ChainCategoryBuildInput): MultisignBuildResult {\n const { keyGen, destinationChainID, legs } = input\n if (legs.length === 0) {\n throw new Error('finalizeMultisign requires at least one leg')\n }\n\n const ph = (keyGen.pubkeyhex ?? '').trim()\n if (!ph) throw new Error('keyGen pubKey (pubkeyhex) is required')\n\n const keyList = keyGen.keylist ?? []\n const clientId = getClientIdFromKeyGenResult(keyGen)\n const first = legs[0]!\n\n const messageHashes = legs.map((l) => l.msgHash)\n const messageRawBatch = legs.map((l) => l.msgRaw)\n const batchMeta = legs.map((l) => ({\n destinationAddress: l.destinationAddress,\n signatureText: l.signatureText,\n ...l.audit,\n }))\n\n const proposalTxParams = legs\n .map((l) => l.proposalTxParams)\n .filter((p): p is Record<string, unknown> => p != null && typeof p === 'object')\n\n const extraPayload: Record<string, unknown> = {\n batchMeta,\n ...(input.extraJSON ?? {}),\n }\n const extraJSON = JSON.stringify(extraPayload)\n\n const bodyForSign: Record<string, unknown> = {\n keyList,\n pubKey: ph,\n msgHash: messageHashes[0],\n msgRaw: first.msgRaw,\n destinationChainID,\n destinationAddress: input.destinationAddress ?? first.destinationAddress,\n extraJSON,\n signatureText: first.signatureText,\n purpose: mergePurposeText(input.purposeText, input.purposeSuffix),\n ...first.feeSnapshot,\n }\n\n if (legs.length > 1) {\n bodyForSign.messageHashes = messageHashes\n bodyForSign.messageRawBatch = messageRawBatch\n }\n\n if (proposalTxParams.length > 0) {\n bodyForSign.proposalTxParams = proposalTxParams\n }\n\n const valueWei = first.valueWei\n if (valueWei != null && valueWei > 0n) {\n bodyForSign.value = valueWei.toString()\n }\n\n if (clientId) bodyForSign.clientId = clientId\n\n return { bodyForSign, messageToSign: JSON.stringify(bodyForSign) }\n}\n\nexport const coreChainCategoryModule: ChainCategoryModule = {\n category: 'evm',\n finalizeMultisign,\n}\n","import type { ProtocolModule } from './types.js'\n\nconst modules: ProtocolModule[] = []\n\nexport function registerProtocolModule(mod: ProtocolModule): void {\n const existing = modules.findIndex((m) => m.id === mod.id)\n if (existing >= 0) {\n modules[existing] = mod\n } else {\n modules.push(mod)\n }\n}\n\nexport function getProtocolModules(): readonly ProtocolModule[] {\n return modules\n}\n\nexport function getProtocolModule(id: string): ProtocolModule | undefined {\n return modules.find((m) => m.id === id)\n}\n\nexport function getActionsByChainCategory(category: string): ProtocolModule['actions'] {\n return modules.filter((m) => m.chainCategory === category).flatMap((m) => m.actions)\n}\n"]}
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,43 +1,9 @@
|
|
|
1
|
-
export { C as ChainCategory, a as ChainSupportContext, E as EvmTokenKind, K as KeyGenSubset, M as MultisignBuildResult,
|
|
2
|
-
export {
|
|
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-
|
|
5
|
-
import { N as NodeReadAuth } from '../nodeRead-BnmSaMGO.js';
|
|
6
|
-
export { n as nodeFetchWithReadAuth } from '../nodeRead-BnmSaMGO.js';
|
|
1
|
+
export { C as ChainCategory, a as ChainSupportContext, E as EvmTokenKind, K as KeyGenSubset, b as KeyGenSubsetForPermit, M as MultisignBuildResult, c as MultisignCommonArgs, N as NearTokenKind, P as ParamDoc, d as ProtocolActionDescriptor, e as ProtocolModule, S as SolanaTokenKind, T as TokenRef } from '../types-BfjWdw1j.js';
|
|
2
|
+
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-CpBUh9eP.js';
|
|
4
|
+
export { g as getActionsByChainCategory, a as getProtocolModule, b as getProtocolModules, r as registerProtocolModule } from '../registry-Bv5o37_w.js';
|
|
7
5
|
|
|
8
6
|
/** Merge user purpose text with an optional batch / protocol suffix. */
|
|
9
7
|
declare function mergePurposeText(purposeText: string, purposeSuffix?: string): string;
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
type ManagementSigFields = {
|
|
13
|
-
nonce: number;
|
|
14
|
-
clientSig: string;
|
|
15
|
-
nodeKey: string;
|
|
16
|
-
};
|
|
17
|
-
declare function normalizeManagementNodeKey(nodeKey: string | null | undefined): string;
|
|
18
|
-
/** Base fields for NodeMgtKeySig-style POST bodies (`clientSig` cleared for signing). */
|
|
19
|
-
declare function managementSigFields(nonce: number, nodeKey: string | null | undefined): ManagementSigFields;
|
|
20
|
-
/** Spread management fields first, then endpoint-specific fields (preserves key order when spreading). */
|
|
21
|
-
declare function buildManagementPostBody(nonce: number, nodeKey: string | null | undefined, fields?: Record<string, unknown>): Record<string, unknown>;
|
|
22
|
-
/** Exact UTF-8 string to sign: same JSON with `clientSig` cleared. */
|
|
23
|
-
declare function messageToSignManagementBody(body: Record<string, unknown>): string;
|
|
24
|
-
declare function withManagementClientSig(body: Record<string, unknown>, clientSig: string): Record<string, unknown>;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* GET /getNodeKey — 128-hex MPC node id required on all NodeMgtKeySig POST bodies.
|
|
28
|
-
*/
|
|
29
|
-
declare function fetchNodeKey(nodeUrl: string, readAuth?: NodeReadAuth): Promise<{
|
|
30
|
-
nodeKey: string;
|
|
31
|
-
ok: boolean;
|
|
32
|
-
}>;
|
|
33
|
-
/**
|
|
34
|
-
* Fetch management nonce: GET /getPublicMgtKeyNonce (Ed25519) or GET /getNodeMgtKeyNonce (Ethereum NodeMgtKey).
|
|
35
|
-
* For Ed25519 added keys, pass `?publicKey=<64-hex>`.
|
|
36
|
-
*/
|
|
37
|
-
declare function fetchManagementNonce(nodeUrl: string, useEd25519: boolean, ed25519PublicKey?: string, readAuth?: NodeReadAuth): Promise<{
|
|
38
|
-
nonce: number;
|
|
39
|
-
ok: boolean;
|
|
40
|
-
code: number;
|
|
41
|
-
}>;
|
|
42
|
-
|
|
43
|
-
export { type ManagementSigFields, NodeReadAuth, buildManagementPostBody, fetchManagementNonce, fetchNodeKey, managementSigFields, mergePurposeText, messageToSignManagementBody, normalizeManagementNodeKey, withManagementClientSig };
|
|
9
|
+
export { mergePurposeText };
|
package/dist/core/index.js
CHANGED
|
@@ -1,20 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
for (const v of Object.values(map)) {
|
|
6
|
-
if (typeof v === "string" && v.trim()) return v.trim();
|
|
7
|
-
}
|
|
8
|
-
return null;
|
|
9
|
-
}
|
|
10
|
-
function requirePubKeyHex(keyGen) {
|
|
11
|
-
const ph = (keyGen.pubkeyhex ?? "").trim();
|
|
12
|
-
if (!ph) throw new Error("keyGen pubKey (pubkeyhex) is required");
|
|
13
|
-
return ph;
|
|
14
|
-
}
|
|
15
|
-
function keyListFromKeyGen(keyGen) {
|
|
16
|
-
return keyGen.keylist ?? [];
|
|
17
|
-
}
|
|
1
|
+
import { getClientIdFromKeyGenResult } from '@continuumdao/continuum-node-sdk';
|
|
2
|
+
export { getClientIdFromKeyGenResult as firstClientIdFromKeyGen } from '@continuumdao/continuum-node-sdk';
|
|
3
|
+
|
|
4
|
+
// src/core/index.ts
|
|
18
5
|
|
|
19
6
|
// src/core/purpose.ts
|
|
20
7
|
function mergePurposeText(purposeText, purposeSuffix) {
|
|
@@ -25,8 +12,6 @@ function mergePurposeText(purposeText, purposeSuffix) {
|
|
|
25
12
|
|
|
26
13
|
${suffix}` : suffix;
|
|
27
14
|
}
|
|
28
|
-
|
|
29
|
-
// src/core/envelope.ts
|
|
30
15
|
function finalizeMultisign(input) {
|
|
31
16
|
const { keyGen, destinationChainID, legs } = input;
|
|
32
17
|
if (legs.length === 0) {
|
|
@@ -35,7 +20,7 @@ function finalizeMultisign(input) {
|
|
|
35
20
|
const ph = (keyGen.pubkeyhex ?? "").trim();
|
|
36
21
|
if (!ph) throw new Error("keyGen pubKey (pubkeyhex) is required");
|
|
37
22
|
const keyList = keyGen.keylist ?? [];
|
|
38
|
-
const clientId =
|
|
23
|
+
const clientId = getClientIdFromKeyGenResult(keyGen);
|
|
39
24
|
const first = legs[0];
|
|
40
25
|
const messageHashes = legs.map((l) => l.msgHash);
|
|
41
26
|
const messageRawBatch = legs.map((l) => l.msgRaw);
|
|
@@ -101,85 +86,6 @@ function getActionsByChainCategory(category) {
|
|
|
101
86
|
return modules.filter((m) => m.chainCategory === category).flatMap((m) => m.actions);
|
|
102
87
|
}
|
|
103
88
|
|
|
104
|
-
|
|
105
|
-
function nodeFetchWithReadAuth(url, init, auth) {
|
|
106
|
-
const method = (init?.method ?? "GET").toUpperCase();
|
|
107
|
-
const headers = new Headers(init?.headers);
|
|
108
|
-
if (auth.bearerOnGet && method === "GET" && auth.jwt && auth.jwt.trim()) {
|
|
109
|
-
headers.set("Authorization", `Bearer ${auth.jwt.trim()}`);
|
|
110
|
-
}
|
|
111
|
-
return fetch(url, { ...init, headers });
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// src/core/managementPostSig.ts
|
|
115
|
-
function normalizeManagementNodeKey(nodeKey) {
|
|
116
|
-
const nk = nodeKey?.trim().replace(/^0x/i, "");
|
|
117
|
-
if (!nk || !/^[0-9a-fA-F]{128}$/.test(nk)) {
|
|
118
|
-
throw new Error("nodeKey is required (128 hex from GET /getNodeKey).");
|
|
119
|
-
}
|
|
120
|
-
return nk.toLowerCase();
|
|
121
|
-
}
|
|
122
|
-
function managementSigFields(nonce, nodeKey) {
|
|
123
|
-
return { nonce, clientSig: "", nodeKey: normalizeManagementNodeKey(nodeKey) };
|
|
124
|
-
}
|
|
125
|
-
function buildManagementPostBody(nonce, nodeKey, fields = {}) {
|
|
126
|
-
return { ...managementSigFields(nonce, nodeKey), ...fields };
|
|
127
|
-
}
|
|
128
|
-
function messageToSignManagementBody(body) {
|
|
129
|
-
return JSON.stringify({ ...body, clientSig: "" });
|
|
130
|
-
}
|
|
131
|
-
function withManagementClientSig(body, clientSig) {
|
|
132
|
-
return { ...body, clientSig: clientSig.trim().replace(/^0x/i, "") };
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// src/core/managementNonce.ts
|
|
136
|
-
function mpcAuthData(raw) {
|
|
137
|
-
const code = raw.Code ?? raw.code;
|
|
138
|
-
if (code !== 0 && code !== void 0) return void 0;
|
|
139
|
-
return raw.Data ?? raw.data;
|
|
140
|
-
}
|
|
141
|
-
async function fetchNodeKey(nodeUrl, readAuth = { bearerOnGet: false, jwt: null }) {
|
|
142
|
-
const base = nodeUrl.trim().replace(/\/$/, "");
|
|
143
|
-
const res = await nodeFetchWithReadAuth(`${base}/getNodeKey`, { cache: "no-store" }, readAuth);
|
|
144
|
-
const text = await res.text();
|
|
145
|
-
let raw;
|
|
146
|
-
try {
|
|
147
|
-
raw = JSON.parse(text);
|
|
148
|
-
} catch {
|
|
149
|
-
return { nodeKey: "", ok: false };
|
|
150
|
-
}
|
|
151
|
-
const data = mpcAuthData(raw);
|
|
152
|
-
const nk = typeof data === "string" ? data : data != null && typeof data === "object" && !Array.isArray(data) ? String(data.nodeKey ?? data.NodeKey ?? "") : data != null ? String(data) : "";
|
|
153
|
-
const trimmed = nk.trim().replace(/^0x/i, "");
|
|
154
|
-
if (!/^[0-9a-fA-F]{128}$/.test(trimmed)) {
|
|
155
|
-
return { nodeKey: "", ok: false };
|
|
156
|
-
}
|
|
157
|
-
return { nodeKey: trimmed.toLowerCase(), ok: res.ok };
|
|
158
|
-
}
|
|
159
|
-
async function fetchManagementNonce(nodeUrl, useEd25519, ed25519PublicKey, readAuth = { bearerOnGet: false, jwt: null }) {
|
|
160
|
-
const base = nodeUrl.trim().replace(/\/$/, "");
|
|
161
|
-
const path = useEd25519 ? "/getPublicMgtKeyNonce" : "/getNodeMgtKeyNonce";
|
|
162
|
-
const url = useEd25519 && ed25519PublicKey && /^[0-9a-fA-F]{64}$/.test(ed25519PublicKey.trim()) ? `${base}${path}?publicKey=${encodeURIComponent(ed25519PublicKey.trim())}` : `${base}${path}`;
|
|
163
|
-
const res = await nodeFetchWithReadAuth(url, { cache: "no-store" }, readAuth);
|
|
164
|
-
const text = await res.text();
|
|
165
|
-
let raw;
|
|
166
|
-
try {
|
|
167
|
-
raw = JSON.parse(text);
|
|
168
|
-
} catch {
|
|
169
|
-
return { nonce: 0, ok: false, code: -1 };
|
|
170
|
-
}
|
|
171
|
-
const code = raw.Code ?? raw.code;
|
|
172
|
-
const payload = mpcAuthData(raw) ?? raw.Data ?? raw.data;
|
|
173
|
-
let nonce = 0;
|
|
174
|
-
if (typeof payload === "number" && !Number.isNaN(payload)) {
|
|
175
|
-
nonce = payload;
|
|
176
|
-
} else if (payload && typeof payload === "object") {
|
|
177
|
-
const n = payload.nonce ?? payload.Nonce;
|
|
178
|
-
nonce = typeof n === "number" && !Number.isNaN(n) ? n : Number(n) || 0;
|
|
179
|
-
}
|
|
180
|
-
return { nonce, ok: res.ok && (code === 0 || code === void 0), code: code ?? -1 };
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
export { buildManagementPostBody, coreChainCategoryModule, fetchManagementNonce, fetchNodeKey, finalizeMultisign, firstClientIdFromKeyGen, getActionsByChainCategory, getProtocolModule, getProtocolModules, keyListFromKeyGen, managementSigFields, mergePurposeText, messageToSignManagementBody, nodeFetchWithReadAuth, normalizeManagementNodeKey, registerProtocolModule, requirePubKeyHex, withManagementClientSig };
|
|
89
|
+
export { coreChainCategoryModule, finalizeMultisign, getActionsByChainCategory, getProtocolModule, getProtocolModules, mergePurposeText, registerProtocolModule };
|
|
184
90
|
//# sourceMappingURL=index.js.map
|
|
185
91
|
//# sourceMappingURL=index.js.map
|