Skip to content

Commit fb77235

Browse files
committed
cloud_functions: more rework
1 parent 79eebdb commit fb77235

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

cloud_functions/src/computeMessageCountHistory.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { assertEnvironmentVariable } from './utils';
33
import { Firestore } from 'firebase-admin/firestore';
44
import { MessageCountsHistory } from './types';
55
import { deserialize } from '@wormhole-foundation/sdk-definitions';
6-
import { stringToChainId } from '@wormhole-foundation/wormhole-monitor-common';
6+
import { chainToChainId } from '@wormhole-foundation/sdk-base';
77

88
export async function computeMessageCountHistory(req: any, res: any) {
99
res.set('Access-Control-Allow-Origin', '*');
@@ -46,11 +46,7 @@ export async function computeMessageCountHistory(req: any, res: any) {
4646
continue;
4747
}
4848
const date = new Date(parsed.timestamp * 1000).toISOString().slice(0, 10);
49-
const chainId = stringToChainId(parsed.emitterChain);
50-
if (!chainId) {
51-
console.error(`Unknown emitter chain: ${parsed.emitterChain}`);
52-
continue;
53-
}
49+
const chainId = chainToChainId(parsed.emitterChain);
5450
messageCounts.DailyTotals[date] = {
5551
...messageCounts.DailyTotals[date],
5652
[chainId]: (messageCounts.DailyTotals[date]?.[chainId] || 0) + 1,

cloud_functions/src/consts.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { ChainId, toChainId } from '@wormhole-foundation/sdk-base';
1+
import { ChainId, chainToChainId } from '@wormhole-foundation/sdk-base';
22

33
// TODO: this should probably be a table in the database
44
export const TVL_TOKEN_DENYLIST: { [key in ChainId]?: string[] } = {
5-
[toChainId('Fantom')]: ['0x5b2af7fd27e2ea14945c82dd254c79d3ed34685e'], // coingecko reporting bad prices
5+
[chainToChainId('Fantom')]: ['0x5b2af7fd27e2ea14945c82dd254c79d3ed34685e'], // coingecko reporting bad prices
66
};
77

88
export const isTokenDenylisted = (chainId: ChainId, address: string): boolean => {

cloud_functions/src/getReobserveVaas.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Connection } from '@solana/web3.js';
2-
import { contracts, toChainId } from '@wormhole-foundation/sdk-base';
2+
import { chainToChainId, contracts } from '@wormhole-foundation/sdk-base';
33
import {
44
getNetwork,
55
isLegacyMessage,
@@ -114,7 +114,7 @@ async function getAndProcessReobsVAAs(): Promise<Map<string, ReobserveInfo>> {
114114
// So we put the rest back in the collection
115115
let solanaCount = 0;
116116
for (const vaa of vaas) {
117-
if (vaa.chain === toChainId('Solana')) {
117+
if (vaa.chain === chainToChainId('Solana')) {
118118
solanaCount++;
119119
if (solanaCount > MAX_SOLANA_VAAS_TO_REOBSERVE) {
120120
putBack.push(vaa);
@@ -143,7 +143,7 @@ async function getAndProcessReobsVAAs(): Promise<Map<string, ReobserveInfo>> {
143143
async function processVaa(vaa: ReobserveInfo): Promise<ReobserveInfo[] | null> {
144144
let vaas: ReobserveInfo[] = [];
145145

146-
if (vaa.chain === toChainId('Solana')) {
146+
if (vaa.chain === chainToChainId('Solana')) {
147147
const origTxHash = vaa.txhash;
148148
const convertedTxHash: string[] = await convertSolanaTxToAccts(origTxHash);
149149
console.log(`Converted solana txHash ${origTxHash} to account ${convertedTxHash}`);

0 commit comments

Comments
 (0)