forked from Northgate-Systems/RemitX
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
142 lines (135 loc) · 3.71 KB
/
Copy pathtypes.ts
File metadata and controls
142 lines (135 loc) · 3.71 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/**
* Hand-written row types matching the Supabase schema (see
* supabase-schema.sql). There's no Prisma client generating these anymore —
* if you add/change a column, update both the SQL and this file.
*/
export type KycStatus = "pending" | "verified" | "rejected";
export type TransactionStatus = "pending" | "validating" | "confirmed" | "failed";
export type EscrowStatus = "locked" | "released" | "refunded" | "expired";
export type User = {
id: string;
email: string;
firstName: string;
lastName: string;
passwordHash: string;
stellarPublicKey: string | null;
kycStatus: KycStatus;
sessionVersion: number;
failedLoginAttempts: number;
lockedUntil: string | null;
createdAt: string;
updatedAt: string;
}
export type Transaction = {
id: string;
userId: string;
fromAsset: string;
toAsset: string;
fromAmount: string;
toAmount: string | null;
recipientAddress: string;
stellarTxHash: string | null;
escrowId: string | null;
status: TransactionStatus;
createdAt: string;
confirmedAt: string | null;
updatedAt: string;
}
export type Escrow = {
id: string;
userId: string;
transactionId: string;
contractAddress: string;
senderAddress: string;
recipientAddress: string;
amount: string;
asset: string;
status: EscrowStatus;
depositTxHash: string | null;
releaseTxHash: string | null;
createdAt: string;
expiresAt: string;
updatedAt: string;
}
export type Rate = {
id: string;
fromAsset: string;
toAsset: string;
rate: string;
fetchedAt: string;
}
// ── Supabase Database type ──────────────────────────────────────────────
// Hand-written to match supabase-schema.sql. Passed as the generic to
// createClient<Database>() in lib/supabase.ts so insert()/update() calls
// are typed instead of falling back to `never`. Shape matches
// @supabase/postgrest-js's GenericTable/GenericSchema exactly (Row/Insert/
// Update/Relationships per table, Tables/Views/Functions per schema).
type Tables<Row, Insert extends object> = {
Row: Row;
Insert: Insert;
Update: Partial<Insert>;
Relationships: [];
};
export type Database = {
public: {
Tables: {
users: Tables<
User,
Partial<
Pick<
User,
| "id"
| "kycStatus"
| "stellarPublicKey"
| "sessionVersion"
| "failedLoginAttempts"
| "lockedUntil"
| "createdAt"
| "updatedAt"
>
> &
Pick<User, "email" | "firstName" | "lastName" | "passwordHash">
>;
transactions: Tables<
Transaction,
Partial<
Pick<
Transaction,
| "id"
| "toAmount"
| "stellarTxHash"
| "escrowId"
| "status"
| "createdAt"
| "confirmedAt"
| "updatedAt"
>
> &
Pick<Transaction, "userId" | "fromAsset" | "toAsset" | "fromAmount" | "recipientAddress">
>;
escrows: Tables<
Escrow,
Partial<
Pick<
Escrow,
"id" | "status" | "depositTxHash" | "releaseTxHash" | "createdAt" | "updatedAt"
>
> &
Pick<
Escrow,
| "userId"
| "transactionId"
| "contractAddress"
| "senderAddress"
| "recipientAddress"
| "amount"
| "asset"
| "expiresAt"
>
>;
rates: Tables<Rate, Partial<Pick<Rate, "id" | "fetchedAt">> & Pick<Rate, "fromAsset" | "toAsset" | "rate">>;
};
Views: Record<string, never>;
Functions: Record<string, never>;
};
};