1
- import { ChainId , Network } from '@wormhole-foundation/sdk-base' ;
1
+ import { ChainId , Network , toChainId } from '@wormhole-foundation/sdk-base' ;
2
2
import {
3
3
MISS_THRESHOLD_IN_MINS ,
4
4
explorerBlock ,
@@ -92,7 +92,7 @@ export async function alarmMissingVaas(req: any, res: any) {
92
92
thePast . setMinutes ( now . getMinutes ( ) - MISS_THRESHOLD_IN_MINS ) ;
93
93
const missThreshold = thePast . toISOString ( ) ;
94
94
for ( const chain of Object . keys ( messages ) ) {
95
- const chainId = chain as unknown as ChainId ;
95
+ const chainId : ChainId = toChainId ( Number ( chain ) ) ;
96
96
const msgs = messages [ chainId ] ;
97
97
if ( msgs && msgs . messages ) {
98
98
for ( let i = 0 ; i < msgs . messages . length ; i ++ ) {
@@ -154,7 +154,7 @@ export async function alarmMissingVaas(req: any, res: any) {
154
154
return ;
155
155
}
156
156
157
- // This function gets all the enqueued VAAs from he governorStatus collection.
157
+ // This function gets all the enqueued VAAs from the governorStatus collection.
158
158
async function getGovernedVaas ( ) : Promise < GovernedVAAMap > {
159
159
const vaas : GovernedVAAMap = new Map < string , GovernedVAA > ( ) ;
160
160
// Walk all the guardians and retrieve the enqueued VAAs
@@ -292,8 +292,8 @@ function convert(msg: ObservedMessage): FirestoreVAA {
292
292
function formatMessage ( msg : ObservedMessage ) : string {
293
293
const cName : string = chainIdToName ( msg . chain ) ;
294
294
const vaaKeyUrl : string = `https://wormholescan.io/#/tx/${ msg . chain } /${ msg . emitter } /${ msg . seq } ` ;
295
- const txHashUrl : string = explorerTx ( network , msg . chain as ChainId , msg . txHash ) ;
296
- const blockUrl : string = explorerBlock ( network , msg . chain as ChainId , msg . block . toString ( ) ) ;
295
+ const txHashUrl : string = explorerTx ( network , toChainId ( msg . chain ) , msg . txHash ) ;
296
+ const blockUrl : string = explorerBlock ( network , toChainId ( msg . chain ) , msg . block . toString ( ) ) ;
297
297
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 } ` ;
298
298
return formattedMsg ;
299
299
}
@@ -310,7 +310,7 @@ async function getLastBlockTimeFromFirestore(): Promise<LatestTimeByChain> {
310
310
snapshot . docs
311
311
. sort ( ( a , b ) => Number ( a . id ) - Number ( b . id ) )
312
312
. forEach ( ( doc ) => {
313
- values [ Number ( doc . id ) as ChainId ] = { latestTime : doc . data ( ) . lastBlockKey . split ( '/' ) [ 1 ] } ;
313
+ values [ toChainId ( Number ( doc . id ) ) ] = { latestTime : doc . data ( ) . lastBlockKey . split ( '/' ) [ 1 ] } ;
314
314
} ) ;
315
315
} catch ( e ) {
316
316
console . error ( e ) ;
@@ -338,7 +338,7 @@ async function alarmOldBlockTimes(latestTimes: LatestTimeByChain): Promise<void>
338
338
// Walk all chains and check the latest block time.
339
339
const now = new Date ( ) ;
340
340
for ( const chain of Object . keys ( latestTimes ) ) {
341
- const chainId : ChainId = chain as any as ChainId ;
341
+ const chainId : ChainId = toChainId ( Number ( chain ) ) ;
342
342
const latestTime : string | undefined = latestTimes [ chainId ] ?. latestTime ;
343
343
if ( ! latestTime ) {
344
344
continue ;
0 commit comments