@merkl/api 0.20.103 → 0.20.105

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.
@@ -1875,6 +1875,74 @@ declare const eden: {
1875
1875
  200: number;
1876
1876
  }>>;
1877
1877
  };
1878
+ webhooks: {
1879
+ notion: {
1880
+ post: (body: {
1881
+ data: {
1882
+ properties: {
1883
+ id: {
1884
+ title: {
1885
+ text: {
1886
+ content: string;
1887
+ };
1888
+ }[];
1889
+ };
1890
+ name: {
1891
+ rich_text: {
1892
+ text: {
1893
+ content: string;
1894
+ };
1895
+ }[];
1896
+ };
1897
+ url: {
1898
+ url: string;
1899
+ };
1900
+ description: {
1901
+ rich_text: {
1902
+ text: {
1903
+ content: string;
1904
+ };
1905
+ }[];
1906
+ };
1907
+ tags: {
1908
+ rich_text: {
1909
+ text: {
1910
+ content: string;
1911
+ };
1912
+ }[];
1913
+ };
1914
+ icon: {
1915
+ files: ({
1916
+ file: {
1917
+ url: string;
1918
+ };
1919
+ name: string;
1920
+ } | {
1921
+ external: {
1922
+ url: string;
1923
+ };
1924
+ })[];
1925
+ };
1926
+ };
1927
+ };
1928
+ }, options: {
1929
+ headers: {
1930
+ authorization: string;
1931
+ };
1932
+ query?: Record<string, unknown> | undefined;
1933
+ fetch?: RequestInit | undefined;
1934
+ }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
1935
+ 200: {
1936
+ id: string;
1937
+ name: string;
1938
+ url: string;
1939
+ description: string;
1940
+ tags: string[];
1941
+ icon: string;
1942
+ };
1943
+ }>>;
1944
+ };
1945
+ };
1878
1946
  };
1879
1947
  explorers: {
1880
1948
  post: (body: {
@@ -7001,9 +7069,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
7001
7069
  };
7002
7070
  };
7003
7071
  };
7004
- };
7005
- } & {
7006
- protocols: {
7072
+ } & {
7007
7073
  count: {
7008
7074
  get: {
7009
7075
  body: unknown;
@@ -7024,9 +7090,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
7024
7090
  };
7025
7091
  };
7026
7092
  };
7027
- };
7028
- } & {
7029
- protocols: {
7093
+ } & {
7030
7094
  ":id": {
7031
7095
  get: {
7032
7096
  body: unknown;
@@ -7050,9 +7114,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
7050
7114
  };
7051
7115
  };
7052
7116
  };
7053
- };
7054
- } & {
7055
- protocols: {
7117
+ } & {
7056
7118
  ":id": {
7057
7119
  patch: {
7058
7120
  body: {
@@ -7080,9 +7142,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
7080
7142
  };
7081
7143
  };
7082
7144
  };
7083
- };
7084
- } & {
7085
- protocols: {
7145
+ } & {
7086
7146
  index: {
7087
7147
  post: {
7088
7148
  body: {
@@ -7110,6 +7170,77 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
7110
7170
  };
7111
7171
  };
7112
7172
  };
7173
+ } & {
7174
+ webhooks: {
7175
+ notion: {
7176
+ post: {
7177
+ body: {
7178
+ data: {
7179
+ properties: {
7180
+ id: {
7181
+ title: {
7182
+ text: {
7183
+ content: string;
7184
+ };
7185
+ }[];
7186
+ };
7187
+ name: {
7188
+ rich_text: {
7189
+ text: {
7190
+ content: string;
7191
+ };
7192
+ }[];
7193
+ };
7194
+ url: {
7195
+ url: string;
7196
+ };
7197
+ description: {
7198
+ rich_text: {
7199
+ text: {
7200
+ content: string;
7201
+ };
7202
+ }[];
7203
+ };
7204
+ tags: {
7205
+ rich_text: {
7206
+ text: {
7207
+ content: string;
7208
+ };
7209
+ }[];
7210
+ };
7211
+ icon: {
7212
+ files: ({
7213
+ file: {
7214
+ url: string;
7215
+ };
7216
+ name: string;
7217
+ } | {
7218
+ external: {
7219
+ url: string;
7220
+ };
7221
+ })[];
7222
+ };
7223
+ };
7224
+ };
7225
+ };
7226
+ params: {};
7227
+ query: unknown;
7228
+ headers: {
7229
+ authorization: string;
7230
+ };
7231
+ response: {
7232
+ 200: {
7233
+ id: string;
7234
+ name: string;
7235
+ url: string;
7236
+ description: string;
7237
+ tags: string[];
7238
+ icon: string;
7239
+ };
7240
+ };
7241
+ };
7242
+ };
7243
+ };
7113
7244
  };
7114
7245
  };
7115
7246
  } & {
@@ -12789,6 +12920,74 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
12789
12920
  200: number;
12790
12921
  }>>;
12791
12922
  };
12923
+ webhooks: {
12924
+ notion: {
12925
+ post: (body: {
12926
+ data: {
12927
+ properties: {
12928
+ id: {
12929
+ title: {
12930
+ text: {
12931
+ content: string;
12932
+ };
12933
+ }[];
12934
+ };
12935
+ name: {
12936
+ rich_text: {
12937
+ text: {
12938
+ content: string;
12939
+ };
12940
+ }[];
12941
+ };
12942
+ url: {
12943
+ url: string;
12944
+ };
12945
+ description: {
12946
+ rich_text: {
12947
+ text: {
12948
+ content: string;
12949
+ };
12950
+ }[];
12951
+ };
12952
+ tags: {
12953
+ rich_text: {
12954
+ text: {
12955
+ content: string;
12956
+ };
12957
+ }[];
12958
+ };
12959
+ icon: {
12960
+ files: ({
12961
+ file: {
12962
+ url: string;
12963
+ };
12964
+ name: string;
12965
+ } | {
12966
+ external: {
12967
+ url: string;
12968
+ };
12969
+ })[];
12970
+ };
12971
+ };
12972
+ };
12973
+ }, options: {
12974
+ headers: {
12975
+ authorization: string;
12976
+ };
12977
+ query?: Record<string, unknown> | undefined;
12978
+ fetch?: RequestInit | undefined;
12979
+ }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
12980
+ 200: {
12981
+ id: string;
12982
+ name: string;
12983
+ url: string;
12984
+ description: string;
12985
+ tags: string[];
12986
+ icon: string;
12987
+ };
12988
+ }>>;
12989
+ };
12990
+ };
12792
12991
  };
12793
12992
  explorers: {
12794
12993
  post: (body: {
@@ -45,7 +45,7 @@ export const computeSubTypes = async (chainId, campaigns) => {
45
45
  callData: BalancerV3StablePoolInterface.encodeFunctionData("getVault"),
46
46
  target: targetToken,
47
47
  });
48
- if (calls.length !== callsPerCampaign * index)
48
+ if (calls.length !== callsPerCampaign * (index + 1))
49
49
  throw new Error("computeSubTypes: calls.length !== callsPerCampaign * index");
50
50
  }
51
51
  const callResult = await ChainInteractionService(chainId).fetchState(calls);
@@ -67,34 +67,47 @@ export const computeSubTypes = async (chainId, campaigns) => {
67
67
  // Get erc20SubType from factory address
68
68
  try {
69
69
  const factory = decodeReturnValue(values.factory, "factory");
70
- res.push(getTypeFromFactoryAddress(factory));
71
- continue;
70
+ const type = getTypeFromFactoryAddress(factory);
71
+ if (type !== Erc20SubType.unknown) {
72
+ res.push(type);
73
+ continue;
74
+ }
72
75
  }
73
76
  catch { }
74
77
  // Get erc20SubType from owner address
75
78
  try {
76
79
  const owner = decodeReturnValue(values.owner, "owner");
77
- res.push(getTypeFromOwnerAddress(owner));
78
- continue;
80
+ const type = getTypeFromOwnerAddress(owner);
81
+ if (type !== Erc20SubType.unknown) {
82
+ res.push(type);
83
+ continue;
84
+ }
79
85
  }
80
86
  catch { }
81
87
  // Get erc20SubType from address
82
88
  try {
83
- res.push(getTypeFromAddressChain(chainId, targetToken));
84
- continue;
89
+ const type = getTypeFromAddressChain(chainId, targetToken);
90
+ if (type !== Erc20SubType.unknown) {
91
+ res.push(type);
92
+ continue;
93
+ }
85
94
  }
86
95
  catch { }
87
96
  // Get erc20SubType for enzyme (factory is replaced by dispatcher)
88
97
  try {
89
98
  const factory = decodeReturnValue(values.creator, "getCreator");
90
- res.push(getTypeFromFactoryAddress(factory));
91
- continue;
99
+ const type = getTypeFromFactoryAddress(factory);
100
+ if (type !== Erc20SubType.unknown) {
101
+ res.push(type);
102
+ continue;
103
+ }
92
104
  }
93
105
  catch { }
94
106
  // Get erc20SubType for morpho
95
107
  try {
96
108
  decodeReturnValue(values.metamorpho, "MORPHO");
97
109
  res.push(Erc20SubType.metamorpho);
110
+ continue;
98
111
  }
99
112
  catch { }
100
113
  // Starting from this point, assume the name is working
@@ -104,11 +117,13 @@ export const computeSubTypes = async (chainId, campaigns) => {
104
117
  try {
105
118
  decodeReturnValue(values.poolId, "getPoolId");
106
119
  res.push(Erc20SubType.balancerPool);
120
+ continue;
107
121
  }
108
122
  catch { }
109
123
  try {
110
124
  decodeReturnValue(values.vault, "getVault");
111
125
  res.push(Erc20SubType.balancerPool);
126
+ continue;
112
127
  }
113
128
  catch { }
114
129
  // Get erc20SubType by parsing information from the erc20 name
@@ -124,5 +139,5 @@ export const computeSubTypes = async (chainId, campaigns) => {
124
139
  }
125
140
  if (res.length !== campaigns.length)
126
141
  throw new Error("computeSubTypes: res.length !== campaigns.length");
127
- return [];
142
+ return res;
128
143
  };
@@ -3,7 +3,11 @@ import { computeSubTypes } from "./computeSubTypes";
3
3
  import { erc20SubTypeTVLBuilderFactory } from "./factory";
4
4
  export class Erc20CampaignTVLBuilder {
5
5
  async build(chainId, campaigns) {
6
+ console.log("START");
6
7
  const subTypes = await computeSubTypes(chainId, campaigns);
8
+ console.log(subTypes);
9
+ const dynamicDataList = await new Erc20DynamicData().build(chainId, campaigns);
10
+ console.log(dynamicDataList.map(d => d.typeInfo.type));
7
11
  let tvls = [];
8
12
  for (const subtype of new Set(subTypes)) {
9
13
  const builder = erc20SubTypeTVLBuilderFactory(subtype);
@@ -11,6 +15,7 @@ export class Erc20CampaignTVLBuilder {
11
15
  tvls = tvls.concat(await builder.build(chainId, campaigns.filter((_campaign, index) => subTypes[index] === subtype)));
12
16
  }
13
17
  else {
18
+ console.log(`building TVLs for subtype ${subtype}`);
14
19
  // @deprecated In case we don't have the new builder, use the old erc20 dynamic data
15
20
  const dynamicDataList = await new Erc20DynamicData().build(chainId, campaigns);
16
21
  for (const [index, dynamicData] of dynamicDataList.entries()) {
@@ -2153,9 +2153,7 @@ declare const app: Elysia<"", false, {
2153
2153
  };
2154
2154
  };
2155
2155
  };
2156
- };
2157
- } & {
2158
- protocols: {
2156
+ } & {
2159
2157
  count: {
2160
2158
  get: {
2161
2159
  body: unknown;
@@ -2176,9 +2174,7 @@ declare const app: Elysia<"", false, {
2176
2174
  };
2177
2175
  };
2178
2176
  };
2179
- };
2180
- } & {
2181
- protocols: {
2177
+ } & {
2182
2178
  ":id": {
2183
2179
  get: {
2184
2180
  body: unknown;
@@ -2202,9 +2198,7 @@ declare const app: Elysia<"", false, {
2202
2198
  };
2203
2199
  };
2204
2200
  };
2205
- };
2206
- } & {
2207
- protocols: {
2201
+ } & {
2208
2202
  ":id": {
2209
2203
  patch: {
2210
2204
  body: {
@@ -2232,9 +2226,7 @@ declare const app: Elysia<"", false, {
2232
2226
  };
2233
2227
  };
2234
2228
  };
2235
- };
2236
- } & {
2237
- protocols: {
2229
+ } & {
2238
2230
  index: {
2239
2231
  post: {
2240
2232
  body: {
@@ -2262,6 +2254,77 @@ declare const app: Elysia<"", false, {
2262
2254
  };
2263
2255
  };
2264
2256
  };
2257
+ } & {
2258
+ webhooks: {
2259
+ notion: {
2260
+ post: {
2261
+ body: {
2262
+ data: {
2263
+ properties: {
2264
+ id: {
2265
+ title: {
2266
+ text: {
2267
+ content: string;
2268
+ };
2269
+ }[];
2270
+ };
2271
+ name: {
2272
+ rich_text: {
2273
+ text: {
2274
+ content: string;
2275
+ };
2276
+ }[];
2277
+ };
2278
+ url: {
2279
+ url: string;
2280
+ };
2281
+ description: {
2282
+ rich_text: {
2283
+ text: {
2284
+ content: string;
2285
+ };
2286
+ }[];
2287
+ };
2288
+ tags: {
2289
+ rich_text: {
2290
+ text: {
2291
+ content: string;
2292
+ };
2293
+ }[];
2294
+ };
2295
+ icon: {
2296
+ files: ({
2297
+ file: {
2298
+ url: string;
2299
+ };
2300
+ name: string;
2301
+ } | {
2302
+ external: {
2303
+ url: string;
2304
+ };
2305
+ })[];
2306
+ };
2307
+ };
2308
+ };
2309
+ };
2310
+ params: {};
2311
+ query: unknown;
2312
+ headers: {
2313
+ authorization: string;
2314
+ };
2315
+ response: {
2316
+ 200: {
2317
+ id: string;
2318
+ name: string;
2319
+ url: string;
2320
+ description: string;
2321
+ tags: string[];
2322
+ icon: string;
2323
+ };
2324
+ };
2325
+ };
2326
+ };
2327
+ };
2265
2328
  };
2266
2329
  };
2267
2330
  } & {
@@ -40,11 +40,14 @@ const main = async () => {
40
40
  const futureOpportunities = await CampaignService.getFutureCampaigns({ computeChainId: chainId });
41
41
  const liveOpportunityIds = (await CampaignService.getLiveCampaigns({ computeChainId: chainId })).map(c => c.Opportunity.id);
42
42
  const idToUpdate = futureOpportunities
43
- ?.filter(c => !liveOpportunityIds.includes(c.id) && c.Opportunity.status !== "SOON")
43
+ ?.filter(c => !liveOpportunityIds.includes(c.Opportunity.id) && c.Opportunity.status !== "SOON")
44
44
  .map(c => c.Opportunity.id);
45
45
  if (idToUpdate.length > 0) {
46
46
  await OpportunityService.updateMany(idToUpdate, { status: "SOON" });
47
- logger.info(`updated ${idToUpdate.length} opportunities to SOON status.`);
47
+ if (idToUpdate.length === 1)
48
+ logger.info(`updated opportunity ${idToUpdate[0]} to SOON status.`);
49
+ else
50
+ logger.info(`updated ${idToUpdate.length} opportunities to SOON status.`);
48
51
  }
49
52
  // 4. Update the status of the opportunities associated to live campaigns
50
53
  await OpportunityService.updateMany(liveOpportunityIds, { status: "LIVE" });
@@ -3,6 +3,7 @@ export declare class BucketService {
3
3
  #private;
4
4
  defaultUploadOptions: UploadOptions<unknown>;
5
5
  constructor(bucket: string, projectId: string);
6
+ getBucketName(): string;
6
7
  pushArray<T>(filename: string, arr: T[], options?: UploadOptions<T>): Promise<number>;
7
8
  push(filename: string, text: string, options?: Omit<UploadOptions<never>, "transform" | "separator">): Promise<number>;
8
9
  pushRaw(filename: string, data: Uint8Array, options?: Omit<UploadOptions<never>, "transform" | "separator">): Promise<number>;
@@ -7,6 +7,7 @@ export class BucketService {
7
7
  #gcsBucket;
8
8
  #encoder;
9
9
  #decoder;
10
+ #bucketName;
10
11
  // ─── Default Options ─────────────────────────────────────────────────────────
11
12
  defaultUploadOptions = {
12
13
  type: "text/plain",
@@ -27,6 +28,10 @@ export class BucketService {
27
28
  this.#gcsBucket = new Storage({ projectId }).bucket(bucket);
28
29
  this.#encoder = new TextEncoder();
29
30
  this.#decoder = new TextDecoder();
31
+ this.#bucketName = bucket;
32
+ }
33
+ getBucketName() {
34
+ return this.#bucketName;
30
35
  }
31
36
  // ─── Process And Upload Chunks Of Data ───────────────────────────────
32
37
  async pushArray(filename, arr, options) {
@@ -1,5 +1,5 @@
1
1
  import type { BucketService } from "../bucket/bucket.service";
2
2
  import type { FileMetadata } from "./icon.model";
3
3
  export declare abstract class IconService {
4
- static pullPush(url: string, bucket: BucketService, metadata?: FileMetadata): Promise<number>;
4
+ static pullPush(url: string, bucket: BucketService, metadata?: FileMetadata): Promise<string>;
5
5
  }
@@ -5,11 +5,12 @@ export class IconService {
5
5
  const mimeType = iconFile.headers.get("content-type");
6
6
  const extension = metadata?.extension ? metadata.extension : mimeType.split("/")[1].split("+")[0];
7
7
  const byteArray = await iconFile.bytes();
8
- return await bucket.pushRaw(`${filename}.${extension}`, byteArray, {
8
+ await bucket.pushRaw(`${filename}.${extension}`, byteArray, {
9
9
  type: mimeType,
10
10
  isPublic: true,
11
11
  compression: true,
12
12
  overwrite: true,
13
13
  });
14
+ return `${process.env.GCS_ENDPOINT}/${bucket.getBucketName()}/${filename}.${extension}`;
14
15
  }
15
16
  }
@@ -44,9 +44,7 @@ export declare const ProtocolController: Elysia<"/protocols", false, {
44
44
  };
45
45
  };
46
46
  };
47
- };
48
- } & {
49
- protocols: {
47
+ } & {
50
48
  count: {
51
49
  get: {
52
50
  body: unknown;
@@ -67,9 +65,7 @@ export declare const ProtocolController: Elysia<"/protocols", false, {
67
65
  };
68
66
  };
69
67
  };
70
- };
71
- } & {
72
- protocols: {
68
+ } & {
73
69
  ":id": {
74
70
  get: {
75
71
  body: unknown;
@@ -93,9 +89,7 @@ export declare const ProtocolController: Elysia<"/protocols", false, {
93
89
  };
94
90
  };
95
91
  };
96
- };
97
- } & {
98
- protocols: {
92
+ } & {
99
93
  ":id": {
100
94
  patch: {
101
95
  body: {
@@ -123,9 +117,7 @@ export declare const ProtocolController: Elysia<"/protocols", false, {
123
117
  };
124
118
  };
125
119
  };
126
- };
127
- } & {
128
- protocols: {
120
+ } & {
129
121
  index: {
130
122
  post: {
131
123
  body: {
@@ -153,6 +145,77 @@ export declare const ProtocolController: Elysia<"/protocols", false, {
153
145
  };
154
146
  };
155
147
  };
148
+ } & {
149
+ webhooks: {
150
+ notion: {
151
+ post: {
152
+ body: {
153
+ data: {
154
+ properties: {
155
+ id: {
156
+ title: {
157
+ text: {
158
+ content: string;
159
+ };
160
+ }[];
161
+ };
162
+ name: {
163
+ rich_text: {
164
+ text: {
165
+ content: string;
166
+ };
167
+ }[];
168
+ };
169
+ url: {
170
+ url: string;
171
+ };
172
+ description: {
173
+ rich_text: {
174
+ text: {
175
+ content: string;
176
+ };
177
+ }[];
178
+ };
179
+ tags: {
180
+ rich_text: {
181
+ text: {
182
+ content: string;
183
+ };
184
+ }[];
185
+ };
186
+ icon: {
187
+ files: ({
188
+ file: {
189
+ url: string;
190
+ };
191
+ name: string;
192
+ } | {
193
+ external: {
194
+ url: string;
195
+ };
196
+ })[];
197
+ };
198
+ };
199
+ };
200
+ };
201
+ params: {};
202
+ query: unknown;
203
+ headers: {
204
+ authorization: string;
205
+ };
206
+ response: {
207
+ 200: {
208
+ id: string;
209
+ name: string;
210
+ url: string;
211
+ description: string;
212
+ tags: string[];
213
+ icon: string;
214
+ };
215
+ };
216
+ };
217
+ };
218
+ };
156
219
  };
157
220
  }, {
158
221
  derive: {};