@merkl/api 0.18.0 → 0.18.1

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.
@@ -2942,6 +2942,21 @@ declare const eden: {
2942
2942
  }>>;
2943
2943
  };
2944
2944
  };
2945
+ error: ((params: {
2946
+ campaignId: string | number;
2947
+ }) => {
2948
+ put: (body: {
2949
+ error: string;
2950
+ }, options: {
2951
+ headers: {
2952
+ authorization: string;
2953
+ };
2954
+ query?: Record<string, unknown> | undefined;
2955
+ fetch?: RequestInit | undefined;
2956
+ }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
2957
+ 200: void;
2958
+ }>>;
2959
+ }) & {};
2945
2960
  index: {
2946
2961
  get: (options: {
2947
2962
  headers?: Record<string, unknown> | undefined;
@@ -3019,7 +3034,7 @@ declare const eden: {
3019
3034
  endOfDisputePeriod: number;
3020
3035
  disputer: string;
3021
3036
  liveCampaigns: number;
3022
- delayed: Awaited<ReturnType<typeof import("../modules/v4/status").StatusService["findManyDelay"]>>;
3037
+ delayed: Awaited<ReturnType<typeof import("../modules/v4/status/status.service").StatusService["findManyDelay"]>>;
3023
3038
  };
3024
3039
  };
3025
3040
  }>>;
@@ -6366,6 +6381,21 @@ declare const eden: {
6366
6381
  }>>;
6367
6382
  };
6368
6383
  };
6384
+ error: ((params: {
6385
+ campaignId: string | number;
6386
+ }) => {
6387
+ put: (body: {
6388
+ error: string;
6389
+ }, options: {
6390
+ headers: {
6391
+ authorization: string;
6392
+ };
6393
+ query?: Record<string, unknown> | undefined;
6394
+ fetch?: RequestInit | undefined;
6395
+ }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
6396
+ 200: void;
6397
+ }>>;
6398
+ }) & {};
6369
6399
  index: {
6370
6400
  get: (options: {
6371
6401
  headers?: Record<string, unknown> | undefined;
@@ -6443,7 +6473,7 @@ declare const eden: {
6443
6473
  endOfDisputePeriod: number;
6444
6474
  disputer: string;
6445
6475
  liveCampaigns: number;
6446
- delayed: Awaited<ReturnType<typeof import("../modules/v4/status").StatusService["findManyDelay"]>>;
6476
+ delayed: Awaited<ReturnType<typeof import("../modules/v4/status/status.service").StatusService["findManyDelay"]>>;
6447
6477
  };
6448
6478
  };
6449
6479
  }>>;
@@ -11039,6 +11069,26 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
11039
11069
  };
11040
11070
  };
11041
11071
  };
11072
+ } & {
11073
+ error: {
11074
+ ":campaignId": {
11075
+ put: {
11076
+ body: {
11077
+ error: string;
11078
+ };
11079
+ params: {
11080
+ campaignId: string;
11081
+ };
11082
+ query: unknown;
11083
+ headers: {
11084
+ authorization: string;
11085
+ };
11086
+ response: {
11087
+ 200: void;
11088
+ };
11089
+ };
11090
+ };
11091
+ };
11042
11092
  } & {
11043
11093
  engine: {
11044
11094
  overlaps: {
@@ -11173,7 +11223,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
11173
11223
  endOfDisputePeriod: number;
11174
11224
  disputer: string;
11175
11225
  liveCampaigns: number;
11176
- delayed: Awaited<ReturnType<typeof import("../modules/v4/status").StatusService["findManyDelay"]>>;
11226
+ delayed: Awaited<ReturnType<typeof import("../modules/v4/status/status.service").StatusService["findManyDelay"]>>;
11177
11227
  };
11178
11228
  };
11179
11229
  };
@@ -15497,6 +15547,21 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
15497
15547
  }>>;
15498
15548
  };
15499
15549
  };
15550
+ error: ((params: {
15551
+ campaignId: string | number;
15552
+ }) => {
15553
+ put: (body: {
15554
+ error: string;
15555
+ }, options: {
15556
+ headers: {
15557
+ authorization: string;
15558
+ };
15559
+ query?: Record<string, unknown> | undefined;
15560
+ fetch?: RequestInit | undefined;
15561
+ }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
15562
+ 200: void;
15563
+ }>>;
15564
+ }) & {};
15500
15565
  index: {
15501
15566
  get: (options: {
15502
15567
  headers?: Record<string, unknown> | undefined;
@@ -15574,7 +15639,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
15574
15639
  endOfDisputePeriod: number;
15575
15640
  disputer: string;
15576
15641
  liveCampaigns: number;
15577
- delayed: Awaited<ReturnType<typeof import("../modules/v4/status").StatusService["findManyDelay"]>>;
15642
+ delayed: Awaited<ReturnType<typeof import("../modules/v4/status/status.service").StatusService["findManyDelay"]>>;
15578
15643
  };
15579
15644
  };
15580
15645
  }>>;
@@ -18921,6 +18986,21 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
18921
18986
  }>>;
18922
18987
  };
18923
18988
  };
18989
+ error: ((params: {
18990
+ campaignId: string | number;
18991
+ }) => {
18992
+ put: (body: {
18993
+ error: string;
18994
+ }, options: {
18995
+ headers: {
18996
+ authorization: string;
18997
+ };
18998
+ query?: Record<string, unknown> | undefined;
18999
+ fetch?: RequestInit | undefined;
19000
+ }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
19001
+ 200: void;
19002
+ }>>;
19003
+ }) & {};
18924
19004
  index: {
18925
19005
  get: (options: {
18926
19006
  headers?: Record<string, unknown> | undefined;
@@ -18998,7 +19078,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
18998
19078
  endOfDisputePeriod: number;
18999
19079
  disputer: string;
19000
19080
  liveCampaigns: number;
19001
- delayed: Awaited<ReturnType<typeof import("../modules/v4/status").StatusService["findManyDelay"]>>;
19081
+ delayed: Awaited<ReturnType<typeof import("../modules/v4/status/status.service").StatusService["findManyDelay"]>>;
19002
19082
  };
19003
19083
  };
19004
19084
  }>>;
@@ -0,0 +1,4 @@
1
+ import { HttpError } from "./HttpError";
2
+ export declare class VoidString extends HttpError {
3
+ constructor(message?: string);
4
+ }
@@ -0,0 +1,7 @@
1
+ import { HttpError } from "./HttpError";
2
+ export class VoidString extends HttpError {
3
+ constructor(message = "Void String is invalid") {
4
+ super(message, 409);
5
+ this.name = "VoidString";
6
+ }
7
+ }
@@ -16,7 +16,7 @@ export class UniswapV4Metadata {
16
16
  // }
17
17
  // }
18
18
  return {
19
- name: `Provide liquidity to ${whitelistNameString} UniswapV4 ${params.symbolCurrency0}-${params.symbolCurrency1}${params.lpFee ? ` ${params.lpFee}%` : ""}`,
19
+ name: `Provide liquidity to ${whitelistNameString} UniswapV4 ${params.symbolCurrency0}-${params.symbolCurrency1}${params.lpFee ? ` ${params.lpFee / 10_000}%` : ""}`,
20
20
  action: OpportunityAction.POOL,
21
21
  tokens: [
22
22
  { chainId: computeChainId, address: params.currency0 },
@@ -3522,6 +3522,26 @@ declare const app: Elysia<"", false, {
3522
3522
  };
3523
3523
  };
3524
3524
  };
3525
+ } & {
3526
+ error: {
3527
+ ":campaignId": {
3528
+ put: {
3529
+ body: {
3530
+ error: string;
3531
+ };
3532
+ params: {
3533
+ campaignId: string;
3534
+ };
3535
+ query: unknown;
3536
+ headers: {
3537
+ authorization: string;
3538
+ };
3539
+ response: {
3540
+ 200: void;
3541
+ };
3542
+ };
3543
+ };
3544
+ };
3525
3545
  } & {
3526
3546
  engine: {
3527
3547
  overlaps: {
@@ -3656,7 +3676,7 @@ declare const app: Elysia<"", false, {
3656
3676
  endOfDisputePeriod: number;
3657
3677
  disputer: string;
3658
3678
  liveCampaigns: number;
3659
- delayed: Awaited<ReturnType<typeof import("./modules/v4/status").StatusService["findManyDelay"]>>;
3679
+ delayed: Awaited<ReturnType<typeof import("./modules/v4/status/status.service").StatusService["findManyDelay"]>>;
3660
3680
  };
3661
3681
  };
3662
3682
  };
@@ -3392,6 +3392,26 @@ export declare const v4: Elysia<"/v4", false, {
3392
3392
  };
3393
3393
  };
3394
3394
  };
3395
+ } & {
3396
+ error: {
3397
+ ":campaignId": {
3398
+ put: {
3399
+ body: {
3400
+ error: string;
3401
+ };
3402
+ params: {
3403
+ campaignId: string;
3404
+ };
3405
+ query: unknown;
3406
+ headers: {
3407
+ authorization: string;
3408
+ };
3409
+ response: {
3410
+ 200: void;
3411
+ };
3412
+ };
3413
+ };
3414
+ };
3395
3415
  } & {
3396
3416
  engine: {
3397
3417
  overlaps: {
@@ -3526,7 +3546,7 @@ export declare const v4: Elysia<"/v4", false, {
3526
3546
  endOfDisputePeriod: number;
3527
3547
  disputer: string;
3528
3548
  liveCampaigns: number;
3529
- delayed: Awaited<ReturnType<typeof import("./status").StatusService["findManyDelay"]>>;
3549
+ delayed: Awaited<ReturnType<typeof import("./status/status.service").StatusService["findManyDelay"]>>;
3530
3550
  };
3531
3551
  };
3532
3552
  };
@@ -66,6 +66,26 @@ export declare const StatusController: Elysia<"/campaign-status", false, {
66
66
  };
67
67
  };
68
68
  };
69
+ } & {
70
+ error: {
71
+ ":campaignId": {
72
+ put: {
73
+ body: {
74
+ error: string;
75
+ };
76
+ params: {
77
+ campaignId: string;
78
+ };
79
+ query: unknown;
80
+ headers: {
81
+ authorization: string;
82
+ };
83
+ response: {
84
+ 200: void;
85
+ };
86
+ };
87
+ };
88
+ };
69
89
  } & {
70
90
  engine: {
71
91
  overlaps: {
@@ -1,7 +1,8 @@
1
+ import { BackOfficeGuard } from "../../../guards/BackOffice.guard";
1
2
  import { AuthorizationHeadersDto, EngineGuard } from "../../../guards/Engine.guard";
2
3
  import { throwOnUnsupportedChainId } from "../../../utils/throw";
3
4
  import Elysia from "elysia";
4
- import { CampaignUniqueDto, ComputedUntilDto, DelayDto, QueryCampaignStatusDto, UpdateCampaignStatusDto, } from "./status.model";
5
+ import { CampaignUniqueDto, ComputedUntilDto, DelayDto, QueryCampaignStatusDto, StatusErrorDto, UpdateCampaignStatusDto, } from "./status.model";
5
6
  import { StatusService } from "./status.service";
6
7
  export const StatusController = new Elysia({ prefix: "/campaign-status", detail: { tags: ["Status"], hide: true } })
7
8
  // ─── Update a Campaign Status ──────────────────────────────────────
@@ -21,6 +22,15 @@ export const StatusController = new Elysia({ prefix: "/campaign-status", detail:
21
22
  beforeHandle: EngineGuard,
22
23
  headers: AuthorizationHeadersDto,
23
24
  body: ComputedUntilDto,
25
+ })
26
+ // ─── Updates only the computed until field ───────────────────────────
27
+ .put("/error/:campaignId", async ({ params, body }) => {
28
+ const [distributionChain, campaignId] = params.campaignId.split("-");
29
+ return await StatusService.updateErrorMessage({ distributionChain: +distributionChain, campaignId }, body.error);
30
+ }, {
31
+ beforeHandle: BackOfficeGuard,
32
+ headers: AuthorizationHeadersDto,
33
+ body: StatusErrorDto,
24
34
  })
25
35
  // ─── Is Safe For Overlaps ───────────────────────────────────────────
26
36
  .get("/engine/overlaps", async ({ query }) => await StatusService.isSafeForOverlaps(query), {
@@ -41,6 +41,9 @@ export declare const UpdateCampaignStatusDto: import("@sinclair/typebox").TUnion
41
41
  export declare const ComputedUntilDto: import("@sinclair/typebox").TObject<{
42
42
  computedUntil: import("@sinclair/typebox").TNumber;
43
43
  }>;
44
+ export declare const StatusErrorDto: import("@sinclair/typebox").TObject<{
45
+ error: import("@sinclair/typebox").TString;
46
+ }>;
44
47
  export declare const QueryCampaignStatusDto: import("@sinclair/typebox").TObject<{
45
48
  computeChainId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
46
49
  status: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TArray<import("@sinclair/typebox").TEnum<{
@@ -27,6 +27,7 @@ export const UpdateCampaignStatusDto = t.Union([
27
27
  t.Object({ value: t.Literal(RunStatus.FAILED), error: t.String(), details: t.String() }),
28
28
  ]);
29
29
  export const ComputedUntilDto = t.Object({ computedUntil: t.Numeric() });
30
+ export const StatusErrorDto = t.Object({ error: t.String() });
30
31
  export const QueryCampaignStatusDto = t.Object({
31
32
  computeChainId: t.Optional(t.Numeric()),
32
33
  status: t.Optional(t.Union([t.Array(t.Enum(RunStatus)), t.Enum(RunStatus)])),
@@ -68,6 +68,14 @@ export declare abstract class StatusRepository {
68
68
  computedUntil: bigint;
69
69
  processingStarted: bigint;
70
70
  }>;
71
+ static updateErrorMessage(campaignUnique: CampaignUnique, error: string): Promise<{
72
+ error: string;
73
+ details: Prisma.JsonValue;
74
+ status: import("../../../../database/api/.generated").$Enums.RunStatus;
75
+ campaignId: string;
76
+ computedUntil: bigint;
77
+ processingStarted: bigint;
78
+ }>;
71
79
  static findManyDelay(query: DelayModel): Promise<{
72
80
  startTimestamp: bigint;
73
81
  endTimestamp: bigint;
@@ -65,7 +65,7 @@ export class StatusRepository {
65
65
  },
66
66
  data: {
67
67
  status,
68
- error,
68
+ error: error?.length > 0 ? error : undefined,
69
69
  details,
70
70
  },
71
71
  });
@@ -98,12 +98,22 @@ export class StatusRepository {
98
98
  },
99
99
  });
100
100
  }
101
+ static async updateErrorMessage(campaignUnique, error) {
102
+ return await apiDbClient.campaignStatus.update({
103
+ where: {
104
+ campaignId: CampaignService.hashId(campaignUnique),
105
+ },
106
+ data: {
107
+ error,
108
+ },
109
+ });
110
+ }
101
111
  static async findManyDelay(query) {
102
112
  return await apiDbClient.campaign.findMany({
103
113
  where: {
104
114
  distributionChainId: !!query.chainId ? query.chainId : undefined,
105
115
  endTimestamp: {
106
- gte: !!query.endTimestampLowerBound ? query.endTimestampLowerBound : moment().subtract(1, "week").unix(),
116
+ gte: !!query.endTimestampLowerBound ? query.endTimestampLowerBound : moment().subtract(2, "week").unix(),
107
117
  },
108
118
  },
109
119
  select: {
@@ -43,6 +43,7 @@ export declare abstract class StatusService {
43
43
  } | null>;
44
44
  static update(campaignUnique: CampaignUnique, status: UpdateStatusModel): Promise<void>;
45
45
  static updateComputedUntil(campaignUnique: CampaignUnique, computedUntil: number): Promise<void>;
46
+ static updateErrorMessage(campaignUnique: CampaignUnique, error: string): Promise<void>;
46
47
  static isSafeForOverlaps(campaignUnique: CampaignUnique): Promise<boolean>;
47
48
  static findUpdatesAndDelays(): Promise<Record<number, {
48
49
  live: string;
@@ -1,3 +1,5 @@
1
+ import { NotFoundError } from "../../../errors";
2
+ import { VoidString } from "../../../errors/VoidString.error";
1
3
  import { log } from "../../../utils/logger";
2
4
  import { RunStatus } from "../../../../database/api/.generated";
3
5
  import { HOUR, MAX_COMPUTE_JOB_TIME, NETWORK_LABELS, getMultisigURL, registry } from "@sdk";
@@ -66,6 +68,17 @@ export class StatusService {
66
68
  }
67
69
  await StatusRepository.updateComputedUntil(campaignUnique, computedUntil);
68
70
  }
71
+ static async updateErrorMessage(campaignUnique, error) {
72
+ // Check if the status exists already, otherwise thros
73
+ const campaignStatus = await StatusRepository.findUnique(campaignUnique);
74
+ if (!(error?.length > 0)) {
75
+ throw new VoidString("Error message is empty");
76
+ }
77
+ if (!campaignStatus) {
78
+ throw new NotFoundError("CampaignStatus not found");
79
+ }
80
+ await StatusRepository.updateErrorMessage(campaignUnique, error);
81
+ }
69
82
  static async isSafeForOverlaps(campaignUnique) {
70
83
  const status = await StatusRepository.findUnique(campaignUnique);
71
84
  if (!status) {
@@ -106,7 +119,6 @@ export class StatusService {
106
119
  delayed: delayedCampaigns,
107
120
  };
108
121
  }
109
- console.log(res[146]);
110
122
  return res;
111
123
  }
112
124
  static async findManyDelay(query) {