@unlink-xyz/react 0.1.5 → 0.1.6

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,106 @@
1
+ import { MultisigAccount, IndexedDbStore, MultisigAccountStore, ViewingKeyPair, SessionEvent } from '@unlink-xyz/multisig';
2
+ import { SignerOverride } from '@unlink-xyz/core';
3
+
4
+ type UseMultisigAccountsResult = {
5
+ /** All stored multisig accounts. */
6
+ accounts: MultisigAccount[];
7
+ /** Whether the initial load is in progress. */
8
+ loading: boolean;
9
+ /** Load a single account by groupId. */
10
+ load: (groupId: string) => Promise<MultisigAccount | null>;
11
+ /** Delete an account by groupId and refresh the list. */
12
+ remove: (groupId: string) => Promise<void>;
13
+ /** Re-fetch the account list from the store. */
14
+ refresh: () => Promise<void>;
15
+ /** The underlying store instance (for save() from other hooks). */
16
+ store: IndexedDbStore;
17
+ };
18
+ /**
19
+ * Reactive wrapper around `IndexedDbStore` for managing multisig accounts.
20
+ */
21
+ declare function useMultisigAccounts(): UseMultisigAccountsResult;
22
+
23
+ type DkgState = "idle" | "creating" | "joining" | "completing" | "complete" | "error";
24
+ type CreateParams = {
25
+ threshold: number;
26
+ totalShares: number;
27
+ gatewayUrl: string;
28
+ viewingKeyPair?: ViewingKeyPair;
29
+ };
30
+ type JoinParams = {
31
+ code: string;
32
+ gatewayUrl: string;
33
+ viewingKeyPair?: ViewingKeyPair;
34
+ };
35
+ type UseDkgOptions = {
36
+ /** Provide a store from useMultisigAccounts to share persistence. */
37
+ store?: MultisigAccountStore;
38
+ };
39
+ type UseDkgResult = {
40
+ state: DkgState;
41
+ /** The completed multisig account (available when state === "complete"). */
42
+ account: MultisigAccount | null;
43
+ /** The DKG group ID / join code (available after create()). */
44
+ groupId: string | null;
45
+ error: Error | null;
46
+ /** Start a new DKG ceremony as the creator. */
47
+ create: (params: CreateParams) => Promise<void>;
48
+ /** Join an existing DKG ceremony. */
49
+ join: (params: JoinParams) => Promise<void>;
50
+ /** Reset to idle state. */
51
+ reset: () => void;
52
+ };
53
+ /**
54
+ * DKG ceremony state machine.
55
+ *
56
+ * Wraps `createMultisig()` / `joinMultisig()` with React state.
57
+ * On completion, auto-stores the account via the provided store
58
+ * (or a default `IndexedDbStore` if none is given).
59
+ */
60
+ declare function useDkg(options?: UseDkgOptions): UseDkgResult;
61
+
62
+ type UseMultisigSignerParams = {
63
+ account: MultisigAccount;
64
+ /** Participant indices that will co-sign. */
65
+ participants: number[];
66
+ metadata?: Record<string, string>;
67
+ onSessionCreated?: (code: string) => void;
68
+ };
69
+ /**
70
+ * Build a `SignerOverride` from a `MultisigAccount`.
71
+ *
72
+ * The returned value can be passed to `useTransfer(overrides)` or
73
+ * `useWithdraw(overrides)` to sign transactions with the multisig.
74
+ *
75
+ * Returns `null` when `params` is `undefined` (no account selected).
76
+ */
77
+ declare function useMultisigSigner(params: UseMultisigSignerParams | undefined): SignerOverride | null;
78
+
79
+ type UseSigningListenerParams = {
80
+ account: MultisigAccount;
81
+ /** Called before signing. Return false to skip. Defaults to auto-approve. */
82
+ approve?: (session: SessionEvent) => Promise<boolean> | boolean;
83
+ /** Polling interval in ms (default 1000). */
84
+ pollIntervalMs?: number;
85
+ /** Start listening immediately on mount (default true). */
86
+ autoStart?: boolean;
87
+ };
88
+ type UseSigningListenerResult = {
89
+ /** Whether the listener is currently running. */
90
+ listening: boolean;
91
+ /** Session events received so far. */
92
+ events: SessionEvent[];
93
+ /** Start the listener. */
94
+ start: () => void;
95
+ /** Stop the listener. */
96
+ stop: () => void;
97
+ };
98
+ /**
99
+ * Lifecycle wrapper around `runSigningListener()`.
100
+ *
101
+ * Automatically starts/stops with component mount/unmount
102
+ * when `autoStart` is true (default).
103
+ */
104
+ declare function useSigningListener(params: UseSigningListenerParams): UseSigningListenerResult;
105
+
106
+ export { type DkgState, type UseDkgOptions, useDkg, useMultisigAccounts, useMultisigSigner, useSigningListener };