@merkl/api 0.10.254 → 0.10.256

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.
@@ -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;
@@ -812,6 +812,7 @@ declare const eden: {
812
812
  get: (options: {
813
813
  headers?: Record<string, unknown> | undefined;
814
814
  query: {
815
+ name?: string | undefined;
815
816
  id?: string | undefined;
816
817
  items?: number | undefined;
817
818
  tags?: string[] | undefined;
@@ -2972,7 +2973,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
2972
2973
  200: {
2973
2974
  id: string;
2974
2975
  chainId: number;
2975
- type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
2976
+ type: import("../../database/api/.generated").$Enums.CampaignType;
2976
2977
  identifier: string;
2977
2978
  name: string;
2978
2979
  status: "PAST" | "LIVE" | "SOON";
@@ -3488,7 +3489,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
3488
3489
  tags?: string[] | undefined;
3489
3490
  identifier?: string | undefined;
3490
3491
  subType?: number | undefined;
3491
- type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
3492
+ type: number;
3492
3493
  params: string;
3493
3494
  creator: string;
3494
3495
  chainId: number;
@@ -3689,6 +3690,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
3689
3690
  body: unknown;
3690
3691
  params: {};
3691
3692
  query: {
3693
+ name?: string | undefined;
3692
3694
  id?: string | undefined;
3693
3695
  items?: number | undefined;
3694
3696
  tags?: string[] | undefined;
@@ -6388,7 +6390,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
6388
6390
  200: {
6389
6391
  id: string;
6390
6392
  chainId: number;
6391
- type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
6393
+ type: import("../../database/api/.generated").$Enums.CampaignType;
6392
6394
  identifier: string;
6393
6395
  name: string;
6394
6396
  status: "PAST" | "LIVE" | "SOON";
@@ -6879,7 +6881,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
6879
6881
  tags?: string[] | undefined;
6880
6882
  identifier?: string | undefined;
6881
6883
  subType?: number | undefined;
6882
- type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
6884
+ type: number;
6883
6885
  params: string;
6884
6886
  creator: string;
6885
6887
  chainId: number;
@@ -7093,6 +7095,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
7093
7095
  get: (options: {
7094
7096
  headers?: Record<string, unknown> | undefined;
7095
7097
  query: {
7098
+ name?: string | undefined;
7096
7099
  id?: string | undefined;
7097
7100
  items?: number | undefined;
7098
7101
  tags?: string[] | undefined;
@@ -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;
@@ -906,6 +906,7 @@ declare const app: Elysia<"", false, {
906
906
  body: unknown;
907
907
  params: {};
908
908
  query: {
909
+ name?: string | undefined;
909
910
  id?: string | undefined;
910
911
  items?: number | undefined;
911
912
  tags?: string[] | undefined;
@@ -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":
@@ -18,6 +18,7 @@ export declare const ProtocolController: Elysia<"/protocols", false, {
18
18
  body: unknown;
19
19
  params: {};
20
20
  query: {
21
+ name?: string | undefined;
21
22
  id?: string | undefined;
22
23
  items?: number | undefined;
23
24
  tags?: string[] | undefined;
@@ -17,6 +17,7 @@ export declare const ProtocolResourceDto: import("@sinclair/typebox").TObject<{
17
17
  }>;
18
18
  export declare const GetProtocolsQueryDto: import("@sinclair/typebox").TObject<{
19
19
  id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
20
+ name: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
20
21
  tags: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
21
22
  opportunityTag: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
22
23
  page: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
@@ -79,6 +79,7 @@ export const ProtocolResourceDto = t.Object({
79
79
  });
80
80
  export const GetProtocolsQueryDto = t.Object({
81
81
  id: t.Optional(t.String({ description: "Filter results by name. Useful for searching a protocol to verify its integration" })),
82
+ name: t.Optional(t.String({ description: "Search protocols by name" })),
82
83
  tags: t.Optional(t.Array(t.String())),
83
84
  opportunityTag: t.Optional(t.String({ description: "Filter by underlying opportunities' tag" })),
84
85
  page: t.Optional(t.Numeric({ description: "0-indexed page number", default: 0 })),
@@ -24,6 +24,7 @@ export class ProtocolRepository {
24
24
  where: {
25
25
  id: query.id ? { contains: query.id, mode: "insensitive" } : undefined,
26
26
  tags: query.tags ? { hasEvery: query.tags } : undefined,
27
+ name: query.name ? { contains: query.name, mode: "insensitive" } : undefined,
27
28
  OR: query.opportunityTag // The opportunity tag specified can be either at the protocol level or the opportunity level
28
29
  ? [
29
30
  {
@@ -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;
@@ -784,6 +784,7 @@ export declare const v4: Elysia<"/v4", false, {
784
784
  body: unknown;
785
785
  params: {};
786
786
  query: {
787
+ name?: string | undefined;
787
788
  id?: string | undefined;
788
789
  items?: number | undefined;
789
790
  tags?: string[] | undefined;