forked from 0xilbiscione/dlmm-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev-blocklist.js
More file actions
65 lines (56 loc) · 1.9 KB
/
Copy pathdev-blocklist.js
File metadata and controls
65 lines (56 loc) · 1.9 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
/**
* Dev (deployer) blocklist — deployer wallet addresses that should never be deployed into.
*
* Agent/user can add deployers via Telegram ("block this deployer").
* Screening hard-filters any pool whose base token was deployed by a blocked wallet
* before the pool list reaches the LLM.
*/
import fs from "fs";
import { log } from "./logger.js";
const BLOCKLIST_FILE = "./dev-blocklist.json";
function load() {
if (!fs.existsSync(BLOCKLIST_FILE)) return {};
try {
return JSON.parse(fs.readFileSync(BLOCKLIST_FILE, "utf8"));
} catch {
return {};
}
}
function save(data) {
fs.writeFileSync(BLOCKLIST_FILE, JSON.stringify(data, null, 2));
}
export function isDevBlocked(devWallet) {
if (!devWallet) return false;
return !!load()[devWallet];
}
export function getBlockedDevs() {
return load();
}
export function blockDev({ wallet, reason, label }) {
if (!wallet) return { error: "wallet required" };
const db = load();
if (db[wallet]) return { already_blocked: true, wallet, label: db[wallet].label, reason: db[wallet].reason };
db[wallet] = {
label: label || "unknown",
reason: reason || "no reason provided",
added_at: new Date().toISOString(),
};
save(db);
log("dev_blocklist", `Blocked deployer ${label || wallet}: ${reason}`);
return { blocked: true, wallet, label, reason };
}
export function unblockDev({ wallet }) {
if (!wallet) return { error: "wallet required" };
const db = load();
if (!db[wallet]) return { error: `Wallet ${wallet} not on dev blocklist` };
const entry = db[wallet];
delete db[wallet];
save(db);
log("dev_blocklist", `Removed deployer ${entry.label || wallet} from blocklist`);
return { unblocked: true, wallet, was: entry };
}
export function listBlockedDevs() {
const db = load();
const entries = Object.entries(db).map(([wallet, info]) => ({ wallet, ...info }));
return { count: entries.length, blocked_devs: entries };
}