forked from Gearbox-protocol/safe-watcher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.ts
52 lines (45 loc) · 1.24 KB
/
schema.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { Address } from "abitype/zod";
import { z } from "zod";
import { SafeAPIMode } from "../safe/schema.js";
export type PrefixedAddress = `${string}:0x${string}`;
export const PrefixedAddress = z.string().transform((val, ctx) => {
const regex = /^[a-zA-Z0-9]+:0x[a-fA-F0-9]{40}$/;
if (!regex.test(val)) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: `Invalid Prefixed Safe Address ${val}`,
});
}
return val as PrefixedAddress;
});
export const Schema = z.object({
/**
* URL of the Safe web app to generate links in notifications
*/
safeURL: z.string().url().default("https://app.safe.global"),
/**
* Polling interval in seconds
*/
pollInterval: z.number().int().positive().default(20),
/**
* Telegram bot token
*/
telegramBotToken: z.string(),
/**
* Telegram channel ID
*/
telegramChannelId: z.string(),
/**
* Prefixed safe addresses to watch, e.g. `eth:0x11111`
*/
safeAddresses: z.array(PrefixedAddress).min(1),
/**
* Mapping of signer address to human-readable name
*/
signers: z.record(Address, z.string().min(1)).default({}),
/**
* Which safe API to use
*/
api: SafeAPIMode.default("fallback"),
});
export type Schema = z.infer<typeof Schema>;