๐ src/web3/session/types.ts
D-OPEN SOVEREIGN
1export type { WalletType } from '../client/types';
2import { type WalletType } from '../client/types';
3
4export interface Web3SessionAccount {
5 account: string; // EVM hex address
6 username: string;
7 hasAccount: boolean;
8 userId: number; // needed for archivistStorage.userLevel(account.userId)
9 lastPatchIndex: number;
10 lastRestorationIndex: number;
11 country?: string;
12 language?: string;
13 lastUpdated?: number;
14 level?: number;
15 projectBalance?: { contributions: number; allocated: number; remaining: number };
16 donationsPerProject?: number[];
17
18 chainId: number;
19 wallet: WalletType; // 'metamask' | 'private_key'
20}
21
22export interface SessionState {
23 active: Web3SessionAccount | null;
24 known: Web3SessionAccount[]; // all known accounts including active
25}
26
27export interface SessionStore {
28 getState(): SessionState;
29
30 // account lifecycle
31 setActive(account: Web3SessionAccount | null): void;
32 addKnown(account: Web3SessionAccount): void;
33 updateAccount(address: string, chainId: number, patch: Partial<Web3SessionAccount>): void;
34 removeAccount(address: string, chainId: number): void;
35 clearAll(): void;
36
37 // counters (called from mutations)
38 setLastSavedPatchIndex(address: string, chainId: number, index: number): void;
39 setLastRestorationIndex(address: string, chainId: number, index: number): void;
40 lastSyncCounters(address: string, chainId: number): { lastPatchIndex: number; lastRestorationIndex: number };
41
42 // project votes (called from mutations)
43 updateProjectVotes(address: string, chainId: number, projectId: number, amount: number): void;
44
45 // persistence
46 persist(): void;
47 load(): void;
48
49 // reactive change notification โ the Vue composable layer subscribes once at
50 // module load to bump its local reactive counter (spec ยง13.2 G2 resolution:
51 // "wires sessionStore event listeners internally via an install() call
52 // triggered at module load"), independent of which code path mutated the store.
53 subscribe(listener: () => void): () => void;
54}
55