@merkl/api 0.10.254 → 0.10.255

Sign up to get free protection for your applications and to get access to all the features.
@@ -107,7 +107,7 @@ declare const eden: {
107
107
  200: {
108
108
  id: string;
109
109
  chainId: number;
110
- type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
110
+ type: import("../../database/api/.generated").$Enums.CampaignType;
111
111
  identifier: string;
112
112
  name: string;
113
113
  status: "PAST" | "LIVE" | "SOON";
@@ -598,7 +598,7 @@ declare const eden: {
598
598
  tags?: string[] | undefined;
599
599
  identifier?: string | undefined;
600
600
  subType?: number | undefined;
601
- type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
601
+ type: number;
602
602
  params: string;
603
603
  creator: string;
604
604
  chainId: number;
@@ -2972,7 +2972,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
2972
2972
  200: {
2973
2973
  id: string;
2974
2974
  chainId: number;
2975
- type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
2975
+ type: import("../../database/api/.generated").$Enums.CampaignType;
2976
2976
  identifier: string;
2977
2977
  name: string;
2978
2978
  status: "PAST" | "LIVE" | "SOON";
@@ -3488,7 +3488,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
3488
3488
  tags?: string[] | undefined;
3489
3489
  identifier?: string | undefined;
3490
3490
  subType?: number | undefined;
3491
- type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
3491
+ type: number;
3492
3492
  params: string;
3493
3493
  creator: string;
3494
3494
  chainId: number;
@@ -6388,7 +6388,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
6388
6388
  200: {
6389
6389
  id: string;
6390
6390
  chainId: number;
6391
- type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
6391
+ type: import("../../database/api/.generated").$Enums.CampaignType;
6392
6392
  identifier: string;
6393
6393
  name: string;
6394
6394
  status: "PAST" | "LIVE" | "SOON";
@@ -6879,7 +6879,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
6879
6879
  tags?: string[] | undefined;
6880
6880
  identifier?: string | undefined;
6881
6881
  subType?: number | undefined;
6882
- type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
6882
+ type: number;
6883
6883
  params: string;
6884
6884
  creator: string;
6885
6885
  chainId: number;
@@ -189,7 +189,7 @@ declare const app: Elysia<"", false, {
189
189
  200: {
190
190
  id: string;
191
191
  chainId: number;
192
- type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
192
+ type: import("../database/api/.generated").$Enums.CampaignType;
193
193
  identifier: string;
194
194
  name: string;
195
195
  status: "PAST" | "LIVE" | "SOON";
@@ -705,7 +705,7 @@ declare const app: Elysia<"", false, {
705
705
  tags?: string[] | undefined;
706
706
  identifier?: string | undefined;
707
707
  subType?: number | undefined;
708
- type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
708
+ type: number;
709
709
  params: string;
710
710
  creator: string;
711
711
  chainId: number;
@@ -19,7 +19,7 @@ export declare const CampaignController: Elysia<"/campaigns", false, {
19
19
  tags?: string[] | undefined;
20
20
  identifier?: string | undefined;
21
21
  subType?: number | undefined;
22
- type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
22
+ type: number;
23
23
  params: string;
24
24
  creator: string;
25
25
  chainId: number;
@@ -92,24 +92,7 @@ export declare const CreateCampaignDto: import("@sinclair/typebox").TObject<{
92
92
  campaignId: import("@sinclair/typebox").TString;
93
93
  identifier: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
94
94
  creator: import("@sinclair/typebox").TString;
95
- type: import("@sinclair/typebox").TEnum<{
96
- INVALID: "INVALID";
97
- ERC20: "ERC20";
98
- CLAMM: "CLAMM";
99
- ERC20_SNAPSHOT: "ERC20_SNAPSHOT";
100
- JSON_AIRDROP: "JSON_AIRDROP";
101
- SILO: "SILO";
102
- RADIANT: "RADIANT";
103
- MORPHO: "MORPHO";
104
- DOLOMITE: "DOLOMITE";
105
- BADGER: "BADGER";
106
- COMPOUND: "COMPOUND";
107
- AJNA: "AJNA";
108
- EULER: "EULER";
109
- UNISWAP_V4: "UNISWAP_V4";
110
- ION: "ION";
111
- EIGENLAYER: "EIGENLAYER";
112
- }>;
95
+ type: import("@sinclair/typebox").TNumber;
113
96
  subType: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
114
97
  rewardTokenAddress: import("@sinclair/typebox").TString;
115
98
  amount: import("@sinclair/typebox").TString;
@@ -53,7 +53,7 @@ export const CreateCampaignDto = t.Object({
53
53
  campaignId: t.String(),
54
54
  identifier: t.Optional(t.String()),
55
55
  creator: t.String(),
56
- type: t.Enum(CampaignType),
56
+ type: t.Numeric(),
57
57
  subType: t.Optional(t.Number()),
58
58
  rewardTokenAddress: t.String(),
59
59
  amount: t.String(),
@@ -44,6 +44,7 @@ export class CampaignRepository {
44
44
  }
45
45
  // ─── Public Methods ──────────────────────────────────────────────────
46
46
  static async upsert(campaign) {
47
+ const campaignType = CampaignService.getTypeFromV3(campaign.type);
47
48
  try {
48
49
  const [rewardToken] = await TokenService.getManyOrCreate([
49
50
  { chainId: campaign.chainId, address: campaign.rewardTokenAddress },
@@ -55,7 +56,7 @@ export class CampaignRepository {
55
56
  const opportunityId = OpportunityService.hashId({
56
57
  chainId: campaign.computeChainId,
57
58
  identifier: campaign.opportunityIdentifier,
58
- type: campaign.type,
59
+ type: campaignType,
59
60
  });
60
61
  const data = {
61
62
  id: campaign.id,
@@ -64,7 +65,7 @@ export class CampaignRepository {
64
65
  endTimestamp: BigInt(campaign.endTimestamp),
65
66
  params,
66
67
  startTimestamp: BigInt(campaign.startTimestamp),
67
- type: campaign.type,
68
+ type: campaignType,
68
69
  ComputeChain: {
69
70
  connect: {
70
71
  id: campaign.computeChainId,
@@ -100,6 +101,7 @@ export class CampaignRepository {
100
101
  }
101
102
  }
102
103
  static async upsertMany(campaigns) {
104
+ const campaignType = CampaignService.getTypeFromV3(campaigns[0].type);
103
105
  const data = [];
104
106
  for (const campaign of campaigns) {
105
107
  const [rewardToken] = await TokenService.getManyOrCreate([
@@ -108,7 +110,7 @@ export class CampaignRepository {
108
110
  const opportunityId = OpportunityService.hashId({
109
111
  chainId: campaign.computeChainId,
110
112
  identifier: campaign.opportunityIdentifier,
111
- type: campaign.type,
113
+ type: campaignType,
112
114
  });
113
115
  data.push({
114
116
  id: campaign.id,
@@ -117,7 +119,7 @@ export class CampaignRepository {
117
119
  endTimestamp: BigInt(campaign.endTimestamp),
118
120
  params: JSON.parse(campaign.params),
119
121
  startTimestamp: BigInt(campaign.startTimestamp),
120
- type: campaign.type,
122
+ type: campaignType,
121
123
  ComputeChain: {
122
124
  connect: {
123
125
  id: campaign.computeChainId,
@@ -106,7 +106,7 @@ export class CampaignService {
106
106
  params: JSON.stringify(campaign.campaignParameters),
107
107
  rewardTokenAddress: campaign.rewardToken,
108
108
  startTimestamp: campaign.startTimestamp.toString(),
109
- type: CampaignService.getTypeFromV3(campaign.campaignType),
109
+ type: campaign.campaignType,
110
110
  subType: campaign.campaignSubType,
111
111
  };
112
112
  }));
@@ -58,7 +58,7 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
58
58
  200: {
59
59
  id: string;
60
60
  chainId: number;
61
- type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
61
+ type: import("../../../../database/api/.generated").$Enums.CampaignType;
62
62
  identifier: string;
63
63
  name: string;
64
64
  status: "PAST" | "LIVE" | "SOON";
@@ -14,7 +14,7 @@ export declare abstract class OpportunityService {
14
14
  static createFromCampaign(campaign: Omit<CreateCampaignModel, "id">): Promise<{
15
15
  id: string;
16
16
  chainId: number;
17
- type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
17
+ type: import("../../../../database/api/.generated").$Enums.CampaignType;
18
18
  identifier: string;
19
19
  name: string;
20
20
  status: "PAST" | "LIVE" | "SOON";
@@ -42,7 +42,7 @@ export declare abstract class OpportunityService {
42
42
  static recreate(opportunityId: string | OpportunityUnique): Promise<{
43
43
  id: string;
44
44
  chainId: number;
45
- type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
45
+ type: import("../../../../database/api/.generated").$Enums.CampaignType;
46
46
  identifier: string;
47
47
  name: string;
48
48
  status: "PAST" | "LIVE" | "SOON";
@@ -1,5 +1,5 @@
1
1
  import { NotFoundError } from "../../../errors";
2
- import { CampaignService } from "../campaign";
2
+ import { CampaignService, campaignTypeToEnumMap } from "../campaign";
3
3
  import { log } from "../../../utils/logger";
4
4
  import { OpportunityAction, Prisma, Status } from "../../../../database/api/.generated";
5
5
  import { record } from "@elysiajs/opentelemetry";
@@ -35,19 +35,20 @@ export class OpportunityService {
35
35
  return await OpportunityRepository.upsert({ ...newOpp, id });
36
36
  }
37
37
  static async createFromCampaign(campaign) {
38
+ const campaignType = CampaignService.getTypeFromV3(campaign.type);
38
39
  const metadata = await OpportunityService.getMetadata(campaign);
39
40
  metadata.tags = [...((await UserService.findUnique(campaign.creator))?.tags ?? []), ...(campaign?.tags ?? [])];
40
41
  const opportunityId = OpportunityService.hashId({
41
42
  chainId: campaign.computeChainId,
42
43
  identifier: campaign.opportunityIdentifier,
43
- type: campaign.type,
44
+ type: campaignType,
44
45
  });
45
46
  const tokens = (await TokenService.getManyOrCreate(metadata.tokens)).filter(t => t !== undefined);
46
47
  const params = JSON.parse(campaign.params);
47
48
  const opportunity = {
48
49
  id: opportunityId,
49
50
  chainId: campaign.computeChainId,
50
- type: campaign.type,
51
+ type: campaignType,
51
52
  identifier: campaign.opportunityIdentifier, // mainParameter
52
53
  name: metadata.name,
53
54
  status: +campaign.startTimestamp >= new Date().getTime() * 1000
@@ -75,6 +76,7 @@ export class OpportunityService {
75
76
  const firstCampaign = opportunity?.Campaigns[0];
76
77
  return await OpportunityService.createFromCampaign({
77
78
  ...firstCampaign,
79
+ type: campaignTypeToEnumMap[firstCampaign.type],
78
80
  chainId: firstCampaign.distributionChainId,
79
81
  creator: firstCampaign.creatorAddress,
80
82
  rewardTokenAddress: firstCampaign.RewardToken.address,
@@ -91,9 +93,10 @@ export class OpportunityService {
91
93
  * @returns {OpportunityMetadata}
92
94
  */
93
95
  static async getMetadata(campaign) {
96
+ const campaignType = CampaignService.getTypeFromV3(campaign.type);
94
97
  const campaignParams = JSON.parse(campaign.params);
95
98
  const chainId = campaign.computeChainId === 0 ? campaign.chainId : campaign.computeChainId;
96
- switch (campaign.type) {
99
+ switch (campaignType) {
97
100
  case "CLAMM":
98
101
  return getClammMetadata(chainId, campaignParams);
99
102
  case "ERC20":
@@ -67,7 +67,7 @@ export declare const v4: Elysia<"/v4", false, {
67
67
  200: {
68
68
  id: string;
69
69
  chainId: number;
70
- type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
70
+ type: import("../../../database/api/.generated").$Enums.CampaignType;
71
71
  identifier: string;
72
72
  name: string;
73
73
  status: "PAST" | "LIVE" | "SOON";
@@ -583,7 +583,7 @@ export declare const v4: Elysia<"/v4", false, {
583
583
  tags?: string[] | undefined;
584
584
  identifier?: string | undefined;
585
585
  subType?: number | undefined;
586
- type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
586
+ type: number;
587
587
  params: string;
588
588
  creator: string;
589
589
  chainId: number;