-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsecrets.ts
39 lines (30 loc) · 995 Bytes
/
secrets.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
import fs from "fs/promises";
import { logger } from "./src/utils/logger.js";
export const PRIVATE_KEYS = await importPrivateKeys(
"resources/private-keys.txt",
);
async function importPrivateKeys(path: string) {
const EXCLUDED_WALLETS = await importExcludedWallets(
"resources/excluded-wallets.txt",
);
const text = await fs.readFile(path, "utf8");
const lines = text.split("\n");
const privateKeys: Record<string, string> = {};
lines.forEach((line: string) => {
const [name, privateKey] = line.trim().replace("\r", "").split(":");
if (EXCLUDED_WALLETS.has(name)) {
logger.info`Skipping wallet ${name} as it's in the excluded list.`;
return;
}
privateKeys[name] = privateKey;
});
return privateKeys;
}
async function importExcludedWallets(path: string) {
const text = await fs.readFile(path, "utf8");
const lines = text.split(",");
const excludedWallets = lines.map((line: string) =>
line.trim().replace("\r", ""),
);
return new Set(excludedWallets);
}