-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
60 lines (55 loc) · 2.03 KB
/
Copy pathtypes.ts
File metadata and controls
60 lines (55 loc) · 2.03 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
// ─── Invoice ──────────────────────────────────────────────────────────────────
/**
* All nine on-chain invoice states.
*
* Intentionally differs from @iln/shared's InvoiceStatus only in that this is
* a local copy kept in sync with the contract. If a new status is added to the
* contract, it must be added here as well.
*/
export type InvoiceStatus =
| 'Pending'
| 'PartiallyFunded'
| 'Funded'
| 'Paid'
| 'Defaulted'
| 'Appealed'
| 'Disputed'
| 'Expired'
| 'Cancelled';
/**
* Invoice row as stored in SQLite.
*
* This is a DB-specific projection of @iln/shared's Invoice, not a duplicate.
* Field names use snake_case to match the SQL schema, `amount` is a string
* (i128 exceeds JS Number.MAX_SAFE_INTEGER), and it omits contract-only fields
* like `token`, `amountFunded`, `submitterReputation`, etc.
*/
export interface Invoice {
id: number;
freelancer: string;
payer: string;
/** Full invoice value in stroops (1 USDC = 10_000_000). Stored as string. */
amount: string;
/** Unix timestamp — when the payer must settle by. */
due_date: number;
/** Basis points, e.g. 300 = 3.00%. */
discount_rate: number;
status: InvoiceStatus;
funder: string | null;
funded_at: number | null;
created_at: number;
updated_at: number;
}
// ─── Events ───────────────────────────────────────────────────────────────────
export type ILNEventType = 'submitted' | 'funded' | 'paid' | 'defaulted';
/** Processed ILN contract event as stored in SQLite. */
export interface ILNEvent {
/** Unique Soroban event ID (e.g. "0000001234-0-0"). Used for deduplication. */
event_id: string;
event_type: ILNEventType;
invoice_id: number;
ledger: number;
/** ISO 8601 timestamp of ledger close. */
ledger_closed_at: string;
created_at: number;
}