@merkl/api 0.15.36 → 0.15.38

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.
@@ -2683,7 +2683,7 @@ declare const eden: {
2683
2683
  }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
2684
2684
  200: {
2685
2685
  delay: number;
2686
- delayFormatted: string;
2686
+ computedUntil: bigint;
2687
2687
  startTimestamp: bigint;
2688
2688
  endTimestamp: bigint;
2689
2689
  CampaignStatus: {
@@ -2696,6 +2696,7 @@ declare const eden: {
2696
2696
  }[];
2697
2697
  Opportunity: {
2698
2698
  name: string;
2699
+ id: string;
2699
2700
  };
2700
2701
  computeChainId: number;
2701
2702
  distributionChainId: number;
@@ -2720,6 +2721,7 @@ declare const eden: {
2720
2721
  distributionCreator: string;
2721
2722
  endOfDisputePeriod: number;
2722
2723
  disputer: string;
2724
+ liveCampaigns: number;
2723
2725
  delayed: Awaited<ReturnType<typeof import("../modules/v4/status").StatusService.findManyDelay>>;
2724
2726
  };
2725
2727
  };
@@ -5766,7 +5768,7 @@ declare const eden: {
5766
5768
  }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
5767
5769
  200: {
5768
5770
  delay: number;
5769
- delayFormatted: string;
5771
+ computedUntil: bigint;
5770
5772
  startTimestamp: bigint;
5771
5773
  endTimestamp: bigint;
5772
5774
  CampaignStatus: {
@@ -5779,6 +5781,7 @@ declare const eden: {
5779
5781
  }[];
5780
5782
  Opportunity: {
5781
5783
  name: string;
5784
+ id: string;
5782
5785
  };
5783
5786
  computeChainId: number;
5784
5787
  distributionChainId: number;
@@ -5803,6 +5806,7 @@ declare const eden: {
5803
5806
  distributionCreator: string;
5804
5807
  endOfDisputePeriod: number;
5805
5808
  disputer: string;
5809
+ liveCampaigns: number;
5806
5810
  delayed: Awaited<ReturnType<typeof import("../modules/v4/status").StatusService.findManyDelay>>;
5807
5811
  };
5808
5812
  };
@@ -10173,7 +10177,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
10173
10177
  response: {
10174
10178
  200: {
10175
10179
  delay: number;
10176
- delayFormatted: string;
10180
+ computedUntil: bigint;
10177
10181
  startTimestamp: bigint;
10178
10182
  endTimestamp: bigint;
10179
10183
  CampaignStatus: {
@@ -10186,6 +10190,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
10186
10190
  }[];
10187
10191
  Opportunity: {
10188
10192
  name: string;
10193
+ id: string;
10189
10194
  };
10190
10195
  computeChainId: number;
10191
10196
  distributionChainId: number;
@@ -10215,6 +10220,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
10215
10220
  distributionCreator: string;
10216
10221
  endOfDisputePeriod: number;
10217
10222
  disputer: string;
10223
+ liveCampaigns: number;
10218
10224
  delayed: Awaited<ReturnType<typeof import("../modules/v4/status").StatusService.findManyDelay>>;
10219
10225
  };
10220
10226
  };
@@ -14281,7 +14287,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
14281
14287
  }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
14282
14288
  200: {
14283
14289
  delay: number;
14284
- delayFormatted: string;
14290
+ computedUntil: bigint;
14285
14291
  startTimestamp: bigint;
14286
14292
  endTimestamp: bigint;
14287
14293
  CampaignStatus: {
@@ -14294,6 +14300,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
14294
14300
  }[];
14295
14301
  Opportunity: {
14296
14302
  name: string;
14303
+ id: string;
14297
14304
  };
14298
14305
  computeChainId: number;
14299
14306
  distributionChainId: number;
@@ -14318,6 +14325,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
14318
14325
  distributionCreator: string;
14319
14326
  endOfDisputePeriod: number;
14320
14327
  disputer: string;
14328
+ liveCampaigns: number;
14321
14329
  delayed: Awaited<ReturnType<typeof import("../modules/v4/status").StatusService.findManyDelay>>;
14322
14330
  };
14323
14331
  };
@@ -17364,7 +17372,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
17364
17372
  }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
17365
17373
  200: {
17366
17374
  delay: number;
17367
- delayFormatted: string;
17375
+ computedUntil: bigint;
17368
17376
  startTimestamp: bigint;
17369
17377
  endTimestamp: bigint;
17370
17378
  CampaignStatus: {
@@ -17377,6 +17385,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
17377
17385
  }[];
17378
17386
  Opportunity: {
17379
17387
  name: string;
17388
+ id: string;
17380
17389
  };
17381
17390
  computeChainId: number;
17382
17391
  distributionChainId: number;
@@ -17401,6 +17410,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
17401
17410
  distributionCreator: string;
17402
17411
  endOfDisputePeriod: number;
17403
17412
  disputer: string;
17413
+ liveCampaigns: number;
17404
17414
  delayed: Awaited<ReturnType<typeof import("../modules/v4/status").StatusService.findManyDelay>>;
17405
17415
  };
17406
17416
  };
@@ -3309,7 +3309,7 @@ declare const app: Elysia<"", false, {
3309
3309
  response: {
3310
3310
  200: {
3311
3311
  delay: number;
3312
- delayFormatted: string;
3312
+ computedUntil: bigint;
3313
3313
  startTimestamp: bigint;
3314
3314
  endTimestamp: bigint;
3315
3315
  CampaignStatus: {
@@ -3322,6 +3322,7 @@ declare const app: Elysia<"", false, {
3322
3322
  }[];
3323
3323
  Opportunity: {
3324
3324
  name: string;
3325
+ id: string;
3325
3326
  };
3326
3327
  computeChainId: number;
3327
3328
  distributionChainId: number;
@@ -3351,6 +3352,7 @@ declare const app: Elysia<"", false, {
3351
3352
  distributionCreator: string;
3352
3353
  endOfDisputePeriod: number;
3353
3354
  disputer: string;
3355
+ liveCampaigns: number;
3354
3356
  delayed: Awaited<ReturnType<typeof import("./modules/v4/status").StatusService.findManyDelay>>;
3355
3357
  };
3356
3358
  };
@@ -194,6 +194,7 @@ export declare abstract class CampaignRepository {
194
194
  creatorAddress: string;
195
195
  })[]>;
196
196
  static countMany(query: GetCampaignQueryModel): Promise<number>;
197
+ static countLives(chainId: number): Promise<number>;
197
198
  static findManyCampaignId(chainId: ChainId): Promise<{
198
199
  campaignId: string;
199
200
  }[]>;
@@ -299,6 +299,20 @@ export class CampaignRepository {
299
299
  const args = CampaignRepository.transformQueryToPrismaFilters(query);
300
300
  return await apiDbClient.campaign.count(args);
301
301
  }
302
+ static async countLives(chainId) {
303
+ const now = moment().unix();
304
+ return await apiDbClient.campaign.count({
305
+ where: {
306
+ distributionChainId: chainId,
307
+ endTimestamp: {
308
+ gte: now,
309
+ },
310
+ startTimestamp: {
311
+ lte: now,
312
+ },
313
+ },
314
+ });
315
+ }
302
316
  static async findManyCampaignId(chainId) {
303
317
  return await apiDbClient.campaign.findMany({
304
318
  select: {
@@ -98,6 +98,7 @@ export declare abstract class CampaignService {
98
98
  * @returns the number of campaigns
99
99
  */
100
100
  static countMany(query: GetCampaignQueryModel): Promise<number>;
101
+ static countLives(chainId: number): Promise<number>;
101
102
  static checkIfExist(campaign: CampaignUnique): Promise<boolean>;
102
103
  static checkIfIdExist(id: string): Promise<boolean>;
103
104
  static findUnique(campaign: CampaignUnique): Promise<{
@@ -137,6 +137,9 @@ export class CampaignService {
137
137
  }
138
138
  return await CampaignRepository.countMany(query);
139
139
  }
140
+ static async countLives(chainId) {
141
+ return await CampaignRepository.countLives(chainId);
142
+ }
140
143
  static async checkIfExist(campaign) {
141
144
  return await CampaignRepository.checkIfExist(campaign);
142
145
  }
@@ -3179,7 +3179,7 @@ export declare const v4: Elysia<"/v4", false, {
3179
3179
  response: {
3180
3180
  200: {
3181
3181
  delay: number;
3182
- delayFormatted: string;
3182
+ computedUntil: bigint;
3183
3183
  startTimestamp: bigint;
3184
3184
  endTimestamp: bigint;
3185
3185
  CampaignStatus: {
@@ -3192,6 +3192,7 @@ export declare const v4: Elysia<"/v4", false, {
3192
3192
  }[];
3193
3193
  Opportunity: {
3194
3194
  name: string;
3195
+ id: string;
3195
3196
  };
3196
3197
  computeChainId: number;
3197
3198
  distributionChainId: number;
@@ -3221,6 +3222,7 @@ export declare const v4: Elysia<"/v4", false, {
3221
3222
  distributionCreator: string;
3222
3223
  endOfDisputePeriod: number;
3223
3224
  disputer: string;
3225
+ liveCampaigns: number;
3224
3226
  delayed: Awaited<ReturnType<typeof import("./status").StatusService.findManyDelay>>;
3225
3227
  };
3226
3228
  };
@@ -128,7 +128,7 @@ export declare const StatusController: Elysia<"/campaign-status", false, {
128
128
  response: {
129
129
  200: {
130
130
  delay: number;
131
- delayFormatted: string;
131
+ computedUntil: bigint;
132
132
  startTimestamp: bigint;
133
133
  endTimestamp: bigint;
134
134
  CampaignStatus: {
@@ -141,6 +141,7 @@ export declare const StatusController: Elysia<"/campaign-status", false, {
141
141
  }[];
142
142
  Opportunity: {
143
143
  name: string;
144
+ id: string;
144
145
  };
145
146
  computeChainId: number;
146
147
  distributionChainId: number;
@@ -170,6 +171,7 @@ export declare const StatusController: Elysia<"/campaign-status", false, {
170
171
  distributionCreator: string;
171
172
  endOfDisputePeriod: number;
172
173
  disputer: string;
174
+ liveCampaigns: number;
173
175
  delayed: Awaited<ReturnType<typeof StatusService.findManyDelay>>;
174
176
  };
175
177
  };
@@ -80,6 +80,7 @@ export declare class StatusRepository {
80
80
  }[];
81
81
  Opportunity: {
82
82
  name: string;
83
+ id: string;
83
84
  };
84
85
  computeChainId: number;
85
86
  distributionChainId: number;
@@ -100,6 +100,7 @@ export class StatusRepository {
100
100
  Opportunity: {
101
101
  select: {
102
102
  name: true,
103
+ id: true,
103
104
  },
104
105
  },
105
106
  CampaignStatus: {
@@ -45,11 +45,12 @@ export declare class StatusService {
45
45
  distributionCreator: string;
46
46
  endOfDisputePeriod: number;
47
47
  disputer: string;
48
+ liveCampaigns: number;
48
49
  delayed: Awaited<ReturnType<typeof StatusService.findManyDelay>>;
49
50
  }>>;
50
51
  static findManyDelay(query: DelayModel): Promise<{
51
52
  delay: number;
52
- delayFormatted: string;
53
+ computedUntil: bigint;
53
54
  startTimestamp: bigint;
54
55
  endTimestamp: bigint;
55
56
  CampaignStatus: {
@@ -62,6 +63,7 @@ export declare class StatusService {
62
63
  }[];
63
64
  Opportunity: {
64
65
  name: string;
66
+ id: string;
65
67
  };
66
68
  computeChainId: number;
67
69
  distributionChainId: number;
@@ -57,11 +57,15 @@ export class StatusService {
57
57
  }
58
58
  static async findUpdatesAndDelays() {
59
59
  const merklRoots = await MerklRootService.fetchAll();
60
- const delayedCampaignPromises = await Promise.allSettled(Object.keys(merklRoots).map(chainId => StatusService.findManyDelay({ chainId: Number.parseInt(chainId), delayLowerBound: 8 * HOUR })));
60
+ const delayedCampaignPromises = Promise.allSettled(Object.keys(merklRoots).map(chainId => StatusService.findManyDelay({ chainId: Number.parseInt(chainId), delayLowerBound: 8 * HOUR })));
61
+ const liveCampaignPromises = await Promise.allSettled(Object.keys(merklRoots).map(chainId => CampaignService.countLives(Number.parseInt(chainId))));
62
+ const delayedCampaignArray = await delayedCampaignPromises;
63
+ const liveCampaignArray = await liveCampaignPromises;
61
64
  const res = {};
62
65
  for (const [index, chainIdString] of Object.keys(merklRoots).entries()) {
63
66
  const chainId = Number.parseInt(chainIdString);
64
- const delayedCampaigns = delayedCampaignPromises[index].status === "rejected" ? [] : delayedCampaignPromises[index].value;
67
+ const delayedCampaigns = delayedCampaignArray[index].status === "rejected" ? [] : delayedCampaignArray[index].value;
68
+ const liveCampaigns = liveCampaignArray[index].status === "rejected" ? 0 : liveCampaignArray[index].value;
65
69
  if (!registry(chainId)?.Merkl?.DistributionCreator ||
66
70
  !registry(chainId)?.Merkl?.Distributor ||
67
71
  !registry(chainId)?.AngleLabs) {
@@ -78,6 +82,7 @@ export class StatusService {
78
82
  adminUrl,
79
83
  distributor: registry(chainId)?.Merkl?.Distributor,
80
84
  distributionCreator: registry(chainId)?.Merkl?.DistributionCreator,
85
+ liveCampaigns,
81
86
  delayed: delayedCampaigns,
82
87
  };
83
88
  }
@@ -92,8 +97,8 @@ export class StatusService {
92
97
  Math.min(now, endTimestamp, Number.parseInt((x.CampaignStatus?.[0]?.computedUntil ?? x.startTimestamp).toString()));
93
98
  return {
94
99
  ...x,
95
- delay: delay,
96
- delayFormatted: moment.duration(delay, "seconds").humanize(),
100
+ delay,
101
+ computedUntil: x.CampaignStatus?.[0]?.computedUntil ?? x.startTimestamp,
97
102
  };
98
103
  })
99
104
  .sort((a, b) => b.delay - a.delay)