@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,482 @@
|
|
|
1
|
+
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Framework-agnostic action-template engine for SHHH multisig governance.
|
|
7
|
+
*
|
|
8
|
+
* An {@link ActionTemplate} maps friendly, typed form fields → an
|
|
9
|
+
* OutsideExecution call list + a human-readable title. It's the seam that
|
|
10
|
+
* turns "call any contract" (powerful, scary) into "fill in this form"
|
|
11
|
+
* (founder-grade) — and the whitelabel seam: every integrator registers
|
|
12
|
+
* its own templates (Roca: create_pool / borrow / repay), while `Vote`
|
|
13
|
+
* ships built-in. The raw-call escape hatch lives in the UI layer, not
|
|
14
|
+
* here, because its arguments are open-ended.
|
|
15
|
+
*
|
|
16
|
+
* Pure: no React, no network — so the same template renders the proposer's
|
|
17
|
+
* form, every approver's inbox, and the notification, from one source of
|
|
18
|
+
* truth, and `toCalls` is deterministic (proposer and executor build the
|
|
19
|
+
* identical OE → the hash matches).
|
|
20
|
+
*/
|
|
21
|
+
type FeltLike = string | number | bigint;
|
|
22
|
+
/** One call in an action — the shape the OE builder consumes. */
|
|
23
|
+
interface CallSpec {
|
|
24
|
+
to: string;
|
|
25
|
+
entrypoint: string;
|
|
26
|
+
/** Flat 0x-hex felts. */
|
|
27
|
+
calldata: string[];
|
|
28
|
+
}
|
|
29
|
+
/** A typed input in an action template. */
|
|
30
|
+
type FieldSpec = {
|
|
31
|
+
name: string;
|
|
32
|
+
label: string;
|
|
33
|
+
type: "amount";
|
|
34
|
+
decimals: number;
|
|
35
|
+
help?: string;
|
|
36
|
+
} | {
|
|
37
|
+
name: string;
|
|
38
|
+
label: string;
|
|
39
|
+
type: "address";
|
|
40
|
+
help?: string;
|
|
41
|
+
} | {
|
|
42
|
+
name: string;
|
|
43
|
+
label: string;
|
|
44
|
+
type: "number" | "bps" | "days" | "felt";
|
|
45
|
+
help?: string;
|
|
46
|
+
} | {
|
|
47
|
+
name: string;
|
|
48
|
+
label: string;
|
|
49
|
+
type: "select";
|
|
50
|
+
options: {
|
|
51
|
+
label: string;
|
|
52
|
+
value: string;
|
|
53
|
+
}[];
|
|
54
|
+
help?: string;
|
|
55
|
+
} | {
|
|
56
|
+
name: string;
|
|
57
|
+
label: string;
|
|
58
|
+
type: "text";
|
|
59
|
+
help?: string;
|
|
60
|
+
};
|
|
61
|
+
interface ActionTemplate<V = Record<string, unknown>> {
|
|
62
|
+
/** Stable id, persisted on the proposal. */
|
|
63
|
+
key: string;
|
|
64
|
+
/** Display label ("Create pool"). */
|
|
65
|
+
label: string;
|
|
66
|
+
description?: string;
|
|
67
|
+
/** Typed inputs rendered by `<ProposeAction>`. */
|
|
68
|
+
fields: FieldSpec[];
|
|
69
|
+
/** Pure: validated field values → the OE call list. */
|
|
70
|
+
toCalls: (v: V) => CallSpec[];
|
|
71
|
+
/** Pure: the plain-language title shown in the preview, inbox, and email. */
|
|
72
|
+
title: (v: V) => string;
|
|
73
|
+
/** Optional metadata persisted with the proposal so the approver's app
|
|
74
|
+
* can render business context (e.g. `{ poolId }`). */
|
|
75
|
+
meta?: (v: V) => Record<string, string | number>;
|
|
76
|
+
/** App-level risk tier (decision §11.4). When the treasury configured the
|
|
77
|
+
* matching quorum, the backend OVERRIDES requiredApprovals at propose
|
|
78
|
+
* (ROUTINE → routineQuorum, SENSITIVE → sensitiveQuorum). App-enforced
|
|
79
|
+
* for human treasuries — the on-chain wallet threshold stays the hard
|
|
80
|
+
* floor at execute. Omit = no tier (the client's value is used). */
|
|
81
|
+
risk?: "ROUTINE" | "SENSITIVE";
|
|
82
|
+
}
|
|
83
|
+
/** Starknet felt252 field prime — args must be a non-negative felt below it. */
|
|
84
|
+
declare const FELT_PRIME: bigint;
|
|
85
|
+
/** Parse a decimal or 0x-hex value to a canonical `0x` felt. Throws on a
|
|
86
|
+
* non-numeric or out-of-range value. */
|
|
87
|
+
declare function toFelt(v: FeltLike): string;
|
|
88
|
+
/** Split a u256 value into its `[low, high]` felts (Cairo calling convention). */
|
|
89
|
+
declare function u256(v: FeltLike): [string, string];
|
|
90
|
+
/** Convert a human amount ("10.5") to base units given a token's decimals. */
|
|
91
|
+
declare function amountToBase(amount: string, decimals: number): bigint;
|
|
92
|
+
/**
|
|
93
|
+
* Identity + light validation for a template registry: keys are present
|
|
94
|
+
* and unique. Returns the same array (typed) so call sites keep inference.
|
|
95
|
+
*/
|
|
96
|
+
declare function defineActions<T extends ActionTemplate<any>[]>(templates: [...T]): [...T];
|
|
97
|
+
interface VoteValues {
|
|
98
|
+
contract: string;
|
|
99
|
+
proposalId: string;
|
|
100
|
+
choice: string;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Built-in `Vote` template — `vote(proposalId, choice)` on a governance
|
|
104
|
+
* contract. Pin the contract and/or entrypoint up front (then they drop
|
|
105
|
+
* out of the form), or leave them for the proposer to fill.
|
|
106
|
+
*/
|
|
107
|
+
declare function voteTemplate(opts?: {
|
|
108
|
+
governanceContract?: string;
|
|
109
|
+
entrypoint?: string;
|
|
110
|
+
}): ActionTemplate<VoteValues>;
|
|
111
|
+
|
|
112
|
+
/** shortString.encodeShortString("SN_MAIN") — Starknet mainnet. */
|
|
113
|
+
declare const SN_MAIN_CHAIN_ID = "0x534e5f4d41494e";
|
|
114
|
+
/**
|
|
115
|
+
* Max on-chain OE validity window (`executeBefore - executeAfter`), capped
|
|
116
|
+
* by the SHHH contract audit (M-2). This is the longest a proposal stays
|
|
117
|
+
* EXECUTABLE — distinct from how long its record lives in the coordination
|
|
118
|
+
* backend. NOTE: with `executeAfter` pinned to 0 the window would be the
|
|
119
|
+
* whole epoch and the contract rejects it, so `executeAfter` is set to ~now
|
|
120
|
+
* and persisted alongside the nonce + `executeBefore`.
|
|
121
|
+
*/
|
|
122
|
+
declare const OE_WINDOW_SECONDS: number;
|
|
123
|
+
/**
|
|
124
|
+
* Signs an OE message hash for one owner → that owner's inner V2_SNIP12
|
|
125
|
+
* envelope (an array of felts). Implementations wrap a passkey / MetaMask /
|
|
126
|
+
* Phantom / STARK signer; the private key never leaves the implementation.
|
|
127
|
+
*/
|
|
128
|
+
type OeSigner = (params: {
|
|
129
|
+
messageHash: bigint;
|
|
130
|
+
ownerIndex: bigint;
|
|
131
|
+
}) => Promise<bigint[]> | bigint[];
|
|
132
|
+
/** Serialize an inner envelope (felt[]) to the comma-joined 0x-hex string
|
|
133
|
+
* the coordination backend stores per signature. */
|
|
134
|
+
declare function serializeEnvelope(env: bigint[]): string;
|
|
135
|
+
declare function deserializeEnvelope(s: string): bigint[];
|
|
136
|
+
/**
|
|
137
|
+
* OE replay nonce: ms timestamp shifted left 24 bits, ORed with a 24-bit
|
|
138
|
+
* random suffix. `nowMs`/`rand` are injectable for deterministic tests.
|
|
139
|
+
*/
|
|
140
|
+
declare function newOeNonce(nowMs: number, rand: number): bigint;
|
|
141
|
+
interface ActionProposal {
|
|
142
|
+
oeMessageHash: string;
|
|
143
|
+
oeNonce: string;
|
|
144
|
+
oeExecuteBefore: string;
|
|
145
|
+
/** The proposer's inner V2_SNIP12 envelope, comma-joined 0x-hex. */
|
|
146
|
+
proposerSignature: string;
|
|
147
|
+
}
|
|
148
|
+
/** Derive the OE's executeAfter from its persisted executeBefore. The
|
|
149
|
+
* window is a fixed constant (the contract cap), so the executor needs
|
|
150
|
+
* only executeBefore to reconstruct the exact signed OE — no separate
|
|
151
|
+
* executeAfter persistence (and no backend column). */
|
|
152
|
+
declare function deriveExecuteAfter(oeExecuteBefore: string): bigint;
|
|
153
|
+
/**
|
|
154
|
+
* Build an OE over `calls`, sign it as the proposer (owner 0 by default),
|
|
155
|
+
* and return everything a propose endpoint needs. The OE params (nonce +
|
|
156
|
+
* executeBefore) are returned; executeAfter is `executeBefore - OE_WINDOW`,
|
|
157
|
+
* so only executeBefore needs persisting. The window is the contract cap
|
|
158
|
+
* (the longest executable window M-2 allows).
|
|
159
|
+
*/
|
|
160
|
+
declare function buildActionProposal(params: {
|
|
161
|
+
walletAddress: string;
|
|
162
|
+
calls: CallSpec[];
|
|
163
|
+
sign: OeSigner;
|
|
164
|
+
ownerIndex?: bigint;
|
|
165
|
+
chainId?: string;
|
|
166
|
+
nowMs?: number;
|
|
167
|
+
rand?: number;
|
|
168
|
+
}): Promise<ActionProposal>;
|
|
169
|
+
/** Sign an existing proposal's OE hash as an approver → inner envelope string. */
|
|
170
|
+
declare function signActionApproval(params: {
|
|
171
|
+
oeMessageHash: string;
|
|
172
|
+
ownerIndex: bigint;
|
|
173
|
+
sign: OeSigner;
|
|
174
|
+
}): Promise<string>;
|
|
175
|
+
/**
|
|
176
|
+
* Rebuild the exact OE from the persisted params + collected signatures and
|
|
177
|
+
* serialize the `execute` calldata. A 1-of-N wallet uses the single inner
|
|
178
|
+
* envelope; N≥2 wraps the inner envelopes in a V2_THRESHOLD envelope.
|
|
179
|
+
*/
|
|
180
|
+
declare function assembleActionExecuteCalldata(params: {
|
|
181
|
+
calls: CallSpec[];
|
|
182
|
+
oeNonce: string;
|
|
183
|
+
oeExecuteBefore: string;
|
|
184
|
+
signatures: string[];
|
|
185
|
+
requiredApprovals: number;
|
|
186
|
+
}): string[];
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Injectable boundaries for the multisig governance hooks. The package owns
|
|
190
|
+
* the OE crypto + template engine + orchestration; the host supplies the
|
|
191
|
+
* transport (an authed coordination backend) and the signer (a per-owner
|
|
192
|
+
* OE signer + owner-index resolution). This keeps the package auth- and
|
|
193
|
+
* chain-agnostic: the dashboard wires Clerk today; the owner-signature SDK
|
|
194
|
+
* client wires it for integrators at P1.
|
|
195
|
+
*/
|
|
196
|
+
|
|
197
|
+
/** One owner's collected signature on a proposal. */
|
|
198
|
+
interface ProposalSignature {
|
|
199
|
+
ownerId: number;
|
|
200
|
+
signerKind: string;
|
|
201
|
+
/** The owner's serialized inner V2_SNIP12 envelope (comma-joined felts). */
|
|
202
|
+
signature: string;
|
|
203
|
+
}
|
|
204
|
+
/** A treasury proposal as returned by the coordination backend. */
|
|
205
|
+
interface TreasuryProposal {
|
|
206
|
+
id: string;
|
|
207
|
+
/** Set for generalized actions (vote / call any contract). */
|
|
208
|
+
calls?: {
|
|
209
|
+
to: string;
|
|
210
|
+
entrypoint: string;
|
|
211
|
+
calldata: string[];
|
|
212
|
+
}[] | null;
|
|
213
|
+
/** Human label for an action ("Vote YES on Proposal #5"). */
|
|
214
|
+
title?: string | null;
|
|
215
|
+
/** Arbitrary integrator context (e.g. `{ poolId }`). */
|
|
216
|
+
meta?: Record<string, string | number> | null;
|
|
217
|
+
/** App-level risk tier the proposal was filed under (null = none). */
|
|
218
|
+
risk?: "ROUTINE" | "SENSITIVE" | null;
|
|
219
|
+
oeMessageHash: string;
|
|
220
|
+
oeNonce: string | null;
|
|
221
|
+
oeExecuteBefore: string | null;
|
|
222
|
+
requiredApprovals: number;
|
|
223
|
+
status: "PROPOSED" | "APPROVED" | "EXECUTED" | "CANCELED" | "EXPIRED";
|
|
224
|
+
executedTxHash?: string | null;
|
|
225
|
+
signatures: ProposalSignature[];
|
|
226
|
+
}
|
|
227
|
+
/** The body the coordination backend's `propose` endpoint accepts. */
|
|
228
|
+
interface ProposeBody {
|
|
229
|
+
proposerOwnerId: number;
|
|
230
|
+
recipient: string;
|
|
231
|
+
tokenAddress: string;
|
|
232
|
+
amount: string;
|
|
233
|
+
title: string;
|
|
234
|
+
calls: {
|
|
235
|
+
to: string;
|
|
236
|
+
entrypoint: string;
|
|
237
|
+
calldata: string[];
|
|
238
|
+
}[];
|
|
239
|
+
meta?: Record<string, string | number>;
|
|
240
|
+
/** Template risk tier — lets the backend apply the treasury's quorum policy. */
|
|
241
|
+
risk?: "ROUTINE" | "SENSITIVE";
|
|
242
|
+
oeMessageHash: string;
|
|
243
|
+
oeNonce: string;
|
|
244
|
+
oeExecuteBefore: string;
|
|
245
|
+
requiredApprovals: number;
|
|
246
|
+
proposerSignature: string;
|
|
247
|
+
proposerSignerKind: string;
|
|
248
|
+
}
|
|
249
|
+
/** The coordination backend (propose / list / sign / execute), host-wired. */
|
|
250
|
+
interface MultisigTransport {
|
|
251
|
+
list(): Promise<{
|
|
252
|
+
items: TreasuryProposal[];
|
|
253
|
+
}>;
|
|
254
|
+
propose(body: ProposeBody): Promise<TreasuryProposal>;
|
|
255
|
+
sign(proposalId: string, body: {
|
|
256
|
+
ownerId: number;
|
|
257
|
+
signature: string;
|
|
258
|
+
signerKind: string;
|
|
259
|
+
}): Promise<unknown>;
|
|
260
|
+
execute(proposalId: string, calldata: string[]): Promise<{
|
|
261
|
+
executedTxHash?: string;
|
|
262
|
+
transactionHash?: string;
|
|
263
|
+
}>;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* A per-owner OE signer. `sign` produces this device's inner envelope (key
|
|
267
|
+
* never leaves it). `resolveOwnerIndex` maps the device's credential to its
|
|
268
|
+
* position in the on-chain owner set (for approving as a non-proposer).
|
|
269
|
+
*/
|
|
270
|
+
interface MultisigSigner {
|
|
271
|
+
/** ShhhSignerKind, e.g. "WEBAUTHN_P256" / "STARK" / "EIP191_SECP256K1". */
|
|
272
|
+
signerKind: string;
|
|
273
|
+
/** Owner index this device proposes as (the bootstrap owner; default 0). */
|
|
274
|
+
proposerOwnerIndex?: number;
|
|
275
|
+
sign: OeSigner;
|
|
276
|
+
resolveOwnerIndex(walletAddress: string): Promise<number>;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Pure orchestration for the multisig governance flow — build a propose
|
|
281
|
+
* body, build an approval, assemble execute calldata. No React, no network:
|
|
282
|
+
* the hooks (`use-hooks.ts`) wrap these in mutations/queries, and they're
|
|
283
|
+
* directly unit-testable with a mock signer + injected `nowMs`/`rand`.
|
|
284
|
+
*/
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Build a propose body for a template + its validated field values: derive
|
|
288
|
+
* the call(s) + title (+ meta), build & proposer-sign the OE, and shape the
|
|
289
|
+
* body the coordination backend expects. For an action the payment fields
|
|
290
|
+
* are placeholders (recipient/token = the first call's target, amount "0");
|
|
291
|
+
* the real intent rides in `calls` + `title`.
|
|
292
|
+
*/
|
|
293
|
+
declare function createProposal<V>(params: {
|
|
294
|
+
template: ActionTemplate<V>;
|
|
295
|
+
values: V;
|
|
296
|
+
walletAddress: string;
|
|
297
|
+
requiredApprovals: number;
|
|
298
|
+
signer: MultisigSigner;
|
|
299
|
+
chainId?: string;
|
|
300
|
+
nowMs?: number;
|
|
301
|
+
rand?: number;
|
|
302
|
+
}): Promise<ProposeBody>;
|
|
303
|
+
/**
|
|
304
|
+
* Build an approver's signature on an existing proposal: resolve this
|
|
305
|
+
* device's owner index from chain, then sign the SAME OE hash.
|
|
306
|
+
*/
|
|
307
|
+
declare function buildApproval(params: {
|
|
308
|
+
proposal: Pick<TreasuryProposal, "oeMessageHash">;
|
|
309
|
+
walletAddress: string;
|
|
310
|
+
signer: MultisigSigner;
|
|
311
|
+
}): Promise<{
|
|
312
|
+
ownerId: number;
|
|
313
|
+
signature: string;
|
|
314
|
+
signerKind: string;
|
|
315
|
+
}>;
|
|
316
|
+
/**
|
|
317
|
+
* Assemble the execute calldata from a proposal's persisted call(s) + its
|
|
318
|
+
* collected signatures (sorted by owner index). Requires `calls` — this is
|
|
319
|
+
* the generalized-action flow; a host with payment-only proposals supplies
|
|
320
|
+
* the transfer calls.
|
|
321
|
+
*/
|
|
322
|
+
declare function buildExecuteCalldata(proposal: TreasuryProposal): string[];
|
|
323
|
+
|
|
324
|
+
interface ProposeInput {
|
|
325
|
+
template: ActionTemplate<any>;
|
|
326
|
+
values: any;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Propose a templated action: build the call(s) + title from the template,
|
|
330
|
+
* passkey-/key-sign the OE as the proposer, and submit it. `getRequiredApprovals`
|
|
331
|
+
* supplies the wallet's threshold (the host reads it from chain — the package
|
|
332
|
+
* stays chain-agnostic).
|
|
333
|
+
*/
|
|
334
|
+
declare function useProposeAction(config: {
|
|
335
|
+
walletAddress: string;
|
|
336
|
+
transport: MultisigTransport;
|
|
337
|
+
signer: MultisigSigner;
|
|
338
|
+
getRequiredApprovals: () => Promise<number>;
|
|
339
|
+
chainId?: string;
|
|
340
|
+
}): _tanstack_react_query.UseMutationResult<TreasuryProposal, Error, ProposeInput, unknown>;
|
|
341
|
+
/**
|
|
342
|
+
* List a treasury's proposals and expose approve / execute mutations. An
|
|
343
|
+
* approver signs the same OE hash as their resolved owner index; once enough
|
|
344
|
+
* approvals are collected, execute rebuilds the OE from the persisted call(s)
|
|
345
|
+
* and relays it.
|
|
346
|
+
*/
|
|
347
|
+
declare function useTreasuryProposals(config: {
|
|
348
|
+
walletAddress: string;
|
|
349
|
+
transport: MultisigTransport;
|
|
350
|
+
signer: MultisigSigner;
|
|
351
|
+
}): {
|
|
352
|
+
proposals: _tanstack_react_query.UseQueryResult<{
|
|
353
|
+
items: TreasuryProposal[];
|
|
354
|
+
}, Error>;
|
|
355
|
+
approve: _tanstack_react_query.UseMutationResult<unknown, Error, TreasuryProposal, unknown>;
|
|
356
|
+
execute: _tanstack_react_query.UseMutationResult<{
|
|
357
|
+
executedTxHash?: string;
|
|
358
|
+
transactionHash?: string;
|
|
359
|
+
}, Error, TreasuryProposal, unknown>;
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Theming for the embeddable governance components (design brief §8).
|
|
364
|
+
*
|
|
365
|
+
* One mechanism: every component root carries inline CSS variables derived
|
|
366
|
+
* from a `theme` prop merged over the defaults, and a single namespaced
|
|
367
|
+
* stylesheet (injected once at runtime) styles everything off those vars.
|
|
368
|
+
* Integrators theme by passing tokens — `<Approvals theme={{ accent:
|
|
369
|
+
* "#0f766e", radius: "0.375rem" }} />` — and the components render native
|
|
370
|
+
* to the host app. No Tailwind/CSS-import requirement; SSR-safe (the
|
|
371
|
+
* stylesheet injects in an effect, and first paint is already var-driven).
|
|
372
|
+
*
|
|
373
|
+
* Default skin = the Chipi neobrutalism system: bold borders, hard offset
|
|
374
|
+
* shadow, high-contrast text.
|
|
375
|
+
*/
|
|
376
|
+
interface ChipiGovTheme {
|
|
377
|
+
/** Primary action color (buttons, focus, progress). */
|
|
378
|
+
accent?: string;
|
|
379
|
+
/** Text color on the accent. */
|
|
380
|
+
accentText?: string;
|
|
381
|
+
/** Card/dialog background. */
|
|
382
|
+
surface?: string;
|
|
383
|
+
/** Page-muted background (rows, inputs). */
|
|
384
|
+
surfaceMuted?: string;
|
|
385
|
+
/** Primary text. */
|
|
386
|
+
text?: string;
|
|
387
|
+
/** Secondary text. */
|
|
388
|
+
textMuted?: string;
|
|
389
|
+
/** Error/destructive color. */
|
|
390
|
+
danger?: string;
|
|
391
|
+
/** Success color (executed, looks-good). */
|
|
392
|
+
success?: string;
|
|
393
|
+
/** Border color. */
|
|
394
|
+
border?: string;
|
|
395
|
+
/** Corner radius (any CSS length). */
|
|
396
|
+
radius?: string;
|
|
397
|
+
/** Hard offset shadow (set to "none" for flat hosts). */
|
|
398
|
+
shadow?: string;
|
|
399
|
+
/** Font stack. */
|
|
400
|
+
font?: string;
|
|
401
|
+
}
|
|
402
|
+
declare const DEFAULT_THEME: Required<ChipiGovTheme>;
|
|
403
|
+
/** Inline CSS-var style object for a component root. */
|
|
404
|
+
declare function themeVars(theme?: ChipiGovTheme): Record<string, string>;
|
|
405
|
+
/** Idempotently inject the component stylesheet into the document head. */
|
|
406
|
+
declare function injectGovStyles(): void;
|
|
407
|
+
|
|
408
|
+
/** Light per-type syntax check; returns a human error or null. */
|
|
409
|
+
declare function fieldSyntaxError(field: FieldSpec, raw: string): string | null;
|
|
410
|
+
declare function FieldInput(props: {
|
|
411
|
+
field: FieldSpec;
|
|
412
|
+
value: string;
|
|
413
|
+
onChange: (raw: string) => void;
|
|
414
|
+
/** Shown once the user has touched the field. */
|
|
415
|
+
error?: string | null;
|
|
416
|
+
disabled?: boolean;
|
|
417
|
+
}): react_jsx_runtime.JSX.Element;
|
|
418
|
+
|
|
419
|
+
interface ProposeActionProps {
|
|
420
|
+
/** The treasury's SHHH wallet address. */
|
|
421
|
+
walletAddress: string;
|
|
422
|
+
/** Action templates the proposer can pick from (`defineActions(...)`). */
|
|
423
|
+
actions: ActionTemplate<any>[];
|
|
424
|
+
transport: MultisigTransport;
|
|
425
|
+
signer: MultisigSigner;
|
|
426
|
+
/** Read the wallet's current threshold (host-supplied; chain read). */
|
|
427
|
+
getRequiredApprovals: () => Promise<number>;
|
|
428
|
+
/** Preselect a template by key (also hides the tabs when it's the only one). */
|
|
429
|
+
preselect?: string;
|
|
430
|
+
/** Custom trigger; receives the open callback. Defaults to a button. */
|
|
431
|
+
trigger?: (open: () => void) => React.ReactNode;
|
|
432
|
+
theme?: ChipiGovTheme;
|
|
433
|
+
onProposed?: (proposal: TreasuryProposal) => void;
|
|
434
|
+
chainId?: string;
|
|
435
|
+
}
|
|
436
|
+
declare function ProposeAction(props: ProposeActionProps): react_jsx_runtime.JSX.Element;
|
|
437
|
+
|
|
438
|
+
type ApprovalsFilter = "actionable" | "pending" | "all";
|
|
439
|
+
interface ApprovalsProps {
|
|
440
|
+
/** The treasury's SHHH wallet address. */
|
|
441
|
+
walletAddress: string;
|
|
442
|
+
transport: MultisigTransport;
|
|
443
|
+
signer: MultisigSigner;
|
|
444
|
+
/** Inject business context per row (reads `proposal.meta`). */
|
|
445
|
+
renderContext?: (proposal: TreasuryProposal) => React.ReactNode;
|
|
446
|
+
/** actionable = needs me or ready; pending = not terminal; all. Default actionable. */
|
|
447
|
+
filter?: ApprovalsFilter;
|
|
448
|
+
theme?: ChipiGovTheme;
|
|
449
|
+
onExecuted?: (proposal: TreasuryProposal, txHash?: string) => void;
|
|
450
|
+
/** Custom empty state. */
|
|
451
|
+
empty?: React.ReactNode;
|
|
452
|
+
/** Build an explorer URL for an executed tx hash (row link). */
|
|
453
|
+
explorerTxUrl?: (txHash: string) => string;
|
|
454
|
+
/**
|
|
455
|
+
* Mark a proposal as filed by an AI agent (governance §9). When this
|
|
456
|
+
* returns true, the row reads "{agentLabel} wants: {title}" with an
|
|
457
|
+
* Agent chip — the founder-facing "your agent wants…" copy. The host
|
|
458
|
+
* decides agent-ness (it knows which owner index is its agent); the
|
|
459
|
+
* package stays chain-read-free.
|
|
460
|
+
*/
|
|
461
|
+
isAgentProposal?: (proposal: TreasuryProposal) => boolean;
|
|
462
|
+
/** Label for agent rows (default "Agent"). */
|
|
463
|
+
agentLabel?: string;
|
|
464
|
+
}
|
|
465
|
+
/** Human fallback title for legacy payment proposals without `title`. */
|
|
466
|
+
declare function proposalTitle(p: TreasuryProposal): string;
|
|
467
|
+
declare function Approvals(props: ApprovalsProps): react_jsx_runtime.JSX.Element;
|
|
468
|
+
|
|
469
|
+
interface InboxTreasury extends Pick<ApprovalsProps, "walletAddress" | "transport" | "signer" | "renderContext" | "explorerTxUrl" | "isAgentProposal" | "agentLabel"> {
|
|
470
|
+
/** Group heading ("Ops treasury", "Acme · Pool fund"). */
|
|
471
|
+
label: string;
|
|
472
|
+
}
|
|
473
|
+
interface ApprovalInboxProps {
|
|
474
|
+
treasuries: InboxTreasury[];
|
|
475
|
+
theme?: ChipiGovTheme;
|
|
476
|
+
/** Shown when every treasury is caught up. */
|
|
477
|
+
onEmpty?: React.ReactNode;
|
|
478
|
+
onExecuted?: (treasury: InboxTreasury, proposal: TreasuryProposal, txHash?: string) => void;
|
|
479
|
+
}
|
|
480
|
+
declare function ApprovalInbox(props: ApprovalInboxProps): react_jsx_runtime.JSX.Element;
|
|
481
|
+
|
|
482
|
+
export { type ActionProposal, type ActionTemplate, ApprovalInbox, type ApprovalInboxProps, Approvals, type ApprovalsFilter, type ApprovalsProps, type CallSpec, type ChipiGovTheme, DEFAULT_THEME, FELT_PRIME, type FeltLike, FieldInput, type FieldSpec, type InboxTreasury, type MultisigSigner, type MultisigTransport, OE_WINDOW_SECONDS, type OeSigner, type ProposalSignature, ProposeAction, type ProposeActionProps, type ProposeBody, type ProposeInput, SN_MAIN_CHAIN_ID, type TreasuryProposal, type VoteValues, amountToBase, assembleActionExecuteCalldata, buildActionProposal, buildApproval, buildExecuteCalldata, createProposal, defineActions, deriveExecuteAfter, deserializeEnvelope, fieldSyntaxError, injectGovStyles, newOeNonce, proposalTitle, serializeEnvelope, signActionApproval, themeVars, toFelt, u256, useProposeAction, useTreasuryProposals, voteTemplate };
|