-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathenv.ts
36 lines (28 loc) · 1.04 KB
/
env.ts
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
import { z } from "zod";
const envSchema = z.object({
// Master account
VITE_PUBLIC_MASTER_ADDRESS: z.string().startsWith("0x"),
VITE_PUBLIC_MASTER_PRIVATE_KEY: z.string().startsWith("0x"),
VITE_PUBLIC_ACCOUNT_CLASS_HASH: z.string().startsWith("0x"),
VITE_PUBLIC_FEE_TOKEN_ADDRESS: z.string().startsWith("0x"),
// Client fee recipient
VITE_PUBLIC_CLIENT_FEE_RECIPIENT: z.string().startsWith("0x"),
// API endpoints
VITE_PUBLIC_TORII: z.string().url(),
VITE_PUBLIC_NODE_URL: z.string().url(),
VITE_PUBLIC_TORII_RELAY: z.string(),
// Version and chain info
VITE_PUBLIC_CHAIN: z.enum(["sepolia", "mainnet", "slot", "local"]), // Add other chains as needed
VITE_PUBLIC_SLOT: z.string(),
});
let env: z.infer<typeof envSchema>;
console.log(import.meta.env);
try {
env = envSchema.parse(import.meta.env);
} catch (error) {
if (error instanceof z.ZodError) {
console.error("❌ Invalid environment variables:", JSON.stringify(error.errors, null, 2));
}
throw new Error("Invalid environment variables");
}
export { env };