Skip to content

Commit cb89234

Browse files
committed
fix: parametrize polling interval
1 parent 00a810c commit cb89234

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

src/config/env.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const envConfigMapping: Record<keyof ConfigSchema, string | string[]> = {
1414
ethProviderRpcs: "JSON_RPC_PROVIDERS",
1515
ignoreAccounts: "IGNORE_ACCOUNTS",
1616
logsPageSize: "LOGS_PAGE_SIZE",
17+
pollingInterval: "POLLING_INTERVAL",
1718
hfThreshold: "HF_TRESHOLD",
1819
restakingWorkaround: "RESTAKING_WORKAROUND",
1920
minBalance: "MIN_BALANCE",

src/config/schema.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ export const ConfigSchema = PartialV300ConfigSchema.extend({
7575
* Page size in blocks for eth_getLogs, default to some network-specific value
7676
*/
7777
logsPageSize: bigintLike.optional(),
78+
/**
79+
* Polling interval in milliseconds, default to what's default in viem
80+
*/
81+
pollingInterval: z.coerce.number().nonnegative().optional(),
7882
/**
7983
* Private key used to send liquidation transactions
8084
*/

src/services/Client.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ export default class Client {
116116
>;
117117

118118
public async launch(): Promise<void> {
119-
const { chainId, network, optimistic, privateKey } = this.config;
119+
const { chainId, network, optimistic, privateKey, pollingInterval } =
120+
this.config;
120121
const chain = defineChain({
121122
...CHAINS[network],
122123
id: chainId,
@@ -126,13 +127,13 @@ export default class Client {
126127
cacheTime: 0,
127128
chain,
128129
transport: this.#createTransport(),
129-
pollingInterval: optimistic ? 25 : undefined,
130+
pollingInterval: optimistic ? 25 : pollingInterval,
130131
});
131132
this.#logsClient = createPublicClient({
132133
cacheTime: 0,
133134
chain,
134135
transport: this.#createTransport(true),
135-
pollingInterval: optimistic ? 25 : undefined,
136+
pollingInterval: optimistic ? 25 : pollingInterval,
136137
});
137138
this.#walletClient = createWalletClient({
138139
account: privateKeyToAccount(privateKey),

0 commit comments

Comments
 (0)