Skip to content

Commit 5669cea

Browse files
committed
Make nested lookup in gas-price.ts safer
1 parent 46367c8 commit 5669cea

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/gas-price/gas-price.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ethers } from 'ethers';
2+
import { get } from 'lodash';
23

34
import type { GasSettings } from '../config/schema';
45
import { getState, setState } from '../state';
@@ -130,7 +131,12 @@ export const clearSponsorLastUpdateTimestampMs = (
130131
) => {
131132
const state = getState();
132133

133-
if (state.gasPriceStore[chainId]![providerName]!.sponsorLastUpdateTimestampMs[sponsorWalletAddress]) {
134+
const sponsorLastUpdateTimestampMs = get(
135+
state,
136+
`gasPriceStore[${chainId}][${providerName}].sponsorLastUpdateTimestampMs[${sponsorWalletAddress}]`
137+
);
138+
139+
if (sponsorLastUpdateTimestampMs) {
134140
const { [sponsorWalletAddress]: _value, ...sponsorLastUpdateTimestampMs } =
135141
state.gasPriceStore[chainId]![providerName]!.sponsorLastUpdateTimestampMs;
136142

src/update-feeds/update-feeds.ts

+2
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ export const processBatch = async (batch: ReadDapiWithIndexResponsesAndChainId)
220220
// });
221221
// });
222222

223+
// clearSponsorLastUpdateTimestampMs();
224+
223225
const feedsToUpdate = allFeeds.filter((feed) => feed.shouldUpdate);
224226

225227
return Promise.allSettled(chunk(feedsToUpdate, FEEDS_TO_UPDATE_CHUNK_SIZE).map(async (feed) => updateFeeds(feed)));

0 commit comments

Comments
 (0)