diff --git a/src/state/state.ts b/src/state/state.ts index 2f630ec2..4cd4f02d 100644 --- a/src/state/state.ts +++ b/src/state/state.ts @@ -2,7 +2,16 @@ import type { BigNumber } from 'ethers'; import { produce, type Draft } from 'immer'; import type { Config } from '../config/schema'; -import type { DapiName, PrivateKey, DecodedDataFeed, ChainId, SignedData, DataFeedId, ProviderName } from '../types'; +import type { + DapiName, + PrivateKey, + DecodedDataFeed, + ChainId, + SignedData, + DataFeedId, + ProviderName, + SignedApiUrl, +} from '../types'; interface GasState { gasPrices: { price: BigNumber; timestampMs: number }[]; @@ -32,7 +41,7 @@ export interface State { gasPriceStore: Record>; derivedSponsorWallets: Record; signedApiStore: Record; - signedApiUrlStore: Record>; + signedApiUrlStore: Record>; dapis: Record; } diff --git a/src/types.ts b/src/types.ts index 85a185c8..89d575c0 100644 --- a/src/types.ts +++ b/src/types.ts @@ -9,6 +9,7 @@ export type PrivateKey = string; export type DataFeedId = EvmId; export type ChainId = string; export type ProviderName = string; +export type SignedApiUrl = string; // Taken from https://github.com/api3dao/signed-api/blob/main/packages/api/src/schema.ts export const signedDataSchema = z.object({ diff --git a/src/update-feeds/update-feeds.ts b/src/update-feeds/update-feeds.ts index e0fce453..2bc12f05 100644 --- a/src/update-feeds/update-feeds.ts +++ b/src/update-feeds/update-feeds.ts @@ -187,7 +187,11 @@ export const getFeedsToUpdate = (batch: ReadDapiWithIndexResponse[]): Updateable }) .filter((updateableDapi): updateableDapi is UpdateableDapi => updateableDapi !== null); -export const processBatch = async (batch: ReadDapiWithIndexResponse[], providerName: ProviderName, chainId: string) => { +export const processBatch = async ( + batch: ReadDapiWithIndexResponse[], + providerName: ProviderName, + chainId: ChainId +) => { logger.debug('Processing batch of active dAPIs', { batch }); const { config: { sponsorWalletMnemonic, chains }, @@ -221,13 +225,13 @@ export const processBatch = async (batch: ReadDapiWithIndexResponse[], providerN // Clear last update timestamps for feeds that don't need an update for (const feed of batch) { - if (dapiNamesToUpdate.has(feed.dapiName)) continue; - - clearSponsorLastUpdateTimestampMs( - chainId, - providerName, - getDerivedSponsorWallet(sponsorWalletMnemonic, feed.dapiName).address - ); + if (!dapiNamesToUpdate.has(feed.dapiName)) { + clearSponsorLastUpdateTimestampMs( + chainId, + providerName, + getDerivedSponsorWallet(sponsorWalletMnemonic, feed.dapiName).address + ); + } } const updatedFeeds = await updateFeeds(