From 6156e399a2b71aeded4e051316ffbc519771d393 Mon Sep 17 00:00:00 2001 From: Philip Paetz Date: Tue, 6 Aug 2024 10:34:45 +0200 Subject: [PATCH] fix: removed eslint-disable comment via assert statement --- src/index.ts | 20 +++++++++++--------- src/parse-transaction-receipts.ts | 9 ++++++--- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/index.ts b/src/index.ts index d3b0fd2..41518d2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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, @@ -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, diff --git a/src/parse-transaction-receipts.ts b/src/parse-transaction-receipts.ts index 9e2f0ae..d2f39c6 100644 --- a/src/parse-transaction-receipts.ts +++ b/src/parse-transaction-receipts.ts @@ -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 @@ -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, @@ -79,6 +80,7 @@ export default function parseTransactionReceipts( }); break; } + case EventType.MedianUpdated: { const event = decodeEventLog({ abi: SortedOraclesABI, @@ -98,6 +100,7 @@ export default function parseTransactionReceipts( }); break; } + default: assert( false,