diff --git a/src/loaders/subscribers.ts b/src/loaders/subscribers.ts index 33da67011..c252f1354 100644 --- a/src/loaders/subscribers.ts +++ b/src/loaders/subscribers.ts @@ -12,7 +12,14 @@ import CommunityService from '../services/community'; export default async (): Promise => { const provider = new ethers.providers.JsonRpcProvider(config.jsonRpcUrl); const startFrom = await startFromBlock(provider, config.impactMarketContractBlockNumber); - await updateImpactMarketCache(provider, startFrom); + const fromLogs = await updateImpactMarketCache(provider, startFrom); + fromLogs.forEach((community) => updateCommunityCache( + community.block === undefined + ? startFrom + : community.block, + provider, + community.address + )); // Because we are filtering events by address // when the community is created, the first coordinator // is actually added by impactmarket in an internal transaction. diff --git a/src/subscribers/index.ts b/src/subscribers/index.ts index 0d16b1de9..64fbe56b5 100644 --- a/src/subscribers/index.ts +++ b/src/subscribers/index.ts @@ -133,7 +133,7 @@ async function subscribeChainEvents( ) => { addToTransactionCache(event); // it's necessary to get CoordinatorAdded here! - updateCommunityCache(event.blockNumber - 1, provider, config.impactMarketContractAddress); + updateCommunityCache(event.blockNumber - 1, provider, _addr); communitiesCallbackFn(_addr); }); impactMarketInstance.on('CommunityRemoved', async (_addr, event) => addToTransactionCache(event)); @@ -182,7 +182,7 @@ async function updateImpactMarketCache( return communitiesAdded; } -async function updateCommunityCache( +function updateCommunityCache( startFromBlock: number, provider: ethers.providers.JsonRpcProvider, contractAddress: string,