@chipi-stack/chipi-react 14.7.0 → 14.9.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.
- package/README.md +41 -0
- package/dist/hooks.d.mts +6 -2619
- package/dist/hooks.d.ts +6 -2619
- package/dist/hooks.js +18553 -211
- package/dist/hooks.js.map +1 -1
- package/dist/hooks.mjs +18400 -80
- package/dist/hooks.mjs.map +1 -1
- package/dist/index-B8e6TdyG.d.mts +2743 -0
- package/dist/index-B8e6TdyG.d.ts +2743 -0
- package/dist/index.d.mts +60 -2
- package/dist/index.d.ts +60 -2
- package/dist/index.js +18668 -178
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18651 -185
- package/dist/index.mjs.map +1 -1
- package/dist/multisig.d.mts +482 -0
- package/dist/multisig.d.ts +482 -0
- package/dist/multisig.js +744 -0
- package/dist/multisig.js.map +1 -0
- package/dist/multisig.mjs +714 -0
- package/dist/multisig.mjs.map +1 -0
- package/package.json +16 -4
|
@@ -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","../src/multisig/components/theme.ts","../src/multisig/components/field-input.tsx","../src/multisig/components/propose-action.tsx","../src/multisig/components/approvals.tsx","../src/multisig/components/approval-inbox.tsx"],"names":["MAX_OE_VALIDITY_WINDOW_SECONDS","buildOutsideExecution","ANY_CALLER_FELT","computeOeHash","buildThresholdEnvelope","serializeExecuteFromOutsideV2Calldata","useQueryClient","useMutation","useQuery","jsxs","jsx","useState","useEffect","useMemo","Fragment"],"mappings":";;;;;;;;AAiEO,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,OAA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AAA,CAAE,eAAA;AAAA,QACnB,YAAY,CAAA,CAAE,UAAA;AAAA,QACd,MAAA,EAAO,YAAA;AAAA,QACP,OAAO,KAAA,CAAM,KAAA;AAAA,QACb,KAAA,EAAO,MAAM,OAAA,IAAW,gBAAA;AAAA,QACxB,UAAA,EAAY,CAAC,CAAA,EAAG,EAAA,KAAO,MAAM,UAAA,GAAa,CAAA,EAAG,GAAG,EAAE;AAAA;AAAA;AACpD,GAAA,EAAA,EAdY,CAAA,CAAE,aAehB,CACD,CAAA,EACH,CAAA;AAEJ","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 /** App-level risk tier (decision §11.4). When the treasury configured the\n * matching quorum, the backend OVERRIDES requiredApprovals at propose\n * (ROUTINE → routineQuorum, SENSITIVE → sensitiveQuorum). App-enforced\n * for human treasuries — the on-chain wallet threshold stays the hard\n * floor at execute. Omit = no tier (the client's value is used). */\n risk?: \"ROUTINE\" | \"SENSITIVE\";\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 ...(params.template.risk ? { risk: params.template.risk } : {}),\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 // H3 — wrap exactly `requiredApprovals` signatures, not every collected\n // one. `sign()` accepts signatures until status flips, so a proposal can\n // gather MORE than the threshold (eager/concurrent signers). The Cairo\n // V2_THRESHOLD dispatch verifies EVERY inner envelope, so wrapping extras\n // — especially one from a since-rotated owner — reverts the whole\n // execute. Take the lowest-index threshold-sized subset (deterministic;\n // matches the on-chain threshold). For 1-of-N this is the single envelope.\n const need = Math.max(1, proposal.requiredApprovals);\n const signatures = [...proposal.signatures]\n .sort((a: ProposalSignature, b: ProposalSignature) => a.ownerId - b.ownerId)\n .slice(0, need)\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","/**\n * Theming for the embeddable governance components (design brief §8).\n *\n * One mechanism: every component root carries inline CSS variables derived\n * from a `theme` prop merged over the defaults, and a single namespaced\n * stylesheet (injected once at runtime) styles everything off those vars.\n * Integrators theme by passing tokens — `<Approvals theme={{ accent:\n * \"#0f766e\", radius: \"0.375rem\" }} />` — and the components render native\n * to the host app. No Tailwind/CSS-import requirement; SSR-safe (the\n * stylesheet injects in an effect, and first paint is already var-driven).\n *\n * Default skin = the Chipi neobrutalism system: bold borders, hard offset\n * shadow, high-contrast text.\n */\n\nexport interface ChipiGovTheme {\n /** Primary action color (buttons, focus, progress). */\n accent?: string;\n /** Text color on the accent. */\n accentText?: string;\n /** Card/dialog background. */\n surface?: string;\n /** Page-muted background (rows, inputs). */\n surfaceMuted?: string;\n /** Primary text. */\n text?: string;\n /** Secondary text. */\n textMuted?: string;\n /** Error/destructive color. */\n danger?: string;\n /** Success color (executed, looks-good). */\n success?: string;\n /** Border color. */\n border?: string;\n /** Corner radius (any CSS length). */\n radius?: string;\n /** Hard offset shadow (set to \"none\" for flat hosts). */\n shadow?: string;\n /** Font stack. */\n font?: string;\n}\n\nexport const DEFAULT_THEME: Required<ChipiGovTheme> = {\n accent: \"#4f46e5\",\n accentText: \"#ffffff\",\n surface: \"#fffdf8\",\n surfaceMuted: \"#f4f1ea\",\n text: \"#111111\",\n textMuted: \"#6b7280\",\n danger: \"#dc2626\",\n success: \"#16a34a\",\n border: \"#111111\",\n radius: \"12px\",\n shadow: \"4px 4px 0 0 #111111\",\n font: \"ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif\",\n};\n\n/** Inline CSS-var style object for a component root. */\nexport function themeVars(theme?: ChipiGovTheme): Record<string, string> {\n const t = { ...DEFAULT_THEME, ...theme };\n return {\n \"--cgov-accent\": t.accent,\n \"--cgov-accent-text\": t.accentText,\n \"--cgov-surface\": t.surface,\n \"--cgov-surface-muted\": t.surfaceMuted,\n \"--cgov-text\": t.text,\n \"--cgov-text-muted\": t.textMuted,\n \"--cgov-danger\": t.danger,\n \"--cgov-success\": t.success,\n \"--cgov-border\": t.border,\n \"--cgov-radius\": t.radius,\n \"--cgov-shadow\": t.shadow,\n \"--cgov-font\": t.font,\n };\n}\n\nconst STYLE_ID = \"chipi-gov-styles\";\n\n/**\n * The single namespaced stylesheet. Class prefix `cgov-`; everything reads\n * the CSS vars set on the component root so per-instance themes coexist.\n */\nconst STYLE_TEXT = `\n.cgov-root{font-family:var(--cgov-font);color:var(--cgov-text);box-sizing:border-box}\n.cgov-root *,.cgov-root *::before,.cgov-root *::after{box-sizing:inherit}\n.cgov-card{background:var(--cgov-surface);border:2px solid var(--cgov-border);border-radius:var(--cgov-radius);box-shadow:var(--cgov-shadow)}\n.cgov-btn{display:inline-flex;align-items:center;gap:.5em;font:inherit;font-weight:600;cursor:pointer;border:2px solid var(--cgov-border);border-radius:calc(var(--cgov-radius) * .75);padding:.5em 1em;background:var(--cgov-surface);color:var(--cgov-text);transition:transform .06s ease}\n.cgov-btn:hover:not(:disabled){transform:translate(-1px,-1px)}\n.cgov-btn:active:not(:disabled){transform:translate(1px,1px)}\n.cgov-btn:disabled{opacity:.5;cursor:not-allowed}\n.cgov-btn-primary{background:var(--cgov-accent);color:var(--cgov-accent-text)}\n.cgov-btn-sm{font-size:.8125rem;padding:.35em .8em}\n.cgov-input,.cgov-select{font:inherit;width:100%;padding:.5em .75em;border:2px solid var(--cgov-border);border-radius:calc(var(--cgov-radius) * .6);background:var(--cgov-surface-muted);color:var(--cgov-text)}\n.cgov-input:focus,.cgov-select:focus{outline:3px solid color-mix(in srgb, var(--cgov-accent) 40%, transparent);outline-offset:1px}\n.cgov-label{display:block;font-size:.8125rem;font-weight:600;margin:0 0 .3em}\n.cgov-help{font-size:.75rem;color:var(--cgov-text-muted);margin:.25em 0 0}\n.cgov-field{margin-bottom:.9rem}\n.cgov-field-error{font-size:.75rem;color:var(--cgov-danger);margin:.25em 0 0}\n.cgov-overlay{position:fixed;inset:0;background:rgba(0,0,0,.45);display:flex;align-items:flex-end;justify-content:center;z-index:2147483000;padding:1rem}\n@media (min-width:640px){.cgov-overlay{align-items:center}}\n.cgov-dialog{width:100%;max-width:28rem;max-height:calc(100vh - 2rem);overflow-y:auto;padding:1.25rem}\n.cgov-dialog-title{font-size:1.05rem;font-weight:700;margin:0 0 .25rem}\n.cgov-dialog-desc{font-size:.8125rem;color:var(--cgov-text-muted);margin:0 0 1rem}\n.cgov-preview{background:var(--cgov-surface-muted);border:2px dashed var(--cgov-border);border-radius:calc(var(--cgov-radius) * .6);padding:.75rem;margin:.25rem 0 1rem}\n.cgov-preview-title{font-weight:700;font-size:.9375rem;margin:0}\n.cgov-preview-rule{font-size:.75rem;color:var(--cgov-text-muted);margin:.35em 0 0}\n.cgov-preview-call{font-family:ui-monospace,monospace;font-size:.6875rem;color:var(--cgov-text-muted);margin:.35em 0 0;word-break:break-all}\n.cgov-tabs{display:flex;gap:.4rem;flex-wrap:wrap;margin:0 0 1rem}\n.cgov-tab{font:inherit;font-size:.8125rem;font-weight:600;padding:.35em .8em;cursor:pointer;border:2px solid var(--cgov-border);border-radius:999px;background:var(--cgov-surface)}\n.cgov-tab[aria-selected=\"true\"]{background:var(--cgov-accent);color:var(--cgov-accent-text)}\n.cgov-row{display:flex;align-items:center;gap:.75rem;padding:.75rem;border-bottom:2px solid color-mix(in srgb, var(--cgov-border) 15%, transparent)}\n.cgov-row:last-child{border-bottom:none}\n.cgov-row-main{flex:1;min-width:0}\n.cgov-row-title{font-weight:600;font-size:.9375rem;margin:0;overflow:hidden;text-overflow:ellipsis}\n.cgov-row-sub{font-size:.75rem;color:var(--cgov-text-muted);margin:.15em 0 0;display:flex;gap:.5em;align-items:center;flex-wrap:wrap}\n.cgov-chip{display:inline-block;font-size:.6875rem;font-weight:700;padding:.15em .6em;border:1.5px solid var(--cgov-border);border-radius:999px;background:var(--cgov-surface-muted)}\n.cgov-chip-success{background:color-mix(in srgb, var(--cgov-success) 18%, transparent)}\n.cgov-chip-accent{background:color-mix(in srgb, var(--cgov-accent) 18%, transparent)}\n.cgov-empty{padding:1.5rem;text-align:center;color:var(--cgov-text-muted);font-size:.875rem}\n.cgov-error{padding:.6rem .75rem;border:2px solid var(--cgov-danger);border-radius:calc(var(--cgov-radius) * .6);background:color-mix(in srgb, var(--cgov-danger) 8%, transparent);color:var(--cgov-danger);font-size:.8125rem;margin:.5rem 0}\n.cgov-group-label{font-size:.75rem;font-weight:700;text-transform:uppercase;letter-spacing:.04em;color:var(--cgov-text-muted);margin:1rem 0 .35rem;padding:0 .25rem}\n.cgov-group-label:first-child{margin-top:0}\n.cgov-spinner{display:inline-block;width:.9em;height:.9em;border:2px solid currentColor;border-right-color:transparent;border-radius:50%;animation:cgov-spin .7s linear infinite}\n@keyframes cgov-spin{to{transform:rotate(360deg)}}\n`;\n\n/** The slice of `document` we need — structural so the repo's node-globals\n * eslint env (no DOM lib identifiers) stays clean. */\ninterface DocumentLike {\n getElementById(id: string): unknown;\n createElement(tag: \"style\"): { id: string; textContent: string | null };\n head: { appendChild(node: unknown): void };\n}\n\n/** Idempotently inject the component stylesheet into the document head. */\nexport function injectGovStyles(): void {\n // Via globalThis so this stays SSR-safe AND lint-clean (no bare\n // `document` identifier under the node eslint env).\n const doc = (globalThis as { document?: DocumentLike }).document;\n if (!doc) return; // SSR — inject on the client\n if (doc.getElementById(STYLE_ID)) return;\n const el = doc.createElement(\"style\");\n el.id = STYLE_ID;\n el.textContent = STYLE_TEXT;\n doc.head.appendChild(el);\n}\n","\"use client\";\n\n/**\n * One typed input for an {@link FieldSpec} — the rendering half of the\n * template engine. Values stay RAW STRINGS in form state; the template's\n * own `toCalls`/`title` do the semantic conversion (amountToBase / u256 /\n * toFelt), so the proposer's preview and the executor's rebuild share one\n * conversion path. Per-field validation here is the friendly first line\n * (\"must be a 0x address\"), not the source of truth.\n */\nimport React from \"react\";\nimport type { FieldSpec } from \"../action-template\";\n\n/** Light per-type syntax check; returns a human error or null. */\nexport function fieldSyntaxError(field: FieldSpec, raw: string): string | null {\n if (raw.trim() === \"\") return `${field.label} is required`;\n const v = raw.trim();\n switch (field.type) {\n case \"address\":\n return /^0x[0-9a-fA-F]{1,64}$/.test(v) ? null : `${field.label} must be a 0x address`;\n case \"felt\":\n return /^(0x[0-9a-fA-F]+|\\d+)$/.test(v)\n ? null\n : `${field.label} must be a felt (0x-hex or decimal)`;\n case \"amount\":\n return /^\\d+(\\.\\d+)?$/.test(v) ? null : `${field.label} must be a positive amount`;\n case \"number\":\n case \"bps\":\n case \"days\":\n return /^\\d+$/.test(v) ? null : `${field.label} must be a whole number`;\n default:\n return null;\n }\n}\n\nexport function FieldInput(props: {\n field: FieldSpec;\n value: string;\n onChange: (raw: string) => void;\n /** Shown once the user has touched the field. */\n error?: string | null;\n disabled?: boolean;\n}) {\n const { field, value, onChange, error, disabled } = props;\n const id = `cgov-field-${field.name}`;\n return (\n <div className=\"cgov-field\">\n <label className=\"cgov-label\" htmlFor={id}>\n {field.label}\n </label>\n {field.type === \"select\" ? (\n <select\n id={id}\n className=\"cgov-select\"\n value={value}\n disabled={disabled}\n onChange={(e) => onChange(e.target.value)}\n >\n <option value=\"\" disabled>\n Choose…\n </option>\n {field.options.map((o) => (\n <option key={o.value} value={o.value}>\n {o.label}\n </option>\n ))}\n </select>\n ) : (\n <input\n id={id}\n className=\"cgov-input\"\n value={value}\n disabled={disabled}\n inputMode={\n field.type === \"amount\" ||\n field.type === \"number\" ||\n field.type === \"bps\" ||\n field.type === \"days\"\n ? \"decimal\"\n : \"text\"\n }\n placeholder={\n field.type === \"address\" ? \"0x…\" : field.type === \"amount\" ? \"0.00\" : undefined\n }\n onChange={(e) => onChange(e.target.value)}\n />\n )}\n {\"help\" in field && field.help ? <p className=\"cgov-help\">{field.help}</p> : null}\n {error ? <p className=\"cgov-field-error\">{error}</p> : null}\n </div>\n );\n}\n","\"use client\";\n\n/**\n * `<ProposeAction>` — the embeddable propose dialog (design brief §4).\n *\n * Template-driven: renders the selected {@link ActionTemplate}'s fields as\n * typed inputs, shows a live \"What this does\" card (the template's plain-\n * language `title`, the exact encoded call list, and the approval rule),\n * then signs + proposes through the injected signer/transport on submit.\n * No OE building, SNIP-12, or signature plumbing in the host app.\n *\n * Intentionally dependency-free UI (no portal/animation libs): a fixed\n * overlay + card styled by the namespaced stylesheet, themeable via the\n * `theme` tokens. Mobile-first (bottom-sheet under 640px).\n */\nimport React, { useEffect, useMemo, useState } from \"react\";\nimport type { ActionTemplate, CallSpec } from \"../action-template\";\nimport type { MultisigSigner, MultisigTransport, TreasuryProposal } from \"../types\";\nimport { useProposeAction } from \"../use-hooks\";\nimport { type ChipiGovTheme, injectGovStyles, themeVars } from \"./theme\";\nimport { FieldInput, fieldSyntaxError } from \"./field-input\";\n\nexport interface ProposeActionProps {\n /** The treasury's SHHH wallet address. */\n walletAddress: string;\n /** Action templates the proposer can pick from (`defineActions(...)`). */\n actions: ActionTemplate<any>[];\n transport: MultisigTransport;\n signer: MultisigSigner;\n /** Read the wallet's current threshold (host-supplied; chain read). */\n getRequiredApprovals: () => Promise<number>;\n /** Preselect a template by key (also hides the tabs when it's the only one). */\n preselect?: string;\n /** Custom trigger; receives the open callback. Defaults to a button. */\n trigger?: (open: () => void) => React.ReactNode;\n theme?: ChipiGovTheme;\n onProposed?: (proposal: TreasuryProposal) => void;\n chainId?: string;\n}\n\n/** Compute the live preview, or the reason it can't be built yet. */\nfunction buildPreview(\n template: ActionTemplate<any>,\n values: Record<string, string>\n): { title: string; calls: CallSpec[] } | { error: string } {\n for (const f of template.fields) {\n const err = fieldSyntaxError(f, values[f.name] ?? \"\");\n if (err) return { error: err };\n }\n try {\n return { title: template.title(values), calls: template.toCalls(values) };\n } catch (e) {\n return { error: e instanceof Error ? e.message : \"Invalid values\" };\n }\n}\n\nexport function ProposeAction(props: ProposeActionProps) {\n const [open, setOpen] = useState(false);\n const [templateKey, setTemplateKey] = useState(props.preselect ?? props.actions[0]?.key ?? \"\");\n const [values, setValues] = useState<Record<string, string>>({});\n const [touched, setTouched] = useState<Record<string, boolean>>({});\n const [requiredApprovals, setRequiredApprovals] = useState<number | null>(null);\n const [done, setDone] = useState<TreasuryProposal | null>(null);\n\n useEffect(injectGovStyles, []);\n\n const template = props.actions.find((t) => t.key === templateKey) ?? props.actions[0];\n\n const propose = useProposeAction({\n walletAddress: props.walletAddress,\n transport: props.transport,\n signer: props.signer,\n getRequiredApprovals: props.getRequiredApprovals,\n chainId: props.chainId,\n });\n\n // Approval rule for the preview card — best-effort (the propose flow\n // re-reads it authoritatively at submit).\n useEffect(() => {\n if (!open) return;\n let on = true;\n props.getRequiredApprovals().then(\n (n) => on && setRequiredApprovals(n),\n () => on && setRequiredApprovals(null)\n );\n return () => {\n on = false;\n };\n }, [open]);\n\n const preview = useMemo(\n () => (template ? buildPreview(template, values) : { error: \"No action templates\" }),\n [template, values]\n );\n\n const reset = () => {\n setValues({});\n setTouched({});\n setDone(null);\n propose.reset();\n };\n const close = () => {\n setOpen(false);\n reset();\n };\n\n const submit = async () => {\n if (!template || \"error\" in preview) return;\n try {\n const proposal = await propose.mutateAsync({ template, values });\n setDone(proposal);\n props.onProposed?.(proposal);\n } catch {\n /* surfaced via propose.error below */\n }\n };\n\n return (\n <div className=\"cgov-root\" style={themeVars(props.theme) as React.CSSProperties}>\n {props.trigger ? (\n props.trigger(() => setOpen(true))\n ) : (\n <button type=\"button\" className=\"cgov-btn cgov-btn-primary\" onClick={() => setOpen(true)}>\n Propose action\n </button>\n )}\n\n {open ? (\n <div className=\"cgov-overlay\" role=\"presentation\" onClick={close}>\n <div\n className=\"cgov-card cgov-dialog cgov-root\"\n style={themeVars(props.theme) as React.CSSProperties}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label={done ? \"Proposal created\" : \"Propose an action\"}\n onClick={(e) => e.stopPropagation()}\n >\n {done ? (\n <>\n <h2 className=\"cgov-dialog-title\">Proposed ✓</h2>\n <p className=\"cgov-dialog-desc\">\n {done.title ?? \"Your action\"} —{\" \"}\n {done.status === \"APPROVED\"\n ? \"approved and ready to execute.\"\n : `needs ${done.requiredApprovals} approval${done.requiredApprovals === 1 ? \"\" : \"s\"}.`}\n </p>\n <button type=\"button\" className=\"cgov-btn cgov-btn-primary\" onClick={close}>\n Done\n </button>\n </>\n ) : (\n <>\n <h2 className=\"cgov-dialog-title\">Propose an action</h2>\n <p className=\"cgov-dialog-desc\">\n Your team approves before anything moves on chain.\n </p>\n\n {props.actions.length > 1 ? (\n <div className=\"cgov-tabs\" role=\"tablist\" aria-label=\"Action type\">\n {props.actions.map((t) => (\n <button\n key={t.key}\n type=\"button\"\n role=\"tab\"\n aria-selected={t.key === template?.key}\n className=\"cgov-tab\"\n onClick={() => {\n setTemplateKey(t.key);\n reset();\n }}\n >\n {t.label}\n </button>\n ))}\n </div>\n ) : null}\n\n {template?.description ? (\n <p className=\"cgov-help\" style={{ marginBottom: \"0.9rem\" }}>\n {template.description}\n </p>\n ) : null}\n\n {template?.fields.map((f) => (\n <FieldInput\n key={f.name}\n field={f}\n value={values[f.name] ?? \"\"}\n disabled={propose.isPending}\n error={touched[f.name] ? fieldSyntaxError(f, values[f.name] ?? \"\") : null}\n onChange={(raw) => {\n setValues((v) => ({ ...v, [f.name]: raw }));\n setTouched((t) => ({ ...t, [f.name]: true }));\n }}\n />\n ))}\n\n <div className=\"cgov-preview\" aria-live=\"polite\">\n {\"error\" in preview ? (\n <p className=\"cgov-preview-rule\">What this does — fill in the fields above.</p>\n ) : (\n <>\n <p className=\"cgov-preview-title\">{preview.title}</p>\n {preview.calls.map((c, i) => (\n <p key={i} className=\"cgov-preview-call\">\n {c.entrypoint}({c.calldata.join(\", \")}) → {c.to.slice(0, 10)}…\n </p>\n ))}\n <p className=\"cgov-preview-rule\">\n {requiredApprovals != null\n ? `Needs ${requiredApprovals} approval${requiredApprovals === 1 ? \"\" : \"s\"} before it executes.`\n : \"Approval rule loads from your wallet.\"}\n </p>\n </>\n )}\n </div>\n\n {propose.error ? (\n <div className=\"cgov-error\" role=\"alert\">\n {propose.error instanceof Error\n ? propose.error.message\n : \"Could not create the proposal. Try again.\"}\n </div>\n ) : null}\n\n <div style={{ display: \"flex\", gap: \"0.5rem\", justifyContent: \"flex-end\" }}>\n <button\n type=\"button\"\n className=\"cgov-btn\"\n onClick={close}\n disabled={propose.isPending}\n >\n Cancel\n </button>\n <button\n type=\"button\"\n className=\"cgov-btn cgov-btn-primary\"\n disabled={\"error\" in preview || propose.isPending}\n onClick={submit}\n >\n {propose.isPending ? (\n <>\n <span className=\"cgov-spinner\" aria-hidden /> Signing…\n </>\n ) : (\n \"Sign & propose\"\n )}\n </button>\n </div>\n </>\n )}\n </div>\n </div>\n ) : null}\n </div>\n );\n}\n","\"use client\";\n\n/**\n * `<Approvals>` — the embeddable approvals list (design brief §4).\n *\n * Pending + recent proposals for one treasury with Approve / Execute, built\n * on {@link useTreasuryProposals}. The `renderContext` slot injects the\n * integrator's business data per row (read back from the proposal's `meta`)\n * — Chipi's rails stay domain-agnostic; the host app supplies meaning.\n *\n * Action rules (mirrors the coordination backend's state machine):\n * PROPOSED + I haven't signed → Approve (one signer prompt)\n * APPROVED → Execute (relayed via the host transport)\n * EXECUTED / CANCELED / EXPIRED → terminal chips (receipt link if known)\n */\nimport React, { useEffect, useState } from \"react\";\nimport type { MultisigSigner, MultisigTransport, TreasuryProposal } from \"../types\";\nimport { useTreasuryProposals } from \"../use-hooks\";\nimport { type ChipiGovTheme, injectGovStyles, themeVars } from \"./theme\";\n\nexport type ApprovalsFilter = \"actionable\" | \"pending\" | \"all\";\n\nexport interface ApprovalsProps {\n /** The treasury's SHHH wallet address. */\n walletAddress: string;\n transport: MultisigTransport;\n signer: MultisigSigner;\n /** Inject business context per row (reads `proposal.meta`). */\n renderContext?: (proposal: TreasuryProposal) => React.ReactNode;\n /** actionable = needs me or ready; pending = not terminal; all. Default actionable. */\n filter?: ApprovalsFilter;\n theme?: ChipiGovTheme;\n onExecuted?: (proposal: TreasuryProposal, txHash?: string) => void;\n /** Custom empty state. */\n empty?: React.ReactNode;\n /** Build an explorer URL for an executed tx hash (row link). */\n explorerTxUrl?: (txHash: string) => string;\n /**\n * Mark a proposal as filed by an AI agent (governance §9). When this\n * returns true, the row reads \"{agentLabel} wants: {title}\" with an\n * Agent chip — the founder-facing \"your agent wants…\" copy. The host\n * decides agent-ness (it knows which owner index is its agent); the\n * package stays chain-read-free.\n */\n isAgentProposal?: (proposal: TreasuryProposal) => boolean;\n /** Label for agent rows (default \"Agent\"). */\n agentLabel?: string;\n}\n\nconst STATUS_LABEL: Record<TreasuryProposal[\"status\"], string> = {\n PROPOSED: \"Needs approvals\",\n APPROVED: \"Ready to execute\",\n EXECUTED: \"Executed\",\n CANCELED: \"Canceled\",\n EXPIRED: \"Expired\",\n};\n\n/** Human fallback title for legacy payment proposals without `title`. */\nexport function proposalTitle(p: TreasuryProposal): string {\n return p.title?.trim() || \"Treasury action\";\n}\n\nfunction ProposalRow(props: {\n proposal: TreasuryProposal;\n myOwnerIndex: number | null;\n busy: boolean;\n onApprove: (p: TreasuryProposal) => void;\n onExecute: (p: TreasuryProposal) => void;\n renderContext?: ApprovalsProps[\"renderContext\"];\n explorerTxUrl?: ApprovalsProps[\"explorerTxUrl\"];\n isAgent?: boolean;\n agentLabel?: string;\n}) {\n const p = props.proposal;\n const signed =\n props.myOwnerIndex != null && p.signatures.some((s) => s.ownerId === props.myOwnerIndex);\n const canApprove = p.status === \"PROPOSED\" && props.myOwnerIndex != null && !signed;\n const canExecute = p.status === \"APPROVED\";\n const label = props.agentLabel ?? \"Agent\";\n // \"your agent wants…\" framing for an agent's escalated proposal.\n const title = props.isAgent ? `${label} wants: ${proposalTitle(p)}` : proposalTitle(p);\n return (\n <div className=\"cgov-row\">\n <div className=\"cgov-row-main\">\n <p className=\"cgov-row-title\">{title}</p>\n <div className=\"cgov-row-sub\">\n {props.isAgent ? <span className=\"cgov-chip cgov-chip-accent\">{label}</span> : null}\n <span\n className={`cgov-chip${p.status === \"EXECUTED\" ? \" cgov-chip-success\" : p.status === \"APPROVED\" ? \" cgov-chip-accent\" : \"\"}`}\n >\n {STATUS_LABEL[p.status]}\n </span>\n <span>\n {p.signatures.length} of {p.requiredApprovals} approvals\n </span>\n {p.risk === \"SENSITIVE\" ? <span className=\"cgov-chip\">Sensitive</span> : null}\n {signed && p.status === \"PROPOSED\" ? <span>· you approved</span> : null}\n {p.status === \"EXECUTED\" && p.executedTxHash && props.explorerTxUrl ? (\n <a\n href={props.explorerTxUrl(p.executedTxHash)}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n receipt ↗\n </a>\n ) : null}\n {props.renderContext ? <span>{props.renderContext(p)}</span> : null}\n </div>\n </div>\n {canApprove ? (\n <button\n type=\"button\"\n className=\"cgov-btn cgov-btn-primary cgov-btn-sm\"\n disabled={props.busy}\n onClick={() => props.onApprove(p)}\n >\n Approve\n </button>\n ) : canExecute ? (\n <button\n type=\"button\"\n className=\"cgov-btn cgov-btn-primary cgov-btn-sm\"\n disabled={props.busy}\n onClick={() => props.onExecute(p)}\n >\n Execute\n </button>\n ) : null}\n </div>\n );\n}\n\nexport function Approvals(props: ApprovalsProps) {\n const filter = props.filter ?? \"actionable\";\n const [myOwnerIndex, setMyOwnerIndex] = useState<number | null>(null);\n const [actionError, setActionError] = useState<string | null>(null);\n\n useEffect(injectGovStyles, []);\n\n // Resolve this device's owner index once — Approve needs to know whether\n // I already signed, and which index to sign as.\n useEffect(() => {\n let on = true;\n props.signer.resolveOwnerIndex(props.walletAddress).then(\n (i) => on && setMyOwnerIndex(i),\n () => on && setMyOwnerIndex(null) // not an owner on this device → read-only\n );\n return () => {\n on = false;\n };\n }, [props.walletAddress]);\n\n const { proposals, approve, execute } = useTreasuryProposals({\n walletAddress: props.walletAddress,\n transport: props.transport,\n signer: props.signer,\n });\n\n const busy = approve.isPending || execute.isPending;\n\n const onApprove = async (p: TreasuryProposal) => {\n setActionError(null);\n try {\n await approve.mutateAsync(p);\n } catch (e) {\n setActionError(e instanceof Error ? e.message : \"Could not approve. Try again.\");\n }\n };\n const onExecute = async (p: TreasuryProposal) => {\n setActionError(null);\n try {\n const res = await execute.mutateAsync(p);\n props.onExecuted?.(p, res.executedTxHash ?? res.transactionHash);\n } catch (e) {\n setActionError(e instanceof Error ? e.message : \"Could not execute. Try again.\");\n }\n };\n\n const items = (proposals.data?.items ?? []).filter((p) => {\n if (filter === \"all\") return true;\n if (filter === \"pending\") return p.status === \"PROPOSED\" || p.status === \"APPROVED\";\n // actionable: ready to execute, or awaiting an approval I can give\n return (\n p.status === \"APPROVED\" ||\n (p.status === \"PROPOSED\" &&\n (myOwnerIndex == null || !p.signatures.some((s) => s.ownerId === myOwnerIndex)))\n );\n });\n\n return (\n <div className=\"cgov-root\" style={themeVars(props.theme) as React.CSSProperties}>\n <div className=\"cgov-card\">\n {proposals.isLoading ? (\n <div className=\"cgov-empty\">\n <span className=\"cgov-spinner\" aria-hidden /> Loading…\n </div>\n ) : proposals.error ? (\n <div className=\"cgov-empty\">Could not load proposals.</div>\n ) : items.length === 0 ? (\n <div className=\"cgov-empty\">{props.empty ?? \"You're all caught up.\"}</div>\n ) : (\n items.map((p) => (\n <ProposalRow\n key={p.id}\n proposal={p}\n myOwnerIndex={myOwnerIndex}\n busy={busy}\n onApprove={onApprove}\n onExecute={onExecute}\n renderContext={props.renderContext}\n explorerTxUrl={props.explorerTxUrl}\n isAgent={props.isAgentProposal?.(p) ?? false}\n agentLabel={props.agentLabel}\n />\n ))\n )}\n </div>\n {actionError ? (\n <div className=\"cgov-error\" role=\"alert\">\n {actionError}\n </div>\n ) : null}\n </div>\n );\n}\n","\"use client\";\n\n/**\n * `<ApprovalInbox>` — the founder surface (design brief §4): cross-treasury\n * \"what needs me\", grouped by treasury, one-tap approve. Mobile-first — this\n * is the component a CEO opens on their phone.\n *\n * v1 aggregates CLIENT-SIDE over the treasuries the host wires in (each with\n * its own transport+signer — reads are sk_-gated per decision §11.3, so the\n * host's backend mediates them anyway). A server-side cross-treasury feed is\n * a later optimization, not a blocker: inboxes have a handful of treasuries.\n */\nimport React, { useEffect } from \"react\";\nimport type { TreasuryProposal } from \"../types\";\nimport { Approvals, type ApprovalsProps } from \"./approvals\";\nimport { type ChipiGovTheme, injectGovStyles, themeVars } from \"./theme\";\n\nexport interface InboxTreasury\n extends Pick<\n ApprovalsProps,\n | \"walletAddress\"\n | \"transport\"\n | \"signer\"\n | \"renderContext\"\n | \"explorerTxUrl\"\n | \"isAgentProposal\"\n | \"agentLabel\"\n > {\n /** Group heading (\"Ops treasury\", \"Acme · Pool fund\"). */\n label: string;\n}\n\nexport interface ApprovalInboxProps {\n treasuries: InboxTreasury[];\n theme?: ChipiGovTheme;\n /** Shown when every treasury is caught up. */\n onEmpty?: React.ReactNode;\n onExecuted?: (treasury: InboxTreasury, proposal: TreasuryProposal, txHash?: string) => void;\n}\n\nexport function ApprovalInbox(props: ApprovalInboxProps) {\n useEffect(injectGovStyles, []);\n return (\n <div className=\"cgov-root\" style={themeVars(props.theme) as React.CSSProperties}>\n {props.treasuries.map((t) => (\n <section key={t.walletAddress} aria-label={t.label}>\n <p className=\"cgov-group-label\">{t.label}</p>\n <Approvals\n walletAddress={t.walletAddress}\n transport={t.transport}\n signer={t.signer}\n renderContext={t.renderContext}\n explorerTxUrl={t.explorerTxUrl}\n isAgentProposal={t.isAgentProposal}\n agentLabel={t.agentLabel}\n filter=\"actionable\"\n theme={props.theme}\n empty={props.onEmpty ?? \"All caught up.\"}\n onExecuted={(p, tx) => props.onExecuted?.(t, p, tx)}\n />\n </section>\n ))}\n </div>\n );\n}\n"]}
|