-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathConfigurationService.ts
More file actions
51 lines (48 loc) · 2.17 KB
/
ConfigurationService.ts
File metadata and controls
51 lines (48 loc) · 2.17 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
import { Factory, Singleton } from "typescript-ioc";
import { readJSON } from "../utils/config-utils";
import { INetworkConfigJson } from "../utils/interfaces";
import { logException } from "../logger/logger";
@Singleton
@Factory(() => new ConfigurationService())
export class ConfigurationService {
network!: string;
networkRPC!: string;
maxBlocksForEventReads!: number;
maxRequestsPerSecond!: number | string;
rewardEpoch?: number;
requiredFtsoPerformanceWei!: string;
boostingFactor!: number;
votePowerCapBIPS!: number;
uptimeVotigPeriodLengthSeconds!: number;
uptimeVotingThreshold?: number;
minForBEBGwei!: string;
rewardAmountEpochWei?: string;
apiPath?: string;
numEpochs!: number;
constructor() {
if (process.env.CONFIG_FILE) {
let configFile: INetworkConfigJson;
try {
configFile = readJSON<INetworkConfigJson>(process.env.CONFIG_FILE);
} catch (error) {
logException(error, `ConfigFile doesn't exist`);
configFile = {} as INetworkConfigJson;
}
this.network = configFile.NETWORK ?? "flare";
const rpcOverride = process.env[`RPC_URL_${this.network.toUpperCase()}`];
this.networkRPC = rpcOverride ?? configFile.RPC ?? "https://flare-api.flare.network/ext/C/rpc";
this.maxBlocksForEventReads = configFile.MAX_BLOCKS_FOR_EVENT_READS ?? 30;
this.maxRequestsPerSecond = rpcOverride ? "Infinity" : (configFile.MAX_REQUESTS_PER_SECOND ?? 3);
this.rewardEpoch = configFile.REWARD_EPOCH ?? undefined;
this.requiredFtsoPerformanceWei = configFile.REQUIRED_FTSO_PERFORMANCE_WEI ?? "0";
this.boostingFactor = configFile.BOOSTING_FACTOR ?? 5;
this.votePowerCapBIPS = configFile.VOTE_POWER_CAP_BIPS ?? 500;
this.uptimeVotigPeriodLengthSeconds = configFile.UPTIME_VOTING_PERIOD_LENGTH_SECONDS ?? 600;
this.uptimeVotingThreshold = configFile.UPTIME_VOTING_THRESHOLD ?? undefined;
this.minForBEBGwei = configFile.MIN_FOR_BEB_GWEI ?? "1000000000000000";
this.rewardAmountEpochWei = configFile.REWARD_AMOUNT_EPOCH_WEI ?? undefined;
this.apiPath = configFile.API_PATH ?? undefined;
this.numEpochs = configFile.NUM_EPOCHS ? configFile.NUM_EPOCHS : 4;
}
}
}