@merkl/api 0.10.259 → 0.10.261

Sign up to get free protection for your applications and to get access to all the features.
@@ -130,11 +130,13 @@ declare const eden: {
130
130
  tags: string[];
131
131
  };
132
132
  }>>;
133
- get: (options?: {
133
+ get: (options: {
134
134
  headers?: Record<string, unknown> | undefined;
135
- query?: Record<string, unknown> | undefined;
135
+ query: {
136
+ test?: boolean | undefined;
137
+ };
136
138
  fetch?: RequestInit | undefined;
137
- } | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
139
+ }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
138
140
  200: {
139
141
  protocol?: {
140
142
  name: string;
@@ -547,6 +549,21 @@ declare const eden: {
547
549
  identifier: string;
548
550
  chainId: number;
549
551
  action: import("../../database/api/.generated").$Enums.OpportunityAction;
552
+ Campaigns: {
553
+ type: import("../../database/api/.generated").$Enums.CampaignType;
554
+ id: string;
555
+ params: import("database/api/.generated/runtime/library").JsonValue;
556
+ subType: number | null;
557
+ startTimestamp: bigint;
558
+ endTimestamp: bigint;
559
+ computeChainId: number;
560
+ distributionChainId: number;
561
+ campaignId: string;
562
+ rewardTokenId: string;
563
+ amount: string;
564
+ opportunityId: string;
565
+ creatorAddress: string;
566
+ }[];
550
567
  tvl: number;
551
568
  apr: number;
552
569
  dailyRewards: number;
@@ -2151,7 +2168,7 @@ declare const eden: {
2151
2168
  fetch?: RequestInit | undefined;
2152
2169
  }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
2153
2170
  200: (import("../modules/v4/claims").ClaimModel & {
2154
- token: import("../modules/v4").Token["model"] | null;
2171
+ token?: import("../modules/v4").Token["model"];
2155
2172
  })[];
2156
2173
  }>>;
2157
2174
  }) & {};
@@ -3135,6 +3152,21 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
3135
3152
  identifier: string;
3136
3153
  chainId: number;
3137
3154
  action: import("../../database/api/.generated").$Enums.OpportunityAction;
3155
+ Campaigns: {
3156
+ type: import("../../database/api/.generated").$Enums.CampaignType;
3157
+ id: string;
3158
+ params: import("database/api/.generated/runtime/library").JsonValue;
3159
+ subType: number | null;
3160
+ startTimestamp: bigint;
3161
+ endTimestamp: bigint;
3162
+ computeChainId: number;
3163
+ distributionChainId: number;
3164
+ campaignId: string;
3165
+ rewardTokenId: string;
3166
+ amount: string;
3167
+ opportunityId: string;
3168
+ creatorAddress: string;
3169
+ }[];
3138
3170
  tvl: number;
3139
3171
  apr: number;
3140
3172
  dailyRewards: number;
@@ -3180,7 +3212,9 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
3180
3212
  params: {
3181
3213
  id: string;
3182
3214
  };
3183
- query: unknown;
3215
+ query: {
3216
+ test?: boolean | undefined;
3217
+ };
3184
3218
  headers: unknown;
3185
3219
  response: {
3186
3220
  200: {
@@ -5471,7 +5505,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
5471
5505
  headers: unknown;
5472
5506
  response: {
5473
5507
  200: (import("../modules/v4/claims").ClaimModel & {
5474
- token: import("../modules/v4").Token["model"] | null;
5508
+ token?: import("../modules/v4").Token["model"];
5475
5509
  })[];
5476
5510
  };
5477
5511
  };
@@ -6441,11 +6475,13 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
6441
6475
  tags: string[];
6442
6476
  };
6443
6477
  }>>;
6444
- get: (options?: {
6478
+ get: (options: {
6445
6479
  headers?: Record<string, unknown> | undefined;
6446
- query?: Record<string, unknown> | undefined;
6480
+ query: {
6481
+ test?: boolean | undefined;
6482
+ };
6447
6483
  fetch?: RequestInit | undefined;
6448
- } | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
6484
+ }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
6449
6485
  200: {
6450
6486
  protocol?: {
6451
6487
  name: string;
@@ -6858,6 +6894,21 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
6858
6894
  identifier: string;
6859
6895
  chainId: number;
6860
6896
  action: import("../../database/api/.generated").$Enums.OpportunityAction;
6897
+ Campaigns: {
6898
+ type: import("../../database/api/.generated").$Enums.CampaignType;
6899
+ id: string;
6900
+ params: import("database/api/.generated/runtime/library").JsonValue;
6901
+ subType: number | null;
6902
+ startTimestamp: bigint;
6903
+ endTimestamp: bigint;
6904
+ computeChainId: number;
6905
+ distributionChainId: number;
6906
+ campaignId: string;
6907
+ rewardTokenId: string;
6908
+ amount: string;
6909
+ opportunityId: string;
6910
+ creatorAddress: string;
6911
+ }[];
6861
6912
  tvl: number;
6862
6913
  apr: number;
6863
6914
  dailyRewards: number;
@@ -8462,7 +8513,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
8462
8513
  fetch?: RequestInit | undefined;
8463
8514
  }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
8464
8515
  200: (import("../modules/v4/claims").ClaimModel & {
8465
- token: import("../modules/v4").Token["model"] | null;
8516
+ token?: import("../modules/v4").Token["model"];
8466
8517
  })[];
8467
8518
  }>>;
8468
8519
  }) & {};
@@ -337,6 +337,21 @@ declare const app: Elysia<"", false, {
337
337
  identifier: string;
338
338
  chainId: number;
339
339
  action: import("../database/api/.generated").$Enums.OpportunityAction;
340
+ Campaigns: {
341
+ type: import("../database/api/.generated").$Enums.CampaignType;
342
+ id: string;
343
+ params: import("database/api/.generated/runtime/library").JsonValue;
344
+ subType: number | null;
345
+ startTimestamp: bigint;
346
+ endTimestamp: bigint;
347
+ computeChainId: number;
348
+ distributionChainId: number;
349
+ campaignId: string;
350
+ rewardTokenId: string;
351
+ amount: string;
352
+ opportunityId: string;
353
+ creatorAddress: string;
354
+ }[];
340
355
  tvl: number;
341
356
  apr: number;
342
357
  dailyRewards: number;
@@ -382,7 +397,9 @@ declare const app: Elysia<"", false, {
382
397
  params: {
383
398
  id: string;
384
399
  };
385
- query: unknown;
400
+ query: {
401
+ test?: boolean | undefined;
402
+ };
386
403
  headers: unknown;
387
404
  response: {
388
405
  200: {
@@ -2673,7 +2690,7 @@ declare const app: Elysia<"", false, {
2673
2690
  headers: unknown;
2674
2691
  response: {
2675
2692
  200: (import("./modules/v4/claims").ClaimModel & {
2676
- token: import("./modules/v4").Token["model"] | null;
2693
+ token?: import("./modules/v4").Token["model"];
2677
2694
  })[];
2678
2695
  };
2679
2696
  };
@@ -25,7 +25,7 @@ export declare const ClaimController: Elysia<"/claims", false, {
25
25
  headers: unknown;
26
26
  response: {
27
27
  200: (import("./claims.model").ClaimModel & {
28
- token: import("..").Token["model"] | null;
28
+ token?: import("..").Token["model"];
29
29
  })[];
30
30
  };
31
31
  };
@@ -4,6 +4,6 @@ import type { UserUniqueModel } from "../user";
4
4
  import type { ClaimModel } from "./claims.model";
5
5
  export declare abstract class ClaimService {
6
6
  static getHistoricalClaims(params: UserUniqueModel, chainFilter?: ChainId[]): Promise<(ClaimModel & {
7
- token: Token["model"] | null;
7
+ token?: Token["model"];
8
8
  })[]>;
9
9
  }
@@ -25,11 +25,11 @@ export class ClaimService {
25
25
  .flatMap(p => p.value ?? []) // null/undefined claim arrays
26
26
  .filter(claim => {
27
27
  // Ensure the claim's token exists and matches the chainFilter
28
- const token = claim?.token ? tokens[claim.token.toLowerCase()] : null;
28
+ const token = claim?.token ? tokens[claim.token.toLowerCase()] : undefined;
29
29
  return token && (!chainFilter.length || chainFilter.includes(token.chainId));
30
30
  })
31
31
  .map(claim => {
32
- const token = claim?.token ? tokens[claim.token.toLowerCase()] : null;
32
+ const token = claim?.token ? tokens[claim.token.toLowerCase()] : undefined;
33
33
  return {
34
34
  ...claim,
35
35
  token,
@@ -206,6 +206,21 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
206
206
  identifier: string;
207
207
  chainId: number;
208
208
  action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
209
+ Campaigns: {
210
+ type: import("../../../../database/api/.generated").$Enums.CampaignType;
211
+ id: string;
212
+ params: import("database/api/.generated/runtime/library").JsonValue;
213
+ subType: number | null;
214
+ startTimestamp: bigint;
215
+ endTimestamp: bigint;
216
+ computeChainId: number;
217
+ distributionChainId: number;
218
+ campaignId: string;
219
+ rewardTokenId: string;
220
+ amount: string;
221
+ opportunityId: string;
222
+ creatorAddress: string;
223
+ }[];
209
224
  tvl: number;
210
225
  apr: number;
211
226
  dailyRewards: number;
@@ -251,7 +266,9 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
251
266
  params: {
252
267
  id: string;
253
268
  };
254
- query: unknown;
269
+ query: {
270
+ test?: boolean | undefined;
271
+ };
255
272
  headers: unknown;
256
273
  response: {
257
274
  200: {
@@ -2,7 +2,7 @@ import { HttpErrorDto, NotFoundError, NotFoundErrorDto } from "../../../errors";
2
2
  import { BackOfficeGuard } from "../../../guards/BackOffice.guard";
3
3
  import { AuthorizationHeadersDto, TokenAuthGuard } from "../../../guards/TokenAuth.guard";
4
4
  import Elysia, { t } from "elysia";
5
- import { CreateOpportunityDto, GetOpportunitiesQueryDto, OpportunityAggregateFieldDto, OpportunityIdDto, OpportunityResourceDto, OpportunityUniqueDto, OpportunityWithCampaignsResourceDto, UpdateOpportunityDto, } from "./opportunity.model";
5
+ import { CreateOpportunityDto, GetOpportunitiesQueryDto, GetOpportunityQueryDto, OpportunityAggregateFieldDto, OpportunityIdDto, OpportunityResourceDto, OpportunityUniqueDto, OpportunityWithCampaignsResourceDto, UpdateOpportunityDto, } from "./opportunity.model";
6
6
  import { OpportunityService } from "./opportunity.service";
7
7
  import { transformId } from "./transform-id.pipe";
8
8
  import { validateId } from "./validate-id.pipe";
@@ -59,16 +59,16 @@ export const OpportunityController = new Elysia({
59
59
  response: { 200: t.Number() },
60
60
  })
61
61
  // ─── Get An Opportunity By Id ────────────────────────────────────────
62
- .get("/:id", async ({ params }) => {
62
+ .get("/:id", async ({ params, query }) => {
63
63
  try {
64
64
  if (!params.id.includes("-"))
65
- return await OpportunityService.getUniqueOrThrow(params.id);
65
+ return await OpportunityService.getUniqueOrThrow(params.id, query.test ?? false);
66
66
  const [chainId, type, identifier] = params.id.split("-");
67
67
  return await OpportunityService.getUniqueOrThrow({
68
68
  chainId: +chainId,
69
69
  type: type,
70
70
  identifier,
71
- });
71
+ }, query.test ?? false);
72
72
  }
73
73
  catch (err) {
74
74
  if (err.code && err.code === "P2025")
@@ -77,6 +77,7 @@ export const OpportunityController = new Elysia({
77
77
  }
78
78
  }, {
79
79
  params: OpportunityUniqueDto,
80
+ query: GetOpportunityQueryDto,
80
81
  transform: transformId,
81
82
  beforeHandle: validateId,
82
83
  response: {
@@ -291,6 +291,9 @@ export declare const GetOpportunitiesQueryDto: import("@sinclair/typebox").TObje
291
291
  page: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
292
292
  items: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
293
293
  }>;
294
+ export declare const GetOpportunityQueryDto: import("@sinclair/typebox").TObject<{
295
+ test: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
296
+ }>;
294
297
  export declare const CreateOpportunityDto: import("@sinclair/typebox").TObject<{
295
298
  chainId: import("@sinclair/typebox").TNumber;
296
299
  type: import("@sinclair/typebox").TEnum<{
@@ -347,6 +350,7 @@ export declare const UpdateOpportunityDto: import("@sinclair/typebox").TObject<{
347
350
  tags: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
348
351
  }>;
349
352
  export type GetOpportunitiesQueryModel = typeof GetOpportunitiesQueryDto.static;
353
+ export type GetOpportunityQueryModel = typeof GetOpportunityQueryDto.static;
350
354
  export type CreateOpportunityModel = typeof CreateOpportunityDto.static & {
351
355
  id: string;
352
356
  };
@@ -70,6 +70,9 @@ export const GetOpportunitiesQueryDto = t.Object({
70
70
  page: t.Optional(t.Numeric({ description: "0-indexed page number", default: 0 })),
71
71
  items: t.Optional(t.Numeric({ description: "Number of items returned by page", default: 20 })), // items per page
72
72
  });
73
+ export const GetOpportunityQueryDto = t.Object({
74
+ test: t.Optional(t.Boolean({ description: "Include test campaigns" })),
75
+ });
73
76
  export const CreateOpportunityDto = t.Object({
74
77
  chainId: t.Number(),
75
78
  type: t.Enum(CampaignType),
@@ -168,12 +168,27 @@ export declare abstract class OpportunityRepository {
168
168
  apr: number;
169
169
  dailyRewards: number;
170
170
  }) | null>;
171
- static findUniqueOrThrow(id: string): Promise<{
171
+ static findUniqueOrThrow(id: string, withTest?: boolean): Promise<{
172
172
  Chain: {
173
173
  name: string;
174
174
  id: number;
175
175
  icon: string;
176
176
  };
177
+ Campaigns: {
178
+ type: import("../../../../database/api/.generated").$Enums.CampaignType;
179
+ id: string;
180
+ params: Prisma.JsonValue;
181
+ subType: number | null;
182
+ startTimestamp: bigint;
183
+ endTimestamp: bigint;
184
+ computeChainId: number;
185
+ distributionChainId: number;
186
+ campaignId: string;
187
+ rewardTokenId: string;
188
+ amount: string;
189
+ opportunityId: string;
190
+ creatorAddress: string;
191
+ }[];
177
192
  Tokens: {
178
193
  symbol: string;
179
194
  name: string | null;
@@ -6,7 +6,7 @@ import { ProtocolService } from "../protocol";
6
6
  import { RewardService } from "../reward";
7
7
  import { TvlService } from "../tvl";
8
8
  export class OpportunityRepository {
9
- static #getRecordInclusion() {
9
+ static #getRecordInclusion(withTest = true) {
10
10
  return {
11
11
  AprRecords: {
12
12
  take: 1,
@@ -23,6 +23,11 @@ export class OpportunityRepository {
23
23
  orderBy: { timestamp: "desc" },
24
24
  include: {
25
25
  DailyRewardsBreakdown: {
26
+ where: {
27
+ Campaign: {
28
+ RewardToken: { isTest: withTest },
29
+ },
30
+ },
26
31
  include: {
27
32
  Campaign: {
28
33
  select: {
@@ -120,14 +125,23 @@ export class OpportunityRepository {
120
125
  where: { id },
121
126
  });
122
127
  }
123
- static async findUniqueOrThrow(id) {
128
+ static async findUniqueOrThrow(id, withTest = true) {
124
129
  return await apiDbClient.opportunity.findUniqueOrThrow({
125
130
  include: {
126
- ...OpportunityRepository.#getRecordInclusion(),
131
+ ...OpportunityRepository.#getRecordInclusion(withTest),
127
132
  Chain: true,
128
133
  MainProtocol: true,
129
134
  Protocols: true,
130
135
  Tokens: true,
136
+ Campaigns: withTest
137
+ ? undefined
138
+ : {
139
+ where: {
140
+ RewardToken: {
141
+ isTest: false,
142
+ },
143
+ },
144
+ },
131
145
  },
132
146
  where: { id },
133
147
  });
@@ -241,7 +255,7 @@ export class OpportunityRepository {
241
255
  take: items,
242
256
  skip: page * items,
243
257
  include: {
244
- ...OpportunityRepository.#getRecordInclusion(),
258
+ ...OpportunityRepository.#getRecordInclusion(test),
245
259
  MainProtocol: true,
246
260
  Chain: true,
247
261
  Protocols: true,
@@ -1,9 +1,10 @@
1
1
  import { type CreateCampaignModel } from "../campaign";
2
2
  import { Prisma } from "../../../../database/api/.generated";
3
3
  import type { ChainId, MerklChainId } from "@sdk";
4
- import type { CreateOpportunityModel, GetOpportunitiesQueryModel, LightOpportunityFromDB, OpportunityMetadata, OpportunityResourceModel, OpportunityUnique, OpportunityWithCampaignsResourceModel, UpdateOpportunityModel } from "./opportunity.model";
4
+ import type { CreateOpportunityModel, GetOpportunitiesQueryModel, LightOpportunityFromDB, OpportunityResourceModel, OpportunityUnique, OpportunityWithCampaignsResourceModel, UpdateOpportunityModel } from "./opportunity.model";
5
5
  import { OpportunityRepository } from "./opportunity.repository";
6
6
  export declare abstract class OpportunityService {
7
+ #private;
7
8
  static hashId(opportunity: OpportunityUnique): string;
8
9
  /**
9
10
  * create an opportunity without campaigns
@@ -78,15 +79,9 @@ export declare abstract class OpportunityService {
78
79
  depositUrl: any;
79
80
  tags: string[];
80
81
  }>;
81
- /**
82
- * build/fetch metadata of a campaign's opportunity
83
- * @param campaign
84
- * @returns {OpportunityMetadata}
85
- */
86
- static getMetadata(campaign: Omit<CreateCampaignModel, "id">): Promise<OpportunityMetadata>;
87
82
  static updateMetadata(chain: ChainId): Promise<void>;
88
83
  static getUniqueWithCampaignsOrThrow(opportunityId: string | OpportunityUnique): Promise<OpportunityWithCampaignsResourceModel>;
89
- static getUniqueOrThrow(opportunityId: string | OpportunityUnique): Promise<OpportunityResourceModel>;
84
+ static getUniqueOrThrow(opportunityId: string | OpportunityUnique, withTest?: boolean): Promise<OpportunityResourceModel>;
90
85
  /**
91
86
  * Get the list of opportunities satisfying the query
92
87
  * @param query
@@ -176,6 +171,21 @@ export declare abstract class OpportunityService {
176
171
  identifier: string;
177
172
  chainId: number;
178
173
  action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
174
+ Campaigns: {
175
+ type: import("../../../../database/api/.generated").$Enums.CampaignType;
176
+ id: string;
177
+ params: Prisma.JsonValue;
178
+ subType: number | null;
179
+ startTimestamp: bigint;
180
+ endTimestamp: bigint;
181
+ computeChainId: number;
182
+ distributionChainId: number;
183
+ campaignId: string;
184
+ rewardTokenId: string;
185
+ amount: string;
186
+ opportunityId: string;
187
+ creatorAddress: string;
188
+ }[];
179
189
  tvl: number;
180
190
  apr: number;
181
191
  dailyRewards: number;
@@ -264,6 +274,21 @@ export declare abstract class OpportunityService {
264
274
  identifier: string;
265
275
  chainId: number;
266
276
  action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
277
+ Campaigns: {
278
+ type: import("../../../../database/api/.generated").$Enums.CampaignType;
279
+ id: string;
280
+ params: Prisma.JsonValue;
281
+ subType: number | null;
282
+ startTimestamp: bigint;
283
+ endTimestamp: bigint;
284
+ computeChainId: number;
285
+ distributionChainId: number;
286
+ campaignId: string;
287
+ rewardTokenId: string;
288
+ amount: string;
289
+ opportunityId: string;
290
+ creatorAddress: string;
291
+ }[];
267
292
  tvl: number;
268
293
  apr: number;
269
294
  dailyRewards: number;
@@ -409,6 +434,21 @@ export declare abstract class OpportunityService {
409
434
  identifier: string;
410
435
  chainId: number;
411
436
  action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
437
+ Campaigns: {
438
+ type: import("../../../../database/api/.generated").$Enums.CampaignType;
439
+ id: string;
440
+ params: Prisma.JsonValue;
441
+ subType: number | null;
442
+ startTimestamp: bigint;
443
+ endTimestamp: bigint;
444
+ computeChainId: number;
445
+ distributionChainId: number;
446
+ campaignId: string;
447
+ rewardTokenId: string;
448
+ amount: string;
449
+ opportunityId: string;
450
+ creatorAddress: string;
451
+ }[];
412
452
  tvl: number;
413
453
  apr: number;
414
454
  dailyRewards: number;
@@ -449,6 +489,21 @@ export declare abstract class OpportunityService {
449
489
  identifier: string;
450
490
  chainId: number;
451
491
  action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
492
+ Campaigns: {
493
+ type: import("../../../../database/api/.generated").$Enums.CampaignType;
494
+ id: string;
495
+ params: Prisma.JsonValue;
496
+ subType: number | null;
497
+ startTimestamp: bigint;
498
+ endTimestamp: bigint;
499
+ computeChainId: number;
500
+ distributionChainId: number;
501
+ campaignId: string;
502
+ rewardTokenId: string;
503
+ amount: string;
504
+ opportunityId: string;
505
+ creatorAddress: string;
506
+ }[];
452
507
  tvl: number;
453
508
  apr: number;
454
509
  dailyRewards: number;
@@ -34,9 +34,56 @@ export class OpportunityService {
34
34
  const id = OpportunityService.hashId(newOpp);
35
35
  return await OpportunityRepository.create({ ...newOpp, id });
36
36
  }
37
+ /**
38
+ * build/fetch metadata of a campaign's opportunity
39
+ * @param campaign
40
+ * @returns {OpportunityMetadata}
41
+ */
42
+ static async #getMetadata(campaign) {
43
+ const campaignType = CampaignService.getTypeFromV3(campaign.type);
44
+ const campaignParams = JSON.parse(campaign.params);
45
+ const chainId = campaign.computeChainId === 0 ? campaign.chainId : campaign.computeChainId;
46
+ switch (campaignType) {
47
+ case "CLAMM":
48
+ return getClammMetadata(chainId, campaignParams);
49
+ case "ERC20":
50
+ return getErc20Metadata(chainId, campaign.chainId, // distributionChainId
51
+ campaign.campaignId, campaign.rewardTokenAddress, campaign.amount, campaignParams);
52
+ case "ERC20_SNAPSHOT":
53
+ return getErc20SnapshotMetadata(chainId, campaignParams);
54
+ case "JSON_AIRDROP":
55
+ return getJsonAirdropMetadata(chainId, campaign.creator, campaignParams);
56
+ case "SILO":
57
+ return getSiloMetadata(chainId, campaign.subType, campaignParams);
58
+ case "RADIANT":
59
+ return getRadiantMetadata(chainId, campaign.subType, campaignParams);
60
+ case "MORPHO":
61
+ return getMorphoMetadata(chainId, campaign.subType, campaignParams);
62
+ case "DOLOMITE":
63
+ return getDolomiteMetadata(chainId, campaign.subType, campaignParams);
64
+ case "BADGER":
65
+ return getBadgerMetadata(chainId, campaignParams);
66
+ case "COMPOUND":
67
+ return getCompoundMetadata(chainId, campaign.subType, campaignParams);
68
+ case "AJNA":
69
+ return getAjnaMetadata(chainId, campaign.subType, campaignParams);
70
+ case "EIGENLAYER":
71
+ return getEigenLayerMetadata(chainId, campaignParams);
72
+ case "EULER":
73
+ return getEulerMetadata(chainId, campaign.campaignId, campaign.subType, campaign.rewardTokenAddress, campaign.amount, campaignParams);
74
+ case "INVALID":
75
+ return {
76
+ name: "Invalid Campaigns",
77
+ action: OpportunityAction.INVALID,
78
+ tokens: [],
79
+ };
80
+ default:
81
+ throw "UNKNOWN CAMPAIGN TYPE";
82
+ }
83
+ }
37
84
  static async createFromCampaign(campaign, upsert = false) {
38
85
  const campaignType = CampaignService.getTypeFromV3(campaign.type);
39
- const metadata = await OpportunityService.getMetadata(campaign);
86
+ const metadata = await OpportunityService.#getMetadata(campaign);
40
87
  metadata.tags = [...((await UserService.findUnique(campaign.creator))?.tags ?? []), ...(campaign?.tags ?? [])];
41
88
  const opportunityId = OpportunityService.hashId({
42
89
  chainId: campaign.computeChainId,
@@ -89,53 +136,6 @@ export class OpportunityService {
89
136
  }, true // Upserting
90
137
  );
91
138
  }
92
- /**
93
- * build/fetch metadata of a campaign's opportunity
94
- * @param campaign
95
- * @returns {OpportunityMetadata}
96
- */
97
- static async getMetadata(campaign) {
98
- const campaignType = CampaignService.getTypeFromV3(campaign.type);
99
- const campaignParams = JSON.parse(campaign.params);
100
- const chainId = campaign.computeChainId === 0 ? campaign.chainId : campaign.computeChainId;
101
- switch (campaignType) {
102
- case "CLAMM":
103
- return getClammMetadata(chainId, campaignParams);
104
- case "ERC20":
105
- return getErc20Metadata(chainId, campaign.chainId, // distributionChainId
106
- campaign.campaignId, campaign.rewardTokenAddress, campaign.amount, campaignParams);
107
- case "ERC20_SNAPSHOT":
108
- return getErc20SnapshotMetadata(chainId, campaignParams);
109
- case "JSON_AIRDROP":
110
- return getJsonAirdropMetadata(chainId, campaign.creator, campaignParams);
111
- case "SILO":
112
- return getSiloMetadata(chainId, campaign.subType, campaignParams);
113
- case "RADIANT":
114
- return getRadiantMetadata(chainId, campaign.subType, campaignParams);
115
- case "MORPHO":
116
- return getMorphoMetadata(chainId, campaign.subType, campaignParams);
117
- case "DOLOMITE":
118
- return getDolomiteMetadata(chainId, campaign.subType, campaignParams);
119
- case "BADGER":
120
- return getBadgerMetadata(chainId, campaignParams);
121
- case "COMPOUND":
122
- return getCompoundMetadata(chainId, campaign.subType, campaignParams);
123
- case "AJNA":
124
- return getAjnaMetadata(chainId, campaign.subType, campaignParams);
125
- case "EIGENLAYER":
126
- return getEigenLayerMetadata(chainId, campaignParams);
127
- case "EULER":
128
- return getEulerMetadata(chainId, campaign.campaignId, campaign.subType, campaign.rewardTokenAddress, campaign.amount, campaignParams);
129
- case "INVALID":
130
- return {
131
- name: "Invalid Campaigns",
132
- action: OpportunityAction.INVALID,
133
- tokens: [],
134
- };
135
- default:
136
- throw "UNKNOWN CAMPAIGN TYPE";
137
- }
138
- }
139
139
  static async updateMetadata(chain) {
140
140
  try {
141
141
  const opportunities = await OpportunityRepository.findManyWithCampaigns({
@@ -163,9 +163,9 @@ export class OpportunityService {
163
163
  const formatted = OpportunityService.formatResponse(opportunity);
164
164
  return Object.assign(formatted, { campaigns: Campaigns.map(CampaignService.format) });
165
165
  }
166
- static async getUniqueOrThrow(opportunityId) {
166
+ static async getUniqueOrThrow(opportunityId, withTest = false) {
167
167
  const id = typeof opportunityId === "string" ? opportunityId : OpportunityService.hashId(opportunityId);
168
- const opportunity = await OpportunityRepository.findUniqueOrThrow(id);
168
+ const opportunity = await OpportunityRepository.findUniqueOrThrow(id, withTest);
169
169
  return OpportunityService.formatResponse(opportunity);
170
170
  }
171
171
  /**