-
Notifications
You must be signed in to change notification settings - Fork 228
Expand file tree
/
Copy pathvault.ts
More file actions
77 lines (69 loc) · 2.05 KB
/
Copy pathvault.ts
File metadata and controls
77 lines (69 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/**
* Shared vault and validation status types.
*
* Single source of truth for the status unions that were previously redeclared
* (and had drifted out of sync) across Dashboard, Vaults, VaultDetail,
* VaultCard, and VaultTransactions. Every `VaultStatus` is a valid
* `ChipStatus` in `components/StatusChip.tsx`, so any vault status can be passed
* straight to `<StatusChip />`.
*/
/** Lifecycle state of a vault. Superset of every variant used across pages. */
export type VaultStatus =
| 'active'
| 'pending_validation'
| 'completed'
| 'failed'
| 'cancelled';
/** State of an individual milestone within a vault. */
export type MilestoneStatus = 'pending' | 'validated' | 'failed';
/** On-chain transaction category. */
export type TxType = 'create' | 'validate' | 'release' | 'redirect';
/** Confirmation state of an on-chain transaction. */
export type TxStatus = 'confirmed' | 'pending' | 'failed';
/**
* Canonical display order for vault statuses, used for consistent sorting.
* Contains every `VaultStatus` member exactly once, ordered from most to least
* active.
*/
export const VAULT_STATUS_ORDER: readonly VaultStatus[] = [
'active',
'pending_validation',
'completed',
'failed',
'cancelled',
] as const;
/** A single milestone within a vault. */
export interface Milestone {
id: string;
title: string;
description: string;
criteria: string;
status: MilestoneStatus;
validatedAt?: string;
evidenceUrl?: string;
}
/** A lightweight on-chain transaction record stored on the Vault itself. */
export interface VaultTransaction {
id: string;
type: TxType;
hash: string;
timestamp: string;
amount?: number;
}
/** Full vault record — canonical shape used across all pages. */
export interface Vault {
id: string;
name: string;
status: VaultStatus;
amount: number;
currency: string;
createdAt: string;
deadline: string;
creatorAddress: string;
verifierAddress?: string;
successAddress: string;
failureAddress: string;
contractAddress: string;
milestones: Milestone[];
transactions: VaultTransaction[];
}