diff --git a/src/services/ProjectService.ts b/src/services/ProjectService.ts index 55c9de0fd..de6d3b240 100644 --- a/src/services/ProjectService.ts +++ b/src/services/ProjectService.ts @@ -1,6 +1,5 @@ import logger from 'decentraland-gatsby/dist/entities/Development/logger' -import { DclData } from '../clients/DclData' import UnpublishedBidModel from '../entities/Bid/model' import { GrantTier } from '../entities/Grant/GrantTier' import { GRANT_PROPOSAL_DURATION_IN_SECONDS } from '../entities/Grant/constants' @@ -23,11 +22,12 @@ import { createProject } from '../utils/projects' import { BudgetService } from './BudgetService' import { ProposalInCreation } from './ProposalService' +import { VestingService } from './VestingService' export class ProjectService { public static async getProjects() { const data = await ProposalModel.getProjectList() - const vestings = await DclData.get().getVestings() + const vestings = await VestingService.getAllVestings() const projects: ProjectWithUpdate[] = [] await Promise.all( diff --git a/src/services/VestingService.ts b/src/services/VestingService.ts index 75713bfbd..ae6b3b3c1 100644 --- a/src/services/VestingService.ts +++ b/src/services/VestingService.ts @@ -1,6 +1,22 @@ +import { DclData, TransparencyVesting } from '../clients/DclData' import { VestingInfo, getVestingContractData } from '../clients/VestingData' +import CacheService, { TTL_24_HS } from './CacheService' + export class VestingService { + static async getAllVestings() { + const cacheKey = `vesting-data` + + const cachedData = CacheService.get(cacheKey) + if (cachedData) { + return cachedData + } + + const transparencyVestings = await DclData.get().getVestings() + CacheService.set(cacheKey, transparencyVestings, TTL_24_HS) + return transparencyVestings + } + static async getVestingInfo(addresses: string[]): Promise { const vestings = await Promise.all(addresses.map((address) => getVestingContractData(address)))