diff --git a/watcher/scripts/fetchMissingVAAs.ts b/watcher/scripts/fetchMissingVAAs.ts index bf309e74..afbc6f82 100644 --- a/watcher/scripts/fetchMissingVAAs.ts +++ b/watcher/scripts/fetchMissingVAAs.ts @@ -7,6 +7,7 @@ import { BigtableDatabase } from '../src/databases/BigtableDatabase'; import { makeSignedVAAsRowKey, parseMessageId } from '../src/databases/utils'; import { AXIOS_CONFIG_JSON, GUARDIAN_RPC_HOSTS } from '../src/consts'; import { parseVaa } from '@certusone/wormhole-sdk'; +import { Environment, getEnvironment } from '@wormhole-foundation/wormhole-monitor-common'; // This script checks for messages which don't have VAAs and attempts to fetch the VAAs from the guardians // This is useful for cases where the VAA doesn't exist in bigtable (perhaps due to an outage) but is available @@ -22,6 +23,7 @@ const missingVaas: { [id: string]: string | undefined } = {}; if (!bt.bigtable) { throw new Error('bigtable is undefined'); } + const environment: Environment = getEnvironment(); const now = Math.floor(Date.now() / 1000); try { let log = ora('Fetching messages without a signed VAA...').start(); @@ -37,7 +39,7 @@ const missingVaas: { [id: string]: string | undefined } = {}; const { chain, emitter, sequence } = parseMessageId(observedMessage.id); const id = makeSignedVAAsRowKey(chain, emitter, sequence.toString()); let vaaBytes: string | null = null; - for (const host of GUARDIAN_RPC_HOSTS) { + for (const host of GUARDIAN_RPC_HOSTS[environment]) { log.text = `Searching for VAA ${search}/${total} (${host})...`; try { const result = await axios.get( diff --git a/watcher/src/consts.ts b/watcher/src/consts.ts index 4daed0f9..d2333351 100644 --- a/watcher/src/consts.ts +++ b/watcher/src/consts.ts @@ -148,12 +148,16 @@ export const AXIOS_CONFIG_JSON: AxiosRequestConfig = { headers: { 'Accept-Encoding': 'application/json' }, }; -export const GUARDIAN_RPC_HOSTS = [ - 'https://api.wormholescan.io', - 'https://wormhole-v2-mainnet-api.mcf.rocks', - 'https://wormhole-v2-mainnet-api.chainlayer.network', - 'https://wormhole-v2-mainnet-api.staking.fund', -]; +export const GUARDIAN_RPC_HOSTS: { [key in Environment]: string[] } = { + ['mainnet']: [ + 'https://api.wormholescan.io', + 'https://wormhole-v2-mainnet-api.mcf.rocks', + 'https://wormhole-v2-mainnet-api.chainlayer.network', + 'https://wormhole-v2-mainnet-api.staking.fund', + ], + ['testnet']: ['https://api.testnet.wormholescan.io'], + ['devnet']: [], +}; export type AlgorandInfo = { appid: number; diff --git a/watcher/src/utils/getSignedVAA.ts b/watcher/src/utils/getSignedVAA.ts index 4a1ce875..77840808 100644 --- a/watcher/src/utils/getSignedVAA.ts +++ b/watcher/src/utils/getSignedVAA.ts @@ -1,12 +1,14 @@ import axios from 'axios'; import { AXIOS_CONFIG_JSON, GUARDIAN_RPC_HOSTS } from '../consts'; +import { Environment, getEnvironment } from '@wormhole-foundation/wormhole-monitor-common'; export const getSignedVAA = async ( chain: number, emitter: string, sequence: string ): Promise => { - for (const host of GUARDIAN_RPC_HOSTS) { + const environment: Environment = getEnvironment(); + for (const host of GUARDIAN_RPC_HOSTS[environment]) { try { const result = await axios.get( `${host}/v1/signed_vaa/${chain}/${emitter}/${sequence.toString()}`,