Skip to content

Commit

Permalink
Make gateway optional
Browse files Browse the repository at this point in the history
  • Loading branch information
mj52951 committed Jul 11, 2024
1 parent 7f288dc commit 507c5e1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export type DomainConfig = {

export type ProcessorConfig = {
contractAddress: string;
gateway: string;
gateway?: string;
rpcURL: string;
startBlock: number;
numberOfConfirmations: number;
Expand Down Expand Up @@ -87,12 +87,13 @@ export type RpcUrlConfig = Array<{
export function getProcessorConfig(): ProcessorConfig {
const processorConfig: ProcessorConfig = {
contractAddress: process.env.DOMAIN_BRIDGE_ADDRESS!,
gateway: process.env.DOMAIN_GATEWAY!,
gateway: process.env.DOMAIN_GATEWAY || "",
rpcURL: process.env.RPC_URL!,
numberOfConfirmations: Number(process.env.DOMAIN_CONFIRMATIONS),
startBlock: Number(process.env.START_BLOCK!),
};
validateConfig(processorConfig);
const { gateway, ...requiredConfig } = processorConfig;
validateConfig(requiredConfig);
return processorConfig;
}

Expand Down
8 changes: 6 additions & 2 deletions src/evmProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ export async function startEvmProcessing(
}

function getEvmProcessor(processorConfig: ProcessorConfig): EvmBatchProcessor {
return new EvmBatchProcessor()
.setGateway(processorConfig.gateway)
const evmProcessor = new EvmBatchProcessor()
.setRpcEndpoint({
url: processorConfig.rpcURL,
rateLimit: 10,
Expand All @@ -131,6 +130,11 @@ function getEvmProcessor(processorConfig: ProcessorConfig): EvmBatchProcessor {
topic0: [bridge.events.FailedHandlerExecution.topic],
transaction: true,
});

if (processorConfig.gateway && processorConfig.gateway.trim() !== "") {
evmProcessor.setGateway(processorConfig.gateway);
}
return evmProcessor;
}

export type Fields = EvmBatchProcessorFields<typeof processor>;
Expand Down

0 comments on commit 507c5e1

Please sign in to comment.