Skip to content

Commit

Permalink
lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nischitpra committed Dec 17, 2024
1 parent eed1f6f commit 1a458ef
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/worker/tasks/track-address-balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ type WebhookDetail = {
revokedAt: Date | null;
};

type WebhookConfig = {
address: string;
chainId: number;
threshold: number;
};

export const trackAddressBalance = async () => {
const today = Date.now();
const oneDayAgo = today - 24 * 60 * 60 * 1000;
Expand All @@ -38,8 +44,9 @@ export const trackAddressBalance = async () => {
let promises = [];
let ids = [];
for (const webhookDetail of webhookDetails) {
if (!webhookDetail.config?.address) continue;
if (!webhookDetail.config?.chainId) continue;
const config = webhookDetail.config as WebhookConfig | null;
if (!config?.address) continue;
if (!config?.chainId) continue;

ids.push(webhookDetail.id);
promises.push(
Expand Down Expand Up @@ -67,7 +74,7 @@ export const trackAddressBalance = async () => {
};

const _checkBalanceAndEnqueueWebhook = async (webhookDetail: WebhookDetail) => {
const { address, chainId, threshold } = webhookDetail.config;
const { address, chainId, threshold } = webhookDetail.config as WebhookConfig;

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

// dont do anything if has enough balance
if (currentBalance > threshold) return;
if (Number.parseFloat(currentBalance) > threshold) return;

await SendWebhookQueue.enqueueWebhook({
type: WebhooksEventTypes.BACKEND_WALLET_BALANCE,
body: {
chainId,
walletAddress: address,
minimumBalance: threshold,
minimumBalance: threshold.toString(),
currentBalance: currentBalance,
message: `LowBalance: The address ${address} on chain ${chainId} has ${Number.parseFloat(
currentBalance,
Expand Down

0 comments on commit 1a458ef

Please sign in to comment.