Skip to content

Commit

Permalink
fix: Wormhole recovery api endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
jsanmigimeno committed May 21, 2024
1 parent 2c5e0f0 commit a9c4006
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/collector/wormhole/api-utils.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import pino from "pino";
import { wait } from "src/common/utils";

export const WORMHOLESCAN_API_ENDPOINT = 'https://api.testnet.wormholescan.io';
export const WORMHOLESCAN_API_ENDPOINT = 'https://api.wormholescan.io';
export const WORMHOLESCAN_API_ENDPOINT_TESTNET = 'https://api.testnet.wormholescan.io';

export async function fetchVAAs(
womrholeChainId: number,
emitterAddress: string,
isTestnet: boolean,
pageIndex: number,
logger: pino.Logger,
pageSize = 1000,
Expand All @@ -14,8 +16,9 @@ export async function fetchVAAs(
): Promise<any[]> {
for (let tryCount = 0; tryCount < maxTries; tryCount++) {
try {
const apiEndpoint = isTestnet ? WORMHOLESCAN_API_ENDPOINT_TESTNET : WORMHOLESCAN_API_ENDPOINT;
const response = await fetch(
`${WORMHOLESCAN_API_ENDPOINT}/api/v1/vaas/${womrholeChainId}/${emitterAddress}?page=${pageIndex}&pageSize=${pageSize}`,
`${apiEndpoint}/api/v1/vaas/${womrholeChainId}/${emitterAddress}?page=${pageIndex}&pageSize=${pageSize}`,
);

const body = await response.text();
Expand Down
1 change: 1 addition & 0 deletions src/collector/wormhole/wormhole-engine.worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ class WormholeEngineWorker {
const mostRecentVAAs = await fetchVAAs(
wormholeChainId,
wormholeConfig.incentivesAddress,
this.config.isTestnet,
0,
this.logger,
1,
Expand Down
1 change: 1 addition & 0 deletions src/collector/wormhole/wormhole-recovery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function loadRecoveryWorkerData(
}

return {
isTestnet: wormholeConfig.isTestnet,
...wormholeChainConfig,
startingBlock,
wormholeChainIdMap: wormholeConfig.wormholeChainIdMap,
Expand Down
1 change: 1 addition & 0 deletions src/collector/wormhole/wormhole-recovery.worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ class WormholeRecoveryWorker {
const pageVAAs: any[] = await fetchVAAs(
womrholeChainId,
emitterAddress,
this.config.isTestnet,
pageIndex,
this.logger,
pageSize,
Expand Down
1 change: 1 addition & 0 deletions src/collector/wormhole/wormhole.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export interface WormholeMessageSnifferWorkerData extends WormholeChainConfig {
}

export interface WormholeRecoveryWorkerData extends WormholeChainConfig {
isTestnet: boolean;
startingBlock: number;
wormholeChainIdMap: Map<WormholeChainId, string>;
loggerOptions: LoggerOptions;
Expand Down

0 comments on commit a9c4006

Please sign in to comment.