feat: getTickers method was updated

This commit is contained in:
Mikhail Gladchenko
2024-04-25 14:07:48 +01:00
parent 54e0ab8e76
commit ffe714d4b2
3 changed files with 10 additions and 5 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@orionprotocol/sdk",
"version": "0.20.79-rc11",
"version": "0.20.79-rc12",
"description": "Orion Protocol SDK",
"main": "./lib/index.cjs",
"module": "./lib/index.js",

View File

@@ -46,9 +46,10 @@ export class Frontage {
sortType,
offset,
limit,
}: { category: TickersCategories } & TickersBaseSearchParams) => {
tickers,
}: { category: TickersCategories, tickers?: string } & TickersBaseSearchParams) => {
const queryParams = [
`category=${encodeURIComponent(category)}`,
category === 'FAVORITES' && tickers !== undefined ? `tickers=${encodeURIComponent(tickers)}` : `category=${encodeURIComponent(category)}`,
currentNetwork !== undefined ? `&currentNetwork=${encodeURIComponent(currentNetwork).toUpperCase()}` : '',
targetNetwork !== undefined ? `&targetNetwork=${encodeURIComponent(targetNetwork).toUpperCase()}` : '',
sortBy !== undefined ? `&sortBy=${encodeURIComponent(sortBy)}` : '',
@@ -57,8 +58,12 @@ export class Frontage {
limit !== undefined ? `&limit=${limit}` : '',
].filter(Boolean).join('&');
const url = category === 'FAVORITES' && tickers !== undefined
? `${this.apiUrl}/api/v1/tickers/get/favourites?${queryParams}`
: `${this.apiUrl}/api/v1/tickers/get/category?${queryParams}`;
return fetchWithValidation(
`${this.apiUrl}/api/v1/tickers/get/category?${queryParams}`,
url,
tickersSchema
);
};

View File

@@ -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' | 'NATIVE' | 'ALTS';
export type TickersCategories = 'FAVORITES' | 'USD' | 'ORN' | 'NATIVE' | 'ALTS';
export type TickersSortBy = 'PRICE' | 'CHANGE' | 'VOLUME';