Skip to content

Commit

Permalink
Update cron-cache-gas-costs.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholaspai committed Jan 14, 2025
1 parent 7a5ec18 commit 88c9b7c
Showing 1 changed file with 20 additions and 22 deletions.
42 changes: 20 additions & 22 deletions api/cron-cache-gas-costs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,28 +164,26 @@ const handler = async (
// To circumvent this, we run the function in a loop and update gas prices every
// `secondsPerUpdateForChain` seconds and stop after `maxDurationSec` seconds (1 minute).
const cacheUpdatePromises = Promise.all([
Promise.all(
mainnetChains.map(async (chain) => {
const routesToChain = availableRoutes.filter(
({ destinationChainId }) => destinationChainId === chain.chainId
);
const outputTokensForChain = routesToChain.map(
({ destinationToken }) => destinationToken
);
await Promise.all([
Promise.all(
outputTokensForChain.map((outputToken) =>
updateNativeGasCostPromise(chain.chainId, outputToken)
)
),
Promise.all(
outputTokensForChain.map((outputToken) =>
updateL1DataFeePromise(chain.chainId, outputToken)
)
),
]);
})
),
mainnetChains.map(async (chain) => {
const routesToChain = availableRoutes.filter(
({ destinationChainId }) => destinationChainId === chain.chainId
);
const outputTokensForChain = routesToChain.map(
({ destinationToken }) => destinationToken
);
return Promise.all([
Promise.all(
outputTokensForChain.map((outputToken) =>
updateNativeGasCostPromise(chain.chainId, outputToken)
)
),
Promise.all(
outputTokensForChain.map((outputToken) =>
updateL1DataFeePromise(chain.chainId, outputToken)
)
),
]);
}),
]);

// The above promises are supposed to complete after maxDurationSec seconds, but there are so many of them
Expand Down

0 comments on commit 88c9b7c

Please sign in to comment.