@chipi-stack/chipi-react 14.7.0 → 14.8.0

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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/multisig/action-template.ts","../src/multisig/oe.ts","../src/multisig/proposals.ts","../src/multisig/use-hooks.ts"],"names":["MAX_OE_VALIDITY_WINDOW_SECONDS","buildOutsideExecution","ANY_CALLER_FELT","computeOeHash","buildThresholdEnvelope","serializeExecuteFromOutsideV2Calldata","useQueryClient","useMutation","useQuery"],"mappings":";;;;;;AA2DO,IAAM,UAAA,GAAa,MAAA;AAAA,EACxB;AACF;AAEA,IAAM,SAAA,GAAA,CAAa,MAAM,IAAA,IAAQ,EAAA;AAI1B,SAAS,OAAO,CAAA,EAAqB;AAC1C,EAAA,IAAI,CAAA;AACJ,EAAA,IAAI;AACF,IAAA,CAAA,GAAI,OAAO,OAAO,CAAA,KAAM,WAAW,CAAA,CAAE,IAAA,KAAS,CAAC,CAAA;AAAA,EACjD,CAAA,CAAA,MAAQ;AACN,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,YAAA,EAAe,MAAA,CAAO,CAAC,CAAC,CAAA,CAAE,CAAA;AAAA,EAC5C;AACA,EAAA,IAAI,CAAA,GAAI,EAAA,IAAM,CAAA,IAAK,UAAA,EAAY;AAC7B,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,mBAAA,EAAsB,MAAA,CAAO,CAAC,CAAC,CAAA,CAAE,CAAA;AAAA,EACnD;AACA,EAAA,OAAO,IAAA,GAAO,CAAA,CAAE,QAAA,CAAS,EAAE,CAAA;AAC7B;AAGO,SAAS,KAAK,CAAA,EAA+B;AAClD,EAAA,MAAM,CAAA,GAAI,OAAO,OAAO,CAAA,KAAM,WAAW,CAAA,CAAE,IAAA,KAAS,CAAC,CAAA;AACrD,EAAA,IAAI,CAAA,GAAI,EAAA,EAAI,MAAM,IAAI,MAAM,2BAA2B,CAAA;AACvD,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AO,MAAA,CAAO,SAAA,CAAU,IAAA,CAAK,QAAA,CAAS,IAAI,IAAI,CAAA;AAAA,IAChD,CAAA;AAAA,IACA,SAAA,EAAW;AAAA,GACZ,CAAA;AAED,EAAA,MAAM,UAAUA,sBAAA,CAAY;AAAA,IAC1B,UAAA,EAAY,CAAC,QAAA,KACX,MAAA,CAAO,SAAA,CAAU,QAAQ,QAAA,CAAS,EAAA,EAAI,oBAAA,CAAqB,QAAQ,CAAC,CAAA;AAAA,IACtE,SAAA,EAAW;AAAA,GACZ,CAAA;AAED,EAAA,OAAO,EAAE,SAAA,EAAW,OAAA,EAAS,OAAA,EAAQ;AACvC","file":"multisig.js","sourcesContent":["/**\n * Framework-agnostic action-template engine for SHHH multisig governance.\n *\n * An {@link ActionTemplate} maps friendly, typed form fields → an\n * OutsideExecution call list + a human-readable title. It's the seam that\n * turns \"call any contract\" (powerful, scary) into \"fill in this form\"\n * (founder-grade) — and the whitelabel seam: every integrator registers\n * its own templates (Roca: create_pool / borrow / repay), while `Vote`\n * ships built-in. The raw-call escape hatch lives in the UI layer, not\n * here, because its arguments are open-ended.\n *\n * Pure: no React, no network — so the same template renders the proposer's\n * form, every approver's inbox, and the notification, from one source of\n * truth, and `toCalls` is deterministic (proposer and executor build the\n * identical OE → the hash matches).\n */\n\nexport type FeltLike = string | number | bigint;\n\n/** One call in an action — the shape the OE builder consumes. */\nexport interface CallSpec {\n to: string;\n entrypoint: string;\n /** Flat 0x-hex felts. */\n calldata: string[];\n}\n\n/** A typed input in an action template. */\nexport type FieldSpec =\n | { name: string; label: string; type: \"amount\"; decimals: number; help?: string }\n | { name: string; label: string; type: \"address\"; help?: string }\n | { name: string; label: string; type: \"number\" | \"bps\" | \"days\" | \"felt\"; help?: string }\n | {\n name: string;\n label: string;\n type: \"select\";\n options: { label: string; value: string }[];\n help?: string;\n }\n | { name: string; label: string; type: \"text\"; help?: string };\n\nexport interface ActionTemplate<V = Record<string, unknown>> {\n /** Stable id, persisted on the proposal. */\n key: string;\n /** Display label (\"Create pool\"). */\n label: string;\n description?: string;\n /** Typed inputs rendered by `<ProposeAction>`. */\n fields: FieldSpec[];\n /** Pure: validated field values → the OE call list. */\n toCalls: (v: V) => CallSpec[];\n /** Pure: the plain-language title shown in the preview, inbox, and email. */\n title: (v: V) => string;\n /** Optional metadata persisted with the proposal so the approver's app\n * can render business context (e.g. `{ poolId }`). */\n meta?: (v: V) => Record<string, string | number>;\n}\n\n/** Starknet felt252 field prime — args must be a non-negative felt below it. */\nexport const FELT_PRIME = BigInt(\n \"0x800000000000011000000000000000000000000000000000000000000000001\"\n);\n\nconst U128_MASK = (1n << 128n) - 1n;\n\n/** Parse a decimal or 0x-hex value to a canonical `0x` felt. Throws on a\n * non-numeric or out-of-range value. */\nexport function toFelt(v: FeltLike): string {\n let n: bigint;\n try {\n n = BigInt(typeof v === \"string\" ? v.trim() : v);\n } catch {\n throw new Error(`Not a felt: ${String(v)}`);\n }\n if (n < 0n || n >= FELT_PRIME) {\n throw new Error(`Felt out of range: ${String(v)}`);\n }\n return \"0x\" + n.toString(16);\n}\n\n/** Split a u256 value into its `[low, high]` felts (Cairo calling convention). */\nexport function u256(v: FeltLike): [string, string] {\n const n = BigInt(typeof v === \"string\" ? v.trim() : v);\n if (n < 0n) throw new Error(\"u256 must be non-negative\");\n return [\"0x\" + (n & U128_MASK).toString(16), \"0x\" + (n >> 128n).toString(16)];\n}\n\n/** Convert a human amount (\"10.5\") to base units given a token's decimals. */\nexport function amountToBase(amount: string, decimals: number): bigint {\n const t = amount.trim();\n if (!/^\\d+(\\.\\d+)?$/.test(t)) throw new Error(`Invalid amount: ${amount}`);\n const [whole, frac = \"\"] = t.split(\".\");\n if (frac.length > decimals) {\n throw new Error(`Too many decimal places (max ${decimals})`);\n }\n const padded = (frac + \"0\".repeat(decimals)).slice(0, decimals);\n return BigInt(whole) * 10n ** BigInt(decimals) + BigInt(padded || \"0\");\n}\n\n/**\n * Identity + light validation for a template registry: keys are present\n * and unique. Returns the same array (typed) so call sites keep inference.\n */\nexport function defineActions<T extends ActionTemplate<any>[]>(templates: [...T]): [...T] {\n const seen = new Set<string>();\n for (const t of templates) {\n if (!t.key) throw new Error(\"ActionTemplate.key is required\");\n if (seen.has(t.key)) throw new Error(`Duplicate ActionTemplate key: ${t.key}`);\n seen.add(t.key);\n }\n return templates;\n}\n\nexport interface VoteValues {\n contract: string;\n proposalId: string;\n choice: string; // felt: \"0x1\" yes / \"0x0\" no / \"0x2\" abstain\n}\n\nconst VOTE_CHOICES = [\n { label: \"Yes\", value: \"0x1\" },\n { label: \"No\", value: \"0x0\" },\n { label: \"Abstain\", value: \"0x2\" },\n];\n\n/**\n * Built-in `Vote` template — `vote(proposalId, choice)` on a governance\n * contract. Pin the contract and/or entrypoint up front (then they drop\n * out of the form), or leave them for the proposer to fill.\n */\nexport function voteTemplate(opts?: {\n governanceContract?: string;\n entrypoint?: string;\n}): ActionTemplate<VoteValues> {\n const fields: FieldSpec[] = [];\n if (!opts?.governanceContract) {\n fields.push({ name: \"contract\", label: \"Governance contract\", type: \"address\" });\n }\n fields.push(\n { name: \"proposalId\", label: \"Proposal ID\", type: \"felt\" },\n { name: \"choice\", label: \"Your vote\", type: \"select\", options: VOTE_CHOICES }\n );\n const labelFor = (v: string) => VOTE_CHOICES.find((c) => c.value === v)?.label ?? v;\n return {\n key: \"vote\",\n label: \"Vote\",\n description: \"Vote on a governance proposal.\",\n fields,\n toCalls: (v) => [\n {\n to: opts?.governanceContract ?? v.contract,\n entrypoint: opts?.entrypoint ?? \"vote\",\n calldata: [toFelt(v.proposalId), toFelt(v.choice)],\n },\n ],\n title: (v) => `Vote ${labelFor(v.choice)} on Proposal #${v.proposalId}`,\n };\n}\n","/**\n * Signer- and transport-agnostic OutsideExecution core for SHHH multisig\n * governance. Build an OE over an arbitrary call list, sign it per-owner\n * (the key never leaves the caller — passkey/MetaMask/Phantom/STARK), and\n * once enough approvals are collected, rebuild the exact OE and wrap the\n * inner envelopes in a V2_THRESHOLD envelope for execution.\n *\n * Deterministic rebuild is the load-bearing property: caller = ANY_CALLER,\n * and the persisted nonce + executeAfter + executeBefore mean the executor\n * reconstructs the identical OE hash the owners signed. executeAfter is\n * pinned to ~now (not 0) so the validity window stays within the contract\n * cap (audit M-2) — so it MUST be persisted, not assumed constant.\n */\nimport {\n ANY_CALLER_FELT,\n MAX_OE_VALIDITY_WINDOW_SECONDS,\n buildOutsideExecution,\n buildThresholdEnvelope,\n computeOeHash,\n serializeExecuteFromOutsideV2Calldata,\n} from \"@chipi-stack/backend\";\nimport type { CallSpec } from \"./action-template\";\n\n/** shortString.encodeShortString(\"SN_MAIN\") — Starknet mainnet. */\nexport const SN_MAIN_CHAIN_ID = \"0x534e5f4d41494e\";\n\n/**\n * Max on-chain OE validity window (`executeBefore - executeAfter`), capped\n * by the SHHH contract audit (M-2). This is the longest a proposal stays\n * EXECUTABLE — distinct from how long its record lives in the coordination\n * backend. NOTE: with `executeAfter` pinned to 0 the window would be the\n * whole epoch and the contract rejects it, so `executeAfter` is set to ~now\n * and persisted alongside the nonce + `executeBefore`.\n */\nexport const OE_WINDOW_SECONDS = Number(MAX_OE_VALIDITY_WINDOW_SECONDS);\n/** Small clock-skew cushion so the OE is valid by the next block. */\nconst OE_AFTER_SKEW_SECONDS = 60;\n\n/**\n * Signs an OE message hash for one owner → that owner's inner V2_SNIP12\n * envelope (an array of felts). Implementations wrap a passkey / MetaMask /\n * Phantom / STARK signer; the private key never leaves the implementation.\n */\nexport type OeSigner = (params: {\n messageHash: bigint;\n ownerIndex: bigint;\n}) => Promise<bigint[]> | bigint[];\n\ninterface OeCall {\n contractAddress: string;\n entrypoint: string;\n calldata: string[];\n}\n\nfunction toOeCalls(calls: CallSpec[]): OeCall[] {\n return calls.map((c) => ({\n contractAddress: c.to,\n entrypoint: c.entrypoint,\n calldata: c.calldata,\n }));\n}\n\n/** Serialize an inner envelope (felt[]) to the comma-joined 0x-hex string\n * the coordination backend stores per signature. */\nexport function serializeEnvelope(env: bigint[]): string {\n return env.map((f) => \"0x\" + f.toString(16)).join(\",\");\n}\n\nexport function deserializeEnvelope(s: string): bigint[] {\n return s\n .split(\",\")\n .filter(Boolean)\n .map((f) => BigInt(f));\n}\n\n/**\n * OE replay nonce: ms timestamp shifted left 24 bits, ORed with a 24-bit\n * random suffix. `nowMs`/`rand` are injectable for deterministic tests.\n */\nexport function newOeNonce(nowMs: number, rand: number): bigint {\n return (BigInt(nowMs) << 24n) | BigInt(Math.floor(rand * 0xffffff));\n}\n\nexport interface ActionProposal {\n oeMessageHash: string;\n oeNonce: string;\n oeExecuteBefore: string;\n /** The proposer's inner V2_SNIP12 envelope, comma-joined 0x-hex. */\n proposerSignature: string;\n}\n\n/** Derive the OE's executeAfter from its persisted executeBefore. The\n * window is a fixed constant (the contract cap), so the executor needs\n * only executeBefore to reconstruct the exact signed OE — no separate\n * executeAfter persistence (and no backend column). */\nexport function deriveExecuteAfter(oeExecuteBefore: string): bigint {\n return BigInt(oeExecuteBefore) - BigInt(OE_WINDOW_SECONDS);\n}\n\n/**\n * Build an OE over `calls`, sign it as the proposer (owner 0 by default),\n * and return everything a propose endpoint needs. The OE params (nonce +\n * executeBefore) are returned; executeAfter is `executeBefore - OE_WINDOW`,\n * so only executeBefore needs persisting. The window is the contract cap\n * (the longest executable window M-2 allows).\n */\nexport async function buildActionProposal(params: {\n walletAddress: string;\n calls: CallSpec[];\n sign: OeSigner;\n ownerIndex?: bigint;\n chainId?: string;\n nowMs?: number;\n rand?: number;\n}): Promise<ActionProposal> {\n const nowMs = params.nowMs ?? Date.now();\n const nonce = newOeNonce(nowMs, params.rand ?? Math.random());\n // executeAfter ~now (minus skew); the window = executeBefore - executeAfter\n // is the fixed contract cap, so executeAfter can't be 0 (which would make\n // the window the whole epoch and the contract reject it). Deriving it from\n // executeBefore at execute time means we persist only executeBefore.\n const executeAfter = BigInt(Math.floor(nowMs / 1000) - OE_AFTER_SKEW_SECONDS);\n const executeBefore = executeAfter + BigInt(OE_WINDOW_SECONDS);\n const oe = buildOutsideExecution({\n nonce,\n calls: toOeCalls(params.calls),\n caller: ANY_CALLER_FELT,\n executeAfter,\n executeBefore,\n });\n const messageHash = computeOeHash(oe, params.walletAddress, params.chainId ?? SN_MAIN_CHAIN_ID);\n const inner = await params.sign({\n messageHash,\n ownerIndex: params.ownerIndex ?? 0n,\n });\n return {\n oeMessageHash: \"0x\" + messageHash.toString(16),\n oeNonce: \"0x\" + nonce.toString(16),\n oeExecuteBefore: executeBefore.toString(),\n proposerSignature: serializeEnvelope(inner),\n };\n}\n\n/** Sign an existing proposal's OE hash as an approver → inner envelope string. */\nexport async function signActionApproval(params: {\n oeMessageHash: string;\n ownerIndex: bigint;\n sign: OeSigner;\n}): Promise<string> {\n const inner = await params.sign({\n messageHash: BigInt(params.oeMessageHash),\n ownerIndex: params.ownerIndex,\n });\n return serializeEnvelope(inner);\n}\n\n/**\n * Rebuild the exact OE from the persisted params + collected signatures and\n * serialize the `execute` calldata. A 1-of-N wallet uses the single inner\n * envelope; N≥2 wraps the inner envelopes in a V2_THRESHOLD envelope.\n */\nexport function assembleActionExecuteCalldata(params: {\n calls: CallSpec[];\n oeNonce: string;\n oeExecuteBefore: string;\n signatures: string[];\n requiredApprovals: number;\n}): string[] {\n const oe = buildOutsideExecution({\n nonce: BigInt(params.oeNonce),\n calls: toOeCalls(params.calls),\n caller: ANY_CALLER_FELT,\n executeAfter: deriveExecuteAfter(params.oeExecuteBefore),\n executeBefore: BigInt(params.oeExecuteBefore),\n });\n const inner = params.signatures.map(deserializeEnvelope);\n if (inner.length < Math.max(1, params.requiredApprovals)) {\n throw new Error(\n `Not enough signatures: have ${inner.length}, need ${params.requiredApprovals}.`\n );\n }\n const signature =\n params.requiredApprovals <= 1 ? inner[0] : buildThresholdEnvelope({ innerEnvelopes: inner });\n return serializeExecuteFromOutsideV2Calldata({\n outsideExecution: oe,\n signature,\n });\n}\n","/**\n * Pure orchestration for the multisig governance flow — build a propose\n * body, build an approval, assemble execute calldata. No React, no network:\n * the hooks (`use-hooks.ts`) wrap these in mutations/queries, and they're\n * directly unit-testable with a mock signer + injected `nowMs`/`rand`.\n */\nimport type { ActionTemplate } from \"./action-template\";\nimport { buildActionProposal, signActionApproval, assembleActionExecuteCalldata } from \"./oe\";\nimport type { MultisigSigner, ProposeBody, ProposalSignature, TreasuryProposal } from \"./types\";\n\n/**\n * Build a propose body for a template + its validated field values: derive\n * the call(s) + title (+ meta), build & proposer-sign the OE, and shape the\n * body the coordination backend expects. For an action the payment fields\n * are placeholders (recipient/token = the first call's target, amount \"0\");\n * the real intent rides in `calls` + `title`.\n */\nexport async function createProposal<V>(params: {\n template: ActionTemplate<V>;\n values: V;\n walletAddress: string;\n requiredApprovals: number;\n signer: MultisigSigner;\n chainId?: string;\n nowMs?: number;\n rand?: number;\n}): Promise<ProposeBody> {\n const calls = params.template.toCalls(params.values);\n if (calls.length === 0) {\n throw new Error(\"Template produced no calls\");\n }\n const title = params.template.title(params.values);\n const meta = params.template.meta?.(params.values);\n const proposerOwnerId = params.signer.proposerOwnerIndex ?? 0;\n\n const proposal = await buildActionProposal({\n walletAddress: params.walletAddress,\n calls,\n sign: params.signer.sign,\n ownerIndex: BigInt(proposerOwnerId),\n chainId: params.chainId,\n nowMs: params.nowMs,\n rand: params.rand,\n });\n\n return {\n proposerOwnerId,\n recipient: calls[0].to,\n tokenAddress: calls[0].to,\n amount: \"0\",\n title,\n calls,\n ...(meta ? { meta } : {}),\n oeMessageHash: proposal.oeMessageHash,\n oeNonce: proposal.oeNonce,\n oeExecuteBefore: proposal.oeExecuteBefore,\n requiredApprovals: params.requiredApprovals,\n proposerSignature: proposal.proposerSignature,\n proposerSignerKind: params.signer.signerKind,\n };\n}\n\n/**\n * Build an approver's signature on an existing proposal: resolve this\n * device's owner index from chain, then sign the SAME OE hash.\n */\nexport async function buildApproval(params: {\n proposal: Pick<TreasuryProposal, \"oeMessageHash\">;\n walletAddress: string;\n signer: MultisigSigner;\n}): Promise<{ ownerId: number; signature: string; signerKind: string }> {\n const ownerId = await params.signer.resolveOwnerIndex(params.walletAddress);\n const signature = await signActionApproval({\n oeMessageHash: params.proposal.oeMessageHash,\n ownerIndex: BigInt(ownerId),\n sign: params.signer.sign,\n });\n return { ownerId, signature, signerKind: params.signer.signerKind };\n}\n\n/**\n * Assemble the execute calldata from a proposal's persisted call(s) + its\n * collected signatures (sorted by owner index). Requires `calls` — this is\n * the generalized-action flow; a host with payment-only proposals supplies\n * the transfer calls.\n */\nexport function buildExecuteCalldata(proposal: TreasuryProposal): string[] {\n if (!proposal.calls || proposal.calls.length === 0) {\n throw new Error(\"Proposal has no calls to execute\");\n }\n if (!proposal.oeNonce || !proposal.oeExecuteBefore) {\n throw new Error(\"Proposal is missing OE params (nonce / executeBefore)\");\n }\n const signatures = [...proposal.signatures]\n .sort((a: ProposalSignature, b: ProposalSignature) => a.ownerId - b.ownerId)\n .map((s) => s.signature);\n return assembleActionExecuteCalldata({\n calls: proposal.calls,\n oeNonce: proposal.oeNonce,\n oeExecuteBefore: proposal.oeExecuteBefore,\n signatures,\n requiredApprovals: proposal.requiredApprovals,\n });\n}\n","/**\n * React hooks for the multisig governance flow — the reusable orchestration\n * the dashboard (and integrators) build their UI on. They wrap the pure\n * functions in `proposals.ts` with @tanstack/react-query, parameterized by\n * an injectable {@link MultisigTransport} (authed coordination backend) and\n * {@link MultisigSigner} (per-owner OE signer). The host owns the UI.\n */\nimport { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport type { ActionTemplate } from \"./action-template\";\nimport { createProposal, buildApproval, buildExecuteCalldata } from \"./proposals\";\nimport type { MultisigSigner, MultisigTransport, TreasuryProposal } from \"./types\";\n\nconst proposalsKey = (walletAddress: string) => [\"chipi-multisig-proposals\", walletAddress];\n\nexport interface ProposeInput {\n template: ActionTemplate<any>;\n values: any;\n}\n\n/**\n * Propose a templated action: build the call(s) + title from the template,\n * passkey-/key-sign the OE as the proposer, and submit it. `getRequiredApprovals`\n * supplies the wallet's threshold (the host reads it from chain — the package\n * stays chain-agnostic).\n */\nexport function useProposeAction(config: {\n walletAddress: string;\n transport: MultisigTransport;\n signer: MultisigSigner;\n getRequiredApprovals: () => Promise<number>;\n chainId?: string;\n}) {\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: ProposeInput) => {\n const requiredApprovals = await config.getRequiredApprovals();\n const body = await createProposal({\n template: input.template,\n values: input.values,\n walletAddress: config.walletAddress,\n requiredApprovals,\n signer: config.signer,\n chainId: config.chainId,\n });\n return config.transport.propose(body);\n },\n onSuccess: () =>\n qc.invalidateQueries({\n queryKey: proposalsKey(config.walletAddress),\n }),\n });\n}\n\n/**\n * List a treasury's proposals and expose approve / execute mutations. An\n * approver signs the same OE hash as their resolved owner index; once enough\n * approvals are collected, execute rebuilds the OE from the persisted call(s)\n * and relays it.\n */\nexport function useTreasuryProposals(config: {\n walletAddress: string;\n transport: MultisigTransport;\n signer: MultisigSigner;\n}) {\n const qc = useQueryClient();\n const invalidate = () => qc.invalidateQueries({ queryKey: proposalsKey(config.walletAddress) });\n\n const proposals = useQuery({\n queryKey: proposalsKey(config.walletAddress),\n staleTime: 30 * 1000,\n queryFn: () => config.transport.list(),\n });\n\n const approve = useMutation({\n mutationFn: async (proposal: TreasuryProposal) => {\n const body = await buildApproval({\n proposal,\n walletAddress: config.walletAddress,\n signer: config.signer,\n });\n return config.transport.sign(proposal.id, body);\n },\n onSuccess: invalidate,\n });\n\n const execute = useMutation({\n mutationFn: (proposal: TreasuryProposal) =>\n config.transport.execute(proposal.id, buildExecuteCalldata(proposal)),\n onSuccess: invalidate,\n });\n\n return { proposals, approve, execute };\n}\n"]}
@@ -0,0 +1,257 @@
1
+ import { MAX_OE_VALIDITY_WINDOW_SECONDS, buildOutsideExecution, ANY_CALLER_FELT, computeOeHash, buildThresholdEnvelope, serializeExecuteFromOutsideV2Calldata } from '@chipi-stack/backend';
2
+ import { useQueryClient, useMutation, useQuery } from '@tanstack/react-query';
3
+
4
+ // src/multisig/action-template.ts
5
+ var FELT_PRIME = BigInt(
6
+ "0x800000000000011000000000000000000000000000000000000000000000001"
7
+ );
8
+ var U128_MASK = (1n << 128n) - 1n;
9
+ function toFelt(v) {
10
+ let n;
11
+ try {
12
+ n = BigInt(typeof v === "string" ? v.trim() : v);
13
+ } catch {
14
+ throw new Error(`Not a felt: ${String(v)}`);
15
+ }
16
+ if (n < 0n || n >= FELT_PRIME) {
17
+ throw new Error(`Felt out of range: ${String(v)}`);
18
+ }
19
+ return "0x" + n.toString(16);
20
+ }
21
+ function u256(v) {
22
+ const n = BigInt(typeof v === "string" ? v.trim() : v);
23
+ if (n < 0n) throw new Error("u256 must be non-negative");
24
+ return ["0x" + (n & U128_MASK).toString(16), "0x" + (n >> 128n).toString(16)];
25
+ }
26
+ function amountToBase(amount, decimals) {
27
+ const t = amount.trim();
28
+ if (!/^\d+(\.\d+)?$/.test(t)) throw new Error(`Invalid amount: ${amount}`);
29
+ const [whole, frac = ""] = t.split(".");
30
+ if (frac.length > decimals) {
31
+ throw new Error(`Too many decimal places (max ${decimals})`);
32
+ }
33
+ const padded = (frac + "0".repeat(decimals)).slice(0, decimals);
34
+ return BigInt(whole) * 10n ** BigInt(decimals) + BigInt(padded || "0");
35
+ }
36
+ function defineActions(templates) {
37
+ const seen = /* @__PURE__ */ new Set();
38
+ for (const t of templates) {
39
+ if (!t.key) throw new Error("ActionTemplate.key is required");
40
+ if (seen.has(t.key)) throw new Error(`Duplicate ActionTemplate key: ${t.key}`);
41
+ seen.add(t.key);
42
+ }
43
+ return templates;
44
+ }
45
+ var VOTE_CHOICES = [
46
+ { label: "Yes", value: "0x1" },
47
+ { label: "No", value: "0x0" },
48
+ { label: "Abstain", value: "0x2" }
49
+ ];
50
+ function voteTemplate(opts) {
51
+ const fields = [];
52
+ if (!opts?.governanceContract) {
53
+ fields.push({ name: "contract", label: "Governance contract", type: "address" });
54
+ }
55
+ fields.push(
56
+ { name: "proposalId", label: "Proposal ID", type: "felt" },
57
+ { name: "choice", label: "Your vote", type: "select", options: VOTE_CHOICES }
58
+ );
59
+ const labelFor = (v) => VOTE_CHOICES.find((c) => c.value === v)?.label ?? v;
60
+ return {
61
+ key: "vote",
62
+ label: "Vote",
63
+ description: "Vote on a governance proposal.",
64
+ fields,
65
+ toCalls: (v) => [
66
+ {
67
+ to: opts?.governanceContract ?? v.contract,
68
+ entrypoint: opts?.entrypoint ?? "vote",
69
+ calldata: [toFelt(v.proposalId), toFelt(v.choice)]
70
+ }
71
+ ],
72
+ title: (v) => `Vote ${labelFor(v.choice)} on Proposal #${v.proposalId}`
73
+ };
74
+ }
75
+ var SN_MAIN_CHAIN_ID = "0x534e5f4d41494e";
76
+ var OE_WINDOW_SECONDS = Number(MAX_OE_VALIDITY_WINDOW_SECONDS);
77
+ var OE_AFTER_SKEW_SECONDS = 60;
78
+ function toOeCalls(calls) {
79
+ return calls.map((c) => ({
80
+ contractAddress: c.to,
81
+ entrypoint: c.entrypoint,
82
+ calldata: c.calldata
83
+ }));
84
+ }
85
+ function serializeEnvelope(env) {
86
+ return env.map((f) => "0x" + f.toString(16)).join(",");
87
+ }
88
+ function deserializeEnvelope(s) {
89
+ return s.split(",").filter(Boolean).map((f) => BigInt(f));
90
+ }
91
+ function newOeNonce(nowMs, rand) {
92
+ return BigInt(nowMs) << 24n | BigInt(Math.floor(rand * 16777215));
93
+ }
94
+ function deriveExecuteAfter(oeExecuteBefore) {
95
+ return BigInt(oeExecuteBefore) - BigInt(OE_WINDOW_SECONDS);
96
+ }
97
+ async function buildActionProposal(params) {
98
+ const nowMs = params.nowMs ?? Date.now();
99
+ const nonce = newOeNonce(nowMs, params.rand ?? Math.random());
100
+ const executeAfter = BigInt(Math.floor(nowMs / 1e3) - OE_AFTER_SKEW_SECONDS);
101
+ const executeBefore = executeAfter + BigInt(OE_WINDOW_SECONDS);
102
+ const oe = buildOutsideExecution({
103
+ nonce,
104
+ calls: toOeCalls(params.calls),
105
+ caller: ANY_CALLER_FELT,
106
+ executeAfter,
107
+ executeBefore
108
+ });
109
+ const messageHash = computeOeHash(oe, params.walletAddress, params.chainId ?? SN_MAIN_CHAIN_ID);
110
+ const inner = await params.sign({
111
+ messageHash,
112
+ ownerIndex: params.ownerIndex ?? 0n
113
+ });
114
+ return {
115
+ oeMessageHash: "0x" + messageHash.toString(16),
116
+ oeNonce: "0x" + nonce.toString(16),
117
+ oeExecuteBefore: executeBefore.toString(),
118
+ proposerSignature: serializeEnvelope(inner)
119
+ };
120
+ }
121
+ async function signActionApproval(params) {
122
+ const inner = await params.sign({
123
+ messageHash: BigInt(params.oeMessageHash),
124
+ ownerIndex: params.ownerIndex
125
+ });
126
+ return serializeEnvelope(inner);
127
+ }
128
+ function assembleActionExecuteCalldata(params) {
129
+ const oe = buildOutsideExecution({
130
+ nonce: BigInt(params.oeNonce),
131
+ calls: toOeCalls(params.calls),
132
+ caller: ANY_CALLER_FELT,
133
+ executeAfter: deriveExecuteAfter(params.oeExecuteBefore),
134
+ executeBefore: BigInt(params.oeExecuteBefore)
135
+ });
136
+ const inner = params.signatures.map(deserializeEnvelope);
137
+ if (inner.length < Math.max(1, params.requiredApprovals)) {
138
+ throw new Error(
139
+ `Not enough signatures: have ${inner.length}, need ${params.requiredApprovals}.`
140
+ );
141
+ }
142
+ const signature = params.requiredApprovals <= 1 ? inner[0] : buildThresholdEnvelope({ innerEnvelopes: inner });
143
+ return serializeExecuteFromOutsideV2Calldata({
144
+ outsideExecution: oe,
145
+ signature
146
+ });
147
+ }
148
+
149
+ // src/multisig/proposals.ts
150
+ async function createProposal(params) {
151
+ const calls = params.template.toCalls(params.values);
152
+ if (calls.length === 0) {
153
+ throw new Error("Template produced no calls");
154
+ }
155
+ const title = params.template.title(params.values);
156
+ const meta = params.template.meta?.(params.values);
157
+ const proposerOwnerId = params.signer.proposerOwnerIndex ?? 0;
158
+ const proposal = await buildActionProposal({
159
+ walletAddress: params.walletAddress,
160
+ calls,
161
+ sign: params.signer.sign,
162
+ ownerIndex: BigInt(proposerOwnerId),
163
+ chainId: params.chainId,
164
+ nowMs: params.nowMs,
165
+ rand: params.rand
166
+ });
167
+ return {
168
+ proposerOwnerId,
169
+ recipient: calls[0].to,
170
+ tokenAddress: calls[0].to,
171
+ amount: "0",
172
+ title,
173
+ calls,
174
+ ...meta ? { meta } : {},
175
+ oeMessageHash: proposal.oeMessageHash,
176
+ oeNonce: proposal.oeNonce,
177
+ oeExecuteBefore: proposal.oeExecuteBefore,
178
+ requiredApprovals: params.requiredApprovals,
179
+ proposerSignature: proposal.proposerSignature,
180
+ proposerSignerKind: params.signer.signerKind
181
+ };
182
+ }
183
+ async function buildApproval(params) {
184
+ const ownerId = await params.signer.resolveOwnerIndex(params.walletAddress);
185
+ const signature = await signActionApproval({
186
+ oeMessageHash: params.proposal.oeMessageHash,
187
+ ownerIndex: BigInt(ownerId),
188
+ sign: params.signer.sign
189
+ });
190
+ return { ownerId, signature, signerKind: params.signer.signerKind };
191
+ }
192
+ function buildExecuteCalldata(proposal) {
193
+ if (!proposal.calls || proposal.calls.length === 0) {
194
+ throw new Error("Proposal has no calls to execute");
195
+ }
196
+ if (!proposal.oeNonce || !proposal.oeExecuteBefore) {
197
+ throw new Error("Proposal is missing OE params (nonce / executeBefore)");
198
+ }
199
+ const signatures = [...proposal.signatures].sort((a, b) => a.ownerId - b.ownerId).map((s) => s.signature);
200
+ return assembleActionExecuteCalldata({
201
+ calls: proposal.calls,
202
+ oeNonce: proposal.oeNonce,
203
+ oeExecuteBefore: proposal.oeExecuteBefore,
204
+ signatures,
205
+ requiredApprovals: proposal.requiredApprovals
206
+ });
207
+ }
208
+ var proposalsKey = (walletAddress) => ["chipi-multisig-proposals", walletAddress];
209
+ function useProposeAction(config) {
210
+ const qc = useQueryClient();
211
+ return useMutation({
212
+ mutationFn: async (input) => {
213
+ const requiredApprovals = await config.getRequiredApprovals();
214
+ const body = await createProposal({
215
+ template: input.template,
216
+ values: input.values,
217
+ walletAddress: config.walletAddress,
218
+ requiredApprovals,
219
+ signer: config.signer,
220
+ chainId: config.chainId
221
+ });
222
+ return config.transport.propose(body);
223
+ },
224
+ onSuccess: () => qc.invalidateQueries({
225
+ queryKey: proposalsKey(config.walletAddress)
226
+ })
227
+ });
228
+ }
229
+ function useTreasuryProposals(config) {
230
+ const qc = useQueryClient();
231
+ const invalidate = () => qc.invalidateQueries({ queryKey: proposalsKey(config.walletAddress) });
232
+ const proposals = useQuery({
233
+ queryKey: proposalsKey(config.walletAddress),
234
+ staleTime: 30 * 1e3,
235
+ queryFn: () => config.transport.list()
236
+ });
237
+ const approve = useMutation({
238
+ mutationFn: async (proposal) => {
239
+ const body = await buildApproval({
240
+ proposal,
241
+ walletAddress: config.walletAddress,
242
+ signer: config.signer
243
+ });
244
+ return config.transport.sign(proposal.id, body);
245
+ },
246
+ onSuccess: invalidate
247
+ });
248
+ const execute = useMutation({
249
+ mutationFn: (proposal) => config.transport.execute(proposal.id, buildExecuteCalldata(proposal)),
250
+ onSuccess: invalidate
251
+ });
252
+ return { proposals, approve, execute };
253
+ }
254
+
255
+ export { FELT_PRIME, OE_WINDOW_SECONDS, SN_MAIN_CHAIN_ID, amountToBase, assembleActionExecuteCalldata, buildActionProposal, buildApproval, buildExecuteCalldata, createProposal, defineActions, deriveExecuteAfter, deserializeEnvelope, newOeNonce, serializeEnvelope, signActionApproval, toFelt, u256, useProposeAction, useTreasuryProposals, voteTemplate };
256
+ //# sourceMappingURL=multisig.mjs.map
257
+ //# sourceMappingURL=multisig.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/multisig/action-template.ts","../src/multisig/oe.ts","../src/multisig/proposals.ts","../src/multisig/use-hooks.ts"],"names":[],"mappings":";;;;AA2DO,IAAM,UAAA,GAAa,MAAA;AAAA,EACxB;AACF;AAEA,IAAM,SAAA,GAAA,CAAa,MAAM,IAAA,IAAQ,EAAA;AAI1B,SAAS,OAAO,CAAA,EAAqB;AAC1C,EAAA,IAAI,CAAA;AACJ,EAAA,IAAI;AACF,IAAA,CAAA,GAAI,OAAO,OAAO,C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AA,EAIlC;AACD,EAAA,MAAM,KAAK,cAAA,EAAe;AAC1B,EAAA,MAAM,UAAA,GAAa,MAAM,EAAA,CAAG,iBAAA,CAAkB,EAAE,UAAU,YAAA,CAAa,MAAA,CAAO,aAAa,CAAA,EAAG,CAAA;AAE9F,EAAA,MAAM,YAAY,QAAA,CAAS;AAAA,IACzB,QAAA,EAAU,YAAA,CAAa,MAAA,CAAO,aAAa,CAAA;AAAA,IAC3C,WAAW,EAAA,GAAK,GAAA;AAAA,IAChB,OAAA,EAAS,MAAM,MAAA,CAAO,SAAA,CAAU,IAAA;AAAK,GACtC,CAAA;AAED,EAAA,MAAM,UAAU,WAAA,CAAY;AAAA,IAC1B,UAAA,EAAY,OAAO,QAAA,KAA+B;AAChD,MAAA,MAAM,IAAA,GAAO,MAAM,aAAA,CAAc;AAAA,QAC/B,QAAA;AAAA,QACA,eAAe,MAAA,CAAO,aAAA;AAAA,QACtB,QAAQ,MAAA,CAAO;AAAA,OAChB,CAAA;AACD,MAAA,OAAO,MAAA,CAAO,SAAA,CAAU,IAAA,CAAK,QAAA,CAAS,IAAI,IAAI,CAAA;AAAA,IAChD,CAAA;AAAA,IACA,SAAA,EAAW;AAAA,GACZ,CAAA;AAED,EAAA,MAAM,UAAU,WAAA,CAAY;AAAA,IAC1B,UAAA,EAAY,CAAC,QAAA,KACX,MAAA,CAAO,SAAA,CAAU,QAAQ,QAAA,CAAS,EAAA,EAAI,oBAAA,CAAqB,QAAQ,CAAC,CAAA;AAAA,IACtE,SAAA,EAAW;AAAA,GACZ,CAAA;AAED,EAAA,OAAO,EAAE,SAAA,EAAW,OAAA,EAAS,OAAA,EAAQ;AACvC","file":"multisig.mjs","sourcesContent":["/**\n * Framework-agnostic action-template engine for SHHH multisig governance.\n *\n * An {@link ActionTemplate} maps friendly, typed form fields → an\n * OutsideExecution call list + a human-readable title. It's the seam that\n * turns \"call any contract\" (powerful, scary) into \"fill in this form\"\n * (founder-grade) — and the whitelabel seam: every integrator registers\n * its own templates (Roca: create_pool / borrow / repay), while `Vote`\n * ships built-in. The raw-call escape hatch lives in the UI layer, not\n * here, because its arguments are open-ended.\n *\n * Pure: no React, no network — so the same template renders the proposer's\n * form, every approver's inbox, and the notification, from one source of\n * truth, and `toCalls` is deterministic (proposer and executor build the\n * identical OE → the hash matches).\n */\n\nexport type FeltLike = string | number | bigint;\n\n/** One call in an action — the shape the OE builder consumes. */\nexport interface CallSpec {\n to: string;\n entrypoint: string;\n /** Flat 0x-hex felts. */\n calldata: string[];\n}\n\n/** A typed input in an action template. */\nexport type FieldSpec =\n | { name: string; label: string; type: \"amount\"; decimals: number; help?: string }\n | { name: string; label: string; type: \"address\"; help?: string }\n | { name: string; label: string; type: \"number\" | \"bps\" | \"days\" | \"felt\"; help?: string }\n | {\n name: string;\n label: string;\n type: \"select\";\n options: { label: string; value: string }[];\n help?: string;\n }\n | { name: string; label: string; type: \"text\"; help?: string };\n\nexport interface ActionTemplate<V = Record<string, unknown>> {\n /** Stable id, persisted on the proposal. */\n key: string;\n /** Display label (\"Create pool\"). */\n label: string;\n description?: string;\n /** Typed inputs rendered by `<ProposeAction>`. */\n fields: FieldSpec[];\n /** Pure: validated field values → the OE call list. */\n toCalls: (v: V) => CallSpec[];\n /** Pure: the plain-language title shown in the preview, inbox, and email. */\n title: (v: V) => string;\n /** Optional metadata persisted with the proposal so the approver's app\n * can render business context (e.g. `{ poolId }`). */\n meta?: (v: V) => Record<string, string | number>;\n}\n\n/** Starknet felt252 field prime — args must be a non-negative felt below it. */\nexport const FELT_PRIME = BigInt(\n \"0x800000000000011000000000000000000000000000000000000000000000001\"\n);\n\nconst U128_MASK = (1n << 128n) - 1n;\n\n/** Parse a decimal or 0x-hex value to a canonical `0x` felt. Throws on a\n * non-numeric or out-of-range value. */\nexport function toFelt(v: FeltLike): string {\n let n: bigint;\n try {\n n = BigInt(typeof v === \"string\" ? v.trim() : v);\n } catch {\n throw new Error(`Not a felt: ${String(v)}`);\n }\n if (n < 0n || n >= FELT_PRIME) {\n throw new Error(`Felt out of range: ${String(v)}`);\n }\n return \"0x\" + n.toString(16);\n}\n\n/** Split a u256 value into its `[low, high]` felts (Cairo calling convention). */\nexport function u256(v: FeltLike): [string, string] {\n const n = BigInt(typeof v === \"string\" ? v.trim() : v);\n if (n < 0n) throw new Error(\"u256 must be non-negative\");\n return [\"0x\" + (n & U128_MASK).toString(16), \"0x\" + (n >> 128n).toString(16)];\n}\n\n/** Convert a human amount (\"10.5\") to base units given a token's decimals. */\nexport function amountToBase(amount: string, decimals: number): bigint {\n const t = amount.trim();\n if (!/^\\d+(\\.\\d+)?$/.test(t)) throw new Error(`Invalid amount: ${amount}`);\n const [whole, frac = \"\"] = t.split(\".\");\n if (frac.length > decimals) {\n throw new Error(`Too many decimal places (max ${decimals})`);\n }\n const padded = (frac + \"0\".repeat(decimals)).slice(0, decimals);\n return BigInt(whole) * 10n ** BigInt(decimals) + BigInt(padded || \"0\");\n}\n\n/**\n * Identity + light validation for a template registry: keys are present\n * and unique. Returns the same array (typed) so call sites keep inference.\n */\nexport function defineActions<T extends ActionTemplate<any>[]>(templates: [...T]): [...T] {\n const seen = new Set<string>();\n for (const t of templates) {\n if (!t.key) throw new Error(\"ActionTemplate.key is required\");\n if (seen.has(t.key)) throw new Error(`Duplicate ActionTemplate key: ${t.key}`);\n seen.add(t.key);\n }\n return templates;\n}\n\nexport interface VoteValues {\n contract: string;\n proposalId: string;\n choice: string; // felt: \"0x1\" yes / \"0x0\" no / \"0x2\" abstain\n}\n\nconst VOTE_CHOICES = [\n { label: \"Yes\", value: \"0x1\" },\n { label: \"No\", value: \"0x0\" },\n { label: \"Abstain\", value: \"0x2\" },\n];\n\n/**\n * Built-in `Vote` template — `vote(proposalId, choice)` on a governance\n * contract. Pin the contract and/or entrypoint up front (then they drop\n * out of the form), or leave them for the proposer to fill.\n */\nexport function voteTemplate(opts?: {\n governanceContract?: string;\n entrypoint?: string;\n}): ActionTemplate<VoteValues> {\n const fields: FieldSpec[] = [];\n if (!opts?.governanceContract) {\n fields.push({ name: \"contract\", label: \"Governance contract\", type: \"address\" });\n }\n fields.push(\n { name: \"proposalId\", label: \"Proposal ID\", type: \"felt\" },\n { name: \"choice\", label: \"Your vote\", type: \"select\", options: VOTE_CHOICES }\n );\n const labelFor = (v: string) => VOTE_CHOICES.find((c) => c.value === v)?.label ?? v;\n return {\n key: \"vote\",\n label: \"Vote\",\n description: \"Vote on a governance proposal.\",\n fields,\n toCalls: (v) => [\n {\n to: opts?.governanceContract ?? v.contract,\n entrypoint: opts?.entrypoint ?? \"vote\",\n calldata: [toFelt(v.proposalId), toFelt(v.choice)],\n },\n ],\n title: (v) => `Vote ${labelFor(v.choice)} on Proposal #${v.proposalId}`,\n };\n}\n","/**\n * Signer- and transport-agnostic OutsideExecution core for SHHH multisig\n * governance. Build an OE over an arbitrary call list, sign it per-owner\n * (the key never leaves the caller — passkey/MetaMask/Phantom/STARK), and\n * once enough approvals are collected, rebuild the exact OE and wrap the\n * inner envelopes in a V2_THRESHOLD envelope for execution.\n *\n * Deterministic rebuild is the load-bearing property: caller = ANY_CALLER,\n * and the persisted nonce + executeAfter + executeBefore mean the executor\n * reconstructs the identical OE hash the owners signed. executeAfter is\n * pinned to ~now (not 0) so the validity window stays within the contract\n * cap (audit M-2) — so it MUST be persisted, not assumed constant.\n */\nimport {\n ANY_CALLER_FELT,\n MAX_OE_VALIDITY_WINDOW_SECONDS,\n buildOutsideExecution,\n buildThresholdEnvelope,\n computeOeHash,\n serializeExecuteFromOutsideV2Calldata,\n} from \"@chipi-stack/backend\";\nimport type { CallSpec } from \"./action-template\";\n\n/** shortString.encodeShortString(\"SN_MAIN\") — Starknet mainnet. */\nexport const SN_MAIN_CHAIN_ID = \"0x534e5f4d41494e\";\n\n/**\n * Max on-chain OE validity window (`executeBefore - executeAfter`), capped\n * by the SHHH contract audit (M-2). This is the longest a proposal stays\n * EXECUTABLE — distinct from how long its record lives in the coordination\n * backend. NOTE: with `executeAfter` pinned to 0 the window would be the\n * whole epoch and the contract rejects it, so `executeAfter` is set to ~now\n * and persisted alongside the nonce + `executeBefore`.\n */\nexport const OE_WINDOW_SECONDS = Number(MAX_OE_VALIDITY_WINDOW_SECONDS);\n/** Small clock-skew cushion so the OE is valid by the next block. */\nconst OE_AFTER_SKEW_SECONDS = 60;\n\n/**\n * Signs an OE message hash for one owner → that owner's inner V2_SNIP12\n * envelope (an array of felts). Implementations wrap a passkey / MetaMask /\n * Phantom / STARK signer; the private key never leaves the implementation.\n */\nexport type OeSigner = (params: {\n messageHash: bigint;\n ownerIndex: bigint;\n}) => Promise<bigint[]> | bigint[];\n\ninterface OeCall {\n contractAddress: string;\n entrypoint: string;\n calldata: string[];\n}\n\nfunction toOeCalls(calls: CallSpec[]): OeCall[] {\n return calls.map((c) => ({\n contractAddress: c.to,\n entrypoint: c.entrypoint,\n calldata: c.calldata,\n }));\n}\n\n/** Serialize an inner envelope (felt[]) to the comma-joined 0x-hex string\n * the coordination backend stores per signature. */\nexport function serializeEnvelope(env: bigint[]): string {\n return env.map((f) => \"0x\" + f.toString(16)).join(\",\");\n}\n\nexport function deserializeEnvelope(s: string): bigint[] {\n return s\n .split(\",\")\n .filter(Boolean)\n .map((f) => BigInt(f));\n}\n\n/**\n * OE replay nonce: ms timestamp shifted left 24 bits, ORed with a 24-bit\n * random suffix. `nowMs`/`rand` are injectable for deterministic tests.\n */\nexport function newOeNonce(nowMs: number, rand: number): bigint {\n return (BigInt(nowMs) << 24n) | BigInt(Math.floor(rand * 0xffffff));\n}\n\nexport interface ActionProposal {\n oeMessageHash: string;\n oeNonce: string;\n oeExecuteBefore: string;\n /** The proposer's inner V2_SNIP12 envelope, comma-joined 0x-hex. */\n proposerSignature: string;\n}\n\n/** Derive the OE's executeAfter from its persisted executeBefore. The\n * window is a fixed constant (the contract cap), so the executor needs\n * only executeBefore to reconstruct the exact signed OE — no separate\n * executeAfter persistence (and no backend column). */\nexport function deriveExecuteAfter(oeExecuteBefore: string): bigint {\n return BigInt(oeExecuteBefore) - BigInt(OE_WINDOW_SECONDS);\n}\n\n/**\n * Build an OE over `calls`, sign it as the proposer (owner 0 by default),\n * and return everything a propose endpoint needs. The OE params (nonce +\n * executeBefore) are returned; executeAfter is `executeBefore - OE_WINDOW`,\n * so only executeBefore needs persisting. The window is the contract cap\n * (the longest executable window M-2 allows).\n */\nexport async function buildActionProposal(params: {\n walletAddress: string;\n calls: CallSpec[];\n sign: OeSigner;\n ownerIndex?: bigint;\n chainId?: string;\n nowMs?: number;\n rand?: number;\n}): Promise<ActionProposal> {\n const nowMs = params.nowMs ?? Date.now();\n const nonce = newOeNonce(nowMs, params.rand ?? Math.random());\n // executeAfter ~now (minus skew); the window = executeBefore - executeAfter\n // is the fixed contract cap, so executeAfter can't be 0 (which would make\n // the window the whole epoch and the contract reject it). Deriving it from\n // executeBefore at execute time means we persist only executeBefore.\n const executeAfter = BigInt(Math.floor(nowMs / 1000) - OE_AFTER_SKEW_SECONDS);\n const executeBefore = executeAfter + BigInt(OE_WINDOW_SECONDS);\n const oe = buildOutsideExecution({\n nonce,\n calls: toOeCalls(params.calls),\n caller: ANY_CALLER_FELT,\n executeAfter,\n executeBefore,\n });\n const messageHash = computeOeHash(oe, params.walletAddress, params.chainId ?? SN_MAIN_CHAIN_ID);\n const inner = await params.sign({\n messageHash,\n ownerIndex: params.ownerIndex ?? 0n,\n });\n return {\n oeMessageHash: \"0x\" + messageHash.toString(16),\n oeNonce: \"0x\" + nonce.toString(16),\n oeExecuteBefore: executeBefore.toString(),\n proposerSignature: serializeEnvelope(inner),\n };\n}\n\n/** Sign an existing proposal's OE hash as an approver → inner envelope string. */\nexport async function signActionApproval(params: {\n oeMessageHash: string;\n ownerIndex: bigint;\n sign: OeSigner;\n}): Promise<string> {\n const inner = await params.sign({\n messageHash: BigInt(params.oeMessageHash),\n ownerIndex: params.ownerIndex,\n });\n return serializeEnvelope(inner);\n}\n\n/**\n * Rebuild the exact OE from the persisted params + collected signatures and\n * serialize the `execute` calldata. A 1-of-N wallet uses the single inner\n * envelope; N≥2 wraps the inner envelopes in a V2_THRESHOLD envelope.\n */\nexport function assembleActionExecuteCalldata(params: {\n calls: CallSpec[];\n oeNonce: string;\n oeExecuteBefore: string;\n signatures: string[];\n requiredApprovals: number;\n}): string[] {\n const oe = buildOutsideExecution({\n nonce: BigInt(params.oeNonce),\n calls: toOeCalls(params.calls),\n caller: ANY_CALLER_FELT,\n executeAfter: deriveExecuteAfter(params.oeExecuteBefore),\n executeBefore: BigInt(params.oeExecuteBefore),\n });\n const inner = params.signatures.map(deserializeEnvelope);\n if (inner.length < Math.max(1, params.requiredApprovals)) {\n throw new Error(\n `Not enough signatures: have ${inner.length}, need ${params.requiredApprovals}.`\n );\n }\n const signature =\n params.requiredApprovals <= 1 ? inner[0] : buildThresholdEnvelope({ innerEnvelopes: inner });\n return serializeExecuteFromOutsideV2Calldata({\n outsideExecution: oe,\n signature,\n });\n}\n","/**\n * Pure orchestration for the multisig governance flow — build a propose\n * body, build an approval, assemble execute calldata. No React, no network:\n * the hooks (`use-hooks.ts`) wrap these in mutations/queries, and they're\n * directly unit-testable with a mock signer + injected `nowMs`/`rand`.\n */\nimport type { ActionTemplate } from \"./action-template\";\nimport { buildActionProposal, signActionApproval, assembleActionExecuteCalldata } from \"./oe\";\nimport type { MultisigSigner, ProposeBody, ProposalSignature, TreasuryProposal } from \"./types\";\n\n/**\n * Build a propose body for a template + its validated field values: derive\n * the call(s) + title (+ meta), build & proposer-sign the OE, and shape the\n * body the coordination backend expects. For an action the payment fields\n * are placeholders (recipient/token = the first call's target, amount \"0\");\n * the real intent rides in `calls` + `title`.\n */\nexport async function createProposal<V>(params: {\n template: ActionTemplate<V>;\n values: V;\n walletAddress: string;\n requiredApprovals: number;\n signer: MultisigSigner;\n chainId?: string;\n nowMs?: number;\n rand?: number;\n}): Promise<ProposeBody> {\n const calls = params.template.toCalls(params.values);\n if (calls.length === 0) {\n throw new Error(\"Template produced no calls\");\n }\n const title = params.template.title(params.values);\n const meta = params.template.meta?.(params.values);\n const proposerOwnerId = params.signer.proposerOwnerIndex ?? 0;\n\n const proposal = await buildActionProposal({\n walletAddress: params.walletAddress,\n calls,\n sign: params.signer.sign,\n ownerIndex: BigInt(proposerOwnerId),\n chainId: params.chainId,\n nowMs: params.nowMs,\n rand: params.rand,\n });\n\n return {\n proposerOwnerId,\n recipient: calls[0].to,\n tokenAddress: calls[0].to,\n amount: \"0\",\n title,\n calls,\n ...(meta ? { meta } : {}),\n oeMessageHash: proposal.oeMessageHash,\n oeNonce: proposal.oeNonce,\n oeExecuteBefore: proposal.oeExecuteBefore,\n requiredApprovals: params.requiredApprovals,\n proposerSignature: proposal.proposerSignature,\n proposerSignerKind: params.signer.signerKind,\n };\n}\n\n/**\n * Build an approver's signature on an existing proposal: resolve this\n * device's owner index from chain, then sign the SAME OE hash.\n */\nexport async function buildApproval(params: {\n proposal: Pick<TreasuryProposal, \"oeMessageHash\">;\n walletAddress: string;\n signer: MultisigSigner;\n}): Promise<{ ownerId: number; signature: string; signerKind: string }> {\n const ownerId = await params.signer.resolveOwnerIndex(params.walletAddress);\n const signature = await signActionApproval({\n oeMessageHash: params.proposal.oeMessageHash,\n ownerIndex: BigInt(ownerId),\n sign: params.signer.sign,\n });\n return { ownerId, signature, signerKind: params.signer.signerKind };\n}\n\n/**\n * Assemble the execute calldata from a proposal's persisted call(s) + its\n * collected signatures (sorted by owner index). Requires `calls` — this is\n * the generalized-action flow; a host with payment-only proposals supplies\n * the transfer calls.\n */\nexport function buildExecuteCalldata(proposal: TreasuryProposal): string[] {\n if (!proposal.calls || proposal.calls.length === 0) {\n throw new Error(\"Proposal has no calls to execute\");\n }\n if (!proposal.oeNonce || !proposal.oeExecuteBefore) {\n throw new Error(\"Proposal is missing OE params (nonce / executeBefore)\");\n }\n const signatures = [...proposal.signatures]\n .sort((a: ProposalSignature, b: ProposalSignature) => a.ownerId - b.ownerId)\n .map((s) => s.signature);\n return assembleActionExecuteCalldata({\n calls: proposal.calls,\n oeNonce: proposal.oeNonce,\n oeExecuteBefore: proposal.oeExecuteBefore,\n signatures,\n requiredApprovals: proposal.requiredApprovals,\n });\n}\n","/**\n * React hooks for the multisig governance flow — the reusable orchestration\n * the dashboard (and integrators) build their UI on. They wrap the pure\n * functions in `proposals.ts` with @tanstack/react-query, parameterized by\n * an injectable {@link MultisigTransport} (authed coordination backend) and\n * {@link MultisigSigner} (per-owner OE signer). The host owns the UI.\n */\nimport { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport type { ActionTemplate } from \"./action-template\";\nimport { createProposal, buildApproval, buildExecuteCalldata } from \"./proposals\";\nimport type { MultisigSigner, MultisigTransport, TreasuryProposal } from \"./types\";\n\nconst proposalsKey = (walletAddress: string) => [\"chipi-multisig-proposals\", walletAddress];\n\nexport interface ProposeInput {\n template: ActionTemplate<any>;\n values: any;\n}\n\n/**\n * Propose a templated action: build the call(s) + title from the template,\n * passkey-/key-sign the OE as the proposer, and submit it. `getRequiredApprovals`\n * supplies the wallet's threshold (the host reads it from chain — the package\n * stays chain-agnostic).\n */\nexport function useProposeAction(config: {\n walletAddress: string;\n transport: MultisigTransport;\n signer: MultisigSigner;\n getRequiredApprovals: () => Promise<number>;\n chainId?: string;\n}) {\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: ProposeInput) => {\n const requiredApprovals = await config.getRequiredApprovals();\n const body = await createProposal({\n template: input.template,\n values: input.values,\n walletAddress: config.walletAddress,\n requiredApprovals,\n signer: config.signer,\n chainId: config.chainId,\n });\n return config.transport.propose(body);\n },\n onSuccess: () =>\n qc.invalidateQueries({\n queryKey: proposalsKey(config.walletAddress),\n }),\n });\n}\n\n/**\n * List a treasury's proposals and expose approve / execute mutations. An\n * approver signs the same OE hash as their resolved owner index; once enough\n * approvals are collected, execute rebuilds the OE from the persisted call(s)\n * and relays it.\n */\nexport function useTreasuryProposals(config: {\n walletAddress: string;\n transport: MultisigTransport;\n signer: MultisigSigner;\n}) {\n const qc = useQueryClient();\n const invalidate = () => qc.invalidateQueries({ queryKey: proposalsKey(config.walletAddress) });\n\n const proposals = useQuery({\n queryKey: proposalsKey(config.walletAddress),\n staleTime: 30 * 1000,\n queryFn: () => config.transport.list(),\n });\n\n const approve = useMutation({\n mutationFn: async (proposal: TreasuryProposal) => {\n const body = await buildApproval({\n proposal,\n walletAddress: config.walletAddress,\n signer: config.signer,\n });\n return config.transport.sign(proposal.id, body);\n },\n onSuccess: invalidate,\n });\n\n const execute = useMutation({\n mutationFn: (proposal: TreasuryProposal) =>\n config.transport.execute(proposal.id, buildExecuteCalldata(proposal)),\n onSuccess: invalidate,\n });\n\n return { proposals, approve, execute };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chipi-stack/chipi-react",
3
- "version": "14.7.0",
3
+ "version": "14.8.0",
4
4
  "description": "React hooks and components for Chipi SDK",
5
5
  "keywords": [
6
6
  "chipi",
@@ -69,6 +69,16 @@
69
69
  "default": "./dist/components.js"
70
70
  }
71
71
  },
72
+ "./multisig": {
73
+ "import": {
74
+ "types": "./dist/multisig.d.mts",
75
+ "default": "./dist/multisig.mjs"
76
+ },
77
+ "require": {
78
+ "types": "./dist/multisig.d.ts",
79
+ "default": "./dist/multisig.js"
80
+ }
81
+ },
72
82
  "./package.json": "./package.json"
73
83
  },
74
84
  "main": "./dist/index.js",
@@ -92,11 +102,11 @@
92
102
  },
93
103
  "dependencies": {
94
104
  "@tanstack/react-query": "^5.85.0",
95
- "@chipi-stack/backend": "^14.7.0",
105
+ "@chipi-stack/backend": "^14.8.0",
96
106
  "@chipi-stack/chipi-passkey": "^2.2.0",
97
107
  "@chipi-stack/core": "^0.3.1",
98
- "@chipi-stack/shared": "^14.7.0",
99
- "@chipi-stack/types": "^14.7.0"
108
+ "@chipi-stack/shared": "^14.8.0",
109
+ "@chipi-stack/types": "^14.8.0"
100
110
  },
101
111
  "peerDependencies": {
102
112
  "react": ">=18.0.0",