Skip to content

Commit

Permalink
Fix: Extensions tracking loop using return instead of continue
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubcolony authored and rdig committed Jun 5, 2023
1 parent c43ecc3 commit 2bead94
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions src/trackExtensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
isExtensionDeprecated,
isExtensionInitialised,
mapLogToContractEvent,
output,
toNumber,
verbose,
writeExtensionFromEvent,
Expand All @@ -23,13 +24,13 @@ export default async (): Promise<void> => {

const trackingPromises = SUPPORTED_EXTENSION_IDS.map(
(extensionId) => async () => {
verbose(
output(
`Fetching current version of extension: ${extensionId} starting from block: ${latestBlock}`,
);

await trackExtensionAddedToNetwork(extensionId, latestBlock);

verbose(`Fetching events for extension: ${extensionId}`);
output(`Fetching events for extension: ${extensionId}`);
await trackExtensionEvents(extensionId, latestBlock);
},
);
Expand Down Expand Up @@ -106,9 +107,15 @@ const trackExtensionEvents = async (
}
});

for (const [colony, installationsCount] of Object.entries(
installedInColonyCount,
)) {
const installationsEntries = Object.entries(installedInColonyCount);
const coloniesCount = installationsEntries.length;
let currentColonyIndex = 0;
for (const [colony, installationsCount] of installationsEntries) {
currentColonyIndex++;
verbose(
`Processing extension events for colony ${colony} (${currentColonyIndex} out of ${coloniesCount})`,
);

/**
* If installation count is 0, that means the extension has been uninstalled
*/
Expand All @@ -125,20 +132,20 @@ const trackExtensionEvents = async (
!mostRecentUninstalledLog ||
mostRecentUninstalledLog.blockNumber < latestBlock
) {
return;
continue;
}

const event = await mapLogToContractEvent(
mostRecentUninstalledLog,
networkClient.interface,
);
if (!event) {
return;
continue;
}

await deleteExtensionFromEvent(event);

return;
continue;
}

// Otherwise, the extension is currently installed
Expand All @@ -156,15 +163,15 @@ const trackExtensionEvents = async (
colony,
);
if (!mostRecentInstalledLog) {
return;
continue;
}

const event = await mapLogToContractEvent(
mostRecentInstalledLog,
networkClient.interface,
);
if (!event) {
return;
continue;
}

/**
Expand Down

0 comments on commit 2bead94

Please sign in to comment.