Skip to content

Commit 1a458ef

Browse files
committed
lint fixes
1 parent eed1f6f commit 1a458ef

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/worker/tasks/track-address-balance.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ type WebhookDetail = {
1919
revokedAt: Date | null;
2020
};
2121

22+
type WebhookConfig = {
23+
address: string;
24+
chainId: number;
25+
threshold: number;
26+
};
27+
2228
export const trackAddressBalance = async () => {
2329
const today = Date.now();
2430
const oneDayAgo = today - 24 * 60 * 60 * 1000;
@@ -38,8 +44,9 @@ export const trackAddressBalance = async () => {
3844
let promises = [];
3945
let ids = [];
4046
for (const webhookDetail of webhookDetails) {
41-
if (!webhookDetail.config?.address) continue;
42-
if (!webhookDetail.config?.chainId) continue;
47+
const config = webhookDetail.config as WebhookConfig | null;
48+
if (!config?.address) continue;
49+
if (!config?.chainId) continue;
4350

4451
ids.push(webhookDetail.id);
4552
promises.push(
@@ -67,7 +74,7 @@ export const trackAddressBalance = async () => {
6774
};
6875

6976
const _checkBalanceAndEnqueueWebhook = async (webhookDetail: WebhookDetail) => {
70-
const { address, chainId, threshold } = webhookDetail.config;
77+
const { address, chainId, threshold } = webhookDetail.config as WebhookConfig;
7178

7279
// get native balance of address
7380
const balanceData = await getWalletBalance({
@@ -78,14 +85,14 @@ const _checkBalanceAndEnqueueWebhook = async (webhookDetail: WebhookDetail) => {
7885
const currentBalance = balanceData.displayValue;
7986

8087
// dont do anything if has enough balance
81-
if (currentBalance > threshold) return;
88+
if (Number.parseFloat(currentBalance) > threshold) return;
8289

8390
await SendWebhookQueue.enqueueWebhook({
8491
type: WebhooksEventTypes.BACKEND_WALLET_BALANCE,
8592
body: {
8693
chainId,
8794
walletAddress: address,
88-
minimumBalance: threshold,
95+
minimumBalance: threshold.toString(),
8996
currentBalance: currentBalance,
9097
message: `LowBalance: The address ${address} on chain ${chainId} has ${Number.parseFloat(
9198
currentBalance,

0 commit comments

Comments
 (0)