Skip to content

Commit

Permalink
fix: removed eslint-disable comment via assert statement
Browse files Browse the repository at this point in the history
  • Loading branch information
chapati23 committed Aug 6, 2024
1 parent a3e6d1c commit 6156e39
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
20 changes: 11 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import assert from "assert/strict";

// Types
import type {
HttpFunction,
Request,
Response,
} from "@google-cloud/functions-framework";
import { EventType } from "./types.js";
import assert from "assert/strict";
import parseTransactionReceipts from "./parse-transaction-receipts";
import sendDiscordNotification from "./send-discord-notification";
import sendTelegramNotification from "./send-telegram-notification";
import { isFromQuicknode, hasAuthToken } from "./validate-request-origin";
import { EventType } from "./types.js";
import { hasAuthToken, isFromQuicknode } from "./validate-request-origin";

export const watchdogNotifier: HttpFunction = async (
req: Request,
Expand All @@ -34,23 +32,27 @@ export const watchdogNotifier: HttpFunction = async (
for (const parsedEvent of parsedEvents) {
switch (parsedEvent.event.eventName) {
case EventType.ProposalCreated:
assert(parsedEvent.timeLockId, "Time lock ID is missing");

await sendDiscordNotification(
parsedEvent.event,
// eslint-disable-next-line
parsedEvent.timeLockId!,
parsedEvent.timeLockId,
parsedEvent.txHash,
);

await sendTelegramNotification(
parsedEvent.event,
// eslint-disable-next-line
parsedEvent.timeLockId!,
parsedEvent.timeLockId,
parsedEvent.txHash,
);

break;

case EventType.MedianUpdated:
// Acts a health check/heartbeat for the service, as it's a frequently emitted event
console.info("[HealthCheck]: Block", parsedEvent.block);
break;

default:
assert(
false,
Expand Down
9 changes: 6 additions & 3 deletions src/parse-transaction-receipts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import { decodeEventLog } from "viem";

// Internal
import GovernorABI from "./governor-abi.js";
import SortedOraclesABI from "./sorted-oracles-abi.js";
import { EventType, HealthCheckEvent, ProposalCreatedEvent } from "./types.js";
import hasLogs from "./utils/has-logs.js";
import getEventByTopic from "./utils/get-event-by-topic.js";
import getProposalTimeLockId from "./utils/get-time-lock-id.js";
import hasLogs from "./utils/has-logs.js";
import isHealthCheckEvent from "./utils/is-health-check-event.js";
import isProposalCreatedEvent from "./utils/is-proposal-created-event.js";
import isTransactionReceipt from "./utils/is-transaction-receipt.js";
import SortedOraclesABI from "./sorted-oracles-abi.js";
import getProposalTimeLockId from "./utils/get-time-lock-id.js";

/**
* Parse request body containing raw transaction receipts
Expand Down Expand Up @@ -60,6 +60,7 @@ export default function parseTransactionReceipts(
// It can happen that a single transaction fires multiple events,
// some of which we are not interested in
continue;

case EventType.ProposalCreated: {
const event = decodeEventLog({
abi: GovernorABI,
Expand All @@ -79,6 +80,7 @@ export default function parseTransactionReceipts(
});
break;
}

case EventType.MedianUpdated: {
const event = decodeEventLog({
abi: SortedOraclesABI,
Expand All @@ -98,6 +100,7 @@ export default function parseTransactionReceipts(
});
break;
}

default:
assert(
false,
Expand Down

0 comments on commit 6156e39

Please sign in to comment.