๐ src/web3/events/interfaces.ts
D-OPEN SOVEREIGN
1import { type WalletType } from '../client/types';
2import { type WalletError, type WalletState, type WalletUxError } from './enums';
3
4export interface CommonWalletEvent {
5 wallet: WalletType;
6 chainId?: number;
7 timestamp: number;
8}
9
10export interface WalletStateEvent extends CommonWalletEvent {
11 event: WalletState;
12 functionName?: string;
13 functionArgs?: any[];
14}
15
16export interface WalletSessionEvent {
17 account: string;
18 chainId: number;
19 wallet: WalletType;
20}
21
22export interface WalletSessionDeletedEvent {
23 account: string;
24 chainId: number;
25 wallet: WalletType;
26}
27
28export interface WalletErrorEvent extends CommonWalletEvent {
29 reason: WalletUxError | WalletError;
30 args?: any[];
31}
32
33export interface WalletChainChangedEvent extends CommonWalletEvent {}
34
35export interface WalletDisconnectedEvent extends CommonWalletEvent {
36 reason?: string;
37 timestamp: number;
38}
39
40// UX-only completion signal โ restoreAccountSave() (session/sync.ts) has
41// already decoded, persisted, and merged the restored patches into the live
42// ORM by the time this fires. Consumers use it to reflect "sync finished" in
43// the UI (toast, status line); it carries no patch payload to act on.
44export interface WalletSaveRestoredEvent extends CommonWalletEvent {
45 username: string;
46 account: string;
47 newRestorationIndex: number;
48 appliedCount: number;
49}
50
51// UX-only completion signal โ mirrors WalletSaveRestoredEvent for the
52// subscription-graph path. Fired by session/sync.ts's syncAccount() whenever
53// triggerSubscriptionSync() applies newly-delivered patches from followed
54// libraries; useSubscriptionSync() listens for this to surface a count
55// without itself triggering a sync or touching patches (spec ยง15.8).
56export interface SubscriptionPatchesSyncedEvent {
57 rootUserId: number;
58 chainId: number;
59 appliedCount: number;
60 timestamp: number;
61}
62