Skip to content

Commit

Permalink
fix store last blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
vrtnd committed Jun 18, 2024
1 parent 31af132 commit df5128e
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/handlers/runAllAdapters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,19 @@ export default wrapScheduledLambda(async (_event) => {
) subquery;
`;
try {
await store("lastRecordedBlocks.json", JSON.stringify(lastRecordedBlocks[0].result));
const bridgeConfig = await sql`SELECT * FROM bridges.config`;

const bridgeConfigById = bridgeConfig.reduce((acc: any, config: any) => {
acc[config.id] = config;
return acc;
}, {});

const lastBlocksByName = Object.keys(lastRecordedBlocks).reduce((acc: any, bridgeId: any) => {
acc[`${bridgeConfigById[bridgeId].bridge_name}-${bridgeConfigById[bridgeId].chain}`] =
lastRecordedBlocks[bridgeId];
return acc;
}, {});
await store("lastRecordedBlocks.json", JSON.stringify(lastBlocksByName));
console.log("Stored last recorded blocks");
} catch (e) {
console.error("Failed to store last recorded blocks");
Expand Down

0 comments on commit df5128e

Please sign in to comment.