@@ -2,7 +2,12 @@ import { CHAIN_ID_TO_NAME, ChainId, ChainName } from '@certusone/wormhole-sdk';
2
2
import { MissingVaasByChain , commonGetMissingVaas } from './getMissingVaas' ;
3
3
import { assertEnvironmentVariable , formatAndSendToSlack , isVAASigned } from './utils' ;
4
4
import { ObservedMessage , ReobserveInfo , SlackInfo } from './types' ;
5
- import { NETWORK , explorerBlock , explorerTx } from '@wormhole-foundation/wormhole-monitor-common' ;
5
+ import {
6
+ Environment ,
7
+ getEnvironment ,
8
+ explorerBlock ,
9
+ explorerTx ,
10
+ } from '@wormhole-foundation/wormhole-monitor-common' ;
6
11
import { Firestore } from 'firebase-admin/firestore' ;
7
12
8
13
interface EnqueuedVAAResponse {
@@ -34,10 +39,7 @@ interface GovernedVAA {
34
39
// The key is the vaaKey
35
40
type GovernedVAAMap = Map < string , GovernedVAA > ;
36
41
37
- const network : NETWORK =
38
- assertEnvironmentVariable ( 'NETWORK' ) . toLowerCase ( ) === 'mainnet'
39
- ? NETWORK . MAINNET
40
- : NETWORK . TESTNET ;
42
+ const network : Environment = getEnvironment ( ) ;
41
43
42
44
export async function alarmMissingVaas ( req : any , res : any ) {
43
45
res . set ( 'Access-Control-Allow-Origin' , '*' ) ;
@@ -127,7 +129,7 @@ export async function alarmMissingVaas(req: any, res: any) {
127
129
txhash : msg . txHash ,
128
130
vaaKey : vaaKey ,
129
131
} ) ;
130
- if ( network === NETWORK . MAINNET ) {
132
+ if ( network === 'mainnet' ) {
131
133
alarmSlackInfo . msg = formatMessage ( msg ) ;
132
134
await formatAndSendToSlack ( alarmSlackInfo ) ;
133
135
}
@@ -323,7 +325,6 @@ async function alarmOldBlockTimes(latestTimes: LatestTimeByChain): Promise<void>
323
325
bannerTxt : 'Wormhole Missing VAA Alarm' ,
324
326
msg : '' ,
325
327
} ;
326
- const envNetwork : string = network === NETWORK . MAINNET ? 'mainnet' : 'testnet' ;
327
328
328
329
let alarmsToStore : AlarmedChainTime [ ] = [ ] ;
329
330
// Read in the already alarmed chains.
@@ -351,7 +352,7 @@ async function alarmOldBlockTimes(latestTimes: LatestTimeByChain): Promise<void>
351
352
const chainTime : Date = new Date ( latestTime ) ;
352
353
const cName : string = CHAIN_ID_TO_NAME [ chainId ] as ChainName ;
353
354
const deltaTime : number = ( now . getTime ( ) - chainTime . getTime ( ) ) / ( 1000 * 60 * 60 * 24 ) ;
354
- alarmSlackInfo . msg = `*Chain:* ${ cName } (${ chainId } )\nThe ${ envNetwork } watcher is behind by ${ deltaTime } days.` ;
355
+ alarmSlackInfo . msg = `*Chain:* ${ cName } (${ chainId } )\nThe ${ network } watcher is behind by ${ deltaTime } days.` ;
355
356
await formatAndSendToSlack ( alarmSlackInfo ) ;
356
357
alarmsToStore . push ( { chain : chainId , alarmTime : now . toISOString ( ) } ) ;
357
358
}
0 commit comments