Skip to content

Commit

Permalink
dashboard: update consts
Browse files Browse the repository at this point in the history
  • Loading branch information
panoel committed Jan 23, 2024
1 parent 919418a commit 2ee5f4a
Show file tree
Hide file tree
Showing 10 changed files with 568 additions and 287 deletions.
16 changes: 10 additions & 6 deletions cloud_functions/src/alarmMissingVaas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { CHAIN_ID_TO_NAME, ChainId, ChainName } from '@certusone/wormhole-sdk';
import { MissingVaasByChain, commonGetMissingVaas } from './getMissingVaas';
import { assertEnvironmentVariable, formatAndSendToSlack, isVAASigned } from './utils';
import { ObservedMessage, ReobserveInfo, SlackInfo } from './types';
import { explorerBlock, explorerTx } from '@wormhole-foundation/wormhole-monitor-common';
import { NETWORK, explorerBlock, explorerTx } from '@wormhole-foundation/wormhole-monitor-common';
import { Firestore } from 'firebase-admin/firestore';

interface EnqueuedVAAResponse {
Expand Down Expand Up @@ -122,8 +122,10 @@ export async function alarmMissingVaas(req: any, res: any) {
txhash: msg.txHash,
vaaKey: vaaKey,
});
alarmSlackInfo.msg = formatMessage(msg);
await formatAndSendToSlack(alarmSlackInfo);
if (assertEnvironmentVariable('NETWORK') === 'MAINNET') {
alarmSlackInfo.msg = formatMessage(msg);
await formatAndSendToSlack(alarmSlackInfo);
}
}
}
} else {
Expand Down Expand Up @@ -280,11 +282,12 @@ function convert(msg: ObservedMessage): FirestoreVAA {
}

function formatMessage(msg: ObservedMessage): string {
const network: NETWORK = assertEnvironmentVariable('NETWORK') ? NETWORK.MAINNET : NETWORK.TESTNET;
const cName: string = CHAIN_ID_TO_NAME[msg.chain as ChainId] as ChainName;
// const vaaKeyUrl: string = `https://wormhole.com/explorer/?emitterChain=${msg.chain}&emitterAddress=${msg.emitter}&sequence=${msg.seq}`;
const vaaKeyUrl: string = `https://wormholescan.io/#/tx/${msg.chain}/${msg.emitter}/${msg.seq}`;
const txHashUrl: string = explorerTx(msg.chain as ChainId, msg.txHash);
const blockUrl: string = explorerBlock(msg.chain as ChainId, msg.block.toString());
const txHashUrl: string = explorerTx(network, msg.chain as ChainId, msg.txHash);
const blockUrl: string = explorerBlock(network, msg.chain as ChainId, msg.block.toString());
const formattedMsg = `*Chain:* ${cName}(${msg.chain})\n*TxHash:* <${txHashUrl}|${msg.txHash}>\n*VAA Key:* <${vaaKeyUrl}|${msg.chain}/${msg.emitter}/${msg.seq}> \n*Block:* <${blockUrl}|${msg.block}> \n*Timestamp:* ${msg.timestamp}`;
return formattedMsg;
}
Expand Down Expand Up @@ -317,6 +320,7 @@ async function alarmOldBlockTimes(latestTimes: LatestTimeByChain): Promise<void>
bannerTxt: 'Wormhole Missing VAA Alarm',
msg: '',
};
const NETWORK: string = assertEnvironmentVariable('NETWORK');

let alarmsToStore: AlarmedChainTime[] = [];
// Read in the already alarmed chains.
Expand Down Expand Up @@ -344,7 +348,7 @@ async function alarmOldBlockTimes(latestTimes: LatestTimeByChain): Promise<void>
const chainTime: Date = new Date(latestTime);
const cName: string = CHAIN_ID_TO_NAME[chainId] as ChainName;
const deltaTime: number = (now.getTime() - chainTime.getTime()) / (1000 * 60 * 60 * 24);
alarmSlackInfo.msg = `*Chain:* ${cName}(${chainId})\nThe watcher is behind by ${deltaTime} days.`;
alarmSlackInfo.msg = `*Chain:* ${cName}(${chainId})\nThe ${NETWORK} watcher is behind by ${deltaTime} days.`;
await formatAndSendToSlack(alarmSlackInfo);
alarmsToStore.push({ chain: chainId, alarmTime: now.toISOString() });
}
Expand Down
Loading

0 comments on commit 2ee5f4a

Please sign in to comment.