Skip to content

Commit c77c1a5

Browse files
committed
feat: keeper bot support for the Neo core type
1 parent b03eb5a commit c77c1a5

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

contracts/scripts/keeperBot.ts

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
import { DisputeKitClassic, KlerosCore, PNK, RandomizerRNG, BlockHashRNG, SortitionModule } from "../typechain-types";
1+
import {
2+
DisputeKitClassic,
3+
KlerosCore,
4+
PNK,
5+
RandomizerRNG,
6+
BlockHashRNG,
7+
SortitionModule,
8+
KlerosCoreNeo,
9+
KlerosCoreUniversity,
10+
} from "../typechain-types";
211
import request from "graphql-request";
312
import env from "./utils/env";
413
import loggerFactory from "./utils/logger";
@@ -15,6 +24,7 @@ const HIGH_GAS_LIMIT = { gasLimit: 50_000_000 }; // 50M gas
1524
const HEARTBEAT_URL = env.optionalNoDefault("HEARTBEAT_URL_KEEPER_BOT");
1625
const SUBGRAPH_URL = env.require("SUBGRAPH_URL");
1726
const MAX_JURORS_PER_DISPUTE = 1000; // Skip disputes with more than this number of jurors
27+
const CORE_TYPE = env.optional("CORE_TYPE", "base");
1828
const DISPUTES_TO_SKIP = env
1929
.optional("DISPUTES_TO_SKIP", "")
2030
.split(",")
@@ -33,7 +43,21 @@ const loggerOptions = env.optionalNoDefault("LOGTAIL_TOKEN_KEEPER_BOT")
3343
const logger = loggerFactory.createLogger(loggerOptions);
3444

3545
const getContracts = async () => {
36-
const core = (await ethers.getContract("KlerosCore")) as KlerosCore;
46+
let core: KlerosCore | KlerosCoreNeo | KlerosCoreUniversity;
47+
const coreType = Cores[CORE_TYPE.toUpperCase() as keyof typeof Cores];
48+
switch (coreType) {
49+
case Cores.UNIVERSITY:
50+
core = (await ethers.getContract("KlerosCoreUniversity")) as KlerosCoreUniversity;
51+
break;
52+
case Cores.NEO:
53+
core = (await ethers.getContract("KlerosCoreNeo")) as KlerosCoreNeo;
54+
break;
55+
case Cores.BASE:
56+
core = (await ethers.getContract("KlerosCore")) as KlerosCore;
57+
break;
58+
default:
59+
throw new Error("Invalid core type, must be one of base, neo, university");
60+
}
3761
const sortition = (await ethers.getContract("SortitionModule")) as SortitionModule;
3862
const randomizerRng = (await ethers.getContract("RandomizerRNG")) as RandomizerRNG;
3963
const blockHashRNG = (await ethers.getContract("BlockHashRNG")) as BlockHashRNG;
@@ -67,6 +91,12 @@ type CustomError = {
6791
errorSignature: string;
6892
};
6993

94+
enum Cores {
95+
BASE,
96+
NEO,
97+
UNIVERSITY,
98+
}
99+
70100
enum Phase {
71101
STAKING = "staking",
72102
GENERATING = "generating",

0 commit comments

Comments
 (0)