@continuumdao/ctm-mpc-defi 0.2.28 → 0.2.30
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 +1305 -21
- package/dist/agent/catalog.cjs.map +1 -1
- package/dist/agent/catalog.d.ts +1468 -1
- package/dist/agent/catalog.js +1236 -23
- package/dist/agent/catalog.js.map +1 -1
- package/dist/agent/skills/continuum-dao/SKILL.md +139 -0
- package/dist/agent/skills/ethena/SKILL.md +1 -1
- package/dist/agent/skills/lido/SKILL.md +4 -1
- package/dist/core/index.cjs +42 -39
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +42 -39
- package/dist/core/index.js.map +1 -1
- package/dist/{eip712Multisign-xhXpUYp3.d.ts → eip712Multisign-DCW7heqX.d.ts} +11 -8
- package/dist/index.cjs +64 -57
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +64 -57
- package/dist/index.js.map +1 -1
- package/dist/protocols/evm/arcus/index.cjs +62 -55
- package/dist/protocols/evm/arcus/index.cjs.map +1 -1
- package/dist/protocols/evm/arcus/index.js +62 -55
- package/dist/protocols/evm/arcus/index.js.map +1 -1
- package/dist/protocols/evm/continuum-dao/index.cjs +2237 -0
- package/dist/protocols/evm/continuum-dao/index.cjs.map +1 -0
- package/dist/protocols/evm/continuum-dao/index.d.ts +700 -0
- package/dist/protocols/evm/continuum-dao/index.js +2110 -0
- package/dist/protocols/evm/continuum-dao/index.js.map +1 -0
- package/dist/protocols/evm/ethena/index.cjs +41 -4
- package/dist/protocols/evm/ethena/index.cjs.map +1 -1
- package/dist/protocols/evm/ethena/index.d.ts +12 -2
- package/dist/protocols/evm/ethena/index.js +38 -5
- package/dist/protocols/evm/ethena/index.js.map +1 -1
- package/dist/protocols/evm/hyperliquid/index.cjs +125 -110
- package/dist/protocols/evm/hyperliquid/index.cjs.map +1 -1
- package/dist/protocols/evm/hyperliquid/index.js +125 -110
- package/dist/protocols/evm/hyperliquid/index.js.map +1 -1
- package/dist/protocols/evm/lido/index.cjs +66 -1
- package/dist/protocols/evm/lido/index.cjs.map +1 -1
- package/dist/protocols/evm/lido/index.d.ts +11 -1
- package/dist/protocols/evm/lido/index.js +60 -2
- package/dist/protocols/evm/lido/index.js.map +1 -1
- package/dist/protocols/evm/permit2/index.cjs +66 -59
- package/dist/protocols/evm/permit2/index.cjs.map +1 -1
- package/dist/protocols/evm/permit2/index.js +66 -59
- package/dist/protocols/evm/permit2/index.js.map +1 -1
- package/dist/protocols/evm/uniswap-v4/index.cjs +63 -56
- package/dist/protocols/evm/uniswap-v4/index.cjs.map +1 -1
- package/dist/protocols/evm/uniswap-v4/index.d.ts +1 -1
- package/dist/protocols/evm/uniswap-v4/index.js +63 -56
- package/dist/protocols/evm/uniswap-v4/index.js.map +1 -1
- package/package.json +6 -1
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: continuum-dao
|
|
3
|
+
description: ContinuumDAO CTM lock, veCTM escrow, node attach, and Linea governance (Bravo/Delta propose, vote, execute, cancel).
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# ContinuumDAO (MCP)
|
|
7
|
+
|
|
8
|
+
## Chains
|
|
9
|
+
|
|
10
|
+
- **Linea (59144) / Linea Sepolia (59141)** — create lock, escrow actions, attach veCTM, request detach, and governance.
|
|
11
|
+
- **Ethereum mainnet (`chainId: 1`)** — CTM hold/transfer only. Governance is Linea-only.
|
|
12
|
+
|
|
13
|
+
Addresses are placeholders until CTM / VotingEscrow / NodeProperties / Rewards / Governor are redeployed. Prefer live `GET https://app-api.continuumdao.org/protocol/dao|ve|networks` and pass `governor` when the constant is still zero. Do not submit write tools until the target address is non-zero.
|
|
14
|
+
|
|
15
|
+
## Billing
|
|
16
|
+
|
|
17
|
+
These tools build protocol batches only. Do **not** prepend MPA billing legs (`register`, `deposit`, `syncBilling`). Fee payment stays on Compose / credit modals.
|
|
18
|
+
|
|
19
|
+
## Governance encoding
|
|
20
|
+
|
|
21
|
+
One contract: `ContinuumDAO.propose`. Bravo vs Delta is encoding, not a separate function. Five UI types (Admin / Constitution / Decision / Election / Treasury) are backend tags; their **meaning** is the Constitution section **ContinuumDAO Proposals and Voting** (`get_continuum_doc` path `ContinuumDAO/Governance/Constitution`, `sectionId` `continuumdao-proposals-and-voting`). Load **`continuum-dao-proposal-standards`** and apply that fetch before choosing a type or appraising a proposal.
|
|
22
|
+
|
|
23
|
+
- **Bravo:** `targets[] / values[] / calldatas[]` are the actions; on-chain `description` is the title. Empty user actions insert one succeeding no-op (`target = KeyGen ETH`, `value = 0`, `calldata = 0x`) so `targets.length >= 1` and `targets[0] != address(0)`.
|
|
24
|
+
- **Delta:** slot 0 is metadata (`targets[0]=0`, `values[0]=0`, `calldatas[0]` = nOptions, nWinners, 1-indexed option starts). Remaining slots are flattened option actions. Empty options get the same no-op so start indices increment. Option **label** is required. Backend payload stores `actions: []` for empty options (user actions only).
|
|
25
|
+
- **Delta vote:** `weights` must be **nOptions + 1**. The last slot is baked-in NOTA. Do not ship nOptions-only params.
|
|
26
|
+
- **Queue is not implemented.** `queue()` reverts. Execute from `Succeeded`.
|
|
27
|
+
|
|
28
|
+
After a propose multi-sign request is **mined**, call `ctm_continuum_dao_register_proposal` (`POST /proposals/create`) so [app.continuumdao.org/governance](https://app.continuumdao.org/governance) stays in sync. If the POST fails, retry — do not revert the chain tx. `onchainId` comes from `hashProposal` or `ProposalCreated`.
|
|
29
|
+
|
|
30
|
+
`load_defi_protocol({ protocolId: "continuum-dao" })` loads escrow, attach, and governance together.
|
|
31
|
+
|
|
32
|
+
## Chat: “What proposals are live now?”
|
|
33
|
+
|
|
34
|
+
Do **not** answer from `ctm_continuum_dao_fetch_proposals` or backend `status` alone.
|
|
35
|
+
|
|
36
|
+
1. `load_defi_protocol({ protocolId: "continuum-dao" })` if not already loaded.
|
|
37
|
+
2. `ctm_continuum_dao_fetch_live_proposals({ chainId: 59144, rpcUrl })` (Linea Sepolia: `59141`). Get `rpcUrl` from the chain registry. Pass `governor` when the constant is still zero (from `GET https://app-api.continuumdao.org/protocol/dao`).
|
|
38
|
+
3. Read the returned `note`, then the buckets:
|
|
39
|
+
- **`live`** — `state === Active` (voting now). This is the answer to “live now.”
|
|
40
|
+
- **`pending`** — proposed, voting has not started.
|
|
41
|
+
- **`readyToExecute`** — `Succeeded`. No queue. Offer `ctm_continuum_dao_build_execute_multisign`.
|
|
42
|
+
- **`recentlyCompleted`** — Canceled / Defeated / Expired / Executed in this scan.
|
|
43
|
+
- **`unknown`** — no on-chain overlay (missing governor/RPC, or a failed `state` read). Do not call these live.
|
|
44
|
+
4. If `overlay` is `backend-only`, say you could not confirm live Governor state.
|
|
45
|
+
|
|
46
|
+
For one proposal, call `ctm_continuum_dao_explain_proposal` and read `briefing` aloud (every action / Delta option, no-ops labeled signaling, C3 called out). Do not vote from this protocol skill.
|
|
47
|
+
|
|
48
|
+
Operator presentation and vote policy live in the node catalogue (mpc-config): load skills **`continuum-dao-proposals`** and **`continuum-dao-vote-policy`** via `agent_load_skill`. To **create** a proposal in chat, load **`continuum-dao-compose-proposal`** (interactive only). Cron must never propose or load that skill — vote and governor Join only.
|
|
49
|
+
|
|
50
|
+
When a proposal has a `forumKey`, fetch that thread (`ctm_continuum_dao_forum_resolve` then `forum_fetch_thread` / `forum_fetch_post`) before voting. Check `section` on the thread against the proposal type. List recent posts with `forum_recent` (`hours` or `since`; privilege-filtered, whole forum; id, title, username, createdAt), or find matching posts with `forum_search` (title of a new thread or body text, case-insensitive; optional `hours` / `since`), then `forum_fetch_post` on a returned `id`. Walk a user's posts with `forum_user_post_ids` then `forum_fetch_post`. Writes need a `ticket` from forum EIP-712 login. `forum_unread` / `forum_mark_read` / `forum_mark_unread` are **interactive inbox** tools (NodeBB Unread is per topic). Confirm before `forum_mark_read` with `all: true`. `forum_delete` is **admin/moderator only** (not the post owner): exactly one of `pid`, `tid`/`url`, or `username`; optional `hours` / `since` (default all). Confirm with the operator before deleting. Never from cron.
|
|
51
|
+
|
|
52
|
+
**Classify first: Idea vs formal proposal.** An Idea/Suggestion is early discussion or feedback — not a Temperature Check. Post it with `forum_create_idea`. Do **not** use that URL as `forumKey`. A formal proposal belongs in a **Governance** section and must go on-chain.
|
|
53
|
+
|
|
54
|
+
| Type | Forum `section` | Typical vote |
|
|
55
|
+
|------|-----------------|--------------|
|
|
56
|
+
| Decision | `decision` | Bravo |
|
|
57
|
+
| Election | `election` | Delta |
|
|
58
|
+
| Treasury | `treasury` | Bravo |
|
|
59
|
+
| Constitution | `constitution` | Bravo (include the new Constitution text) |
|
|
60
|
+
| Admin | `admin` | Bravo |
|
|
61
|
+
|
|
62
|
+
**A proposal MUST have a Governance forum thread.** Never call `build_propose_*` or `register_proposal` with the homepage, an empty `forumKey`, or an Ideas thread. Required agent order:
|
|
63
|
+
|
|
64
|
+
1. `forum_sign_in_eligible` then `build_forum_sign_in_multisign` (if no ticket).
|
|
65
|
+
2. If it is only an idea: `forum_create_idea`. Stop (no propose).
|
|
66
|
+
3. If it is a proposal: `forum_create_topic` with the matching Governance `section` (proposal-threshold veCTM). Keep the returned `url`.
|
|
67
|
+
4. `build_propose_bravo_multisign` or `build_propose_delta_multisign` with that `url` as `forumKey`.
|
|
68
|
+
5. After the propose tx is mined, `register_proposal` with the same `forumKey`.
|
|
69
|
+
|
|
70
|
+
`forumKey` must match `/topic/:tid` or `/t/:tid` on forum.continuumdao.org. Builders and `register_proposal` throw otherwise.
|
|
71
|
+
|
|
72
|
+
Forum KeyGen sign-in is EIP-712 multi-sign (no EVM tx). Always check eligibility first:
|
|
73
|
+
|
|
74
|
+
1. `ctm_continuum_dao_forum_sign_in_eligible({ address })` — holder or attach-key veCTM vs `veCtmThresholdPower`. If `eligible` is false, stop. Do **not** compose a multi-sign request.
|
|
75
|
+
2. `ctm_continuum_dao_build_forum_sign_in_multisign` also refuses ineligible addresses (same gate) so other nodes never enter the sign loop. Pass `nodeKey` (username = first 16 chars) or a `username` on first login.
|
|
76
|
+
3. After the multi-sign request is signed, exchange the signature for a ticket (`/api/continuum/eip712/ticket`). Then `forum_reply` / `forum_react` / `forum_create_topic` / `forum_create_idea`.
|
|
77
|
+
4. `ctm_continuum_dao_forum_sign_out({ ticket })` revokes the ticket and forum sessions. No multi-sign.
|
|
78
|
+
|
|
79
|
+
Forum sign-in and sign-out are **agent/MCP only**. There is no Sign in / Sign out control in the node-app Compose header.
|
|
80
|
+
|
|
81
|
+
Propose builders read live `proposalThreshold()` and refuse if `getVotes(KeyGen) < threshold`. On-chain rule (vectm `ContinuumDAO`): `max(1000 ether, 1% of past total voting power)`. Do not hardcode `1000`.
|
|
82
|
+
|
|
83
|
+
## Tools
|
|
84
|
+
|
|
85
|
+
| Intent | Tool |
|
|
86
|
+
|--------|------|
|
|
87
|
+
| Create lock | `ctm_continuum_dao_build_create_lock_multisign` |
|
|
88
|
+
| Increase amount | `ctm_continuum_dao_build_increase_amount_multisign` |
|
|
89
|
+
| Increase unlock time | `ctm_continuum_dao_build_increase_unlock_time_multisign` |
|
|
90
|
+
| Split | `ctm_continuum_dao_build_split_multisign` |
|
|
91
|
+
| Merge | `ctm_continuum_dao_build_merge_multisign` |
|
|
92
|
+
| Withdraw | `ctm_continuum_dao_build_withdraw_multisign` |
|
|
93
|
+
| Liquidate | `ctm_continuum_dao_build_liquidate_multisign` |
|
|
94
|
+
| Delegate | `ctm_continuum_dao_build_delegate_multisign` |
|
|
95
|
+
| Undelegate (delegate to self) | `ctm_continuum_dao_build_undelegate_multisign` |
|
|
96
|
+
| Fetch current delegatee | `ctm_continuum_dao_fetch_delegates` |
|
|
97
|
+
| Transfer NFT | `ctm_continuum_dao_build_transfer_multisign` |
|
|
98
|
+
| Attach veCTM | `ctm_continuum_dao_build_attach_multisign` |
|
|
99
|
+
| Request detach | `ctm_continuum_dao_build_request_detach_multisign` |
|
|
100
|
+
| Propose Bravo | `ctm_continuum_dao_build_propose_bravo_multisign` |
|
|
101
|
+
| Propose Delta | `ctm_continuum_dao_build_propose_delta_multisign` |
|
|
102
|
+
| Vote Bravo | `ctm_continuum_dao_build_cast_vote_bravo_multisign` |
|
|
103
|
+
| Vote Delta (+ NOTA) | `ctm_continuum_dao_build_cast_vote_delta_multisign` |
|
|
104
|
+
| Execute | `ctm_continuum_dao_build_execute_multisign` |
|
|
105
|
+
| Cancel | `ctm_continuum_dao_build_cancel_multisign` |
|
|
106
|
+
| Register proposal (backend) | `ctm_continuum_dao_register_proposal` |
|
|
107
|
+
| Fetch live / pending / executable | `ctm_continuum_dao_fetch_live_proposals` |
|
|
108
|
+
| Explain / deconstruct one proposal | `ctm_continuum_dao_explain_proposal` |
|
|
109
|
+
| Fetch raw backend list | `ctm_continuum_dao_fetch_proposals` |
|
|
110
|
+
| Fetch one proposal | `ctm_continuum_dao_fetch_proposal` |
|
|
111
|
+
| Fetch on-chain state | `ctm_continuum_dao_fetch_proposal_state` |
|
|
112
|
+
| Fetch voting power | `ctm_continuum_dao_fetch_voting_power` |
|
|
113
|
+
| Forum sign-in eligible? | `ctm_continuum_dao_forum_sign_in_eligible` |
|
|
114
|
+
| Forum KeyGen sign-in | `ctm_continuum_dao_build_forum_sign_in_multisign` |
|
|
115
|
+
| Forum sign-out | `ctm_continuum_dao_forum_sign_out` |
|
|
116
|
+
| Resolve forum URL | `ctm_continuum_dao_forum_resolve` |
|
|
117
|
+
| Fetch forum thread | `ctm_continuum_dao_forum_fetch_thread` |
|
|
118
|
+
| Fetch one forum post | `ctm_continuum_dao_forum_fetch_post` |
|
|
119
|
+
| Search forum (title/body, optional recency) | `ctm_continuum_dao_forum_search` |
|
|
120
|
+
| Recent forum posts (id, title, username, createdAt; hours / since) | `ctm_continuum_dao_forum_recent` |
|
|
121
|
+
| Admin/mod delete post, thread, or user posts | `ctm_continuum_dao_forum_delete` |
|
|
122
|
+
| User post ids | `ctm_continuum_dao_forum_user_post_ids` |
|
|
123
|
+
| Forum reply count | `ctm_continuum_dao_forum_reply_count` |
|
|
124
|
+
| Forum reply | `ctm_continuum_dao_forum_reply` |
|
|
125
|
+
| Forum react | `ctm_continuum_dao_forum_react` |
|
|
126
|
+
| Create Governance proposal thread | `ctm_continuum_dao_forum_create_topic` |
|
|
127
|
+
| Post Idea / Suggestion | `ctm_continuum_dao_forum_create_idea` |
|
|
128
|
+
| Forum unread topics | `ctm_continuum_dao_forum_unread` |
|
|
129
|
+
| Forum mark topic read | `ctm_continuum_dao_forum_mark_read` |
|
|
130
|
+
| Forum mark topic unread | `ctm_continuum_dao_forum_mark_unread` |
|
|
131
|
+
| Forum me / sections | `ctm_continuum_dao_forum_me` / `ctm_continuum_dao_forum_sections` |
|
|
132
|
+
|
|
133
|
+
Attach requires the claimed `nodeWithdrawAuthority` KeyGen that owns the NFT. `groupId` is implicit from that KeyGen. You cannot replace an attached NFT — only governance detaches after `request detach`.
|
|
134
|
+
|
|
135
|
+
Attached locks block transfer / merge / split / withdraw on-chain (`checkNotAttached`).
|
|
136
|
+
|
|
137
|
+
Propose and vote use `getVotes` at the **KeyGen** address. If the KeyGen has delegated away (`fetch_delegates` → `self: false`), that power sits with the delegatee until `build_undelegate_multisign` (on-chain this is `delegate(self)`; there is no `undelegate()`). Attach-to-node is unrelated. Propose requires `getVotes(keyAddress) >= proposalThreshold()`. The live threshold is `max(1000e18 ve power, 1% of total voting power)`, not a flat 1000. `ctm_continuum_dao_build_propose_*` throws if the KeyGen is below the live bar.
|
|
138
|
+
|
|
139
|
+
All `ctm_continuum_dao_build_*_multisign` tools return `{ requestId }` on success (shared gas/submit section appended by the server).
|
|
@@ -5,6 +5,6 @@ description: Ethena USDe stake, redeem, cooldown, and claim on Ethereum mainnet.
|
|
|
5
5
|
|
|
6
6
|
# Ethena (MCP)
|
|
7
7
|
|
|
8
|
-
Stake/redeem MCP tools target **mainnet (chainId 1)**.
|
|
8
|
+
Stake/redeem MCP tools target **mainnet (chainId 1)**. USDe/sUSDe are also listed on several L2s including **Robinhood Chain (4663)** for asset recognition/transfers — use `get_defi_protocol_supported_tokens` for addresses.
|
|
9
9
|
|
|
10
10
|
Tools: `ctm_ethena_build_stake_multisign`, `_redeem_`, `_cooldown_`, `_claim_`. Each returns `{ requestId }` on success (shared gas/submit section appended by the server).
|
|
@@ -7,7 +7,10 @@ description: Lido ETH staking, withdrawals, and wstETH wrap/unwrap on Ethereum m
|
|
|
7
7
|
|
|
8
8
|
## Chains
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
- **Ethereum mainnet (`chainId: 1`)** — stake, withdraw, wrap/unwrap MCP tools.
|
|
11
|
+
- **Robinhood Chain (`chainId: 4663`)** — bridged wstETH recognition only (no stake/withdraw on 4663).
|
|
12
|
+
|
|
13
|
+
Use `get_defi_protocol_supported_chains` / `get_defi_protocol_supported_tokens` and confirm the node has the chain in `get_chain_registry`.
|
|
11
14
|
|
|
12
15
|
## Tools
|
|
13
16
|
|
package/dist/core/index.cjs
CHANGED
|
@@ -182,57 +182,60 @@ function eip712SignatureText(domain, primaryType) {
|
|
|
182
182
|
function jsonStringifyForAudit(value) {
|
|
183
183
|
return JSON.stringify(value, (_, v) => typeof v === "bigint" ? v.toString() : v);
|
|
184
184
|
}
|
|
185
|
-
function
|
|
186
|
-
|
|
185
|
+
function eip712LegEnvelope(typedData, delivery, digest) {
|
|
186
|
+
return {
|
|
187
187
|
version: 1,
|
|
188
|
-
|
|
189
|
-
delivery
|
|
190
|
-
};
|
|
191
|
-
return viem.stringToHex(jsonStringifyForAudit(envelope));
|
|
192
|
-
}
|
|
193
|
-
function buildEip712MultisignBody(args) {
|
|
194
|
-
const { typedData, delivery } = args;
|
|
195
|
-
const digest = viem.hashTypedData({
|
|
188
|
+
digest,
|
|
196
189
|
domain: typedData.domain,
|
|
197
190
|
types: typedData.types,
|
|
198
191
|
primaryType: typedData.primaryType,
|
|
199
|
-
message: typedData.message
|
|
200
|
-
});
|
|
201
|
-
const extraJSON = {
|
|
202
|
-
signRequestKind: EIP712_SIGN_REQUEST_KIND,
|
|
203
|
-
eip712: {
|
|
204
|
-
version: 1,
|
|
205
|
-
digest,
|
|
206
|
-
domain: typedData.domain,
|
|
207
|
-
types: typedData.types,
|
|
208
|
-
primaryType: typedData.primaryType,
|
|
209
|
-
message: typedData.message
|
|
210
|
-
},
|
|
192
|
+
message: typedData.message,
|
|
211
193
|
delivery
|
|
212
194
|
};
|
|
195
|
+
}
|
|
196
|
+
function eip712MsgRawHex(envelope) {
|
|
197
|
+
return viem.stringToHex(jsonStringifyForAudit(envelope));
|
|
198
|
+
}
|
|
199
|
+
function buildEip712Multisign(args) {
|
|
200
|
+
if (args.legs.length < 1) {
|
|
201
|
+
throw new Error("buildEip712Multisign requires at least one leg");
|
|
202
|
+
}
|
|
203
|
+
const eip712 = [];
|
|
204
|
+
const legs = args.legs.map((leg) => {
|
|
205
|
+
const digest = viem.hashTypedData({
|
|
206
|
+
domain: leg.typedData.domain,
|
|
207
|
+
types: leg.typedData.types,
|
|
208
|
+
primaryType: leg.typedData.primaryType,
|
|
209
|
+
message: leg.typedData.message
|
|
210
|
+
});
|
|
211
|
+
const envelope = eip712LegEnvelope(leg.typedData, leg.delivery, digest);
|
|
212
|
+
eip712.push(envelope);
|
|
213
|
+
return {
|
|
214
|
+
msgHash: msgHashNo0x(digest),
|
|
215
|
+
msgRaw: eip712MsgRawHex(envelope),
|
|
216
|
+
destinationAddress: args.destinationAddress,
|
|
217
|
+
signatureText: eip712SignatureText(leg.typedData.domain, leg.typedData.primaryType),
|
|
218
|
+
audit: {
|
|
219
|
+
kind: "EIP712",
|
|
220
|
+
primaryType: leg.typedData.primaryType,
|
|
221
|
+
deliveryKind: leg.delivery.kind,
|
|
222
|
+
...leg.audit ?? {}
|
|
223
|
+
},
|
|
224
|
+
feeSnapshot: {}
|
|
225
|
+
};
|
|
226
|
+
});
|
|
213
227
|
return finalizeMultisign({
|
|
214
228
|
keyGen: args.keyGen,
|
|
215
229
|
purposeText: args.purposeText,
|
|
216
230
|
purposeSuffix: args.purposeSuffix,
|
|
217
231
|
destinationChainID: args.destinationChainID,
|
|
218
232
|
destinationAddress: args.destinationAddress,
|
|
219
|
-
extraJSON
|
|
233
|
+
extraJSON: {
|
|
234
|
+
signRequestKind: EIP712_SIGN_REQUEST_KIND,
|
|
235
|
+
eip712
|
|
236
|
+
},
|
|
220
237
|
expiryDate: args.expiryDate,
|
|
221
|
-
legs
|
|
222
|
-
{
|
|
223
|
-
msgHash: msgHashNo0x(digest),
|
|
224
|
-
msgRaw: eip712MsgRawHex(typedData, delivery),
|
|
225
|
-
destinationAddress: args.destinationAddress,
|
|
226
|
-
signatureText: eip712SignatureText(typedData.domain, typedData.primaryType),
|
|
227
|
-
audit: {
|
|
228
|
-
kind: "EIP712",
|
|
229
|
-
primaryType: typedData.primaryType,
|
|
230
|
-
deliveryKind: delivery.kind,
|
|
231
|
-
...args.audit ?? {}
|
|
232
|
-
},
|
|
233
|
-
feeSnapshot: {}
|
|
234
|
-
}
|
|
235
|
-
]
|
|
238
|
+
legs
|
|
236
239
|
});
|
|
237
240
|
}
|
|
238
241
|
var PAYLOAD_SIGN_ED25519_REQUEST_KIND = "payload_sign_ed25519";
|
|
@@ -315,7 +318,7 @@ exports.DEFAULT_DEFI_MULTISIGN_EXPIRY_SECONDS = DEFAULT_DEFI_MULTISIGN_EXPIRY_SE
|
|
|
315
318
|
exports.DEFI_PROTOCOLS_WITH_30MIN_EXPIRY = DEFI_PROTOCOLS_WITH_30MIN_EXPIRY;
|
|
316
319
|
exports.EIP712_SIGN_REQUEST_KIND = EIP712_SIGN_REQUEST_KIND;
|
|
317
320
|
exports.PAYLOAD_SIGN_ED25519_REQUEST_KIND = PAYLOAD_SIGN_ED25519_REQUEST_KIND;
|
|
318
|
-
exports.
|
|
321
|
+
exports.buildEip712Multisign = buildEip712Multisign;
|
|
319
322
|
exports.buildPayloadSignEd25519MultisignBody = buildPayloadSignEd25519MultisignBody;
|
|
320
323
|
exports.coreChainCategoryModule = coreChainCategoryModule;
|
|
321
324
|
exports.defiMultisignExpiryUnixSeconds = defiMultisignExpiryUnixSeconds;
|
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","../../src/core/payloadSignEd25519Multisign.ts","../../src/core/expiry.ts"],"names":["getClientIdFromKeyGenResult","r","stringToHex","hashTypedData"],"mappings":";;;;;;;;AACO,SAAS,gBAAA,CAAiB,aAAiC,aAAA,EAAgC;AAChG,EAAA,MAAM,CAAA,GAAA,CAAK,WAAA,IAAe,EAAA,EAAI,IAAA,EAAK;AACnC,EAAA,MAAM,MAAA,GAAA,CAAU,aAAA,IAAiB,EAAA,EAAI,IAAA,EAAK;AAC1C,EAAA,IAAI,CAAC,QAAQ,OAAO,CAAA;AACpB,EAAA,OAAO,CAAA,GAAI,GAAG,CAAC;;AAAA,EAAO,MAAM,CAAA,CAAA,GAAK,MAAA;AACnC;ACgCO,SAAS,kBAAkB,KAAA,EAAsD;AACtF,EAAA,MAAM,EAAE,MAAA,EAAQ,kBAAA,EAAoB,IAAA,EAAK,GAAI,KAAA;AAC7C,EAAA,IAAI,IAAA,CAAK,WAAW,CAAA,EAAG;AACrB,IAAA,MAAM,IAAI,MAAM,6CAA6C,CAAA;AAAA,EAC/D;AAEA,EAAA,MAAM,EAAA,GAAA,CAAM,MAAA,CAAO,SAAA,IAAa,EAAA,EAAI,IAAA,EAAK;AACzC,EAAA,IAAI,CAAC,EAAA,EAAI,MAAM,IAAI,MAAM,uCAAuC,CAAA;AAEhE,EAAA,MAAM,OAAA,GAAU,MAAA,CAAO,OAAA,IAAW,EAAC;AACnC,EAAA,MAAM,QAAA,GAAWA,6CAA4B,MAAM,CAAA;AACnD,EAAA,MAAM,KAAA,GAAQ,KAAK,CAAC,CAAA;AAEpB,EAAA,MAAM,gBAAgB,IAAA,CAAK,GAAA,CAAI,CAAC,CAAA,KAAM,EA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AI;AAAA,EACtD,YAAA;AAAA,EACA,KAAA;AAAA,EACA,aAAA;AAAA,EACA,OAAA;AAAA,EACA;AACF,CAAC;AAEM,SAAS,8BAAA,CACd,YACA,kBAAA,EACoB;AACpB,EAAA,IAAI,OAAO,uBAAuB,QAAA,IAAY,MAAA,CAAO,SAAS,kBAAkB,CAAA,IAAK,qBAAqB,CAAA,EAAG;AAC3G,IAAA,OAAO,IAAA,CAAK,MAAM,kBAAkB,CAAA;AAAA,EACtC;AACA,EAAA,IAAI,UAAA,IAAc,gCAAA,CAAiC,GAAA,CAAI,UAAU,CAAA,EAAG;AAClE,IAAA,OAAO,KAAK,KAAA,CAAM,IAAA,CAAK,GAAA,EAAI,GAAI,GAAI,CAAA,GAAI,qCAAA;AAAA,EACzC;AACA,EAAA,OAAO,MAAA;AACT","file":"index.cjs","sourcesContent":["/** Merge user purpose text with an optional batch / protocol suffix. */\nexport function mergePurposeText(purposeText: string | undefined, purposeSuffix?: string): string {\n const t = (purposeText ?? '').trim()\n const suffix = (purposeSuffix ?? '').trim()\n if (!suffix) return t\n return t ? `${t}\\n\\n${suffix}` : suffix\n}\n","import type { ChainCategory, MultisignBuildResult, KeyGenSubset } from './types.js'\nimport { getClientIdFromKeyGenResult } from '@continuumdao/continuum-node-sdk'\nimport { mergePurposeText } from './purpose.js'\n\nexport interface MultisignLeg {\n msgHash: string\n msgRaw: string\n destinationAddress: string\n signatureText: string\n audit: Record<string, unknown>\n feeSnapshot: Record<string, unknown>\n proposalTxParams?: Record<string, unknown>\n /** Payable value wei string for first leg only when relevant */\n valueWei?: bigint\n}\n\nexport interface ChainCategoryBuildInput {\n keyGen: KeyGenSubset\n purposeText: string\n purposeSuffix?: string\n destinationChainID: string\n legs: MultisignLeg[]\n extraJSON?: Record<string, unknown>\n /** Top-level destination address (first leg destination if omitted) */\n destinationAddress?: string\n /** Unix seconds (UTC) for mpc-auth multiSignRequest expiryDate. */\n expiryDate?: number\n}\n\nexport interface ChainCategoryModule {\n category: ChainCategory\n finalizeMultisign(input: ChainCategoryBuildInput): MultisignBuildResult\n}\n\n/**\n * Assemble mpc-auth `bodyForSign` from category-built legs.\n * Supports single-tx and batch (messageHashes / messageRawBatch / proposalTxParams).\n */\nexport function finalizeMultisign(input: ChainCategoryBuildInput): MultisignBuildResult {\n const { keyGen, destinationChainID, legs } = input\n if (legs.length === 0) {\n throw new Error('finalizeMultisign requires at least one leg')\n }\n\n const ph = (keyGen.pubkeyhex ?? '').trim()\n if (!ph) throw new Error('keyGen pubKey (pubkeyhex) is required')\n\n const keyList = keyGen.keylist ?? []\n const clientId = getClientIdFromKeyGenResult(keyGen)\n const first = legs[0]!\n\n const messageHashes = legs.map((l) => l.msgHash)\n const messageRawBatch = legs.map((l) => l.msgRaw)\n const batchMeta = legs.map((l) => ({\n destinationAddress: l.destinationAddress,\n signatureText: l.signatureText,\n ...l.audit,\n }))\n\n const proposalTxParams = legs\n .map((l) => l.proposalTxParams)\n .filter((p): p is Record<string, unknown> => p != null && typeof p === 'object')\n\n const extraPayload: Record<string, unknown> = {\n batchMeta,\n ...(input.extraJSON ?? {}),\n }\n const extraJSON = JSON.stringify(extraPayload, (_, v) => (typeof v === 'bigint' ? v.toString() : v))\n\n const bodyForSign: Record<string, unknown> = {\n keyList,\n pubKey: ph,\n msgHash: messageHashes[0],\n msgRaw: first.msgRaw,\n destinationChainID,\n destinationAddress: input.destinationAddress ?? first.destinationAddress,\n extraJSON,\n signatureText: first.signatureText,\n purpose: mergePurposeText(input.purposeText, input.purposeSuffix),\n ...first.feeSnapshot,\n }\n\n if (legs.length > 1) {\n bodyForSign.messageHashes = messageHashes\n bodyForSign.messageRawBatch = messageRawBatch\n }\n\n if (proposalTxParams.length > 0) {\n bodyForSign.proposalTxParams = proposalTxParams\n }\n\n const valueWei = first.valueWei\n if (valueWei != null && valueWei > 0n) {\n bodyForSign.value = valueWei.toString()\n }\n\n if (clientId) bodyForSign.clientId = clientId\n\n if (input.expiryDate != null && input.expiryDate > 0) {\n bodyForSign.expiryDate = Math.floor(input.expiryDate)\n }\n\n return { bodyForSign, messageToSign: JSON.stringify(bodyForSign) }\n}\n\nexport const coreChainCategoryModule: ChainCategoryModule = {\n category: 'evm',\n finalizeMultisign,\n}\n","import type { ProtocolModule } from './types.js'\n\nconst modules: ProtocolModule[] = []\n\nexport function registerProtocolModule(mod: ProtocolModule): void {\n const existing = modules.findIndex((m) => m.id === mod.id)\n if (existing >= 0) {\n modules[existing] = mod\n } else {\n modules.push(mod)\n }\n}\n\nexport function getProtocolModules(): readonly ProtocolModule[] {\n return modules\n}\n\nexport function getProtocolModule(id: string): ProtocolModule | undefined {\n return modules.find((m) => m.id === id)\n}\n\nexport function getActionsByChainCategory(category: string): ProtocolModule['actions'] {\n return modules.filter((m) => m.chainCategory === category).flatMap((m) => m.actions)\n}\n","/**\n * Optional browser → Next.js API proxy paths for DeFi upstream calls.\n * Set once from continuumdao-node-app client bootstrap.\n */\n\nlet aaveGraphqlProxyUrl: string | undefined\nlet eulerGraphqlProxyUrl: string | undefined\nlet mapleGraphqlProxyUrl: string | undefined\nlet morphoGraphqlProxyUrl: string | undefined\nlet coingeckoProxyUrl: string | undefined\n\nexport function setAaveGraphqlProxyUrl(url: string | undefined): void {\n aaveGraphqlProxyUrl = url?.trim() || undefined\n}\n\nexport function getAaveGraphqlProxyUrl(): string | undefined {\n return aaveGraphqlProxyUrl\n}\n\nexport function setEulerGraphqlProxyUrl(url: string | undefined): void {\n eulerGraphqlProxyUrl = url?.trim() || undefined\n}\n\nexport function getEulerGraphqlProxyUrl(): string | undefined {\n return eulerGraphqlProxyUrl\n}\n\nexport function setMapleGraphqlProxyUrl(url: string | undefined): void {\n mapleGraphqlProxyUrl = url?.trim() || undefined\n}\n\nexport function getMapleGraphqlProxyUrl(): string | undefined {\n return mapleGraphqlProxyUrl\n}\n\nexport function setMorphoGraphqlProxyUrl(url: string | undefined): void {\n morphoGraphqlProxyUrl = url?.trim() || undefined\n}\n\nexport function getMorphoGraphqlProxyUrl(): string | undefined {\n return morphoGraphqlProxyUrl\n}\n\n/** Browser → Next.js base path for Morpho Midnight REST (replaces api.morpho.org/v0/midnight). */\nlet morphoMidnightRestProxyUrl: string | undefined\n\nexport function setMorphoMidnightRestProxyUrl(url: string | undefined): void {\n morphoMidnightRestProxyUrl = url?.trim() || undefined\n}\n\nexport function getMorphoMidnightRestProxyUrl(): string | undefined {\n return morphoMidnightRestProxyUrl\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\nexport async function getJsonViaOptionalProxy<T>(args: {\n directUrl: string\n /** When set, GET this URL instead of directUrl (same path semantics as caller built). */\n proxyUrl?: string\n}): Promise<T> {\n const url = args.proxyUrl?.trim() || args.directUrl\n const r = await fetch(url, { method: 'GET', headers: { accept: 'application/json' } })\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","import { stringToHex } from 'viem'\nimport type { KeyGenSubset, MultisignBuildResult } from './types.js'\nimport { finalizeMultisign } from './envelope.js'\n\nexport const PAYLOAD_SIGN_ED25519_REQUEST_KIND = 'payload_sign_ed25519' as const\n\nexport type PayloadSignEd25519Delivery = Record<string, unknown> & { kind: string }\n\nexport type BuildPayloadSignEd25519MultisignBodyArgs = {\n keyGen: KeyGenSubset\n purposeText: string\n purposeSuffix?: string\n destinationChainID: string\n destinationAddress: string\n /** UTF-8 bytes to sign (Arcus canonical JSON). */\n messageUtf8: string\n /** secp256k1 pub key hex for billing when signing with paired ed25519 KeyGen. */\n billingKeyGenPubKey?: string\n delivery: PayloadSignEd25519Delivery\n audit?: Record<string, unknown>\n expiryDate?: number\n signatureText?: string\n}\n\nfunction msgHashNo0xFromBytes(bytes: Uint8Array): string {\n return Buffer.from(bytes).toString('hex')\n}\n\nfunction payloadMsgRawHex(messageUtf8: string, delivery: PayloadSignEd25519Delivery): string {\n const envelope = {\n version: 1,\n messageUtf8,\n delivery,\n }\n return stringToHex(JSON.stringify(envelope))\n}\n\n/**\n * Build mpc-auth multiSignRequest for Ed25519 FROST signing over variable-length UTF-8 (Arcus Scheme 1).\n * `msgHash` is hex of the raw message bytes (not SHA-256); mpc-auth givre worker signs these bytes directly.\n */\nexport function buildPayloadSignEd25519MultisignBody(\n args: BuildPayloadSignEd25519MultisignBodyArgs,\n): MultisignBuildResult {\n const messageBytes = Buffer.from(args.messageUtf8, 'utf8')\n const msgHash = msgHashNo0xFromBytes(messageBytes)\n\n const extraJSON: Record<string, unknown> = {\n signRequestKind: PAYLOAD_SIGN_ED25519_REQUEST_KIND,\n payloadSignEd25519: {\n version: 1,\n messageHex: msgHash,\n messageLength: messageBytes.length,\n },\n delivery: args.delivery,\n }\n if (args.billingKeyGenPubKey?.trim()) {\n extraJSON.billingKeyGenPubKey = args.billingKeyGenPubKey.trim()\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,\n msgRaw: payloadMsgRawHex(args.messageUtf8, args.delivery),\n destinationAddress: args.destinationAddress,\n signatureText: args.signatureText ?? 'Arcus Ed25519 payload sign',\n audit: {\n kind: 'PAYLOAD_SIGN_ED25519',\n deliveryKind: args.delivery.kind,\n messageLength: messageBytes.length,\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 'arcus',\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
|
+
{"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/payloadSignEd25519Multisign.ts","../../src/core/expiry.ts"],"names":["getClientIdFromKeyGenResult","r","stringToHex","hashTypedData"],"mappings":";;;;;;;;AACO,SAAS,gBAAA,CAAiB,aAAiC,aAAA,EAAgC;AAChG,EAAA,MAAM,CAAA,GAAA,CAAK,WAAA,IAAe,EAAA,EAAI,IAAA,EAAK;AACnC,EAAA,MAAM,MAAA,GAAA,CAAU,aAAA,IAAiB,EAAA,EAAI,IAAA,EAAK;AAC1C,EAAA,IAAI,CAAC,QAAQ,OAAO,CAAA;AACpB,EAAA,OAAO,CAAA,GAAI,GAAG,CAAC;;AAAA,EAAO,MAAM,CAAA,CAAA,GAAK,MAAA;AACnC;ACgCO,SAAS,kBAAkB,KAAA,EAAsD;AACtF,EAAA,MAAM,EAAE,MAAA,EAAQ,kBAAA,EAAoB,IAAA,EAAK,GAAI,KAAA;AAC7C,EAAA,IAAI,IAAA,CAAK,WAAW,CAAA,EAAG;AACrB,IAAA,MAAM,IAAI,MAAM,6CAA6C,CAAA;AAAA,EAC/D;AAEA,EAAA,MAAM,EAAA,GAAA,CAAM,MAAA,CAAO,SAAA,IAAa,EAAA,EAAI,IAAA,EAAK;AACzC,EAAA,IAAI,CAAC,EAAA,EAAI,MAAM,IAAI,MAAM,uCAAuC,CAAA;AAEhE,EAAA,MAAM,OAAA,GAAU,MAAA,CAAO,OAAA,IAAW,EAAC;AACnC,EAAA,MAAM,QA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AAA,QACA,MAAA,EAAQ,gBAAA,CAAiB,IAAA,CAAK,WAAA,EAAa,KAAK,QAAQ,CAAA;AAAA,QACxD,oBAAoB,IAAA,CAAK,kBAAA;AAAA,QACzB,aAAA,EAAe,KAAK,aAAA,IAAiB,4BAAA;AAAA,QACrC,KAAA,EAAO;AAAA,UACL,IAAA,EAAM,sBAAA;AAAA,UACN,YAAA,EAAc,KAAK,QAAA,CAAS,IAAA;AAAA,UAC5B,eAAe,YAAA,CAAa,MAAA;AAAA,UAC5B,GAAI,IAAA,CAAK,KAAA,IAAS;AAAC,SACrB;AAAA,QACA,aAAa;AAAC;AAChB;AACF,GACD,CAAA;AACH;;;ACnFO,IAAM,wCAAwC,EAAA,GAAK;AAGnD,IAAM,gCAAA,uBAAuC,GAAA,CAAI;AAAA,EACtD,YAAA;AAAA,EACA,KAAA;AAAA,EACA,aAAA;AAAA,EACA,OAAA;AAAA,EACA;AACF,CAAC;AAEM,SAAS,8BAAA,CACd,YACA,kBAAA,EACoB;AACpB,EAAA,IAAI,OAAO,uBAAuB,QAAA,IAAY,MAAA,CAAO,SAAS,kBAAkB,CAAA,IAAK,qBAAqB,CAAA,EAAG;AAC3G,IAAA,OAAO,IAAA,CAAK,MAAM,kBAAkB,CAAA;AAAA,EACtC;AACA,EAAA,IAAI,UAAA,IAAc,gCAAA,CAAiC,GAAA,CAAI,UAAU,CAAA,EAAG;AAClE,IAAA,OAAO,KAAK,KAAA,CAAM,IAAA,CAAK,GAAA,EAAI,GAAI,GAAI,CAAA,GAAI,qCAAA;AAAA,EACzC;AACA,EAAA,OAAO,MAAA;AACT","file":"index.cjs","sourcesContent":["/** Merge user purpose text with an optional batch / protocol suffix. */\nexport function mergePurposeText(purposeText: string | undefined, purposeSuffix?: string): string {\n const t = (purposeText ?? '').trim()\n const suffix = (purposeSuffix ?? '').trim()\n if (!suffix) return t\n return t ? `${t}\\n\\n${suffix}` : suffix\n}\n","import type { ChainCategory, MultisignBuildResult, KeyGenSubset } from './types.js'\nimport { getClientIdFromKeyGenResult } from '@continuumdao/continuum-node-sdk'\nimport { mergePurposeText } from './purpose.js'\n\nexport interface MultisignLeg {\n msgHash: string\n msgRaw: string\n destinationAddress: string\n signatureText: string\n audit: Record<string, unknown>\n feeSnapshot: Record<string, unknown>\n proposalTxParams?: Record<string, unknown>\n /** Payable value wei string for first leg only when relevant */\n valueWei?: bigint\n}\n\nexport interface ChainCategoryBuildInput {\n keyGen: KeyGenSubset\n purposeText: string\n purposeSuffix?: string\n destinationChainID: string\n legs: MultisignLeg[]\n extraJSON?: Record<string, unknown>\n /** Top-level destination address (first leg destination if omitted) */\n destinationAddress?: string\n /** Unix seconds (UTC) for mpc-auth multiSignRequest expiryDate. */\n expiryDate?: number\n}\n\nexport interface ChainCategoryModule {\n category: ChainCategory\n finalizeMultisign(input: ChainCategoryBuildInput): MultisignBuildResult\n}\n\n/**\n * Assemble mpc-auth `bodyForSign` from category-built legs.\n * Supports single-tx and batch (messageHashes / messageRawBatch / proposalTxParams).\n */\nexport function finalizeMultisign(input: ChainCategoryBuildInput): MultisignBuildResult {\n const { keyGen, destinationChainID, legs } = input\n if (legs.length === 0) {\n throw new Error('finalizeMultisign requires at least one leg')\n }\n\n const ph = (keyGen.pubkeyhex ?? '').trim()\n if (!ph) throw new Error('keyGen pubKey (pubkeyhex) is required')\n\n const keyList = keyGen.keylist ?? []\n const clientId = getClientIdFromKeyGenResult(keyGen)\n const first = legs[0]!\n\n const messageHashes = legs.map((l) => l.msgHash)\n const messageRawBatch = legs.map((l) => l.msgRaw)\n const batchMeta = legs.map((l) => ({\n destinationAddress: l.destinationAddress,\n signatureText: l.signatureText,\n ...l.audit,\n }))\n\n const proposalTxParams = legs\n .map((l) => l.proposalTxParams)\n .filter((p): p is Record<string, unknown> => p != null && typeof p === 'object')\n\n const extraPayload: Record<string, unknown> = {\n batchMeta,\n ...(input.extraJSON ?? {}),\n }\n const extraJSON = JSON.stringify(extraPayload, (_, v) => (typeof v === 'bigint' ? v.toString() : v))\n\n const bodyForSign: Record<string, unknown> = {\n keyList,\n pubKey: ph,\n msgHash: messageHashes[0],\n msgRaw: first.msgRaw,\n destinationChainID,\n destinationAddress: input.destinationAddress ?? first.destinationAddress,\n extraJSON,\n signatureText: first.signatureText,\n purpose: mergePurposeText(input.purposeText, input.purposeSuffix),\n ...first.feeSnapshot,\n }\n\n if (legs.length > 1) {\n bodyForSign.messageHashes = messageHashes\n bodyForSign.messageRawBatch = messageRawBatch\n }\n\n if (proposalTxParams.length > 0) {\n bodyForSign.proposalTxParams = proposalTxParams\n }\n\n const valueWei = first.valueWei\n if (valueWei != null && valueWei > 0n) {\n bodyForSign.value = valueWei.toString()\n }\n\n if (clientId) bodyForSign.clientId = clientId\n\n if (input.expiryDate != null && input.expiryDate > 0) {\n bodyForSign.expiryDate = Math.floor(input.expiryDate)\n }\n\n return { bodyForSign, messageToSign: JSON.stringify(bodyForSign) }\n}\n\nexport const coreChainCategoryModule: ChainCategoryModule = {\n category: 'evm',\n finalizeMultisign,\n}\n","import type { ProtocolModule } from './types.js'\n\nconst modules: ProtocolModule[] = []\n\nexport function registerProtocolModule(mod: ProtocolModule): void {\n const existing = modules.findIndex((m) => m.id === mod.id)\n if (existing >= 0) {\n modules[existing] = mod\n } else {\n modules.push(mod)\n }\n}\n\nexport function getProtocolModules(): readonly ProtocolModule[] {\n return modules\n}\n\nexport function getProtocolModule(id: string): ProtocolModule | undefined {\n return modules.find((m) => m.id === id)\n}\n\nexport function getActionsByChainCategory(category: string): ProtocolModule['actions'] {\n return modules.filter((m) => m.chainCategory === category).flatMap((m) => m.actions)\n}\n","/**\n * Optional browser → Next.js API proxy paths for DeFi upstream calls.\n * Set once from continuumdao-node-app client bootstrap.\n */\n\nlet aaveGraphqlProxyUrl: string | undefined\nlet eulerGraphqlProxyUrl: string | undefined\nlet mapleGraphqlProxyUrl: string | undefined\nlet morphoGraphqlProxyUrl: string | undefined\nlet coingeckoProxyUrl: string | undefined\n\nexport function setAaveGraphqlProxyUrl(url: string | undefined): void {\n aaveGraphqlProxyUrl = url?.trim() || undefined\n}\n\nexport function getAaveGraphqlProxyUrl(): string | undefined {\n return aaveGraphqlProxyUrl\n}\n\nexport function setEulerGraphqlProxyUrl(url: string | undefined): void {\n eulerGraphqlProxyUrl = url?.trim() || undefined\n}\n\nexport function getEulerGraphqlProxyUrl(): string | undefined {\n return eulerGraphqlProxyUrl\n}\n\nexport function setMapleGraphqlProxyUrl(url: string | undefined): void {\n mapleGraphqlProxyUrl = url?.trim() || undefined\n}\n\nexport function getMapleGraphqlProxyUrl(): string | undefined {\n return mapleGraphqlProxyUrl\n}\n\nexport function setMorphoGraphqlProxyUrl(url: string | undefined): void {\n morphoGraphqlProxyUrl = url?.trim() || undefined\n}\n\nexport function getMorphoGraphqlProxyUrl(): string | undefined {\n return morphoGraphqlProxyUrl\n}\n\n/** Browser → Next.js base path for Morpho Midnight REST (replaces api.morpho.org/v0/midnight). */\nlet morphoMidnightRestProxyUrl: string | undefined\n\nexport function setMorphoMidnightRestProxyUrl(url: string | undefined): void {\n morphoMidnightRestProxyUrl = url?.trim() || undefined\n}\n\nexport function getMorphoMidnightRestProxyUrl(): string | undefined {\n return morphoMidnightRestProxyUrl\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\nexport async function getJsonViaOptionalProxy<T>(args: {\n directUrl: string\n /** When set, GET this URL instead of directUrl (same path semantics as caller built). */\n proxyUrl?: string\n}): Promise<T> {\n const url = args.proxyUrl?.trim() || args.directUrl\n const r = await fetch(url, { method: 'GET', headers: { accept: 'application/json' } })\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 BuildEip712MultisignLeg = {\n typedData: Eip712TypedDataPayload\n delivery: Eip712MultisignDelivery\n audit?: Record<string, unknown>\n}\n\nexport type BuildEip712MultisignArgs = {\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 legs: readonly BuildEip712MultisignLeg[]\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 eip712LegEnvelope(\n typedData: Eip712TypedDataPayload,\n delivery: Eip712MultisignDelivery,\n digest: `0x${string}`,\n): Record<string, unknown> {\n return {\n version: 1,\n digest,\n domain: typedData.domain,\n types: typedData.types,\n primaryType: typedData.primaryType,\n message: typedData.message,\n delivery,\n }\n}\n\nfunction eip712MsgRawHex(envelope: Record<string, unknown>): string {\n return stringToHex(jsonStringifyForAudit(envelope))\n}\n\n/**\n * Build an mpc-auth multiSignRequest body for one or more EIP-712 digests (no EVM tx broadcast).\n * `extraJSON.eip712` is always an array. N=1 uses `msgHash`/`msgRaw`; N>=2 uses `messageHashes`/`messageRawBatch`.\n */\nexport function buildEip712Multisign(args: BuildEip712MultisignArgs): MultisignBuildResult {\n if (args.legs.length < 1) {\n throw new Error('buildEip712Multisign requires at least one leg')\n }\n\n const eip712: Record<string, unknown>[] = []\n const legs = args.legs.map((leg) => {\n const digest = hashTypedData({\n domain: leg.typedData.domain,\n types: leg.typedData.types,\n primaryType: leg.typedData.primaryType,\n message: leg.typedData.message,\n })\n const envelope = eip712LegEnvelope(leg.typedData, leg.delivery, digest)\n eip712.push(envelope)\n return {\n msgHash: msgHashNo0x(digest),\n msgRaw: eip712MsgRawHex(envelope),\n destinationAddress: args.destinationAddress,\n signatureText: eip712SignatureText(leg.typedData.domain, leg.typedData.primaryType),\n audit: {\n kind: 'EIP712',\n primaryType: leg.typedData.primaryType,\n deliveryKind: leg.delivery.kind,\n ...(leg.audit ?? {}),\n },\n feeSnapshot: {},\n }\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 signRequestKind: EIP712_SIGN_REQUEST_KIND,\n eip712,\n },\n expiryDate: args.expiryDate,\n legs,\n })\n}\n","import { stringToHex } from 'viem'\nimport type { KeyGenSubset, MultisignBuildResult } from './types.js'\nimport { finalizeMultisign } from './envelope.js'\n\nexport const PAYLOAD_SIGN_ED25519_REQUEST_KIND = 'payload_sign_ed25519' as const\n\nexport type PayloadSignEd25519Delivery = Record<string, unknown> & { kind: string }\n\nexport type BuildPayloadSignEd25519MultisignBodyArgs = {\n keyGen: KeyGenSubset\n purposeText: string\n purposeSuffix?: string\n destinationChainID: string\n destinationAddress: string\n /** UTF-8 bytes to sign (Arcus canonical JSON). */\n messageUtf8: string\n /** secp256k1 pub key hex for billing when signing with paired ed25519 KeyGen. */\n billingKeyGenPubKey?: string\n delivery: PayloadSignEd25519Delivery\n audit?: Record<string, unknown>\n expiryDate?: number\n signatureText?: string\n}\n\nfunction msgHashNo0xFromBytes(bytes: Uint8Array): string {\n return Buffer.from(bytes).toString('hex')\n}\n\nfunction payloadMsgRawHex(messageUtf8: string, delivery: PayloadSignEd25519Delivery): string {\n const envelope = {\n version: 1,\n messageUtf8,\n delivery,\n }\n return stringToHex(JSON.stringify(envelope))\n}\n\n/**\n * Build mpc-auth multiSignRequest for Ed25519 FROST signing over variable-length UTF-8 (Arcus Scheme 1).\n * `msgHash` is hex of the raw message bytes (not SHA-256); mpc-auth givre worker signs these bytes directly.\n */\nexport function buildPayloadSignEd25519MultisignBody(\n args: BuildPayloadSignEd25519MultisignBodyArgs,\n): MultisignBuildResult {\n const messageBytes = Buffer.from(args.messageUtf8, 'utf8')\n const msgHash = msgHashNo0xFromBytes(messageBytes)\n\n const extraJSON: Record<string, unknown> = {\n signRequestKind: PAYLOAD_SIGN_ED25519_REQUEST_KIND,\n payloadSignEd25519: {\n version: 1,\n messageHex: msgHash,\n messageLength: messageBytes.length,\n },\n delivery: args.delivery,\n }\n if (args.billingKeyGenPubKey?.trim()) {\n extraJSON.billingKeyGenPubKey = args.billingKeyGenPubKey.trim()\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,\n msgRaw: payloadMsgRawHex(args.messageUtf8, args.delivery),\n destinationAddress: args.destinationAddress,\n signatureText: args.signatureText ?? 'Arcus Ed25519 payload sign',\n audit: {\n kind: 'PAYLOAD_SIGN_ED25519',\n deliveryKind: args.delivery.kind,\n messageLength: messageBytes.length,\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 'arcus',\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
|
@@ -3,7 +3,7 @@ export { C as ChainCategory, a as ChainSupportContext, E as EvmTokenKind, b as K
|
|
|
3
3
|
export { getClientIdFromKeyGenResult as firstClientIdFromKeyGen } from '@continuumdao/continuum-node-sdk';
|
|
4
4
|
export { C as ChainCategoryBuildInput, a as ChainCategoryModule, M as MultisignLeg, c as coreChainCategoryModule, f as finalizeMultisign } from '../envelope-C_bfuKab.js';
|
|
5
5
|
export { g as getActionsByChainCategory, a as getProtocolModule, b as getProtocolModules, r as registerProtocolModule } from '../registry-DxDSPQ-p.js';
|
|
6
|
-
export { B as
|
|
6
|
+
export { B as BuildEip712MultisignArgs, a as BuildEip712MultisignLeg, E as EIP712_SIGN_REQUEST_KIND, b as Eip712MultisignDelivery, c as Eip712TypedDataField, d as Eip712TypedDataPayload, e as buildEip712Multisign } from '../eip712Multisign-DCW7heqX.js';
|
|
7
7
|
import 'viem';
|
|
8
8
|
|
|
9
9
|
/** Merge user purpose text with an optional batch / protocol suffix. */
|
package/dist/core/index.js
CHANGED
|
@@ -181,57 +181,60 @@ function eip712SignatureText(domain, primaryType) {
|
|
|
181
181
|
function jsonStringifyForAudit(value) {
|
|
182
182
|
return JSON.stringify(value, (_, v) => typeof v === "bigint" ? v.toString() : v);
|
|
183
183
|
}
|
|
184
|
-
function
|
|
185
|
-
|
|
184
|
+
function eip712LegEnvelope(typedData, delivery, digest) {
|
|
185
|
+
return {
|
|
186
186
|
version: 1,
|
|
187
|
-
|
|
188
|
-
delivery
|
|
189
|
-
};
|
|
190
|
-
return stringToHex(jsonStringifyForAudit(envelope));
|
|
191
|
-
}
|
|
192
|
-
function buildEip712MultisignBody(args) {
|
|
193
|
-
const { typedData, delivery } = args;
|
|
194
|
-
const digest = hashTypedData({
|
|
187
|
+
digest,
|
|
195
188
|
domain: typedData.domain,
|
|
196
189
|
types: typedData.types,
|
|
197
190
|
primaryType: typedData.primaryType,
|
|
198
|
-
message: typedData.message
|
|
199
|
-
});
|
|
200
|
-
const extraJSON = {
|
|
201
|
-
signRequestKind: EIP712_SIGN_REQUEST_KIND,
|
|
202
|
-
eip712: {
|
|
203
|
-
version: 1,
|
|
204
|
-
digest,
|
|
205
|
-
domain: typedData.domain,
|
|
206
|
-
types: typedData.types,
|
|
207
|
-
primaryType: typedData.primaryType,
|
|
208
|
-
message: typedData.message
|
|
209
|
-
},
|
|
191
|
+
message: typedData.message,
|
|
210
192
|
delivery
|
|
211
193
|
};
|
|
194
|
+
}
|
|
195
|
+
function eip712MsgRawHex(envelope) {
|
|
196
|
+
return stringToHex(jsonStringifyForAudit(envelope));
|
|
197
|
+
}
|
|
198
|
+
function buildEip712Multisign(args) {
|
|
199
|
+
if (args.legs.length < 1) {
|
|
200
|
+
throw new Error("buildEip712Multisign requires at least one leg");
|
|
201
|
+
}
|
|
202
|
+
const eip712 = [];
|
|
203
|
+
const legs = args.legs.map((leg) => {
|
|
204
|
+
const digest = hashTypedData({
|
|
205
|
+
domain: leg.typedData.domain,
|
|
206
|
+
types: leg.typedData.types,
|
|
207
|
+
primaryType: leg.typedData.primaryType,
|
|
208
|
+
message: leg.typedData.message
|
|
209
|
+
});
|
|
210
|
+
const envelope = eip712LegEnvelope(leg.typedData, leg.delivery, digest);
|
|
211
|
+
eip712.push(envelope);
|
|
212
|
+
return {
|
|
213
|
+
msgHash: msgHashNo0x(digest),
|
|
214
|
+
msgRaw: eip712MsgRawHex(envelope),
|
|
215
|
+
destinationAddress: args.destinationAddress,
|
|
216
|
+
signatureText: eip712SignatureText(leg.typedData.domain, leg.typedData.primaryType),
|
|
217
|
+
audit: {
|
|
218
|
+
kind: "EIP712",
|
|
219
|
+
primaryType: leg.typedData.primaryType,
|
|
220
|
+
deliveryKind: leg.delivery.kind,
|
|
221
|
+
...leg.audit ?? {}
|
|
222
|
+
},
|
|
223
|
+
feeSnapshot: {}
|
|
224
|
+
};
|
|
225
|
+
});
|
|
212
226
|
return finalizeMultisign({
|
|
213
227
|
keyGen: args.keyGen,
|
|
214
228
|
purposeText: args.purposeText,
|
|
215
229
|
purposeSuffix: args.purposeSuffix,
|
|
216
230
|
destinationChainID: args.destinationChainID,
|
|
217
231
|
destinationAddress: args.destinationAddress,
|
|
218
|
-
extraJSON
|
|
232
|
+
extraJSON: {
|
|
233
|
+
signRequestKind: EIP712_SIGN_REQUEST_KIND,
|
|
234
|
+
eip712
|
|
235
|
+
},
|
|
219
236
|
expiryDate: args.expiryDate,
|
|
220
|
-
legs
|
|
221
|
-
{
|
|
222
|
-
msgHash: msgHashNo0x(digest),
|
|
223
|
-
msgRaw: eip712MsgRawHex(typedData, delivery),
|
|
224
|
-
destinationAddress: args.destinationAddress,
|
|
225
|
-
signatureText: eip712SignatureText(typedData.domain, typedData.primaryType),
|
|
226
|
-
audit: {
|
|
227
|
-
kind: "EIP712",
|
|
228
|
-
primaryType: typedData.primaryType,
|
|
229
|
-
deliveryKind: delivery.kind,
|
|
230
|
-
...args.audit ?? {}
|
|
231
|
-
},
|
|
232
|
-
feeSnapshot: {}
|
|
233
|
-
}
|
|
234
|
-
]
|
|
237
|
+
legs
|
|
235
238
|
});
|
|
236
239
|
}
|
|
237
240
|
var PAYLOAD_SIGN_ED25519_REQUEST_KIND = "payload_sign_ed25519";
|
|
@@ -306,6 +309,6 @@ function defiMultisignExpiryUnixSeconds(protocolId, explicitExpiryDate) {
|
|
|
306
309
|
return void 0;
|
|
307
310
|
}
|
|
308
311
|
|
|
309
|
-
export { DEFAULT_DEFI_MULTISIGN_EXPIRY_SECONDS, DEFI_PROTOCOLS_WITH_30MIN_EXPIRY, EIP712_SIGN_REQUEST_KIND, PAYLOAD_SIGN_ED25519_REQUEST_KIND,
|
|
312
|
+
export { DEFAULT_DEFI_MULTISIGN_EXPIRY_SECONDS, DEFI_PROTOCOLS_WITH_30MIN_EXPIRY, EIP712_SIGN_REQUEST_KIND, PAYLOAD_SIGN_ED25519_REQUEST_KIND, buildEip712Multisign, buildPayloadSignEd25519MultisignBody, coreChainCategoryModule, defiMultisignExpiryUnixSeconds, finalizeMultisign, getAaveGraphqlProxyUrl, getActionsByChainCategory, getCoingeckoProxyUrl, getEulerGraphqlProxyUrl, getJsonViaOptionalProxy, getMapleGraphqlProxyUrl, getMorphoGraphqlProxyUrl, getMorphoMidnightRestProxyUrl, getProtocolModule, getProtocolModules, mergePurposeText, postJsonViaOptionalProxy, registerProtocolModule, setAaveGraphqlProxyUrl, setCoingeckoProxyUrl, setEulerGraphqlProxyUrl, setMapleGraphqlProxyUrl, setMorphoGraphqlProxyUrl, setMorphoMidnightRestProxyUrl };
|
|
310
313
|
//# sourceMappingURL=index.js.map
|
|
311
314
|
//# sourceMappingURL=index.js.map
|