@merkl/api 0.10.394 → 0.10.397

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.
Files changed (43) hide show
  1. package/dist/database/api/.generated/drizzle/schema.d.ts +2806 -0
  2. package/dist/database/api/.generated/drizzle/schema.js +849 -0
  3. package/dist/database/api/.generated/drizzle/schema.ts +906 -0
  4. package/dist/database/api/.generated/edge.js +2 -2
  5. package/dist/database/api/.generated/index.js +2 -2
  6. package/dist/database/api/.generated/package.json +1 -1
  7. package/dist/database/api/.generated/schema.prisma +5 -0
  8. package/dist/src/backgroundJobs/jobs/campaignsCacheUpdater.js +1 -1
  9. package/dist/src/eden/index.d.ts +314 -36
  10. package/dist/src/index.d.ts +120 -12
  11. package/dist/src/modules/v4/cache/cache.service.js +2 -0
  12. package/dist/src/modules/v4/campaign/campaign.controller.d.ts +1 -1
  13. package/dist/src/modules/v4/campaign/campaign.repository.d.ts +10 -10
  14. package/dist/src/modules/v4/campaign/campaign.repository.js +2 -2
  15. package/dist/src/modules/v4/campaign/campaign.service.d.ts +3 -2
  16. package/dist/src/modules/v4/campaign/campaign.service.js +9 -1
  17. package/dist/src/modules/v4/dynamicData/dynamicData.controller.d.ts +1 -1
  18. package/dist/src/modules/v4/opportunity/opportunity.controller.d.ts +3 -3
  19. package/dist/src/modules/v4/opportunity/opportunity.model.d.ts +5 -5
  20. package/dist/src/modules/v4/opportunity/opportunity.repository.d.ts +72 -72
  21. package/dist/src/modules/v4/opportunity/opportunity.service.d.ts +1 -1
  22. package/dist/src/modules/v4/reward/reward.controller.d.ts +109 -1
  23. package/dist/src/modules/v4/reward/reward.controller.js +29 -21
  24. package/dist/src/modules/v4/reward/reward.model.d.ts +5 -0
  25. package/dist/src/modules/v4/reward/reward.model.js +8 -0
  26. package/dist/src/modules/v4/reward/reward.repository.d.ts +12 -8
  27. package/dist/src/modules/v4/reward/reward.repository.js +13 -16
  28. package/dist/src/modules/v4/reward/reward.service.d.ts +10 -5
  29. package/dist/src/modules/v4/router.d.ts +120 -12
  30. package/dist/src/modules/v4/status/status.controller.d.ts +6 -6
  31. package/dist/src/modules/v4/status/status.repository.d.ts +6 -6
  32. package/dist/src/modules/v4/status/status.service.d.ts +6 -6
  33. package/dist/src/modules/v4/token/token.repository.d.ts +2 -2
  34. package/dist/src/modules/v4/token/token.service.d.ts +3 -4
  35. package/dist/src/modules/v4/token/token.service.js +2 -1
  36. package/dist/src/modules/v4/user/user.model.d.ts +5 -0
  37. package/dist/src/modules/v4/user/user.model.js +4 -0
  38. package/dist/src/modules/v4/user/user.repository.d.ts +1 -1
  39. package/dist/src/modules/v4/user/user.service.d.ts +1 -1
  40. package/dist/src/utils/prisma.d.ts +16 -3
  41. package/dist/src/utils/prisma.js +2 -1
  42. package/dist/tsconfig.package.tsbuildinfo +1 -1
  43. package/package.json +4 -2
@@ -467,7 +467,6 @@ declare const app: Elysia<"", {
467
467
  tags: string[];
468
468
  icon: string;
469
469
  } | null | undefined;
470
- depositUrl?: string | undefined;
471
470
  aprRecord?: {
472
471
  timestamp: string | bigint;
473
472
  cumulated: number;
@@ -479,6 +478,7 @@ declare const app: Elysia<"", {
479
478
  aprRecordId: string;
480
479
  }[];
481
480
  } | undefined;
481
+ depositUrl?: string | undefined;
482
482
  tvlRecord?: {
483
483
  total: number;
484
484
  timestamp: string | bigint;
@@ -600,7 +600,6 @@ declare const app: Elysia<"", {
600
600
  tags: string[];
601
601
  icon: string;
602
602
  } | null | undefined;
603
- depositUrl?: string | undefined;
604
603
  aprRecord?: {
605
604
  timestamp: string | bigint;
606
605
  cumulated: number;
@@ -612,6 +611,7 @@ declare const app: Elysia<"", {
612
611
  aprRecordId: string;
613
612
  }[];
614
613
  } | undefined;
614
+ depositUrl?: string | undefined;
615
615
  tvlRecord?: {
616
616
  total: number;
617
617
  timestamp: string | bigint;
@@ -768,7 +768,6 @@ declare const app: Elysia<"", {
768
768
  tags: string[];
769
769
  icon: string;
770
770
  } | null | undefined;
771
- depositUrl?: string | undefined;
772
771
  aprRecord?: {
773
772
  timestamp: string | bigint;
774
773
  cumulated: number;
@@ -780,6 +779,7 @@ declare const app: Elysia<"", {
780
779
  aprRecordId: string;
781
780
  }[];
782
781
  } | undefined;
782
+ depositUrl?: string | undefined;
783
783
  tvlRecord?: {
784
784
  total: number;
785
785
  timestamp: string | bigint;
@@ -1350,10 +1350,10 @@ declare const app: Elysia<"", {
1350
1350
  response: {
1351
1351
  200: {
1352
1352
  endTimestamp: bigint;
1353
- campaignId: string;
1354
1353
  CampaignStatus: {
1355
1354
  computedUntil: bigint;
1356
1355
  }[];
1356
+ campaignId: string;
1357
1357
  }[];
1358
1358
  422: {
1359
1359
  type: "validation";
@@ -2028,6 +2028,106 @@ declare const app: Elysia<"", {
2028
2028
  };
2029
2029
  };
2030
2030
  };
2031
+ } & {
2032
+ campaign: {
2033
+ ":campaignId": {
2034
+ index: {
2035
+ get: {
2036
+ body: unknown;
2037
+ params: {
2038
+ campaignId: string;
2039
+ };
2040
+ query: {
2041
+ items?: number | undefined;
2042
+ page?: number | undefined;
2043
+ };
2044
+ headers: unknown;
2045
+ response: {
2046
+ 200: {
2047
+ amount: string;
2048
+ claimed: string;
2049
+ pending: string;
2050
+ recipient: string;
2051
+ }[];
2052
+ 422: {
2053
+ type: "validation";
2054
+ on: string;
2055
+ summary?: string;
2056
+ message?: string;
2057
+ found?: unknown;
2058
+ property?: string;
2059
+ expected?: string;
2060
+ };
2061
+ };
2062
+ };
2063
+ };
2064
+ };
2065
+ };
2066
+ } & {
2067
+ campaign: {
2068
+ ":campaignId": {
2069
+ total: {
2070
+ get: {
2071
+ body: unknown;
2072
+ params: {
2073
+ campaignId: string;
2074
+ };
2075
+ query: {
2076
+ items?: number | undefined;
2077
+ page?: number | undefined;
2078
+ };
2079
+ headers: unknown;
2080
+ response: {
2081
+ 200: {
2082
+ tokenId: string;
2083
+ amount: bigint;
2084
+ };
2085
+ 422: {
2086
+ type: "validation";
2087
+ on: string;
2088
+ summary?: string;
2089
+ message?: string;
2090
+ found?: unknown;
2091
+ property?: string;
2092
+ expected?: string;
2093
+ };
2094
+ };
2095
+ };
2096
+ };
2097
+ };
2098
+ };
2099
+ } & {
2100
+ campaign: {
2101
+ ":campaignId": {
2102
+ count: {
2103
+ get: {
2104
+ body: unknown;
2105
+ params: {
2106
+ campaignId: string;
2107
+ };
2108
+ query: {
2109
+ items?: number | undefined;
2110
+ page?: number | undefined;
2111
+ };
2112
+ headers: unknown;
2113
+ response: {
2114
+ 200: {
2115
+ count: number;
2116
+ };
2117
+ 422: {
2118
+ type: "validation";
2119
+ on: string;
2120
+ summary?: string;
2121
+ message?: string;
2122
+ found?: unknown;
2123
+ property?: string;
2124
+ expected?: string;
2125
+ };
2126
+ };
2127
+ };
2128
+ };
2129
+ };
2130
+ };
2031
2131
  } & {
2032
2132
  token: {
2033
2133
  index: {
@@ -2037,12 +2137,18 @@ declare const app: Elysia<"", {
2037
2137
  query: {
2038
2138
  items?: number | undefined;
2039
2139
  page?: number | undefined;
2140
+ campaignIds?: string[] | undefined;
2040
2141
  chainId: number;
2041
2142
  address: string;
2042
2143
  };
2043
2144
  headers: unknown;
2044
2145
  response: {
2045
- 200: import("./modules/v4/reward").BreakdownForTokenRaw[];
2146
+ 200: {
2147
+ amount: string;
2148
+ claimed: string;
2149
+ pending: string;
2150
+ recipient: string;
2151
+ }[];
2046
2152
  422: {
2047
2153
  type: "validation";
2048
2154
  on: string;
@@ -2065,6 +2171,7 @@ declare const app: Elysia<"", {
2065
2171
  query: {
2066
2172
  items?: number | undefined;
2067
2173
  page?: number | undefined;
2174
+ campaignIds?: string[] | undefined;
2068
2175
  chainId: number;
2069
2176
  address: string;
2070
2177
  };
@@ -2096,6 +2203,7 @@ declare const app: Elysia<"", {
2096
2203
  query: {
2097
2204
  items?: number | undefined;
2098
2205
  page?: number | undefined;
2206
+ campaignIds?: string[] | undefined;
2099
2207
  chainId: number;
2100
2208
  address: string;
2101
2209
  };
@@ -3746,13 +3854,13 @@ declare const app: Elysia<"", {
3746
3854
  chainId?: number | undefined;
3747
3855
  startTimestamp?: string | undefined;
3748
3856
  endTimestamp?: string | undefined;
3857
+ campaignStatus?: {} | undefined;
3749
3858
  distributionChainId?: number | undefined;
3750
3859
  campaignId?: string | undefined;
3751
3860
  rewardTokenId?: string | undefined;
3752
3861
  amount?: string | undefined;
3753
3862
  opportunityId?: string | undefined;
3754
3863
  creatorAddress?: string | undefined;
3755
- campaignStatus?: {} | undefined;
3756
3864
  rewardToken?: {} | undefined;
3757
3865
  rewardTokenAddress?: string | undefined;
3758
3866
  distributionChain?: {} | undefined;
@@ -3980,12 +4088,6 @@ declare const app: Elysia<"", {
3980
4088
  delayFormatted: string;
3981
4089
  startTimestamp: bigint;
3982
4090
  endTimestamp: bigint;
3983
- computeChainId: number;
3984
- distributionChainId: number;
3985
- campaignId: string;
3986
- Opportunity: {
3987
- name: string;
3988
- };
3989
4091
  CampaignStatus: {
3990
4092
  error: string;
3991
4093
  details: import("database/api/.generated/runtime/library").JsonValue;
@@ -3994,6 +4096,12 @@ declare const app: Elysia<"", {
3994
4096
  computedUntil: bigint;
3995
4097
  processingStarted: bigint;
3996
4098
  }[];
4099
+ Opportunity: {
4100
+ name: string;
4101
+ };
4102
+ computeChainId: number;
4103
+ distributionChainId: number;
4104
+ campaignId: string;
3997
4105
  }[];
3998
4106
  422: {
3999
4107
  type: "validation";
@@ -18,6 +18,8 @@ export class CacheService {
18
18
  return JSON.parse(decoded);
19
19
  }
20
20
  static async wrap(ttl, fn, ...args) {
21
+ if (Bun.env.NODE_ENV === "local")
22
+ return (await fn(...args));
21
23
  const key = CacheService.#hashKey(fn, args);
22
24
  const cached = await CacheRepository.get(key);
23
25
  if (cached !== null)
@@ -268,10 +268,10 @@ export declare const CampaignController: Elysia<"/campaigns", {
268
268
  response: {
269
269
  200: {
270
270
  endTimestamp: bigint;
271
- campaignId: string;
272
271
  CampaignStatus: {
273
272
  computedUntil: bigint;
274
273
  }[];
274
+ campaignId: string;
275
275
  }[];
276
276
  422: {
277
277
  type: "validation";
@@ -124,7 +124,7 @@ export declare abstract class CampaignRepository {
124
124
  opportunityId: string;
125
125
  creatorAddress: string;
126
126
  } | null>;
127
- static findUniqueOrThrow(campaign: CampaignUnique): Promise<{
127
+ static findUniqueOrThrow(id: string): Promise<{
128
128
  params: Prisma.JsonValue;
129
129
  type: import("../../../../database/api/.generated").$Enums.CampaignType;
130
130
  id: string;
@@ -141,12 +141,20 @@ export declare abstract class CampaignRepository {
141
141
  }>;
142
142
  static findCampaignsToProcess(distributionChainId: ChainId): Promise<{
143
143
  endTimestamp: bigint;
144
- campaignId: string;
145
144
  CampaignStatus: {
146
145
  computedUntil: bigint;
147
146
  }[];
147
+ campaignId: string;
148
148
  }[]>;
149
149
  static findMany(query: GetCampaignQueryModel): Promise<({
150
+ CampaignStatus: {
151
+ error: string;
152
+ details: Prisma.JsonValue;
153
+ status: import("../../../../database/api/.generated").$Enums.RunStatus;
154
+ campaignId: string;
155
+ computedUntil: bigint;
156
+ processingStarted: bigint;
157
+ }[];
150
158
  ComputeChain: {
151
159
  name: string;
152
160
  id: number;
@@ -170,14 +178,6 @@ export declare abstract class CampaignRepository {
170
178
  isTest: boolean;
171
179
  price: number | null;
172
180
  };
173
- CampaignStatus: {
174
- error: string;
175
- details: Prisma.JsonValue;
176
- status: import("../../../../database/api/.generated").$Enums.RunStatus;
177
- campaignId: string;
178
- computedUntil: bigint;
179
- processingStarted: bigint;
180
- }[];
181
181
  } & {
182
182
  params: Prisma.JsonValue;
183
183
  type: import("../../../../database/api/.generated").$Enums.CampaignType;
@@ -222,10 +222,10 @@ export class CampaignRepository {
222
222
  },
223
223
  });
224
224
  }
225
- static async findUniqueOrThrow(campaign) {
225
+ static async findUniqueOrThrow(id) {
226
226
  return await apiDbClient.campaign.findUniqueOrThrow({
227
227
  where: {
228
- id: CampaignService.hashId(campaign),
228
+ id,
229
229
  },
230
230
  });
231
231
  }
@@ -4,6 +4,7 @@ import type { CampaignType } from "../../../../database/api/.generated";
4
4
  import { type CampaignParameters, type Campaign as CampaignTypeV3, type ChainId } from "@sdk";
5
5
  export declare abstract class CampaignService {
6
6
  static hashId(campaign: CampaignUnique): string;
7
+ static splitIdOrThrow(chainAndCampaignId: `${number}-${string}` | string): CampaignUnique;
7
8
  static create(campaign: Omit<CreateCampaignModel, "id">): Promise<{
8
9
  params: import("database/api/.generated/runtime/library").JsonValue;
9
10
  type: import("../../../../database/api/.generated").$Enums.CampaignType;
@@ -114,7 +115,7 @@ export declare abstract class CampaignService {
114
115
  opportunityId: string;
115
116
  creatorAddress: string;
116
117
  } | null>;
117
- static findUniqueOrThrow(campaign: CampaignUnique): Promise<{
118
+ static findUniqueOrThrow(campaign: CampaignUnique | string): Promise<{
118
119
  params: import("database/api/.generated/runtime/library").JsonValue;
119
120
  type: import("../../../../database/api/.generated").$Enums.CampaignType;
120
121
  id: string;
@@ -131,10 +132,10 @@ export declare abstract class CampaignService {
131
132
  }>;
132
133
  static findCampaignsToProcess(distributionChainId: ChainId): Promise<{
133
134
  endTimestamp: bigint;
134
- campaignId: string;
135
135
  CampaignStatus: {
136
136
  computedUntil: bigint;
137
137
  }[];
138
+ campaignId: string;
138
139
  }[]>;
139
140
  static pickCampaignToProcess(chainId: ChainId): Promise<string>;
140
141
  static fill(campaigns: CampaignUnique[]): Promise<{
@@ -3,6 +3,7 @@ import { campaignsDynamicData } from "../../../libs/campaigns/campaignsDynamicDa
3
3
  import { campaignTypeToEnumMap, } from "./";
4
4
  import { CampaignRepository } from "./campaign.repository";
5
5
  import { OpportunityService } from "../opportunity";
6
+ import { InvalidParameter } from "../../../utils/error";
6
7
  import { executeSimple } from "../../../utils/execute";
7
8
  import { log } from "../../../utils/logger";
8
9
  import { NETWORK_LABELS, } from "@sdk";
@@ -15,6 +16,12 @@ export class CampaignService {
15
16
  static hashId(campaign) {
16
17
  return Bun.hash(`${campaign.distributionChain}${campaign.campaignId}`).toString();
17
18
  }
19
+ static splitIdOrThrow(chainAndCampaignId) {
20
+ if (!chainAndCampaignId.includes("-"))
21
+ throw new InvalidParameter("Campaign id should be formatted as chainId-campaignId");
22
+ const [chainId, campaignId] = chainAndCampaignId.split("-");
23
+ return { distributionChain: +chainId, campaignId };
24
+ }
18
25
  static async create(campaign) {
19
26
  const id = CampaignService.hashId({ distributionChain: campaign.chainId, campaignId: campaign.campaignId });
20
27
  await OpportunityService.createFromCampaign(campaign);
@@ -140,7 +147,8 @@ export class CampaignService {
140
147
  return await CampaignRepository.findUnique(campaign);
141
148
  }
142
149
  static async findUniqueOrThrow(campaign) {
143
- return await CampaignRepository.findUniqueOrThrow(campaign);
150
+ const id = typeof campaign === "string" ? campaign : CampaignService.hashId(campaign);
151
+ return await CampaignRepository.findUniqueOrThrow(id);
144
152
  }
145
153
  static async findCampaignsToProcess(distributionChainId) {
146
154
  return (await CampaignRepository.findCampaignsToProcess(distributionChainId)).filter(campaign => campaign.endTimestamp > campaign?.CampaignStatus?.[0]?.computedUntil);
@@ -61,13 +61,13 @@ export declare const DynamicDataController: Elysia<"/dynamic-data", {
61
61
  chainId?: number | undefined;
62
62
  startTimestamp?: string | undefined;
63
63
  endTimestamp?: string | undefined;
64
+ campaignStatus?: {} | undefined;
64
65
  distributionChainId?: number | undefined;
65
66
  campaignId?: string | undefined;
66
67
  rewardTokenId?: string | undefined;
67
68
  amount?: string | undefined;
68
69
  opportunityId?: string | undefined;
69
70
  creatorAddress?: string | undefined;
70
- campaignStatus?: {} | undefined;
71
71
  rewardToken?: {} | undefined;
72
72
  rewardTokenAddress?: string | undefined;
73
73
  distributionChain?: {} | undefined;
@@ -303,7 +303,6 @@ export declare const OpportunityController: Elysia<"/opportunities", {
303
303
  tags: string[];
304
304
  icon: string;
305
305
  } | null | undefined;
306
- depositUrl?: string | undefined;
307
306
  aprRecord?: {
308
307
  timestamp: string | bigint;
309
308
  cumulated: number;
@@ -315,6 +314,7 @@ export declare const OpportunityController: Elysia<"/opportunities", {
315
314
  aprRecordId: string;
316
315
  }[];
317
316
  } | undefined;
317
+ depositUrl?: string | undefined;
318
318
  tvlRecord?: {
319
319
  total: number;
320
320
  timestamp: string | bigint;
@@ -436,7 +436,6 @@ export declare const OpportunityController: Elysia<"/opportunities", {
436
436
  tags: string[];
437
437
  icon: string;
438
438
  } | null | undefined;
439
- depositUrl?: string | undefined;
440
439
  aprRecord?: {
441
440
  timestamp: string | bigint;
442
441
  cumulated: number;
@@ -448,6 +447,7 @@ export declare const OpportunityController: Elysia<"/opportunities", {
448
447
  aprRecordId: string;
449
448
  }[];
450
449
  } | undefined;
450
+ depositUrl?: string | undefined;
451
451
  tvlRecord?: {
452
452
  total: number;
453
453
  timestamp: string | bigint;
@@ -604,7 +604,6 @@ export declare const OpportunityController: Elysia<"/opportunities", {
604
604
  tags: string[];
605
605
  icon: string;
606
606
  } | null | undefined;
607
- depositUrl?: string | undefined;
608
607
  aprRecord?: {
609
608
  timestamp: string | bigint;
610
609
  cumulated: number;
@@ -616,6 +615,7 @@ export declare const OpportunityController: Elysia<"/opportunities", {
616
615
  aprRecordId: string;
617
616
  }[];
618
617
  } | undefined;
618
+ depositUrl?: string | undefined;
619
619
  tvlRecord?: {
620
620
  total: number;
621
621
  timestamp: string | bigint;
@@ -165,11 +165,6 @@ export declare const OpportunityWithCampaignsResourceDto: import("@sinclair/type
165
165
  icon: import("@sinclair/typebox").TString;
166
166
  }>;
167
167
  chainId: import("@sinclair/typebox").TNumber;
168
- action: import("@sinclair/typebox").TString;
169
- depositUrl: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
170
- tvl: import("@sinclair/typebox").TNumber;
171
- apr: import("@sinclair/typebox").TNumber;
172
- dailyRewards: import("@sinclair/typebox").TNumber;
173
168
  aprRecord: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
174
169
  cumulated: import("@sinclair/typebox").TNumber;
175
170
  timestamp: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TBigInt, import("@sinclair/typebox").TString]>;
@@ -185,6 +180,11 @@ export declare const OpportunityWithCampaignsResourceDto: import("@sinclair/type
185
180
  aprRecordId: import("@sinclair/typebox").TString;
186
181
  }>>;
187
182
  }>>;
183
+ action: import("@sinclair/typebox").TString;
184
+ depositUrl: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
185
+ tvl: import("@sinclair/typebox").TNumber;
186
+ apr: import("@sinclair/typebox").TNumber;
187
+ dailyRewards: import("@sinclair/typebox").TNumber;
188
188
  tvlRecord: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
189
189
  total: import("@sinclair/typebox").TNumber;
190
190
  timestamp: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TBigInt, import("@sinclair/typebox").TString]>;