@merkl/api 0.10.345 → 0.10.347

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 (26) hide show
  1. package/dist/src/cache/declaration.d.ts +5 -0
  2. package/dist/src/cache/declaration.js +5 -0
  3. package/dist/src/eden/index.d.ts +139 -4
  4. package/dist/src/index.d.ts +51 -1
  5. package/dist/src/libs/campaigns/utils/getUniswapV4Pools.d.ts +7 -0
  6. package/dist/src/libs/campaigns/utils/getUniswapV4Pools.js +109 -0
  7. package/dist/src/modules/v4/campaign/campaign.controller.d.ts +32 -0
  8. package/dist/src/modules/v4/campaign/campaign.controller.js +7 -1
  9. package/dist/src/modules/v4/campaign/campaign.model.d.ts +10 -2
  10. package/dist/src/modules/v4/campaign/campaign.model.js +7 -2
  11. package/dist/src/modules/v4/campaign/campaign.repository.d.ts +16 -1
  12. package/dist/src/modules/v4/campaign/campaign.repository.js +7 -1
  13. package/dist/src/modules/v4/campaign/campaign.service.d.ts +16 -1
  14. package/dist/src/modules/v4/campaign/campaign.service.js +14 -1
  15. package/dist/src/modules/v4/opportunity/opportunity.model.d.ts +2 -2
  16. package/dist/src/modules/v4/opportunity/opportunity.model.js +2 -2
  17. package/dist/src/modules/v4/programPayload/programPayload.repository.d.ts +2 -1
  18. package/dist/src/modules/v4/programPayload/programPayload.repository.js +15 -4
  19. package/dist/src/modules/v4/router.d.ts +32 -0
  20. package/dist/src/routes/v3/campaigns.d.ts +1 -1
  21. package/dist/src/routes/v3/router.d.ts +19 -1
  22. package/dist/src/routes/v3/router.js +3 -1
  23. package/dist/src/routes/v3/uniswapv4.d.ts +45 -0
  24. package/dist/src/routes/v3/uniswapv4.js +9 -0
  25. package/dist/tsconfig.package.tsbuildinfo +1 -1
  26. package/package.json +1 -1
@@ -125,4 +125,9 @@ export declare const CacheDeclaration: {
125
125
  redisTTL: TTLType.Minutes2;
126
126
  localCache: true;
127
127
  };
128
+ UniswapV4Pools: {
129
+ compressed: false;
130
+ redisTTL: TTLType.Minutes30;
131
+ localCache: false;
132
+ };
128
133
  };
@@ -113,4 +113,9 @@ export const CacheDeclaration = {
113
113
  redisTTL: TTLType.Minutes2,
114
114
  localCache: true,
115
115
  },
116
+ UniswapV4Pools: {
117
+ compressed: false,
118
+ redisTTL: TTLType.Minutes30,
119
+ localCache: false,
120
+ },
116
121
  };
@@ -1,4 +1,4 @@
1
- import type { Campaign as CampaignResource } from "../modules/v4";
1
+ import type { Campaign as CampaignResource, CampaignWithParams } from "../modules/v4";
2
2
  import type { CampaignType } from "../../database/api/.generated";
3
3
  declare const eden: {
4
4
  index: {
@@ -724,6 +724,35 @@ declare const eden: {
724
724
  200: string;
725
725
  }>>;
726
726
  };
727
+ metadata: {
728
+ patch: (body: {
729
+ url: string;
730
+ campaignId: string;
731
+ distributionChain: number;
732
+ }, options: {
733
+ headers: {
734
+ authorization: string;
735
+ };
736
+ query?: Record<string, unknown> | undefined;
737
+ fetch?: RequestInit | undefined;
738
+ }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
739
+ 200: {
740
+ type: import("../../database/api/.generated").$Enums.CampaignType;
741
+ id: string;
742
+ params: import("database/api/.generated/runtime/library").JsonValue;
743
+ subType: number | null;
744
+ startTimestamp: bigint;
745
+ endTimestamp: bigint;
746
+ computeChainId: number;
747
+ distributionChainId: number;
748
+ campaignId: string;
749
+ rewardTokenId: string;
750
+ amount: string;
751
+ opportunityId: string;
752
+ creatorAddress: string;
753
+ };
754
+ }>>;
755
+ };
727
756
  index: {
728
757
  get: (options: {
729
758
  headers?: Record<string, unknown> | undefined;
@@ -2612,8 +2641,8 @@ declare const eden: {
2612
2641
  query: {
2613
2642
  types?: string | number | string[] | number[] | undefined;
2614
2643
  chainIds?: string | string[] | undefined;
2615
- live?: boolean | undefined;
2616
2644
  creatorTag?: string | undefined;
2645
+ live?: boolean | undefined;
2617
2646
  hideTestTokens?: string | undefined;
2618
2647
  };
2619
2648
  fetch?: RequestInit | undefined;
@@ -3130,6 +3159,19 @@ declare const eden: {
3130
3159
  };
3131
3160
  }>>;
3132
3161
  };
3162
+ uniswapv4: {
3163
+ get: (options: {
3164
+ headers?: Record<string, unknown> | undefined;
3165
+ query: {};
3166
+ fetch?: RequestInit | undefined;
3167
+ }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
3168
+ 200: {
3169
+ [x: string]: {
3170
+ [poolId: string]: UniswapV4PoolType;
3171
+ } | undefined;
3172
+ };
3173
+ }>>;
3174
+ };
3133
3175
  };
3134
3176
  };
3135
3177
  type Api = typeof eden;
@@ -3993,6 +4035,38 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
3993
4035
  };
3994
4036
  };
3995
4037
  };
4038
+ } & {
4039
+ metadata: {
4040
+ patch: {
4041
+ body: {
4042
+ url: string;
4043
+ campaignId: string;
4044
+ distributionChain: number;
4045
+ };
4046
+ params: {};
4047
+ query: unknown;
4048
+ headers: {
4049
+ authorization: string;
4050
+ };
4051
+ response: {
4052
+ 200: {
4053
+ type: import("../../database/api/.generated").$Enums.CampaignType;
4054
+ id: string;
4055
+ params: import("database/api/.generated/runtime/library").JsonValue;
4056
+ subType: number | null;
4057
+ startTimestamp: bigint;
4058
+ endTimestamp: bigint;
4059
+ computeChainId: number;
4060
+ distributionChainId: number;
4061
+ campaignId: string;
4062
+ rewardTokenId: string;
4063
+ amount: string;
4064
+ opportunityId: string;
4065
+ creatorAddress: string;
4066
+ };
4067
+ };
4068
+ };
4069
+ };
3996
4070
  } & {
3997
4071
  index: {
3998
4072
  get: {
@@ -6393,8 +6467,8 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
6393
6467
  query: {
6394
6468
  types?: string | number | string[] | number[] | undefined;
6395
6469
  chainIds?: string | string[] | undefined;
6396
- live?: boolean | undefined;
6397
6470
  creatorTag?: string | undefined;
6471
+ live?: boolean | undefined;
6398
6472
  hideTestTokens?: string | undefined;
6399
6473
  };
6400
6474
  headers: unknown;
@@ -7068,6 +7142,24 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
7068
7142
  };
7069
7143
  };
7070
7144
  };
7145
+ } & {
7146
+ v3: {
7147
+ uniswapv4: {
7148
+ get: {
7149
+ body: unknown;
7150
+ params: {};
7151
+ query: {};
7152
+ headers: unknown;
7153
+ response: {
7154
+ 200: {
7155
+ [x: string]: {
7156
+ [poolId: string]: UniswapV4PoolType;
7157
+ } | undefined;
7158
+ };
7159
+ };
7160
+ };
7161
+ };
7162
+ };
7071
7163
  }, {
7072
7164
  derive: {};
7073
7165
  resolve: {};
@@ -7800,6 +7892,35 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
7800
7892
  200: string;
7801
7893
  }>>;
7802
7894
  };
7895
+ metadata: {
7896
+ patch: (body: {
7897
+ url: string;
7898
+ campaignId: string;
7899
+ distributionChain: number;
7900
+ }, options: {
7901
+ headers: {
7902
+ authorization: string;
7903
+ };
7904
+ query?: Record<string, unknown> | undefined;
7905
+ fetch?: RequestInit | undefined;
7906
+ }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
7907
+ 200: {
7908
+ type: import("../../database/api/.generated").$Enums.CampaignType;
7909
+ id: string;
7910
+ params: import("database/api/.generated/runtime/library").JsonValue;
7911
+ subType: number | null;
7912
+ startTimestamp: bigint;
7913
+ endTimestamp: bigint;
7914
+ computeChainId: number;
7915
+ distributionChainId: number;
7916
+ campaignId: string;
7917
+ rewardTokenId: string;
7918
+ amount: string;
7919
+ opportunityId: string;
7920
+ creatorAddress: string;
7921
+ };
7922
+ }>>;
7923
+ };
7803
7924
  index: {
7804
7925
  get: (options: {
7805
7926
  headers?: Record<string, unknown> | undefined;
@@ -9688,8 +9809,8 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
9688
9809
  query: {
9689
9810
  types?: string | number | string[] | number[] | undefined;
9690
9811
  chainIds?: string | string[] | undefined;
9691
- live?: boolean | undefined;
9692
9812
  creatorTag?: string | undefined;
9813
+ live?: boolean | undefined;
9693
9814
  hideTestTokens?: string | undefined;
9694
9815
  };
9695
9816
  fetch?: RequestInit | undefined;
@@ -10206,11 +10327,25 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
10206
10327
  };
10207
10328
  }>>;
10208
10329
  };
10330
+ uniswapv4: {
10331
+ get: (options: {
10332
+ headers?: Record<string, unknown> | undefined;
10333
+ query: {};
10334
+ fetch?: RequestInit | undefined;
10335
+ }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
10336
+ 200: {
10337
+ [x: string]: {
10338
+ [poolId: string]: UniswapV4PoolType;
10339
+ } | undefined;
10340
+ };
10341
+ }>>;
10342
+ };
10209
10343
  };
10210
10344
  };
10211
10345
  export type Opportunity = FromPromise<Api["v4"]["opportunities"]["index"]["get"]>;
10212
10346
  export type Protocol = FromPromise<Api["v4"]["protocols"]["index"]["get"]>;
10213
10347
  export type Campaign<C extends CampaignType = CampaignType> = CampaignResource<C>["model"];
10348
+ export type CampaignParams<C extends CampaignType = CampaignType> = CampaignWithParams<C>["model"]["params"];
10214
10349
  export type Chain = FromPromise<Api["v4"]["chains"]["index"]["get"]>;
10215
10350
  export type Explorer = FromPromise<Api["v4"]["chains"]["index"]["get"]>["explorers"][number];
10216
10351
  export type Token = FromPromise<Api["v4"]["tokens"]["index"]["get"]>;
@@ -852,6 +852,38 @@ declare const app: Elysia<"", false, {
852
852
  };
853
853
  };
854
854
  };
855
+ } & {
856
+ metadata: {
857
+ patch: {
858
+ body: {
859
+ url: string;
860
+ campaignId: string;
861
+ distributionChain: number;
862
+ };
863
+ params: {};
864
+ query: unknown;
865
+ headers: {
866
+ authorization: string;
867
+ };
868
+ response: {
869
+ 200: {
870
+ type: import("../database/api/.generated").$Enums.CampaignType;
871
+ id: string;
872
+ params: import("database/api/.generated/runtime/library").JsonValue;
873
+ subType: number | null;
874
+ startTimestamp: bigint;
875
+ endTimestamp: bigint;
876
+ computeChainId: number;
877
+ distributionChainId: number;
878
+ campaignId: string;
879
+ rewardTokenId: string;
880
+ amount: string;
881
+ opportunityId: string;
882
+ creatorAddress: string;
883
+ };
884
+ };
885
+ };
886
+ };
855
887
  } & {
856
888
  index: {
857
889
  get: {
@@ -3252,8 +3284,8 @@ declare const app: Elysia<"", false, {
3252
3284
  query: {
3253
3285
  types?: string | number | string[] | number[] | undefined;
3254
3286
  chainIds?: string | string[] | undefined;
3255
- live?: boolean | undefined;
3256
3287
  creatorTag?: string | undefined;
3288
+ live?: boolean | undefined;
3257
3289
  hideTestTokens?: string | undefined;
3258
3290
  };
3259
3291
  headers: unknown;
@@ -3927,6 +3959,24 @@ declare const app: Elysia<"", false, {
3927
3959
  };
3928
3960
  };
3929
3961
  };
3962
+ } & {
3963
+ v3: {
3964
+ uniswapv4: {
3965
+ get: {
3966
+ body: unknown;
3967
+ params: {};
3968
+ query: {};
3969
+ headers: unknown;
3970
+ response: {
3971
+ 200: {
3972
+ [x: string]: {
3973
+ [poolId: string]: UniswapV4PoolType;
3974
+ } | undefined;
3975
+ };
3976
+ };
3977
+ };
3978
+ };
3979
+ };
3930
3980
  }, {
3931
3981
  derive: {};
3932
3982
  resolve: {};
@@ -0,0 +1,7 @@
1
+ import { type MerklChainId, type UniswapV4PoolType } from "@sdk";
2
+ export type UniswapV4PoolsReturnType = {
3
+ [chainId in MerklChainId]?: {
4
+ [poolId: string]: UniswapV4PoolType;
5
+ };
6
+ };
7
+ export declare const getUniswapV4PoolsWithCache: () => Promise<UniswapV4PoolsReturnType>;
@@ -0,0 +1,109 @@
1
+ import { Redis } from "../../../cache";
2
+ import { log } from "../../../utils/logger";
3
+ import { providers } from "../../../utils/providers";
4
+ import { ChainInteractionService, ERC20Interface, NETWORK_LABELS, NULL_ADDRESS, PoolManagerInterface, UniswapV4Addresses, getContractCreationBlock, } from "@sdk";
5
+ import { safeFetchLogs } from "./fetchLogs";
6
+ const UNIV4_CHAINIDS = Object.keys(UniswapV4Addresses).map((x) => Number(x));
7
+ async function getUniswapV4Pools() {
8
+ const res = {};
9
+ for (let chainId of UNIV4_CHAINIDS) {
10
+ chainId = chainId;
11
+ res[chainId] = {};
12
+ const poolManagerAddress = UniswapV4Addresses[chainId]?.PoolManager ?? NULL_ADDRESS;
13
+ const jsonRPCprovider = providers[chainId];
14
+ try {
15
+ const fromBlock = await getContractCreationBlock(poolManagerAddress, jsonRPCprovider);
16
+ const toBlock = await jsonRPCprovider.getBlockNumber();
17
+ const logs = await safeFetchLogs(chainId, // TODO: rm type enforcing
18
+ [PoolManagerInterface.getEventTopic("Initialize")], [poolManagerAddress], fromBlock, toBlock);
19
+ const decodedPools = await Promise.all(logs.map(async (log) => {
20
+ const [id, currency0, currency1, fee, tickSpacing, hooks] = PoolManagerInterface.decodeEventLog("Initialize", log.data, log.topics);
21
+ // Respect typing
22
+ return {
23
+ poolId: id,
24
+ chainId: chainId,
25
+ currency0: currency0,
26
+ currency1: currency1,
27
+ tickSpacing: tickSpacing,
28
+ lpFee: fee,
29
+ hooks: hooks,
30
+ initializeBlock: Number(log.blockNumber),
31
+ };
32
+ }));
33
+ log.local(`fetched ${decodedPools.length} pool(s) on ${NETWORK_LABELS[chainId] ?? "Sepolia"} between blocks ${fromBlock} and ${toBlock}`);
34
+ /** Extra calls batch to get the collateral addresses */
35
+ const resCurrencies = await ChainInteractionService(chainId).fetchState(decodedPools.flatMap(pool => {
36
+ return [
37
+ {
38
+ allowFailure: true,
39
+ callData: ERC20Interface.encodeFunctionData("symbol"),
40
+ target: pool.currency0,
41
+ },
42
+ {
43
+ allowFailure: true,
44
+ callData: ERC20Interface.encodeFunctionData("decimals"),
45
+ target: pool.currency0,
46
+ },
47
+ {
48
+ allowFailure: true,
49
+ callData: ERC20Interface.encodeFunctionData("symbol"),
50
+ target: pool.currency1,
51
+ },
52
+ {
53
+ allowFailure: true,
54
+ callData: ERC20Interface.encodeFunctionData("decimals"),
55
+ target: pool.currency1,
56
+ },
57
+ ].filter(x => x.target !== NULL_ADDRESS);
58
+ }));
59
+ let index = 0;
60
+ for (const pool of decodedPools) {
61
+ let symbolCurrency0;
62
+ let decimalsCurrency0;
63
+ if (pool.currency0 !== NULL_ADDRESS) {
64
+ symbolCurrency0 = ERC20Interface.decodeFunctionResult("symbol", resCurrencies[index].returnData)[0];
65
+ decimalsCurrency0 = ERC20Interface.decodeFunctionResult("decimals", resCurrencies[index + 1].returnData)[0];
66
+ }
67
+ else {
68
+ symbolCurrency0 = "ETH";
69
+ decimalsCurrency0 = 18;
70
+ index -= 2;
71
+ }
72
+ let symbolCurrency1;
73
+ let decimalsCurrency1;
74
+ if (pool.currency1 !== NULL_ADDRESS) {
75
+ symbolCurrency1 = ERC20Interface.decodeFunctionResult("symbol", resCurrencies[index + 2].returnData)[0];
76
+ decimalsCurrency1 = ERC20Interface.decodeFunctionResult("decimals", resCurrencies[index + 3].returnData)[0];
77
+ }
78
+ else {
79
+ symbolCurrency1 = "ETH";
80
+ decimalsCurrency1 = 18;
81
+ index -= 2;
82
+ }
83
+ const id = pool.poolId;
84
+ res[chainId][id ?? "unknownKey"] = {
85
+ chainId: pool.chainId,
86
+ currency0: pool.currency0,
87
+ currency1: pool.currency1,
88
+ decimalsCurrency0,
89
+ decimalsCurrency1,
90
+ hooks: pool.hooks,
91
+ initializeBlock: pool.initializeBlock,
92
+ lpFee: pool.lpFee,
93
+ poolId: id,
94
+ poolKey: pool.poolKey,
95
+ symbolCurrency0,
96
+ symbolCurrency1,
97
+ tickSpacing: pool.tickSpacing,
98
+ };
99
+ index += 4;
100
+ }
101
+ }
102
+ catch (e) {
103
+ log.error(`issue when fetching UniswapV4 pools on ${chainId}`, e);
104
+ }
105
+ }
106
+ log.info("✅ successfully fetched pools on UniswapV4");
107
+ return res;
108
+ }
109
+ export const getUniswapV4PoolsWithCache = async () => await Redis.getOrSet("UniswapV4Pools", getUniswapV4Pools);
@@ -74,6 +74,38 @@ export declare const CampaignController: Elysia<"/campaigns", false, {
74
74
  };
75
75
  };
76
76
  };
77
+ } & {
78
+ metadata: {
79
+ patch: {
80
+ body: {
81
+ url: string;
82
+ campaignId: string;
83
+ distributionChain: number;
84
+ };
85
+ params: {};
86
+ query: unknown;
87
+ headers: {
88
+ authorization: string;
89
+ };
90
+ response: {
91
+ 200: {
92
+ type: import("../../../../database/api/.generated").$Enums.CampaignType;
93
+ id: string;
94
+ params: import("database/api/.generated/runtime/library").JsonValue;
95
+ subType: number | null;
96
+ startTimestamp: bigint;
97
+ endTimestamp: bigint;
98
+ computeChainId: number;
99
+ distributionChainId: number;
100
+ campaignId: string;
101
+ rewardTokenId: string;
102
+ amount: string;
103
+ opportunityId: string;
104
+ creatorAddress: string;
105
+ };
106
+ };
107
+ };
108
+ };
77
109
  } & {
78
110
  index: {
79
111
  get: {
@@ -3,7 +3,7 @@ import { AuthorizationHeadersDto, EngineGuard } from "../../../guards/Engine.gua
3
3
  import Elysia, { t } from "elysia";
4
4
  import { throwOnUnsupportedChainId } from "src/utils/throw";
5
5
  import { ChainUniqueDto } from "../chain";
6
- import { CampaignResourceDto, CreateCampaignDto, GetCampaignQueryDto, UpdateCampaignDto } from "./campaign.model";
6
+ import { CampaignResourceDto, CreateCampaignDto, GetCampaignQueryDto, UpdateCampaignDto, UpdateMetaDataCampaignDto, } from "./campaign.model";
7
7
  import { CampaignService } from "./campaign.service";
8
8
  // ─── Campaigns Controller ────────────────────────────────────────────────────
9
9
  export const CampaignController = new Elysia({ prefix: "/campaigns", detail: { tags: ["Campaigns"] } })
@@ -19,6 +19,12 @@ export const CampaignController = new Elysia({ prefix: "/campaigns", detail: { t
19
19
  headers: AuthorizationHeadersDto,
20
20
  body: UpdateCampaignDto,
21
21
  detail: { hide: true },
22
+ })
23
+ .patch("/metadata", async ({ body }) => await CampaignService.updateMetaData(body), {
24
+ beforeHandle: BackOfficeGuard,
25
+ headers: AuthorizationHeadersDto,
26
+ body: UpdateMetaDataCampaignDto,
27
+ detail: { hide: true },
22
28
  })
23
29
  // ─── Get Many Campaigns ──────────────────────────────────────────────
24
30
  .get("/", async ({ query }) => await CampaignService.findMany(query), {
@@ -2,8 +2,8 @@ import type { Resource } from "../prisma";
2
2
  import { type Token } from "../token";
3
3
  import { CampaignType } from "../../../../database/api/.generated";
4
4
  import { type CampaignParameters } from "@sdk";
5
- import { type Chain } from "../chain";
6
- import { type Status } from "../status";
5
+ import { type Chain } from "../chain/chain.model";
6
+ import { type Status } from "../status/status.model";
7
7
  /**
8
8
  * Campaign
9
9
  * @description Target description of rewards campaigns
@@ -112,6 +112,11 @@ export declare const UpdateCampaignDto: import("@sinclair/typebox").TObject<{
112
112
  opportunityIdentifier: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
113
113
  tags: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
114
114
  }>;
115
+ export declare const UpdateMetaDataCampaignDto: import("@sinclair/typebox").TObject<{
116
+ distributionChain: import("@sinclair/typebox").TNumber;
117
+ campaignId: import("@sinclair/typebox").TString;
118
+ url: import("@sinclair/typebox").TString;
119
+ }>;
115
120
  export declare const GetCampaignQueryDto: import("@sinclair/typebox").TObject<{
116
121
  creatorTag: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
117
122
  chainId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
@@ -156,6 +161,9 @@ export type CreateCampaignModel = typeof CreateCampaignDto.static & {
156
161
  export type UpdateCampaignModel = typeof UpdateCampaignDto.static & {
157
162
  id: string;
158
163
  };
164
+ export type UpdateMetaDataCampaignModel = typeof UpdateMetaDataCampaignDto.static & {
165
+ url: string;
166
+ };
159
167
  export type extendedUpdateCampaignModel = UpdateCampaignModel & {
160
168
  opportunityId: string;
161
169
  };
@@ -2,8 +2,8 @@ import { TokenResourceDto } from "../token";
2
2
  import { CampaignType } from "../../../../database/api/.generated";
3
3
  import { Campaign as CampaignTypeEnum } from "@sdk";
4
4
  import { t } from "elysia";
5
- import { ChainResourceDto } from "../chain";
6
- import { CampaignStatusResourceDto } from "../status";
5
+ import { ChainResourceDto } from "../chain/chain.model";
6
+ import { CampaignStatusResourceDto } from "../status/status.model";
7
7
  // ─── Utils ───────────────────────────────────────────────────────────────────
8
8
  export const campaignTypeToEnumMap = {
9
9
  INVALID: CampaignTypeEnum.INVALID,
@@ -73,6 +73,11 @@ export const UpdateCampaignDto = t.Object({
73
73
  opportunityIdentifier: t.Optional(t.String()),
74
74
  tags: t.Optional(t.Array(t.String())),
75
75
  });
76
+ export const UpdateMetaDataCampaignDto = t.Object({
77
+ distributionChain: t.Numeric(),
78
+ campaignId: t.String(),
79
+ url: t.String(),
80
+ });
76
81
  export const GetCampaignQueryDto = t.Object({
77
82
  creatorTag: t.Optional(t.String({ description: "Filter campaigns created by a user who has a specific tag" })),
78
83
  chainId: t.Optional(t.Numeric({
@@ -135,7 +135,22 @@ export declare abstract class CampaignRepository {
135
135
  campaignId: string;
136
136
  }[]>;
137
137
  static findChains(): Promise<Record<string, ChainId>>;
138
- static update(id: string, data: extendedUpdateCampaignModel): Promise<{
138
+ static updateOpportunity(id: string, data: extendedUpdateCampaignModel): Promise<{
139
+ type: import("../../../../database/api/.generated").$Enums.CampaignType;
140
+ id: string;
141
+ params: Prisma.JsonValue;
142
+ subType: number | null;
143
+ startTimestamp: bigint;
144
+ endTimestamp: bigint;
145
+ computeChainId: number;
146
+ distributionChainId: number;
147
+ campaignId: string;
148
+ rewardTokenId: string;
149
+ amount: string;
150
+ opportunityId: string;
151
+ creatorAddress: string;
152
+ }>;
153
+ static updateMetaData(id: string, params: string): Promise<{
139
154
  type: import("../../../../database/api/.generated").$Enums.CampaignType;
140
155
  id: string;
141
156
  params: Prisma.JsonValue;
@@ -313,7 +313,7 @@ export class CampaignRepository {
313
313
  return acc;
314
314
  }, {});
315
315
  }
316
- static async update(id, data) {
316
+ static async updateOpportunity(id, data) {
317
317
  const updateData = {
318
318
  Opportunity: {
319
319
  connect: { id: data.opportunityId },
@@ -321,4 +321,10 @@ export class CampaignRepository {
321
321
  };
322
322
  return await apiDbClient.campaign.update({ where: { id }, data: updateData });
323
323
  }
324
+ static async updateMetaData(id, params) {
325
+ const updateData = {
326
+ params: JSON.parse(params),
327
+ };
328
+ return await apiDbClient.campaign.update({ where: { id }, data: updateData });
329
+ }
324
330
  }
@@ -1,4 +1,4 @@
1
- import { type CampaignUnique, type CampaignWithParams, type ConvertedCampaignType, type CreateCampaignModel, type GetCampaignQueryModel, type UpdateCampaignModel } from "./";
1
+ import { type CampaignUnique, type CampaignWithParams, type ConvertedCampaignType, type CreateCampaignModel, type GetCampaignQueryModel, type UpdateCampaignModel, type UpdateMetaDataCampaignModel } from "./";
2
2
  import { CampaignRepository } from "./campaign.repository";
3
3
  import type { CampaignType } from "../../../../database/api/.generated";
4
4
  import { type CampaignParameters, type Campaign as CampaignTypeV3, type ChainId } from "@sdk";
@@ -19,6 +19,21 @@ export declare abstract class CampaignService {
19
19
  opportunityId: string;
20
20
  creatorAddress: string;
21
21
  } | undefined>;
22
+ static updateMetaData(campaign: Omit<UpdateMetaDataCampaignModel, "id">): Promise<{
23
+ type: import("../../../../database/api/.generated").$Enums.CampaignType;
24
+ id: string;
25
+ params: import("database/api/.generated/runtime/library").JsonValue;
26
+ subType: number | null;
27
+ startTimestamp: bigint;
28
+ endTimestamp: bigint;
29
+ computeChainId: number;
30
+ distributionChainId: number;
31
+ campaignId: string;
32
+ rewardTokenId: string;
33
+ amount: string;
34
+ opportunityId: string;
35
+ creatorAddress: string;
36
+ }>;
22
37
  static moveToOpportunity(campaign: Omit<UpdateCampaignModel, "id">, upsert?: boolean): Promise<string>;
23
38
  static createMany(campaigns: Omit<CreateCampaignModel, "id">[], upsert?: boolean): Promise<{
24
39
  success: number;
@@ -20,6 +20,19 @@ export class CampaignService {
20
20
  await OpportunityService.createFromCampaign(campaign);
21
21
  return await CampaignRepository.upsert({ id, ...campaign });
22
22
  }
23
+ static async updateMetaData(campaign) {
24
+ const id = CampaignService.hashId({
25
+ distributionChain: campaign.distributionChain,
26
+ campaignId: campaign.campaignId,
27
+ });
28
+ const existingCampaign = await CampaignService.findUniqueOrThrow(campaign);
29
+ const params = existingCampaign.params;
30
+ if ("url" in params) {
31
+ params.url = campaign.url;
32
+ }
33
+ const updatedParams = JSON.stringify(params);
34
+ return await CampaignRepository.updateMetaData(id, updatedParams);
35
+ }
23
36
  static async moveToOpportunity(campaign, upsert = false) {
24
37
  const id = CampaignService.hashId({
25
38
  distributionChain: campaign.distributionChain,
@@ -61,7 +74,7 @@ export class CampaignService {
61
74
  // Create new opportunity
62
75
  await OpportunityService.createFromCampaign(updatedCampaign, upsert);
63
76
  // Move campaign to new opportunity
64
- await CampaignRepository.update(id, { id, ...updatedCampaignData });
77
+ await CampaignRepository.updateOpportunity(id, { id, ...updatedCampaignData });
65
78
  // Update new opportunity with campaign
66
79
  // await OpportunityService.recreate(opportunityId);
67
80
  // Remov (update) campaign from old opportunity
@@ -1,12 +1,12 @@
1
1
  import { type AprRecord } from "../apr/apr.model";
2
+ import { type Campaign } from "../campaign/campaign.model";
2
3
  import type { Resource } from "../prisma";
3
4
  import { type Protocol, type ProtocolId } from "../protocol/protocol.model";
4
- import { type DailyRewardsRecord } from "../reward";
5
+ import { type DailyRewardsRecord } from "../reward/reward.model";
5
6
  import { type Token } from "../token/token.model";
6
7
  import { type TvlRecord } from "../tvl/tvl.model";
7
8
  import { CampaignType, OpportunityAction } from "../../../../database/api/.generated";
8
9
  import type { ChainId } from "@sdk";
9
- import { type Campaign } from "../campaign";
10
10
  import { type Chain } from "../chain/chain.model";
11
11
  import type { OpportunityRepository } from "./opportunity.repository";
12
12
  /**