@merkl/api 0.18.4 → 0.18.6

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.
@@ -1605,6 +1605,7 @@ declare const eden: {
1605
1605
  verified?: boolean | undefined;
1606
1606
  isNative?: boolean | undefined;
1607
1607
  test?: boolean | undefined;
1608
+ missingIcons?: boolean | undefined;
1608
1609
  };
1609
1610
  fetch?: RequestInit | undefined;
1610
1611
  }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
@@ -1664,18 +1665,21 @@ declare const eden: {
1664
1665
  verified?: boolean | undefined;
1665
1666
  isNative?: boolean | undefined;
1666
1667
  test?: boolean | undefined;
1668
+ missingIcons?: boolean | undefined;
1667
1669
  };
1668
1670
  fetch?: RequestInit | undefined;
1669
1671
  }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
1670
1672
  200: number;
1671
1673
  }>>;
1672
1674
  };
1673
- sync: {
1674
- get: (options?: {
1675
- headers?: Record<string, unknown> | undefined;
1675
+ icons: {
1676
+ post: (body: unknown, options: {
1677
+ headers: {
1678
+ authorization: string;
1679
+ };
1676
1680
  query?: Record<string, unknown> | undefined;
1677
1681
  fetch?: RequestInit | undefined;
1678
- } | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
1682
+ }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
1679
1683
  200: void;
1680
1684
  }>>;
1681
1685
  };
@@ -5060,6 +5064,7 @@ declare const eden: {
5060
5064
  verified?: boolean | undefined;
5061
5065
  isNative?: boolean | undefined;
5062
5066
  test?: boolean | undefined;
5067
+ missingIcons?: boolean | undefined;
5063
5068
  };
5064
5069
  fetch?: RequestInit | undefined;
5065
5070
  }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
@@ -5119,18 +5124,21 @@ declare const eden: {
5119
5124
  verified?: boolean | undefined;
5120
5125
  isNative?: boolean | undefined;
5121
5126
  test?: boolean | undefined;
5127
+ missingIcons?: boolean | undefined;
5122
5128
  };
5123
5129
  fetch?: RequestInit | undefined;
5124
5130
  }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
5125
5131
  200: number;
5126
5132
  }>>;
5127
5133
  };
5128
- sync: {
5129
- get: (options?: {
5130
- headers?: Record<string, unknown> | undefined;
5134
+ icons: {
5135
+ post: (body: unknown, options: {
5136
+ headers: {
5137
+ authorization: string;
5138
+ };
5131
5139
  query?: Record<string, unknown> | undefined;
5132
5140
  fetch?: RequestInit | undefined;
5133
- } | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
5141
+ }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
5134
5142
  200: void;
5135
5143
  }>>;
5136
5144
  };
@@ -9410,6 +9418,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
9410
9418
  verified?: boolean | undefined;
9411
9419
  isNative?: boolean | undefined;
9412
9420
  test?: boolean | undefined;
9421
+ missingIcons?: boolean | undefined;
9413
9422
  };
9414
9423
  headers: unknown;
9415
9424
  response: {
@@ -9445,6 +9454,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
9445
9454
  verified?: boolean | undefined;
9446
9455
  isNative?: boolean | undefined;
9447
9456
  test?: boolean | undefined;
9457
+ missingIcons?: boolean | undefined;
9448
9458
  };
9449
9459
  headers: unknown;
9450
9460
  response: {
@@ -9520,12 +9530,14 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
9520
9530
  };
9521
9531
  };
9522
9532
  } & {
9523
- sync: {
9524
- get: {
9533
+ icons: {
9534
+ post: {
9525
9535
  body: unknown;
9526
9536
  params: {};
9527
9537
  query: unknown;
9528
- headers: unknown;
9538
+ headers: {
9539
+ authorization: string;
9540
+ };
9529
9541
  response: {
9530
9542
  200: void;
9531
9543
  };
@@ -14268,6 +14280,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
14268
14280
  verified?: boolean | undefined;
14269
14281
  isNative?: boolean | undefined;
14270
14282
  test?: boolean | undefined;
14283
+ missingIcons?: boolean | undefined;
14271
14284
  };
14272
14285
  fetch?: RequestInit | undefined;
14273
14286
  }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
@@ -14327,18 +14340,21 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
14327
14340
  verified?: boolean | undefined;
14328
14341
  isNative?: boolean | undefined;
14329
14342
  test?: boolean | undefined;
14343
+ missingIcons?: boolean | undefined;
14330
14344
  };
14331
14345
  fetch?: RequestInit | undefined;
14332
14346
  }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
14333
14347
  200: number;
14334
14348
  }>>;
14335
14349
  };
14336
- sync: {
14337
- get: (options?: {
14338
- headers?: Record<string, unknown> | undefined;
14350
+ icons: {
14351
+ post: (body: unknown, options: {
14352
+ headers: {
14353
+ authorization: string;
14354
+ };
14339
14355
  query?: Record<string, unknown> | undefined;
14340
14356
  fetch?: RequestInit | undefined;
14341
- } | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
14357
+ }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
14342
14358
  200: void;
14343
14359
  }>>;
14344
14360
  };
@@ -17723,6 +17739,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
17723
17739
  verified?: boolean | undefined;
17724
17740
  isNative?: boolean | undefined;
17725
17741
  test?: boolean | undefined;
17742
+ missingIcons?: boolean | undefined;
17726
17743
  };
17727
17744
  fetch?: RequestInit | undefined;
17728
17745
  }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
@@ -17782,18 +17799,21 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
17782
17799
  verified?: boolean | undefined;
17783
17800
  isNative?: boolean | undefined;
17784
17801
  test?: boolean | undefined;
17802
+ missingIcons?: boolean | undefined;
17785
17803
  };
17786
17804
  fetch?: RequestInit | undefined;
17787
17805
  }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
17788
17806
  200: number;
17789
17807
  }>>;
17790
17808
  };
17791
- sync: {
17792
- get: (options?: {
17793
- headers?: Record<string, unknown> | undefined;
17809
+ icons: {
17810
+ post: (body: unknown, options: {
17811
+ headers: {
17812
+ authorization: string;
17813
+ };
17794
17814
  query?: Record<string, unknown> | undefined;
17795
17815
  fetch?: RequestInit | undefined;
17796
- } | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
17816
+ }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
17797
17817
  200: void;
17798
17818
  }>>;
17799
17819
  };
@@ -1826,6 +1826,7 @@ declare const app: Elysia<"", false, {
1826
1826
  verified?: boolean | undefined;
1827
1827
  isNative?: boolean | undefined;
1828
1828
  test?: boolean | undefined;
1829
+ missingIcons?: boolean | undefined;
1829
1830
  };
1830
1831
  headers: unknown;
1831
1832
  response: {
@@ -1861,6 +1862,7 @@ declare const app: Elysia<"", false, {
1861
1862
  verified?: boolean | undefined;
1862
1863
  isNative?: boolean | undefined;
1863
1864
  test?: boolean | undefined;
1865
+ missingIcons?: boolean | undefined;
1864
1866
  };
1865
1867
  headers: unknown;
1866
1868
  response: {
@@ -1936,12 +1938,14 @@ declare const app: Elysia<"", false, {
1936
1938
  };
1937
1939
  };
1938
1940
  } & {
1939
- sync: {
1940
- get: {
1941
+ icons: {
1942
+ post: {
1941
1943
  body: unknown;
1942
1944
  params: {};
1943
1945
  query: unknown;
1944
- headers: unknown;
1946
+ headers: {
1947
+ authorization: string;
1948
+ };
1945
1949
  response: {
1946
1950
  200: void;
1947
1951
  };
@@ -16,7 +16,7 @@ export const PriceController = new Elysia({ prefix: "/prices", detail: { tags: [
16
16
  .group("/sources", app => {
17
17
  return (app
18
18
  // ─── Get All Price Sources ───────────────────
19
- .get("/", async () => await PriceService.getManyPriceSources())
19
+ .get("/", async () => await PriceService.findManyPriceSources({}))
20
20
  // ─── Get Price Source By Token Symbol ────────
21
21
  .get("/symbol/:symbol", async ({ params }) => await PriceService.getPriceSourceBySymbol(params.symbol), {
22
22
  params: PriceSourceIdentifier,
@@ -1,3 +1,4 @@
1
+ import type { PriceSourceMethod } from "@db/api";
1
2
  import type { CreatePriceSourceModel, UpdatePriceSourceModel } from ".";
2
3
  export declare class PriceRepository {
3
4
  static findBySymbolOrThrow(symbol: string): Promise<{
@@ -6,7 +7,9 @@ export declare class PriceRepository {
6
7
  id: number;
7
8
  args: import("database/api/.generated/runtime/library").JsonValue | null;
8
9
  }>;
9
- static findMany(): Promise<{
10
+ static findManyPriceSources(query: {
11
+ method?: PriceSourceMethod;
12
+ }): Promise<{
10
13
  symbol: string;
11
14
  method: import("@db/api").$Enums.PriceSourceMethod;
12
15
  id: number;
@@ -3,8 +3,12 @@ export class PriceRepository {
3
3
  static async findBySymbolOrThrow(symbol) {
4
4
  return await apiDbClient.priceSource.findUniqueOrThrow({ where: { symbol } });
5
5
  }
6
- static async findMany() {
7
- return await apiDbClient.priceSource.findMany();
6
+ static async findManyPriceSources(query) {
7
+ return await apiDbClient.priceSource.findMany({
8
+ where: {
9
+ method: query.method ?? undefined,
10
+ },
11
+ });
8
12
  }
9
13
  static async create(priceSource) {
10
14
  return await apiDbClient.priceSource.create({ data: priceSource });
@@ -1,3 +1,4 @@
1
+ import { PriceSourceMethod } from "@db/api";
1
2
  import type { CreatePriceSourceModel, UpdatePriceSourceModel } from ".";
2
3
  export declare class PriceService {
3
4
  static findMany(): Promise<{
@@ -15,7 +16,9 @@ export declare class PriceService {
15
16
  id: number;
16
17
  args: import("database/api/.generated/runtime/library").JsonValue | null;
17
18
  }>;
18
- static getManyPriceSources(): Promise<{
19
+ static findManyPriceSources(query: {
20
+ method?: PriceSourceMethod;
21
+ }): Promise<{
19
22
  symbol: string;
20
23
  method: import("@db/api").$Enums.PriceSourceMethod;
21
24
  id: number;
@@ -28,8 +28,8 @@ export class PriceService {
28
28
  static async getPriceSourceBySymbol(symbol) {
29
29
  return await PriceRepository.findBySymbolOrThrow(symbol);
30
30
  }
31
- static async getManyPriceSources() {
32
- return await PriceRepository.findMany();
31
+ static async findManyPriceSources(query) {
32
+ return await PriceRepository.findManyPriceSources(query);
33
33
  }
34
34
  static async createPriceSource(priceSource) {
35
35
  const created = await PriceRepository.create(priceSource);
@@ -1696,6 +1696,7 @@ export declare const v4: Elysia<"/v4", false, {
1696
1696
  verified?: boolean | undefined;
1697
1697
  isNative?: boolean | undefined;
1698
1698
  test?: boolean | undefined;
1699
+ missingIcons?: boolean | undefined;
1699
1700
  };
1700
1701
  headers: unknown;
1701
1702
  response: {
@@ -1731,6 +1732,7 @@ export declare const v4: Elysia<"/v4", false, {
1731
1732
  verified?: boolean | undefined;
1732
1733
  isNative?: boolean | undefined;
1733
1734
  test?: boolean | undefined;
1735
+ missingIcons?: boolean | undefined;
1734
1736
  };
1735
1737
  headers: unknown;
1736
1738
  response: {
@@ -1806,12 +1808,14 @@ export declare const v4: Elysia<"/v4", false, {
1806
1808
  };
1807
1809
  };
1808
1810
  } & {
1809
- sync: {
1810
- get: {
1811
+ icons: {
1812
+ post: {
1811
1813
  body: unknown;
1812
1814
  params: {};
1813
1815
  query: unknown;
1814
- headers: unknown;
1816
+ headers: {
1817
+ authorization: string;
1818
+ };
1815
1819
  response: {
1816
1820
  200: void;
1817
1821
  };
@@ -151,6 +151,7 @@ export declare const TokenController: Elysia<"/tokens", false, {
151
151
  verified?: boolean | undefined;
152
152
  isNative?: boolean | undefined;
153
153
  test?: boolean | undefined;
154
+ missingIcons?: boolean | undefined;
154
155
  };
155
156
  headers: unknown;
156
157
  response: {
@@ -186,6 +187,7 @@ export declare const TokenController: Elysia<"/tokens", false, {
186
187
  verified?: boolean | undefined;
187
188
  isNative?: boolean | undefined;
188
189
  test?: boolean | undefined;
190
+ missingIcons?: boolean | undefined;
189
191
  };
190
192
  headers: unknown;
191
193
  response: {
@@ -261,12 +263,14 @@ export declare const TokenController: Elysia<"/tokens", false, {
261
263
  };
262
264
  };
263
265
  } & {
264
- sync: {
265
- get: {
266
+ icons: {
267
+ post: {
266
268
  body: unknown;
267
269
  params: {};
268
270
  query: unknown;
269
- headers: unknown;
271
+ headers: {
272
+ authorization: string;
273
+ };
270
274
  response: {
271
275
  200: void;
272
276
  };
@@ -93,7 +93,11 @@ export const TokenController = new Elysia({ prefix: "/tokens", detail: { tags: [
93
93
  beforeHandle: BackOfficeGuard,
94
94
  detail: { hide: true },
95
95
  })
96
- .get("/sync", async () => await TokenService.fillTokenAndIconsFromTokenList(), { detail: { hide: true } })
96
+ .post("/icons", async () => await TokenService.tryToFillWithCoingeckoIcons(), {
97
+ headers: AuthorizationHeadersDto,
98
+ beforeHandle: BackOfficeGuard,
99
+ detail: { hide: true },
100
+ })
97
101
  .group("/webhooks", app => {
98
102
  return app.post("/notion", async ({ body }) => TokenService.notionWebhook(body), {
99
103
  body: NotionWebhookDto,
@@ -41,6 +41,7 @@ export declare const GetTokenQueryDto: import("@sinclair/typebox").TObject<{
41
41
  name: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
42
42
  verified: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
43
43
  test: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
44
+ missingIcons: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
44
45
  }>;
45
46
  export declare const TokenDto: import("@sinclair/typebox").TObject<{
46
47
  address: import("@sinclair/typebox").TString;
@@ -30,6 +30,7 @@ export const GetTokenQueryDto = t.Object({
30
30
  name: t.Optional(t.String()),
31
31
  verified: t.Optional(t.Boolean()),
32
32
  test: t.Optional(t.Boolean()),
33
+ missingIcons: t.Optional(t.Boolean()),
33
34
  });
34
35
  export const TokenDto = t.Object({
35
36
  address: t.String(),
@@ -3,34 +3,6 @@ import { executeSimple } from "@/utils/execute";
3
3
  import { apiDbClient } from "@/utils/prisma";
4
4
  import { NETWORK_LABELS } from "@sdk";
5
5
  export class TokenRepository {
6
- /**
7
- * Fetch token metadata from onchain
8
- * @param chainId
9
- * @param address
10
- * @returns
11
- */
12
- static async getTokenInfo(token) {
13
- //TODO: replace with onchain module
14
- const calls = getTokenInfo(token.address);
15
- //TODO: replace with onchain module
16
- return executeSimple(token.chainId, calls);
17
- }
18
- /**
19
- * Read token from database
20
- * @param chainId
21
- * @param address
22
- */
23
- static async findUnique(id) {
24
- return (await apiDbClient.token.findUnique({ where: { id } })) ?? undefined;
25
- }
26
- /**
27
- * Read token from database
28
- * @param chainId
29
- * @param address
30
- */
31
- static async findUniqueOrThrow(id) {
32
- return await apiDbClient.token.findUniqueOrThrow({ where: { id } });
33
- }
34
6
  static #transformQueryToPrismaFilters(query) {
35
7
  const ids = query.id ? query.id.map(id => ({ id })) : [];
36
8
  return {
@@ -58,9 +30,38 @@ export class TokenRepository {
58
30
  name: query.name ? { contains: query.name, mode: "insensitive" } : undefined,
59
31
  verified: query.verified ? { equals: query.verified } : undefined,
60
32
  isTest: query.test ? { equals: query.test } : undefined,
33
+ icon: query.missingIcons ? { equals: "" } : undefined,
61
34
  },
62
35
  };
63
36
  }
37
+ /**
38
+ * Fetch token metadata from onchain
39
+ * @param chainId
40
+ * @param address
41
+ * @returns
42
+ */
43
+ static async getTokenInfo(token) {
44
+ //TODO: replace with onchain module
45
+ const calls = getTokenInfo(token.address);
46
+ //TODO: replace with onchain module
47
+ return executeSimple(token.chainId, calls);
48
+ }
49
+ /**
50
+ * Read token from database
51
+ * @param chainId
52
+ * @param address
53
+ */
54
+ static async findUnique(id) {
55
+ return (await apiDbClient.token.findUnique({ where: { id } })) ?? undefined;
56
+ }
57
+ /**
58
+ * Read token from database
59
+ * @param chainId
60
+ * @param address
61
+ */
62
+ static async findUniqueOrThrow(id) {
63
+ return await apiDbClient.token.findUniqueOrThrow({ where: { id } });
64
+ }
64
65
  /**
65
66
  * Read token from database by its symbol
66
67
  * @param symbol
@@ -54,6 +54,7 @@ export declare abstract class TokenService {
54
54
  balance: bigint;
55
55
  })[]>;
56
56
  static fetchOnChain(token: TokenModel): Promise<Omit<Token["model"], "id">>;
57
+ static tryToFillWithCoingeckoIcons(): Promise<void>;
57
58
  static fetchManyOnChain(chainId: ChainId, addresses: string[]): Promise<{
58
59
  [address: string]: Omit<{
59
60
  symbol: string;
@@ -91,11 +92,6 @@ export declare abstract class TokenService {
91
92
  * @param excludeAddresses to not update symbols that defined using addresses
92
93
  */
93
94
  static updatePrices(pricer: Pricer): Promise<void>;
94
- /**
95
- * Get all tokens from https://github.com/AngleProtocol/angle-token-list and override icons from it
96
- * TODO: use the bucket
97
- */
98
- static fillTokenAndIconsFromTokenList(): Promise<void>;
99
95
  /**
100
96
  * Create token on database
101
97
  * @param chainId
@@ -254,4 +250,10 @@ export declare abstract class TokenService {
254
250
  isNative: boolean;
255
251
  price: number | null;
256
252
  }>;
253
+ /**
254
+ * Get all tokens from https://github.com/AngleProtocol/angle-token-list and override icons from it
255
+ * TODO: use the bucket
256
+ * @deprecated Should be useless now that the token list is not used anymore
257
+ */
258
+ static fillTokenAndIconsFromTokenList(): Promise<void>;
257
259
  }