Skip to content

Commit

Permalink
More info when RPC creation fails
Browse files Browse the repository at this point in the history
  • Loading branch information
Siegrift committed May 1, 2024
1 parent a464c57 commit 648d13c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 6 additions & 2 deletions src/update-feeds-loops/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { go } from '@api3/promise-utils';
import { ethers } from 'ethers';
import { zip } from 'lodash';

import { decodeDapiName } from '../utils';
import { logger } from '../logger';
import { decodeDapiName, sanitizeEthersError } from '../utils';

export const createProvider = async (chainId: string, chainAlias: string, providerUrl: string) => {
// Create a static network provider (bound to a specific network) to avoid the overhead of fetching the chain ID
Expand All @@ -24,7 +25,10 @@ export const createProvider = async (chainId: string, chainAlias: string, provid

// Make sure the RPC is working by making a call to get the chain ID.
const goChainId = await go(async () => provider.send('eth_chainId', []));
if (!goChainId.success) return null;
if (!goChainId.success) {
logger.warn('Failed to create provider. This is likely an RPC issue.', sanitizeEthersError(goChainId.error));
return null;
}

return provider;
};
Expand Down
6 changes: 2 additions & 4 deletions src/update-feeds-loops/update-feeds-loops.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,8 @@ export const runUpdateFeeds = async (providerName: string, chain: Chain, chainId

// Create a provider and connect it to the AirseekerRegistry contract.
const provider = await createProvider(chainId, alias, providers[providerName]!.url);
if (!provider) {
logger.warn('Failed to create provider. This is likely an RPC issue.');
return;
}
if (!provider) return;

const airseekerRegistry = getAirseekerRegistry(contracts.AirseekerRegistry, provider);

logger.debug(`Fetching first batch of data feeds batches.`);
Expand Down

0 comments on commit 648d13c

Please sign in to comment.