Skip to content

Commit

Permalink
chore: Add missing 'resolver' to the wormhole recovery worker
Browse files Browse the repository at this point in the history
  • Loading branch information
jsanmigimeno committed Jul 19, 2024
1 parent b1aec2c commit 135ccd1
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/collector/wormhole/wormhole-recovery.worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
import { WormholeRecoveryWorkerData } from './wormhole.types';
import { JsonRpcProvider } from 'ethers6';
import { fetchVAAs } from './api-utils';
import { Resolver, loadResolver } from 'src/resolvers/resolver';

interface RecoveredVAAData {
vaa: ParsedVaaWithBytes,
Expand All @@ -34,6 +35,8 @@ class WormholeRecoveryWorker {

private readonly messageEscrowContract: IncentivizedMessageEscrow;

private readonly resolver: Resolver;

private readonly destinationImplementationCache: Record<string, Record<string, string>> = {}; // Map fromApplication + toChainId => destinationImplementation

constructor() {
Expand All @@ -47,6 +50,11 @@ class WormholeRecoveryWorker {
this.config.loggerOptions,
);
this.provider = this.initializeProvider(this.config.rpc);
this.resolver = this.loadResolver(
this.config.resolver,
this.provider,
this.logger
);
this.messageEscrowContract = this.initializeMessageEscrow(
this.config.incentivesAddress,
this.provider,
Expand All @@ -70,6 +78,14 @@ class WormholeRecoveryWorker {
return new JsonRpcProvider(rpc, undefined, { staticNetwork: true });
}

private loadResolver(
resolver: string | null,
provider: JsonRpcProvider,
logger: pino.Logger
): Resolver {
return loadResolver(resolver, provider, logger);
}

private initializeMessageEscrow(
incentivesAddress: string,
provider: JsonRpcProvider,
Expand Down Expand Up @@ -185,6 +201,10 @@ class WormholeRecoveryWorker {
);
}

const transactionBlockNumber = await this.resolver.getTransactionBlockNumber(
transactionBlockMetadata.blockNumber
);

const ambMessage: AMBMessage = {
messageIdentifier: decodedWormholeMessage.messageIdentifier,

Expand All @@ -197,7 +217,7 @@ class WormholeRecoveryWorker {
incentivesPayload: decodedWormholeMessage.payload,
recoveryContext: vaa.sequence.toString(),

// transactionBlockNumber: , //TODO add resolver and translate the block number
transactionBlockNumber,

transactionHash,
blockHash: transactionBlockMetadata.blockHash,
Expand Down

0 comments on commit 135ccd1

Please sign in to comment.