diff --git a/package.json b/package.json index bc32648..0960beb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@orionprotocol/sdk", - "version": "0.20.79-rc7", + "version": "0.20.79-rc8", "description": "Orion Protocol SDK", "main": "./lib/index.cjs", "module": "./lib/index.js", diff --git a/src/services/Frontage/index.ts b/src/services/Frontage/index.ts index 6217b85..edc82c1 100644 --- a/src/services/Frontage/index.ts +++ b/src/services/Frontage/index.ts @@ -10,6 +10,7 @@ export class Frontage { this.searchTickers = this.searchTickers.bind(this); this.getTickers = this.getTickers.bind(this); + this.getFavorites = this.getFavorites.bind(this); } searchTickers = ({ @@ -57,7 +58,32 @@ export class Frontage { ].filter(Boolean).join('&'); return fetchWithValidation( - `${this.apiUrl}/api/v1/tickers/get?${queryParams}`, + `${this.apiUrl}/api/v1/tickers/get/category?${queryParams}`, + tickersSchema + ); + }; + + getFavorites = ({ + tickers, + currentNetwork, + targetNetwork, + sortBy, + sortType, + offset, + limit, + }: { tickers: string } & TickersBaseSearchParams) => { + const queryParams = [ + `tickers=${encodeURIComponent(tickers)}`, + currentNetwork !== undefined ? `¤tNetwork=${encodeURIComponent(currentNetwork).toUpperCase()}` : '', + targetNetwork !== undefined ? `&targetNetwork=${encodeURIComponent(targetNetwork).toUpperCase()}` : '', + sortBy !== undefined ? `&sortBy=${encodeURIComponent(sortBy)}` : '', + sortType !== undefined ? `&sortType=${encodeURIComponent(sortType)}` : '', + offset !== undefined ? `&offset=${offset}` : '', + limit !== undefined ? `&limit=${limit}` : '', + ].filter(Boolean).join('&'); + + return fetchWithValidation( + `${this.apiUrl}/api/v1/tickers/get/favourites?${queryParams}`, tickersSchema ); }; diff --git a/src/services/Frontage/schemas/tickers-schema.ts b/src/services/Frontage/schemas/tickers-schema.ts index 46f894f..a55410a 100644 --- a/src/services/Frontage/schemas/tickers-schema.ts +++ b/src/services/Frontage/schemas/tickers-schema.ts @@ -1,9 +1,11 @@ import { z } from 'zod'; -export const tickersSchema = z.array(z.object({ +export const tickerSchema = z.object({ pair: z.string(), volume24: z.number(), change24: z.number(), lastPrice: z.number(), networks: z.array(z.string()), -})); +}); + +export const tickersSchema = z.array(tickerSchema); diff --git a/src/types.ts b/src/types.ts index 7cf26f1..c877620 100644 --- a/src/types.ts +++ b/src/types.ts @@ -465,7 +465,7 @@ export type OrderSource = 'TERMINAL_MARKET' | 'TERMINAL_LIMIT' | 'SWAP_UI' | 'WI // Frontage export type NetworkCode = typeof networkCodes[number]; -export type TickersCategories = 'USD' | 'ORN' | 'BNB' | 'ALTS'; +export type TickersCategories = 'USD' | 'ORN' | 'NATIVE' | 'ALTS'; export type TickersSortBy = 'PRICE' | 'CHANGE' | 'VOLUME';