@merkl/api 0.20.34 → 0.20.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/modules/v4/chain/chain.service.js +3 -1
- package/dist/src/modules/v4/opportunity/opportunity.service.js +4 -2
- package/dist/src/modules/v4/protocol/protocol.service.d.ts +1 -0
- package/dist/src/modules/v4/protocol/protocol.service.js +13 -10
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +1 -1
@@ -6,8 +6,10 @@ export class ChainService {
|
|
6
6
|
static async get(chainId) {
|
7
7
|
return ChainRepository.read(chainId);
|
8
8
|
}
|
9
|
-
//TODO: determine find vs get nomenclature and cache handling
|
10
9
|
static async findMany(query) {
|
10
|
+
// Bypass cache in test mode
|
11
|
+
if (query.test)
|
12
|
+
return ChainRepository.findMany(query);
|
11
13
|
return await CacheService.wrap(TTLPresets.MIN_10, ChainRepository.findMany, query);
|
12
14
|
}
|
13
15
|
static async countMany(query) {
|
@@ -166,9 +166,11 @@ export class OpportunityService {
|
|
166
166
|
* @returns A list of opportunities
|
167
167
|
*/
|
168
168
|
static async findMany(query) {
|
169
|
+
// Bypass cache in test mode
|
170
|
+
if (query.test)
|
171
|
+
return (await OpportunityRepository.findMany(query)).map(c => OpportunityService.formatResponse(c));
|
169
172
|
return await CacheService.wrap(TTLPresets.MIN_5, async (query) => {
|
170
|
-
|
171
|
-
return opportunities.map(c => OpportunityService.formatResponse(c));
|
173
|
+
return (await OpportunityRepository.findMany(query)).map(c => OpportunityService.formatResponse(c));
|
172
174
|
}, query);
|
173
175
|
}
|
174
176
|
/**
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import type { CreateProtocolModel, GetProtocolsQueryModel, Protocol, ProtocolId, UpdateProtocolModel } from "./protocol.model";
|
2
2
|
export declare abstract class ProtocolService {
|
3
|
+
#private;
|
3
4
|
static findMany(query: GetProtocolsQueryModel): Promise<Protocol["model"][]>;
|
4
5
|
static countMany(query: GetProtocolsQueryModel): Promise<number>;
|
5
6
|
static getFromId(id: ProtocolId | string): Promise<Protocol["model"] | null>;
|
@@ -6,17 +6,20 @@ import { TTLPresets } from "../cache/cache.model";
|
|
6
6
|
import { ProtocolRepository } from "./protocol.repository";
|
7
7
|
// ─── Protocols Services ──────────────────────────────────────────────────────
|
8
8
|
export class ProtocolService {
|
9
|
+
static async #findMany(query) {
|
10
|
+
const protocols = await ProtocolRepository.findMany(query);
|
11
|
+
const enrichedProtocols = protocols.map(({ MainOpportunities, ...protocol }) => ({
|
12
|
+
...protocol,
|
13
|
+
dailyRewards: MainOpportunities.reduce((sum, opportunity) => sum + opportunity.dailyRewards, 0),
|
14
|
+
numberOfLiveCampaigns: MainOpportunities.reduce((sum, opportunity) => sum + opportunity.Campaigns.length, 0),
|
15
|
+
opportunityLiveTags: [...new Set(MainOpportunities.flatMap(opportunity => opportunity.action))], // ensure uniqness of tags
|
16
|
+
}));
|
17
|
+
return enrichedProtocols;
|
18
|
+
}
|
9
19
|
static async findMany(query) {
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
...protocol,
|
14
|
-
dailyRewards: MainOpportunities.reduce((sum, opportunity) => sum + opportunity.dailyRewards, 0),
|
15
|
-
numberOfLiveCampaigns: MainOpportunities.reduce((sum, opportunity) => sum + opportunity.Campaigns.length, 0),
|
16
|
-
opportunityLiveTags: [...new Set(MainOpportunities.flatMap(opportunity => opportunity.action))], // ensure uniqness of tags
|
17
|
-
}));
|
18
|
-
return enrichedProtocols;
|
19
|
-
}, query);
|
20
|
+
if (query.test)
|
21
|
+
return await ProtocolRepository.findMany(query);
|
22
|
+
return await CacheService.wrap(TTLPresets.MIN_10, ProtocolService.#findMany, query);
|
20
23
|
}
|
21
24
|
static async countMany(query) {
|
22
25
|
return ProtocolRepository.countMany(query);
|